akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=1e9+7;
const int MAXN=5005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
vector<int> e[MAXN];
int sz[MAXN],f[MAXN][MAXN],g[MAXN],h[MAXN];
inline int upd(int x,int y) { return x+y>=mods?x+y-mods:x+y; }
inline void tree_dp(int x,int father)
{
	for (auto v:e[x]) if (v!=father) tree_dp(v,x);
	sz[x]=f[x][1]=1;
	for (auto v:e[x])
	{
		if (v==father) continue;
		for (int i=0;i<=sz[x]+sz[v];i++) h[i]=0;
		for (int i=1;i<=sz[x];i++)
			for (int j=0;j<=sz[v];j++) h[i+j]=upd(h[i+j],1ll*f[x][i]*f[v][j]%mods);
		for (int i=0;i<=sz[x]+sz[v];i++) f[x][i]=h[i];
		sz[x]+=sz[v];
	}
	for (int i=2;i<=sz[x];i+=2) f[x][0]=upd(f[x][0],mods-1ll*f[x][i]*g[i-1]%mods);
}
int main()
{
	int n=read();
	for (int i=1;i<n;i++)
	{
		int u=read(),v=read();
		e[u].PB(v),e[v].PB(u);
	}
	g[0]=g[1]=1;
	for (int i=2;i<=n;i++) g[i]=1ll*g[i-2]*i%mods;
	tree_dp(1,0);
	printf("%d\n",mods-f[1][0]);
	return 0;
}


Measured memory_bytes: 97152
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		String[] S = new String[H];
		for (int i = 0; i < H; i++) {
			S[i] = sc.next();
		}

		int[] x = { 0, 1, 1, 1, 0, -1, -1, -1 };
		int[] y = { 1, 1, 0, -1, -1, -1, 0, 1 };
		for (int i = 0; i < H; i++) {
			String result = "";
			for (int j = 0; j < W; j++) {
				String str = "#";
				if (!"#".equals(String.valueOf(S[i].charAt(j)))) {
					int count = 0;
					for (int k = 0; k < 8; k++) {
						int dx = j + x[k];
						int dy = i + y[k];
						if (dx < 0 || W <= dx || dy < 0 || H <= dy) {
							continue;
						}
						if ("#".equals(String.valueOf(S[dy].charAt(dx)))) {
							count++;
						}
					}
					str =  String.valueOf(count);
				}
				result += str;
			}
			System.out.println(result);
		}
	}
}


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

int cnt,head[100005],color[200005];
int read() {
	int x=0,neg=1;char ch=getchar();
	while(!isdigit(ch)) {
		if (ch=='-') neg=-1;
		ch=getchar();
	}
	while(isdigit(ch)) {
		x=x*10+(ch-'0');
		ch=getchar();
	}
	return x*neg;
}
struct node{
	int to,next,v;
}edge[200005];

void add(int u,int v,int w) {
	edge[++cnt]=(node) {v,head[u],w};
	head[u]=cnt;
}

void dfs(int u,int pre) {
	for (int i=head[u];~i;i=edge[i].next) {
		int v=edge[i].to,w=edge[i].v%2;
		if (v!=pre) {
			color[v]=(color[u]+w)%2;
			dfs(v,u);
		}
	}
}
int main() {
	memset(head,-1,sizeof(head));
	int n=read();
//	cout<<n<<endl;
	for (int i=1;i<=n-1;++i) {
		int u=read(),v=read(),w=read();
		add(u,v,w);
		add(v,u,w);
	}
	dfs(1,0);
	for (int i=1;i<=n;++i) {
		cout<<color[i]<<'\n';
	}
	return 0;
}

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

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

  int max = 0;
  int min = 1000;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;

    if (a > max) {
      max = a;
    }
    if (a < min) {
      min = a;
    }
  }

  cout << max - min << endl;

  return 0;
}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;

int main()
{
	int x, y; cin >> x >> y;

	if (x % y == 0) cout << 0 << endl;
	else cout << 1 << endl;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N = int(input())
S = list()
for i in range(N):
    S.append(input())

S.sort()
count = list()
now = 0
for i in range(N - 1):
    if S[i] != S[i + 1]:
        count.append([now, i - now + 1])
        now = i + 1
    if i + 1 == N - 1:
        count.append([now, len(S) - now])

m = max([c[1] for c in count])
for c in count:
    if c[1] == m:
        print(S[c[0]])


Measured memory_bytes: 46304
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;
typedef unsigned long long BITMASK; typedef long long ll; typedef long double ld;
#define has_bit(bit_mask, x) ((bit_mask) & (1Uint << (x)))
#define turn_on_bit(bit_mask, x) (bit_mask |= (1Uint << (x)))
#define turn_off_bit(bit_mask, x) (bit_mask &= (~(1Uint << (x))))
#define smallest_on_bit(bit_mask) (__builtin_ctzint((bit_mask) & (-(bit_mask))))
#define CLOCK_START clock_t chrono_clk_beg = clock()
#define CLOCK_END clock_t chrono_clk_end = clock(); cerr << (double(chrono_clk_end - chrono_clk_beg) / CLOCKS_PER_SEC) << " sec"
#define bug(args ...) cerr << __LINE__ << ">> ", err(new istringstream(string(#args)), args), cerr << '\n'
#define all(x) x.begin(), x.end()
#define mapfind(mp, x) (mp.find(x) != mp.end())
#define removeDuplicates(vec) sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define int ll
#define double ld
void err(istringstream *iss) {} template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) { string _name; *iss >> _name; if (_name.back()==',') _name.pop_back(); cerr << _name << " = " << _val << "; ", err(iss, args ...); }
#define MOD 1000000007

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int k, x;
    cin >> k >> x;
    k *= 500;
    if (k >= x) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/
