akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Apolloliu
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

#define MEM(a,b)    memset(a, b, sizeof(a))
#define UN(a)       sort(all(a)), a.erase(unique(all(a)), a.end())
#define REV(a)      reverse(all(a))
#define MP(a, b)    make_pair(a, b)
#define PAIR(a, b)  pair<int, int>(a, b)

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int maxn = 123456;
const double EPS = 1e-8;
const ll inf = 1e18;

ll a[maxn], dp[maxn][2];
class DFlippingSigns {
public:
	void solve(std::istream& in, std::ostream& out) {
		int N;
		in>>N;
		memset(a, 0, sizeof(a));
		for(int i = 0; i <= N; ++i)dp[i][0] = dp[i][1] = -inf;
		for(int i = 0; i < N; ++i){
			in>>a[i];
		}
		dp[1][0] = a[0]+a[1];
		dp[1][1] = -1*(a[0]+a[1]);
		if(N >= 3)
		for(int i = 2; i < N; ++i){
		    dp[i][0] = max(dp[i][0], dp[i-1][0] + a[i]);
			dp[i][0] = max(dp[i][0], dp[i-1][1] + a[i]);
		    dp[i][1] = max(dp[i][1], dp[i-1][0] - 2*a[i-1] - a[i]);
		    dp[i][1] = max(dp[i][1], dp[i-1][1] + 2*a[i-1] - a[i]);
		}
//		cerr<<dp[N-1][0]<<" "<<dp[N-1][1]<<endl;
		out<<max(dp[N-1][0], dp[N-1][1])<<endl;
	}
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	DFlippingSigns solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 2816
a,b,c=gets.split(" ").map(&:to_i)
count5=0
count7=0
count5 +=1 if a == 5
count7 +=1 if a == 7
count5 +=1 if b == 5
count7 +=1 if b == 7
count5 +=1 if c == 5
count7 +=1 if c == 7
print count5 == 2 && count7==1 ? "YES\n" : "NO\n"

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

void FuncReverseArray(char *, int);

int main(void)
{
	char num[3][1024] = {{'\0'}};
	int n;
	int i;

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		int sum=0, career=0;
		int array_long, len_long, len_short;
		int flag = 0;
		int j, k;

		for (j = 0; j < 3; j++) {
			for (k = 0; k < sizeof(num[j]) / sizeof(char); k++) {
				num[j][k] = '\0';
			}
		}

		for (j = 0; j < 2; j++) {
			scanf("%s", num[j]);

			if (strlen(num[j]) > 80) flag = 1;
			FuncReverseArray(num[j], strlen(num[j]));
		}

		if (flag != 1) {
			if (strlen(num[0]) > strlen(num[1])) {
				len_long = strlen(num[0]);
				len_short = strlen(num[1]);
				array_long = 0;
			} else {
				len_long = strlen(num[1]);
				len_short = strlen(num[0]);
				array_long = 1;
			}

			for (j = 0; j < len_long; j++) {
				if (j < len_short)
					sum = (num[0][j] - '0') + (num[1][j] - '0') + career;
				else
				sum = (num[array_long][j] - '0') + career;
				num[2][j] = (sum % 10) + '0';
				career = sum / 10;
			}
			if (career != 0) num[2][j] = career + '0';
			FuncReverseArray(num[2], strlen(num[2]));

			if (strlen(num[2]) > 80) {
				puts("overflow");
			} else {
				printf("%s\n", num[2]);	
			}
		} else {
			puts("overflow");
		}
	}

	return 0;
}

void FuncReverseArray(char *array, int n)
{
	int i;
	char temp;

	for (i = 0; i < (n/2); i++) {
		temp = array[i];
		array[i] = array[n-1-i];
		array[n-1-i] = temp;
	}
}

Measured memory_bytes: 584
import sys
n = int(input())
f = []
p=[]

for i in range(n):
  f.append(list(map(int, input().split())))
for i in range(n):
  p.append(list(map(int, input().split())))

ans=-1*sys.maxsize
for i in range(1, 2**10):
  temp=0
  for shop in range(n):
    cnt=0
    for j in range(10):
      if (i>>j & 1 and f[shop][j] == 1):
        cnt+=1
    temp+=p[shop][cnt]
  ans=max(ans,temp)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;
typedef long long ll;
const int maxn = 1e6+10;
const int inf = 1e9+7;

int cnt,head[maxn];ll dis[maxn];

struct Edge{
    int v;ll w;int next;
    bool operator < (const Edge &rhs) const {
        return w > rhs.w;
    }
}e[maxn];

void add(int u,int v,int value){
    e[cnt].v = v;
    e[cnt].w = value;
    e[cnt].next = head[u];
    head[u] = cnt++;
}

void init(){
    cnt = 0;
    memset(head,-1,sizeof(head));
}

void dij(int s,int len){
    priority_queue<Edge>pq;
    for(int i = 1;i <= len;i++)
        dis[i] = inf;
    bool vis[maxn];
    memset(vis,false,sizeof(vis));
    dis[s] = 0;
    pq.push((Edge){s,0,0});
    while(!pq.empty()){
        Edge tmp = pq.top();pq.pop();
        if(vis[tmp.v]) continue;
        vis[tmp.v] = true;
        for(int i = head[tmp.v];~i;i = e[i].next){
            Edge u = e[i];
            if(dis[u.v] > dis[tmp.v] + u.w){
                dis[u.v] = dis[tmp.v] + u.w;
                pq.push((Edge){u.v,dis[u.v],0});
            }
        }
    }
}

