akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		long l = sc.nextLong(), r = sc.nextLong();
		long ans = Long.MAX_VALUE;
		for(long i = l; i<=r; i++) {
			long x = 0;
			for(long j = i+1; j <= r; j++) {
				x = (i*j)%2019;
				if(x < ans) ans = x;
				if(ans == 0) break;
			}
			if(ans == 0) break;
		}
		System.out.println(ans);
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


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

int main() {
  int N;
  int L[10];
  int max = 0, max_index, sum = 0;

  cin >> N;
  for(int i = 0;i < N;i++) cin >> L[i];

  for (int i = 0; i < N; i++) {
    if (max <= L[i]) {
      max = L[i];
      max_index = i;
    }
  }

  for (int i = 0 ; i < N; i++)
    if (i != max_index) sum += L[i];

  cout << ((max < sum) ? "Yes" : "No") << endl;
  return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> to[100005];
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
    
    vector<int> dist(n,inf);
    vector<int> pre(n);
    queue<int> q;
    dist.at(0) = 0;
    q.push(0);
    while(!q.empty()){
      int v = q.front(); q.pop();
      for(int u : to[v]){
        if(dist.at(u) != inf) continue;
        pre.at(u) = v;
        dist.at(u) = dist.at(v)+1;
        q.push(u);
      }
    }
    cout << "Yes" << endl;
    rep(i,n){
      if (i == 0) continue;
      cout << pre.at(i) + 1 << endl;
    }
}

Measured memory_bytes: 10544
N,M=map(int,input().split())
mp=[ tuple(map(int,input().split())) for _ in range(M)]
#ソート。O(nlogn)
mp_=sorted(mp,key=lambda x: x[1])

ans=0
cut_bridge=0
#最後に切った橋がaより大きいかどうかさえ見ればいい。
for n in range(M):
    if mp_[n][0]>cut_bridge:
        ans+=1
        cut_bridge=mp_[n][1]-1
print(ans)

Measured memory_bytes: 19024
#include <stdio.h>
#include <iostream>
#include <complex>
#include <cmath>
#define prt(cplx) printf("%.8lf %.8lf\n",cplx.real(),cplx.imag())

using namespace std;

typedef complex<double> P;

void draw(P l, P r, int depth) {
	if(depth<=0) {
		prt(l);
		return;
	}

	P _p = (r-l);

	P c1 = l+_p*1.0/3.0;
	P c3 = l+_p*2.0/3.0;

	P _v = _p * P(0,1);
	_v = _v*sqrt(3.0)/6.0;

	P c2 = l + _p/2.0 + _v;

	draw(l ,c1,depth-1);
	draw(c1,c2,depth-1);
	draw(c2,c3,depth-1);
	draw(c3,r ,depth-1);
}

int main() {
	int n;
	cin >> n;
	draw(P(0,0),P(100,0),n);
	prt(P(100,0));
	return 0;
}



Measured memory_bytes: 3208
import math
(a, b, x) = map(int, input().split())

theta = 0
if x < (a ** 2) * b / 2:
    theta = math.pi / 2 - math.atan(2 * x / a / b ** 2)
else:
    if a ** 2 * b == x:
        theta = 0
    else:
        theta = math.pi / 2 - math.atan(a ** 3 / 2 / (a ** 2 * b - x))
print(theta * 180 / math.pi)


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

using namespace std;