#include <algorithm>
#include<bits/stdc++.h>
#include <ios>
#include <iterator>
using namespace std;
#define ll long long
#define f(n)  for(int i=0;i<n;i++) 
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define all(v)   v.begin(),v.end()  
void speed (){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int main() {
    speed();
ll int k,n;
cin>>k>>n;
vector<ll int> v(n);
f(n){
    cin>>v[i];
}
vector<ll int> d(n);
for(ll int i=0;i<n-1;i++){
    d[i]=v[i+1]-v[i];
}
d[n-1]=k-v[n-1]+v[0];
ll int max=*max_element(d.begin(),d.end());
ll int ind=0;
f(n){
    if(d[i]==max){
        ind=i;
        break;
    }
}
d.erase(d.begin()+ind);
ll int ans=0;
for(auto x:d){
    ans+=x;
}
cout<<ans;
    return 0;
}


Measured memory_bytes: 3328
/**
 * 線形探索
 */
fun main(args: Array<String>) {

    Main.init()

    Main.execute()
}

class Main {

    companion object {

        private lateinit var inputs: List<Int>

        private lateinit var searchLists: List<Int>

        fun init() {

            readLine()

            inputs = readLine()!!.split(" ").map { it.toInt() }

            readLine()

            searchLists = readLine()!!.split(" ").map { it.toInt() }

        }

        fun execute() {
            searchLists.forEach {
                println(if (isJust(0, 0, it)) "yes" else "no")
            }
        }

        fun isJust(index: Int, length: Int, goalValue: Int): Boolean {

            // 最後まで見た場合or長くなり過ぎた場合はfalse
            if (index == inputs.size || length > goalValue) {
                return false
            }

            if (inputs[index] + length == goalValue) {
                return true
            }

            return isJust(index + 1, length, goalValue) || isJust(index + 1, length + inputs[index], goalValue)

        }
    }
}




Measured memory_bytes: 35056
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cctype>
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include <map>
#include <set>

using namespace std;

#define REP(i,x) for(int i=0; i<(int)(x); i++)       // 0 <= i < x
#define REPS(i,x) for(int i=1; i<=(int)(x); i++)     // 0 < i <= x
#define RREP(i,x) for(int i=((int)(x)-1); i>=0; i--) // x > i >= 0
#define RREPS(i,x) for(int i=((int)(x)); i>0; i--)   // x >= i > 0
#define INF 100000000

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

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

int main(void){
	int N, A, B;
    cin >> N >> A >> B;
    cout << min(N * A, B) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){

   string s;
   cin>>s;
   ll c=0;
   for( int i=0;i<s.size();i++)
   {
       if(s[s.size()-1]=='s')
       {
           c=1;
       }
   }
   if(c)
    cout<<s<<"es"<<endl;
   else
    cout<<s<<"s"<<endl;







}

Measured memory_bytes: 3624
#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 rate[10], red;

void solve(void){
    int N;
    cin >> N;
    rep(N, i) {
        int A; cin >> A;
        if (A >= 3200) red++;
        else (rate[A/400]++);
    }
    int ans = 0;
    rep(9, e) if(rate[e]) ans++;
    cout << (ans>0?ans:(red>0)) << ' ' << ans + red << '\n';
}

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


Measured memory_bytes: 256
from collections import defaultdict
from heapq import heappush, heappop
import math
import bisect
import random

def LI(): return list(map(int, input().split()))
def I(): return int(input())
def LIM(): return list(map(lambda x:int(x) - 1, input().split()))
def LS(): return input().split()
def S(): return input()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
mod = 1000000007


m, d = LI()


cnt = 0
for i in range(1, m + 1):
    for j in range(1, d + 1):
        if j > 10 and int(str(j)[-1]) >= 2 and int(str(j)[-2]) >= 2 and int(str(j)[-1]) * int(str(j)[-2]) == i:
             cnt += 1




print(cnt)


Measured memory_bytes: 40432
N = int(input())

def divisors(n):
  divisors = set()
  for i in range(1, int(n**0.5)+1):
    if n%i == 0:
      divisors.add(n//i)
  return divisors

ans = 0
for i in divisors(N):
  if i - 1 > N//i:
    ans += i - 1
print(ans)

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

int main(void){
    int n;
    cin >> n;
    
    int res;
    for(int i = 0; i < 10; i++){
        if(n > 111*i && n <= 111*(i+1)) res = 111*(i+1);
    }
    
    cout << res << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
const int N = 200005;


int main() {

	int q;
	scanf("%d", &q);

	multiset<int> lo, hi;
	ll sum_a = 0, sum_b = 0;
	ll sum = 0;
	for(int i = 0; i < q; i++) {
		int type;
		scanf("%d", &type);
		if(type == 1) {
			int a, b;
			scanf("%d %d", &a, &b);
			sum += b;
			lo.insert(a);
			sum_a += a;
			while(!lo.empty() and !hi.empty() and *prev(lo.end()) > *hi.begin()) {
				int elem = *prev(lo.end());
				lo.erase(prev(lo.end()));
				sum_a -= elem;
				sum_b += elem;
				hi.insert(elem);
			}
			while(lo.size() >= hi.size() + 2) {
				int elem = *prev(lo.end());
				lo.erase(prev(lo.end()));
				sum_a -= elem;
				sum_b += elem;
				hi.insert(elem);
			}
			while(hi.size() > lo.size()) {
				int elem = *hi.begin();
				hi.erase(hi.begin());
				sum_a += elem;
				sum_b -= elem;
				lo.insert(elem);
			}
		}
		else {
			int x = *prev(lo.end());
			ll ans = sum;
			ans += 1LL * (int)lo.size() * x - sum_a;
			ans += sum_b - 1LL * (int)hi.size() * x;
			printf("%d %lld\n", x, ans);
		}
	}
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60; //intじゃ扱えないことに注意！
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //範囲外参照とループの初期化に注意！

int main() {
  ll N;
  cin >> N;
  vector<ll> P(N),Q(N);
  for(int i = 0; i < N; i++){
    cin >> P[i];
  }

  int ans = 0;
  ll minv = 1000000;
  for(int i = 0; i < N; i++){
    minv = min(minv, P[i]);
      if(P[i] <= minv){
        ans++;
      }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3328
import java.util.Scanner;

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

    while(input.hasNext()){
      int A = input.nextInt();
      int B = input.nextInt();

      System.out.println(Math.max(A + B, Math.max(A - B, A * B)));
    }
  }
}

Measured memory_bytes: 21844
import numpy as np
import itertools
l, r = map(int, input().split())
if r-l>=2019:
  arr = np.arange(l,l+2019,1)
else:
  arr = np.arange(l,r+1,1)
lst = []
flag = True
for i in list(itertools.combinations(arr,2)):
  a = i[0]*i[1]%2019
  if a==0:
    print(0)
    flag = False
    break
  else:
    lst.append(i[0]*i[1]%2019)
if flag:
  print(min(lst))
else:
  None

Measured memory_bytes: 157616
//標準関数をすべてインクルードする。
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

const int_least64_t INF = 10000000;

int main(){
    //cin coutを高速化
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout.tie(0);

    int n;
    cin >> n;
    vector<int> a(n, 0);
    rep(i, n) cin >> a[i];

    string res = "APPROVED";

    rep(i, n){
        if(0 == a[i] % 2)
            if(0 == a[i] % 3 || 0 == a[i] % 5){
                res = "APPROVED";
            }else{
                res = "DENIED";
                break;
            }
    }
    cout << res << endl;

    return 0;
}



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

void Rotation(char S[], int len) {
  char last = S[len-1];

  for(int i=len-2; i>=0; --i) {
    S[i+1] = S[i];
  }
  S[0] = last;

}

int main() {
  int len = 0, flag = 0;
  char S[120], T[120];

  cin >> S >> T;

  for(int i=0; S[i] != '\0'; ++i) ++len;

  for(int i=0; i<=len-1; ++i) {
    if(!strcmp(S, T)) {
      flag = 1;
      break;
    }
    Rotation(S, len);
  }

  if(flag) cout << "Yes" << "\n";
  else  cout << "No" << "\n";

  return 0;
}

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

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e17;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n;
  cin >> n;
  vector<ll> a(n+1);
  rep(i,n+1) {
    cin >> a[i];
  }
  if (a[0] >= 2) {
    cout << -1 << endl;
    return 0;
  }

  vector<ll> s(n+2); // s[i] .. sum of a[i] in [0,i).
  rep(i,n+1) {
    s[i+1] = s[i] + a[i];
  }

  vector<ll> b(n+1);
  b[0] = 1-a[0];
  for (int i = 1; i <= n; ++i) {
    b[i] = 2*(b[i-1])-a[i];
    chmin(b[i], s[n+1]-s[i+1]); // s[n+1]-s[i+1] .. sum of [i+1,n]
    if (b[i] < 0) {
      cout << -1 << endl;
      return 0;
    }
  }

  ll ans = 0;
  rep(i,n+1) {
    ans += a[i] + b[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 5552
#include <stdio.h>

void dfs(int p, int n, int G[][101], int *pT, int *d, int *f) {
  int i;
  d[p] = *pT;
  for(i = 1; i <= n; ++i) {
    if(!G[p][i]) continue;
    if(d[i] != -1) continue;
    ++(*pT);
    dfs(i,n,G,pT,d,f);
    ++(*pT);
  }
  f[p] = *pT + 1;
}

int main() {
  int n;
  int i,j,k;
  int G[101][101];
  int src, dst;
  int T, d[101], f[101];
  for(i = 0; i < 101; ++i)  {
    d[i] = -1;
    for(j = 0; j < 101; ++j) {
      if(i == 0) G[i][j] = 1;
      else G[i][j] = 0;
    }
  }

  scanf("%d", &n);
  for(i = 1; i <= n; ++i) {
    scanf("%d %d", &src, &k);
    while(k--) {
      scanf("%d", &dst);
      G[src][dst] = 1;
    }
  }

  T = 0;
  dfs(0,n,G,&T,d,f);
  for(i = 1; i <= n; ++i) {
    printf("%d %d %d\n", i, d[i], f[i]);
  }
  return 0;
}

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

int main() {
 int n;
 cin>>n;
  vector<int> a(n),b(n,0);
  long long tot=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    tot+=b[a[i]-1];
    b[a[i]-1]++;
  }
  for(int i=0;i<n;i++){
    cout<< tot-b[a[i]-1]+1<<endl;
  }
}

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

//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3", "Ofast", "unroll-loops", "fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


#define int long long
#define endl '\n'

using namespace std;

const int mod = 998244353;

int dp[3228][3228][2];

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int i, j, n, s, m;
    cin >> n >> s;
    vector < int > a(n + 1);
    for (i = 1; i <= n; i++){
        cin >> a[i];
    }
    dp[0][0][0] = 1;
    dp[0][0][1] = 1;
    int ans = 0;
    for (i = 1; i <= n; i++){
        dp[i][0][1] = i + 1;
        dp[i][0][0] = i * (i - 1) / 2;
        for (j = 1; j <= s; j++){
            dp[i][j][1] = dp[i - 1][j][1];
            dp[i][j][1] %= mod;
            if (j >= a[i]){
                dp[i][j][1] += dp[i - 1][j - a[i]][1];
                dp[i][j][1] %= mod;
            }
        }
        for (j = 1; j <= s; j++){
            dp[i][j][0] = dp[i - 1][j][0];
            dp[i][j][0] += dp[i][j][1];
            dp[i][j][0] %= mod;
        }


    }
    cout << dp[n][s][0] << endl;
    return 0;
}


Measured memory_bytes: 151808
/*
 * @Author: CucumicsMelon
 * @Date: 2018-11-02 21:31:37
 * @Last Modified by: CucumicsMelon
 * @Last Modified time: 2018-11-02 21:46:28
 */
#include <cstdio>
#include <iostream>
#include <string.h>
#include<bits/stdc++.h>
#include <string>
#include <map>
#include <queue>
#include <deque>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <stack>
#include <iomanip>
#define rep(i,n,m) for(int i=n;i<=m;++i)
#define per(i,n,m) for(int i=n;i>=m;--i)
#define mem0(a) memset(a,0,sizeof(a))
#define meminf(a) memset(a,0x3f,sizeof(a))
#define maxn 100000+50
#define inf 0x7fffffff
#define ll long long
void swap(int a,int b)
{
    int t=a;a=b;b=t;
}
using namespace std;
int nex[maxn];
void  getn(int n,char c[])
{
    int i=0,j=-1;
    nex[0]=-1;
    while(i<n)
    {
        if(c[i]==c[j]||j==-1)
        {
            i++;j++;nex[i]=j;
        }
        else j=nex[j];
    }
}
int kmp(char c1[],char c2[])
{
    int i,j=0,l1,l2;
    l1=strlen(c1);l2=strlen(c2);
    getn(l2,c2);
    rep(i,0,l1-1)
    {
        while(j&&c1[i]!=c2[j]) j=nex[j];
        if(c1[i]==c2[j]) j++;
    }
    return j;
}
int main()
{
    int n,t,a,x;
    double q,minn=inf;
    cin>>n>>t>>a;
    int index=0;
    for(int i=1;i<=n;++i)
    {
        cin>>x;
        q=t-x*0.006;
        if(fabs(a-q)<minn) {
            minn=fabs(a-q);index=i;
        }
    }
    cout<<index;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
typedef pair<int, int> pint;
#define mp make_pair

int main() {
    int n, m, q;
    cin >> n >> m >> q;
    multiset<pint> st;
    for (int k = 0; k < m; ++k) {
        int x, y;
        cin >> x >> y;
        st.insert(mp(x, y));
    }
    vector<vector<int>> v(n + 1, vector<int>(n + 1));
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            v[i][j] = v[i - 1][j] + v[i][j - 1] - v[i - 1][j - 1] + st.count(mp(i, j));
        }
    }
    
    for (int l = 0; l < q; ++l) {
        int a, b;
        cin >> a >> b;
        cout << v[b][b] - v[a - 1][b] - v[b][a - 1] + v[a - 1][a - 1] << endl;
    }
}


Measured memory_bytes: 11264
#include<cstdint>
#include<climits>
#include<cstdbool>
#include<cmath>
#include<iostream>
#include<vector>
#include<array>
#include<string>
#include<sstream>
#include<algorithm>

int main(){
	uint32_t a,b,c,tempa,tempb,tempc,i;
	std::cin>>a>>b>>c;
	if(a%2 || b%2 || c%2){
		std::cout<<0;
		return 0;
	}
	for (i = 1; i <= 1000000; ++i){
		tempa = (b+c)/2;
		tempb = (a+c)/2;
		tempc = (b+c)/2;
		if(tempa%2 || tempb%2 || tempc%2)
			break;
		a = tempa;
		b = tempb;
		c = tempc;
	}
	if(i != 1000001)
		std::cout<<i;
	else
		std::cout<<-1;
	return 0;
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf-8');
 
let inputString = '';
let currentLine = 0;
 
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
 
process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    
    main();    
});
 
function readLine() {
    return inputString[currentLine++];
}

function main() {
    const num = Number(readLine())
    console.log(num >= 30 ? 'Yes' : 'No')
}

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

}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
class Solver{
public:
    void solve(){
        ios::sync_with_stdio(false);
        cin.tie(0);
        int n;
        cin>>n;
        multiset<int>m;
        for(int u=0;u<n;u++){
            int a;
            cin>>a;
            auto it=m.lower_bound(a);
            if(it!=m.begin()){
                it--;
                m.erase(it);
            }
            m.insert(a);
        }
        cout<<m.size();
    }
};
int main()
{
    // freopen("in.txt","r",stdin);
    (new Solver())->solve();
}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> kudamono(N);
  
  int count = 0;
  
  for (int i = 0; i < N; i++) {
    cin >> kudamono.at(i);
  }
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      if (kudamono.at(i) > kudamono.at(j)) {
        int tmp = kudamono.at(i);
        kudamono.at(i) = kudamono.at(j);
        kudamono.at(j) = tmp;
      }
    }
  }
  for (int i = 0; i < M; i++) {
    count += kudamono.at(i);
  }
  cout << count << endl;
} 

