akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

long long power( long long x, int n )
{
	long long res = 1;
	while( n > 0 ) {
		if( n % 2 ) res = res * x;
		x = x * x;
		n /= 2;
	}
	return res;
}

int main()
{
	long long X;
	cin >> X;

	long long A;
	long long B;
	int flag = 0;
	for( A = -200; A < 200; A++ ) {
		for( B = -200; B < 200; B++ ) {
			if( power( A, 5 ) - power( B, 5 ) == X ) {
				flag = 1;
				break;
			}
		}
		if( flag ) break;
	}

	cout << A << " " << B << endl;
}


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

int top, S[1000];

void push(int x){
    S[++top] = x;
}

int pop(){
    top--;
    return S[top+1];
}

int main(){
    int a,b;
    top = 0;
    char s[100];
    while(scanf("%s", s) != EOF){
        if(s[0] == '+'){
            a = pop();
            b = pop();
            push(a+b);
        } else if(s[0] == '-'){
            a = pop();
            b = pop();
            push(b-a);
        } else if(s[0] == '*'){
            a = pop();
            b = pop();
            push(a*b);
        } else {
            push(atoi(s));
        }
    }

    printf("%d\n", pop());
}


Measured memory_bytes: 3220
import heapq


def main():
    X, Y, A, B, C = list(map(int, input().split(' ')))
    P = list(map(int, input().split(' ')))
    Q = list(map(int, input().split(' ')))
    R = list(map(int, input().split(' ')))
    P.sort(reverse=True)
    Q.sort(reverse=True)
    R.sort(reverse=True)
    que = []
    for p in P[:X]:
        heapq.heappush(que, p)
    for q in Q[:Y]:
        heapq.heappush(que, q)
    for r in R:
        min_que = heapq.heappop(que)
        if min_que >= r:
            heapq.heappush(que, min_que)
            break
        else:
            heapq.heappush(que, r)
    print(sum(que))


if __name__ == '__main__':
    main()


Measured memory_bytes: 23216
import sys
from collections import deque
input = sys.stdin.readline
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]
graph = [[] for i in range(n+1)]
for a,b in ab:
  graph[a].append(b)
  graph[b].append(a)
vis = [0 for i in range(n+1)]
vis[1] = 1
stack = [1]
ans = deque()
while stack:
  x = stack.pop()
  flg = 0
  ans.append(x)
  for y in graph[x]:
    if vis[y] == 0:
      stack.append(y)
      vis[y] = 1
      flg = 1
      break
  if not flg:
    break
stack = [1]
while stack:
  x = stack.pop()
  flg = 0
  if x != 1:
    ans.appendleft(x)
  for y in graph[x]:
    if vis[y] == 0:
      stack.append(y)
      vis[y] = 1
      flg = 1
      break
  if not flg:
    break
print(len(ans))
print(*ans)

Measured memory_bytes: 77916
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using pll=pair<ll,ll>;
using plll=pair<ll,pll>;
using graph=vector<vector<int>>;

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

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1){
      ret*=a;
    }
    a*=a;
    if(a>=p)a%=p;
    b=b>>1;
  }
  return ret;
}

int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p=MOD){
  a%=p;
  ll n=solveLinear(a,p,1);
  n%=p;
  if(n<0)return n+p;
  return n;
}

ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  int i;
  ll ret=1;
  for(i=0;i<n;i++){
    ret=ret*(i+1);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll binom(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1,fact=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    fact*=i+1;
    if(ret>=p)ret%=p;
    if(fact>=p)fact%=p;
  }
  return (ret*modRev(fact))%p;
}

void dfs(const graph &g,int v,int p){
  for(auto i:g[v]){
    if(i==p)continue;
    dfs(g,i,v);
  }
}

void pushHeap(vector<int>& h,int n){
  int i=h.size();
  h.push_back(n);
  while(i!=0 && h[(i-1)/2]<h[i]){
    swap(h[i],h[(i-1)/2]);
    i=(i-1)/2;
  }
  h[i]=n;
}

int popHeap(vector<int>& h){
  int n=h.size()-1;
  if(n==-1)return 0;
  int i,ret=h[0];
  swap(h[0],h[n]);
  h.pop_back();
  for(i=0;i<n;){
    int j=2*i+1;
    if(j>=n)break;
    if(j!=n-1 && h[j]<h[j+1])j++;
    if(h[i]<h[j]){
      swap(h[i],h[j]);
    }
    i=j;
  }
  return ret;
}

int main(){
  int i,j,k,cnt=0;
  int n,m;
  cin>>n>>m;
  vector<int> h;
  for(i=0;i<n;i++){
    int a;
    cin>>a;
    pushHeap(h,a);
  }
  for(i=0;i<m;i++){
    pushHeap(h,popHeap(h)/2);
  }
  ll sum=0;
  for(i=0;i<n;i++)sum+=h[i];
  cout<<sum<<endl;
}


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

#define FOR( i, m, n )   for( int i = m; i < n; i++ )
#define REP( i, n )      FOR( i, 0, n )
#define ALL( a )         (a).begin(), (a).end()