void Main() {
    int X, A, B;
    cin >> X >> A >> B;
    X -= A;
    X %= B;
    cout << X << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3608
import java.io.*;
import java.util.*;

class Graph2{
	private int[] discover;
	private int[] finish;
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Graph2() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	public int DFS(int v, int time){
		if (discover[v] == 0) {
			discover[v] = time; 
			time++;
		}
		else {
			return time;
		}
		for (int i: adjList.get(v)) {
			//time++;
			time = DFS(i, time);
		}
		finish[v] = time;
		time++;
		return time;
	}
	public void searchGraph() {
		discover = new int[totalVertex];
		finish = new int[totalVertex];
		int time = 1;
		
		for (int i = 0; i < totalVertex; i++) {
			
			time = DFS(i, time);
			
		}
		for (int j = 0; j < totalVertex; j++ ) {
			System.out.println(j+1 + " " + discover[j] + " " + finish[j]);
		}
	}
}
public class Main {
	public static void main(String argv[]) {
		Graph2 g = new Graph2();
		g.loadAdjList();
		g.searchGraph();
	}
}




Measured memory_bytes: 28692
#include<stdio.h>
#include<math.h>
void print(double p[]){
    printf("%lf %lf\n",p[0],p[1]);
}
 
void kock(int n, double p1[],double p2[]){
double s[2],t[2],u[2];
    s[0]=(p2[0]-p1[0])/3+p1[0];
    s[1]=(p2[1]-p1[1])/3+p1[1];
    t[0]=2*(p2[0]-p1[0])/3+p1[0];
    t[1]=2*(p2[1]-p1[1])/3+p1[1];
    u[0]=(t[0]-s[0])/2-sqrt(3)/2*(t[1]-s[1])+s[0];
    u[1]=(t[1]-s[1])/2+sqrt(3)/2*(t[0]-s[0])+s[1];
    if(n==0) return;
    kock(n-1,p1,s);
    print(s);
    kock(n-1,s,u);
    print(u);
    kock(n-1,u,t);
    print(t);
    kock(n-1,t,p2);
}
 
 
int main(){
    int n;
    double p1[2],p2[2];
    p1[0]=p1[1]=p2[1]=0;
p2[0]=100;
     
    scanf("%d",&n);
    print(p1);
    kock(n,p1,p2);
    print(p2);
     
    return 0;
}

Measured memory_bytes: 636
import numpy as np
from numpy.fft import fft, ifft

mod = 10 ** 9 + 7
S = input()

mat = []
for i in range(6):
    w = np.zeros(13)
    for j in range(10):
        w[(10 ** i * j) % 13] += 1
    mat.append(fft(w))

ress = [[(10 ** i * j) % 13 for j in range(10)] for i in range(6)]


state = np.zeros(13)
state[0] = 1
state = fft(state)

keta = 0
res = 5
for s in reversed(S):
    if s == "?":
        state = state * mat[keta]
    else:
        res -= ress[keta][int(s)]

    if keta == 5:
        keta = 0
        state = fft(np.remainder(np.round(np.real(ifft(state))), mod))
    else:
        keta += 1


state = ifft(state)
print(int(np.round(np.real(state[res % 13]))) % mod)


Measured memory_bytes: 14732
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;  
const int M=200005;  
ll n,i,ans;
int a[M],c[M];

main(){
	cin>>n;  
	
    for(i=1;i<=n;i++){
        cin>>a[i];
        c[a[i]]++;  
    }
    
    for(i=1;i<=n;i++)
    ans+=(ll)(c[i]-1)*c[i]/2;  
    for(i=1;i<=n;i++)
    cout<<ans-(ll)(c[a[i]]-1)<<endl;
}

Measured memory_bytes: 3712
#include <iostream>
using namespace std;
typedef unsigned long long u64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int cnt = 0;
  int size = s.size();
  int depth = 0;
  for (int i = 0; i < size; ++i) {
    if (s[i] == 'S') {
      depth++;
    } else {
      if (depth > 0) {
        depth--;
      } else {
        cnt++;
      }
    }
  }
  cout << cnt+depth << endl;
  return 0;
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

set<lli> divisorList(lli num){
	set<lli> v;

	for(lli i=1;i*i<=num;i++){
		if(num%i==0){
			v.insert(i);
			v.insert(num/i);
		}
	}
	return v;
}

bool ok(lli n,lli k){
    if(DEBUG)cout<<"n="<<n<<"k="<<k<<endl;
    if(n<k){
        if(n==1)return true;
        else return false;
    }
    if(n%k==0)return ok(n/k,k);
    else return ok(n%k,k);
}

void func(long long N){
    set<lli> yaku0 = divisorList(N);
    set<lli> yaku1 = divisorList(N-1);

    lli cnt = yaku1.size()-1;
    for(auto e:yaku0){
        if(e==1)continue;
        if(ok(N,e))cnt++;
    }
    cout<<cnt<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    func(N);
    return 0;
}


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

int main(){
    string s;
    cin >> s;
    int tmp1=0,tmp2=0;
    for(int i=0;i<s.size();i++){
        if(i%2==0){
            if(s[i]!='0')tmp1++;
        }
        else{
            if(s[i]!='1')tmp1++;
        }
    }
    for(int i=0;i<s.size();i++){
        if(i%2==0){
            if(s[i]!='1')tmp2++;
        }
        else{
            if(s[i]!='0')tmp2++;
        }
    }
    cout << min(tmp1,tmp2) << endl;
    return 0;
}

Measured memory_bytes: 512
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N, L;
        N = scan.nextInt();
        L = scan.nextInt();
        int[] apple = new int[N];
        if (L > 0) {
            for (int i = 0; i < N; i++) {
                apple[i] = L + (i + 1) - 1;
            }
            quick_sort(apple, 0, N - 1);
            int taste = 0;
            for (int i = 1; i < N; i++) {
                taste += apple[i];
            }
            System.out.println(taste);
        } else {
            int taste = 0;
            int index = 0;
            for (int i = 0; i < N; i++) {
                apple[i] = L + (i + 1) - 1;
            }
            int[] copyapple = new int[N];
            for (int i = 0; i < N; i++) {
                copyapple[i] = (int) Math.abs(L + (i + 1) - 1);
            }
            quick_sort(copyapple, 0, N - 1);
            if (copyapple[0] == 0) {
                for (int i = 0; i < N; i++) {
                    if (apple[i] != 0) {
                        taste += apple[i];
                    }
                }
            } else {
                quick_sort(apple, 0, N - 1);
                for (int i = 0; i < N - 1; i++) {
                    taste += apple[i];
                }
            }
            System.out.println(taste);
        }
    }

    static void quick_sort(int[] d, int left, int right) {
        if (left >= right) {
            return;
        }
        int p = d[(left + right) / 2];
        int l = left, r = right, tmp;
        while (l <= r) {
            while (d[l] < p) {
                l++;
            }
            while (d[r] > p) {
                r--;
            }
            if (l <= r) {
                tmp = d[l];
                d[l] = d[r];
                d[r] = tmp;
                l++;
                r--;
            }
        }
        quick_sort(d, left, r);
        quick_sort(d, l, right);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define dout cout
#ifndef dout
#define //
#endif

int main(){
    char map[50+2][50+2];//vector忘れた、場合分け避けるために一周多く作ってる

    int H,W;
    cin>>H>>W;
    //dout<<"H:"<<H<<"W:"<<W<<"\n";
    char c;
    for(int i = 0; i < H; i++){//////////////入力
        for(int j=0; j<W; j++){
            cin>>c;
            if(c=='.'){//ドット
                map[i+1][j+1] = '0';
            }
            else{//爆弾
                map[i+1][j+1] = '#';
            }
        }
    }

    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(map[i+1][j+1] == '#'){///////爆弾なら周り8マスに+1する
                if(map[i+0][j+0] != '#') map[i+0][j+0]++;
                if(map[i+0][j+1] != '#') map[i+0][j+1]++;
                if(map[i+0][j+2] != '#') map[i+0][j+2]++;
                if(map[i+1][j+0] != '#') map[i+1][j+0]++;
                //map[i+1][j+1]
                if(map[i+1][j+2] != '#') map[i+1][j+2]++;
                if(map[i+2][j+0] != '#') map[i+2][j+0]++;
                if(map[i+2][j+1] != '#') map[i+2][j+1]++;
                if(map[i+2][j+2] != '#') map[i+2][j+2]++;
            }
        }
    }
    
    
   dout<<"\n\n";//////////////////////////////////////////
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cout<<map[i+1][j+1];
        }
        cout<<'\n';
    }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define bit(k) (1LL<<(k))