Measured memory_bytes: 3628
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>

using namespace std;
//using ll = long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
const long long INF = 1LL << 60;

int main(){
    int N, T;
    scanf("%d %d", &N, &T);
    unsigned prev_t, t;
    unsigned long long answer = T;
    scanf("%u", &prev_t);
    for (int i = 0; i < N - 1; ++i) {
        scanf("%u", &t);
        answer += (t >= prev_t + T)? T : t - prev_t;
        prev_t = t;
    }
    printf("%llu", answer);
    return 0;
}

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

int n, m;
int c[16], x[20001];

ll dp[20001][256];

ll rec(int p, int y) {
    if (dp[p][y] >= 0) return dp[p][y];

    if (p == n) return 0;

    ll ret=1e10;
    for (int i=0; i<m; ++i) {
        int ny=y+c[i];
        if (ny<0) ny=0;
        else if (ny>255) ny=255;
        ret = min(ret, rec(p+1, ny)+(ny-x[p])*(ny-x[p]));
    }

    return dp[p][y] = ret;
}

int main() {
    while (cin >> n >> m and (n or m)) {
        rep(i,m) cin >> c[i];
        rep(i,n) cin >> x[i];
        fill(dp[0], dp[20001], -1);
        cout << rec(0, 128) << endl;
    }
}

