akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

struct edge{
    ll to, cost;
};
vector<vector<edge> > G(51, vector<edge>(0));
set<int> ans;
vec a(51), b(51);
vector<bool> used(51, false);
bool dfs(ll v, ll id, ll border){
    if(v == b[id]) return true;
    used[v] = true;
    for(edge e : G[v]){
        if((ans.find(e.cost) != ans.end() || e.cost <= border) && !used[e.to]){
            if(dfs(e.to, id, border)) return true;
        }
    }
    return false;
}
int main(){
    cin>>N;
    rep(i,N) cin>>a[i];
    rep(i,N) cin>>b[i];
    rep(i,51){
        reps(j,1,i + 1){
            G[i].push_back((edge){i%j, j});
        }
    }
    rep(roop,52){
        rep(border, 52){
            if(border == 51){
                cout<<-1<<endl;
                return 0;
            }
            bool ok = true;
            rep(i,N){
                rep(j,51) used[j] = false;
                if(!dfs(a[i], i, border)){
                    ok = false;
                    break;
                }
            }
            if(ok){
                if(border == 0){
                    ll sum = 0;
                    for(ll s : ans) sum += 1LL<<s;
                    cout<<sum<<endl;
                    return 0;
                }else{
                    ans.insert(border);
                    break;
                }
            }
        }
    }
}

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

#define 	ll 						long long int
#define 	pb 						push_back
#define 	mp 						make_pair
#define 	fast 					ios_base::sync_with_stdio(false);cin.tie(NULL);
#define 	ff 						first
#define 	ss 						second
#define 	nil 					-10e+9
#define 	initial 				0
#define 	waiting 				1
#define 	visit 					2
#define 	inf  					10e+9
#define 	mx   					200005
#define 	mxx  					1000005
#define 	mod  					1000000007
#define 	pr   					pair<ll,ll>
#define 	pp_queue 			priority_queue<pr,vector<pr>, greater<pr> >
#define 	dp_queue 			priority_queue<int,vector<int>, greater<int> >
#define 	sp_queue 			priority_queue<int>
#define 	fr(i,p,q)			for(int i=p;i<q;++i)
#define 	frr(i,p,q) 		for(int i=p;i<=q;++i)
#define 	mem(a,b) 			memset(a,b,sizeof(a))
#define 	len(a)   			(int)a.size()
#define 	input  				freopen("input.txt", "r", stdin);
#define 	output 				freopen("output.txt", "w", stdout);
#define 	debug(arr,j,n) fr(i,j,n) cout<<arr[i]<<" ";

ll power(ll a,ll b){ll aa=1;while(b){if(b&1){aa=aa*a;aa%=mod;}a=a*a;a%=mod;b/=2;}return aa;}

using namespace std;

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

	bool flag=true;

	for(int i=0;i<len(s);i++){
		if((i+1)%2==0 and s[i]=='R') {
			flag=false;
			break;
		}
		if((i+1)%2!=0 and s[i]=='L') {
			flag=false;
			break;
		}
	}

	if(flag) cout<<"Yes\n";
	else
	cout<<"No\n";

  return 0;
}


Measured memory_bytes: 256
N=int(input())
R=[list(map(int,input().split())) for i in range(N)]
B=[list(map(int,input().split())) for i in range(N)]

R.sort(key=lambda x:x[1],reverse=True)
B.sort()

ANS=0
checked=[0]*N
for x1,y1 in R:
    for i in range(N):
        x2,y2=B[i]
        if x1<x2 and y1<y2 and checked[i]==0:
            ANS+=1
            checked[i]=1
            break

print(ANS)

Measured memory_bytes: 3064
x, y = map(int, input().split())
def a(n):
    if n == 1:
        return 100000 * 3
    if n == 2:
        return 100000 * 2
    if n == 3:
        return 100000
    return 0
res = a(x) + a(y)
if x == y == 1:
    res += 100000*4
print(res)

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

int main() {
  long a,b,c,d,ans,aa,bb,cd,mincd,maxcd,div;
  cin >> a >> b >> c >> d;
  ans=b-a+1;

  if(a%c>0) aa=a/c+1;
  else aa=a/c;
  bb=b/c+1;
  ans-=bb-aa;

  if(a%d>0) aa=a/d+1;
  else aa=a/d;
  bb=b/d+1;
  ans-=bb-aa;

  cd=c*d;
  div=1;
  mincd=min(c,d);
  maxcd=max(c,d);
  for(long i=1;i*i<=mincd;i++) {
    if(mincd%i==0) {
      if(maxcd%i==0) div=max(i,div);
      if(maxcd%(mincd/i)==0) div=max(mincd/i,div);
    };
  };
  cd=cd/div;

  if(a%cd>0) aa=a/cd+1;
  else aa=a/cd;
  bb=b/cd+1;
  ans+=bb-aa;
  cout << ans << endl;
}

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

