akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,b,a) for(i=b-1;i>=(ll)a;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  if(n<r)return 0;
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  // startupcpp();
  // int codeforces;cin>>codeforces;while(codeforces--){
  ll N,l,r;
  string s;
  cin>>s;
  N=s.size();
  l=r=N>>1;
  --l;
  if(N&1)++r;
  while(~l&&s[l]==s[l+1])--l;
  while(r<N&&s[r]==s[r-1])++r;
  print(min(r,N-l-1));
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

int main(){
    int h,w;
    cin>>h>>w;
    vector<string>s(h);
    rep(i,0,h){
        cin>>s.at(i);
    }
    int ans=0;
    rep(i,0,h){
        rep(j,0,w){
            if(s.at(i).at(j)=='#')continue;
            int ma=0;
            vector<vector<int>>d(h,vector<int>(w,-1));
            d[i][j]=0;
            queue<pii>q;
            q.push({i,j});
            while(!q.empty()){
                int y=q.front().first;
                int x=q.front().second;
                q.pop();
                vector<int>dy={0,0,-1,1};
                vector<int>dx={1,-1,0,0};
                rep(k,0,4){
                    int ny=y+dy.at(k);
                    int nx=x+dx.at(k);
                    if(ny<0 or h<=ny or nx<0 or w<=nx)continue;
                    if(s.at(ny).at(nx)=='#')continue;
                    if(d.at(ny).at(nx)!=-1)continue;
                    d.at(ny).at(nx)=d.at(y).at(x)+1;
                    q.push({ny,nx});
                    ma=max(ma,d.at(ny).at(nx));
                }
            }
            ans=max(ans,ma);
        }
    }
    cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>

using namespace std;

#define INF 1000000007
#define MAX 15
int v,e;
int d[MAX][MAX] = {{0}};

int dp[1 << MAX][MAX] = {{0}};

int dfs(int s, int n){
  // cout << dp[s][n] << endl;
  if(dp[s][n] >= 0) return dp[s][n];
  if(s == (1 << v) - 1 && n == 0) return dp[s][n] = 0;
  int res = INF;
  for(int u = 0; u < v; u++){
    if(!(s >> u & 1) && d[n][u] != -1){
      // cout << s << " " << n << " " << u << endl;
      res = min(res, dfs( s | (1 << u), u) + d[n][u]);
    }
  }
  return dp[s][n] = res;
}

int main(){
  cin >> v >> e;
  for(int i = 0; i < v; i++){
    for(int j = 0; j < v; j++){
      d[i][j] = -1;
    }
  }
  for(int i = 0; i < (1<<v); i++){
    for(int j = 0; j < v; j++){
      dp[i][j] = -1;
    }
  }
  // cout << dp[0][0] << endl;
  for(int i = 0; i < e; i++){
    int s,t,c;
    cin >> s >> t >> c;
    d[s][t] = c;
  }
   // cout << "hi" << endl;
  int ans = dfs(0, 0);
  if(ans == INF) cout << -1 << endl;
  else cout << ans << endl;
}



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

int main(void){
  char s[100];
  scanf("%s",s);
  if(s[0]=='S'){
    printf("Cloudy");
  }
  else if(s[0]=='C'){
    printf("Rainy");
  }
  else {
    printf("Sunny");
  }
  return 0;
}
  


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

public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static Scanner sc = new Scanner(System.in);
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    int H,W;
    int[] dr = new int[]{1,0,-1,0}, dc = new int[]{0,1,0,-1};
    Set<Integer>[] tree;
    public static void main(String[] args) throws IOException {
        Main main = new Main();
        main.solve();
        out.flush();
    }
    void solve() throws IOException {
        int n = sc.nextInt(), m = sc.nextInt();
        tree = new Set[n+1];
        for(int i=0;i<=n;i++) tree[i]=new HashSet<>();
        while(m-->0){
            int a = sc.nextInt(), b = sc.nextInt();
            tree[a].add(b); tree[b].add(a);
        }
        // dfs from vertex 1
        int[] prev = new int[n+1];
        boolean[] vis = new boolean[n+1];
        List<Integer> cur = new LinkedList<>(), next = new LinkedList<>();
        vis[1] = true; cur.add(1);
        while(cur.size()>0){
            for(int now:cur){
                for(int to:tree[now]){
                    if(vis[to]) continue;
                    prev[to] = now;
                    vis[to] = true;
                    next.add(to);
                }
            }
            cur = next; next = new LinkedList<>();
        }
        out.println("Yes");
        for(int i=2;i<=n;i++){
            out.println(prev[i]);
        }
    }
}

Measured memory_bytes: 97688
def prime?(num)
  return false if num < 2
  return true if num == 2
  (2..(num**(0.5))).each do |i|
    return false if num % i == 0
  end
  return true
end

N=gets.to_i
ans = [11]
num = 11
while ans.size < N
  num += 5 
  next if !(prime?(num))
  ans << num
end

puts ans * ' '



Measured memory_bytes: 1916
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';
using namespace std;

ll cutter[]={1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384};

bool cut(int in, ll index){
    if(in/cutter[index]%2==0) return false;
    else return true;
}


int main(void){
    ll N;
    vector< pair<int, int> > wit[20];
    cin>>N;
    rep(i, N){
        ll A, x, y;
        cin>>A;
        rep(j, A){
            cin>>x>>y;
            wit[i].push_back({x, y});
        }
    }
    ll Maxima=0;
    rep(i, 32768){
        bool ok=true;
        ll teller=0;
        rep(j, N){
            if(cut(i, j)){
                teller++;
                rep(k, wit[j].size()){
                    int x=wit[j][k].first;
                    int y=wit[j][k].second;
                    if(cut(i, x-1)!=(y==1)){
                        ok=false;
                        break;
                    }
                }
                if(!ok) break;
            }
        }
        if(ok) Maxima=max(Maxima, teller);
    }
    cout<<Maxima<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 110 , mz = 1e9+7;
char s[N][N];
bool vis[N][N];
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};

int main(){
    int n,m;
    cin>>n>>m;
    for(int i=1 ; i <= n ; i++) scanf("%s",s+i);
    for(int i = 1 ; i <= n ; i++){
        for(int j = 1 ; j <= m ; j++){
            if( s[i][j] == '#' ){
                bool f = 0;
                for(int k = 0 ; k < 4 ; k++){
                    if( s[i+dx[k]][j+dy[k]] == '#' ){
                        f = 1;
                    }
                }
                if( !f ){
                    return 0*printf("No\n");
                }
            }
        }
    }
    puts("Yes");
    return 0;
}


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

int main() {

  int A, B;
  cin >> A >> B;
  
  int count = 0;
  for (int i = A; i <= B; i++) {
    int s = i % 10, t = i / 10000 % 10;
    int u = i / 10 % 10, v = i / 1000 % 10;
    if (s == t && u == v) count++;
  }
  cout << count << endl;
    
}


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

int main (void) {
    char s[100002];
    s[0] = 'a';
    scanf("%s", &s[1]);

    char s_unified[100002];
    s_unified[0] = 'a';
    int ans=0;
    int s_len = strlen(&s[1]);
    int tail=0;
    for ( int i=1; i<=s_len; i++ ) {
        if ( tail == 0 || s[i] == s_unified[tail] ) {
            tail++;
            s_unified[tail] = s[i];
        }
        else
        {
            ans += 2;
            tail--;
        }
    }

    printf("%d\n", ans);
    return EXIT_SUCCESS;
}


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

int n, a, b, c, x;
int Random()
{
	return (a * x + b) % c;
}

int main()
{
	int ary[100];

	while (cin >> n >> a >> b >> c >> x, n)
	{
		for (int i = 0; i < n; i++)
		{
			cin >> ary[i];
		}
		int ans = 0;
		int i = 0;
		while (true)
		{
			if (ary[i] == x) i++;
			if (i == n) break;
			x = Random();
			ans++;
			if (ans > 10000)
			{
				ans = -1;
				break;
			}
		}
		cout << ans << endl;
	}

	return 0;
}

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

const int N = 310;
const int M = N << 1;
const int Mod = 1e9 + 7;
int n, m, ans, cnt, tot, a[M], b[M], c[M], f[M][N][N];

inline int dec(int x) {return x < 0 ? x + Mod : x;}
inline int inc(int x) {return x >= Mod ? x - Mod : x;}

template <class T> inline void in(T &x) {
	x = 0; int f = 0; char ch = getchar();
	for (; ch<'0' || ch>'9';) {if (ch=='-') f=-1; ch = getchar();}
	for (; ch>='0' && ch<='9';) x = x*10 + ch-'0', ch = getchar();
	x = f ? -x : x;
}

int main() {
	in(n), m = n << 1;
	for (int i = 1; i <= m; ++i) in(a[i]);
	for (int i = 1; i <= m; i += 2)
		if (~a[i] && ~a[i + 1]) b[a[i]] = b[a[i + 1]] = 2;
		else if (~a[i]) b[a[i]] = 1;
		else if (~a[i + 1]) b[a[i + 1]] = 1;
		else ++cnt;
	for (int i = 1; i <= m; ++i)
		if (b[i] & 1) c[++tot] = 1;
		else if (!b[i]) c[++tot] = 0;
	f[tot][0][0] = 1;
	for (int i = tot; i; --i)
		for (int j = 0; j <= tot && j <= n; ++j)
			for (int k = 0; k <= tot && k <= n; ++k) if (c[i]) {
				f[i - 1][j + 1][k] = inc(f[i - 1][j + 1][k] + f[i][j][k]);
				if (k) f[i - 1][j][k - 1] = inc(f[i - 1][j][k - 1] + f[i][j][k]);
			} else {
				f[i - 1][j][k + 1] = inc(f[i - 1][j][k + 1] + f[i][j][k]);
				if (k) f[i - 1][j][k - 1] = inc(f[i - 1][j][k - 1] + f[i][j][k]);
				if (j) f[i - 1][j - 1][k] = inc(f[i - 1][j - 1][k] + 1LL * f[i][j][k] * j % Mod);
			}
	ans = f[0][0][0];
	for (int i = 1; i <= cnt; ++i) ans = 1LL * ans * i % Mod;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 225536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double ld;
#define F first
#define S second
#define fi(a, b) for(ll i=(a);i<=b;i++)
#define fj(a, b) for(ll j=(a);j<=b;j++)
#define fid(a, b) for(ll i=(a);i>=b;i--)
#define fjd(a, b) for(ll i=(a);i>=b;j--)

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for(auto v : V) os << v << " ";
    os << "]";
	return os;
}
template<class T> ostream& operator<<(ostream &os, set<T> S){
    os << "{ ";
    for(auto s:S) os<<s<<" ";
    return os<<"}";
}
template<class T> ostream& operator<<(ostream &os, multiset<T> S){
    os << "{ ";
    for(auto s:S) os<<s<<" ";
    return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
    os << "{ ";
    for(auto m:M) os<<"("<<m.F<<":"<<m.S<<") ";
    return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, unordered_map<L,R> M) {
    os << "{ ";
    for(auto m:M) os<<"("<<m.F<<":"<<m.S<<") ";
    return os<<"}";
}

// Kevin Mathew T
// Birla Institute of Technology, Mesra
// LinkedIn - https://www.linkedin.com/in/KevinMathewT/
// GitHub - https://github.com/KevinMathewT
// CodeForces - https://codeforces.com/profile/KevinMathew
// CodeChef - https://www.codechef.com/users/KevinMathew
// HackerRank - https://www.hackerrank.com/KevinMathew

const ll N = 100010, M = 1e9 + 7;
ll n, a[N], m;

void solve(){
	cin >> n >> m;
	fi(0, n - 1) cin >> a[i];

	priority_queue<ll> pq;
	fi(0, n - 1) pq.push(a[i]);

	while(m--) {
		ll top = pq.top(); pq.pop();
		top = top / 2LL;
		pq.push(top);
	}

	ll tot = 0;
	while(!pq.empty()) {
		tot += pq.top();
		pq.pop();
	}

	cout << tot << '\n';
}

int main(){
	// freopen("input.txt", "r", stdin);		//Comment
	// freopen("output.txt", "w", stdout);		//this out.
	ios::sync_with_stdio(false);			//Not
	cin.tie(NULL);							//this.
	cout.tie(0);							//or this.

	// ll T;
	// cin >> T;
	// while(T--)
		solve();

	return 0;
}

Measured memory_bytes: 2168
#include<iostream>
//scanfのdouble型は%lf　printfのdoubleは%f
int main(){
 
	int A,B;
	std::cin >> A >> B;
	
	int coin = 0;
	//int array[2];
	int total;
	int answer = 0;
	for (int i = 0;i<2;i++) {
		for (int j = 0;j<2;j++) {
			total = 0;
			int array[2] = {A,B};
			total += array[i];
			array[i] -=1;
			total += array[j];
			if (answer<total) {
				answer = total;
			}
		}
	}
 
	std::cout << answer << std::endl;
 
	return 0;
}

Measured memory_bytes: 256
n = int(input())

num = -n
ans = ""
#num = -n

if n == 0:
    print(0)
    exit()

while num!= 0:
    if num % 2 == 0:
       ans = "0" + ans
    else:
        ans = "1" + ans
    num //= (-2)
    #print(num)
    
print(ans)

Measured memory_bytes: 2940
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
#define MOD 924844033LL
using namespace std;
typedef long long ll;

int n,k;

int main(void){
	scanf("%d%d",&n,&k);
	vector<int> cnt(n+1,0);
	cnt[0]=1;
	//abs(a[i]±i)=kに関係するのは2k個毎に離れた要素の集合なので, 集合毎にabs(a[i]±i)=kを満たすものを数えていく
	for(int i=0;i<2*k;i++){
		vector<vector<int> > dp(2,vector<int>(n+1,0));
		if(i<k){
			dp[0]=cnt;
		}else{
			dp[1]=cnt;
		}
		for(int j=i;j<n;j+=2*k){
			vector<vector<int> > nextDp(2,vector<int>(n+1,0));
			for(int a=0;a<2;a++){
				for(int b=0;b<n;b++){
					//abs(a[i]-i)=kが使われていない時にabs(a[i]-i)=kを使うとき
					if(a==1){
						nextDp[1][b+1]+=dp[a][b];
						nextDp[1][b+1]%=MOD;
					}
					//abs(a[i]+i)=kを使うとき
					if(j+k<n){
						nextDp[0][b+1]+=dp[a][b];
						nextDp[0][b+1]%=MOD;
					}
					//abs(a[i]±i)=kを使わない時
					nextDp[1][b]+=dp[a][b];
					nextDp[1][b]%=MOD;
				}
			}
			dp.swap(nextDp);
		}
		for(int b=0;b<=n;b++){
			cnt[b]=(dp[0][b]+dp[1][b])%MOD;
		}
	}
	ll tmp=1;
	ll ans=0;
	//包除原理で答えを求める
	for(int i=0;i<=n;i++){
		if((n-i)%2==0){
			ans+=tmp*cnt[n-i];
		}else{
			ans-=tmp*cnt[n-i];
		}
		ans%=MOD;
		ans+=MOD;
		ans%=MOD;
		tmp*=i+1;
		tmp%=MOD;
	}
	printf("%lld\n",ans);
	return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    long double a, b;
    cin >> a >> b;
    LL t = a * b;
    cout << t << endl;
    return 0;
}



Measured memory_bytes: 3812
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    C = readline().strip()

    left = 0
    right = N - 1

    ans = 0
    while True:
        while left < N and C[left] == 'R':
            left += 1
        while right >= 0 and C[right] == 'W':
            right -= 1

        if left < right:
            ans += 1
            left += 1
            right -= 1
        else:
            break

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 67708
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<int>>;
#define MAX 1000000007

class Calc_Mod{//calculate mod
    public:
        unsigned int mod=1000000007;
        ll plus_mod(ll a,ll b){
            return (a+b)%mod;
        }
        ll minus_mod(ll a,ll b){
            return (a-b)%mod;
        }
        ll multi_mod(ll a,ll b){
            return a*b%mod;
        }
        ll LSM(ll a,int b){//a^b%mod
            queue<int> q;
            while(b>=1){
                q.push(b%2);
                b/=2;
            }
            ll ans=1;
            while(!q.empty()){
                if(q.front()==1){
                    ans=multi_mod(ans,a);
                }
                a=multi_mod(a,a);
                q.pop();
            }
            return ans;
        }
        ll div_mod(ll a,ll b){// a/b
            return multi_mod(a,LSM(b,mod-2));
        }
        ll combi(ll a,ll b){//aCb
            ll ans=1;
            ll kaijo=1;
            rep(i,b){
                ans=multi_mod(ans,a-i);
                kaijo=multi_mod(kaijo,b-i);
            }
            ans=div_mod(ans,kaijo);
            return ans;
        }
        
};

int main()
{
    ll n;
    cin >> n;
    vector<ll> l(n);
    rep(i,n)cin >> l[i];
    ssort(l);
    ll count=0;
    rep(i,n-2){
        for(int j=i+1;j<n-1;++j){
            if(l[j]>=l[i]+l[j+1]){
                break;
            }
            for(int k=j+1;k<n;++k){
                if(l[k]<l[i]+l[j]){
                    count++;
                }else{
                    break;
                }
            }
        }
    }
    cout << count << endl;
    
}

Measured memory_bytes: 3580
from itertools import permutations

def warshall_floyd(V, E):
    INF = 10 ** 9
    d = [[INF for j in range(V)] for i in range(V)]
    for i, j, c in E:
        d[i - 1][j - 1] = c
        d[j - 1][i - 1] = c
    for k in range(V):
        for i in range(V - 1):
            for j in range(i, V):
                dk = d[i][k] + d[k][j]
                if d[i][j] > dk:
                    d[i][j] = dk
                    d[j][i] = dk
    return d

N, M, R = map(int, input().split())
r = list(map(int, input().split()))
E = [list(map(int, input().split())) for _ in range(M)]
d = warshall_floyd(N, E)

ans = 10 ** 9
for ri in permutations(r):
    x = 0
    for i in range(R - 1):
        x += d[ri[i] - 1][ri[i + 1] - 1]
    if ans > x:
        ans = x
print(ans)


Measured memory_bytes: 8240
#!/usr/bin/env python
import sys
import re
from collections import deque, defaultdict
from itertools import combinations, combinations_with_replacement
import bisect
from math import factorial, sqrt, log, ceil, floor
sys.setrecursionlimit(1000000)


def main():
    input = sys.stdin.readline
    #N, M = map(int, input().split())
    #N, K = map(int, input().split())
    #ps = list(map(int, input().split()))

    N = int(input())

    A_all = []
    for i in range(N):
        As = list(map(int, input().split()))
        A_all.append(As)
    A_index = [0] * N

    candidates = set(range(1, N+1))
    for i in range(N * (N - 1) // 2 + 1):
        matches = set()
        for j in candidates:
            A_idx = A_index[j - 1]
            if A_idx >= N - 1:
                continue
            k = A_all[j - 1][A_idx]
            B_idx = A_index[k - 1]
            if B_idx >= N - 1:
                continue
            if j == A_all[k - 1][B_idx]:
                pair = tuple(sorted([j, k]))
                matches.add(pair)

        if not matches:
            break

        candidates = set()
        for match in matches:
            for j in match:
                A_index[j - 1] += 1
                candidates.add(j)

    if all([A_idx == N - 1 for A_idx in A_index]):
        print(i)
    else:
        print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 88828
a,b = map(int, input().split())

if b<10:
    N=10*a+b
elif b<100:
    N=100*a+b
else:
    N=1000*a+b
    
flag = -1

for i in range(317):
    if i*i == N:
        flag=1

if flag==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string.h>
#include<queue>
#include<cmath>
using namespace std;
typedef long long ll;

int a[1234567];
int b[1234567];
int main() {
	int n, k, q;
	cin >> n >> k >> q;
	for (int i = 1; i <= n; i++) a[i] = k;
	for (int i = 1; i <= n; i++) b[i] = a[i] - a[i - 1];

	while (q--) {
		cin >> k;
		if (k == 1) {
			b[2] --;
			b[n + 1]++;
		}
		else if (k == n) {
			b[1]--;
			b[n]++;
		}
		else {
			b[1]--;
			b[k]++; b[k + 1]--;
			b[n + 1]++;
		}
	}
	for (int i = 1; i <= n; i++) {
			a[i] = b[i] + a[i - 1];
			if (a[i] > 0) puts("Yes");
			else puts("No");
		}
	
		
	
	return 0;
}






Measured memory_bytes: 3072
num1 = int(input())
num2 = input()
num3 = input()
num4 = input()

num2 = list(num2)
num3 = list(num3)
num4 = list(num4)

_num = 0
for num in range(num1):
    if(num2[num] == num3[num]):
        if(num2[num] == num4[num]):
            _num += 0
        else:
            _num += 1
    else:
        if(num2[num] == num4[num]):
            _num += 1
        else:
            if(num3[num] == num4[num]):
                _num += 1
            else:
                _num += 2

print(_num)

Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))