Measured memory_bytes: 44676
# -*- coding: utf-8 -*-
H, W, K = map(int, input().split(' '))
s = [input() for _ in range(H)]
ans = [[0 for _  in range(W)] for _ in range(H)]

def paint_upper(i, j, n):
    # 上下
    num = 0

    k = i-1
    while k >= 0 and s[k][j] != '#' and ans[k][j] == 0:
        ans[k][j] = n
        k -= 1
        num += 1

    k = i+1
    while k < H and s[k][j] != '#' and ans[k][j] == 0:
        ans[k][j] = n
        k += 1
        num += 1

    return num


# def paint_left(i, j, n):
#     # 左右
#     num = 0
#
#     k = j-1
#     while k >= 0  and s[i][k] != '#' and ans[i][k] == 0:
#         ans[i][k] = n
#         k -= 1
#         num += 1
#
#     k = j+1
#     while k < W and s[i][k] != '#' and ans[i][k] == 0:
#         ans[i][k] = n
#         k += 1
#         num += 1
#
#     return num


n = 1
for j in range(W):
    for i in range(H):
        if s[i][j] == '#':
            ans[i][j] = n
            paint_upper(i, j, n)
            # if  == 0:
            #     paint_left(i, j, n)

            n+=1

for j in range(W):
    if ans[0][j] == 0:
        # 左側を使用する
        if j > 0:
            for i in range(H):
                ans[i][j] = ans[i][j-1]

        else:
            k = j + 1
            while k < W and ans[0][k] == 0:
                k += 1
            for i in range(H):
                ans[i][j] = ans[i][k]