using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
struct cake{
	int w,h;
	cake(int aa,int bb){
		w = aa;h = bb;
	}
	int area() const{
		return w*h;
	}
		void pri(){
				cout << "(a,b) = " << w << ", " << h<< ",are = " << area() << endl;
		}
};	

bool comp(const cake &c1, const cake &c2){
	return c1.area() < c2.area();
}
int main(){
	int n,w,d;
	while(cin>>n>>w>>d,n||w||d){
		vector<cake> c(2*(n+1),cake(0,0));
		c[0] = cake(w,d);
		REP(i,n){
			int num;
			int s;
			cin >> num  >> s;
			num--;
			int a = c[num].w;//width
			int b = c[num].h;//height
			int add_i = i+1;
 			s %= 2*(a + b);
			if(a > s || a*2 + b > s && a + b < s ){
				if(a*2 + b > s && a + b < s )s = a*2 + b - s;
				c[add_i] = cake(s,b);
				c[add_i+1] = cake(a-s,b);
			}else{
				if(a + b > s ){
					s -= a;
				}else{
					s = a*2 + b*2 - s;
				}
				c[add_i] = cake(a,s);
				c[add_i+1] = cake(a,b-s);
			}
			if(c[add_i].area() > c[add_i+1].area())swap(c[add_i],c[add_i+1]);
			//c[add_i].pri();c[add_i+1].pri();
			c.erase(c.begin() + num);
			//			cout << "i = " << i << endl;c[0].pri();c[1].pri();c[2].pri();
		}
		sort(c.begin(),c.end(),comp);
		//	c[0].pri();c[1].pri();c[2].pri();
		while(c[0].area() == 0)c.erase(c.begin());
		REP(i,n+1){
			if(i)cout << ' ';
			cout << c[i].area();
		}
		cout << '\n';
	}
	return 0;
}					
		

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    char a, b; cin >> a >> b;
    cout << ((a == 'H' and b == 'H') or (a == 'D' and b == 'D') ? 'H' : 'D') << "\n";

}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.NoSuchElementException;

public class Main {

	static HashMap<Long, Long> cnt = new HashMap<Long, Long>();

	public static void main(String[] args) {
		for (long num = 1L; num <= 100000L; ++num) {
			cnt.put(num, 0L);
		}

		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		for (int i = 0; i < n; ++i) {
			long a = sc.nextLong();
			cnt.put(a, cnt.get(a) + 1L);
		}

		long s = 0L;
		for (long num = 1L; num <= 100000L; ++num) {
			s += num * cnt.get(num);
		}

		int q = sc.nextInt();
		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < q; ++i) {
			long b = sc.nextLong();
			long cntB = cnt.get(b);
			s -= b * cntB;

			long c = sc.nextLong();
			cnt.put(b, 0L);
			cnt.put(c, cnt.get(c) + cntB);
			s += c * cntB;
			pw.println(s);
		}
		pw.flush();
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		}

		ptr = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}

		return buflen > 0;
	}

	private int readByte() {
		return hasNextByte() ? buffer[ptr++] : -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public String nextLine() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b) || b == ' ') {
			sb.appendCodePoint(b);
			b = readByte();
		}

		while (b != '\n') {
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 64208
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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

int main() {
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int ans = 0;
  ans += min(a, k);
  k -= a;
  k -= b;
  if(k>0) ans -= k;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3636
<?php
$n = fscanf(STDIN,"%d",$n);
$a = explode(" ",trim(fgets(STDIN)));
$a_count = array_count_values($a);
//print_r($a_count);
foreach ($a_count as $nunber => $values) {
    if ($values !=1) {
        exit("NO"."\n");
    }
}
echo "YES"."\n";
?>


Measured memory_bytes: 67044
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1LL << 60;
const long double pi = 3.14159265358979323846;

// ****************************************CODE***************************************//

ll n, h[100100];
ll dp[100100];

int main() {
    cin >> n;
    for(int i = 0; i < n; i++) cin >> h[i];

    for(int i = 0; i < 100100; i++) dp[i] = inf;

    dp[0] = 0;
    for(int i = 1; i < n; i++){
        dp[i] = min(dp[i], dp[i-1]+ abs(h[i] - h[i-1]));
        if(i > 1) dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }

    cout << dp[n-1] << endl;
}

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

int main(){

    int N,M;
    cin >> N >> M;
    vector<int> A(M),B(M);
    for(int i=0;i<M;i++){
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }

    scc_graph graph(N);
    for(int i=0;i<M;i++){
        graph.add_edge(A[i],B[i]);
        graph.add_edge(B[i],A[i]);
    }

    auto scc = graph.scc();
    cout << scc.size() - 1;
    return 0;
}

Measured memory_bytes: 11948
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

h,n = get_nums_l()
lines = sys.stdin.readlines()
magics = [ tuple(map(int, l.split(" "))) for l in lines ]

# 残りHPがiの時に倒すのに必要な最小魔力
dp = [99999999999999] * (h + 10)

dp[0] = 0
for i in range(len(dp)):
    for m in magics:
        next_ = min(i + m[0], h)
        tmp = dp[i] + m[1]
        if dp[next_] > tmp:
            dp[next_] = tmp

print(dp[h])

Measured memory_bytes: 41324
N=int(input())
H=input().split()
H=[int(i) for i in H]
cnt=1
key=False

for i in range(N):
    for j in range(i):
        if H[i]<H[j]:
            key=False
            break
        else:
            key=True
    if key==True:
        cnt+=1
    key=False
    
print(cnt)

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

ll a,b,c,ans=0;

int main() {
	ios::sync_with_stdio(0);
	cin >> a >> b >> c;
	ans=min(a,c);
	c-=ans;
	ans+=b+min(b+1,c);
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.rbegin(),a.rend())
#define lb(a,b) lower_bound(a.begin(),a.end(),b)
#define ub(a,b) upper_bound(a.begin(),a.end(),b)
#define MOD ((int)(1e9+9))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double
#define sqrt sqrtl
#define cbrt cbrtl
typedef vector<int> vi;
typedef vector<float> vf;
typedef pair<float,int> fi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<fi> vfi;
typedef vector<vi> vvi;
typedef vector<vf> vvf;
typedef vector<vii> vvii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef priority_queue<fi> pqfi;
typedef priority_queue <int, vector<int>, greater<int> > rpqi; 
typedef priority_queue <ii, vector<ii>, greater<ii> > rpqii; 
typedef priority_queue <fi, vector<fi>, greater<fi> > rpqfi; 

	
	
int32_t main()
{
	IOS
	int n;cin>>n;
	vi a(n),s;
	map<int,int>M;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];M[a[i]]++;
	}
	for(int i=1;i<n;i++)
	{
		if( M.find( a[0] ^ a[i] )!=M.end() )
		{
			s.pb(a[0]);
			s.pb(a[i]);
			M[a[0]]--;
			M[a[i]]--;
			break;
		}
	}
	if(s.size()==0)
	{
		cout<<"No"<<endl;return 0;
	}
	while( s.size() < n )
	{
		int num1=s[ s.size() -2 ];
		int num2=s[ s.size() -1 ];
		if( M.find( num1 ^ num2 )!=M.end() && M[ num1 ^ num2 ] )
		{
			s.pb( num1 ^ num2 );
			M[ num1 ^ num2 ]--;
		}
		else break;
	}
	if( s.size() == n && s[0] ^ s[1] == s.back())
	{
		cout<<"Yes"<<endl;return 0;
	}
	cout<<"No"<<endl;
			
	
	
}

			