int main(){
    int n,m,u,v,w;
    while(~scanf("%d%d",&n,&m)){
        init();
        while(m--){
            scanf("%d%d",&u,&v);
            w = 1;
            add(u,v,w);
            add(v,u,w);
        }
        dij(1,n);
        if(dis[n] > 2) puts("IMPOSSIBLE");
        else puts("POSSIBLE");
    }
    return 0;
}


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

using namespace std;

int main(){

    int N;

    cin>>N;

    int a[201];

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

    long long ans=1000;

    for(int i=0;i<N-1;i++){
        if(a[i+1]>a[i]){
            
            ans=(ans/a[i])*a[i+1]+(ans%a[i]);
        }
    }

    cout<<ans<<endl;



}


Measured memory_bytes: 3624
from collections import defaultdict
H, W, M = map(int, input().split())
rows = {i: 0 for i in range(H)}
cols = {i: 0 for i in range(W)}
d = defaultdict(int)
for _ in range(M):
    h, w = map(int, input().split())
    h -= 1
    w -= 1
    rows[h] += 1
    cols[w] += 1
    d[(h,w)] += 1
mr = max(rows.values())
mc = max(cols.values())
max_rows = [kv for kv in rows.items() if kv[1] == mr]
max_cols = [kv for kv in cols.items() if kv[1] == mc]
non_dup = False
ans = max_rows[0][1] + max_cols[0][1]
flg = False
for kh, vh in max_rows:
    for kw, vw in max_cols:
        if d[(kh, kw)] == 0:
            non_dup = True
            flg = True
            break
    if flg:
        break
if not non_dup:
    ans -= 1
print(ans)

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

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; }

const long long INF = 1LL << 60;

int N;
long long h[100010];

long long dp[100010];

int main() {
	cin >> N;
	for (int i = 0; i < N; ++i) cin >> h[i];
	
	//DPテーブル全体を初期化
	for (int i = 0; i < 100010; ++i) dp[i] = INF;
	
	//初期条件
	dp[0] = 0;
	
	//ループ
	for (int i = 0; i < N; ++i) {
		chmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
		chmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
	}
	
	cout << dp[N - 1] << endl;
}


Measured memory_bytes: 1792
s=gets.chomp.split("").map &:to_s
s.each_with_index do |si,i|
  if i%2==0
    unless ["R","U","D"].include?(si)
      puts "No"
      exit
    end
  else
    unless ["L","U","D"].include?(si)
      puts "No"
      exit
    end
  end
end
puts "Yes"