typedef long long ll;


int main(){
  int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;

  int lx, ly;
  lx = abs( sx - tx );
  ly = abs( sy - ty );

  REP( i, lx ){
    if( tx - sx > 0 ) cout << "R";
    else              cout << "L";
  }
  
  REP( i, ly ){
    if( ty - sy > 0) cout << "U";
    else          cout << "D";
  }

  REP( i, lx ){
    if( tx - sx < 0 ) cout << "R";
    else              cout << "L";
  }
  
  REP( i, ly ){
    if( ty - sy < 0) cout << "U";
    else          cout << "D";
  }

  // 2回目
  if( tx - sx > 0 ) cout << "L";
  else              cout << "R";

  REP( i, ly + 1 ){
    if( ty - sy > 0) cout << "U";
    else          cout << "D";
  }

  REP( i, lx + 1 ){
    if( tx - sx > 0 ) cout << "R";
    else              cout << "L";
  }

  if( ty - sy < 0) cout << "U";
  else             cout << "D";


  // 2back
  if( tx - sx > 0 ) cout << "R";
  else              cout << "L";

  REP( i, ly  + 1 ){
    if( ty - sy < 0) cout << "U";
    else          cout << "D";
  }

  REP( i, lx + 1 ){
    if( tx - sx < 0 ) cout << "R";
    else              cout << "L";
  }

  if( ty - sy > 0) cout << "U";
    else          cout << "D";

  cout << endl;
}


Measured memory_bytes: 256
#include <cstdio>
int s[100001];

int main(){
//  freopen("in.in", "r", stdin);
//  freopen("out.out", "w", stdout);
  char ch, lc = 0;
  int n, m, i;
  scanf("%d%d ", &n, &m);
  ch = fgetc(stdin);
  n = 0;
  while(ch >= 'A' && ch <= 'Z'){
    if(lc == 'A' && ch == 'C')
      s[n + 1] = 1;
    lc = ch;
    ch = fgetc(stdin);
    n++;
  }
  for(i = 1; i <= n; i++)
    s[i] += s[i - 1];
  int x, y;
  for(i = 0; i < m; i++){
    scanf("%d%d", &x, &y);
    printf("%d\n", s[y] - s[x]);
  }
  return 0;
}


Measured memory_bytes: 1152
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
n = int(input())
flag = 0
for _ in range(n):
    b = int(input())
    for i in range(3):
        if b == a1[i]:
            a1[i] = 0
        elif b == a2[i]:
            a2[i] = 0
        elif b == a3[i]:
            a3[i] = 0
    for i in range(3):
        if a1[i] == a2[i] == a3[i]:
            flag = 1
        if sum(a1) == 0:
            flag = 1
        if sum(a2) == 0:
            flag = 1
        if sum(a3) == 0:
            flag = 1
        if a1[0] == a2[1] == a3[2]:
            flag = 1
        if a1[2] == a2[1] == a3[0]:
            flag = 1
    if flag == 1:
        print("Yes")
        break
if flag == 0:
    print("No")

Measured memory_bytes: 9072
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll H, W, N;
    cin >> H >> W >> N;
    if (H < W) swap(H, W);
    cout << (N + H - 1) / H << endl;
}

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

static const double EPS = 1e-6;

