akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>

int N = 10000;
int isprime(int);

int main(){
  
  int count=0,n,A[N],i;
  
  scanf("%d",&n);
  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
  for(i=0;i<n;i++){
    if(isprime(A[i])==1){
      count++;
    }
  }
  printf("%d\n",count);
  return 0;
}

int isprime(int A){
  int c1,c2,i;
  
  if(A == 2){ 
    return 1;
  }
  c1=A%2;
  if(A < 2 || c1==0){
    return 2;
  }
  i = 3;
  while(i <=sqrt(A)){
    c2=A%i;
    if(c2==0)
      return 2;
    i = i + 2;
  }
  return 1;
}

Measured memory_bytes: 628
#include <iostream>
#include <vector>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<vb> vmb;
typedef vector<vi> vmi;
typedef vector<vll> vmll;

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

    vi weight(n), value(n);
    for (int i = 0; i < n; ++i)
        cin >> weight[i] >> value[i];

    vmll dp(n + 1, vll(w + 1, 0));
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= w; ++j)
        {
            dp[i][j] = dp[i - 1][j];
            if (j >= weight[i - 1])
                dp[i][j] = max(dp[i][j], value[i - 1] + dp[i - 1][j - weight[i - 1]]);
        }
    }

    cout << dp[n][w];
    return 0;
}

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

int main(void) {
	int num, max, min, tem, point[200], flag;
	vector<int> ans;
	
	while (cin >> num >> min >> max, num && min && max) {
		tem = -1;
		flag = 0;
		for (int i = 1;i <= num;i++) {
			cin >> point[i];
		}
		for (int i = min;i <= max;i++) {
			if (tem <= point[i] - point[i + 1]) {
				tem = point[i] - point[i + 1];
				flag = i;
			}
		}
		ans.push_back(flag);
	}

	for (auto itr = ans.begin();itr != ans.end();itr++) {
		cout << *itr << endl;
	}

	return 0;
}


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

using namespace std;

int sq;

struct qu {
    int l, r, id;
};

bool cmp (qu q1, qu q2) {
    if (q1.l / sq != q2.l / sq) return q1.l / sq < q2.l / sq;
    return q1.r < q2.r;
}

void solve() {
    int n, q;
    cin >> n >> q;
    sq = (int) sqrt(n);
    vector <int> cnt(n);
    int c[n];
    for (int i = 0; i < n; ++i) {
        cin >> c[i];
        --c[i];
    }
    int ans[q];
    vector <qu> qs;
    for (int i = 0; i < q; ++i) {
        int l, r;
        cin >> l >> r;
        qu tq;
        tq.l = l - 1;
        tq.r = r - 1;
        tq.id = i;
        qs.push_back(tq);
    }
    sort(qs.begin(), qs.end(), cmp);
    int tans = 0;
    int l = 0, r = -1;
    for (int i = 0; i < q; ++i) {
        while (l > qs[i].l) {
            --l;
            ++cnt[c[l]];
            if (cnt[c[l]] == 1) ++tans;
        }
        while (r < qs[i].r) {
            ++r;
            ++cnt[c[r]];
            if (cnt[c[r]] == 1) ++tans;
        }
        while (l < qs[i].l) {
            --cnt[c[l]];
            if (cnt[c[l]] == 0) --tans;
            ++l;
        }
        while (r > qs[i].r) {
            --cnt[c[r]];
            if (cnt[c[r]] == 0) --tans;
            --r;
        }
        ans[qs[i].id] = tans;
    }
    for (int i = 0; i < q; ++i) cout << ans[i] << '\n';
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 15540
import java.util.Scanner;

public class Main {

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

        int N = sc.nextInt();
        int K = sc.nextInt();

        int result = 0;
        for (int i = 0; i < N; i++) {
            if (sc.nextInt() >= K) {
                result++;
            }
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 50176
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int w = sc.nextInt();
			int h = sc.nextInt();
			if(w==0 && h==0) break;
			
			char[][] map = new char[h][w];
			int[][] left = new int[h][w];
			int[][] right = new int[h][w];
			
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					map[i][j] = sc.next().charAt(0);
					left[i][j] = Integer.MAX_VALUE;
					right[i][j] = Integer.MAX_VALUE;
				}
			}
			
			for(int i=0;i<w;i++){
				if(map[h-1][i]=='S'){
					left[h-1][i] = 0;
					right[h-1][i] = 0;
				}
			}
			
			int ans = Integer.MAX_VALUE;
			while(true){
				boolean flag = false;
				for(int i=0;i<h;i++){
					for(int j=0;j<w;j++){
						if(left[i][j]!=Integer.MAX_VALUE){
							for(int p=-2;p<=2;p++){
								for(int q=1;q<=3-Math.abs(p);q++){
									if(0<=j+q && j+q<w && 0<=i+p && i+p<h){
										if(map[i+p][j+q]=='T' && ans>left[i][j]){
											ans = left[i][j];
											flag = true;
										}else if(map[i+p][j+q]=='S' || map[i+p][j+q]=='X'){
											continue;
										}else{
											if(left[i][j]+(int)map[i+p][j+q]-48 < right[i+p][j+q]){
												right[i+p][j+q] = left[i][j] + (int)map[i+p][j+q]-48;
												flag = true;
											}
										}
									}
								}
							}
						}
					}
				}
				
				for(int i=0;i<h;i++){
					for(int j=0;j<w;j++){
						if(right[i][j]!=Integer.MAX_VALUE){
							for(int p=-2;p<=2;p++){
								for(int q=1;q<=3-Math.abs(p);q++){
									if(0<=j-q && j-q<w && 0<=i+p && i+p<h){
										if(map[i+p][j-q]=='T' && ans>right[i][j]){
											ans = right[i][j];
											flag = true;
										}else if(map[i+p][j-q]=='S' || map[i+p][j-q]=='X'){
											continue;
										}else{
											if(right[i][j]+(int)map[i+p][j-q]-48 < left[i+p][j-q]){
												left[i+p][j-q] = right[i][j] + (int)map[i+p][j-q]-48;
												flag = true;
											}
										}
									}
								}
							}
						}
					}
				}
				
				if(flag==false) break;
			}
			if(ans==Integer.MAX_VALUE) System.out.println(-1);
			else System.out.println(ans);
		}
	}	
}