Measured memory_bytes: 5760
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const N = parseInt(args[0][0], 10)
	let cnt = 0

	for (let i = 1; i <= N; i++) {
		if (String(i).length % 2 == 1) cnt++
	}

	console.log(cnt)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 21064
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

string s, t;
int sn, tn;
bool is_match(int k) {
  rep(i, 0, tn) {
    if (t[i] != s[i + k] && s[i + k] != '?') {
      return false;
    }
  }
  return true;
}

string construct(int k) {
  string ret = s;
  rep(i, 0, tn) ret[k + i] = t[i];
  rep(i, 0, sn) if (ret[i] == '?') ret[i] = 'a';
  return ret;
}

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

  cin >> s >> t;
  sn = s.size(), tn = t.size();

  string ans = string(1, 'z' + 1);
  bool is_ok = false;
  rep(i, 0, sn - tn + 1) {
    if (is_match(i)) {
      chmin(ans, construct(i));
      is_ok = true;
    }
  }

  if (is_ok)
    cout << ans << endl;
  else
    cout << "UNRESTORABLE" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int n, m, q;

struct Adj {
  int key;
  struct Adj *adj;
};

struct Node {
  int k;
  int group;
  struct Adj *adj;
};

struct Node node[100000];

void setup() {
  for (int i = 0; i < n; i++) {
    node[i].k = 0;
    node[i].group = -1;
  }
}

void neighbor_list(int from, int to) {
  int count;
  struct Adj *adj, *dummy;
  adj = (struct Adj*)malloc(sizeof(struct Adj));
  adj->key = to;
  if (node[from].k == 0) {
    node[from].adj = adj;
    node[from].k++;
  }
  else {
    dummy = node[from].adj;
    count = node[from].k - 1;
    while (count--) {
      dummy = dummy->adj;
    }
    dummy->adj = adj;
    node[from].k++;
  }
  adj = (struct Adj*)malloc(sizeof(struct Adj));
  adj->key = from;
  if (node[to].k == 0) {
    node[to].adj = adj;
    node[to].k++;
  }
  else {
    dummy = node[to].adj;
    count = node[to].k - 1;
    while (count--) {
      dummy = dummy->adj;
    }
    dummy->adj = adj;
    node[to].k++;
  }
}