int main(void) {
	double vec[3][4];
	double a[3];

	double v[3];

	cin >> a[0] >> a[1] >> a[2];
	for(int i = 0; i < 4; i++) {
		for(int j = 0; j < 3; j++) {
			cin >> vec[j][3 - i];
			vec[j][3 - i] -= a[j];
		}
	}

	for(int i = 0; i < 3; i++) {
		/* [vec[i][i] == 0] swap */
		if(fabs(vec[i][i]) < EPS) {
			for(int j = i + 1; j < 3; j++) {
				if(fabs(vec[j][i]) > EPS) {
					for(int k = 0; k < 4; k++) {
						double tmp;
						tmp = vec[i][k];
						vec[i][k] = vec[j][k];
						vec[j][k] = tmp;
					}
					break;
				}
			}
		}
		for(int j = i + 1; j < 3; j++) {
			double mul = vec[j][i] / vec[i][i];
			for(int k = i; k < 4; k++) {
				vec[j][k] -= vec[i][k] * mul;
			}
		}
	}

	if(fabs(vec[2][2]) < EPS) {
		cout << "HIT" << endl;
		return 0;
	}

	for(int i = 0; i < 3; i++) {
		double d = vec[2- i][3];
		for(int j = 3 - i; j < 3; j++) {
			d -= vec[2 - i][j] * v[j];
		}
		v[2 - i] = d / vec[2 - i][2 - i];
	}
	/*
	for(int i = 0; i < 3; i++) {
		for(int j = 0; j < 4; j++) {
			cout << vec[i][j] << " ";
		}
		cout << endl;
	}
	// */

	double sum = 0;
	for(int i = 0; i < 3; i++) {
		if(v[i] < 0) {
			cout << "HIT" << endl;
			return 0;
		}
		sum += v[i];
	}

	if(sum < 1) {
		cout << "HIT" << endl;
		return 0;
	}

	cout << "MISS" << endl;

	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less

#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define show(x) cerr << #x << " = " << x << "\n"
#define mem( a , b ) memset( a , b , sizeof a )
#define popcnt(x) __builtin_popcount(x)
#define all(x) x.begin() , x.end()
#define mod(x,m) ((x%m + m )%m)
#define SZ(a) (int)a.size()
#define ll  long long
#define ld  long double
#define vii vector  <ll>
#define dqi deque   <ll>
#define sii set     <ll>
#define vpi vector  <pii>
#define mii map     <ll,ll>
#define pii pair    <ll,ll>
#define pi  pair    <int,int>
#define pb  push_back
#define F   first
#define S   second
#define L   length()
#define OO  (ll)1e18
#define EPS 1e-9
using namespace std;
using namespace __gnu_pbds;
void ONLINE__JUDGE();

typedef tree<ll, null_type, less<ll>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
pii swapii( pii pr ){ return { pr.S , pr.F }; }
ll binEXP( ll x , ll pw , ll MOD = LLONG_MAX );
int dx[] = {  0 ,  0 , -1 , +1 , -1 , +1 , -1 , +1 };
int dy[] = { -1 , +1 ,  0 ,  0 , -1 , +1 , +1 , -1 };

const ll MOD = 1e9 + 7;
const ll MAX = 1e5 + 7;

ll x , w; vpi vec;
ll dp[102][MAX];

ll go( ll i , ll rem ){

    if ( i == x ) return 0;
    ll& ret = dp[i][rem];
    if ( ~ret ) return ret;

    ll leave = go(i+1 , rem) , pick = 0;
    if ( vec[i].F <= rem ){
        pick = go(i+1 , rem-vec[i].F) + vec[i].S;
    }
    return ret = max( pick , leave );
}

int main()
{
    FASTIO //ONLINE__JUDGE();

    cin >> x >> w; vec.resize(x); mem( dp , -1 );
    for ( auto& i : vec ) cin >> i.F >> i.S;
    cout << go(0 , w);
    return 0;
}

void ONLINE__JUDGE()
{
    #ifndef ONLINE_JUDGE
    freopen( "inp.c"         , "r" , stdin  );
    //freopen( "OutPut.txt"   , "w" , stdout );
    #endif // ONLINE_JUDGE
}

ll binEXP( ll x , ll pw , ll MOD )
{ ll res=1; while(pw>0){ pw%2 ? res *= x : 0; x *= x; x%=MOD; pw /= 2; res%= MOD; } return res%=MOD; }


Measured memory_bytes: 80128
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <tuple>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <complex>
#include <bitset>
#include <numeric>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define SE second
#define FI first
#define DBG(a) cerr<<(a)<<endl;
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;  typedef pair<LL, LL> PLL; typedef vector<LL> VLL;
const LL LINF=334ll<<53; const int INF=15<<26; const LL MOD=1E9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w,a,b;
    string s;
    cin >> h >> w;
    REP(i,h){
        REP(j,w){
            cin >> s;
            if(s=="snuke"){
                a=i;
                b=j;
            }

        }
    }

    cout << (char)('A'+b) <<a+1<<endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A,B,C,K;
  cin>>A>>B>>C>>K;
  if(K<=A+B)
  {
    cout<<min(K,A)<<endl;
    return 0;
  }
  cout<<A-(K-A-B)<<endl;
  return 0;
}

Measured memory_bytes: 3488
import sys, math
from collections import deque

readline = sys.stdin.readline

N, M = map(int, readline().split())
AB = [list(map(int, readline().split())) for i in range(N)]

AB.sort(key=lambda x:-x[1])

skip_pointer = [i for i in range(M)]
total = 0

def update_skip(s):
    if s < 0:
        return -1
    else:
        if s == skip_pointer[s]:
            skip_pointer[s] -= 1
            return s
        else:
            t = update_skip(skip_pointer[s])
            skip_pointer[s] = t - 1
            return t

for a, b in AB:
    s = M - a
    t = update_skip(s)

    if t >= 0:
        total += b

print(total)