for a in ans:
    print(' '.join(map(str, a)))

# print(ans)
# print(s)
# print(ans)

Measured memory_bytes: 45788
n=int(input())
s=[int(input()) for _ in range(n)]
sort=sorted(s,key=int)
if sum(sort)%10!=0:
    print(sum(sort))
    exit()
else:
    for i in range(n):
        if (sum(sort)-sort[i])%10!=0:
            print(sum(sort)-sort[i])
            exit()
print(0)


Measured memory_bytes: 3060
#include<stdio.h>

int main(){

    int a[3] = {0};
    scanf("%d%d%d", &a[0], &a[1], &a[2]);

    int i,j;
    int flag = 0;
 
    for( i = 0; i <= 1; i++ ){
        for( j = i+1; j <= 2; j++ ){
            if( a[i] == a[j] ) flag++;
        }
    }

    if( flag == 1 ){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }

    return 0;
}
            


Measured memory_bytes: 128
from collections import Counter
import math
import statistics
import itertools
a=int(input())
# b=input()
# c=[]
# for i in a:
#     c.append(int(i))
# A,B,C= map(int,input().split())
# f = list(map(int,input().split()))
g = [input() for _ in range(a)]
# h = []
# for i in range(a):
#     h.append(list(map(int,input().split())))
# a = [[0] for _ in range(H)]#nizigen