void list_output() {
  struct Adj *dummy;
  for (int i = 0; i < n; i++) {
    printf("node:%d", i);
    for (int j = 0; j < node[i].k; j++) {
      if (j == 0) {
	dummy = node[i].adj;
      }
      else {
	dummy = dummy->adj;
      }
      printf(" %d", dummy->key);
    }
    printf("\n");
  }
}

void solve(int num, int g) {
  struct Adj *dummy;
  for (int i = 0; i < node[num].k; i++) {
    if (i == 0)
      dummy = node[num].adj;
    else
      dummy = dummy->adj;
    if (node[dummy->key].group == -1) {
      node[dummy->key].group = g;
      solve(dummy->key, g);
    }
  }
}

int main(void) {
  int from, to;
  int count;
  struct Adj *adj, *dummy;

  scanf("%d%d", &n, &m);
  setup();
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &from, &to);
    neighbor_list(from, to);
  }
  //list_output();
  //printf("\n");
  for (int i = 0; i < n; i++) {
    if (node[i].group == -1) {
      node[i].group = i;
      solve(i, i);
    }
    //printf("node:%d group:%d\n", i, node[i].group);
  }

  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d%d", &from, &to);
    if (node[from].group == node[to].group)
      printf("yes\n");
    else
      printf("no\n");
  }

  return 0;
}



Measured memory_bytes: 14148
#include <cstdlib>
#include <iostream>
#include <set>
#include <string>
using namespace std;

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

	int n;
	cin >> n;

	set<string> u;
	for(int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		u.insert(s);
	}

	int m;
	cin >> m;

	bool lock = true;
	for(int i = 0; i < m; ++i) {
		string t;
		cin >> t;

		if(u.find(t) != u.end()) {
			if(lock)
				cout << "Opened by " << t << endl;
			else
				cout << "Closed by " << t << endl;

			lock = !lock;
		}
		else {
			cout << "Unknown " << t << endl;
		}
	}
	
	return EXIT_SUCCESS;
}

Measured memory_bytes: 1240
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
int a[3][3];
void check(int c)
{
}
void solve()
{
	int n, m;
	int s[10], c[10];
	int num[5] = {-1,-1,-1,-1,-1};
	cin >> n >> m;
	for (int i = 1; i <=m; i++)
	{
		cin >> s[i] >> c[i];
	}
	for (int i = 1; i <= m; i++)
	{
		if (s[i] == 1 && c[i] == 0 && n != 1)
		{
			cout << "-1" << endl;
			return;
		}
		if(num[s[i]]==-1)
		num[s[i]] = c[i];
		else
		{
			if (num[s[i]] != c[i])
			{
				cout << "-1" << endl;
				return;
			}
		}
	}
	if (num[1] == -1)
	{
		num[1] = 1;
	}
	if (n == 1 && m == 0)
	{
		cout << 0 << endl;
		return;
	}
	for (int i = 1; i <= n; i++)
	{
		if (i != 1 && num[i] == -1)
			num[i] = 0;
		cout << num[i];
	}
	cout << endl;
	return;
}
int main()
{

	solve();
		
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (H, W) = Slice2<long>();
            var N = 10;
            var csts = Enumerable.Repeat(0, N).Select(_ => new long[N]).ToArray();
            for (var i = 0; i < N; ++i)
                csts[i] = Sarray();
            for (var k = 0; k < N; ++k)
                for (var i = 0; i < N; ++i)
                    for (var j = 0; j < N; ++j)
                        if (csts[i][k] + csts[k][j] < csts[i][j])
                            csts[i][j] = csts[i][k] + csts[k][j];
            var sum = 0L;
            for(var i=0;i<H;++i)
            {
                var Ai = Sarray();
                foreach (var a in Ai)
                    if (a != -1)
                        sum += csts[a][1];
            }
            WriteLine(sum);
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 30520
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  string s, t;
  cin >> s >> t;
  for (ll i = 0; i < s.size(); ++i) {
    if (s[i] != t[i]) {
      cout << "No" << "\n";
      return 0;
    }
  }
  cout << "Yes" << "\n";
}


Measured memory_bytes: 3592
#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>
using namespace std;

#define ll long long
#define mst(a) memset(a, 0, sizeof a)

const int mod = 1e9+7;
const int maxn = 1e5+50;
const int inf = 1e9;

int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[] = {1, 0, -1, 0, -1, 1, 1, -1};
int n, m, g;
int x[maxn], y[maxn], t[maxn];