Measured memory_bytes: 3836
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

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

    cout<<N*N*N<<endl;

    return 0;
}





Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
	(source = $s:expr, $($r:tt)*) => {
		let mut iter = $s.split_whitespace();
		input_inner!{iter, $($r)*}
	};
	($($r:tt)*) => {
		let s = {
			use std::io::Read;
			let mut s = String::new();
			std::io::stdin().read_to_string(&mut s).unwrap();
			s
		};
		let mut iter = s.split_whitespace();
		input_inner!{iter, $($r)*}
	};
}
#[allow(unused_macros)]
macro_rules! input_inner {
	($iter:expr) => {};
	($iter:expr, ) => {};

	($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
		let $var = read_value!($iter, $t);
		input_inner!{$iter $($r)*}
	};
}
#[allow(unused_macros)]
macro_rules! read_value {
	($iter:expr, ( $($t:tt),* )) => {
		( $(read_value!($iter, $t)),* )
	};

	($iter:expr, [ $t:tt ; $len:expr ]) => {
		(0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
	};

	($iter:expr, chars) => {
		read_value!($iter, String).chars().collect::<Vec<char>>()
	};

	($iter:expr, usize1) => {
		read_value!($iter, usize) - 1
	};

	($iter:expr, $t:ty) => {
		$iter.next().unwrap().parse::<$t>().expect("Parse error")
	};
}

// use priority_queue::PriorityQueue;
use std::collections::BinaryHeap;

fn main(){
	input! {
		n: i32,
		m: i32,
		a: [i64; n],
	}
	let mut que = BinaryHeap::new();
	for i in 0..a.len() {
		que.push(a[i]);
	}
	for _ in 0..m {
		match que.pop() {
			Some(ref mut ai) => {
				*ai /= 2;
				que.push(*ai);
			},
			_ => {}
		}
	}
	let mut ans: i64 = 0;
	while !que.is_empty() {
		match que.pop() {
			Some(ai) => {
				ans += ai;
			},
			_ =>  {}
		}
	}
	println!("{}", ans);
}

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

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

class UnionFindTree {
public:
  UnionFindTree(i64 N) : trees(N, -1), height(N, 1), count(N, 1) {
  }

  void merge(i64 ia, i64 ib) {
    if(ia == -1 || ib == -1) {
      return;
    }
    
    if(is_same_group(ia, ib)) {
      return;
    }

    if(height[ia] > height[ib]) {
      swap(ia, ib);
    }

    i64 rb = find_root(ib), ra = find_root(ia);
    count[rb] += count[ra];
    count[ra] = 0;

    while(trees[ia] != -1) {
      i64 next = trees[ia];
      trees[ia] = ib;
      ia = next;
    }
    trees[ia] = ib;
  }

  bool is_same_group(i64 ia, i64 ib) {
    return find_root(ia) == find_root(ib);
  }

  i64 find_root(i64 ia) {
    vi children;
    i64 i;
    while(trees[ia] != -1) {
      children.pb(ia);
      ia = trees[ia];
    }
    REP(0, sz(children), i) {
      trees[children[i]] = ia;
    }
    return ia;
  }

  vi trees;
  vi height;
  vi count;
};


int main(int argc, char *argv[]) {
  i64 N, i;
  cin >> N;
  vi idx(N), y(N);
  REP(0, N, i) {
    i64 x, y_;
    cin >> x >> y_;
    x--;
    y_--;
    idx[x] = i;
    y[x] = y_;
  }

  vi ans(N, 1);

  UnionFindTree tree(N);
  set<pi> y_min; // y_min, root indices
  i64 x;
  REP(0, N, x) {
    i64 ym = y[x];
    for(auto p=y_min.begin(); p!=y_min.end();) {
      i64 yc = p->first;
      i64 rc = p->second;
      if(yc > y[x]) {
	break;
      }
      else {
	tree.merge(x, rc);
	ym = min(ym, yc);
	p = y_min.erase(p);
      }
    }
    y_min.insert({ym, tree.find_root(x)});
  }

  REP(0, N, i) {
    ans[idx[i]] = tree.count[tree.find_root(i)];
  }

  REP(0, N, i) {
    assert(ans[i] != -1);
    printf("%lld\n", ans[i]);
  }

  return 0;
}


Measured memory_bytes: 17256
S=str(input())

N=len(S)

if((N+1)%4 == 0):
    k=(N-1)//4+1
else:
    k=(N-1)//4

for i in range(0, (N-1)//4+1):
    if(S[i] == S[(N-1)//2-i-1] == S[i+(N+1)//2] == S[N-i-1]):
        if i == k-1:
            print("Yes")
            break;
        else:
            continue
    else:
        print("No")
        break;


Measured memory_bytes: 3064
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int n;
    scanf("%d", &n);
    ll ans = 0;
    int max = -1;
    int i;
    for (i = 0; i < n; i++) {
        int tmp;
        scanf("%d", &tmp);
        if (i == 0) {
            max = tmp;
        }
        else {
            if (tmp < max) {
                ans += (max - tmp);
            }
            else {
                max = tmp;
            }
        }
    }
    printf("%lld\n", ans);
    return;
}

int main()
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for (t = 0; t < T; t++) {
        //printf("Case #%d: ", t + 1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 1732
def examA():
    X = [I() for _ in range(5)]
    k = I()
    X.sort()
    ans = "Yay!"
    if X[-1]-X[0]>k:
        ans = ":("
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examA()


Measured memory_bytes: 3548
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 

#define M 10010
#define N 110
ll n,d;
string s;
ll dp[M][N][2];
ll f(ll pos,ll sum,ll ok){
	if(pos>=sz(s)) return !sum;
	if(dp[pos][sum][ok] != -1) return dp[pos][sum][ok];
	ll ans = 0;
	rep(i,0,10){
		ll c = s[pos]-'0';
		bool okk = ok or i<c;
		bool ff = okk or i==c;
		if(ff){
			(ans+=f(pos+1,(sum+i)%d,okk)) %= md;
		}
	}
	return dp[pos][sum][ok] = ans;
}
int main(){
	IOS;
	tihs;
	memset(dp,-1,sizeof(dp));
	cin>>s>>d;
	ll ans = f(0,0,0);
	ans--;
	if(ans<0)ans+=md;
	cout<<ans;

	return 0;
}

Measured memory_bytes: 18304
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long int lli;

int main() {
    lli N;
    lli temp_num;
    string ans = "";
    cin >> N;
    temp_num = N;
    while (temp_num > 0) {
        lli word = (temp_num % 26);
        if (word == 0) {
            word = 26;
            temp_num--;
        }
        char temp_c;
        temp_c = char(word + 96);
        ans.push_back(temp_c);
        temp_num /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    vector<vector<int>> c(3, vector<int>(3, 0));
    rep(i, 3)rep(j, 3) cin >> c[i][j];
    vector<int> a(3, 0), b(3, 0);
    b[0] = c[0][0] - a[0];
    a[1] = c[1][0] - b[0];
    a[2] = c[2][0] - b[0];
    b[1] = c[0][1] - a[0];
    b[2] = c[0][2] - a[0];

    rep(i, 3)rep(j, 3){
        if(a[i] + b[j] != c[i][j]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

int main()
{
int a[3];
cin>>a[0]>>a[1]>>a[2];
for(int i=0;i<3;i++)
for(int j=i;j<3;j++)
if(a[i]>a[j])
swap(a[i],a[j]);
for(int i=0;i<3;i++)
{
cout<<a[i];
if(i==2)
cout<<endl;
else
cout<<" ";
}
}

Measured memory_bytes: 1164
import sys

n, m = list(map(int, input().split()))
if m > 0:
    aaa = set(map(int, sys.stdin))
else:
    aaa = set()
dp = [0] * (n + 1)
dp[0] = 1
dp[1] = 1 if 1 not in aaa else 0
MOD = 10 ** 9 + 7

for i in range(2, n + 1):
    if i in aaa:
        continue
    dp[i] = (dp[i - 2] + dp[i - 1]) % MOD
print(dp[n])


Measured memory_bytes: 11884
#include <stdio.h>

int main(void)
{
	int array[5], i, j, camp;
	
	for (i = 0; i < 5; i++){
		scanf("%d", &array[i]);
	}
	
	for (i = 0; i < 4; i++){
		for (j = i + 1; j < 5; j++){
			if (array[i] < array[j]){
				camp = array[i];
				array[i] = array[j];
				array[j] = camp;
			}
		}
	}
	
	for (i = 0; i < 5; i++){
		printf("%d", array[i]);
		
		if (i != 4){
			printf(" ");
		}
	}
	puts("");
	
	return (0);
}

Measured memory_bytes: 612
#include <stdio.h>
#include <stdlib.h>
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
int main(){
    int d,n,t[200],a[200],b[200],c[200],dp[200][200],i,j,k,maxc=0,minc=100,ans=0;
    scanf("%d%d",&d,&n);
    for (i=0; i<d; i++) {
        scanf("%d",&t[i]);
    }
    for (i=0; i<n; i++) {
        scanf("%d%d%d",&a[i],&b[i],&c[i]);
        if (t[0]>=a[i]&&t[0]<=b[i]) {
            maxc=max(c[i], maxc);
            minc=min(c[i], minc);
        }
    }
    for (i=0; i<n; i++) {
        if (t[1]>=a[i]&&t[1]<=b[i]) {
            dp[1][i]=max(maxc-c[i], c[i]-minc);
        }
        else dp[1][i]=-100;
    }
    for (i=2; i<d; i++) {
        for (j=0; j<n; j++) {
            if (t[i]>=a[j]&&t[i]<=b[j]) {
                for (k=0; k<n; k++) {
                    dp[i][j]=max(dp[i-1][k]+abs(c[j]-c[k]), dp[i][j]);
                }
            }else{
                dp[i][j]=-100;
            }
        }
    }
    for (i=0; i<n; i++) {
        ans=max(dp[d-1][i], ans);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 760
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
vector<int>v(3);
for(int i = 0; i<3; i++){
	cin>> v[i];
}
sort(v.begin(), v.end());
cout << (v[2] * 10) + v[1] + v[0];

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int n;
string s;

void input(){
    cin >> n >> s;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    vector<int> button = {1,2,3,4,5,6,7,8,9};
    // 9!ためす
    int tmp = INF;
    vector<int> ans;
    map<pair<int, int>, int> cnt; //key:grid->grid, value:回数
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            cnt[make_pair(i, j)] = 0;
        }
    }
    for(int i=0;i<n-1;i++){
        cnt[make_pair(int(s[i]-'0'), int(s[i+1]-'0'))]++;
    }

    do{
        map<int, pair<int, int>> grid; //key:button, value:grid
        for(int i=0;i<9;i++){
            grid[button[i]] = make_pair(i/3, i%3);
        }
        int rec = 0;
        for(int i=1;i<=9;i++){
            for(int j=1;j<=9;j++){
                pair<int, int> a,b;
                a = grid[i];
                b = grid[j];
                rec += cnt[make_pair(i, j)] * (abs(a.first - b.first) + abs(a.second - b.second));
            }
        }
        if(tmp > rec){
            tmp = rec;
            ans = button;
        }
    }while(next_permutation(button.begin(), button.end()));
    for(int i=0;i<9;i++){
        cout << ans[i];
        if(i%3 == 2) cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3316
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


# show_flg = True
show_flg = False


def sumXOR(arr,  n):
    _sum = 0
    for i in range(0, 64):
        zc = 0
        oc = 0

        # Individual sum at each bit position
        idsum = 0
        for j in range(0, n):
            if (arr[j] % 2 == 0):
                zc = zc + 1
            else:
                oc = oc + 1
            arr[j] = arr[j] // 2

        # calculating individual bit sum
        idsum = oc * zc * (1 << i)

        # final sum
        _sum = _sum + idsum
        _sum %= MOD

    return _sum


def main():
    N = I()
    A = list(MI())
    print(sumXOR(A, len(A)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 120232
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    L,R = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    if R-L>=2019:
        print(0)
        return
    ans=2019
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            ans=min(ans,i*j%2019)
    print(ans)





if __name__ == "__main__":
    main()

Measured memory_bytes: 72892
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const mod int = 998244353

func main() {
	sc.Split(bufio.ScanWords)
	n, k := nextInt(), nextInt()

	ls := make([]int, k)
	rs := make([]int, k)
	for i := 0; i < k; i++ {
		ls[i], rs[i] = nextInt(), nextInt()
	}

	dp := [210000]int{}
	ss := make([]int, n+1)
	dp[1] = 1
	ss[1] = 1
	for i := 2; i <= n; i++ {
		for j := 0; j < k; j++ {
			l := i - rs[j] - 1
			r := i - ls[j]
			if r < 0 {
				continue
			}
			if l < 0 {
				l = 0
			}
			dp[i] += ss[r] - ss[l]
			dp[i] %= 998244353
		}
		ss[i] = ss[i-1] + dp[i]
	}

	fmt.Println(dp[n])
}

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


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

int a[200010];
long long sum1[200010], sum2[200010];

int main(){
	int n; scanf("%d", &n);
	for (int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		sum1[i] = sum1[i - 1] + a[i];
		sum2[i] = sum2[i - 1] ^ a[i];
	}
	long long ans = 0;
	for (int i = 1; i <= n; i++){
		int l = i, r = n;
		while (l < r){
			int mid = (l + r + 1) >> 1;
			if ((sum1[mid] - sum1[i - 1]) == (sum2[mid] ^ sum2[i - 1])) l = mid;
			else r = mid - 1;
		}
		ans += l - i + 1;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 4096
n = int(input())
t,a = map(int,input().split())
for i in range(n-1):
  T,A=map(int,input().split())
  count = max(a//A,t//T)
  while (A*count < a) or (T*count < t):
    count += 1
  a = count * A
  t = count * T
print(a+t)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef  long long   ll;
typedef  long double ld;
#define ceil(n, m) ((n / m) + ( n % m ? 1 : 0))
#define mod(n, m) (((n % m) + m) % m)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    vector<ll> a(n);
    for(auto& i : a)
        cin >> i;
    ll ans = 0;
    for(int i = 1; i < n; i++)
        ans += max(0LL, a[i - 1] - a[i]), a[i] = max(a[i], a[i - 1]);
//    for(auto i :a)
//        cout<< i<< ' ';
//    cout << '\n';

    cout << ans;
}

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

using namespace std;

int main(int argc, char *argv[]) {
	int r, g, b;
	cin >> r >> g >> b;

	int all = (100 * r) + (10 * g) + b;
	cout << ((all % 4 == 0) ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env ruby
a, b, c, d = STDIN.readline().strip.chars.map(&:to_i)
def make_7_exp(a, b, c, d)
  ops = make_combination(['+', '-'], 3)
  exps = ops.map{|o| "#{a}#{o[0]}#{b}#{o[1]}#{c}#{o[2]}#{d}"}
  exps
end
def make_combination(ops, n)
  if n == 0
    [[]]
  else
    c1 = make_combination(ops, n-1)
    c = []
    for i in 0...ops.length
      c << c1.map{|m| [ops[i]] + m }
    end
    c.flatten(1)
  end
end
def check_7(a, b, c, d)
  make_7_exp(a, b, c, d).find{|e| eval(e) == 7}
end
puts "#{check_7(a, b, c, d)}=7"

Measured memory_bytes: 1788
//{
#include<bits/stdc++.h>
using namespace std;
 
// #define DEBUG

typedef long long int ll;
typedef long double ld;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define MOD (ll)(1e9 + 7)
#define vi vector<int>
#define vii vector<vector<int> >
#define vl vector<ll>
#define vll vector<vector<ll> >
#define vc(T, nm) vector<T> nm
#define pb push_back
#define popb pop_back
#define si set<int>
#define sl set<ll>
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define ins insert
#define ers erase
#define endl "\n"
#define mul(a, b) ((a % MOD) * (b % MOD)) % MOD
#define adr(a, b) ((a % MOD) + (b % MOD)) % MOD
#define FORA(x, s, e, inc) for(ll x = s; x != e; x += inc)
#define ROFA(x, s, e, inc) for(ll x = s; x != e; x -= inc)
#define FOR(x, s, e) FORA(x, s, e, 1)
#define ROF(x, s, e) ROFA(x, s, e, 1)
#define loop(x, n) FOR(x, 0, n)
#define rd1(t, a) 					t a; cin >> a;
#define rd2(t, a, b) 				rd1(t, a); rd1(t, b); 
#define rd3(t, a, b, c) 			rd2(t, a, b); rd1(t, c);
#define rd4(t, a, b, c, d) 			rd3(t, a, b, c); rd1(t, d);
#define rd5(t, a, b, c, d, e) 		rd4(t, a, b, c, d); rd1(t, e);
#define rd6(t, a, b, c, d, e, f) 	rd5(t, a, b, c, d, e); rd1(t, f);
#define rdA(t, nm, len)				t nm[len]; loop(i, len) {cin >> nm[i];}
#ifdef DEBUG
	#define deb(v) cout << endl << #v << ": " << v << endl
	#define db1(v) cout << endl << #v << ": " << "[ "; for(auto x: v) {cout << x << " ";}; cout << "]" << endl;
	#define db2(v) cout << endl << #v << ": " << endl; for(auto r: v) {cout << "[ "; for(auto x: r) {cout << x << " ";}; cout << "]" << endl;};
	#define dbl cout << "-------------------------------" << endl
#else
	#define deb(v)
	#define db1(v)
	#define db2(v)
	#define dbl
#endif
//}

bool isperfect(ll n) {
    ll old_n = n;
    for(int i = 2; i < n; i++) {
        while(n % i == 0)
            n /= i;
        if(n == 1)
            return true;
        else
            n = old_n;
    }
    
    return false;
}

ll solve(ll n) {
    ROF(i, n, 0) {
        if(isperfect(i))
            return i;
    }
    
    return 1;
    
}

void Input() {
    rd1(ll, n);
    cout << solve(n);
}

int main() {
	
	fastio;

    // rd1(ll, t);
	ll t = 1;

    while(t--) {
        Input();
    }
    
	return 0;
}

Measured memory_bytes: 3604
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 3e18;
const double INFD = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 200005;
const int MAXV = 50000;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
char text[MAXN];
int arr[MAXN];

int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    map<int, int> mpp;
    scanf("%d", &n);
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        arr[i] = read<int>();
        sum += arr[i];
        mpp[arr[i]]++;
    }
    scanf("%d", &m);
    while (m--) {
        int b, c;
        scanf("%d%d", &b, &c);
        sum -= (ll)b * mpp[b];
        sum += (ll)c * mpp[b];
        int cnt = mpp[b];
        mpp[b] = 0;
        mpp[c] += cnt;
        printf("%lld\n", sum);
    }
    return 0;
}

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

int main() {
  // ここにプログラムを追記
  int N;
  cin >> N;
  vector<char> hina(N);
  for(int i =0;i<N;i++){
    cin >> hina.at(i);
  }
  bool Y=false;
  
  for(int i = 0;i<N;i++){
    if(hina.at(i)=='Y'){
      Y=true;
      break;
    }
  }
  if(Y){
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
}


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

int main(){
    int N;
    cin>>N;
    
    long long power=1;
    int i=N;
    
    
    while(i!=1){
        power=i*power%int(pow(10,9)+7);
        i--;
        
    }
    
    cout<<power<<endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N, A[212345], C[212345];

int main() {

	cin >> N;
	rep(i, N - 1) cin >> A[i];

	rep(i, N - 1) C[A[i] - 1]++;

	rep(i, N) cout << C[i] << endl;

	return 0;
}


Measured memory_bytes: 5196
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int N = sc.nextInt();
		int X = sc.nextInt();
		
		int[] L = new int[N+1];
		int[] d = new int[N+1];
        d[0] = 0;
		for (int i = 0; i < N; i++) {
			L[i] = sc.nextInt();
		}
        int ans = 1;
		for (int i = 1; i < N+1; i++) {
            d[i] = d[i-1]+L[i-1];
			if(d[i]<=X){
              ans++;
            }
		}
		System.out.println(ans);
	}		
}


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

using namespace std;

int main()
{
    int t,i,j,ac=0,wa=0,tle=0,re=0;
//    char s[4];
string s;
    char a[]="AC",b[]="WA",c[]="TLE",d[]="RE";
//    cout<<a<<endl;
    scanf("%d",&t);
    while(t--)
    {
//       scanf(" %s",s);
       cin>>s;
       if(s==a)
        ac++;
       else if(s==b)
        wa++;
       else if(s==c)
        tle++;
       else if(s==d)
        re++;
    }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",ac,wa,tle,re);
    return 0;
}


Measured memory_bytes: 3784
/**
 *    author:  tourist
 *    created: 29.12.2019 20:57:06       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  int sz = (int) (unique(a.begin(), a.end()) - a.begin());
  if (sz % 2 == 0) --sz;
  cout << sz << '\n';
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
int main(void)
{
    long long int a, b, n, x, ans = 0;
    scanf("%lld %lld %lld", &a, &b, &n);
    if(b-1<=n)
    {
        x = b - 1;
    }else{
        x = n;
    }
    ans = floor((a * x) / b) - (x / b);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1732
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    float average = 0, x[n];
    for(int i = 0; i < n; i++)
    {
        cin >> x[i];
        average += x[i];
    }
    int avg;
    if((average / n - (int)(average / n)) <= 0.5)
        avg = (int)(average / n);
    else
        avg = (int)(average / n) + 1;
    float stamina = 0;
    for(int i = 0; i < n; i++)
        stamina += (x[i] - avg)*(x[i] - avg);
    cout << stamina << "\n";
    return 0;
}

Measured memory_bytes: 384
sticks=int(input())
lengths=input()
new_list=lengths.split()
list=[]
for item in new_list:
    list.append(int(item))
i=len(list)-1
j=i-1
k=i-2
count=0
empty=[]
while i>=2:
    while j>=1:
        while k>=0:
            if list[i]!=list[j]and list[i]!=list[k]and list[j]!=list[k]:
                empty.append((list[i],list[j],list[k]))
            k=k-1
        j=j-1
        k=j-1
    i=i-1
    j=i-1
    k=j-1
for items in empty:
    if items[0]+items[1]>items[2]and items[1]+items[2]>items[0]and items[2]+items[0]>items[1]:
        count=count+1
print(count)

Measured memory_bytes: 20480
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
template<class T> void read(T & x) {
    x = 0; int f = 1, ch = getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=getchar();}
    x *= f;
}
typedef long long ll;
const int maxn = 1000 + 5;
const int maxm = 1000 + 5;
const int mod = 1e9 + 7;
int n, m; ll k; char s[maxn][maxm];
struct matrix {
    int a[2][2];
    matrix() {memset(a, 0, sizeof(a));}
    void E() {
        a[0][0] = a[1][1] = 1;
    }
};
matrix operator * (const matrix & x, const matrix & y) {
    matrix re;
    for(int i = 0; i < 2; ++i) {
        for(int j = 0; j < 2; ++j) {
            for(int h = 0; h < 2; ++h) {
                (re.a[i][j] += (ll)x.a[i][h] * y.a[h][j] % mod) %= mod;
            }
        }
    }
    return re;
}
matrix qpow(matrix x, ll y) {
    matrix re; re.E();
    while(y) {
        if(y & 1) re = re * x;
        x = x * x, y >>= 1;
    }
    return re;
}
ll qpow(ll x, ll y) {
    ll re = 1;
    while(y) {
        if(y & 1) re = re * x % mod;
        x = x * x % mod, y >>= 1;
    }
    return re;
}
void rever() {
    int p = max(n, m);
    for(int i = 1; i <= p; ++i) for(int j = i + 1; j <= p; ++j) {
        swap(s[i][j], s[j][i]);
    }
    swap(n, m);
}
void solve() {
    int a = 0, b = 0, v = 0;
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= m; ++j) {
            if(s[i][j] == '#') v++;
        }
    }
    for(int i = 1; i <= m; ++i) {
        if(s[1][i] == '#' && s[1][i] == s[n][i]) a++;
    }
    for(int i = 1; i <= n; ++i) {
        if(s[i][1] == '#' && s[i][1] == s[i][m]) b++;
    }
    if(a && b) puts("1");
    else if(!a && !b) printf("%d\n", (int)qpow(v, k - 1));
    else {
        if(b) {
            a = b; rever();
        }
        int c = 0;
        for(int i = 1; i < n; ++ i) for(int j = 1; j <= m; ++j) {
            if(s[i][j] == '#' && s[i][j] == s[i + 1][j]) c++;
        }
        matrix t; t.a[0][0] = v, t.a[1][0] = c, t.a[1][1] = a;
        t = qpow(t, k - 1);
        int an = (t.a[0][0] - t.a[1][0]) % mod; an = (an + mod) % mod;
        printf("%d\n", an);
    }
}
int main() {
    // freopen("testdata.in", "r", stdin);
    read(n), read(m), read(k);
    for(int i = 1; i <= n; ++i) {
        scanf("%s", s[i] + 1);
    }
    solve(); return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt,e) for(ll cnt=0;cnt<e;cnt++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;

typedef tuple<ll,ll,ll> T;


ll i,j,k;


int main(){
    ll N;
    cin>>N;
    V X(N);
    rep(i,N)cin>>X[i];

    ll teis=0;
    ll heiho=0;
    rep(i,N)teis+=X[i];
    rep(i,N)heiho+=X[i]*X[i];
    cout<<heiho+min(N*(teis/N)*(teis/N)-2*(teis/N)*teis,N*(teis/N+1)*(teis/N+1)-2*(teis/N+1)*teis)<<endl;    
}


Measured memory_bytes: 256
import bisect
n,q=map(int,input().split())
year=[1]
name=["kogakubu10gokan"]
for i in range(n):
    ye,na=map(str,input().split())
    year.append(int(ye))
    name.append(na)
b=bisect.bisect_left(year,q+1)
print(name[b-1])


Measured memory_bytes: 5636
import java.util.Scanner;
class Main {

	public static void main(String[] args) {
	Scanner src = new Scanner(System.in);
	
	int a = src.nextInt();
	int b = src.nextInt();
	int c = src.nextInt();
		for(int i=0; i<2; i++){
			if(b>c){
				int t = b;
				b = c;
				c = t;
			}
			if(a>b){
				int t = a;
				a = b;
				b = t;
			}
		}
	System.out.println(a+" "+b+" "+c);
	}
}

Measured memory_bytes: 17164
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    int a, b; cin >> a >> b;
    cout << 6 - a - b << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3492
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
 ll a,b,c,d,i,j,l,k=0;
vector<ll>v,vv;
cin>>a>>b;
 for(i=1;i<=a;i++)
 {
  cin>>c;
v.push_back(c);
 }
sort(v.begin(),v.end());
    for(i=0;i+b<=a;i++)
    {
        
        //cout<<v[i]<<" "<<v[i+b-1]<<endl;
        if(i==0)
        k=abs(v[i]-v[i+b-1]);
        else
    k=min(k,abs(v[i]-v[i+b-1]));
        
    
}

cout<<k<<endl;
}

Measured memory_bytes: 1400
X = int(input())
L = [0 for _ in range(201)]
for i in range(201):
    L[i] = i * i * i * i * i
flg = False
for i in range(201):
    for j in range(201):
        if L[i] - L[j] == X:
            print(i, j)
            flg = True
        elif L[i] + L[j] == X:
            print(i, -j)
            flg = True
        if flg:
            break
    if flg:
        break

Measured memory_bytes: 9200
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;

#define BIG_NUM 2000000000

using namespace std;


int main(){

	bool FLG = false;
	int N,T,E;
	scanf("%d %d %d",&N,&T,&E);
	int tmp,calc;

	for(int i = 0; i < N; i++){
		scanf("%d",&tmp);

		if(!FLG)
		{
			calc = tmp;
			while(calc <= T+E){
				if(abs(T-calc) <= E){
					FLG = true;
					printf("%d\n",i+1);
					break;
				}
				calc += tmp;
			}
		}
	}

	if(!FLG)printf("-1\n");

    return 0;
}

Measured memory_bytes: 2752
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;
char s[52][52];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int d[52][52];

int bfs(int h,int w){
   queue<pair<int,int>> que;
   for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
         d[i][j]=100000000;
      }
   }
   que.push(pair<int,int>(0,0));
   d[0][0]=0;
   
   while(que.size()){
      pair<int,int>p=que.front();
      que.pop();
      if(p.first==h-1 && p.second==w-1)break;
      for(int i=0;i<4;i++){
         int ny=p.first+dy[i],nx=p.second+dx[i];
         if(0<=ny && ny<h && 0<=nx && nx<w && s[ny][nx]=='.' && d[ny][nx]==100000000){
            que.push(pair<int,int>(ny,nx));
            d[ny][nx]=d[p.first][p.second]+1;
         }
      }
   }
   return d[h-1][w-1];
}

int main(){
   int h,w;
   cin>>h>>w;
   int black=0;
   for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
         cin>>s[i][j];
         if(s[i][j]=='#')black++;
      }
   }
   int res=bfs(h,w);
   if(res==100000000){
      cout<<-1<<endl;
   }
   else cout<<h*w-res-black-1<<endl;
}

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

int main() {
  int n;
  cin >> n;
string ans="Three";
  
  for (int i=0; i<n; i++){
    string s;
    cin >> s;
    
    if (s=="Y"){
      ans="Four";
      break;
    }
    

      
}
  cout << ans << endl;
}


Measured memory_bytes: 256
li = input().split()
m = (li[0], 0)
l = (li[0], len(li[0]))
for s in set(li):
    if li.count(s) > m[1]: m = (s, li.count(s))
    if l[1] < len(s): l = (s, len(s))
print(m[0], l[0])
    
    


Measured memory_bytes: 5564
<?php

fscanf(STDIN, "%d %d", $K, $S);

$res = 0;
for ($i=0; $i<=$K; $i++) {
    for ($j=0; $j<=$K; $j++) {
        $k = $S - $i - $j;
        if ($k < 0 || $k > $K) {
            continue;
        }
        $res++;
    }
}
print "$res\n";



Measured memory_bytes: 4856
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

ll solve(ll k){
  if(k < 10) return k;
  vvll dp(10, vll(10, 0));
  ll s = 0;
  for(int i = 0; i < 10; i++) dp[0][i] = 1, s++;
  s--;
  for(int i = 1; i < 10; i++){
    for(int j = 0; j < 10; j++){
      if(j == 0){
        dp[i][0] = dp[i-1][0] + dp[i-1][1];
        continue;
      }
      if(j == 9){
        dp[i][9] = dp[i-1][8] + dp[i-1][9];
      }
      else dp[i][j] = dp[i-1][j-1] + dp[i-1][j] + dp[i-1][j+1];
      if(s + dp[i][j] >= k){
        ll ans = 0;
        while(i+1){
          if(s + dp[i][j] >= k){
            ans = ans * 10 + j;
            if(j > 0) j--;
            i--;
          }
          else{
            s += dp[i][j];
            if(j < 9) j++;
          }
          // cout << i << ' ' << j  << ' ' << s << ' ' << ans << endl;
        }
        return ans;
      }
      s += dp[i][j];
    }
  }
  return 0;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  ll k; cin >> k;
  cout << solve(k) << endl;
  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


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

using namespace std;
using ll = long long;
const int NMAX = 50;
bool graph[NMAX][NMAX];

int dfs(int v, int N, bool visited[NMAX]); 

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

	for (int i = 0; i < M; i++) {
		int a,b;
		cin >> a >> b;
		graph[a - 1][b - 1] = true;
		graph[b - 1][a - 1] = true;
	}

	int ans = 0;
	bool visited[NMAX];
	for (int i = 0; i < N; i++) {
		visited[i] = false;
	}
	visited[0] = true;

	for (int i = 0; i < N; i++) {
		for (int j = i; j < N; j++) {
			if (graph[i][j]) {
				graph[i][j] = false;
				graph[j][i] = false;
				if (!dfs(0,N,visited)) {
					ans++;
				}
				for (int i = 0; i < N; i++) {
					visited[i] = false;
				}
				visited[0] = true;
				graph[i][j] = true;
				graph[j][i] = true;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

int dfs(int v, int N, bool visited[NMAX]) {

	bool all_visited = true;
	for (int i = 0; i < N; i++) {
		if (visited[i] == false) {
			all_visited = false;
		}
	}

	if (all_visited) {
		return true;
	}

	bool ret = false;

	for (int i = 0; i < N; i++) {
		if (graph[v][i] && !visited[i]) {
			visited[i] = true;
			ret = dfs(i,N,visited);
		}
	}

	return ret;

}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    string s;
    cin >> s;

    reverse(s.begin(), s.end());
    ll ten = 1;
    vector<ll> cnt(13);
    cnt.at(0) = 1;
    for (char c : s) {
        vector<ll> tmp(13);
        if (c == '?') {
            for (int i=0; i<10; ++i) {
                int shift = ten * (ll)i % 13;
                for (int j=0; j<13; ++j) tmp.at((j+shift)%13) += cnt.at(j);
                for (int j=0; j<13; ++j) tmp.at(j) %= MOD;
            }
        } else {
            int shift = ten * (ll)(c-'0') % 13;
            for (int i=0; i<13; ++i) tmp.at((i+shift)%13) += cnt.at(i);
            for (int i=0; i<13; ++i) tmp.at(i) %= MOD;
        }
        cnt = tmp;
        ten *= 10;
        ten %= 13;
    }
    cout << cnt.at(5) << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}
int main()
{
	int x , a , b;
	cin >> x >> a >> b;
	if(abs(x - a) < abs(x - b))
		cout << "A" << endl;
	else 
		cout << "B" << endl;
	return 0;
} 




Measured memory_bytes: 256
S = input()
stack = [""]
old = ""
# for s in S:
#     cur = s
#     while(1):
#         if stack[-1]!=cur:
#             stack.append(cur)
#             break
#         else:
#             old = stack[-1]
#             stack.pop()
#             cur = old + s
for s in S:
  
    cur = old + s
    old = ""
    if stack[-1]!=cur:
        stack.append(cur)
    else:
        old = cur

    #print (stack)
print (len(stack)-1)

Measured memory_bytes: 8064