#define SUM(v) accumulate(all(v), 0LL)

typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
struct fast_ios{ fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }fast_ios_;

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 TOSTRING(x) string(#x)
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os  << "["; for(auto _: v) os << _ << ", "; os << "]"; return os; };
template <typename T> ostream &operator<<(ostream &os, set<T> &st) { os << "("; for(auto _: st) { os << _ << ", "; } os << ")";return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair< T, U >& p){os << "{" <<p.first << ", " << p.second << "}";return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &mp){ os << "["; for(auto _: mp){ os << _ << ", "; } os << "]" << endl; return os; }

#define DUMPOUT cerr
void dump_func(){ DUMPOUT << endl; }
template <class Head, class... Tail> void dump_func(Head &&head, Tail &&... tail) { DUMPOUT << head; if (sizeof...(Tail) > 0) { DUMPOUT << ", "; } dump_func(std::move(tail)...); }

#ifdef DEBUG
#define dbg(...) dump_func(__VA_ARGS__)
#define dump(...) DUMPOUT << string(#__VA_ARGS__) << ": "; dump_func(__VA_ARGS__)
#else
#define dbg(...)
#define dump(...)
#endif

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const long double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/


int main() {
    ll X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X), B(Y), C(Z);
    cin >> A >> B >> C;
    vector<ll> v;
    rep(i,X)rep(j,Y){
        v.emplace_back(A[i]+B[j]);
    }
    sort(all(v), greater<>());
    dump(v);
    while(v.size() > K){
        v.pop_back();
    }
    dump(v);
    vector<ll> w;
    rep(i,v.size())rep(j,Z){
        w.emplace_back(v[i]+C[j]);
    }
    sort(all(w), greater<>());
    while(w.size() > K)w.pop_back();
    rep(i,K){
        cout << w[i] << endl;
    }
}


Measured memory_bytes: 44076
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define Q_SIZE 30		// 1_base
typedef struct {
	int sq;				// 0_base
	int eq;             // 0_base
	int len;            // 1_base
	int data[Q_SIZE];
} queue;
void enq(queue *, int);
int deq(queue *);
void Re_primeNos(unsigned);
void quick(int *A, int left, int right);

queue q1 = {0,0,0};
int main(void)
{
	unsigned num;
	fscanf(stdin,"%u",&num);
	Re_primeNos(num);
	fprintf(stdout,"%u:",num);
	quick(q1.data,0,q1.len-1);
	while(q1.len != 0) fprintf(stdout," %d",deq(&q1));
	fputc('\n',stdout);
	return 0;
}