int main()
{
    //freopen("out", "w", stdout);
    scanf("%d\n", &n);
    t[0] = x[0] = y[0] = 0;
    for (int i = 1; i <= n; ++i)
    {
        scanf("%d %d %d", &t[i], &x[i], &y[i]);
    }
    bool ok = true;
    for (int i = 1; i <= n; ++i)
    {
        int dis = abs(x[i]-x[i-1]) + abs(y[i]-y[i-1]);
        int dt = t[i] - t[i-1];
        if (dt < dis || dt > dis && dt % 2 != dis % 2) ok = false;
    }
    if (ok) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define endl '\n'
const int maxn=2*1e5+5;

int main()
{
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
    cin>>arr[i];
sort(arr,arr+n);
int sum=0;
for(int i=n-1;i>=0;i--)
{
    if(n%2)
    {
        if(i%2==0)
            sum+=arr[i];
        else
            sum-=arr[i];

    }
    else
    {
        if(i%2==1)
            sum+=arr[i];
        else
            sum-=arr[i];

    }
}
cout<<sum<<endl;


        return 0;
}


Measured memory_bytes: 256
#include <utility>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int P[100001],value[100001];
void Init(int n)
{
    int i;
    for(i=0;i<=n;i++)
        {P[i] = i;value[i]=0;}
}
int find(int x)
{
    if(P[x] == x)
        return x;
    else    {
                int temp = P[x];
                P[x] = find(P[x]);
                value[x] += value[temp];
                return P[x];
            }
}

int main()
{
    int N,M;
    cin >> N >> M;
    //Init(N);
    while(N && M)
    {
        Init(N);
        while(M)
        {
            M--;
            char st;
            int a,b,w;
            cin >> st;
            if(st == '!')
            {
                cin >> a >> b >> w;
                int u = find(a);
                int v = find(b);
                P[v] = u;
                value[v] = value[a]-value[b]+w;
            }
            else    if(st == '?')
                    {
                        cin >> a >> b;
                        if(find(a) != find(b))
                            cout << "UNKNOWN" << endl;
                        else    cout << value[b]-value[a] << endl; 
                    }
        }
        cin >> N >> M;
    }
    return 0;
}


Measured memory_bytes: 5864
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    string s, ans;
    cin >> s;
    if(s == "Sunny"){
        ans = "Cloudy";
    } else if(s == "Cloudy"){
        ans = "Rainy";
    } else {
        ans = "Sunny";
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
int MOD=1000000007;
signed main(){
    int n;cin>>n;
    vector<double> p(n+1,0);
    rep1(i,n)cin>>p[i];
    vector<vector<double>> dp(n+5,vector<double>(n+5,0.0));
    dp[0][0]=1.0;
    rep(i,n+1){
        rep(j,n){
            dp[i][j+1]+=dp[i][j]*(1.0-p[j+1]);
            dp[i+1][j+1]+=dp[i][j]*p[j+1];
        }
    }
    double res=0.0;
    rep(i,n+1){
        if(i>(n-i)){
            res+=dp[i][n];
        }
    }
    printf("%.12lf\n",res);
    return 0;
}

Measured memory_bytes: 70912
gets
p = gets.split("\s").map(&:to_i)

former = p.shift
present = p.shift
future = nil
count = 0

while !p.empty?
  future = p.shift
  
  trio = [former, present, future]
  count += 1 if trio.min != present && trio.max != present

  former = present
  present = future
end

p count

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

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

  bool yes = true;

  for(int i=0;i<S.size();i++) {
    if(i%2 == 0) {
      if (S[i] == 'L') {
        yes = false;
        break;
      }
    } else {
      if(S[i] == 'R') {
        yes = false;
        break;
      }
    }
  }

  if(yes) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    long long int a[n],b[n],c[n];
    for(int i=0;i<n;i++)
    cin>>a[i]>>b[i]>>c[i];
    //function(a,b,c,0,0);
    long long int ans[n][3];
    ans[0][0]=a[0],ans[0][1]=b[0],ans[0][2]=c[0];
    for(int i=1;i<n;i++)
    {
        ans[i][0]=max(ans[i-1][1],ans[i-1][2])+a[i];
        ans[i][1]=max(ans[i-1][0],ans[i-1][2])+b[i];
        ans[i][2]=max(ans[i-1][0],ans[i-1][1])+c[i];
    }
    long long int maximum=0;
    maximum=max(ans[n-1][0],ans[n-1][1]);
    maximum=max(maximum,ans[n-1][2]);
    cout<<maximum<<endl;
}

Measured memory_bytes: 4992
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll n, m;
vector<int> a;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    ll ans=0;
    for (int i = 1; i <= n; i++)
    {
        if(i%3&&i%5){
            ans+=i;
        }
    }
    cout << ans << "\n";
}


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

#define FIND(c, e) ((c).find(e) != (c).end())
#define NFIND(c, e) ((c).find(e) == (c).end())
#define ALL(t) (t).begin(), (t).end()
#define ALLR(t) (t).rbegin(), (t).rend()
#define MP make_pair

const int N = int( 5e5 ) + 1;
const int M = int( 1e6 ) + 1;
const int MOD = int( 1e9 ) + 7;
const double PI = acos(-1.0);
const double eps = 1e-6;
template<class T> T gcd(T a,T b){while(b){T r=a%b;a=b;b=r;}return a;}
template<class T> T lcm(T a,T b){return (a*b)/gcd(a,b);}
template<class T> T max(T a,T b,T c){return max(max(a,b),c);}
template<class T> T min(T a,T b,T c){return min(min(a,b),c);}