Measured memory_bytes: 111708
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int main(void){
    int n;cin>>n;
    vector<int> col(3,0),a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    long long res = 1;
    for(int i=0;i<n;i++){
        bool changed = false;
        int x=0;
         for(int j=0;j<3;j++){
            if(a[i]==col[j]){
                if(!changed){
                    col[j]++;
                    changed=true;
                }
                x++;
            }
        }
        res*=x;
        res%=mod;
        //cout<<col[0]<<" "<<col[1]<<" "<<col[2]<<endl;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <bits/stdc++.h>
#define rep(k,i,n) for(int i=k;i<n;++i)
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n>=3200){
        cout<<s<<endl;
    }else{
        cout<<"red"<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector <int> vec(n);
  for(int i = 0; i < n; i++) cin >> vec[i];
  sort(vec.begin(), vec.end());
  
  ll ans = 0;
  for(int i = 0; i < n; i++){
      map <int,int> mp;
      for(int j = 0; j < i; j++){
          int cnt = vec[i] - vec[j]+1;
          if(!mp.count(vec[j]))
             mp[vec[j]] = j;
          if(mp.lower_bound(cnt) == mp.end()) continue;
          int val = (*mp.lower_bound(cnt)).first;

          ans += j - mp[val];
          //cout << i << " " << j << " "<< ans << " " << val << " "  << endl;
      }
  }
  cout << ans;
}



Measured memory_bytes: 256
#include <cstdio>
#include <map>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
int a[200010];
int main() {
	int n;
	scanf("%d", &n);
	map<int, int> m;
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		m[a[i]]++;
	}
	vector<pair<int, int> > b(m.begin(), m.end());
	int ans = 0;
	for (int i = (int)b.size() - 1; i >= 0; i--) {
		int x = b[i].first;
		for (int j = 30; j >= 0; j--) {
			if ((1 << j) <= x) break;
			if (b[i].second <= 0) break;
			int l = lower_bound(b.begin(), b.begin() + i + 1, make_pair((1 << j) - x, -1)) - b.begin();
			if (l > i || b[l].first + x != (1 << j)) continue;
			if (l == i) {
				ans += b[i].second / 2;
				b[i].second %= 2;
			} else {
				int t = min(b[i].second, b[l].second);
				ans += t;
				b[i].second -= t;
				b[l].second -= t;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 11904
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

struct edge { int to, cost;};

//O(ElogV)

class Dijkstra{
private:
    vector< vector<edge> > g;

public:
    Dijkstra(){};
    Dijkstra(int size){
        g.resize(size);
    }

    vi dist;

    void add(int a, int b, int c){//無向辺
        edge e1 = {b, c}, e2 = {a, c};
        g[a].push_back(e1);
        //g[b].push_back(e2);//有向辺の場合はここをコメントアウトする
    }

    void calc(int s){
        priority_queue< pii, vector<pii>, greater<pii> > q;
        int n = g.size();
        dist = vi (n, INF);
        dist[s] = 0;
        q.push(pii(0, s));

        while(!q.empty()){
            pii p = q.top();
            q.pop();
            int v = p.second;
            if(dist[v] < p.first)continue; //更新されていたら何もしない
            for(int i = 0; i < g[v].size(); i++){
                edge e = g[v][i];
                if(dist[e.to] > dist[v] + e.cost){
                    dist[e.to] = dist[v] + e.cost;
                    q.push(pii(dist[e.to], e.to));
                }
            }
        }
    }

};


int main(void) {
    int i,j;
    int n;
    int v,e,r;
    cin >> v >> e >> r;

    Dijkstra g = Dijkstra(v);

    rep(i,e){
        int a,b,c;
        cin >> a >> b >> c;
        g.add(a,b,c);
    }

    g.calc(r);

    rep(i,v){
        if(g.dist[i] == INF)
            cout << "INF" << endl;
        else
            cout << g.dist[i] << endl;
    }

}



Measured memory_bytes: 13264
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 X = sc.nextInt();
        int Y = sc.nextInt();
        int total = CorAtoB(A,B,C,X,Y);
        if(X > Y){
            total += CorA(A,C,X,Y);
        }
        else if(X < Y){
            total += CorA(B,C,X,Y);
        }
        System.out.println(total);

    }
    public static int CorA(int A,int C,int X,int Y){
        int total = 0;
        for(int i = 0;i < absolute(X,Y);i++){
            if(A <= 2*C){
                total += A;
            }
            else{
                total += 2*C;
            }
        }
        return total;
    }
    public static int CorAtoB(int A,int B,int C,int X,int Y){
        int total = 0;
        for(int i = 0;i < min(X,Y);i++){
            if(A + B > 2*C){
                total += 2*C;
            }
            else{
                total += A+B;
            }
        }
        return total;
    }
    public static int min(int X,int Y){
        if(X > Y){
            return Y;
        }
        else{
            return X;
        }
    }
    public static int absolute(int X,int Y){
        int z;
        if(X > Y){
            z = X - Y;
        }
        else{
            z = Y - X;
        }
        return z;
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

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

  ll ans = divceil(N - 1, K - 1);
  cout << ans << endl;
}

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

using namespace std;

int main()
{
    int r[505][505], a[505][505], x, y, best;
    char in;

    cin >> x >> y;

    for(int i = 1; i <= x; ++i){
        best = 1;
        a[i][1] = 1;
        for(int j = 1; j <= y; ++j){
            cin >> in;
            if(in == '#'){
                r[i][j] = 1;
                a[i][j] = 1;
                if(a[i][j - 1] || a[i - 1][j])
                    best = j;
                else
                    for(int k = j; k >= best; --k){
                        a[i][k] = 1;
                        if(a[i][k - 1] || a[i - 1][k])
                            break;
                    }
            }
        }
    }
    for(int i = 1; i <= x; ++i){
        for(int j = 1; j <= y; ++j){
            if(a[i][j])
                cout << "#";
            else
                cout << ".";
        }
        cout << endl;
    }
    cout << endl;
    for(int i = 1; i <= x; ++i){
        for(int j = 1; j <= y; ++j){
            if(r[i][j] || !a[i][j])
                cout << "#";
            else
                cout << ".";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 2688
D=int(input())
c=[None]+list(map(int, input().split()))
s=[None]+[list(map(int, input().split())) for _ in range(D)]
T=[None]+[int(input()) for _ in range(D)]

lastdi=[None]+[0]*26

v=0

for i in range(1, D+1):
  v+=s[i][T[i]-1]
  lastdi[T[i]]=i
  for x in range(1, 27):
    v-=(i-lastdi[x])*c[x]
    
  print(v)

Measured memory_bytes: 74460
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

internal static class CR
{
    public static string Get() { return Console.ReadLine(); }
    public static int GetInteger() { return int.Parse(Console.ReadLine()); }
    public static IEnumerable<long> GetIntegers() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)); }
}

namespace C
{
    internal class Program
    {
        public static long A { get; private set; }
        public static long B { get; private set; }

        private static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.WriteLine(r); }

        private static object GetResult()
        {
            var inputs = CR.GetIntegers().ToList();
            A = inputs[0];
            B = inputs[1];

            return Lcm(A, B);
        }

        // 最小公倍数
        public static long Lcm(long a, long b)
        {
            return a * b / Gcd(a, b);
        }

        // ユークリッドの互除法 
        public static long Gcd(long a, long b)
        {
            if (a < b) 
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }

        //private static object GetResult()
        //{
        //    var inputs = CR.GetIntegers().ToList();
        //    A = inputs[0];
        //    B = inputs[1];

        //    // つねにAが小さい
        //    if (A > B)
        //    {
        //        var a = A;
        //        A = B;
        //        B = a;
        //    }

        //    var As = GetA().ToList();
        //    var Bs = GetB().ToList();

        //    foreach (var a in As)
        //    {
        //        if (Bs.Contains(a)) return a;
        //    }

        //    return 0;
        //}

        //private static IEnumerable<long> GetA()
        //{
        //    var x = 1;
        //    while (A * x <= A * B)
        //    {
        //        yield return A * x;
        //        x++;
        //    }
        //}
        //private static IEnumerable<long> GetB()
        //{
        //    var x = 1;
        //    while (B * x <= A * B)
        //    {
        //        yield return B * x;
        //        x++;
        //    }
        //}
    }
}


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

int main() {
  int A, B;
  cin >> A >> B;
  int count;
  for(int i = A; i <= B; i++) {
    int a4,a3,a2,a1,a0;
    int n = i;
    int r = n % 10000;
    a4 = (n - r) / 10000;
    n = r;
    r = n % 1000;
    a3 = (n - r) / 1000;
    n = r;
    r = n % 100;
    a2 = (n - r) / 100;
    n = r;
    r = n % 10;
    a1 = (n - r) / 10;
    a0 = r;
    if ( a4 == a0 && a3 == a1 ) {
      count++;
    }
  }
  cout << count << endl;
}

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

template<typename T, typename E, typename F, typename G, typename H>
class LazySegmentTree {
  int n, height;
  F f; G g; H h; const T ti; const E ei;
  vector<T> dat; vector<E> laz; vector<int> highest;

  void propagate(int k) {
    if(laz[k] != ei) {
      laz[2*k] = h(laz[2*k],laz[k]); laz[2*k+1] = h(laz[2*k+1],laz[k]);
      dat[k] = g(dat[k],laz[k],n/highest[k]);
      laz[k] = ei;
    }
  }
  inline void recalc(int k) {
    while(k >>= 1) dat[k] = f(g(dat[2*k],laz[2*k],n/highest[2*k]),g(dat[2*k+1],laz[2*k+1],n/highest[2*k+1]));
  }
  inline void thrust(int k) {
    for(int i = height; i > 0; i--) propagate(k >> i);
  }
public:
  LazySegmentTree(int _n, F f, G g, H h, T ti, E ei): f(f), g(g), h(h), ti(ti), ei(ei) {
    n = 1; height = 0;
    while(n < _n) n <<= 1, height++;
    dat.assign(2*n,ti); laz.assign(2*n,ei); highest.assign(2*n,0);
    int c = 1;
    for(int i = 1; i < 2*n; i++) {
      if(c*2 <= i) c <<= 1;
      highest[i] = c;
    }
  }
  void set(int k, T x) {
    dat[k+n] = x;
  }
  void build() {
    for(int i = n-1; i >= 0; i--) {
      dat[i] = f(dat[2*i],dat[2*i+1]);
    }
  }
  void update(int a, int b, const E x) {
    thrust(a += n); thrust(b += n-1);
    for(int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
      if(l & 1) laz[l] = h(laz[l],x), ++l;
      if(r & 1) --r, laz[r] = h(laz[r],x);
    }
    recalc(a); recalc(b);
  }
  T query(int a, int b) {
    thrust(a += n); thrust(b += n-1);
    T l = ti, r = ti; b++;
    while(a < b) {
      if(a & 1) l = f(l,g(dat[a],laz[a],n/highest[a])), a++;
      if(b & 1) b--, r = f(g(dat[b],laz[b],n/highest[b]),r);
      a >>= 1; b >>= 1;
    }
    return f(l,r);
  }
};

int main(){
  int n, q;
  cin >> n >> q;
  int s[n], t[n], x[n];
  rep(i,n) cin >> s[i] >> t[i] >> x[i];
  int d[q];
  rep(i,q) cin >> d[i];
  auto f = [](ll a, ll b){return min(a,b);};
  auto g = [](ll a, ll b, int l){return min(a,b);};
  LazySegmentTree<ll,ll,decltype(f),decltype(g),decltype(f)> lst(q,f,g,f,INF,INF); 
  rep(i,n) {
    int l = lower_bound(d,d+q,s[i]-x[i]) - d;
    int r = lower_bound(d,d+q,t[i]-x[i]) - d;
    lst.update(l,r,x[i]);
  }
  rep(i,q) {
    ll ans = lst.query(i,i+1);
    cout << (ans == INF? -1 : ans) << endl;
  }
  return 0;
}

Measured memory_bytes: 15232
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
int N;

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

  cin >> N;
  if (N==1){
    cout << "Hello World" << "\n";
    return 0;
  }
  int a,b;
  cin >> a >> b;

  cout << a+b << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
int dy[]={0,0,-1,1},dx[]={-1,1,0,0};
class data{
public:
    int y,x;
    data(int _y,int _x){
        y=_y;x=_x;
    }
    data(){}
};
int main(){
    int w,h;
    while(cin>>w>>h,h||w){
        char field[20][21];
        bool f[20][20]={{0}};
        for(int i=0;i<h;i++)cin>>field[i];
        int sy,sx;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(field[i][j]=='@'){
                    sy=i;
                    sx=j;
                }
            }
        }
        queue<data>Q;
        Q.push(data(sy,sx));
        int cnt=0;
        while(Q.size()){
            data a=Q.front();Q.pop();
            int y=a.y,x=a.x;
            if(y<0||y>=h||x<0||x>=w)continue;
            if(f[y][x])continue;
            if(field[y][x]=='#')continue;
            f[y][x]=true;
            cnt++;
            for(int i=0;i<4;i++){
                Q.push(data(y+dy[i],x+dx[i]));
            }
        }
        cout<<cnt<<endl;
    }
}