Measured memory_bytes: 70104
n, k, q = gets.split.map(&:to_i)
a = []
q.times do
  a << gets.to_i
end
i = Array.new(n, k-q)
a.each do |j|
  i[j-1]+=1
end
i.each_with_index do |l, num|
  if l>0
    i[num] = "Yes"
  else
    i[num] = "No"
  end
end
puts i

Measured memory_bytes: 21876
n = int(input())
a = map(int, input().split())

tmp_max = 0
springboards = []

for i in a:
    if tmp_max < i:
        tmp_max = i
        springboard = 0
    else:
        springboard = (tmp_max - i)

    springboards.append(springboard)
    # print(springboards)

print(sum(springboards))

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

vector<int> x(8),y(8) ;

double dist(int a,int b){


	int dx=x[a]-x[b] ;
	int dy=y[a]-y[b] ;

	return pow(dx*dx+dy*dy,0.5) ;

}


void solve(){

	int n ;
	cin>>n ;

	rep(i,n){
		cin>>x[i]>>y[i] ;
		//cout<<x[i]<<y[i] ;
	} 

	vector<int> v(n) ;

	rep(i,n)
	{
		v[i]=i ;
	}

	double sum=0 ;
	double factorial=1 ;

	do{

		for(int i=0;i<n-1;i++){
			sum+=dist(v[i],v[i+1]) ;
		}

		/*
		for(int i=0;i<n;i++){
			cout<<v[i]<<" " ;

		}
		cout<<"\n" ;
		*/
	
	}while(next_permutation(v.begin(),v.end())) ;


	for(int i=2;i<=n;i++){
		factorial*=i ;
	}

	cout<<setprecision(11)<<sum/factorial ;

}


int main(){


		int y ;

		y=1 ;
		//cin>>y ;

		while(y--){
 
			solve() ;

		}

}

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

int main(){
  string s,t;
  cin >> s >> t;
  int lens=(int)s.size(),lent=(int)t.size();
  vector<vector<int>> dp(lens+1,vector<int>(lent+1));
  for (int i = 0; i < lens; i++)
  {
    for (int j = 0; j < lent; j++)
    {
      if(s[i]==t[j]) dp[i+1][j+1] = dp[i][j]+1;
      else dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j]);
    }
  }
  
  string ans = "";
  while(lens>0 && lent>0){
    if(dp[lens][lent] == dp[lens-1][lent]) lens--;
    else if(dp[lens][lent] == dp[lens][lent-1]) lent--;
    else{
      ans = s[lens-1]+ans;
      lens--;
      lent--;
    }
  }
  cout << ans << endl;
}

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

const int64_t MOD=1000000007;