void Re_primeNos(unsigned n)
{
	unsigned divide;
	// n ????????????????±??????????
	// ?±??????£?????????????????°????????¨?????§??´??°?????°divide ?????????
	
	divide = (unsigned)sqrt(n);
	for (; 1 < divide && 0 != n % divide; divide -= 1);
	if (1 < divide) 
	{
		n /= divide;
		Re_primeNos(divide);
		Re_primeNos(n);
	}
	else
	{
		enq(&q1,(signed)n);
	}
}

void enq(queue *p, int num) {
	if (Q_SIZE <= p->len) fputs("?????\????????????????????§???\n", stdout), exit(1);

	p->data[p->eq] = num;
	p->eq = (p->eq == Q_SIZE -1) ? 0 : (p->eq) + 1;
	(p->len)++;
}

int deq(queue *p) {
	if (p->len == 0) exit(2);
	
	(p->len)--;

	if (p->sq == Q_SIZE -1) {
		p->sq = 0;
		return p->data[Q_SIZE -1];
	}
	else return p->data[(p->sq)++];
}	

void quick(int *A, int left, int right) {
    int i,                  
        j,                  
        pivot,              
        work,               
        flag;               

    if (left < right) {     
                            

        pivot = A[left];    
        i = left +1;
        j = right;
        flag = 1;
        
        while (flag == 1) {
            while (A[i] <= pivot && i < right) i++;
            while (A[j] >= pivot && j > left) j--; 
                                                   

            if (i >= j) flag = 0;                  
                                                   

            else {                                 
                work = A[i];                       
                A[i] = A[j];                       
                A[j] = work;
            }
        }
        
        A[left] = A[j];                            
        A[j] = pivot;                              
                                                   

        quick(A, left, j -1);                      
        quick(A, j +1, right);                     
    }
}

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

int main() {
int N;
  cin>>N;
  if(N%3==0){
    cout<<N/3<<endl;
  }
 else if(N%3==1){
   cout<<(N-4)/3+1<<endl;
 }
  else if(N%3==2){
    cout<<(N-5)/3+1<<endl;
  }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, K: int, A: "List[int]"):
    for k in range(N-K):
        if A[k] < A[K+k]:
            print(YES)
        else:
            print(NO)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()


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

using namespace std;

#define forn(i, n) for(int i=0;i<int(n);i++)

int main(){
	int a, b; cin >> a >> b;
	int ans1 = a+a-1, ans2 = b+b-1, ans3 = a+b;
	cout << max(ans1, max(ans2, ans3));
}


Measured memory_bytes: 256
#include <iostream>
#define llint long long
#define mod 1000000007

using namespace std;

llint fact[70005], fact_inv[70005];

llint pow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (pow(a, n-1)%mod)) % mod;
	}
	else{
		return pow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < 70005; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	for(int i = 0; i < 70005; i++){
		fact_inv[i] = pow(fact[i], mod-2);
	}
}

llint perm(llint n, llint r)
{
	if(r == 0) return 1;
	return fact[n] * fact_inv[n-r] % mod;
}

llint N, M;
llint A[20];
llint dp[1<<16][20];
llint sum[1<<16];
llint bits[1<<16];

int main(void)
{
	make_fact();
	
	cin >> N >> M;
	for(int i = 1; i <= M; i++) cin >> A[i];
	
	llint S = 1 << N;
	for(int i = 0; i < S; i++){
		for(int j = 0; j < N; j++){
			if(i & (1<<j)) bits[i]++;
		}
	}
	
	dp[0][M+1] = 1;
	for(int i = 0; i < S; i++){
		for(int j = 1; j <= M+1; j++){
			for(int k = 0; k < N; k++){
				if(i & (1<<k)) continue;
				for(int l = 1; l < j; l++){
					if(S-A[l]-i >= (1<<k)-1){
						dp[i|(1<<k)][l] += dp[i][j] * perm(S-A[l]-i, (1<<k)-1) % mod * (1<<k) % mod;
						dp[i|(1<<k)][l] %= mod;
					}
				}
			}
		}
	}
	
	for(int i = 0; i < S; i++){
		for(int j = 1; j <= M+1; j++){
			sum[i] += dp[i][j];
			sum[i] %= mod;
		}
		llint rem = S-i-1;
		for(int j = 0; j < N; j++){
			if(i & (1<<j)) continue;
			sum[i] *= perm(rem, 1<<j);
			sum[i] %= mod;
			rem -= 1<<j;
		}
	}
	
	llint ans = 0;
	for(int i = 1; i < S; i++){
		if(bits[i] % 2) ans += sum[i];
		else ans += mod - sum[i];
		ans %= mod;
	}
	ans *= S, ans %= mod;
	
	ans = (fact[S] + mod - ans) % mod;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 12544
#include <stdio.h>

int main ()
{
    int n,m,a,b,i;
    int grad [1000];
    for (i=0;i<1000;i++)
        {
            grad[i]=0;
        }
    scanf ("%d %d", &n, &m);
    for (i=1;i<=m;i++){
        scanf ("%d %d", &a, &b);
        grad[a]=grad[a]+1;
        grad[b]=grad[b]+1;
    }
    for(i=1;i<=n;i++){
        printf ("%d\n", grad[i]);
    }
    return 0;
}

Measured memory_bytes: 128
n = int(input())
w = list(map(int, input().split()))
result = 100000
for t in range(1,n):
    total1 = 0
    total2 = 0
    for i in range(0,t):
        total1 += w[i]
    for i in range(t,n):
        total2 += w[i]
    result = min(result,abs(total1-total2))

print(result)


Measured memory_bytes: 3060
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.Char
import Data.List


-- space delimited integers
getVals::IO [Int]
getVals = unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

-- space delimited strings
getStrings::IO [String]
getStrings = (map BS.unpack . BS.words) <$> BS.getLine

main::IO()
main = do
    vals <- getVals
    putStrLn $ (\ ls -> if (sum ls) >= 22 then "bust" else "win") vals 

Measured memory_bytes: 3664
function main(input) {
  var n = input[0].split(" ")[0]-0;
  var m = input[0].split(" ")[1]-0;
  var map = [];
  for(var i=0;i<m;i++) map.push(0);
  input.filter((v,i)=>i>0).forEach(v=>{
    v.split(" ").filter((w,i)=>i>0).forEach(w=>{
      map[w-1]++;
    });
  });
  map.sort((a,b)=>a-b);
  console.log(map.filter(v=>v==n).length);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


Measured memory_bytes: 7500
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		
		//変数//
		int A;		//入力A
		int B;		//入力B
		int ans;	//出力結果
		String op;	//入力OP
		
		Scanner scan = new Scanner(System.in);
		
		//入力//
		A = scan.nextInt();
		op = scan.next();
		B = scan.nextInt();
		
		scan.close();
		
		//処理//
		if( op.equals("+") ){
			ans = A + B;
		}else{
			ans = A - B;
		}
		
		//結果//	
		System.out.println(ans);
		
		}
}


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

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 = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