int a[N];

int getSum(int BITree[], int index)
{
    int sum = 0; // Initialize result

    // Traverse ancestors of BITree[index]
    while (index > 0)
    {
        // Add current element of BITree to sum
        sum += BITree[index];

        // Move index to parent node in getSum View
        index -= index & (-index);
    }
    return sum;
}

// Updates a node in Binary Index Tree (BITree) at given index
// in BITree.  The given value 'val' is added to BITree[i] and
// all of its ancestors in tree.
void updateBIT(int BITree[], int n, int index, int val)
{
    // Traverse all ancestors and add 'val'
    while (index <= n)
    {
       // Add 'val' to current node of BI Tree
       BITree[index] += val;

       // Update index to that of parent in update View
       index += index & (-index);
    }
}

// Returns inversion count arr[0..n-1]
int getInvCount(int arr[], int n)
{
    int invcount = 0; // Initialize result

    // Find maximum element in arr[]
    int maxElement = 0;
    for (int i=0; i<n; i++)
        if (maxElement < arr[i])
            maxElement = arr[i];

    // Create a BIT with size equal to maxElement+1 (Extra
    // one is used so that elements can be directly be
    // used as index)
    int BIT[maxElement+1];
    for (int i=1; i<=maxElement; i++)
        BIT[i] = 0;

    // Traverse all elements from right.
    for (int i=n-1; i>=0; i--)
    {
        // Get count of elements smaller than arr[i]
        invcount += getSum(BIT, arr[i]-1);

        // Add current element to BIT
        updateBIT(BIT, maxElement, arr[i], 1);
    }

    return invcount;
}
void __answer()
{
    string s;
    cin >> s;
    cout << s.front() << s.size() - 2 << s.back() << endl;
}
int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    #ifdef LOCAL
        freopen("TEST.txt", "r", stdin);
    #endif
    __answer();
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
using namespace std;

const int MaxNoeuds=10*10*10*10*10;
const int MaxArretes=10*10*10*10*10;
const int MoinsInf=-100000*10000;
vector<pair<int,bool>> ListeAdj[MaxNoeuds+5];
int DP[MaxNoeuds+5];
int NbNoeuds,NbArretes;

void LitGraphe()
{
   scanf("%d%d", &NbNoeuds, &NbArretes);
   for(int iArrete=1;iArrete<=NbArretes;iArrete++)
   {
      int Noeud1,Noeud2;
      scanf("%d%d",&Noeud1,&Noeud2);
      ListeAdj[Noeud1].push_back({Noeud2,false});
   }
   for(int iNoeud=1;iNoeud<=NbNoeuds;iNoeud++)
   {
      if(ListeAdj[iNoeud].size()==0)
         DP[iNoeud]=0;
      else
         DP[iNoeud]=MoinsInf;
   }
}
bool ArreteToutes(int iNoeud)
{
   for(int iFils=0;iFils<(int)ListeAdj[iNoeud].size();iFils++)
       if(!ListeAdj[iNoeud][iFils].second)
          return false;
   return true;
}
           
int plusLong(int iNoeud)
{

   if(DP[iNoeud]!=MoinsInf||ArreteToutes(iNoeud))
      return DP[iNoeud];
      
   else
   {
      for(int iFils=0;iFils<(int)ListeAdj[iNoeud].size();iFils++)
      {       
        int Fils=ListeAdj[iNoeud][iFils].first;
        if(!ListeAdj[iNoeud][iFils].second)
        {
            
            DP[iNoeud]=max(DP[iNoeud],plusLong(Fils)+1); 
            ListeAdj[iNoeud][iFils].second=true;                 
        }                 
      }
      return DP[iNoeud]; 
   }
}

int main()
{
   LitGraphe();
   int CheminPL=MoinsInf;
   
     for(int iNoeud=1;iNoeud<=NbNoeuds;iNoeud++)
        plusLong(iNoeud);
      
   
   for(int iNoeud=1;iNoeud<=NbNoeuds;iNoeud++)
   {
         CheminPL=max(CheminPL,DP[iNoeud]);
         
   }
   printf("%d",CheminPL);
}



Measured memory_bytes: 8192
#include<iostream>
using namespace std;
int main(){
  long long int a,b,c,k;
  cin>>a>>b>>c>>k;
  if(a>=k){
    cout<<k<<endl;
  }
  else if(a+b>=k){
    cout<<a<<endl;
  }
  else if(a+b+c>=k){
    cout<<a-(k-(a+b))<<endl;
  }
  return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  ll ans=1;
  sort(a.begin(),a.end());
  rep(i,n){
    if(a[i]==0){
      cout << 0 << endl;
      return 0;
    }
    if(ans>MX || MX/ans<a[i]){
      cout << -1 << endl;
      return 0;
    }
    ans*=a[i];
  }
  cout << ans << endl;
}


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