int main(){
  int N;
  cin>>N;
  
  int64_t ans=1;
  map<int64_t,int64_t> S;
  for(int i=0;i<N;++i){
    int64_t a;
    cin>>a;
    if(a==0){
      ans = ans*(3-S[0])%MOD;
      ++S[0];
    }
    else{
      ans = ans*(S[a-1]-S[a])%MOD;
      ++S[a];
    }
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <deque>

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

using namespace std;
using P = pair<int, int>;

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

int main(void){
    /*
    BFSで解くよ
    スタートからいけるところに「0」を書く
    いけなくなったら，「0」からいけるところに「1」を書く
    01-BFS　コストが0と1しかないので　それ以外ならダイクストラを使う
    01-BFSを実現するためには，deque（デック）を使うといい　ダイクストラはデータのプッシュにO(log N)かかっちゃうのでdequeで
    */

    int h, w;
    cin >> h >> w;
    int ch, cw, dh, dw;
    cin >> ch >> cw;
    cin >> dh >> dw;
    ch--; cw--; dh--; dw--;

    vector<string> s(h);
    REP(i,h) cin >> s[i];

    const int INF = 1e9;
    vector< vector<int> > dist(h, vector<int>(w, INF));

    deque< P > q;
    dist[ch][cw] = 0;
    //pair<int, int> p = make_pair(ch, cw);
    q.emplace_back(ch, cw); //emplace_backはほとんどpush_back
    //q.push_back(p);

    while(!q.empty()){
        // 前から取り出す
        int i = q.front().first;
        int j = q.front().second;
        q.pop_front();
        int d = dist[i][j];

        // コスト0の移動
        REP(dir, 4){
            int newi = i + dx[dir], newj = j + dy[dir];
            if(newi < 0 || newi >= h || newj < 0 || newj >= w) continue;
            if(s[newi][newj] == '#') continue;

            //そもそも距離が更新できないなら遷移する意味ない
            if(dist[newi][newj] <= d) continue;

            dist[newi][newj] = d;
            //pair<int, int> p = make_pair(newi, newj);
            q.emplace_front(newi, newj);
            //q.push_front(p);
        }

        //コスト1の移動
        for(int ei = -2; ei <= 2; ei++){
            for(int ej = -2; ej <= 2; ej++){
                int newi = i + ei, newj = j + ej;

                if(newi < 0 || newi >= h || newj < 0 || newj >= w) continue;
                if(s[newi][newj] == '#') continue;

                if(dist[newi][newj] <= d+1) continue;

                dist[newi][newj] = d+1;
                //pair<int, int> p = make_pair(newi, newj);
                q.emplace_back(newi, newj);
                //q.push_back(p);
            }
        }
    }

    int ans = dist[dh][dw];
    if(ans == INF) ans = -1;
    cout << ans << endl;
    
    return 0;
}


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

const int INF = 1e9;

struct R {
    int h1, w1, h2, w2;
    R() : h1(INF), w1(INF), h2(-INF), w2(-INF) {}
    void update(int h, int w) {
        h1 = min(h1, h);
        w1 = min(w1, w);
        h2 = max(h2, h);
        w2 = max(w2, w);
    }
    void print() {
        cout << h1 << " " << w1 << " " << h2 << " " << w2 << endl;
    }
};

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

    int T;
    cin >> T;
    rep(testcase, T) {
        int H, W;
        cin >> H >> W;
        vector<string> s(H);
        set<char> itemset;
        rep(i, H) {
            cin >> s[i];
            rep(j, W) {
                if (s[i][j] != '.') {
                    itemset.insert(s[i][j]);
                }
            }
        }

        if (itemset.empty()) {
            cout << "SAFE" << endl;
            continue;
        }

        map<char, R> mprect;
        for (auto c : itemset) {
            R r;
            rep(i, H) rep(j, W) {
                if (s[i][j] == c) {
                    r.update(i, j);
                }
            }
            mprect[c] = r;
        }

        vector<char> items(all(itemset));
        auto check = [&]{
            sort(all(items));
            do {
                vector<string> t(H, string(W, '.'));

                for (auto c : items) {
                    auto r = mprect[c];
                    rep2(i, r.h1, r.h2 + 1) rep2(j, r.w1, r.w2 + 1) {
                        t[i][j] = c;
                    }
                }

                if (s == t) {
                    cout << "SAFE" << endl;
                    return true;
                }
            } while (next_permutation(all(items)));
            return false;
        };

        if (!check()) {
            cout << "SUSPICIOUS" << endl;
        }

    }

}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
  int N,K;
  string S;
  cin>>N>>K>>S;
  if(S[K-1]=='A'){
      S[K-1]='a';
  }
  else if(S[K-1]=='B'){
      S[K-1]='b';
  }
  else{
      S[K-1]='c';
  }
  cout<<S<<endl;
  
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
long long n, k, p(1);
int main() {
    DAU
    cin >> n >> k;
    for (int i = 1 ;; ++i) {
        p *= k;
        if (p > n) {
            cout << i;
            PLEC
        }
    }
    PLEC
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

#define n 10000

int isPrime(void);

int main()
{
    int i, cnt, Pricnt = 0;
    
    scanf("%d", &cnt);
    
    for(i=0;i<cnt;i++)
    {
        if(isPrime()==1)Pricnt++;
    }
    
    printf("%d\n", Pricnt);
    
    return 0;
}

int isPrime()
{
    int i;
    int x=0;

    scanf("%d", &x);
    
    if(x == 2)return 1;
    if(x < 2 || x%2 == 0)return 0;
    
    i=3;
    while(i <= sqrt(x))
    {
        if(x%i==0)return 0;
        i = i+2;
    }
    return 1;
}




Measured memory_bytes: 2128
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t; cin>>t; while(t--)
using namespace std;
int main() 
{ 
    ll n,res=0;
    cin>>n;
    for(ll i=1; i<=n; i++){
    	if((i%3!=0&&i%5!=0)&&i%3!=0&&i%5!=0){
    		res+=i;
    	}
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define MAX 100005
using namespace std;

typedef long long ll;

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //#ifndef ONLINE_JUDGE
    //    freopen("input.txt", "r", stdin);
    //    freopen("output.txt", "w", stdout);
    //#endif
    ll n, m;
    ll Min = 1e18;
    cin>>n;
    int idx;
    for(int i = 1; i <= 5; i++){
        cin>>m;
        if(m < Min){

            Min = m;
            idx = i;
        }
    }

    if(Min >= n){
        cout<<5<<endl;
        return 0;
    }
    ll temp;
    if(n % Min == 0)
        temp = n / Min;
    else
        temp = (n / Min) + 1;
    ll ans = (idx + temp - 1);
    ans += 5 - idx;

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int taxi = N * A;

		System.out.println(Math.min(taxi, B));
	}

}


Measured memory_bytes: 21844
// DFS

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPS(i,n) for(int i=1;i<=(int)(n);i++)
using namespace std;
using ll = long long;
using ld = long double;

int P[8], Q[8];
int a, b;

int cnt = 0;
vector<int> permutation;
void dfs(int depth, const int N) {
    if (depth == N) {
        cnt++;
        bool flg_P = true, flg_Q = true;
        REP (i, N) {
            if (permutation.at(i) != P[i]) {
                flg_P = false;
            }
            if (permutation.at(i) != Q[i]) {
                flg_Q = false;
            }
        }
        if (flg_P) {
            a = cnt;
        }
        if (flg_Q) {
            b = cnt;
        }
    }
    else {
        REP (i, N) {
            bool ok = true;
            if (depth) {
                for (int j = 0; j < depth; j++) {
                    if (i == permutation.at(j)) {
                        ok = false;
                    }
                }
            }
            if (ok) {
                permutation.push_back(i);
                dfs(depth+1, N);
            }
        }
    }
    permutation.pop_back();
}

int main(void) {
    int N;
    cin >> N;
    REP (i, N) {
        cin >> P[i];
        P[i]--;
    }
    REP (i, N) {
        cin >> Q[i];
        Q[i]--;
    }

    dfs(0, N);
    int ans = abs(a-b);
    cout << ans << endl;
}

Measured memory_bytes: 256
// general helpers
const debug = (message?: any, ...optionalParams: any[]) => {
  if (process.env.LOCAL_DEBUG === '1') console.log(message, ...optionalParams)
}

// helpers
const parseLines = (
  lines: string[]
): any => {
  const [N, A, B] = lines[0].split(' ')
  const obj = { N, A, B }
  debug(obj)
  return obj
}

// solver
export const solve = (lines: string[]): string => {
  const { N, A, B } = parseLines(lines)
  let result = 0
  for (let i = 1; i <= N; i++) {
    const digitSum = `${i}`.split("").reduce((prev, current) => prev += +current, 0)
    if (A <= digitSum && digitSum <= B) {
      result += i
    }
  }
  return `${result}`
}

// main
const main = (lines: string[]) => {
  console.log(solve(lines))
}

// exec main function for submit
if (process.env.LOCAL_DEBUG !== '1') {
  const { stdin: input, stdout: output } = process
  input.resume()
  input.setEncoding('utf8')
  const lines: string[] = []
  require('readline')
    .createInterface({ input, output })
    .on('line', (line: string) => lines.push(line))
    .on('close', () => main(lines))
}


Measured memory_bytes: 9624
import java.util.Scanner;
 
 
class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        
        int x = stdIn.nextInt();
        int y = stdIn.nextInt();
        
        if (x == 2)
            System.out.println("No");
        else if (x == 4 || x == 6 || x == 9 || x == 11)
            if (y == 4 || y == 6 || y == 9 || y == 11)
                System.out.println("Yes");
            else
                System.out.println("No");
        else if (x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12)
            if (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12)
                System.out.println("Yes");
            else 
                System.out.println("No");        
    }
}

