akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, a[222222], A[222222];

  memset(A, 0, sizeof(A));

  std::cin >> N;

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

  for (int j = 0, b = 1; j < 31; j ++, b <<= 1) {
    int c = 0;

    for (int i = 0; i < N; i ++)
      if (a[i] & b)
        c ++;

    bool rev = c % 2;

    for (int i = 0; i < N; i ++)
      if (rev) {
        if ((a[i] & b) == 0)
          A[i] |= b;
      }
      else {
        A[i] |= a[i] & b;
      }
  }

  for (int i = 0; i < N; i ++)
    std::cout << A[i] << ' ';
  std::cout << std::endl;

  return 0;
}


Measured memory_bytes: 5240
#define _GLIBCXX_DEBUG
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

void solve() {
    string W, S;
    cin >> W;
    transform(W.begin(), W.end(), W.begin(), ::toupper);
    int ans = 0;
    while (cin >> S) {
        if (S == "END_OF_TEXT") {
            break;
        }
        transform(S.begin(), S.end(), S.begin(), ::toupper);
        if (S == W) {
            ans++;
        }
    }
    cout << ans << "\n";
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 3212
import sys

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


def resolve():
    n = int(input())
    D = list(map(int, input().split()))

    res = 0
    for i in range(n):
        for j in range(i + 1, n):
           res += D[i] * D[j]
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3060
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>
#include<stack>
#include<utility>
#include<map>
#include<queue>

using namespace std;

long long n, k, a[5000], d = 0;

long long solve(long long t, long long s) {
	if (t == n)
		return 0;
	if (a[t] >= s) {
		d = t+1;
		return solve(t + 1, s);
	}
	else return solve(t + 1, s - a[t]);
}

int main() {
	cin >> n >> k;
	for (long long i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n, greater<int>());
	solve(0, k);
	cout << n - d << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <math.h>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <queue>
#include <random>
#include <unordered_set>
#include <unordered_map>
#define DEBUG
#define fi first
#define se second
#define pqueue priority_queue
#define pb(x) push_back(x)
#define endl '\n'
#define all(x) x.begin(), x.end()
#define int long long
#define mk(a, b) make_pair(a, b)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ull> vull;
typedef vector<ll> vll;
// typedef tuple<int, int, int> tiii;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector< vector<int> > vvi;
typedef vector<char> vc;

const int INF = 1e9;
const ll INFLL = 1e16;
const int MOD = 1000000007;
const int MAXN = 3e5;
//const ld eps = 1e-6;
const ld eps2 = 1e-9;
const int MOD2 = 998244353;
const int dosz = 5e5;
const int SZ = (1<<18);
const ld PI = atan2l(0, -1);


void fast_io(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
        // freopen("a.in", "r",stdin);
#else
       // freopen("substrcmp.in", "r", stdin);
       // freopen("substrcmp.out", "w", stdout);
#endif
}

void solve(){
    int x;
    cin >> x;
    int ans = 0;
    ans += x/500 * 1000;
    x %= 500;
    ans += x/5 * 5;
    cout << ans << endl; 
}

signed main() {
    fast_io();
    int q = 1;
    // cout << fixed << setprecision(6);
    // cin >> q;
    // cout << 1 << endl;
    while(q--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<string.h>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<bitset>
#include <cmath>
#include <limits>
#include <numeric>
#include <cmath>
#include <limits>

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

int main(){
    ll n,k,s;
    scanf("%lld%lld%lld",&n,&k,&s);
    ll val;
    if(s==1000000000)val=1000000000-1;
    else val = 1000000000;
    REP(i,k)printf("%lld ",s);
    REP(i,n-k)printf("%lld ",val);
    printf("\n");
    return 0;
}

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

int main() {
        string a, b;
        cin >> a >> b;

        size_t i, j;
        bool flag = true;
        for (i=0, j=0; i<a.size() || j<b.size(); flag = !flag) {
                if (flag) cout << a[i++];
                else cout << b[j++];
        }
        cout << endl;
        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <utility>
using namespace std;

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

    int a[N];
    bool isapproved = true;
    for(int i=0; i<N; ++i) {
        int a;
        cin >> a;
        if(a%2 == 0) {
            if(a%3!=0 && a%5!=0) {
                isapproved = false;
                break;
            }
        }
    }

    if(isapproved) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;

}

Measured memory_bytes: 256
/*
* @Author: Kabid
* @Date:   {{create_time}}
* @Last Modified by:   Kabid
* @Last Modified time: 2020-09-20 20:58:29
*/
#include<bits/stdc++.h>
#include<cstdlib>
using namespace std;
#define ll long long
#define  in(x) scanf("%d",&x);
#define out(x) printf("%d",x);
#define  ins(x)  scanf("%s",x);
#define outs(x) printf("%s",x);
#define lin puts("");
#define _ putchar(' ');

int t;       //test cases
ll i, j;	 //iterators
ll n, k ,  q,  d, m, c, c1, c2, d1, x; //variables;
ll mx1 = LLONG_MIN, mx2 = LLONG_MIN, mx = LLONG_MIN, mn = LLONG_MAX;		// max min
char s[6], s1, s2;		// string
ll a [1000001], b [200001] ;
bool mox [1000001];	// array
map <int, int > mp;
vector <vector<ll>> vc;
vector <ll> v;
set <ll> st;
bool r;
ll p = 1000000007;
ll power(ll x, unsigned ll y, ll p)
{
	ll res = 1;     // Initialize result

	x = x % p; // Update x if it is more than or
	// equal to p

	if (x == 0) return 0; // In case x is divisible by p;

	while (y > 0)
	{
		// If y is odd, multiply x with result
		if (y & 1)
			res = (res * x) % p;

		// y must be even now
		y = y / 2; // y = y/2
		x = (x * x) % p;
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//cin >> t; q = t;
	t = 1;

	while (t--) {

		cin >> n;
		if (n == 1) {
			cout << 0 << endl;
			continue;
		}
		/*if (n == 2) {
			cout << 2 << endl;
			continue;
		}*/
		//ll ans=power(10,n-2,p);
		ll ans = 1;
		ll ans2 = 1;
		ll ans3 = 1;
		for (i = 1; i <= n ; i++) {
			ans = ((ans ) * 10) % p;
			ans2 = (ans2 * 9) % p;
			ans3 = (ans3 * 8) % p;
		}
		//cout<<ans<<' '<<ans2<<' '<<ans3<<endl;

		cout << ((ans -2*ans2 +ans3)%p +p) %p<< endl;


		//cout<<mod;
	}


	return 0;

}

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

int main() {
    string S;
    cin >> S;
    ll ans = 0;
    for (int i = 0; i <= ll(S.size()) / 2 - 1; i++) {
        if (S[i] != S[S.size() - i - 1]) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;

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

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int>d(n);
	
	rep(i, n) cin >> d[i];
	sort(d.begin(), d.end());
	
	int ans = 0;
	int tmp = 0;
	rep(i ,n){
		if(tmp != d[i]){
			tmp = d[i];
			ans++;
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
using namespace std;
int a,b;
int main()
{
  cin>>a>>b;
  a%=500;
  if(a>b)cout<<"No";
  else cout<<"Yes";
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f3f
using namespace std;
int main() {
	int n, a[110];
	long long ans, sum = INF;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	sort(a, a + n);
	for (int i = a[0]; i <= a[n - 1]; i++) {
		ans = 0;
		for (int j = 0; j < n; j++) {
			ans += (a[j] - i) * (a[j] - i);
		}
		sum = min(ans, sum);
	}
	cout << sum << endl;
	return 0;
} 

Measured memory_bytes: 256
package main
 
import (
	"fmt"
	//"math"
)
 
var S string
var ANS int
func main() {
	fmt.Scan(&S)
	fmt.Scan(&S)
	s := string(0) 
	for i := 0; i < len(S); i++ {
		v := S[i:i+1]
		if s != v {
			ANS++
			s = v
		}
	}
	fmt.Println(ANS)
}


Measured memory_bytes: 2492
#7-C tree walk
class node():
    def __init__(self):
        self.left=-1
        self.right=-1
        self.parent=-1

def preorder(i):
    print(' '+str(i),end='')
    if nodes[i].left!=-1:
        preorder(nodes[i].left)
    if nodes[i].right!=-1:
        preorder(nodes[i].right)
    
def inorder(i):
    if nodes[i].left!=-1:
        inorder(nodes[i].left)
    print(' '+str(i),end='')
    if nodes[i].right!=-1:
        inorder(nodes[i].right)
        
def postorder(i):
    if nodes[i].left!=-1:
        postorder(nodes[i].left)
    if nodes[i].right!=-1:
        postorder(nodes[i].right)
    print(' '+str(i),end='')
  

n=int(input())
nodes=[node() for i in range(n)]
for i in range(n):
    p,l,r=[int(i) for i in input().split()]
    nodes[p].left=l
    nodes[p].right=r
    if l!=-1:nodes[l].parent=p
    if r!=-1:nodes[r].parent=p

root=-1
for i in range(n):
    if nodes[i].parent==-1:
        root=i
        break

print('Preorder')
preorder(root)
print()

print('Inorder')
inorder(root)
print()

print('Postorder')
postorder(root)
print()




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

long long ans = 0;
bool ok(long long b) {
  bool flag = false;
  if (b < 0) {
    b *= -1;
    flag = true;
  }
  for (long long i=1; i<=sqrt(b); i++) {
    if (b % i == 0) {
      if (i * i * i * i * i == b) {
        ans = i;
        if (flag) {
          ans *= -1;
        }
        return true;
      }
    }
  }
  return false;
}
int main() {
  long long x;
  cin>>x;
  long long a = 0;
  while (true) {
    long long a5 = a * a * a * a * a;
    long long tmp = a5 - x;
    if (ok(tmp)) {
      cout<<a<<" "<<ans<<endl;
      return 0;
    }
    ++a;
  }
}

Measured memory_bytes: 3680
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	int N;
	cin >> N;
	LL a,b;
	cin >> a >> b;
	for(int i=1; i<N; i++){
		LL x,y;
		cin >> x >> y;
		for(LL j=max(a/x,b/y)-5; j<=LL_MAX; j++){
			if(x*j >= a && y*j >= b){
				a = x*j;
				b = y*j;
				break;
			}
		}
	}
	cout << a+b << endl;

	return 0;
}


Measured memory_bytes: 256
import operator
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

n, m = ril()
ls = ril()
ls2 = rils(m)
ls.sort()
ls2.sort(key=operator.itemgetter(1), reverse=True)
res = sum(ls)
index = 0
b, c = ls2[0]
for x in ls:
    if x >= c:
        break

    res += c - x
    b -= 1
    if b == 0:
        index += 1
        if index < m:
            b, c = ls2[index]
        else:
            break
print(res)

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

int main() {
  int H,W;
  while(1){
    cin >> H >> W;
    
    if(H==0 && W==0)
      break;
    
    for(int i=1; i<=H; i++){
      
      for(int j=1; j<=W; j++){
        
        if(i==1 || i==H || j==1 || j==W)
          cout << '#';
        
          else
            cout << '.';
          
        }
      cout << endl;
      
      }
      cout <<endl;
    }
  
}



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

int main() {
  string s;
  cin >> s;
  vector<string> S = {"Sunny", "Cloudy", "Rainy"};
  rep(i, 3) {
    if(s == S[i]) {
      int sub = (i + 1) % 3;
      cout << S[sub] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3492
#include <iostream>

using namespace std;
typedef long long ll;

ll calc_nmod(ll first, ll last, ll divisor)
{
  ll nfirst = (first-1) / divisor;
  ll nlast = last / divisor;
  return nlast - nfirst;
}

ll gcd(ll a, ll b)
{
  if (a > b) {
    return gcd(b, a);
  }
  if (a == 0) {
    return b;
  }
  return gcd(b % a, a);
}

int main()
{
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll nc = calc_nmod(a, b, c);
  ll nd = calc_nmod(a, b, d);
  ll ncd = calc_nmod(a, b, c*d/gcd(c, d));
  cout << b - a + 1 - (nc + nd - ncd) << '\n';
  return 0;
}


Measured memory_bytes: 256
M, D  = map(int, input().split())
cnt = 0
for i in range(D+1):
    str = "{:02d}".format(i)
    # print(str)
    d1 = str[0]
    d2 = str[1]
    if int(d1)*int(d2) <= M and int(d1)>=2 and int(d2)>=2:
        cnt += 1
        # print(int(d1)*int(d2),d1+d2)
        # print(str)
print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define ld long double
#define mod ((ll)1e9+7)
#define inf ((ll)1e18+5)
#define maxx ((ll)1e6+5)
#define pb push_back
#define endl "\n"
#define time(i) cout<<"\nTime Elapsed "<<i<<" : " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll expm(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
/*
bool sv[maxx]={0};    // returns 0 if a num is prime
int sp[maxx]={0};     // gives smallest prime factor of the number
void Sieve() {for(int i= 2; i< maxx; i+= 2) sv[i]=1,sp[i] = 2;sv[2]=0;for(ll i = 3; i < maxx; i += 2){if (!sv[i]){sp[i] = i;for (ll j = i; (j*i) < maxx; j += 2){if (!sv[j*i])sv[j*i] = true, sp[j*i] = i;}}}}
ll fact[1000007]={0}; // returns factorial of that number
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expm(fact[r],mod-2)))%mod; res=(res*(expm(fact[n-r],mod-2)))%mod; return res;}
*/
using namespace std;
signed main(){
  fast;
  //usefile;
  //test
  {
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&a!=c||a==c&&a!=b||c==b&&a!=b)
        cout<<"Yes";
    else
    {
        cout<<"No";
    }
    
  }
  //time("");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  string S;
  cin >> S;

  int flag = 0;//0はR,1はL
  int x=0;
  int y,z=0;
  vector<int> ans(S.size(),0);
  REP(i,S.size()){
    if(S.at(i)=='L'&&flag==0){
      y=i;
      flag=1;
    }else if(S.at(i)=='R'&&flag==1){
      x=z;
      z=i;
      flag=0;
      ans.at(y-1)=(y-x+1)/2+(z-y)/2;
      ans.at(y)=(y-x)/2+(z-y+1)/2;
    }
  }
  x=z;
  z=S.size();
  ans.at(y-1)=(y-x+1)/2+(z-y)/2;
  ans.at(y)=(y-x)/2+(z-y+1)/2;

  REP(i,S.size()){
    cout << ans.at(i) << " ";
  }
  cout << endl;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		double[] x = new double[n];
		double sum = 0;
		for(int i = 0;i < n;i++){
			x[i] = saori.Hayamin();
			sum = sum + x[i];
		}
		double ave = Math.round(sum/n);
		double ans = 0;
		for(int i = 0;i < n;i++){
			ans = ans + Math.pow(x[i]-ave,2);
		}
		int num = (int)ans;
		System.out.println(num);
		
		
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 22356
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a =sc.nextInt();
    int b =sc.nextInt();
    int c =sc.nextInt();
    int d = 0;
    if(a>b){
      d=a;
      a=b;
      b=d;
    }
    if(b>c){
      d=b;
      b=c;
      c=d;
    }if(a>b){
      d=a;
      a=b;
      b=d;
    }
    System.out.printf("%d %d %d\n",a,b,c);
    sc.close();
  }
}


Measured memory_bytes: 26492
#include<iostream>
#include<list>
using namespace std;
int main(){
    list<int> L;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        char s[20];
        cin>>s;
        if(s[0]=='i'){
            int x;
            cin>>x;
            L.push_front(x);
        }
        else if(s[6]=='F'){
            L.pop_front();
        }
        else if(s[6]=='L'){
            L.pop_back();
        }
        else{
            int x;
            cin>>x;
            for(list<int>::iterator it=L.begin();it!=L.end();it++){
                if(*it==x){
                    L.erase(it);
                    break;
                }
            }
        }
    }
    for(list<int>::iterator it=L.begin();it!=L.end();it++){
        if(it!=L.begin()){
            cout<<' ';
        }
        cout<<*it;
    }
    cout<<endl;
}


Measured memory_bytes: 34236
import sys

ar = []
x = sys.stdin.readline()
x = x.split(' ')
ar.extend([int(str) for str in x])
x = sys.stdin.readline()
x = x.split(' ')
ar.extend([int(str) for str in x])
x = sys.stdin.readline()
x = x.split(' ')
ar.extend([int(str) for str in x])

n = int(sys.stdin.readline())
ret = []
for i in range(n):
  b = int(sys.stdin.readline())
  if( b in ar):
    index = ar.index(b)
    ret.append(index)

result = "No"
for i in range(0,3):
  if( i*3+0 in ret and i*3+1 in ret and i*3+2 in ret ):
    result = "Yes"
  if( i+0*3 in ret and i+1*3 in ret and i+2*3 in ret ):
    result = "Yes"
if( 0 in ret and 4 in ret and 8 in ret ):
  result = "Yes"
if( 2 in ret and 4 in ret and 6 in ret ):
  result = "Yes"

print(result)



sys.stdout.flush()


Measured memory_bytes: 3064
#include <iostream>
#include <set>

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

using namespace std;

string rev(string str){
	string ret="";
	int l = str.length();
	for (int i=l-1; i>=0; i--){
		ret += str[i];
	}
	//cerr << str << "->" << ret << endl;
	return ret;
}

int main() {
	int m;
	cin >> m;
	REP(z, m) {
		string str, l, r;
		int n;
		set<string> st;

		cin >> str;
		n = str.length();

		for (int i = 1; i <= n - 1; i++) {
			l = "";
			r = "";
			for (int j = 0; j < i; j++) {
				l += str[j];
			}
			for (int j = i; j < n; j++) {
				r += str[j];
			}
			//cerr << l << " " << r << " " << rev(l)+r <<  endl;
			
			st.insert(l+r);
			st.insert(rev(l)+r);
			st.insert(l+rev(r));
			st.insert(rev(l)+rev(r));
			
			st.insert(r+l);
			st.insert(rev(r)+l);
			st.insert(r+rev(l));
			st.insert(rev(r)+rev(l));
		}
		
		cout << st.size() << endl;
	}
	return 0;
}


Measured memory_bytes: 3320
N,M = map(int,input().split())
H = list(map(int,input().split()))
mx = [0 for i in range(N)]
for _ in range(M):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    mx[a] = max(mx[a], H[b])
    mx[b] = max(mx[b], H[a])
ans = 0
for i in range(N):
    if H[i] > mx[i]:
        ans += 1
print(ans)

Measured memory_bytes: 20044
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<queue>
#include<set>
#include<stack>
#include<map>
using namespace std;
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define rpe(i,r,l) for(int i=(r);i>=(l);--i)
#define rpp(i,x,e,head) for(int i=head[x];~i;i=e[i].next)
#define dyes cerr<<"yes"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define pts puts("")
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
inline int read(){
    int f=1,x=0;char ch;
    do{ch=getchar();if(ch=='-')f=-1LL;}while(ch<'0'||ch>'9');
    do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
    return f*x;
}
template <class T> inline void chmax(T &a,T b){if(a<b) a=b;}
template <class T> inline void chmin(T &a,T b){if(a>b) a=b;}
inline void swap(int &a,int &b){int c=a;a=b;b=c;}
using namespace std;
#define mst(a,val) memset(a,val,sizeof(a))
#define pii pair<int,int>
#define piii pair<int,pair<int,int> >
#define mp(i,j) make_pair(i,j)
#define fi first
#define sc second
#define inf (0x3f3f3f3f)
#define id(i,j) ((i-1)*m+j)
const int N=1e5+10;
int fa[N],dis[N];
pii find(int x){
    if(!fa[x]) return mp(x,0);
    pii tmp=find(fa[x]);
    dis[x]+=tmp.sc;fa[x]=tmp.fi;
    return mp(fa[x],dis[x]);
}
int n,m;
int main(){
    n=read();m=read();
    rep(i,1,m){
        int l=read(),r=read(),w=read();
        pii x=find(l),y=find(r);
        if(x.fi==y.fi&&x.sc+w!=y.sc){
            puts("No");
            return 0;
        }else if(x.fi!=y.fi){
            fa[y.fi]=x.fi;
            dis[y.fi]=w-y.sc+x.sc;
        }
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 1024
while True:
    a,op,b = map(str,input().split())
    if op == "/":
        x = int(a) // int(b)
        print(str(x))
    elif op == "+":
        x = int(a) + int(b)
        print(str(x))
    elif op == "-":
        x = int(a) - int(b)
        print(str(x))
    elif op == "*":
        x = int(a) * int(b)
        print(str(x))
    elif op == "?":
        break



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

int main(void) {
  string s;
  unsigned ll k;
  cin >> s >> k;
  int ii=-1;
  for (int i = 0; i < s.size(); i++) {
    if(s[i]!='1') {
      ii=i;
      break;
    }
  }

  char res;
  if(ii<0){
    res='1';
  }else if(k-1<ii){
    res='1';
  }else{
    res=s[ii];
  }
	  
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
char memarr[96000000];
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void rd(string &x){
  char *buf = (char *)wmem;
  rd(buf);
  x = buf;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
string S;
const char *str[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
int main(){
  int i;
  wmem = memarr;
  rd(S);
  for(i=(0);i<(7);i++){
    if(S==str[i]){
      wt_L(7-i);
      wt_L('\n');
    }
  }
  return 0;
}
// cLay varsion 20191123-1

// --- original code ---
// string S;
// const char *str[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
// {
//   rd(S);
//   rep(i,7) if(S==str[i]) wt(7-i);
// }


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

int main() {
    int N,M;
  cin >> N >> M;
  vector<int> a(M);
  vector<int> b(M);
  vector<int> c(N);
  rep(i,M){
  cin >> a.at(i) >> b.at(i);
     for(int j = 1;j < N + 1;j++){
  if(a.at(i) == j||b.at(i) == j)
    c.at(j-1)++;
                                 }
          }
  rep(k,N){
  cout << c.at(k) << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main{
  public static void main(String[] ae){
    Scanner scan = new Scanner(System.in);
    
    String str = scan.next();
    
    int len = str.length();
    
    if(len % 2 != 0){
      System.out.println("No");
      return;
    }
    
    char[]chars = str.toCharArray();

    Arrays.sort(chars);
    String sorted = new String(chars);
    
    int cnt = 1, i;
    char a = sorted.charAt(0);
    
    for(i = 1; i < len; i++){
      if(a == sorted.charAt(i)){
        cnt++;
      }
      else{
        if(cnt % 2 != 0){
          System.out.println("No");
   		  return;
    	}
        else{
          a = sorted.charAt(i);
          cnt = 1;
        }
      }
    }
    System.out.println("Yes");
   }
}

Measured memory_bytes: 22740
import heapq as hq
from collections import Counter
N,K = map(int,input().split())
t_d = []
for _ in range(N):
    t,d = map(int,input().split())
    t_d.append([t,d])
t_d = sorted(t_d, key=lambda x:-x[1])
kiso = 0
neta = Counter()
stack = []
for t,d in t_d[:K]:
    kiso += d
    neta[t] += 1
    hq.heappush(stack,[d,t])
ans = kiso + len(neta)**2
for t,d in t_d[K:]:
    if neta[t] > 0 : continue
    while(stack):
        d0,t0 = hq.heappop(stack)
        if neta[t0] > 1:
            kiso += d - d0
            neta[t0] -= 1
            neta[t] += 1
            ans = max(ans, kiso+len(neta)**2)
            hq.heappush(stack,[d0,t0])
            hq.heappop(stack)
            break
print(ans)


Measured memory_bytes: 34068
#include <vector>
using namespace std;
using i64 = long long;

struct WeightedUnionFind
{
	vector<int> par;
	vector<i64> ws;

	WeightedUnionFind(int n) : par(n,0) , ws(n,0)
	{
		for(int i = 0;i < n;i++)
		{
			par[i] = -1;
		}
	}

	int find(int x)
	{
		if(par[x] < 0)
		{
			return x;
		}
		else
		{
			const int parent = find(par[x]);
			ws[x] += ws[par[x]];
			return par[x] = parent;
		}
	}

	int weight(int x)
	{
		find(x);
		return ws[x];
	}

	bool unite(int x,int y,int w) //x + w = y
	{
		w += weight(x);
		w -= weight(y);
		x = find(x);
		y = find(y);

		if(x != y)
		{
			if(par[y] < par[x])
			{
				swap(x,y);
				w = -w;
			}
			par[x] += par[y];
			par[y] = x;
			ws[y] = w;
			return true;
		}
		else
		{
			return false;
		}
	}

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

	pair<bool,int>  diff(int x,int y)
	{
		if(!same(x,y)) return {false,0};
		return {true,weight(x) - weight(y)};
	}
};

#include <iostream>

int n;
int m;

int main()
{
	cin >> n >> m;
	WeightedUnionFind uf(n + 1);
	for(int i = 0;i < m;i++)
	{
		i64 x,y,w;
		cin >> x >> y >> w;
		
		auto p = uf.diff(x,y);
		if(!p.first)
		{
			uf.unite(x,y,-w);
		}
		else if(p.second != w)
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}



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

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

    long m = 12;
    long w[m] = {
            1,
            6,
            9,
            36,
            81,
            216,          // 6^3
            729,          // 9^3
            1296,       // 6^4
            6561,       // 9^4
            7776,       // 6^5
            46656,    // 6^6
            59049,    // 9^5
    };
    long n;
    cin >> n;

    long dp[m + 1][n + 1];
    for (long i = 0; i <= m; ++i) {
        for (int j = 0; j <= n; ++j) {
            if (!j) dp[i][j] =0;
            else dp[i][j] = n;
        }
    }

    for (long i = 0; i < m; ++i) {
        for (long j = 0; j <= n; ++j) {
            if (j < w[i]) {
                dp[i + 1][j] = dp[i][j];
            } else {
                dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - w[i]] + 1);
            }
        }
    }

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


Measured memory_bytes: 10368
/*
Rathin Bhargava
IIIT Bangalore

*/
#include<bits/stdc++.h>
#define mt make_tuple
#define mp make_pair
#define pu push_back
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-6
#define ll long long int
#define ld long double
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pr(v) { for(int i=0;i<v.size();i++) { v[i]==INF? cout<<"INF " : cout<<v[i]<<" "; } cout<<endl;}
#define t1(x)                cerr<<#x<<" : "<<x<<endl
#define t2(x, y)             cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<" : " <<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define t4(a,b,c,d)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<endl
#define t5(a,b,c,d,e)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<endl
#define t6(a,b,c,d,e,f)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<" "<<#f<<" : "<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define _ cerr<<"here"<<endl;
#define __ {ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

using namespace std;
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){ return out<<"("<<a.first<<", "<<a.second<<")";}
template <int> ostream& operator<<(ostream& os, const vector<int>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { if(v[i]!=INF) os << v[i]; else os << "INF";if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; ;if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 


int main()
{
  __;
  int x,y;
  cin >> x >> y;
  int cnt = 0;
  if(x == 1 && y == 1) cnt += 4e5;
  if(x==1) cnt += 3e5;
  else if(x==2) cnt += 2e5;
  else if(x == 3) cnt += 1e5;

  if(y==1) cnt += 3e5;
  else if(y==2) cnt += 2e5;
  else if(y == 3) cnt += 1e5;

  cout << cnt << endl;
  return 0;
}



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

int main(void){
    int k;
    string s, ans;
    cin >> k >> s;
    if(s.size() > k){
        ans = s.substr(0, k);
        ans += "...";
    } else {
        ans = s;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());
		int cnt = 0;

		for (int i = 0; i <= a; i++) {
			for (int j = 0; j <= b; j++) {
				for (int k = 0; k <= c; k++) {
					if (500 * i + 100 * j + 50 * k == x) {
						cnt++;
					}
				}
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 25556
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

#define MAX 100000

ll dp[(1 << 9) + 1][2][MAX + 1];

signed main() {
    int n;
    cin >> n;
    int d = 0;
    while ((1 << d) <= n) {
        d++;
    }
    int V[n + 1], W[n + 1];
    for (int i = 1; i <= n; i++) {
        cin >> V[i] >> W[i];
    }
    int q;
    cin >> q;
    int v[q], l[q];
    rep(i, q) {
        cin >> v[i] >> l[i];
    }
    int h = d / 2;
    int depth[1 << h];
    for (int i = 1; i < (1 << h); i++) {
        int j = 0;
        int cur = i;
        while (cur > 0) {
            for (int k = 0; k <= MAX; k++) {
                dp[i][(j + 1) % 2][k] =
                    max(dp[i][(j + 1) % 2][k], dp[i][j % 2][k]);
                if (k - W[cur] < 0) continue;
                dp[i][(j + 1) % 2][k] = max(dp[i][(j + 1) % 2][k],
                                            dp[i][j % 2][k - W[cur]] + V[cur]);
            }
            j++;
            cur /= 2;
        }
        depth[i] = j % 2;
    }
    int vt[10], wt[10];
    rep(i, q) {
        if (v[i] < (1 << h)) {
            cout << dp[v[i]][depth[v[i]]][l[i]] << endl;
        } else {
            int cur = v[i];
            int sz = 0;
            while ((1 << h) <= cur) {
                vt[sz] = V[cur];
                wt[sz] = W[cur];
                cur /= 2;
                sz++;
            }
            ll ans = 0;
            for (int bit = 0; bit < (1 << sz); bit++) {
                ll V = 0, W = l[i];
                rep(i, sz) {
                    if (bit & (1 << i)) {
                        V += vt[i];
                        W -= wt[i];
                    }
                }
                if (W < 0) continue;
                ans = max(ans, dp[cur][h % 2][W] + V);
            }
            cout << ans << endl;
        }
    }
    return 0;
}

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

int dp[105][4][2];

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int K;
  cin >> K;
  dp[0][0][0] = 1;
  rep(i,n)rep(j,4)rep(k,2) {
    int nd = s[i]-'0';
    rep(d,10) {
      int ni = i+1, nj = j, nk = k;
      if (d != 0) nj++;
      if (nj > K) continue;
      if (k == 0) {
        if (d > nd) continue;
        if (d < nd) nk = 1;
      }
      dp[ni][nj][nk] += dp[i][j][k];
    }
  }
  int ans = dp[n][K][0] + dp[n][K][1];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
from copy import copy

A,B,C = map(int, input().split())

# A <--> B
temp = copy(A)
A = copy(B)
B = copy(temp)

# A <--> C
temp = copy(A)
A = copy(C)
C = copy(temp)

print("%d %d %d" %(A,B,C))


Measured memory_bytes: 3444
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 100000000
for i in range(M):
    x = list(map(int,input().split()))
    # print(x)
    ans = min(a[x[0]-1]+b[x[1]-1]-x[2],ans)
    # x.append(list(map(int,input().split())))
ans = min(min(a) + min(b),ans)#割引券を使わずに最安値2つ買った場合
print(ans)

Measured memory_bytes: 18736
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    X, N = map(int, input().split())
    A = set(map(int, input().split()))

    for i in range(1000):
        if not X-i in A:
            print(X-i)
            break
        elif not X+i in A:
            print(X+i)
            break

if __name__ == '__main__':
    main()

Measured memory_bytes: 9180
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }
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;
}

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;


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

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


    int a, b, c;
    cin >> a >> b >> c;

    cout << min(c,b/a) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int k,x; scanf("%d %d",&k,&x);
	int temp = 2*k-1;
	int t = x-k+1;
	for (int i=0; i<temp; i++) {
		printf("%d ",t+i);
	}
	
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
#include<set>
#include<iomanip>

#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair

using namespace std;
using ll=long long int;

ll func(ll B,ll N){
    if(N<B){
        return N;
    }
    else{
        return func(B,N/B)+N%B;
    }
    return 0;
}

int main(){
    ll n,s;
    cin >> n>> s;
    if(n<s){
    }
    else if(n==s){
        cout << n+1 << endl;
        return 0;
    }
    else{
        ll ans = 1e11+1;
        for(ll i=2;i<=sqrt(n);i++){
            if(s==func(i,n)){
                if(ans > i) ans = i;
            }
        }
        ll b;
        for(ll i=1;i<sqrt(n);i++){
            b=((n-s)/i)+1;
            if(b != 1){
                if(s==func(b,n)){
                    if(ans > b) ans = b;
                }
            }
        }
        if(ans<1e11+1){
            cout << ans << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=4e2+15;
int h,w,vis[N][N];
char a[N][N];
bool check(int x,int y){
    return (x<1||y<1||x>h||y>w)?false:true;
}
int dir[4][2]={
       {-1,0},
    {0,-1},{0,1},
        {1,0}
};
int main()
{
    scanf("%d%d",&h,&w);
    for(int i=1;i<=h;i++){
        scanf("%s",a[i]+1);
    }
    ll ans=0;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(!vis[i][j]){
                queue < pair<int,int> > Q;
                Q.push(make_pair(i,j));
                ll Dot,Well;
                Dot=Well=0;
                while(!Q.empty()){
                    pair<int,int> cur=Q.front();
                    Q.pop();
                    int x=cur.first;
                    int y=cur.second;
                    if(vis[x][y]==1)
                        continue;
                    //printf("[ %d,%d ]\n",x,y);
                    vis[x][y]=1;
                    a[x][y]=='.'?Dot++:Well++;

                    for(int k=0;k<4;k++){
                        int tx=x+dir[k][0];
                        int ty=y+dir[k][1];
                        if(!vis[tx][ty]&&check(tx,ty)&&a[x][y]!=a[tx][ty]){
                             Q.push(make_pair(tx,ty));
                        }
                    }
                }
                ans+=Dot*Well;
                //printf("(%d,%d) = %lld %lld %lld\n",i,j,Dot,Well,Dot*Well);
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> piipi;
typedef pair<pii, pii> piipii;

#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back

int a[100005], cnt[100005];
int idx[100005];
long long ans[100005];
int main(){
    int n;
    scanf("%d", &n);

    vector<int> v;
    v.eb(0);
    for(int i=1;i<=n;i++){
        scanf("%d", &a[i]);
        v.eb(a[i]);
    }
    sort(all(v));
    v.erase(unique(all(v)), v.end());
    for(int i=1;i<=n;i++){
        a[i] = lower_bound(all(v), a[i]) - v.begin();
        cnt[a[i]]++;
        if(idx[a[i]] == 0) idx[a[i]] = i;
    }
    int sum = 0;
    for(int i=sz(v)-1;i>=1;i--){
        sum += cnt[i];
        if(i != sz(v)-1) idx[i] = min(idx[i], idx[i+1]);
        ans[idx[i]] += (v[i]-v[i-1])*1ll*sum;
    }
    for(int i=1;i<=n;i++) printf("%lld\n", ans[i]);
}

Measured memory_bytes: 5852
S = input()
i = len(S)
flag = True
while i>=0:
    if i >= 7 and S[i-7:i] == 'dreamer':
        i -= 7
        continue
    elif i >= 6 and S[i-6:i] == 'eraser':
        i -= 6
        continue
    elif i >= 5 and (S[i-5:i] == 'dream' or S[i-5:i] == 'erase'):
        i -= 5
        continue
    else:
        if i == 0:
            break
        else:
            flag = False
            break
if flag:
    print('YES')
else:
    print('NO')

        
    

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int n,L;
  cin >> n >> L;
  vector<int> v(n);
  rep(i,n)cin >> v[i];
  int k = -1;
  rep(i,n-1)if(v[i]+v[i+1] >= L){
    k = i;
    break;
  }
  if(k < 0){
    cout << "Impossible\n";
    return 0;
  }
  cout << "Possible\n";
  for(int i = 0;i < k;i++)cout << i+1 << endl;
  for(int i = n-2;i > k;i--)cout << i+1 << endl;
  cout << k+1 << endl;
  




  return 0;
}

Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        List<int> A = Console.ReadLine().Split(' ').Select(o => int.Parse(o)).ToList();

        if (A.Where(o => o % 2 == 0).All(o => o % 3 == 0 || o % 5 == 0))
            Console.WriteLine("APPROVED");
        else
            Console.WriteLine("DENIED");
    }
}

Measured memory_bytes: 13396
mod, ans = 10 ** 9 + 7, 0
N, K = map(int, input().split())
for k in range(K, N + 2):
    ans += (N + 1) * (N + 2) // 2 - (N + 2 - k) * (N + 1 - k) // 2 + 1
    ans -= k * (k + 1) // 2
    ans = ans % mod
print(ans)


Measured memory_bytes: 9184
import sys

# import bisect
# from collections import Counter, deque, defaultdict
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
import math

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    k, n = list(map(int, readline().split()))
    a = list(map(int, readline().split()))

    ans = INF

    temp1 = a[-1] - a[0]
    temp2 = k - (a[1] - a[0])
    ans = min(ans, temp1, temp2)

    for i in range(1, n - 1):
        temp1 = k - (a[i + 1] - a[i])
        temp2 = k - (a[i] - a[i - 1])
        ans = min(ans, temp1, temp2)

    temp1 = k - (a[-1] - a[-2])
    temp2 = a[-1] - a[0]
    ans = min(ans, temp1, temp2)

    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int main(void)
{
    ll h,w;
    cin >> h >> w;
    if(h== 1||w==1) {
        cout  << 1 << endl;
    } else {
        cout << h * w / 2 + ((h * w) % 2) << endl;
    }
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int A;
char S[12];
int main(){
  rd(A);
  rd(S);
  if(A >= 3200){
    wt_L(S);
    wt_L('\n');
  }
  else{
    wt_L("red");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190818-1

// --- original code ---
// int A; char S[12];
// {
//   rd(A,S);
//   wt(if[A >= 3200, S, "red"]);
// }


Measured memory_bytes: 256
N, A, B = map(int, input().split())
if A % 2 == B % 2: # 両方とも偶数/奇数の場合
    print((B - A) // 2)
else: # 両方が違う場合
    # BがNにいってから戻るパターンとAが1にいってから戻るパターン
    print(min(A, (N - B + 1)) + ((B - A - 1) // 2))

Measured memory_bytes: 38256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
typedef long long ll;
int main()
{  ll n,k,t,t1,t2,minn,t3;
   cin>>n>>k;
   if(n>=k)
    { t=n%k;
      minn=min(t,k-t);
      cout<<minn<<endl;
      
  }
  else
  {  t1=abs(n-k);
      t2=min(t1,n);
      cout<<t2<<endl;
  }
}

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

ai = max(A)
while ai in A:
    A.remove(ai)

aj_ideal = ai/2

A_diff = [abs(a-aj_ideal) for a in A]
A_diff_closest0 = min(A_diff)
aj = A[A_diff.index(A_diff_closest0)]

print(ai,aj)

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

#define rep(i, n) for ( ll i = 0; i < (n); ++i )
#define reps(i, n) for ( ll i = 1; i <= (n); ++i )
#define _rep(i, n) for ( ll i = (n) - 1; i >= 0; --i )
#define _reps(i, n) for ( ll i = n; i > 0; --i )
#define all(x) (x).begin(), (x).end()
#define _all(x) (x).rbegin(), (x).rend()

using namespace std;
using ll =  long long;
using P = pair<ll, ll>;

int main( void )
{
	ll a;
	cin >> a;

	cout << (a + a * a + a * a * a) << endl;

	return 0;
}


Measured memory_bytes: 3632