int main() {
  int h, n, a = 0;
  cin >> h >> n;
  rep(i, n) {
    int x;
    cin >> x;
    a += x;
  }
  if (a < h) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 3636
main = do
  [a, b, c, d] <- map (read :: String -> Integer) . words <$> getLine
  let a1 = a - 1
  print $ b - a1 - (b `div` c - a1 `div` c) - (b `div` d - a1 `div` d)
    + (b `div` (lcm c d) - a1 `div` (lcm c d))

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

int main(){
int H, W;  cin >> H >> W;
vector<vector<char>> C(H, vector<char>(W));
for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
        cin >> C[i][j];
    }
}
for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
        cout << C[i][j];
    }
    cout << endl;
    for (int k = 0; k < W; k++) {
        cout << C[i][k];
    }
    cout << endl;
}
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	vector<int>score(n);
	vector<int>checked(9, 0);
	for(int i = 0; i < n; i++) cin >> score[i];

	for(int i = 0; i < n; i++){
		for(int j = 0; j < 9; j++){
			if(j != 8 && score[i] >= 400*j && score[i] < 400*(j+1))checked[j] += 1;
			if(j == 8 && score[i] >= 400*j )checked[j] += 1;
		}
	}
	int ans_min = 0, ans_max = 0;
	for(int i = 0; i < 9; i++){
		if(i != 8 && checked[i] != 0)ans_min += 1;
		if(i == 8)ans_max = ans_min + checked[i];
	}
	if(ans_min == 0)ans_min = 1;
	cout << ans_min << " " << ans_max << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n, a, b, c;
    scanf("%d", &n);
    a=n%10;
    n/=10;
    b=n%10;
    n/=10;
    c=n%10;
    if (a==7 || b==7 || c==7) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 1620
n,ma,mb=gets.split.map &:to_i
a=[]
b=[]
c=[]
min={[0,0]=>0}
n.times do |i|
    a[i],b[i],c[i] = gets.split.map &:to_i
end
n.times do |i|
    temp={}
    min.each do |k,price|
        na = k[0]+a[i]
        nb = k[1]+b[i]
        nprice = price + c[i]
        #if min[[na,nb]]
        #    min[[na,nb]] = nprice if nprice < min[k]
        #else
        #    
        #end
        temp[[na,nb]] = nprice
    end
    min.merge!(temp){|key,v0,v1|
        if v0 < v1
            v0
        else
            v1
        end
    }
end

min.delete([0,0])

ans = -1
min.each do |k,price|
    if k[0].to_f*mb == k[1]*ma
        if ans == -1
            ans = price
        else
            ans = price if price < ans
        end
    end
end
puts ans

Measured memory_bytes: 12204
S = chomp(readline())
L = ""
for i in 1:length(S)
    if string(S[i]) == "B"
        if L == ""
            L = L
        else
            L = L[1:end-1]
        end
    else
        L = string(L) * string(S[i])
    end
end
println(L)

Measured memory_bytes: 111608
#include<stdio.h>

int main(void){
	int a[10]={},sw,sk,i,j,c;
	sw=0;
	sk=0;
	for(i=0;i<10;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<3;i++){
		for(j=i+1;j<10;j++){
			if(a[i]<a[j]){c=a[i];a[i]=a[j];a[j]=c;}
		}
	}
	sw=a[0]+a[1]+a[2];
	for(i=0;i<10;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<3;i++){
		for(j=i+1;j<10;j++){
			if(a[i]<a[j]){c=a[i];a[i]=a[j];a[j]=c;}
		}
	}
	sk=a[0]+a[1]+a[2];
	printf("%d %d\n",sw,sk);
    return 0;
}

Measured memory_bytes: 1796
#include<iostream>

using namespace std;

char field[12][13];
int came[12][12];
int islands;

void checker(int X, int Y)
{
	if (field[Y][X] == *"1" && came[Y][X] == 0)
	{
		came[Y][X] = 1;
		if (X != 0)
		{
			checker(X - 1, Y);
		}
		if (Y != 0)
		{
			checker(X, Y - 1);
		}
		if (X != 11)
		{
			checker(X + 1, Y);
		}
		if (Y != 11)
		{
			checker(X, Y + 1);
		}
	}
}

int main()
{
	while (cin >> field[0])
	{
		for (int a = 1; a<12; a++)
		{
			cin >> field[a];
		}

		for (int y = 0; y<12; y++)
		{
			for (int x = 0; x<12; x++)
			{
				if (field[y][x] == *"1" && came[y][x] == 0)
				{
					islands++;
					checker(x, y);
				}
			}
		}

		cout << islands << endl;

		for (int y = 0; y<12; y++)
		{
			for (int x = 0; x<12; x++)
			{
				came[y][x] = 0;
			}
		}

		islands = 0;
	}

	return 0;
}

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