Measured memory_bytes: 1224
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>

 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define LLIandI pair<long long int , int>
#define ll long long

struct Warshall_Floyd{
    int V;
    long long int *d;//d[i_v1*V+i_v2]= v1tov2
    vector<  pair<int,int>  > *edges;
    long long total;
    bool *ifdelete;
    Warshall_Floyd(int N): V(N){
        d = new long long int[V*V];
        total=0;
        ifdelete=new bool[V*V];
        edges=new vector<  pair<int,int>  >[V];
        rep(i,V*V){
            d[i]=LLINF;
            ifdelete[i]=false;
        }
    }
    void push_edges(int a,int b, int c){
        edges[a].pb( mp(c,b));
        edges[b].pb( mp(c,a));
        if(ite(a,b)>c)d[a*V+b]=c;
        if(ite(b,a)>c)d[b*V+a]=c;
        total+=c;
    }
    long long int ite(int i,int j){
        return d[i*V+j];
    }
    void solve() { 
        for (int i = 0; i < V; i++)      // via
        for (int j = 0; j < V; j++)    // start
        for (int k = 0; k < V; k++)
        {// end
            if(i==j||j==k)continue;
            if(ifdelete[j*V+k]==false&&d[j*V+k]== ite(j,i) + ite(i,k) ){
                ifdelete[j*V+k]=true;ifdelete[k*V+j]=true;total-=d[j*V+k];
            }
            d[j*V+k] = min(ite(j,k), ite(j,i) + ite(i,k));
        }  
    }
    void free_wf(){
        delete[] d;
        delete[] edges;
    }
    
};