b = int(input())
g2 = [input() for _ in range(b)]

g.sort()
g2.sort()

count=1
ans={}
ans2={}

for i in range(len(g)-1):
    if g[i+1]==g[i]:
        count+=1
    else:
        ans[g[i]]=count
        count=1

ans[g[-1]]=count
count=1
for i in range(len(g2)-1):
    if g2[i+1]==g2[i]:
        count+=1
    else:
        if g2[i] in ans.keys():
            ans[g2[i]]-=count
            count=1
        else:
            ans[g2[i]]=-count

if g2[-1] in ans.keys():
    ans[g2[-1]]-=count
    count=1
else:
    ans[g2[-1]]=-count

if max(ans.values())>0:
    print(max(ans.values()))
else:
    print(0)


Measured memory_bytes: 10968
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: usize, m: usize,
        mut x: [i64; m]
    }
    x.sort();
    let mut diffs = vec![];
    for i in 0..m-1 {
        diffs.push(x[i+1]-x[i]);
    }
    diffs.sort();
    diffs.reverse();
    let mut ret = x[m-1] - x[0];
    for i in 0..std::cmp::min(n-1, diffs.len()) {
        ret -= diffs[i];
    }
    println!("{}", ret);
}

Measured memory_bytes: 6396
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}




signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
 
    ll n;
    string s;
    cin>>n>>s;
    ll w[n+1]={}, e[n+1]={};
    for(int i=0;i<n;i++){
        w[i+1] = w[i];
        e[i+1] = e[i];
        if(s[i] == 'W'){
            w[i+1]++;
        }
        else e[i+1]++;
    }
    ll ans = 1e7;
    for(int i=0;i<n;i++){
        chmin(ans,w[i]+e[n]-e[i+1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5396
#include <bits/stdc++.h>
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define repl(i, a, b) for (ll i = a; i < (b); ++i)
#define repd(i, a, b) for (int i = b; i >= (a); --i)
#define repdl(i, a, b) for (ll i = b; i >= (a); --i)
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const ll MOD = 1'000'000'007LL;
ll bpow(ll b, ll p, ll m = 1000000007LL) {
  ll rt = 1;
  for (; p; p >>= 1, b = b * b % m)
    if (p & 1)
      rt = rt * b % m;
  return rt;
}
int a[1000005];
int sieve[1000005];
int cnt[1000005];
void fact(int x) {
  if (x == 1)
    return;
  while (x != 1) {
    int tmp = sieve[x];
    cnt[tmp]++;
    while (x % tmp == 0)
      x /= tmp;
  }
}
bool check(int x) {
  if (x == 1)
    return true;
  while (x != 1) {
    int tmp = sieve[x];
    if (cnt[tmp] > 1)
      return false;
    while (x % tmp == 0)
      x /= tmp;
  }
  return true;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i < 1000005; i++)
    sieve[i] = i;
  for (int i = 2; i < 1000005; i += 2)
    sieve[i] = 2;
  for (int i = 3; i < 1000005; i++) {
    if (sieve[i] == i) {
      for (ll j = 1LL * i * i; j < 1000005; j += i) {
        sieve[j] = i;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  int g = 0;
  for (int i = 1; i <= n; i++) {
    g = __gcd(g, a[i]);
    fact(a[i]);
  }
  int ok = 1;
  for (int i = 1; i <= n; i++) {
    if (!check(a[i]))
      ok = 0;
  }
  if (ok) {
    cout << "pairwise coprime" << endl;
  } else if (g == 1) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }
}


Measured memory_bytes: 15280
#include<bits/stdc++.h>
using namespace std;
const int maxx=1e2+10;
typedef long long ll;
char s[maxx][maxx];
int main(){
    int n,m,K;
    cin>>n>>m>>K;
    for(int i=0;i<n;i++){
        scanf("%s",s[i]);
    }
    int h=1<<n,w=1<<m;
    int ans=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int cnt=0;
            for(int k=0;k<n;k++){
                if((i>>k)&1) continue;
                for(int l=0;l<m;l++){
                    if((j>>l)&1) continue;
                    cnt+=s[k][l]=='#';
                }
            }
            ans+=cnt==K;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3764
def dfs(i,f):
  if i == n-1:
    return sum(list(map(int, f.split('+'))))
  
  return dfs(i+1, f+s[i+1]) + dfs(i+1, f+'+'+s[i+1])

s = input()
n = len(s)

print(dfs(0, s[0]))

Measured memory_bytes: 9192
#include<stdio.h>

int main(void){
    
    int i = 1;
    int x;
    
    while(i <= 10000){
        scanf("%d",&x);
        if(x == 0)break;
        else printf("Case %d: %d\n",i,x);
        i++;
    }
    
    return 0;
}


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

int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,i,max=0;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)
    cin>>a[i];
    int count=1;
    max=a[0];
    for(i=1;i<n;i++)
    {
    	if(max<=a[i])
    	{
    		count++;
    		max=a[i];
		}
    
	}
	cout<<count;

}

Measured memory_bytes: 256
l,r = map(int,input().split())

if (r-l+1)>=2019:
    print(0)
else:
    ans = (l*(l+1))%2019
    for j in range(l,r+1):
        for i in range(l,j):
            if ((i*j)%2019)<ans:
                ans = (i*j)%2019
    print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template


vector<vector<int>> calc_cost(string &a, string &b){
    int sz = (int)a.size();
    vector<vector<int>> ret(sz + 1, vector<int>(sz + 1, 0));
// ret[i][j] = 左がi個、右がj個残っているときの次にかかるコスト
    rep(i, sz) rep(j, sz){
        ret[i + 1][j + 1] = ret[i][j] + (a[i] == b[j]);
    }
    return ret;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int H, W;
    cin >> H >> W;
    vector<string> A(H);
    rep(i, H){
        cin >> A[i];
    }
    
    int ret = 0;
    rep(i, W - 1){
        string P = "", Q = "";
        rep(j, H){
            P += A[j][i], Q += A[j][i + 1];
        }
        auto cost = calc_cost(P, Q); // H * H
        // dp[j][k] = 左をj回、右をk回浮かせるまでにかかるコストの最小
        vector<vector<int>> dp(H + 1, vector<int>(H + 1, 0));
        rep(j, H) rep(k, H){
            dp[j + 1][k + 1] = min(dp[j][k + 1], dp[j + 1][k]) + cost[j + 1][k + 1];
        }
        ret += dp[H][H];
    }
    output(ret);
    
    
    return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;
const int INF = 1100000000;
int main(){
  int n, W;
  cin >> n >> W;
  vector<ll> w(n), v(n);
  rep(i, n) {
    cin >> w[i] >> v[i];
  }
  vector<vector<ll> > dp(110, vector<ll>(100105, INF));
  dp[0][0] = 0;
  rep(i, n) {
    rep(j, 100100) {
      if(j - v[i] >= 0) {
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
      }
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
    }
  }
  ll ans = 0;
  for(int i = 0; i < 100100; ++i) {
    if(dp[n][i] <= W) ans = i;
  }
  cout << ans << endl;
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

/*組み合わせ(Combination)*/
const ll CMAX = 1010000;
const ll CMOD = 1e9+7;
ll fac[CMAX], finv[CMAX], inv[CMAX];
// テーブルを作る前処理
void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < CMAX; i++) {
		fac[i] = fac[i - 1] * i % CMOD;
		inv[i] = CMOD - inv[CMOD%i] * (CMOD / i) % CMOD;
		finv[i] = finv[i - 1] * inv[i] % CMOD;
	}
}
// 二項係数計算
ll comb(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % CMOD) % CMOD;
}


int main(){

    ll a, b, x; cin >> a >> b >> x;

    cout << b/x-a/x+(a%x==0) << endl;

    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a, b;
    for (size_t i = 0; i < A; ++i)
    {
        int temp = 0;
        cin >> temp;
        a.push_back(temp);
    }
    for (size_t i = 0; i < B; ++i)
    {
        int temp = 0;
        cin >> temp;
        b.push_back(temp);
    }
    int minimum = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());
    for (size_t i = 0; i < M; ++i)
    {
        int x, y, c;
        cin >> x >> y >> c;
        minimum = min(a[x - 1] + b[y - 1] - c, minimum);
    }
    cout << minimum;

    return 0;
}

Measured memory_bytes: 1400
n = int(input())
a = list(map(int, input().split()))
l = []
rate = ['gray', 'brown', 'green', 'cyan', 'blue', 'yellow', 'orange', 'red']
count = 0

for i in range(n):
    q, r = divmod(a[i], 400)
    if q >= 8:
        count += 1
    else: l.append(rate[q])

print(max(len(set(l)), 1), len(set(l))+count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb emplace_back
#define all(in) in.begin(),in.end()
using ll = long long;
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n, k; scanf("%lld %lld", &n, &k);
    vector<ll> pp, mm;
    ll zero = 0;
    rep(i,n) {
        ll a; scanf("%lld", &a);
        if (a > 0) pp.pb(a);
        else if (a < 0) mm.pb(-a);
        else zero++;
    }
    sort(all(pp)); ll p = (ll)pp.size();
    sort(all(mm)); ll m = (ll)mm.size();
 
    if (p * m >= k) {
        ll left = 1, right = 1ll<<60;
        while (right - left > 1) {
            ll mid = (right + left) / 2;
            ll count = 0; // mid以下になる個数
            ll id = m;
            rep(i,p) {
                while (id > 0 && pp[i] * mm[id - 1] >= mid) id--;
                count += m - id; 
            }
            if (count >= k) left = mid;
            else right = mid;
        }
        cout << -left << endl;
        return 0;
    }
    else if (p * m + (p + m) * zero + zero * (zero - 1) / 2 >= k) {
        cout << 0 << endl;
        return 0;
    }
    else {
        k -= p * m + (p + m) * zero + zero * (zero - 1) / 2;
        ll left = 1, right = 1ll<<60;
        while (right - left > 1) {
            ll mid = (right + left) / 2;
            ll count = 0; // mid以下になる個数
            ll id = p;
            rep(i,p) {
                while (id > 0 && pp[i] * pp[id - 1] > mid) id--;
                count += id;
                if (pp[i] * pp[i] <= mid) count--;
            }
            id = m;
            rep(i,m) {
                while (id > 0 && mm[i] * mm[id - 1] > mid) id--;
                count += id;
                if (mm[i] * mm[i] <= mid) count--;
            }
            if (count < 2 * k) left = mid; 
            else right = mid;
        }
        cout << right << endl;
        return 0;
    }
    return 0;
}



Measured memory_bytes: 5252
fn read() -> (i32, i32, i32) {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let vec: Vec<i32> = s.split_whitespace().map(|x| x.parse().unwrap()).collect();
    (vec[0], vec[1], vec[2])
}

fn main() {
    let (x, a, b) = read();
    match (x, a, b) {
        _ if a >= b => println!("delicious"),
        _ if x >= b - a => println!("safe"),
        _ => println!("dangerous"),
    }
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b) - 1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 333;
const int MIN = 100;

double DP[MIN][MAX][MAX];

int L[MAX];
int n, c;
int nc;

double solve()
{
	FOR (i, 0, 1<<n)
	{
		if (!(i & 1)) continue;
		FOR (j, 0, nc)
		{
			FOR (k, j, nc + 1)
			{
				DP[i][j][k] = 0;
			}
		}
	}

	DP[1][0][L[0] * n] = 1;


	FOR (i, 0, 1<<n)
	{
		if (!(i&1)) continue;
		FOR (j, 0, nc)
		{
			FOR (k, j, nc + 1)
			{
				if (j < k)
				{
					DP[i][j+1][k] += DP[i][j][k];
				}

				int ind = j % n;

				if (i & (1<<ind)) continue;
				DP[i | (1<<ind)][j][min(nc, max(k, j + L[ind] * n))] += DP[i][j][k] / c;
			}
		}
	}

	double res = DP[(1<<n)-1][nc-1][nc];
	return res;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	cin>>n>>c;
	nc = n * c;
	FOR (i, 0, n)
	{
		cin>>L[i];
	}

	sort(L, L+n);
	reverse(L, L+n);
	reverse(L+1, L+n);

	int cnt = 0;
	double res = 0;
	do
	{
		res += solve();
		cnt++;
	//	cout<<cnt<<' '<<res<<endl;
	} while(next_permutation(L+1, L+n));

	res /= cnt;
	printf("%.11f\n", res);

}



Measured memory_bytes: 56448
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e9
typedef long long ll;
using namespace std;
//�I�[�o�[�t���[�ɋC������您����������
//�m�F�Y���Ȃ您����������

int main() {
    int n; cin >> n;
    vector<int> odd;
    vector<int> even;
    if(n%2==0){
        rep(i,n){
            int num; cin >> num;
            if(i%2==0){
                odd.push_back(num);
            }else{
                even.insert(even.begin(),num);
            }
        }
        for(auto a : even){
            cout << a << " ";
        }
        for(auto b :odd){
            cout << b << " ";
        }
        cout << endl;
    }else{
        rep(i,n){
            int num; cin >> num;
            if(i%2!=0){
                odd.push_back(num);
            }else{
                even.insert(even.begin(),num);
            }
        }
        for(auto a : even){
            cout << a << " ";
        }
        for(auto b :odd){
            cout << b << " ";
        }
        cout << endl;
    }

    return 0;
}

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

int main(){
	int w, n, num[31], damy, i, j, bou1, bou2;

	cin >> w >> n;

	for(i = i; i <= w; i++){
		num[i] = i;
	}

	for(i = 0; i < n; i++){
		scanf("%d,%d", &bou1, &bou2);
		damy = num[bou1];
		num[bou1] = num [bou2];
		num[bou2] = damy;
	}

	for(i = 1; i <= w; i++){
		cout << num[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1240