bool check(string T, string sub) {
    int it = 0;
    for (int i = 0; i < T.size(); ++i) {
        if (T[i] == sub[it]) ++it;
        if (it == sub.size()) break;
    }
    return (it == sub.size());
}

int main() {
    string S, T; cin >> S >> T;
    bool ok = false;
    for (int start = 0; start < 2; ++start) {
        string sub = "";
        for (int cur = start; cur < S.size(); cur += 2) sub += S[cur];
        if (check(T, sub)) ok = true;
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3192
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int a = s.nextInt();
    String op = s.next();
    int b = s.nextInt();
    while (!op.equals("?")) {
      switch(op) {
        case "+":
          System.out.println(a + b);
          break;
        case "-":
          System.out.println(a - b);
          break;
        case "*":
          System.out.println(a * b);
          break;
        case "/":
          System.out.println(a / b);
          break;
        default:
          break;
      }
      a = s.nextInt();
      op = s.next();
      b = s.nextInt();
    }
    s.close();
  }
}



Measured memory_bytes: 25940
n = int(input())
x = []
for i in range(n):
    X,L = map(int, input().split())
    x.append([X-L,X+L])
x.sort(key=lambda x:x[0])
ans = n
tmp = x[0][1]
for i in range(1,n):
    if tmp>x[i][0]:
        ans -=1
        tmp = min(tmp,x[i][1])
    else:
        tmp = x[i][1]
print(ans)


Measured memory_bytes: 21376
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
using static Prog;
using NX = System.Int64;

public class Solver
{
    public void Solve()
    {
        int[] x = LineInt();
        Console.WriteLine(x[2] + " " + x[0] + " " + x[1]);
    }
}

public class Prog
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    public struct Pair { public int x, y; public Pair(int a, int b) { x = a; y = b; } }
    static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        new Solver().Solve();
        Console.Out.Flush();
        return;
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}


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

int main(){
  int N;
  cin >>N;
  vector<long long> L(N+1);
  L[0]=2;
  L[1]=1;

  if (N==1){
    cout <<1<<endl;
    return 0;
  }
  for (int i=2;i<=N;++i){
    L[i]=L[i-1]+L[i-2];
  }
  cout <<L[N]<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)

int main(){
    int N,M,C,res=0;
    cin >> N >> M >>C;
    vector<int> B(M);
    vector<vector<int> > A;
    A.resize(N);
    rep(i,0,M) cin >> B[i];
    rep(i,0,N){
        int tmp=0;
        A[i].resize(M);
        rep(j,0,M){
            cin >> A[i][j];
            tmp += A[i][j]*B[j];
        }
        tmp += C;
        if(tmp>0) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long k = sc.nextLong();

        long tmp = a;
        a -= k;
        if (a < 0) {
            a = 0;
        }
        k -= tmp;

        if (k >= 1) {
            b -= k;
            if (b < 0) {
                b = 0;
            }
        }
        System.out.println(String.format("%s %s", a, b));
        sc.close();
    }
}


Measured memory_bytes: 35760
from bisect import *

alpha = list(chr(c) for c in range(ord("a"), ord("z") + 1))

S = list(input())

not_used = list(set(alpha) - set(S))
not_used.sort()

if not not_used:
    can_use = []
    flag = False
    for i in range(len(S) - 1, -1, -1):
        # S[i]以上の値
        idx = bisect_left(can_use, S[i])
        if idx == len(can_use): # ない
            can_use.append(S[i])
        else: # ある
            S[i] = can_use[idx]
            idx = i
            flag = True
            break
    if flag:
        print(*S[:idx + 1], sep="")
    else:
        print(-1)
else:
    S.append(not_used[0])
    print(*S, sep="")

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

using namespace std;

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'
#define sz(a) int((a).size())

int ht[1000];
int a, b;

void pre() {
	ht[1] = 1;
	for (int i = 2; i <1000; i++) {
		ht[i] = ht[i-1] + i;
	}
}

signed main()
{
	IOS;
	pre();
	cin >> a >> b;
	for (int i = 1; i < 1000; i++) {
		if (ht[i] >= a) {
			if (ht[i] - a == ht[i+1] - b) {
				cout << ht[i] - a << endl;
				return 0;
			}
		}
	}
	return 0;
}


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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<double, double> pd;
typedef pair<int, int> pi; typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;  typedef pair<ll, pi> plp;
typedef pair<int, pi> pip; typedef tuple<int, int, int> ti;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

int N, M;
map<int, int> Mp;
int main() {
	cin >> N;
	for(int i=0; i<N; i++) {
		int x; scanf("%d", &x); Mp[x]++;
	}
	cin >> M;
	bool isCan = true;
	for(int i=0; i<M; i++) {
		int x; scanf("%d", &x); Mp[x]--;
		if(Mp[x] < 0) isCan = false;
	}
	puts(isCan?"YES":"NO");
	return 0;
}


Measured memory_bytes: 9600