int main(void){
    int N;
    scanf("%d",&N);
    long long int A[300][300];
    Warshall_Floyd WF(N);
    rep(i,N){
        rep(j,N){
            scanf("%lld",&A[i][j]);
            if(i<j){WF.push_edges(i,j,A[i][j]);}
        }
    }
    WF.solve();
    rep(i,N){
        rep(j,N){
            if(WF.ite(i,j)<A[i][j]){printf("-1\n");return 0;}
        }
    }
    printf("%lld\n",WF.total);
}


Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
int n, m, k[15], s[15][15], p[15];
bool b[15];
int f(int d) {
	if (d == n + 1) {
		for (int i = 1; i <= m; i++) {
			int q = 0;
			for (int j = 1; j <= k[i]; j++)q += b[s[i][j]];
			if (q % 2 != p[i])return 0;
		}
		return 1;
	}
	int r = 0;
	b[d] = 0; r += f(d + 1);
	b[d] = 1; r += f(d + 1);
	return r;
}
signed main() {
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		cin >> k[i];
		for (int j = 1; j <= k[i]; j++)cin >> s[i][j];
	}
	for (int i = 1; i <= m; i++)cin >> p[i];
	cout << f(1) << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const double pi = acos(-1.0);

int main() {
	VI a(5); rep(i, 5)cin >> a[i];

	int m = 10;
	rep(i, 5)if (a[i] % 10)m = min(m, a[i] % 10);

	int sum = -(10 - m);
	rep(i, 5) {
		sum += (a[i] + 9) / 10 * 10;
	}
	Cout(sum);
}

