akhauriyash/Code-Regression huggingface dataset:
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

inline int toInt(string s) { int v; istringstream in(s); in >> v; return v; }
template<class T> inline string toString(T x) { ostringstream out; out << x; return out.str(); }

template<class T> inline T sqr(T x) { return x * x; }
const int INF = (1 << 25);
const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0, sizeof(a))

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a)  (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n)  FOR(i, 0, n)

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
    int n;
    scanf("%d", &n);
    vi a(n), b(n);
    REP(i, n) {
        scanf("%d", &a[i]); b[i] = a[i];
    }
    SORT(b);
    REP(i, n) printf("%d\n", (a[i] <= b[n / 2 - 1]) ? b[n / 2] : b[n / 2 - 1]);

    return 0;
}


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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define output(x) cout << ( x ? "YES" : "NO" ) << '\n' ;
#define mxn 100005
using namespace std;

void solve(){
	int k;
	cin >> k;
	while(k--){
		cout << "ACL";
	}
}

int32_t main()
{
	FLASH
	int t = 1;
	// cin >> t;
	while(t--){
		solve();
	}
	return 0;
}



Measured memory_bytes: 3636
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
int nmax=200000;
vvec g(nmax);

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,k,q;
    cin>>n>>k>>q;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    vec as=a;
    int ans=INF;
    sort(all(as));
    rep(_,n){
        int mi=as[_];
        vvec b(n);
        int idx=0;
        rep(i,n){
            if(a[i]<mi){
                if(b[idx].size()>0) idx++;
            }
            else b[idx].pb(a[i]);
        }
        vec c;
        idx++;
        rep(i,idx){
            if(b[i].size()==0) continue;
            sort(all(b[i]));
            rep(j,((int)b[i].size())-k+1){
                c.pb(b[i][j]);
            }
        }
        sort(all(c));
        if(c.size()<q) continue;
        chmin(ans,c[q-1]-mi);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5120
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int a,b,n;
int main(){
	cin>>a>>b;
	n=b-a;
	n=(n+1)*n/2;
	cout<<n-b<<endl;
	return 0;
}

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

#define ll long long

const int maxN=101000;
const int inf=2147483647;

int n;
ll A[maxN],B[maxN+maxN];

int main(){
	cin>>n;
	for (int i=1;i<=n;i++) cin>>A[i];
	sort(&A[1],&A[n+1]);
	ll sum=0,Ans=0;
	int l=1,r=n;
	for (int i=2;i<n;i++)
		if (i&1) B[i]=A[l++];
		else B[i]=A[r--];
	B[1]=A[l++];B[n]=A[l++];
	
	for (int i=1;i<n;i++) sum=sum+abs(B[i+1]-B[i]);
	//for (int i=1;i<=n;i++) cout<<B[i]<<" ";cout<<endl;

	Ans=sum;sum=0;
	l=1;r=n;
	for (int i=2;i<n;i++)
		if (i&1) B[i]=A[r--];
		else B[i]=A[l++];
	B[1]=A[l++];B[n]=A[l++];
	for (int i=1;i<n;i++) sum=sum+abs(B[i+1]-B[i]);
	Ans=max(Ans,sum);
	cout<<Ans<<endl;return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main (void) {
    int N;
    cin >> N;
    while (N--) {
        string s1, s2;
        cin >> s1;
        cin >> s2;
        vector<int> n1, n2, res;
        for (int i = s1.size(); i--;) {
            n1.push_back((int)(s1[i] - '0'));
        }
        for (int i = s2.size(); i--;) {
            n2.push_back((int)(s2[i] - '0'));
        }
        if (n1.size() < n2.size()) {
            for (int i = n1.size(); i < n2.size(); i++) {
                n1.push_back(0);
            }
        } else if (n2.size() < n1.size()) {
            for (int i = n2.size(); i < n1.size(); i++) {
                n2.push_back(0);
            }
        }
        int s, c = 0;
        for (int i = 0; i < n1.size(); i++) {
            s = n1[i] + n2[i] + c;
            res.push_back(s % 10);
            c = s / 10;
        }
        while (c != 0) {
            res.push_back(c % 10);
            c /= 10;
        }
        int size = res.size();
        while (size > 0 && res[size - 1] == 0) {
            size--;
        }
        if (size > 80) {
            cout << "overflow" << endl;
        } else {
            int i = res.size();
            while (i--) {
                cout << res[i];
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
#define chmax(x,y) x=max(x,y)
#define show(x) cout<<#x<<" "<<x<<endl
using namespace std;
int N;
int b[1<<22];
int bo[1<<22];
void zetan(int* f,int N){
	rep(i,N) rep(j,1<<N) if(0==(j&1<<i)) f[j]+=f[j|(1<<i)];
}
void zetao(int* f,int N){
	rep(i,N) rep(j,1<<N) if(0==(j&1<<i)) f[j]|=f[j|(1<<i)];
}

int pc(int x){
	if(x==0) return 0;
	return __builtin_popcount(x);
}
int main(){
	int N;
	cin>>N;
	rep(i,N){
		int k;
		cin>>k;
		int v=0;
		rep(i,k){
			int x;
			cin>>x;
			x--;
			v|=1<<x;
		}
		b[v]++;
		bo[v]=v;
	}
	zetan(b,22);
	zetao(bo,22);
	int ans = 0;
	rep(i,1<<22) if(b[i]>=3){
//		show(i);
//		show(bo[i]);
		chmax(ans,pc(i)*pc(bo[i]));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 35808
# solution
import io
import math
import itertools as it

nim,mike = map(int, input().split())

arrat = []

for i in range(mike):
    a,b = map(int, input().split())
    arrat.append([a,b])

per = it.permutations(range(2,nim+1),nim-1)

result = 0

for pe in per:
    Flag = True
    pe = list(pe)
    pe.insert(0,1)
    for i in range(len(pe)-1):
        if [pe[i],pe[i+1]] not in arrat and [pe[i+1],pe[i]] not in arrat:
            Flag = False
            break
    if Flag == True:
        result +=1

print(result)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int[] a = new int[26];
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();

		for (int i = 0; i < s.length; i++) {
			a[s[i]-97]++;
			if (a[s[i]-97] >= 2) {
				System.out.println("no");
				return;
			}
		}
		System.out.println("yes");
	}
}


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

int main(){
    ll n;
    cin >> n;
    vector<ll> factor_v;
    for ( ll i = 2; i * i <= n; ++i ) {
        if ( n % i == 0 ) {
            factor_v.push_back(i);
        }
    } 
    if ( factor_v.empty() ) {
        cout << n - 1 << endl;
        return 0;
    }
    ll ans = 1e18;
    for ( auto tmp_num : factor_v ) {
        ans = min(ans, ( tmp_num - 1 ) + ( n / tmp_num - 1 ) );
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
from collections import Counter
import itertools 

N = int(input())
L = list(map(int, input().split()))
C = Counter(L)

S = list(set(L))

ans = 0
for a, b, c in itertools.combinations(S, 3):
    if a + b > c and a + c > b and b + c > a:
        ans += (C[a]*C[b]*C[c])

print(ans)

Measured memory_bytes: 9372
#include <stdio.h> 
int main (void) {
int W,H,x,y,r ;
scanf("%d %d",&W,&H) ;  
 scanf("%d %d",&x,&y) ;  
 scanf("%d",&r) ;
if(W<x+r || H<y+r ||y-r<0||x-r<0 ){
printf("No\n");
}
else{ printf("Yes\n") ;
}
return 0; }

Measured memory_bytes: 580
n,m=map(int,input().split())
if n%2==1:
    for i in range(m):
        print(i+1,n-i)
else:
    for i in range(m):
        if i%2==0:
            print(i//2+1,n-i//2)
        else:
            print(n//2-i//2-1,n//2+i//2+1)

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

int a, b, c, x, y;

int main() {
	ios_base::sync_with_stdio(0);
	long long ans = 1LL << 60;
	cin >> a >> b >> c >> x >> y;
	for (int i = 0; i < 300000; i += 2) {
		long long currAns = 1LL * i * c;
		int xx = max(0, x - i / 2);
		int yy = max(0, y - i / 2);
		currAns += 1LL * xx * a + 1LL * yy * b;
		ans = min(ans, currAns);
	}
	
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

using namespace std;

const int m = 1000000000;

int main() {
    long long s, r, x1, y1, x2, y2;
    
    scanf("%lld", &s);
    
    r = sqrt(s);
    
    for (x1 = r; x1 <= r + 10 && x1 <= m; x1++) {
        for (y2 = r; y2 <= r + 10 && y2 <= m; y2++) {
            if (x1 * y2 < s) continue;
            
            if (x1 * y2 - s <= m) {
                x2 = 1;
                y1 = x1 * y2 - s;
                
                printf("%lld %lld %lld %lld %lld %lld\n", 0, 0, x1, y1, x2, y2);
                
                return 0;
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    int X;
    cin >> X;
    int A = X / 100;
    int B = X % 100;
    if (A * 5 >= B)
    {
        cout << 1 << endl;
    }
    else
    {
        cout << 0 << endl;
    }
}


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

  int q,first,last,i,j,x;
  char str[1000],input[10],replace[1000],background[1000];

  scanf("%s",str);
  scanf("%d",&q);
  
  for(i = 0; i < q; i++){
    
    scanf("%s",input);

    //replace
    x=strcmp(input,"replace");

    if(x == 0){

      scanf("%d %d %s",&first,&last,replace);

      for(j = 0; j < last-first+1; j++){

	str[first+j]=replace[j];

      }

    }

    //reverse
    x=strcmp(input,"reverse");

    if(x == 0){

      scanf("%d %d",&first,&last);

      for(j = 0; j < last-first+1; j++){

	background[j]=str[first+j];

      }

      for(j = 0; j < last-first+1; j++){

	str[last-j]=background[j];

      }
      
    }

    //print
    x=strcmp(input,"print");

    if(x == 0){

      scanf("%d %d",&first,&last);

      for(j = 0; j < last-first+1; j++){

	printf("%c",str[first+j]);

      }

      printf("\n");

    }

  }

  return 0;
  
}

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

int main(void){
   int a,b,c;
   cin>>a>>b>>c;
   set<int> ans;
   ans.insert(a);
   ans.insert(b);
   ans.insert(c);
   cout<<ans.size()<<endl;
   return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define toup toupper
#define tolow tolower
const int mod = 1000000;
const int maxn = 10000;
typedef long long ll;
using namespace std;

int length(ll n){
	return (int)log10(n) + 1;
}

ll quickpow(ll x, ll y){
	ll res = 1;
	while(y){
		if(y & 1) res = res * x % mod;
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}

ll fac(ll x){
	if(x == 0 || x == 1) return 1;
	return x * fac(x - 1);//mod
}


int main(){
	int a, b, k;
	cin >> a >> b >> k;
	if((b - a) / 2 < k){
		for(int i = a; i <= b; i++){
			printf("%d\n", i);
		}
	}
	else{
		for(int i = a; i <= a + k - 1; i++){
			printf("%d\n", i);
		}
		for(int i = b - k + 1; i <= b; i++){
			printf("%d\n", i);
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define big 998244353
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589
int power(int x,int y){
    int r=1,z=x;
    while(y){
        if(y & 1)r*=z;
        z*=z;y=y>>1;}
    return r;}
int powerm(int x,int y,int p){
    int r=1;
    while(y){
        if(y & 1)r=(r*x)%p;
        y=y>>1;
        x=(x*x)%p;}
    return r%p;}
int modinv(int x,int m){
    return powerm(x,m-2,m);}
int logarithm(int a,int b){
    int x=0;
    while(a>1){
        x++;
        a/=b;}
    return x;}
int32_t main(){
    fast;
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int s=1,e=1e9;
    int mid=0;
    int ans;
    while(s<=e){
        mid=(s+e)/2;
        int req=0;
        for(int i=0;i<n;i++)
            req+=(a[i]+mid-1)/mid-1;
        if(req<=k){
            e=mid-1;
            ans=mid;
        }
        else{
            s=mid+1;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 5220
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    map<int, int> m; long long answer=1;
    for(int i=2; i<=n; i++){
        int buf = i;
        for(int j=2; j<=buf; j++){
            while(buf%j==0){
                buf/=j;
                m[j]++;
            }
        }
    }

    for(map<int,int>::iterator it=m.begin(); it!=m.end(); it++){
        answer*=((*it).second+1);
        answer%=1000000007;
    }
    
    cout<<answer;
    return 0;
}

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

int N;
int count[300000];
int* neighbor[300000];
int visited[300000];

struct queue_t {
	int c; /* current */
	int d; /* distance */
} Q[300000];
int Qs, Qe;

int is_win[300000];

int main(void) {
	int i;
	int chokkei = 0;
	int last;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 1; i < N; i++) {
		int a, b;
		if (scanf("%d%d", &a, &b) != 2) return 1;
		a--;
		b--;
		neighbor[a] = realloc(neighbor[a], sizeof(int) * (count[a] + 1));
		if (neighbor[a] == NULL) return 1;
		neighbor[a][count[a]++] = b;
		neighbor[b] = realloc(neighbor[b], sizeof(int) * (count[b] + 1));
		if (neighbor[b] == NULL) return 1;
		neighbor[b][count[b]++] = a;
	}

	Qs = 0; Qe = 1; Q[0].c = 0;
	last = 0;
	while (Qs < Qe) {
		struct queue_t cur = Q[Qs++];
		int idx = cur.c;
		last = idx;
		for (i = 0; i < count[idx]; i++) {
			int next = neighbor[idx][i];
			if (visited[next] < 1) {
				visited[next] = 1;
				Q[Qe].c = next;
				Qe++;
			}
		}
	}
	Qs = 0; Qe = 1; Q[0].c = last; Q[0].d = 0;
	while (Qs < Qe) {
		struct queue_t cur = Q[Qs++];
		int idx = cur.c;
		chokkei = cur.d + 1;
		for (i = 0; i < count[idx]; i++) {
			int next = neighbor[idx][i];
			if (visited[next] < 2) {
				visited[next] = 2;
				Q[Qe].c = next;
				Q[Qe].d = cur.d + 1;
				Qe++;
			}
		}
	}

#if 0
	printf("%d\n", chokkei);
#endif
	is_win[1] = 1;
	is_win[2] = 0;
	for (i = 3; i <= chokkei; i++) {
		/* aite wo makasu koto ga dekire ba OK */
		is_win[i] = (!is_win[i - 1] || !is_win[i - 2]);
#if 0
		printf("%d\n", is_win[i]);
#endif
	}

	puts(is_win[chokkei] ? "First" : "Second");
	return 0;
}

/*
押す → そのノードの次数だけ有効ノードの数が減る
負けでなければ、相手が前の番で選んだノードは選べる → 真似できる

↑嘘：有効ノードが減っていると、ノードの次数より少ないことがある

数をN-1から次数減らしていき、自分の番で0にしてしまったら負け

どこを選んでも、葉(次数1)のノードは無効になる
	(選んだのが葉の場合、それ自身は除く)
	(次数0の場合は、無効になる)

戦略：葉(どれ？)を選ぶ or 葉以外を選ぶ

(予想)
葉を選ばれたのがうれしい→活用する→やだ→しない
うれしくない→葉以外を選ぶことで無効化

※先に自分の手番で1本のパターンを見たら勝ち
	ただし、長さ2なら負け
→相手に1本のパターンを作らせたら勝ち (ただし長さ2なら負け)

(予想)
木の直径から求まる

木の直径 http://www.prefield.com/algorithm/graph/tree_diameter.html

*/


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

using namespace std;


int main()
{
    int n,m,x;
    cin>>n>>m>>x;
    vector<int>c(n);
    vector<vector<int>>a(n,vector<int>(m));
    for(int i=0;i<n;i++)    
    {
        cin>>c[i];
        for(int j=0;j<m;j++)
            cin>>a[i][j];
    }
    int ans=1e9;
    for(int i=0;i<(1<<n);i++)
    {
        int cost=0;
        int temp[m]={};
        for(int j=0;j<n;j++)
            if(i&(1<<j))
            {
                cost+=c[j];
                for(int k=0;k<m;k++)
                    temp[k]+=a[j][k];
            }
        for(int i=0;i<m;i++)
            if(temp[i]<x)cost=1e9;
        ans=min(ans,cost);

    }
if (ans == 1e9) ans = -1;
cout<<ans;
return 0;
}


Measured memory_bytes: 3600
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#include <bits/stdc++.h>
using namespace std;

//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;

int H,W,x,y,mv;
char s,t;
vpi vertex(28);
int adj[26][26],depth[26],exist[26];
string table[51];

int main(){
    cin >> H >> W >> s >> t ;
    REP(i,H){
        cin >> table[i];
        REP(j,W){
            if ('A' <= table[i][j] && table[i][j] <= 'Z'){
                vertex[table[i][j] - 'A'] = {i,j};
                exist[table[i][j] - 'A'] = 1;
            }
        }
    }
    REP(i,26){
        if (! exist[i]) continue;
        y = vertex[i].first;
        x = vertex[i].second;
        if (y >= 2 && table[y-2][x] == '|'){
            mv = y-2;
            while (table[mv][x] == '|') mv--;
            char conn = table[mv-1][x];
            adj[i][conn-'A'] = adj[conn-'A'][i] = 1;
        }
        if (y < H-2 && table[y+2][x] == '|'){
            mv = y+2;
            while (table[mv][x] == '|') mv++;
            char conn = table[mv+1][x];
            adj[i][conn-'A'] = adj[conn-'A'][i] = 1;
        }
        if (x >= 2 && table[y][x-2] == '-'){
            mv = x-2;
            while (table[y][mv] == '-') mv--;
            char conn = table[y][mv-1];
            adj[i][conn-'A'] = adj[conn-'A'][i] = 1;
        }
        if (x < W-2 && table[y][x+2] == '-'){
            mv = x+2;
            while (table[y][mv] == '-') mv++;
            char conn = table[y][mv+1];
            adj[i][conn-'A'] = adj[conn-'A'][i] = 1;
        }
    }

    deque<pi> q;
    q.push_back(mp(0,(s-'A')));

    while (!q.empty()){
        pi tp = q.front();
        q.pop_front();
        depth[tp.second] = tp.first;
        REP(i,26) if (adj[i][tp.second] && !depth[i] && i != s-'A') q.pb(mp(tp.first+1,i));
    }
    cout << depth[t-'A'] << endl;
}



Measured memory_bytes: 3212
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n, m;
		char[][] table;
		char c;
		boolean bool;
		while((n = sc.nextInt()) != 0){
			table = new char[n][2];
			for(int i = 0; i < n; i++){
				table[i][0] = sc.next().charAt(0);
				table[i][1] = sc.next().charAt(0);
			}
			m = sc.nextInt();
			for(int i = 0; i < m; i++){
				c = sc.next().charAt(0);
				bool = true;
				for(int j = 0; j < n; j++){
					if(table[j][0] == c){
						bool = false;
						System.out.print(table[j][1]);
						break;
					}
				}
				if(bool){
					System.out.print(c);
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 12000
X, Y = map(int, input().split())

s = 0
if X == 3:
  s+= 100000
if X == 2:
  s+= 200000
if X == 1:
  s+=300000
  
if Y == 3:
  s+= 100000
if Y == 2:
  s+= 200000
if Y == 1:
  s+=300000
  
if X == 1 and Y == 1:
  s+=400000
print(s)

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

int main() {
  int h, w, a, b;
  cin>>h>>w>>a>>b;
  vector<vector<int>> d(h, vector<int>(w));

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      int x=(j<a)^(i<b);
      cout<<x;
    }
    cout<<endl;
  }
  return 0;
}

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

int main() {
 int k;
 int s;
 cin >> k >> s;
int l =0;
int count=0;

  for (int i = 0; i <= k; i++){
    for (int j =0 ; j <= k; j++){
      l = s - i -j;
        if(0<= l and l <= k ) count++;
      }
    }



  
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

ll bit[41][510000] = {};
ll exist[510000] = {};
int main() {
   

    ll n,k;
    cin >> n >> k;
    vector <ll> a;
    for (ll i=0;i<n;i++){
        ll p;
        cin >> p;
        a.push_back(p);
    }

    vector <ll> lis;
    for (ll i=0;i<n;i++){
        ll par = a[i];
        lis.push_back(par);
        ll post = 0;
        for (ll j=i+1;j<n;j++){
            post += a[j];
            lis.push_back(par + post);
        }
    }
//    for (ll i=0;i<lis.size();i++){
//        cout << lis[i] << " ";
//    }
//    cout << endl;

//    sort(lis.begin(),lis.end());

    for (ll i=0;i<lis.size();i++){
        ll j=0;
        while(lis[i] != 0){
            bit[j][i] = lis[i] % 2;
            lis[i] /= 2;
            j++;
        }
    }
//    for (ll i=0;i<10;i++){
//        cout << i << " " << bit[i][1] << endl;
//    }
//    for (ll i=0;i<lis.size();i++){
//        cout << lis[i] << " ";
//    }
//    cout << endl;

    ll itr = 40;
    ll bitv = 1;
    for (ll i=0;i<40;i++){
        bitv *= 2;
    }
    ll ans = 0;
    while(itr >= 0){
        ll sumbit = 0;
        for (ll i=0;i<lis.size();i++){
            if(bit[itr][i] == 1 and exist[i] == 0){
                sumbit++;
            }
        }
//        cout << itr << " " << sumbit << endl;

        if(sumbit < k){
            itr--;
            bitv /= 2;
            continue;
        }
        for (ll i=0;i<lis.size();i++){
            if(bit[itr][i] == 0){
                exist[i] = 1;
            }
        }
        ans += bitv;
        bitv /= 2;
        itr--;
    }
    cout << ans << endl;

}




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

#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 1000000007
#define EPS ((ld)(1e-9))

#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define rep(i, x)  for (int i = 0, _##i = (x); i < _##i; i++)
#define repp(i, x) for (int i = 1, _##i = (x); i <= _##i; i++)
#define repr(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)

#define L(x) ((x)*2)
#define R(x) ((x)*2+1)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pdd;
typedef pair<ll, ll> pll;

template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    os << pai.first << ' ' << pai.second;
	return os;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    rep(i, sz(v)) cout << v[i] << ' ';
    return os;
}

template<typename T, typename V>
istream &operator>>(istream &is, pair<T, V> &pai) {
	is >> pai.first >> pai.second;
	return is;
}

int N, M;
vector<int> col, row;

int main(void) {
    iostream::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    
    cin >> N >> M;
    rep(i, N) {int t; cin >> t; col.pb(t);}
    rep(i, M) {int t; cin >> t; row.pb(t);}

    col.pb(-1);
    row.pb(-1);

    sort(col.begin(), col.end(), greater<int>());
    sort(row.begin(), row.end(), greater<int>());
    int freecell = 0;
    int fc = 0, fr = 0;
    
    ll tot = 1;

    auto p1 = col.begin(), p2 = row.begin();
    for (int i = M * N; i > 0; i--) {
        if (*p1 > i or *p2 > i or freecell < 0) {
            cout << 0;
            return 0;
        }

        if (*p1 == i and *p2 == i) {
            freecell += fc++ + fr++;

            p1++, p2++;
        } else if (*p1 == i) {
            tot = (tot * fc) % MOD;
            freecell += fc - 1; 
            fr++;

            p1++;
        } else if (*p2 == i) {
            tot = (tot * fr) % MOD;
            freecell += fr - 1; 
            fc++;

            p2++;
        } else {
            tot = (tot * freecell--) % MOD;
        }
    }

    cout << tot;
}

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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int dp[n+5];
	for (int i = 0; i <= n; ++i)
	{
		dp[i]=i;
	}
	for (int i = 1; i <= n; ++i)
	{
		int now=6;
		while (i-now>=0)
		{
			dp[i]=min(dp[i],dp[i-now]+1);
			now*=6;
		}
		now=9;
		while (i-now>=0)
		{
			dp[i]=min(dp[i],dp[i-now]+1);
			now*=9;
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

a,b,k=mii()
cnt=0
for i in range(min(a,b),0,-1):
    if a%i==0 and b%i==0:
        cnt+=1
        if cnt==k:
            print(i)
            exit()



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

int main()
{
 int n, m;
 cin >> n >> m;
 char ch;

 vector<vector<bool>> v(n, vector<bool>(m, 1));
 vector<vector<ll>> dp(n, vector<ll>(m,1));
 for(int i=0; i<n; i++)
 {
  for(int j=0; j<m; j++)
  {
    cin >> ch;
    if(ch == '#')
    {
      v[i][j] = 0;
      dp[i][j] = 0;
    }
  }
 }

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

  for(int i=1; i<m; i++)
    if(dp[0][i] == 1) dp[0][i] = dp[0][i-1];

 for(int i=1; i<n; i++)
 {
  for(int j=1; j<m; j++)
  {
    if(v[i][j])
    {
      dp[i][j] = (dp[i-1][j] + dp[i][j-1])%INTF;
    }
  }
 }

 cout<<dp[n-1][m-1];
  return 0;
}


Measured memory_bytes: 10240
import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7


a, b = MAP()
if a<= b:
    print('unsafe')
else:
    print('safe')

Measured memory_bytes: 72788
#include <cstdio>
#include <queue>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxd = 2e5+10;
struct node
{
	int v,net;
}e[maxd<<1];
int f[maxd],eid;
void insert(int x,int y)
{
	e[eid].v = y;
	e[eid].net =f[x];
	f[x] = eid++;
}
void init()
{
	memset(f,-1,sizeof(f));
	eid = 0;
}
long long t[maxd];
void dfs(int x,int fa = 0)
{
	for(int i=f[x];i+1;i=e[i].net)
	{
		int v = e[i].v;
		if(v == fa) continue;
		t[v] += 1ll * t[x];
		dfs(v,x);
	}
}
int main()
{
	// freopen("a.in","r",stdin);
	// freopen("k.out","w",stdout);
	int n,m;scanf("%d %d",&n,&m);
	init();
	for(int i=1;i<n;i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);
		insert(a,b);insert(b,a);
	}
	for(int i=1;i<=m;i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);
		t[a]+=b;
	}
	dfs(1);
	for(int i=1;i<=n;i++) printf("%lld ",t[i]);
	return 0;
}

Measured memory_bytes: 17152
#include<stdio.h>
#include<string.h>

int main() {
	char s[100];
	scanf("%s", s);
	int n = strlen(s),flag=0;
	for (int i = 0; i < n / 2; i++) {
		if (s[i] != s[n - 1 - i]) {
			flag = 1;
		}
	}
	for (int i = 0; i < n / 2 / 2; i++) {
		if (s[i]!=s[(n-3)/2-i]) {
			flag = 1;
		}
	}
	if (flag == 0) printf("Yes");
	else printf("No");

	return 0;
}

Measured memory_bytes: 128
N, K, Q = map(int, input().split())

A = []
answered = [0 for i in range(0, N)]

for i in range(0, Q):
    a = int(input()) - 1
    answered[a] = answered[a] + 1

for i in range(0, N):
    sub = Q - answered[i]
    if K - sub > 0:
        print("Yes")
    else:
        print("No")



Measured memory_bytes: 4672
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    double r;
    cin >> r;
    cout << r * 3.14 * 2<< endl;
}

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


Measured memory_bytes: 3800
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;
using System.ComponentModel;

class Program
{
    static void Main(string[] args)
    {
        var alice = new Magatro();
        alice.Scan();
        alice.Solve();
    }
}

public class Scanner
{
    private StreamReader Sr;
    private string[] S;
    private int Index;
    private const char Separator = ' ';

    public Scanner() : this(Console.OpenStandardInput())
    {
        Index = 0;
        S = new string[0];
    }
    public Scanner(Stream source)
    {
        Sr = new StreamReader(source);
    }

    private string[] Line()
    {
        return Sr.ReadLine().Split(Separator);
    }

    public string Next()
    {
        string result;
        if (Index >= S.Length)
        {
            S = Line();
            Index = 0;
        }
        result = S[Index];
        Index++;
        return result;
    }
    public T Next<T>()
    {
        var converter = TypeDescriptor.GetConverter(typeof(T));
        return (T)converter.ConvertFromString(Next());

    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public decimal NextDecimal()
    {
        return decimal.Parse(Next());
    }
    public string[] StringArray(int index = 0)
    {
        Next();
        Index = S.Length;
        return S.Skip(index).ToArray();
    }
    public int[] IntArray(int index = 0)
    {
        return StringArray(index).Select(int.Parse).ToArray();
    }
    public long[] LongArray(int index = 0)
    {
        return StringArray(index).Select(long.Parse).ToArray();
    }
    public bool EndOfStream
    {
        get { return Sr.EndOfStream; }
    }
}

public class Magatro
{
    private int N, C, K;
    private int[] T;

    public void Scan()
    {
        Scanner cin = new Scanner();
        N = cin.NextInt();
        C = cin.NextInt();
        K = cin.NextInt();
        T = new int[N];
        for (int i = 0; i < N; i++)
        {
            T[i] = cin.NextInt();
        }
    }

    public void Solve()
    {
        Array.Sort(T);
        int ans = 0;
        int cnt = 1;
        int index = 0;
        for (int i = 1; i < N; i++)
        {
            if (T[i] - T[index] > K)
            {
                index = i;
                ans++;
                cnt = 1;
                continue;
            }
            cnt++;
            if (cnt > C)
            {
                index = i;
                ans++;
                cnt = 1;
            }

        }
        if (cnt > 0)
        {
            ans++;
        }
        Console.WriteLine(ans);
    }

}



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

struct UnionFind {
    vector<int> par;
    vector<int> sz;

    UnionFind(int n=0){
        if(n>0) initialize(n);
    }

    void initialize(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0; i<n; i++){
            par[i] = i;
            sz[i] = 1;
        }
    }

    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }

    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(sz[x] > sz[y]) swap(x, y);
        par[x] = y;
        sz[y] += sz[x];
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }

    int size(int x){
        return sz[find(x)];
    }
};

int main(){
    string S;
    int N;
    cin >> S >> N;
    int L = S.size();
    int sz = L/2;
    vector<int> V(sz+2, 0);
    for(int i=1; i<=sz; i++) V[i] = S[i-1] - S[L-i];
    vector<int> diff(sz+1, 0);
    for(int i=0; i<=sz; i++) diff[i] = V[i+1] - V[i];

    UnionFind uf(sz+1);
    for(int i=0; i<N; i++){
        int l, r;
        cin >> l >> r;
        l--;
        l = min(l, L-l);
        r = min(r, L-r);
        uf.unite(l, r);
    }

    vector<int> sum(sz+1, 0);
    for(int i=0; i<=sz; i++) sum[uf.find(i)] += diff[i];
    for(int i=0; i<=sz; i++) if(sum[i] % 26){
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
    return 0;
}

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

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

    double ans = 2*r*M_PI;
    printf("%.10f\n",ans);
    return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

struct UnionFind
{
   vector<int> parent, size;

   UnionFind(int n){
      parent.resize(n+1);
      size.resize(n+1);
      for (int i = 1; i <= n; ++i)
      {
         parent[i] = i;
         size[i] = 1;         
      }
   }

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

   bool unite(int x, int y){
      x = find(x), y = find(y);
      if(x == y)
         return false;
      if(size[x] < size[y])swap(x, y);
      size[x] += size[y];
      parent[y] = x;
      return true;
   } 

   int getSize(int x){
      x = find(x);
      return size[x];
   }
};

vector<int> a;
void solve0(){
   int n, m;
   cin >> n >> m;

   UnionFind S(n);

   for (int i = 0; i < m; ++i)
   {
      int x, y, z;
      cin >> x >> y >> z;
      S.unite(x, y);
   }

   int compo = 0;
   for (int i = 1; i <= n; ++i)
   {
      if(S.find(i) == i)
         compo++;
   }

   cout<<compo;
}

int32_t main(){_

   int q = 1;
   // cin >> q;

   while(q--){
      solve0();
   }

   return 0;
}

Measured memory_bytes: 1792
N = int(input())
A = list(map(int, input().split()))
counter = 0
m = []
def abab(l):
    for i in range(len(l)):
        m.append(abs(l[i]))
    return m

for i in range(N):
    if A[i] < 0:
        counter += 1
      
if counter % 2 == 1:
    m = abab(A)
    idx = m.index(min(m))
    m[idx] *= -1
    print(sum(m))
else:
    print(sum(abab(A)))

    

Measured memory_bytes: 14412
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
#define mod(int)(1000000007)
using namespace std;
int test[213456], cnt[213456][2];
int par[213456];//親
int depth[213456];//木の深さ
//n要素で初期化
void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		depth[i] = 0;
	}
}
//木の根を求める
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}
//xとyの属する集合を併合
void unite(int x, int y) {
	x = find(x); y = find(y);
	if (x == y) { return; }
	if (depth[x] < depth[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (depth[x] == depth[y])depth[x]++;
	}
}
//xとyが同じ集合に属するか否か
bool same(int x, int y) {
	return find(x) == find(y);
}
signed main() {
	int n, m, a, b, ans = 0; cin >> n >> m;
	for (int h = 0; h < m; h++) {
		cin >> a >> b;
		cnt[h][0] = a; cnt[h][1] = b;
	}
	for (int h = 0; h < m; h++) {
		init(n + 1); int z = 0;
		for (int i = 0; i < m; i++) {
			if (h != i) {
				unite(cnt[i][0], cnt[i][1]);
			}
		}
		for (int j = 1; j <= n; j++) {
			if (same(1, j) == false) { z = 1; }
		}
		if (z == 1) { ans++; }
	}
	cout << ans << endl;
}

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

int main(){
    int n,m,Q,x[502][502];
    cin >> n >> m >> Q;
    for(int i = 0;i < 502;i ++){
        fill(x[i],x[i]+502,0);
    }
    for(int i = 0;i < m;i ++){
        int l,r;
        cin >> l >> r;
        x[l][r] ++;
    }
    for(int j = 1;j <= n;j ++){
        for(int i = n;i >= 1;i --){
            x[i-1][j] += x[i][j];
        }
    }
    for(int i = 1;i <= n;i ++){
        for(int j = 1;j <= n;j ++){
            x[i][j+1] += x[i][j];
        }
    }
    for(int i = 0;i < Q;i ++){
        int p,q;
        cin >> p >> q;
        cout << x[p][q] << endl;
    }
    return 0;
}

Measured memory_bytes: 1920
K, X = map(int, input().split())
min = X-(K-1)
max = X+(K-1)
if min < -1000000:
  min = -1000000
if max > 1000000:
  max = 1000000
li = []
  
for i in range(min,max+1,1):
  li.append(str(i))

print(' '.join(li))

Measured memory_bytes: 3060
h,w = gets.split().map(&:to_i)
r = []
h.times do
	r << gets.split().map(&:to_i)
end

1.upto(h-1) do |i|
	1.upto(w-1) do |j|
		m = [r[i-1][j],r[i][j-1],r[i-1][j-1]].max
		if m == 1 || r[i][j] == 1
			next
		end
		r[i][j] = m-1
	end
end

puts (r.map(&:min).min-1)**2

Measured memory_bytes: 25036
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 9;
 
unordered_map<int, set<int> >X, Y;
unordered_map<int, vector<int> > pX, pY;
map<pair<int, int>, int>Gree;
int n, a, b, x[N], y[N], d;
long long ans;
 
int abs (int x) { return x < 0 ? ~x + 1 : x; }
 
int find (const vector<int> &T, int pl, int pr) {
	int l = 0, r = T.size() - 1, mid, ret;
	while (l <= r) {
		mid = (l + r) >> 1;
		if (T[mid] > pr) r = mid - 1;
		else l = mid + 1;
	}
	ret = l; l = 0, r = T.size() - 1;
	while (l <= r) {
		mid = (l + r) >> 1;
		if (T[mid] >= pl) r = mid - 1;
		else l = mid + 1;
	}
	return ret - l;
}
 
void Dfs (int, int);
 
void find (const set<int> &T, int pl, int pr, int zb, bool o) {
	for (set<int>::iterator p; (p = T.lower_bound(pl)), p != T.end() && *p <= pr; ) if (o)
	Dfs(*p, zb);
	else
	Dfs(zb, *p);
}
 
void Erase (int x, int y) { X[x].erase(y), Y[y].erase(x); }
 
void Dfs (int x, int y) {
	ans += Gree[pair<int, int>(x, y)];
	Erase(x, y);
	find(X[x - d], y - d, y + d, x - d, 0);
	find(X[x + d], y - d, y + d, x + d, 0);
	find(Y[y - d], x - d, x + d, y - d, 1);
	find(Y[y + d], x - d, x + d, y + d, 1);
}
 
int main () {
	scanf("%d%d%d", &n, &a, &b);
	for (int i = 1; i <= n; ++i) {
		scanf("%d%d", &x[i], &y[i]);
		x[i] += y[i], y[i] = x[i] - (y[i] << 1);
		X[x[i]].insert(y[i]), Y[y[i]].insert(x[i]);
		pX[x[i]].emplace_back(y[i]), pY[y[i]].emplace_back(x[i]);
	}
	d = max(abs(x[a] - x[b]), abs(y[a] - y[b]));
	for (auto &v : pX) sort(v.second.begin(), v.second.end());
	for (auto &v : pY) sort(v.second.begin(), v.second.end());
	for (int i = 1; i <= n; ++i) {
		Gree[pair<int, int>(x[i], y[i])] = find(pX[x[i] - d], y[i] - d, y[i] + d) + find(pX[x[i] + d], y[i] - d, y[i] + d) +
		find(pY[y[i] - d], x[i] - d + 1, x[i] + d - 1) + find(pY[y[i] + d], x[i] - d + 1, x[i] + d - 1);
	}
	Dfs(x[a], y[a]);
	printf("%lld\n", ans >> 1);
	return 0;
}

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

int main(void) {
  string s;
  cin >> s;
  vector<string> guki = {"LUD", "RUD"};
  bool flg = true;
  for (int i = 0; i < s.length(); ++i) {
   if (guki[(i + 1) % 2].find(s[i]) == string::npos) {
     flg = false;
     break;
   }
  }
  if (flg) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 384
import java.util.*;

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

        String[] points = point.split(" ");
        int n = Integer.parseInt(points[0]);
        int d = Integer.parseInt(points[1]);

        int d2 = d * 2 + 1;

        double d3 = (double)n / d2;

        //きりあげ
        double kiriage = Math.ceil(d3);

        //少数を消す
        int ans = (int)kiriage;

        System.out.println(ans);
    }
}

Measured memory_bytes: 22996
#include<stdio.h>
int main(){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(x+r<=W && x-r>=0 && y+r<=H && y-r>=0){
		printf("Yes\n");
	} else {
		printf("No\n");
	}
return 0;

}





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

int main()
{
	long long a,b,c,x,y,w;
	cin>>x>>y>>a>>b>>c;
	
	priority_queue<pair<long long,long long> > h;
	while(a--)
	{
		cin>>w;
		h.push(make_pair(w,1));
	}
	while(b--)
	{
		cin>>w;
		h.push(make_pair(w,2));
	}
	while(c--)
	{
		cin>>w;
		h.push(make_pair(w,3));
	}
	long long z=x+y,ans=0;
	while(z)
	{
		pair<long long,long long> f=h.top();
		h.pop();
		if(f.second==3)
		{
			ans+=f.first;
			z--;
		}
		if(f.second==1 && x)
		{
			ans+=f.first;
			z--;
			x--;
		}
		if(f.second==2 && y)
		{
			ans+=f.first;
			z--;
			y--;
		}
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 10476
n=int(input())
x=sorted(list(map(int,input().split())))
min=min(x)
max=max(x)
ans=10**9
for p in range(min,max+1):
    sum=0
    for i in range(n):
        sum+=(x[i]-p)**2
    if ans>sum:
        ans=sum
print(ans)


Measured memory_bytes: 38512
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[100005],ara[100005];
int main()
{
    ll n;
    int i;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>ara[i];
    }
    dp[1]=0;
    dp[2]=abs(ara[1]-ara[2]);
    for(i=3;i<=n;i++)
    {
        dp[i]=min(dp[i-1]+abs(ara[i]-ara[i-1]),dp[i-2]+abs(ara[i]-ara[i-2]));
    }
    cout<<dp[n]<<endl;
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

ll N;
ll cnt = 0;

void rec(string num)
{
    ll now = stoll(num);
    if (now > N) return;

    if (count(all(num), '3') > 0 and count(all(num), '5') > 0 and count(all(num), '7') > 0) {
        ++cnt;
    }

    rec(num + '3');
    rec(num + '5');
    rec(num + '7');
}

int main()
{
        cin >> N;
        rec("0");
        cout << cnt << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int top,S[1000];
 
void push(int x){
    S[++top] = x;
}
 
int pop(){
    top--;
    return S[top+1];
}
 
 
int main(){
    int a,b;
    top = 0;
    char s[100];
    while ( scanf("%s", s) != EOF){
        if( s[0] == '+'){
            a = pop();
            b = pop();
            push(a+b);
        }
        else if(s[0] == '-'){
            b = pop();
            a = pop();
            push( a - b);
        }
        else if(s[0] == '*'){
            a = pop();
            b = pop();
            push(a * b);
        }
        else {
            push(atoi(s));
        }
    }
    printf("%d\n", pop());  
    return 0;
}

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

char s[4];

int main()
{
    scanf("%s",&s);
    if(s[0]=='7'||s[1]=='7'||s[2]=='7')
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 3668