Measured memory_bytes: 22608
import numpy as np
import copy


def main():
    N, K = map(int, input().split())
    x = np.empty((N, 2), dtype=np.int)
    for i in range(N):
        a, b = map(int, input().split())
        x[i, 0] = a
        x[i, 1] = b

    sort_idx = np.argsort(x[:, 0])
    x = x[sort_idx]
    cum_sum = np.cumsum(x[:, 1])
    idx = np.argwhere(cum_sum >= K)[0]

    print(int(x[:, 0][idx]))


if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

bool used[51][51][51][51];
string roomL[51], roomR[51];

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  while (true) {
    int R, C;
    cin >> C >> R;
    if (R == 0 && C == 0) break;
    REP(i, R) cin >> roomL[i] >> roomR[i];

    int slr = 0, slc = 0, elr = 0, elc = 0, srr = 0, src = 0, err = 0, erc = 0;
    REP(r, R) REP(c, C) {
      if (roomL[r][c] == 'L') slr = r, slc = c;
      if (roomR[r][c] == 'R') srr = r, src = c;
      if (roomL[r][c] == '%') elr = r, elc = c;
      if (roomR[r][c] == '%') err = r, erc = c;
    }
    //cout << slr << ' ' << slc << ' ' << elr << ' ' << elc << ' ' << srr << ' ' << src << ' ' << err << ' ' << erc << endl;
    REP(i, R) REP(j, C) REP(k, R) REP(l, C) used[i][j][k][l] = false;
    
    queue<P> que;
    que.push(P(slr * C + slc, srr * C + src));

    bool flag = false;
    while (!que.empty()) {
      P p = que.front(); que.pop();
      int lr = p.first / C, lc = p.first % C, rr = p.second / C, rc = p.second % C;
      //cout << lr << ' ' << lc << ' ' << rr << ' ' << rc << endl;
      if (lr == elr && lc == elc && rr == err && rc == erc) {
	flag = true;
	break;
      } else if (used[lr][lc][rr][rc] || (lr == elr && lc == elc) || (rr == err && rc == erc)) {
	continue;
      }

      used[lr][lc][rr][rc] = true;
      REP(i, 4) {
	int nlr = lr + dr[i], nlc = lc + dc[i], nrr = rr + dr[(i+2*(i&1))%4], nrc = rc + dc[(i+2*(i&1))%4];
	if (nlr < 0 || nlr >= R || nlc < 0 || nlc >= C || roomL[nlr][nlc] == '#') nlr = lr, nlc = lc;
	if (nrr < 0 || nrr >= R || nrc < 0 || nrc >= C || roomR[nrr][nrc] == '#') nrr = rr, nrc = rc;
	que.push(P(nlr * C + nlc, nrr * C + nrc));
      }
    }
    cout << (flag ? "Yes" : "No") << endl;    
  }
  return 0;
}

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

const int N = 2e5 + 5;
int arr[N];
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    map<string, string> mm;
    mm["Sunny"] = "Cloudy";
    mm["Cloudy"] = "Rainy";
    mm["Rainy"] = "Sunny";
    string s;
    cin >> s;
    cout << mm[s];
    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()
    res = ""
    cnt = 0
    for i in range(len(s)):
        if i == 0:
            res += s[i]
        elif i == len(s) - 1:
            res += str(cnt) + s[i]
        else:
            cnt += 1

    print(res)



if __name__ == '__main__':
    resolve()


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