Measured memory_bytes: 256
from collections import Counter 
from collections import defaultdict
from collections import deque
import math
import itertools
import heapq
import sys
sys.setrecursionlimit(10**6)

#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
input_list = lambda : list(map(int,input().split()))

a=input_list()
ans=float("inf")
for i in range(3):
    for j in range(i+1,3):
        ans=min(ans,a[i]+a[j])

print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main() {
  string n; cin >> n;
  int a = n.size(), c=0;
  for(int i; i<a; i++) if(n.at(i) == '0' + i%2 ) c++;
  cout << min(c, a-c) << endl;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll int64_t
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


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

int dp[101010];
int a[101010];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    REP(i,m) cin>>a[i];

    if(a[0]==1&&a[1]==2){
        cout<<0<<endl;
        return 0;
    }
    REP(i,m){
        dp[a[i]]=-1;
    }
    if(a[0]==1){
        dp[0] = 0;
        dp[1]=0;
        dp[2]=1;
        for(int i=3;i<=n;i++){
            if(dp[i]==-1){
                dp[i]=0;
                continue;
            }
            dp[i] = dp[i-1] + dp[i-2];
            dp[i] %= MOD;
        }
    }
    else if(a[0]==2){
        dp[0]=0;
        dp[1]=1;
        dp[2]=0;
        for(int i=3;i<=n;i++){
            if(dp[i]==-1){
                dp[i]=0;
                continue;
            }
            dp[i] = dp[i-1] + dp[i-2];
            dp[i] %= MOD;
        }
    }
    else{
        dp[0]=1;dp[1]=1;
        for(int i=2;i<=n;i++){
            if(dp[i]==-1){
                dp[i]=0;
                continue;
            }
            dp[i] = dp[i-1] + dp[i-2];
            dp[i] %= MOD;
        }
    }
    /*for(int i=2;i<a[0];i++){
        dp[i] = dp[i-1]+dp[i-2];
        dp[i] %= MOD;
    }
    a.push_back(n);
    for(int i=1;i<m+1;i++){
        for(int j=a[i-1]+1;j<a[i]+(i==m);j++){
            dp[j] = dp[j-2]+dp[j-1];
            dp[j]%=MOD;
        }
    }*/
    /*REP(i,m){
        dp[n] -= dp[a[i]];
        if(dp[n]<0) dp[n]+=MOD;
    }*/

    //REP(i,n+1) cout<<dp[i]<<endl;
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 896
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    String S = sc.next();

    sc.close();

    String result = "WA";

    char[] s = S.toCharArray();
    String[] s_= S.split("");

    if (s_[0].equals("A")) {

      int count = 0;
      int position = 0;

      for (int i = 2; i <= s_.length - 2; i++) {
        if (s_[i].equals("C")) {
          count++;
          position = i;
        }
      }

      if (count == 1) {
        for (int i = 1; i < s.length; i++) {
          if (i != position){
            if (97 <= (int)s[i] && (int)s[i] <= 122) {
              result = "AC";
            } else {
              result = "WA";
              break;
            }
          }
        }
      }

    }

    System.out.println(result);

  }

}

Measured memory_bytes: 22100
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext()){
			int[] a = new int[4];
			int[] b = new int[4];
			for(int i = 0;i < a.length; i++){
				a[i] = stdIn.nextInt();
			}
			for(int i = 0;i < b.length; i++){
				b[i] = stdIn.nextInt();
			}
			int hitCount = 0;
			for(int i = 0;i < 4; i++){
				if(a[i] == b[i]){
					hitCount++;
				}
			}
			int blowCount = 0;
			for(int i = 0;i < a.length; i++){
				for(int j = 0;j < b.length; j++){
					if(a[i] == b[j] & i != j){
						blowCount++;
					}
				}
			}
			System.out.println(hitCount + " " + blowCount);
		}
	}
}

Measured memory_bytes: 11000
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let mut result = None;
    for x in 1..n {
        if x * x > n {
            break;
        }
        if n % x == 0 {
            result = Some(x);
        }
    }
    if let Some(res) = result {
        println!("{}", res + n / res - 2);
    } else {
        println!("{}", n);
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 8572
use std::io;

fn main() {
    let mut counter = 1;
    loop {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).ok();
        let num: i32 = buf.trim().parse().unwrap();
        if num == 0 { break; }
        println!("Case {}: {}", counter, num);
        counter += 1;
    }
}



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