const ll MAX_N = 1e5+5;
vector<ll> g[MAX_N];
ll d[MAX_N];

ll dfs(ll v, ll p = -1) {
  if (d[v] > 0) { return d[v]; } // already calculated

  ll dist = 0;
  for (int nv : g[v]) {
    if (nv == p) { continue; }
    chmax(dist, dfs(nv, v));
  }
  return d[v] = dist + 1;
}

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

  ll n, m;
  cin >> n >> m;
  rep(iter, m) {
    ll x, y;
    cin >> x >> y;
    --x; --y;
    g[x].push_back(y);
  }
  // start dfs from each node
  rep(i, n) {
    dfs(i);
  }

  ll ans = 0;
  rep(i, n) {
    chmax(ans, d[i] - 1);
  }
  cout << ans << endl;
}


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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

ll A,B;

int main()
{
	scanf("%lld%lld",&A,&B);
	if(abs(A - B) > 1){
		printf("Alice\n");
	}
	else{
		printf("Brown\n");
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
vector<int> v[9]; int N, M;
struct Node {
    int now = 1; int cnt[9] = {1,1,0};
};
int next(Node n) {
    if(n.cnt[0] == N) return 1;
    int root = 0;
    for(int x : v[n.now]) {
        if(n.cnt[x] == 1) continue;
        Node n2 = n;
        n2.now = x; n2.cnt[x] += 1; n2.cnt[0] += 1;
        root += next(n2);
    }
    return root;
}
int main() {
    cin >> N >> M;
    for(int i = 0, a, b; i < M; i++) {
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    Node n;
    cout << next(n);
}

Measured memory_bytes: 256
let f s = (s/3600)::((s mod 3600)/60)::(s mod 60)::[];;

let put s = 
	let rec put' l =
		match l with
		|[] -> print_string "\n"
		|x::xs -> print_int x;if xs != [] then print_string ":";put' xs in
	put' (f s);;

Scanf.sscanf(read_line()) "%d" put;;



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


void solve()
{
	ll n; cin >> n;

	if (n % 1000 == 0){
		cout << 0 << '\n';
	}else{
		cout << 1000 - ( n % 1000) << '\n';
	}
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 3644
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;

void solve() {
	int N, M; cin >> N >> M;
	vector<int>c(N);
	REP(i, M) {
		int u, v; cin >> u >> v;
		u--, v--;
		c[u]++, c[v]++;
	}
	bool ok = true;
	REP(i, N) {
		if (c[i] & 1)ok = false;
	}
	if (ok)print("YES");
	else print("NO");
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}

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

typedef pair<int, int> P;

int main() {

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

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
using namespace std;
int main(void){
int A;
cin>>A;
string N=to_string(A);
int answer=0;
int a;
for (int i=0;i<N.length();i++){
if (N[i]=='0')
    a=0;
else if(N[i]=='1')
    a=1;
else if(N[i]=='2')
    a=2;
else if(N[i]=='3')
    a=3;
else if(N[i]=='4')
    a=4;
else if(N[i]=='5')
    a=5;
else if(N[i]=='6')
    a=6;
else if(N[i]=='7')
    a=7;
else if(N[i]=='8')
    a=8;
else if(N[i]=='9')
    a=9;
answer+=a;
}
if(A%answer==0)
    cout<<"Yes"<<endl;
else
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class AABC333 {
public:
	void solve(istream& in, ostream& out) {
        int a,b;
        in >> a >> b;
        if(a % 2 == 0 || b % 2 == 0) out << "No" << endl;
        else out << "Yes" << endl;
	}
};

int main() {
	AABC333 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
a = input().split()
a = [int(i) for i in a]
b = input().split()
b = [int(i) for i in b]

def cao(aller, i):
	dicter = dict()
	for m in aller:
		for n in m:
			if n < i:
				try:
					dicter[n].append(m)
				except:
					dicter[n] = [m]
	for i in sorted(dicter)[::-1]:
		if len(dicter[i]) >= a[1]:
			return dicter[i], i
	return [], -1
	
aller = [0]
sumer = 0
for i in b:
	sumer += i
	aller.append(sumer)
	
superlist = dict()
for i in range(len(b)):
	for j in range(i + 1, len(b) + 1):
		temp = bin(aller[j] - aller[i])[::-1]
		x = []
		for k in range(len(temp)):
			if temp[k] == '1':
				x.append(k)
		for m in x:
			try:
				superlist[m].append(x)
			except:
				superlist[m] = [x]
						
for i in sorted(superlist)[::-1]:
	if len(superlist[i]) >= a[1]:
		li = superlist[i]
		sumer = 2 ** i
		gan1, gan2 = cao(li, i)
		while gan2 != -1:
			sumer += 2**gan2
			gan1,gan2 = cao(gan1,gan2)
		print(sumer)
		break

Measured memory_bytes: 352292
//動かない。多分無限ループしてる。

#include <bits/stdc++.h>

using namespace std;

int main(){
  //受け取る要素数
  //カウンタ初期化
  int N, counter = 0;
  cin >> N;
  //要素の配列
  vector<int> A(N);

  for(int &a : A){
    cin >> a;
  }
  //ループ脱出フラグ, falseで初期化
  bool finish = false;

  //以下奇数が出てこない限りループ
  //全ての要素に対して
  //2で割れるか確かめる
  //奇数が出てきた段階でループを出る

  while(true){
    //全部割る
    for(int &a: A){ //多分ここが問題。参照渡しと変数自体に代入する違いがわからん
      if (a % 2){
        finish = true;//このフラグが立たない？ここの理由が知りたい
        break;
      }
      a /= 2;  //全部割れたら全要素に2で割った数を代入
    }
    if(finish){//フラグが立ってないからwhileが抜けられない？(多分)ここが知りたい。
      break;
    }
    counter++;
  }

  cout << counter << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
H = list(map(int, input().split()))

h = []
for i in H:
    h.append(i)
for i in range(M):
    a, b = map(int, input().split())
    if h[a-1] <= H[b-1] and h[a-1] != -1:
        h[a-1] = -1
    if h[b-1] <= H[a-1] and h[b-1] != -1:
        h[b-1] = -1

ans = N
for i in h:
    if i == -1:
        ans -= 1

print(ans)

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

num = int(input())
x = [str(input())]

for i in range(num-1):
    # 先頭の文字は直前に発言した単語の末尾の文字と一致するか
    saigo = x[-1]
    saigoMoji = saigo[-1]

    verStr = str(input())
    tugiMoji = verStr[0]

    if saigoMoji != tugiMoji:
        print("No")
        exit()

    #その単語はまだ発言していない単語であるか
    if verStr in x:
        print("No")
        exit()
    else:
        x.append(verStr)
print("Yes")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int a,b; cin>>a>>b;
  string s; cin>>s;
  bool c=1;
  rep(i,s.size()){
    if(i==a){
      if(s[a]!='-')
      c=0;
    }else{
      if(s[i]=='-')
      c=0;
    }
  }
  if(c)
  cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
from functools import reduce
import collections
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input())
    a = []
    d = collections.defaultdict(int)
    for i in range(N):
        a.append(int(input()))
        d[a[i]] +=1
    ans = 0
    for d_i in d.items():
        if d_i[1] % 2 ==1:
            ans +=1
    print(ans)
    
if __name__ == '__main__':
    main()


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

using namespace std; 

int main(){ 
  string s,t;
  cin>>s>>t;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]){
      cout<<"No";
      break;
    }
    if(i==s.size()-1){
      cout<<"Yes";
      break;
    }
  }
}

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

int main() {
  int n, k;
  cin >> n >> k;
  
  int s = 1, i = 0;
  while (s < k && i < n){
    s *= 2;
    i++;
  }
  while (s >= k && i < n) {
    s += k;
    i++;
  }
  
  cout << s << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
 
using namespace std;
 
int main(void)
{
    int n, m;
    cin >> n >> m;
    
    int a[n];
    int sum = 0;
    for(int i = 0; i < n; i ++)
    {
        cin >> a[i];
        sum += a[i];
    }
 
    int count = 0;
    for(int i = 0; i < n; i ++)
    {
        if (a[i] >= (sum / (4.0 * m)))
            count ++;
    }
 
    if (count >= m)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
 
    return 0;
}

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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC freopen("input.txt" , "r", stdin); freopen("output.txt" , "w", stdout) 
#define MOD (ll)1e9+7; //change it for other mods
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

ll powmod(ll a,ll b)
{
   ll res = 1;
   while(b > 0) {
      if(b & 1) res = (res * a) % MOD;
      a = (a*a)%MOD;
      b = b >> 1; 
  }
  return res % MOD;
}

void solve()
{
    ll h,n;
    cin >> h >> n;
    vll a(n);
    ll sum = 0;
    for(ll i=0;i<n;i++) {
    	cin >> a[i];
    	sum += a[i];
    }
    if(sum >= h) {
    	cout << "Yes\n";
    } else {
    	cout << "No\n";
    }
}

int main()
{
    FAST_IO;
    // #ifndef ONLINE_JUDGE 
    //   OC;
    // #endif
    ll t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 1024
import math
n=int(input())
j=int(math.sqrt(n))
k=[0]*n
for x in range(1,j+1):
     for y in range(1,j+1):
        for z in range(1,j+1):
            p=x**2+y**2+z**2+x*y+y*z+z*x
            if p<=n:
                k[p-1]+=1
[print(i)for i in k]

Measured memory_bytes: 74288
#include<stdio.h>
	
	int main(){
		int a,b,c,d;
		scanf("%d %d %d %d",&a,&b,&c,&d);
		while(a > 0 && c > 0){
			a = a - d;
			c = c - b;
			if(c <= 0){
				printf("Yes");
				break;
			}
			if(a <= 0){
				printf("No");
			}
		}
		
	}

Measured memory_bytes: 1728
//============================================================================
// Name        : C++_tosi01.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================


#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
  int m,n,a;
  cin >> m >> n;
  a = 0;
  switch (m) {
    case 2:
      if(n == 28) a = 1;
      break;
    case 4:
    case 6:
    case 9:
    case 11:
      if(n == 30) a = 1;
      break;

    default:
      if(n == 31) a = 1;
      break;
  }
  cout << a << endl;
}






































/*
#include <iostream>
#include <stdio.h>
using namespace std;


	int main();
	int sumTest(int e);



	int main() {
		cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!







		//sumTest(34);
		return 0;
	}

	int sumTest(int e){
		int a,b;
		cin >> a;
		cin >> b;
		a +=b;
		cout << a << endl;
		cout << a*e << endl;
		return 0;
	}
	*/



Measured memory_bytes: 256
#include <iostream>
#include <vector>
using i64 = long long;

int main() {
    int n, k;
    std::cin >> n >> k;
    std::vector<i64> a(n);
    for (auto &e : a) std::cin >> e;

    int l = 0, r = 1000000000;
    while (r - l > 1) {
        const int mid = (l + r) / 2;
        i64 s = 0;
        for (const auto e : a) {
            s += (e + mid - 1) / mid - 1;
        }
        if (s <= k) r = mid;
        else l = mid;
    }

    std::cout << r << std::endl;

    return 0;
}


Measured memory_bytes: 4752
from sys import stdin

def main():
    N = int(stdin.readline().rstrip())
    S = list(stdin.readline().rstrip())
    X = S[0]
    A = 1
    for i in range(1,N):
        if S[i] != X:
            A += 1
            X = S[i]
    print(A)

main()

Measured memory_bytes: 4084
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
	char s[100]={};
	int n,x=0,ans=0;
	scanf("%d\n",&n);
	scanf("%s",s);
	for(int i=0;i<n;i=i+1){
		if(s[i]=='I'){
			x=x+1;
		}else if(s[i]=='D'){
			x=x-1;
		}
		if(x>ans)ans=x;
	}
	printf("%d",ans);

}

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

int main()
{
    int n;
    cin >> n;
    vector<string> exists(n);
    for (int i=0; i<n; i++)
    {
        string mark;
        string num;
        string card;
        cin >> mark >> num;
        card = mark + " " + num;
        exists.at(i) = card;
    }

    vector<string> all_cards(52);
    vector<string> marks(4);
    marks = {"S", "H", "C", "D"};
    for (int i=0; i<4; i++)
    {
        string mark;
        mark = marks.at(i);
        for (int j=1; j<=13; j++)
        {
            string card;
            ostringstream oss;
            oss << j;
            card = mark + " " + oss.str();
            all_cards.at(13*i + j - 1) = card;
        }
    }

    for (int i=0; i<52; i++)
    {
        string card = all_cards.at(i);
        for (int j=0; j<n+1; j++)
        {
            if (j==n)
            {
                cout << card << endl;
                break;
            }
            else if (card == exists.at(j))
            {
                break;
            }
        }
    }
}



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




























int main () {
    int N;
    cin >> N;
    vector<unsigned> a(N);

    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }

    unsigned n = 0;
    for (int i = 0; i < N; i++) {
        n ^= a[i];
    }

    for (int i = 0; i < N; i++) {
        cout << (n ^ a[i]);
        if (i != N - 1) cout << " ";
        else cout << endl;
    }
}

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

int main() {
  int N, L;
  cin >> N >> L;
  vector<string> S(N);

  
  for (int i = 0; i < N; i++) cin >> S.at(i);
  
  sort(S.begin(), S.end());
      
  string ans = "";
  
  for (int i = 0; i < N; i++) ans += S.at(i);
      
  cout << ans << endl;
      
}

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


using namespace std;


int main()
{
    int a, b, c, k, ans = 0;

    cin >> a >> b >> c >> k;

    ans += min(k, a);

    if(a < k)
    {
        k -= a;
        k -= b;
        if(k > 0)
        {
            ans -= k;
        }
    }


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

Measured memory_bytes: 3636
#include <cstdio>
#include <cmath>
#include <cstring>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <set>
#include <functional>
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
struct Node {
	int val;
	Node *prev;
	Node *next;
	Node(int v) {
		val=v;
		prev=next=NULL;
	}
};
Node *head=NULL,*tail=NULL;
void add(int val) {
	Node *New=new Node(val);
	if(head==NULL) {
		head=tail=New;
	}else {
		tail->next=New;
		New->prev=tail;
		tail=New;
	}
}
void del(Node *node) {
	if(node->prev!=NULL) {
		node->prev->next=node->next;
	}else {
		head=node->next;
	}
	if(node->next!=NULL) {
		node->next->prev=node->prev;
	}else {
		tail=node->prev;
	}
	delete node;
}
bool OK[200000];
int main() {
	int N,M,Q;
	scanf("%d %d %d",&N,&M,&Q);
	for(int i=0;i<N;i++) {
		add(i);
	}
	Node *cur=head;
	for(int i=0;i<M;i++) {
		int a;
		scanf("%d",&a);
		if(a&1) {
			for(int i=0;i<a;i++) {
				cur=cur->prev;
				if(cur==NULL) cur=tail;
			}
			Node *tmp=cur;
			cur=cur->next;
			if(cur==NULL) cur=head;
			del(tmp);
		}else {
			for(int i=0;i<a;i++) {
				cur=cur->next;
				if(cur==NULL) cur=head;
			}
			Node *tmp=cur;
			cur=cur->next;
			if(cur==NULL) cur=head;
			del(tmp);
		}
	}
	for(Node *cur=head;cur!=NULL;cur=cur->next) {
		OK[cur->val]=1;
	}
	for(int i=0;i<Q;i++) {
		int q;
		scanf("%d",&q);
		printf("%d\n",OK[q]);
	}
}

Measured memory_bytes: 7444
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int a, b, t; cin>>a>>b>>t;
  cout<<t/a*b<<endl;
	return 0;
}

Measured memory_bytes: 892
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub
import re
sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A, B):
    if sum(A) < sum(B):
        return -1

    P = []
    M = []
    for i in range(N):
        d = A[i] - B[i]
        if d > 0:
            P.append(d)
        elif d < 0:
            M.append(d)

    P.sort()
    M.sort()

    c = 0
    ans = 0
    for m in M:
        while -m > c:
            c += P.pop()
            ans += 1
        c += m
        ans += 1

    return ans


def main():
    N = read_int()
    A = read_int_n()
    B = read_int_n()
    print(slv(N, A, B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 21464
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

char buffer[200];

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

  int32_t H, W;
  cin >> H >> W;
  vector<vector<char>> frame(H + 2, vector<char>(W + 2, '#'));
  for (int32_t i = 0; i < H; ++i) {
    string temp;
    cin >> temp;
    for (int32_t j = 0; j < W; ++j) {
      int32_t row = i + 1;
      int32_t column = j + 1;
      frame[row][column] = temp.c_str()[j];
    }
  }
  for (const auto &row : frame) {
    buffer[W + 2] = '\0';
    for (int32_t i = 0; i < W + 2; ++i) {
      buffer[i] = row[i];
    }
    string str(buffer);
    cout << str << endl;
  }

  return 0;
}


Measured memory_bytes: 256
N,M,Q=map(int,input().split())
L = []
for i in range(Q):
  L.append(list(map(int, input().split())))
  L[i][0]-=1
  L[i][1]-=1

import itertools
l =list(range(1,M+1))
v=list(itertools.combinations_with_replacement(l,N))
ans=0
for arr in v:
  score=0
  for a,b,c,d in L:
    if (arr[b] - arr[a])==c:      
      score+=d
  ans=max(ans,score)
print(ans)

Measured memory_bytes: 21624