int main() {
    int h[7],w[7];
    int hantei1=0,hantei2=0,hantei3=0;
    int cnt1=0,cnt2=0,cnt3=0;
    int test1=0,test2=0,test3=0;
    bool flg = true;
    int sqrcnt=0;
    
    long long temp=0;

    for (int i=1 ; i<=6 ;i++) {
        cin >> h[i] >> w[i];

        if (h[i] == w[i]) sqrcnt++;


        if ((test1 != h[i] && test2 != h[i] && test3 != h[i]) &&
            (test1 != 0 && test2 != 0 && test3 != 0)
        ) {
            flg =false;
        }
        else {
            if (test1 == 0) {
                test1 = h[i];
            } else if (test2 == 0 && test1 != h[i]) {
                test2 = h[i];
            } else if (test3 == 0 && test1 != h[i] && test2 != h[i]) {
                test3 = h[i];
            }
        }

        if ((test1 != w[i] && test2 != w[i] && test3 != w[i]) && 
            (test1 != 0 && test2 != 0 && test3 != 0)
        ) {
            flg =false;
        }
        else {
            if (test1 == 0) {
                test1 = w[i];
            } else if (test2 == 0 && test1 != w[i]) {
                test2 = w[i];
            } else if (test3 == 0 && test1 != w[i] && test2 != w[i]) {
                test3 = w[i];
            }
        }


        temp = pow(h[i],2) + pow(w[i], 2);

        if (hantei1 == temp) cnt1++;
        else if (hantei2 == temp) cnt2++;
        else if (hantei3 == temp) cnt3++;
        else {
        if (hantei1 == 0) {
            hantei1 = temp;
            cnt1++;
        }
        else if (hantei2 == 0) {
            hantei2 = temp;
            cnt2++;
        }
        else if (hantei3 == 0) {
            hantei3 = temp;
            cnt3++;
        }

        }

    }

    if (sqrcnt >= 2 && test3 != 0) {
        flg = false;
    } else if (test3 == 0 && sqrcnt < 2) {
        flg = false;
    }
    else if (sqrcnt >= 4 && test3 != 0 && test2 != 0) {
        flg = false;
    }

    if ((cnt1 % 2 ==0 && cnt2 % 2 ==0 && cnt3 % 2 ==0) && flg) {
        cout << "yes" << endl;
    } else {
        cout << "no" << endl;
    }

    

    return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int>P;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int n,Ma,Mb;
const int Maxn=45;
int a[Maxn],b[Maxn],c[Maxn],p[Maxn];
const int BS=10005;
int dp[Maxn][2*BS];
int main(){
	scanf("%d%d%d",&n,&Ma,&Mb);
	memset(dp,INF,sizeof(dp));
	for(int i=1;i<=n;i++){
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
		p[i]=Mb*a[i]-Ma*b[i];
		dp[i][BS+p[i]]=c[i];
	}
	rep(i,n)rep(w,2*BS){
		if(w+p[i+1]>=0&&w+p[i+1]<2*BS){
			chkmin(dp[i+1][w+p[i+1]],dp[i][w+p[i+1]]);
			chkmin(dp[i+1][w+p[i+1]],dp[i][w]+c[i+1]);
		}
	}
	if(dp[n][BS]==INF)cout<<-1<<endl;
	else cout<<dp[n][BS]<<endl;
	return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<P> a(n);
	REP(i,n) cin>>a[i].first;
	vector<P> b(n);
	REP(i,n) {
		b[i].first=a[i].first;
		b[i].second=i;
	}
	sort(ALL(b));
	REP(i,n) {
		a[b[i].second].second=i;
	}
	ll cnt=0;
	REP(i,n) {
		if(i%2!=a[i].second%2) ++cnt;
	}
	cout<<cnt/2<<endl;
}


Measured memory_bytes: 3456
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define speedX ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout<< name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_time() cout << "\n\nTime of execution: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define trace(...)
#define end_time()
#endif


#define int long long 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
inline bool equals(ld a, ld b) {return fabs(a - b) < 1e-9;}
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define mod 1000000007


void solve(){
	int n;
	cin>>n;
	vector<int> v;
	for(int i = 0; i<n; i++){
		v.pb(i+1);
	}
	vector<int> a,b;
	for(int i = 0; i<n; i++){
		int x;
		cin>>x;
		a.pb(x);
	}
	for(int i = 0; i<n; i++){
		int x;
		cin>>x;
		b.pb(x);
	}
	int c,d;
	int cnt = 0;
	do{
		cnt++;
		bool e=true,f  = true;
		for(int i = 0; i<n; i++){
			if(v[i]!=a[i]){
				e = false;
				break;
			}
		}
		for(int i = 0; i<n; i++){
			if(v[i]!=b[i]){
				f = false;
				break;
			}
		}
		if(e) c = cnt;
		if(f) d = cnt;
	}while(next_permutation(all(v)));
	cout<<abs(c-d)<<"\n";
}
signed main(){
	speedX;
	#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	end_time();
	return 0;
}

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

#define REP(i, a, b) for(LL i = a; i <= b; i ++)
#define REPG(i, x) for(LL i = head[x]; i; i = g[i].nxt)

#define clr(x, y) memset(x, y, sizeof(x));

using namespace std;

typedef long long LL;
typedef double LF;

LL Max(LL a, LL b){return a > b ? a : b;}
LL Min(LL a, LL b){return a < b ? a : b;}
LL abs(LL x){return x > 0 ? x : -x;}

const LL MAXN = 1e5 + 15;

LL shun1[MAXN], shun2[MAXN], ni1[MAXN], ni2[MAXN], n, c, x[MAXN], v[MAXN], dist[MAXN], tshun[MAXN], tni[MAXN];

inline LL read(){
	LL r = 0, z = 1; char ch = getchar();
	while(ch < '0' || ch > '9'){if(ch == '-') z = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9'){r = r * 10 + ch - '0'; ch = getchar();}
	return r * z;
}

void work(){
	n = read(), c = read();
	for(LL i = 1; i <= n; i ++) x[i] = read(), v[i] = read();
	for(LL i = 1; i <= n; i ++) dist[i] = dist[i - 1] + v[i], shun1[i] = dist[i] - x[i], shun2[i] = shun1[i] - x[i];
	for(LL i = n; i; i --) dist[i] = dist[i + 1] + v[i], ni1[i] = dist[i] - (c - x[i]), ni2[i] = ni1[i] - (c - x[i]);
	LL ans = 0;
	for(LL i = 1; i <= n; i ++) tshun[i] = max(tshun[i - 1], shun1[i]);
	for(LL i = n; i; i --) tni[i] = max(tni[i + 1], ni1[i]);
	for(LL i = 1; i <= n; i ++) ans = max(ans, shun2[i] + tni[i + 1]), ans = max(ans, shun1[i]);
	for(LL i = n; i; i --) ans = max(ans, ni2[i] + tshun[i - 1]), ans = max(ans, ni1[i]);
	printf("%lld\n", ans);
}

int main(){
	work();
	return 0;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int N,T;

vector< P > t;

int main(){
  cin>>N>>T;
  for(int i=0;i<N;i++){
    int l,r;
    cin>>l>>r;
    t.push_back( P(l,1) );
    t.push_back( P(r,-1) );
  }
  sort(t.begin(),t.end());
  int sum=0;
  int ans=0;
  for(int i=0;i<N+N;i++){
    sum+=t[i].second;
    ans=max(ans,sum);
  }
  cout<<ans<<endl;
  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef pair<ld,ld> id;

#define FOR(i, a, b) for(int i=(a); i<=(b); i++)
#define ROF(i, a, b) for(int i=(a); i>=(b); i--)
#define MEM(x, v) memset(x, v, sizeof(x))
#define FILL(x, n, v) fill(x, x+n, v);
#define ALL(x) x.begin(), x.end()
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define f first
#define s second
#define ins insert
#define e emplace
#define eb emplace_back
#define ef emplace_front
#define p push
#define pf push_front
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ft front
#define bk back
#define pp pop
#define ppb pop_back
#define ppf pop_front

#define db cout<<"YEET\n";
#define ct(x) cout<<x<<'\n';

const ll MOD = 1e9+7; //998244353
const ll MAXN = 2e5+5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);

int main(){
    FAST
    ll n;
    cin >> n;
    ll ans=0;
    FOR(i,1,n){
        FOR(j,1,n){
            FOR(k,1,n){
                ans+=__gcd(i,__gcd(j,k));
            }
        }
    }
    cout << ans;
}

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

int main()
{
  string s,ans;
  cin>>s;
  int i=0;
  bool flag=0;
  while(s[i]!='\0'){
    if(i%2==0&&s[i]=='L'){
      flag=1;break;
    }
    else if(i%2==1&&s[i]=='R'){
      flag=1;break;
    }
    i++;
  }
  if(flag==0){
    ans="Yes";
  }
  else{
    ans="No";
  }
  cout<<ans<<endl;
  return 0;
}


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

long long MOD = 1000000007ll;

int main() {
  long long n, m;
  cin >> n >> m;
  vector<int> s(n), t(m);
  for(int i=0;i<n;i++) cin >> s[i];
  for(int i=0;i<m;i++) cin >> t[i];

  vector< vector<long long> > ans(n + 1, vector<long long>(m + 1, 0ll));
  for(int i=0;i<n;i++) {
    for(int j=0;j<m;j++) {
      ans[i][j] = 0;
    }
  }

  for(int i=1;i<n+1;i++) {
    for(int j=1;j<m+1;j++) {
      ans[i][j] = ans[i-1][j] + ans[i][j-1] - ans[i-1][j-1] + MOD;

      if(s[i-1] == t[j-1]) {
        ans[i][j] += ans[i-1][j-1] + 1;
      }
      ans[i][j] %= MOD;

    }
  }

  cout << (ans[n][m] + 1) % MOD << endl;
}


Measured memory_bytes: 31616
n = int(input())
height_list = list(map(int, input().split()))

need_height = height_list[0]
total_need_step = 0

for i in range(1, len(height_list)):
    if height_list[i] < need_height:
        degree = need_height - height_list[i]
        total_need_step += degree
    else:
        need_height = height_list[i]

print(total_need_step)

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

int n, c[500], s[500], f[500];

int main(){
    scanf("%d", &n);
    rep(i,n-1) scanf("%d%d%d", &c[i], &s[i], &f[i]);

    rep(i,n){
        int t = 0;
        for(int j = i; j < n-1; j++){
            if(t < s[j]) t = s[j];
            else if(t%f[j] == 0);
            else t = t + f[j] -t%f[j];
            t+= c[j];
        }
        printf("%d\n", t);
    }
}


Measured memory_bytes: 256
def main():
    n = list(map(int,list(input())))
    if n[0]+n[1]+n[2]+n[3] == 7:
        print(str(n[0])+"+"+str(n[1])+"+"+str(n[2])+"+"+str(n[3])+"=7")
    elif n[0]+n[1]+n[2]-n[3] == 7:
        print(str(n[0])+"+"+str(n[1])+"+"+str(n[2])+"-"+str(n[3])+"=7")
    elif n[0]+n[1]-n[2]-n[3] == 7:
        print(str(n[0])+"+"+str(n[1])+"-"+str(n[2])+"-"+str(n[3])+"=7")
    elif n[0]-n[1]-n[2]-n[3] == 7:
        print(str(n[0])+"-"+str(n[1])+"-"+str(n[2])+"-"+str(n[3])+"=7")
    elif n[0]+n[1]-n[2]+n[3] == 7:
        print(str(n[0])+"+"+str(n[1])+"-"+str(n[2])+"+"+str(n[3])+"=7")
    elif n[0]-n[1]-n[2]+n[3] == 7:
        print(str(n[0])+"-"+str(n[1])+"-"+str(n[2])+"+"+str(n[3])+"=7")
    elif n[0]-n[1]+n[2]+n[3] == 7:
        print(str(n[0])+"-"+str(n[1])+"+"+str(n[2])+"+"+str(n[3])+"=7")
    elif n[0]-n[1]+n[2]-n[3] == 7:
        print(str(n[0])+"-"+str(n[1])+"+"+str(n[2])+"-"+str(n[3])+"=7")
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3192
//#include "pch.h"
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <math.h>
#define OO INT_MAX
#define mp(x,y) make_pair(x,y)
#define x first
#define y second
#define ll unsigned long long int
#define pp pair<int,int>
#define heap priority_queue<pp, vector<pp>, greater<pp>>
using namespace std;

int ans;
string  s;
string s1;
void check(string str, int i) {
	if (i == s.size()) {
		if (str == "ABC")
			ans++;
		return;
	}
	s1 = str;
	check(s1,i+1);
	s1 = str + s[i];
	check(s1, i + 1);
}

int main()
{
//	freopen("test.txt", "r", stdin);

	int n;
	cin >> n;
	string s(n,'o');
	cin >> s;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if ((i+1<n && i+2<n) && (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C'))
			ans++;
	}
	cout << ans;
}




Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int h,w,i,j;
	
	while(1){
		scanf("%d %d",&h,&w);
		if(h==0&&w==0){
			break;
		}
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	N=S.size();
	if(S[N-1]=='1') return _P("-1\n");
	if(S[0]=='0') return _P("-1\n");
	for(i=1;i<=N-1;i++) if(S[i-1]!=S[N-1-i]) return _P("-1\n");
	S[N-1]='1';
	
	int pre=N;
	for(i=N-1;i>=1;i--) {
		cout<<i<<" "<<pre<<endl;
		if(S[i-1]=='1') pre=i;
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 1616
#ifndef __cplusplus
    cat << EOF
#endif
#include <bits/stdc++.h>
using namespace std;

#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define rep_0(i, end) for(int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for(int i = (fr); i <= (ba); ++i)
#define overload_rep(arg0, arg1, arg2, name, ...) name
#define all(box) box.begin(), box.end()

template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if(lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if(lhs > rhs) { lhs = rhs; return 1; } return 0; }

int N, U, V;
int aokidepth[100000], takdist[100000], aokidist[100000];
bool came[100000], cango[100000];
vector<int> graph[100000];

void takdfs(int v, int p, int c) {
    takdist[v] = c;
    came[v] = true;
    for(int x : graph[v]) {
        if(x == p || x == V) continue;
        takdfs(x, v, c + 1);
    }
}

void aokidfs(int v, int p, int c) {
    aokidist[v] = c;
    aokidepth[v] = c;
    if(aokidist[v] > takdist[v]) cango[v] = true;
    for(int x : graph[v]) {
        if(x == p) continue;
        aokidfs(x, v, c + 1);
    }
}

int main() {

    cin >> N >> U >> V;
    --U, --V;

    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    takdfs(U, U, 0);
    aokidfs(V, V, 0);

    int ans = 0;
    rep(v, N) if(cango[v] && came[v]) {
        chmax(ans, aokidepth[v]);
    }
    cout << ans - 1 << '\n';

}


Measured memory_bytes: 10880
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    unordered_set<char> appeared;
    for (const char c : S) {
        appeared.emplace(c);
    }
    for (char c = 'a'; c <= 'z'; c++) {
        if (appeared.find(c) == appeared.end()) {
            cout << c << "\n";
            return 0;
        }
    }
    cout << "None" << "\n";
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+5;
const ll inf = 0x3f3f3f3f3f3f3f3f;
ll city[N], tower[N];
int main()
{
#ifdef LOCAL
//    freopen("in.txt", "r", stdin);
#endif // LOCAL
    int x, y;
    scanf("%d%d", &x, &y);
    printf("%s\n", abs(x-y)<=1?"Brown":"Alice");
    return 0;
}


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

int N,K;
int D[9];

bool iroha(int x){
  int nlen=to_string(x).size();
  for(int j=0; j<nlen; j++){
    for(int i=0; i<K; i++){
      if(x%10==D[i]){
        return false;
      }
    }
    x/=10;
  }
  return true;
}

int main(){
  cin >> N >> K;
  for(int i=0; i<K; i++){
    cin >> D[i];
  }
  bool kirai=true;
  do{
    if(iroha(N)==true){
      kirai=false;
    }else{
      N++;
    }
  }while(kirai);
  cout << N << endl;
}

Measured memory_bytes: 256
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
from bisect import bisect_left

def main():
    n = II()
    aa = MII()
    if n == 2: print(*aa); exit(0)
    aa.sort()
    ans_n = aa[-1]
    m = ans_n/2
    idx = bisect_left(aa, m+1)
    ans_r = aa[idx] if idx!=n-1 else aa[idx-1]
    if abs(aa[idx]-m) > abs(aa[idx-1]-m):
        ans_r = aa[idx-1]
    print(ans_n, ans_r, end= ' ')

if __name__ == '__main__':
    main()


Measured memory_bytes: 14056
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<cstdlib>
#include<math.h>
//#include<iostream>
using namespace std;

int n,m,d;
#define maxn 111
int col[maxn*maxn];
int ans[maxn][maxn];
int main()
{
	scanf("%d%d%d",&n,&m,&d);
	for (int i=1;i<=d;i++) scanf("%d",&col[i]);
	int x=1,y=1;
	for (int i=1;i<=d;i++)
		while (col[i]--)
		{
			ans[x][y]=i;
			if (x&1) y++;else y--;
			if (y>m) {x++;y=m;}
			if (y<1) {x++;y=1;}
		}
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++)
			printf("%d ",ans[i][j]);puts("");}
	return 0;
}

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


typedef long long ll;
#define reg register
#define rep(a,b,c) for(reg int a=b,a##end=c;a<=a##end;++a)
#define drep(a,b,c) for(reg int a=b,a##end=c;a>=a##end;--a)

char IO;
int rd(){
	int s=0,f=0;
	while(IO=getchar(),IO<'0'||IO>'9')if(IO=='-')f=1;
	do s=(s<<1)+(s<<3)+(IO^'0');
	while(IO=getchar(),IO>='0'&&IO<='9');
	return f?-s:s;
}


const int N=100+10,K=20;

int n,m;
int a[N][N];


int main(){
	int l=rd(),r=rd();
	if(r/2019-l/2019>0) return puts("0"),0;
	ll ans=2018;
	rep(i,l,r) rep(j,i+1,r) ans=min(ans,1ll*i*j%2019);
	cout<<ans<<endl;
}















Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
// #include <iomanip>
// std::cout << std::fixed << std::setprecision(5);

int main()
{
    bool a[3] = {false};
    for(int i=0; i<2; i++)
    {
        int temp;
        std::cin >> temp;
        a[temp-1] = true;
    }

    for(int i=0; i<3; i++)
    {
        if(a[i] == false) std::cout << i+1 << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns        #-}
{-# LANGUAGE FlexibleContexts    #-}
{-# LANGUAGE MultiWayIf          #-}
{-# LANGUAGE RankNTypes          #-}
{-# LANGUAGE ScopedTypeVariables #-}
import           Control.Monad.State
import qualified Data.ByteString.Char8 as BS
import           Data.Char
import           Data.List

main :: IO ()
main = do
  _ <- getLine
  (h:hs) <- readLnAsListWith unconsInt

  print $ solve h hs

solve :: Int -> [Int] -> Int
solve h hs = go hs h 0 20000
  where go [] _ a b       = min a b

        go [x] n a b      = let a' = a + (abs $ n - x)
                            in go [] x (min b a') b

        go (x:y:xs) n a b = let a' = a + (abs $ n - x)
                                b' = a + (abs $ n - y)
                            in go (y:xs) x (min b a') b'


unconsInt :: StateT BS.ByteString Maybe Int
unconsInt = StateT $ BS.readInt . BS.dropWhile isSpace

readLnAsListWith :: StateT BS.ByteString Maybe a -> IO [a]
readLnAsListWith !st = unfoldr (runStateT st) <$> BS.getLine



Measured memory_bytes: 5932
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

// ----------- VECTOR ------------
template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}
// ----------- VECTOR ------------

int main() {
  int N, K; cin >> N >> K;
  vector<bool> b(N, false);
  for (int i = 0; i < K; ++i) {
    int d; cin >> d;
    vector<int> A(d); cin >> A;
    for (int i : A) {
      b[i-1] = true;
    }
  }

  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    if (!b[i]) ++cnt;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<iomanip>
#include<cmath>
#include<tuple>
#include<queue>
#include<algorithm>
 
int const MAXN = 50;
double const INF = 1e9;
double const eps = 5e-7;
int x[MAXN], y[MAXN], N;
 
double min_possible(double cx, double cy, double r) {//input//
  double res = 0.0;
  for(int i = 0; i < N; ++i) {
    double dx = x[i] - cx, dy = y[i] - cy;
    dx = std::max(std::fabs(dx) - r, 0.0);
    dy = std::max(std::fabs(dy) - r, 0.0);
    res = std::max(res, dx*dx + dy*dy);
  }
  return std::sqrt(res);
}
 
double calc(double cx, double cy) {
  double res = 0.0;
  for(int i = 0; i < N; ++i) {
    double dx = x[i] - cx, dy = y[i] - cy;
    res = std::max(res, dx*dx + dy*dy);
  }
  return std::sqrt(res);
}
 
int main() {
  std::cin >> N;
  for(int i = 0; i < N; ++i) std::cin >> x[i] >> y[i];
  
  std::queue<std::tuple<double, double, double>> q;
  double ans = INF;
  q.emplace(500.0, 500.0, 500.0);
  while(q.size()>0) {
    double xx, yy, rr; 
    std::tie(xx, yy, rr) = q.front(); q.pop();
    double d = min_possible(xx, yy, rr);
    if(d >= ans - eps*std::max(d, 1.0)) continue; // cut-off no improve
    ans = std::min(ans, calc(xx, yy));
    for(double rx: {-0.5, 0.5}) for(double ry: {-0.5, 0.5}) {
      q.emplace(xx+rx*rr, yy+ry*rr, rr*0.5);
    }
  }
  std::cout << std::setprecision(10) << std::fixed << ans << std::endl;
  return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S, std::string T){
    auto n=S.length();
    for(int i=0; i<n; i++)
        if (S.compare(i, n - i, T.substr(0, n - i)) == 0 && S.compare(0, i, T.substr(n - i, i)) == 0) {
            cout << YES << endl;
            return;
        }
    cout << NO << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n;
int ans;
int a[105][105];
bool vis[5][5];
int b;
bool flag;
int main(){
	for(int i = 1; i <= 3; i++)
		for(int j = 1; j <= 3; j++)
			cin >> a[i][j];
	cin >> n;
	int ans = 0;
	while(n--){
		cin >> b;
		for(int i = 1; i <= 3; i++)
			for(int j = 1; j <= 3; j++)
				if(a[i][j] == b) vis[i][j] = true;
	}
	for(int i = 1; i <= 3; i++){
		if(vis[i][1] && vis[i][2] && vis[i][3]) flag = 1;
		else if(vis[1][i] && vis[2][i] && vis[3][i]) flag = 1;
	}
	if(vis[1][1] && vis[2][2] && vis[3][3]) flag = 1;
	else if(vis[1][3] && vis[2][2] && vis[3][1]) flag = 1;
	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;
}



Measured memory_bytes: 256