int main() {
    ll X;
    cin >> X;
    ll money = 100;
    ll cnt = 0;
    while (money < X) {
        money = money + money / 100;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    int s,w;cin>>s>>w;

    if(s<=w)cout<<"unsafe\n";
    else cout<<"safe\n";

    return 0;

}

Measured memory_bytes: 3632
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d %d %d\n",&a,&b,&c);
    if(a<b&&a<c)
    {
        if(b<c)
        {
            printf("%d %d %d\n",a,b,c);
        }
        else
        {
            printf("%d %d %d\n",a,c,b);

        }
    }
    else if(b<a&&b<c)
    {
        if(a<c)
        {
            printf("%d %d %d\n",b,a,c);

        }
        else
        {
            printf("%d %d %d\n",b,c,a);

        }
    }
    else
    {
        if(a<b)
        {
            printf("%d %d %d\n",c,a,b);
        }
        else
        {
            printf("%d %d %d\n",c,b,a);

        }
    }
    return 0;
}


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

using namespace std;

typedef vector<int> V;

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    V a = V(n, k);
    for (int i = 0; i < q; i++) {
        int ai;
        cin >> ai;
        a[ai - 1] += 1;
    }
    for (int i = 0; i < n; i++) {
        if (a[i] > q) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }
}

Measured memory_bytes: 1024
n,m,k = map(int, input().split())
dat1 = list(map(int, input().split()))
dat2 = list(map(int, input().split()))

finalres = 0
res1 = 0
r1 = 0
t = 0
while r1 < len(dat1):
    if t + dat1[r1] <= k:
        res1 += 1
        t += dat1[r1]
        r1 += 1
    else:
        break

#print("r1", r1, t)
finalres = res1
res2 = 0
r2 = 0
while r2 < len(dat2):
    if t + dat2[r2] <= k:
        res2 += 1
        t += dat2[r2]

        r2 += 1
        finalres = max(finalres, res1+res2)
    else:
        if r1 == 0:
            break
        r1 -= 1
        res1 -= 1
        t -= dat1[r1]

print(finalres)



Measured memory_bytes: 111100
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision; // cpp_int

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>

#define pb(a) push_back(a)
#define mp make_pair


int main(){
  CIN(n,m);V x(m);V y(m);VECIN2(x,y);
  REP(i,m){x[i]--;y[i]--;}
  S may={0};
  V num(n,1);
  REP(i,m){
    if(may.count(x[i]))may.insert(y[i]);
    num[x[i]]--;
    if(num[x[i]]==0)may.erase(x[i]);
    num[y[i]]++;
  }
  COUT(may.size());

  return 0;
}



Measured memory_bytes: 6144
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
using namespace std;
using ll = long long;
#define rep(i,k) for (int i = 0; i < (int)(k); i++)
#define all(c) begin(c), end(c)

bool bad[10];

bool dislike(int n) {
    while (n) {
        if (bad[n % 10]) return true;
        n /= 10;
    }
    return false;
}

int main() {
    int n;
    while (cin >> n) {
        int k;
        cin >> k;
        memset(bad, 0, sizeof bad);
        for (int i = 0; i < k; i++) {
            int x;
            cin >> x;
            bad[x] = true;
        }
        while (dislike(n)) ++n;
        cout << n << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int n;
string str[4][255];
 
int migi(int y,int x) {
  int count = 0;
 
  for(int i=x;i<n;i++){
    if(str[0][y][i] == '1') {
      count++;
      str[0][y][i] = '0';
    }
    else break;
  }
  return count;
 
}
 
int sita(int y,int x) {
  int count = 0;
  for(int i=y;i<n;i++) {
    if(str[1][i][x] == '1') {
      count++;
      str[1][i][x] = '0';
    }
    else break;
  }
 
  return count;
}
 
int migisita(int y,int x) {
  int count = 0;
  int i=0;
  while(1) {
    if(y+i == n || x+i == n) break;
 
    if(str[2][y+i][x+i] == '1'){
      str[2][y+i][x+i] = '0';
      count++;
    }
    else break;
    i++;
  }
  return count;
}
 
int hidarisita(int y,int x) {
 int count = 0;
  int i=0;
  while(1) {
    if(y+i == n || x-i == -1) break;
 
    if(str[3][y+i][x-i] == '1'){
      str[3][y+i][x-i] = '0';
      count++;
    }
    else break;
    i++;
  }
  return count;
}
 
 
int main(){
  while(1) {
  cin >> n;
  if(n == 0) break;
 
  for(int i=0;i<n;i++) {
    cin >> str[0][i];
    str[1][i] = str[2][i] = str[3][i] = str[0][i];
  }
 
  int ans = 0,t;
    for(int i=0;i<n;i++) {
      for(int j=0;j<n;j++) {
    if(str[0][i][j] == '1') ans = max(ans,migi(i,j));
    if(str[1][i][j] == '1') ans = max(ans,sita(i,j));
    if(str[2][i][j] == '1') ans = max(ans,migisita(i,j));
    if(str[3][i][j] == '1') ans = max(ans,hidarisita(i,j));
      }
    }
 
    cout << ans << endl;
}
return 0;
}

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

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

    int n = 3;
    int a[3];
    for (int i = 0; i < 3; ++i) {
        cin >> a[i];
    }
    sort(a, a + 3);


    cout << a[2] - a[0]<< endl;
    return 0;
}


Measured memory_bytes: 256