l = []
for i in range(1<<N):
    cond = [0]*N
    for j in range(N):
        if 1&(i>>j):  # 右シフトして論理積（bit全探索）
            cond[j] = 1
    s = 0
    for i, j in zip(cond, A):
        if i != 0:
            s += j
    l.append(s)

for mm in m:
    if mm in l:
        print('yes')
    else:
        print('no')


Measured memory_bytes: 43080
#include <bits/stdc++.h>
using  namespace  std;
using ll=long long;
int main(){
  int a,b;
  cin>>a>>b;
  if(a==1)a+=13;
  if(b==1)b+=13;
  if(a==b)cout<<"Draw"<<endl;
  else if(a>b)cout<<"Alice"<<endl;
  else cout<<"Bob"<<endl;
}

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

int main(){
	int a, b, c, x;
	cin >> a >> b >> c >> x;
	int pat = 0;
	int aStt = ( x - 100*b - 50*c ) / 500;
	if(aStt<0){
		aStt = 0;
	}
	for(int aIdx=aStt; aIdx<a+1; aIdx++){
		int aTemp = 500*aIdx;
		if(aTemp > x){
			break;
		}
		int bStt = ( x - 500*aIdx - 50*c ) / 100;
		if(bStt < 0){
			bStt = 0;
		}
		for(int bIdx=bStt; bIdx<b+1; bIdx++){
			int bTemp = aTemp + 100*bIdx;
			if(bTemp > x){
				break;
			}
			if((x-bTemp)<=50*c){
				pat++;
			}
		}
	}
	cout << pat << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(a) sort(a.begin(),a.end())
#define rSORT(a) sort(a.rbegin(),a.rend())
#define fSORT(a,f) sort(a.begin(),a.end(),f)
#define all(a) a.begin(),a.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define tp(a,i) get<i>(a)
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    string s; cin >> s;
    if (s == "RRR")print(3);
    else if (s == "RRS" || s == "SRR")print(2);
    else if (s == "SSS")print(0);
    else print(1);

    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

int main() {
    long long t;
    string s, x;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    } else {
        no();
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC129C
{
    class Program
    {
        static int[] dp;
        static int Max = (int)Math.Pow(10, 9) + 7;
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();
            int N = int.Parse(input[0]);
            dp = new int[N + 1];
            for (int i = 0; i < N + 1; i++)
            {
                dp[i] = Max;
            }
            dp[0] = 1;
            dp[1] = 1;
            int M = int.Parse(input[1]);
            int[] a = new int[M];
            for (int i = 0; i < M; i++)
            {
                a[i] = int.Parse(Console.ReadLine());
                dp[a[i]] = 0;
            }
            for (int i = 0; i <= N; i++)
            {
                dp_Sum(i);
            }
            Console.WriteLine(dp_Sum(N));
        }
        static int dp_Sum(int i)
        {
            if (i == 0)
            {
                return 1;
            }
            if (i == 1)
            {
                return 1;
            }
            dp[i]=Math.Min(dp[i],(dp[i - 1]%Max + dp[i - 2]%Max)%Max);
            return dp[i];
        }
    }
}


Measured memory_bytes: 13908
import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from heapq import heappush, heappop
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    stuff = []
    for x in input().split():
        heappush(stuff, -int(x))

    for i in range(M):
        heappush(stuff, -math.floor(-heappop(stuff) / 2))

    print(-sum(stuff))


if __name__ == '__main__':
    main()

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

#define N 100005

typedef struct pp{
	
	char name[100];
	int y;
	
}P;

P Q[N+1];
int head,tail,n;

void enqueue(P x); //キュー末尾にヨウ素を追加
P dequeue();//キューの先頭から要素を取り出す
int min(int a,int b){
	int t;
	if(a>=b){t=b;}
	else {t=a;}
	
	return t;}

  /*／￣＼
○ ／￣￣￣＼ヘ
  /・   ・        ＼>
／￣￣￣＼   Ｖ|
｜ ――― ｜   ｜|
＼＿＿＿／   ∧|
    ＼                  ／〉
       ￣￣￣￣
    ヽ(´･w･)ﾉ
         |    /
         UU
うっせぇ、アンコウ投げんぞ!*/

int main(void){
	
	int n,c,q;
	int elaps = 0;
	P u;
	scanf("%d %d",&n, &q);
	
	for(int i=1;i<=n;i++){
		scanf("%s",Q[i].name);
		scanf("%d",&Q[i].y);
	}
	
	head =1;
	tail = n+1;
	
	while(head != tail){
		
		u = dequeue();
		c = min(q, u.y); //処理時間のどっちが短いか
		u.y -=c; //残り処理時間
		elaps += c;  //トータルの処理時間
		
			if(u.y>0){ enqueue(u);}
		else{
			printf("%s %d\n",u.name,elaps);
		}
				
	}
	
	
	return 0;
}

void enqueue(P x){
	Q[tail] = x;
	tail =( tail + 1) % N;
}

P dequeue(){
		P x = Q[head];
	head = (head + 1) % N;
	return x;
}



Measured memory_bytes: 12888
#include <bits/stdc++.h>
using namespace std;
#define iinf 2000000000
#define linf 1000000000000000000LL
#define ulinf 10000000000000000000ull
#define MOD1 1000000007LL
#define mpr make_pair
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned long UL;
typedef unsigned short US;
typedef pair < int , int > pii;
clock_t __stt;
inline void TStart(){__stt=clock();}
inline void TReport(){printf("\nTaken Time : %.3lf sec\n",(double)(clock()-__stt)/CLOCKS_PER_SEC);}
template < typename T > T MIN(T a,T b){return a<b?a:b;}
template < typename T > T MAX(T a,T b){return a>b?a:b;}
template < typename T > T ABS(T a){return a>0?a:(-a);}
template < typename T > void UMIN(T &a,T b){if(b<a) a=b;}
template < typename T > void UMAX(T &a,T b){if(b>a) a=b;}
int n;
LL a[200005],pre[200005],suf[200005],cutl[200005],cutr[200005];
LL x[4];
int main(){
    // inputting start
    // 数据结构记得初始化！ n，m别写反！
    int i,j,k;
	scanf("%d",&n);
	for(i=0;i<n;++i) scanf("%lld",a+i);
    #ifdef LOCAL
        TStart();
    #endif
    // calculation start
    // 数据结构记得初始化！ n，m别写反！
    pre[0]=a[0];
	suf[n-1]=a[n-1];
	for(i=1;i<n;++i) pre[i]=pre[i-1]+a[i];
	for(i=n-2;i>=0;--i) suf[i]=suf[i+1]+a[i];
	j=0;
	if(n==4){
		sort(a,a+n);
		printf("%lld\n",a[3]-a[0]);
		return 0;
	}
	for(i=1;i<n-2;++i){
		while(j<i-1 && ABS((pre[i]-pre[j])-pre[j])>ABS((pre[i]-pre[j+1])-pre[j+1]))
			++j;
		cutl[i]=j;
	}
	j=n-1;
	for(i=n-3;i>=1;--i){// i+1 ~ n-1
		while(j>i+2 && ABS((suf[i+1]-suf[j])-suf[j])>ABS((suf[i+1]-suf[j-1])-suf[j-1]))
			--j;
		cutr[i]=j;
	}
	LL ret=linf;
	for(i=1;i<n-2;++i){
		x[0]=pre[cutl[i]];
		x[1]=pre[i]-x[0];
		x[2]=suf[cutr[i]];
		x[3]=suf[i+1]-x[2];
		sort(x,x+4);
		UMIN(ret,x[3]-x[0]);
	}
	printf("%lld\n",ret);
    #ifdef LOCAL
        TReport();
    #endif
    return 0;
}

Measured memory_bytes: 8064
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define rep(i, f, n) for (int i = (f); i < (int)(n); i++)
#define repe(i, f, n) for (int i = (f); i <= (int)(n); i++)
using namespace std;
using ll = long long;
using pint = pair<int, int>;

const int MAX = 1e5 + 1;

int main() {
  int n, a;
  cin >> n;
  vector<int> A(MAX);
  double tot = 0;
  rep(i, 0, n) {
    cin >> a;
    A[a]++;
    A[a + 1]++;
    A[a + 2]++;
  }

  int ans = 0;
  rep(i, 0, MAX) ans = max(ans, A[i]);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3780
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
a=list(map(int,input().split()))
if n==0:
    if a[0]==0:
        print(0)
    elif a[0]==1:
        print(1)
    else:
        print(-1)
    quit()
if a[0]==1:
    if n!=0:
        print(-1)
        quit()

if a[0]>1:
    print(-1)
    quit()

maxnode=[1]
for i in range(1,n):
    maxnode.append(maxnode[i-1]*2-a[i])
    if maxnode[i-1]*2-a[i]<=0:
        print(-1)
        quit()
# print(maxnode)

maxnode.append(0)

ans=1
for i in range(1,n+1)[::-1]: 
    # now=pow(2,i)
    # print(now)

    # if i==n:
    #     if a[i]>maxnode[-1]*2:
    #         print(-1)
    #         quit()
    #     else:
    #         maxnode[-1]=min(a[i],maxnode[-1])
    #         ans+=a[i]
    # else:
    if maxnode[i]+a[i]>maxnode[i-1]*2:
        print(-1)
        quit()
    else:
        maxnode[i-1]=min(maxnode[i]+a[i],maxnode[i-1])
        ans+=maxnode[i]+a[i]
    
print(ans)

Measured memory_bytes: 702460
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  string S;
  cin >> S;
  for(int i=0;i<S.size();i++){
    if(S[i]=='?') cout << "D";
    else cout << S[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

void dfs(vvi g,int v, int &time,vb &seen,vi &first_time,vi &last_time) {
  first_time[v]=++time;
  seen[v]=true;
  for(auto next_v:g[v]) {
    if(seen[next_v]) continue;
    dfs(g,next_v,time,seen,first_time,last_time);
  }
  last_time[v]=++time;
}



int main() {
  int n,q;
  cin >> n >> q;
  vvll ab(n);
  REP(i,n-1) {
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    ab[a].push_back(b);
    ab[b].push_back(a);
  }
  vll ans(n,0);
  REP(i,q) {
    int p,x;
    cin >> p >> x;
    p--;
    ans[p]+=x;
  }
  auto f=[&](auto f,int c, int p)->void{
    for(auto y:ab[c]) {
      if(y!=p) {
        ans[y]+=ans[c];
        f(f,y,c);
      }
    }
  };
  f(f,0,-1);
  REP(i,n) {
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 22528
#include<stdio.h>
#include<math.h>
int main(void)
{
	int a,b;
	int flag = 1;
	scanf("%d %d",&a,&b);
	int i,j;
	if(a > b)
	{
		int temp = b;
		b = a;
		a = temp; 
	}
	for(i = a;i<=b;i++)
	{
		if(abs(a-i) == abs(b-i))
		{
			printf("%d",i);
			flag = 1;
			break;
		}
		else
			flag = 0;
	}
	if(flag == 0) printf("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 128
using System;
class Program
 {
   static void Main(string[] args)
   {
     int n;
     n = int.Parse(Console.ReadLine());

     if(n<105)
     {
       Console.WriteLine("0");
     }else if(n<135)
     {
       Console.WriteLine("1");   
     }else if(n<165)
     {
       Console.WriteLine("2");   
     }else if(n<189)
     {
       Console.WriteLine("3");   
     }else if(n<195)
     {
       Console.WriteLine("4");   
     }else 
     {
       Console.WriteLine("5");   
     }
     
   }
 }

Measured memory_bytes: 11092
#include<iostream>
#include<algorithm>
using namespace std;
int main(void) {
  
int a, b, c, d;
cin >> a >> b>> c >> d;
int x=0;
int y=0;
  
  x = min(a, b);
  y = min(c, d);
  
  cout << x+y << endl;
}

  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
    int n;
    cin>>n;
    vector<int> A(n),C(n-1);
    rep(i,n) cin>>A[i];
    int sum=0;
    rep(i,n){
        int b;
        cin>>b;
        sum+=b;
    }
    rep(i,n-1) cin>>C[i];
    rep(i,n-1) if(A[i]+1==A[i+1]) sum+=C[A[i]-1];
    cout<<sum<<endl;
    return 0;
}

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

using namespace std;

int main(){
	string S;
	
	cin >> S;
	
	if((S.at(0) == S.at(1)) || (S.at(1) == S.at(2)) || (S.at(2) == S.at(3))){
		cout << "Bad" << endl;
	}else{
		cout << "Good" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int A,B,C,D; cin>>A>>B>>C>>D;
  cout<<max(A*B,C*D)<<endl;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define L(i, m, n) for(int i(m);i < n;i++)
#define pb push_back
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define in(x) cin >> x
#define SZ(X) int(X.size())
#define ff first
#define ss second
#define RF(X) freopen(X, "r", stdin)
#define WF(X) freopen(X, "w", stdout)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<int, string> pis;
typedef vector<string> vs;
typedef pair<pair<int, int>, pair<int, int > > piiii;

ll a[200005],n,x,y,ans;
int main(){
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		y+= a[i];
	}
	x=a[0];
	y-=a[0];
	ans=abs(x-y);
	for(int i = 1;i < n-1;i++){
		x+=a[i];
		y-=a[i];
		ans=min(ans,abs(x-y));
	}
	cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 1920
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

using namespace std;
using ll = long long;
using ull = unsigned long long;

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

    vector<int> d(K);
    vector<vector<int>> A(K, vector<int>());

    rep(i, K) {
        cin >> d[i];
        A[i].resize(d[i]);
        rep (j, d[i]) {
            cin >> A[i][j];
        }
    }

    int ans = 0;
    rrep(i, 1, N) {
        bool have = false;
        for(auto v : A) {
            for (auto p : v) {
                if (p == i) have = true;
            }
        }
        if (!have) ans++;
    }

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


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

using namespace std;

const int maxn = 20, maxans = 1e3;
int d, g, p[maxn], c[maxn], ans;

int main(){
	cin >> d >> g;
	for (int i = 0; i < d; ++i)
		cin >> p[i] >> c[i];
	int mask = 1 << d;
	ans = maxans;
	for (int i = 0; i < mask; ++i) {
		int k = 0, sum = 0, ind = 0;
		for (int j = 0; j < d; ++j)
			if (i >> j & 1) {
				k += c[j] + p[j] * 100 * (j + 1);
				sum += p[j];
			}
			else 
				ind = j;
		if (k < g) {
			if (k + (p[ind] - 1) * 100 * (ind + 1) < g)
				continue;
			sum += ceil(double(g - k) / (100 * (ind + 1)));
		}
		ans = min(ans, sum);
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define INF 10000000000000001
#define F first
//#define S second
#define LB lower_bound
#define UB upper_bound
#define vc vector
#define vll vector<long long>
#define pll pair<long long,long long>
#define pb push_back
#define all(v) v.begin(),v.end()
#define T ll test;cin>>test; while(test--)
#define rep(i,a,n) for(ll i=a;i<(long long)n;++i)
#define repr(i,n,a) for(ll i=n;i>(long long)a;--i)
#define MAX 100005
#define sz(x) (ll)x.size()
#define ins insert
#define mp make_pair
#define int  long long
typedef long long ll;
typedef long double ld;
using namespace std;
//int nCrModp(int n, int r, int p) 
//{ 
//    if (r > n - r) 
//        r = n - r; 
//    int C[r + 1]; 
//    memset(C, 0, sizeof(C)); 
//  
//    C[0] = 1;  
//    for (int i = 1; i <= n; i++) {  
//        for (int j = min(i, r); j > 0; j--) 
//            C[j] = (C[j] + C[j - 1]) % p; 
//    } 
//    return C[r]; 
//} 
int power(int x, unsigned int y, int p)  
{  
    int res = 1;     
  
    x = x % p;  
   
    if (x == 0) return 0; 
  
    while (y > 0)  
    {  

        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}  

signed  main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	ll n;
	cin>>n;
	ll x[n],y[n],dif[n],ad[n];
	rep(i,0,n)
	{
		cin>>x[i]>>y[i];
		dif[i]=x[i]-y[i];
		ad[i]=x[i]+y[i];
	}
	sort(dif,dif+n);
	sort(ad,ad+n);
	cout<<max((dif[n-1]-dif[0]),(ad[n-1]-ad[0]))<<endl;
}

Measured memory_bytes: 9900
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pllll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  // ll n, m;
  // cin >> n >> m;
  ll h, w, n;
  cin >> h >> w >> n;
  vector< vi > arr(h, vi(w));
  int k = 0, x;
  fi(0, n) {
    cin >> x;
    fj(0, x) {
      arr[k / w][k % w] = i + 1;
      k++;
    }
  }

  fi(0, h) {
    if(i % 2)
      reverse(all(arr[i]));
    fj(0, w)
      cout << arr[i][j] << " ";
    cout << endl;
  }
  
  // cout << ans << endl;
  return 0;
}



Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        String line=sc.nextLine();
        char[] num=new char[line.length()];
        for(int i=0;i<num.length;i++){
            if(line.charAt(i)=='1')
                num[i]='9';
            else if(line.charAt(i)=='9')
                num[i]='1';
            else
                num[i]=line.charAt(i);
            System.out.print(num[i]);
        }
        System.out.println();
    }
}


Measured memory_bytes: 23764