akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

using namespace std;

int main() {
  string S;

  cin >> S;

  int a = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == '+') {
      a += 1;
    } else {
      a -= 1;
    }
  }

  cout << a << endl;

  return 0;
}


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

int main()
{
  string S;
  cin >> S;
  int ans = 0, cnt = 0;
  for (int i = 0; i < S.size(); ++i)
  {
    if (S.at(i) == 'A' | S.at(i) == 'C' | S.at(i) == 'G' | S.at(i) == 'T')
    {
      cnt += 1;
    }
    else
    {
      ans = max(ans, cnt);
      cnt = 0;
    }
  }
  ans = max(ans, cnt);
  cout << ans << endl;
}


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

#define MOD 1000000007

long long mod_pow(long long x, long long n)
{
    long long ret = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            ret *= x;
            ret %= MOD;
        }
        x *= x;
        x %= MOD;
        n >>= 1;
    }
    return ret;
}

long long f(string &l, vector<long long> &t)
{
    if (l.size() == 1)
    {
        if (l[0] == '0')
        {
            return 1;
        }
        else
        {
            return 3;
        }
    }

    if (l[0] == '0')
    {
        l = l.substr(1, l.size() - 1);
        return f(l, t);
    }
    else
    {
        l = l.substr(1, l.size() - 1);
        long long ret = t[l.size()];
        ret += 2 * f(l, t);
        ret %= MOD;
        return ret;
    }
}

int main()
{
    string L;
    cin >> L;
    vector<long long> t(100005, 1);
    for (int i = 1; i < 100005; i++)
    {
        t[i] = t[i - 1] * 3;
        t[i] %= MOD;
    }
    cout << f(L, t) << endl;
}


Measured memory_bytes: 7452
#include<cstdio>

int main(){
	int N;
	scanf("%d", &N);
	int t[N], total_t = 0;
	for (int i = 0; i < N; ++i){
		scanf("%d", t + i);
		total_t += t[i];
	}
	int v_max[total_t*2 + 1];
	for (int i = 0; i <= total_t; ++i) v_max[i] = v_max[total_t*2 - i] = i;
	int time_passed = 0;
	for (int i = 0; i < N; ++i){
		int v;
		scanf("%d", &v);
		for (int j = time_passed*2; j < (time_passed + t[i])*2; ++j) if(v_max[j] > v*2) v_max[j] = v*2;
		for (int j = 1; j < time_passed*2; ++j) if(v_max[j] > v*2 + time_passed*2 - j) v_max[j] = v*2 + time_passed*2 - j;
		for (int j = (time_passed + t[i])*2; j < total_t*2; ++j) if(v_max[j] > v*2 + j - (time_passed + t[i])*2) v_max[j] = v*2 + j - (time_passed + t[i])*2;
		time_passed += t[i];
	}
	int answer = 0;
	for (int i = 0; i < total_t*2; ++i) answer += v_max[i] + v_max[i + 1];
	printf("%lf\n", ((double)answer)/8.0);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define pb push_back
#define fst first
#define snd second
#define INF 0x7fffffff
#define INFLL 0x7FFFFFFFFFFFFFFF
#define lenA(ar) sizeof(ar)/sizeof(*ar)
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define foreI(i,x,y) for(ll i=x-1;i>=y;i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 
typedef long long ll;
typedef unsigned long long ull;
 
using namespace std;
ll n;
const int MAXN= 101;
const int m = 100000;
ll dp[MAXN][m+1];
ll val[MAXN];
ll we[MAXN];
ll solve(int pos,ll want){
    if(pos==n){
        if(want==0)return 0;
        return 1e16;
    }
 
    if(want<0)return 1e16;
    ll &r = dp[pos][want];
    if(r!=-1)return r;
 
    ll a = 1e16; ll b = 1e16;
    a = solve(pos+1,want-val[pos])+we[pos];
    b = solve(pos+1,want);
    r = min(a,b);
    return r;
}
int main() {FIN;
    
    cin>>n;
    ll weight;cin>>weight;
    fill(dp,-1);
    fore(i,0,n){
       cin>>we[i]; cin>>val[i];
    }
     ll ans = 0;
    fore(i,0,m+1){
         if(solve(0,i)<=weight)
            ans=i;
 
 
    }
 
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 82528
// hello {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }

// }}}
int n;
bool visited[9];
double ans;
struct node {
    int x, y;
    node(int a, int b) : x(a), y(b) {}
};
vector<node> v;
void input() {
    RI(n);
    REP(i, n) {
        int a, b;
        RI(a, b);
        v.PB(node(a, b));
    }
}

double distance(node a, node b) {
    return sqrt((double)(a.x - b.x)*(a.x - b.x) + (double)(a.y - b.y)*(a.y - b.y));
}

void permute(int e, double x, int k) {
    if(k == n)
        ans += x;
    REP(i, n) {
        if(visited[i]) continue;
        double y = distance(v[i], v[e]);
        visited[i] = true;
        permute(i, x+y, k+1);
        visited[i] = false;
    }
}

void solve() {
    ans = 0;
    int m = 1;
    REP1(i, 1, n) m*=i;
    REP(i, n)
    {
        visited[i] = true;
        permute(i, 0, 1);
        visited[i] = false;
    }
    printf("%.9lf\n", ans / m);
}

int main( int argc, char *argv[] ) {
    input();
    solve();
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  ll n,m;
  cin >> n >> m;
  vector<pair<ll,ll>> v(n);  
  
  REP(i,n){
    int a,b;
    cin >> a >> b;
    v[i].first = a;
    v[i].second = b;
  }
  sort(v.begin(),v.end());
  ll ans = 0;
  ll i = 0;
  while(m > 0){
    if(v[i].second <= m){ 
      ans += v[i].first * v[i].second;
      m -= v[i].second;
    }
    else{
      ans += v[i].first * m;
      m = 0;
    }
    i++;
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 4896
#include<iostream>
#include<cmath>
#include<algorithm>

using namespace std;

int main(){

    long long int n;

    cin >> n;

    long long int a[3*n];

    for(long long int i=0;i<3*n;i++)cin >> a[i];

    long long int s=0;

    sort(a,a+3*n);

    for(long long int i=0;i<n;i++){
        s += a[n+2*i];
    }

    cout << s << endl;

    
}

Measured memory_bytes: 2560
use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).ok().unwrap();
    let ans = match input.trim() {
        "25" => "Christmas",
        "24" => "Christmas Eve",
        "23" => "Christmas Eve Eve",
        "22" => "Christmas Eve Eve Eve",
        _ => ""
    };
    println!("{}", ans);
}



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

using namespace std;

int main(){
	
	string s;
	
	cin >> s;
	
	if (s == "SUN"){
		cout << "7";
	} else if (s == "MON"){
		cout << "6";
	} else if (s == "TUE"){
		cout << "5";
	} else if (s == "WED"){
		cout << "4";
	} else if (s == "THU"){
		cout << "3";
	} else if (s == "FRI"){
		cout << "2";
	} else if (s == "SAT"){
		cout << "1";
	}
	
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
vector<pint> node[SIZE];
int done[SIZE];
bool ans=0;
void DFS(int NOW,int DONE){
	for(int i=0;i<node[NOW].size();i++){
		int next=node[NOW][i].first;
		if(done[next]==INF){
			done[next]=DONE+node[NOW][i].second;
			//cout<<NOW<<"!"<<next<<" "<<done[next]<<endl;
			DFS(next,done[next]);
		}
		else{
			//cout<<"?"<<done[next]<<" "<<DONE+node[NOW][i].second<<endl;
			if(done[next]!=DONE+node[NOW][i].second)
				ans=1;
		}
	}
}
int main(){
	//tes[人]=場所
	//ket[場所]=人
	map<int,pint> tes,ket;
	int N,M;
	cin>>N>>M;
	if(M==0){
		cout<<"Yes"<<endl;
		return 0;
	}
	for(int i=0;i<M;i++){
		int l,r,d;
		cin>>l>>r>>d;
		l--,r--;
		node[l].pb(mp(r,d));
		node[r].pb(mp(l,-d));
	}
	for(int i=0;i<N;i++){
		done[i]=INF;
	}
	for(int i=0;i<N;i++){
		if(done[i]==INF){
			done[i]=0;
			DFS(i,0);
		}
	}
	cout<<(ans?"No":"Yes")<<endl;
	return 0;
}

Measured memory_bytes: 13184
#include <cmath>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;

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

  string t;
  cin >> t;
  replace(t.begin(), t.end(), '?', 'D');
  cout << t << endl;
}

Measured memory_bytes: 3736
n = int(input())
ab = [list(map(int, input().split())) for i in range(n)]

ans = 0

for i in range(n):
    a = ab[n-i-1][0]+ans
    b = ab[n-i-1][1]
    if a%b!=0:
        ans += b-a%b

print(ans)

Measured memory_bytes: 61656
#include<bits/stdc++.h>
#define int long long 
using namespace std;
int32_t main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t; cin>>s>>t;
    for(int i=0;i<26;++i){
    	string tp=s;
    	tp+='a'+i;
    	if(tp==t){
    		cout<<"Yes\n";
    		return 0;
    	}
    }
    cout<<"No\n";
    return 0;
}



Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

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

	int a = 0;
	int b = 0;
	int c = 0;
	for (auto i = 0; i < 3; ++i)
	{
		if (S[i] == 'a')
		{
			++a;
		}
		else if (S[i] == 'b')
		{
			++b;
		}
		else if (S[i] == 'c')
		{
			++c;
		}
	}

	if (a * b * c == 1)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}


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

using namespace std;

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

int main(){
    int x,t;cin>>x>>t;
    cout<<max(0,x-t)<<endl;
    return 0;
}

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

const int inf = 100000;
const int NIL = -1;

int G[100][100], d[100];
bool color[100];

int main(){
    int n, minc, tag, ans = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        d[i] = inf;
        color[i] = false;
        for(int j = 0; j < n; j++) cin >> G[i][j];
    }
    d[0] = 0;
    while(true){
        minc = inf;
        for(int i = 0; i < n; i++){
            if(color[i] == false && d[i] < minc){
                minc = d[i];
                tag = i;
            }
        }
        if(minc == inf) break;
        ans += minc;
        color[tag] = true;
        for(int v = 0; v < n; v++){
            if(G[tag][v] != -1){
                if(color[v] == false && G[tag][v] < d[v]){
                    d[v] = G[tag][v];
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3108
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main
{
	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			public void run() {
                solve();
            }
        }, "1", 1 << 26).start();
	}
	static void solve () {
		FastReader fr =new FastReader();	PrintWriter op =new PrintWriter(System.out);
 
 		long n =fr.nextLong() ,sm =(n*(n+1))/2 ,th =0 ,fv =0 ,tv =0 ;
 		th =(n/3 * (3 + (n/3)*3))/2 ;	fv =(n/5 * (5 + (n/5)*5))/2 ;
 		tv =(n/15 * (15 + (n/15)*15))/2 ;	sm -= (th + fv -tv) ;
 		op.println(sm) ;
		op.flush();	op.close();
	}
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br =new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st==null || (!st.hasMoreElements())) 
			{
				try
				{
					st =new StringTokenizer(br.readLine());
				}
				catch(IOException e)
				{
					e.printStackTrace();
				}
				
			}
			return st.nextToken();
		}

		String nextLine() {
			String str ="";

			try
			{
				str =br.readLine();
			}
			catch(IOException e)
			{
				e.printStackTrace();
			}

			return str;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next()) ;
		}
	}
}

Measured memory_bytes: 33004
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;
using Graph = vector<vector<ll>>;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main()
{
    vector<ll> li(3);
    rep(i, 3)
    {
        cin >> li[i];
    }
    sort(all(li));
    if (!((li[0] == li[1] && li[1] == li[2]) || (li[0] < li[1] && li[1] < li[2])))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    n %= k;
    cout << min(k-n,n) << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000007 //1000000000000000003
#define INF2 1000000000000000003
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

const int MAXN = 210;
int G[MAXN][MAXN];

void warshall_floyd() {
  rep(k,MAXN) { // 中継ノード k を固定する。
    rep(i,MAXN) {
      rep(j,MAXN) {
        G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }
}



void Main(){

  int N,M,R;

  cin>>N>>M>>R;

  vector<int> r;

  rep(i,R){
    int rr;
    cin>>rr;
    r.emplace_back(rr);
  }

  SORT(r);

  rep(i,MAXN){
    rep(j,MAXN){
      G[i][j]=INF;
    }
    G[i][i]=0;
  }

  rep(i,M){
    int a,b,c;
    cin>>a>>b>>c;
    G[a][b]=c;
    G[b][a]=c;
  }

  warshall_floyd();

  ll ans=INF2;

  do{
    ll buff=0;
    rep(i,R-1){
      buff+=G[r[i]][r[i+1]];
    }
    ans=min(ans,buff);
  } while(next_permutation(begin(r),end(r)));

  cout<< ans<<"\n";

}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


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

int main() {
	int n, m;
	cin >> n >> m;
	int a[n][m], b[m], c;
	cin >> c;
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}

	int ans = 0;
	// 正誤判断
	for (int i = 0; i < n; i++) {
		long long solve = 0;
		for (int k = 0; k < m; k++) {
			solve += a[i][k] * b[k];
		}
	    solve += c;
		if (solve > 0) ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <list>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <fstream>
#include <sstream>
#include <unordered_map>
#include <ctime>
using namespace std;

const unsigned long long BASE = (unsigned long long)(1e9 + 7);

#define FROM_0(i, n) for(int i = 0; i < (n); i++)
#define FROM_S(i, s, e) for(int i = (s); i < (e); i++)
#define ITER_BEGIN_END(iter, vec) for(auto iter = vec.begin(); iter != vec.end(); iter++)

bool isP(int n)
{
    int end = sqrt(n);
    FROM_S(j, 2, end + 1)
    {
        if (n % j == 0)
            return false;
    }
    return true;
}

int gcd(int a, int b)
{
    if (b > a)
        std::swap(a, b);
    while (b != 0)
    {
        a = a % b;
        std::swap(a, b);
    }
    return a;
}

int main()
{
    int n;
    cin >> n;
    int moreThan1 = 0;
    int allGcd = 1;
    int * a = new int[n];
    FROM_0(i, n)
    {
        cin >> a[i];
        if (a[i] > 1)
            moreThan1++;
        if (i == 0)
            allGcd = a[i];
        else
            allGcd = gcd(allGcd, a[i]);
    }
    if (allGcd != 1)
    {
        cout << "not coprime" << endl;
        return 0;
    }
    else if (moreThan1 >= 78500)
    {
        cout << "setwise coprime" << endl;
        return 0;
    }
    // check pairwise coprime
    set<int> prime;
    prime.insert(2);
    for (int i = 3; i < 1000000; i += 2)
    {
        if (isP(i))
            prime.insert(i);
    }
    FROM_0(i, n)
    {
        int number = a[i];
        if (number == 1)
            continue;
        if (isP(number))
        {
            auto pFind = prime.find(number);
            if (pFind != prime.end())
            {
                prime.erase(pFind);
                continue;
            }
            else
            {
                cout << "setwise coprime" << endl;
                return 0;
            }
        }
        for (auto pPrime = prime.begin(); pPrime != prime.end();)
        {
            if (*pPrime > number)
                break;
            if (number % *pPrime == 0)
            {
                do
                {
                    number /= *pPrime;
                } while (number % *pPrime == 0);
                pPrime = prime.erase(pPrime);
            }
            else
                pPrime++;
        }
        if (number > 1)
        {
            if (isP(number))
            {
                auto pFind = prime.find(number);
                if (pFind != prime.end())
                {
                    prime.erase(pFind);
                    continue;
                }
                else
                {
                    cout << "setwise coprime" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "pairwise coprime" << endl;
    return 0;
}


Measured memory_bytes: 10976
use std::io;


/// Abstract
/// a, b, N < 10^5
/// K < sum(b_i)
/// A = [a_1, a_1, ..(b_1)., a_2, a_2, ..(b_2), ..., a_n]
/// A[K] = ?
fn main() {
    let (n, k) = {
        let i = read::<usize>();
        (i[0], i[1])
    };

    let mut vec: Vec<Vec<usize>> = Vec::new();

    for _ in 0..n {
        vec.push(read::<usize>());
    }

    vec.sort();
    vec.reverse();

    let mut count = 0;
    let mut ans = 0;
    while count < k {
        let n = vec.pop().unwrap();
        count += n[1];
        if count >= k { ans = n[0]; }
    }

    println!("{}", ans);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 9720
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n, d, x;
  cin >> n >> d >> x;
  vector<vector<int>> p(d, vector<int>(n));
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < n; j++) {
      cin >> p[i][j];
    }
  }
  for (int i = 0; i + 1 < d; i++) {
    int mx = x;
    vector<int> dp(101010);
    iota(dp.begin(), dp.end(), 0);
    for (int j = 0; j < n; j++) {
      for (int u = 0; u + p[i][j] < 101010; u++) {
        dp[u + p[i][j]] = max(dp[u + p[i][j]], dp[u] + p[i + 1][j]);
      }
    }
    for (int j = 0; j <= mx; j++) {
      x = max(x, dp[j]);
    }
  }
  cout << x << endl;
  return 0;
}


Measured memory_bytes: 3584
#include "bits/stdc++.h"
using namespace std;

const int N=2e3+20,MOD=1e9+7;

int n,m,a[N],b[N],dp[N][N];

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=m;i++) scanf("%d",&b[i]);

	for(int i=0;i<=n;i++) dp[i][0]=1;
	for(int j=0;j<=m;j++) dp[0][j]=1;

	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			dp[i][j]=dp[i-1][j]+dp[i][j-1];
			if(a[i]!=b[j]) dp[i][j]-=dp[i-1][j-1];
			dp[i][j]%=MOD;
			if(dp[i][j]<0) dp[i][j]+=MOD;
		}
	}

	cout<<dp[n][m];
}

Measured memory_bytes: 16000
#include <stdio.h>
#include <stdlib.h>
int main(){
  long long int N,K,flag1=0,num;
  scanf("%lld %lld",&N,&K);
  if(N>K){
    N=N%K;
  }else{
  }
  num=labs(N-K);
  if(num<N){
    N=num;
  }else{
  }  
  printf("%lld",N);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

string convert(int arg){
	string ret = "";
	int tmp = arg/1000;
	if(tmp > 0){
		if(tmp != 1){
			ret += (char)tmp+'0';
		}
		ret += "m";
	}
	arg -= tmp*1000;
	tmp = arg/100;
	if(tmp > 0){
		if(tmp != 1){
			ret += (char)tmp+'0';
		}
		ret += "c";
	}
	arg -= tmp*100;
	tmp = arg/10;
	if(tmp > 0){
		if(tmp != 1){
			ret += (char)tmp+'0';
		}
		ret += "x";
	}
	arg -= tmp*10;
	if(arg > 0){
		if(arg != 1){
			ret += (char)arg+'0';
		}
		ret += "i";
	}
	return ret;
}

int main(void){
	string str;
	int n;
	cin >> n;
	cin.ignore();
	for(int i=0;i<n;i++){
		int input[2];
		for(int j=0;j<2;j++){
			cin >> str;
			int ii=0,xx=0,cc=0,mm=0;
			for(int k=0;k<str.size();k++){
				if(str[k] == 'i'){
					if(k != 0 && '2' <= str[k-1] && str[k-1] <= '9'){
						ii = str[k-1] - '0';
					}else{
						ii = 1;
					}
				}else if(str[k] == 'x'){
					if(k != 0 && '2' <= str[k-1] && str[k-1] <= '9'){
						xx = str[k-1] - '0';
					}else{
						xx = 1;
					}
				}else if(str[k] == 'c'){
					if(k != 0 && '2' <= str[k-1] && str[k-1] <= '9'){
						cc = str[k-1] - '0';
					}else{
						cc = 1;
					}
				}else if(str[k] == 'm'){
					if(k != 0 && '2' <= str[k-1] && str[k-1] <= '9'){
						mm = str[k-1] - '0';
					}else{
						mm = 1;
					}
				}
			}
			input[j] = ii * 1 + xx * 10 + cc * 100 + mm * 1000;
		}
		cout << convert(input[0] + input[1]) << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

    int n; cin >> n;
    string s; cin >> s;

    vector<int> a(n);
    REP(i, n) a[i] = s[i] % 3;

    vector<int> count(3, 0);
    REP(i, n) count[a[i]]++;

    long long ans = 1;
    REP(i, 3) ans *= count[i];

    REP(j, n) REP(i, j) {
        int k = j + (j - i);
        if (k < n) {
            if (a[i] == a[j]) continue ;
            if (a[j] == a[k]) continue ;
            if (a[k] == a[i]) continue ;
            ans--;
        }
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3540
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;
using namespace std;
//LLONG_MAX = 90^18
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }

int N, M;

signed main()
{
	cin >> N >> M;

	int sum = 0;
	REP(i, M)
	{
		int a;
		cin >> a;
		sum += a;
	}

	cout << max(N - sum, -1LL) << endl;

}




Measured memory_bytes: 3584
#include<stdio.h>
int main(void){
  int A1;
  int A2;
  int A3;
  scanf("%d",&A1);
  scanf("%d",&A2);
  scanf("%d",&A3);
  int AA = A1+A2+A3;
  if(AA >= 22){
    printf("bust");
  }else{
    printf("win");
  }
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int x;
	int i;
	
	while (scanf("%d %d", &a, &b) != EOF){
		x = a + b;
		
		i = 0;
		do {
			i++;
			x /= 10;
		} while (x != 0);
		
		printf("%d\n", i);
	}
	
	return 0;
}

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

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

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

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

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

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

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

    LL x;
    cin >> x;
    LL res = x / 11 * 2;
    x = x % 11;
    if(x > 6) res += 2;
    else if(x > 0) ++res;
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a string

	fmt.Scan(&a)
	if a == "SUN" {
		fmt.Print("7")
	} else if a == "MON" {
		fmt.Print("6")
	} else if a == "TUE" {
		fmt.Print("5")
	} else if a == "WED" {
		fmt.Print("4")
	} else if a == "THU" {
		fmt.Print("3")
	} else if a == "FRI" {
		fmt.Print("2")
	} else if a == "SAT" {
		fmt.Print("1")
	}
}


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

class Program
{
    static void Main()
    {
        string[] Ss = Console.ReadLine().Split(' ');

        int K = int.Parse(Ss[0]);
        int X = int.Parse(Ss[1]);

        Console.WriteLine(K * 500 >= X ? "Yes" : "No");
    }
}

Measured memory_bytes: 11092
#include <stdio.h>

int main()
{
    int n,a,bucket[100000] = {0};
    int i,j;

    scanf("%d",&n);
    for (i = 0; i < n; i++)
    {
        scanf("%d",&a);
        bucket[a]++;
    }
    
    int buf = 0,max = 0;
    for (i = 2; i < 100000; i++)
    {
        buf = bucket[i - 2] + bucket[i - 1] + bucket[i];
        if(buf > max)max = buf;
    }
    
    printf("%d",max);
}


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

#define fastio {\
    ios::sync_with_stdio(0);\
    cin.tie(0);\
}

#define file {\
    freopen("io\\in.txt", "r", stdin);\
    freopen("io\\out.txt", "w", stdout);\
    freopen("io\\err.txt", "w", stderr);\
}

#ifdef LOCAL
#define debug(args...) {\
    string _s(#args);\
    replace(_s.begin(), _s.end(), ',', ' ');\
    stringstream _ss(_s);\
    istream_iterator<string> _it(_ss);\
    debug1(_it, args);\
}

#pragma GCC diagnostic ignored "-Wunused-parameter"
void debug1(istream_iterator<string> it) {
    cerr << endl;
}
#pragma GCC diagnostic pop

template<class T, class... Args>
void debug1(istream_iterator<string> it, T a, Args... args) {
    cerr << '>' << *it << " = " << a << "; ";
    debug1(++it, args...);
}
#else
#define debug(args...)
#define cerr if (false) cerr
#endif

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using si = set<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define rep(i, n)   for (int i = 0; i < n; i++)
#define dotc()      int tcs; if (cin >> tcs) rep(tc, tcs)
#define sz(x)       (int)x.size()
#define eb          emplace_back
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define all(x)      x.begin(), x.end()
#define rall(x)     x.rbegin(), x.rend()
#define fi          first
#define se          second

const int inf(0x3fffffff);
const int mod(1000000007);
const double pi(acos(-1.0));

signed main() {
    fastio;
#ifdef LOCAL
    file;
#endif

    int n, k;
    cin >> n >> k;
    ll mn = -1, mx = 0;
    ll cur = 0;
    rep(i, n + 1) {
        mn += i, mx += n - i;

        if (i + 1 >= k) cur += mx - mn;
    }

    cout << cur % mod;

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int a[MAX_N];

int main()
{
	int n;
	string alpha;
	string s;
	alpha = "abcdefghijklmnopqrstuvwxyz";
	cin >> s;
	rep(i,s.length()){
		rep(j,26){
			if(s[i] == alpha[j]){
				a[i] = j;
			}
		}
	}
	int K;
	cin >> K;
	rep(i,s.length()-1){
		if(K >= (26 - a[i])%26){
			K -= (26-a[i])%26;
			a[i] = 0;
		}
	}
	a[s.length()-1] = (a[s.length()-1]+K)%26;
	rep(i,s.length()){
		cout << alpha[a[i]];
	}
}

Measured memory_bytes: 896
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;

 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
    int r = sc.nextInt();
    int[] a = new int[r+1];
    for(int i = 1; i <= r; i++){
      a[i] = sc.nextInt();
    }
    int p = 1;
    int x = a[r];
    int i = p-1;
    for(int j = p; j <= r-1; j++){
      if(a[j] <= x){
        i++;
        int keep = a[i];
        a[i] = a[j];
        a[j] = keep;
      }
    }
    int keep2 = a[i+1];
    a[i+1] = a[r];
    a[r] = keep2;

    for(int k = 1; k < i+1; k++){
      if(k>1){
        System.out.print(" ");
      }
      System.out.print(a[k]);
    }
    System.out.print(" [");
    System.out.print(a[i+1]);
    System.out.print("]");
    for(int k = i+2; k <= r; k++){
      System.out.print(" ");
      System.out.print(a[k]);
    }
    System.out.println("");
  }
 
  
// LinkedList<Integer>[] setsu = new LinkedList[n];
// for(int i = 0; i < n; i++){
//   setsu[i] = new LinkedList<Integer>();
// } 

 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;

      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }

      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

Measured memory_bytes: 42028
#include <bits/stdc++.h>
using namespace std ;
template < class R > inline void Readin( R &K ) {
	K = 0 ; bool F = false ; char C = getchar() ; while( C < '0' or C > '9' ) { if( C == '-' ) F = true ; C = getchar() ; }
	while( C <= '9' and C >= '0' ) K = ( K << 1 ) + ( K << 3 ) + C - '0' , C = getchar() ; if( F ) K = -K ;
}
template < class R > inline void Checkmax( R &A , R B ) {
	if( A < B ) A = B ;
}
template < class R > inline void Checkmin( R &A , R B ) {
	if( A > B ) A = B ;
}
const int MaxN = 100000 + 10 ;
int N , M , Ans ;
pair<int,int> S[MaxN] ;
#define A first
#define B second
priority_queue<int> Q ;
int main() {
	Readin( N ) ;
	Readin( M ) ;
	for(register int i = 0 ; ++i <= N ; ) {
		Readin( S[i].A ) ;
		Readin( S[i].B ) ;
		S[i].A = M - S[i].A + 1 ;
	}
	sort( S + 1 , S + 1 + N ) ;
	for(register int i = 0 ; ++i <= N ; ) {
		if( S[i].A < 1 ) continue ;
		Q.push( -S[i].B ) ;
		while( Q.size() > S[i].A )
			Q.pop() ;
	}
	while( Q.size() ) {
		Ans += Q.top() ;
		Q.pop() ;
	}
	return not printf( "%d\n" , -Ans ) ;
}

Measured memory_bytes: 1660
#include <stdio.h>

int main()
{
	int n, q, x, ans = 0;
	int S[100001];
	int T[50000];
	
	scanf("%d", &n);
	for(int i = 0; i < n; ++i) { scanf("%d", &S[i]); }
	scanf("%d", &q);
	for(int i = 0; i < q; ++i) { scanf("%d", &T[i]); }

	for(int i = 0; i < q; ++i)
	{
		int l = 0;
		int h = n;
		while(l < h)
		{
			int m = (l + h) / 2;
			if(T[i] == S[m])
			{
				++ans;
				break;
			}
			else if(T[i] < S[m])
			{
				h = m;
			}
			else
			{
				l = m + 1;
			}
		}
	}
	printf("%d\n", ans);
}



Measured memory_bytes: 2284
#include<stdio.h>
int main(void)
{
    int a,b,c,d,n,cnt=0;
    while(~scanf("%d",&n)){
    for(cnt=a=0;a<=9;a++)for(b=0;b<=9;b++)for(c=0;c<=9;c++)for(d=0;d<=9;d++)if(a+b+c+d==n)cnt++;
    printf("%d\n",cnt);
    }
    return 0;
}

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

using namespace std;
typedef long long ll;

#define loopinc(i, a, b, inc) for(int i = a; i < (b); i += inc)
#define loop(i, a, b) for(int i = a; i < (b); i++)
#define rep(i, n) loop(i, 0, n)
#define rrep(i, n) for (int i = n-1; i >= 0; i--)
#define endl "\n"
#define all(c) (c).begin(),(c).end()
#define lloopinc(i, a, b, inc) for(ll i = a; i < (b); i += inc)
#define lloop(i, a, b) for(ll i = a; i < (b); i++)
#define lrep(i, n) lloop(i, 0, n)
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tuple<int, int, int> tiii;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

signed main() {
	// freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, k;
	cin >> n >> k;
	vector<bitset<5000>> flags(k);
	loop(i, 1, k) rep(j, n) flags[i][j] = true;
	vi arr(n);
	bitset<5000> tmp;
	rep(i, n) {
		int a;
		cin >> a;
		arr[i] = a;
		for(int j = k-a-1; j >= 0; j--) if (!flags[j][i]) {
			tmp.reset();
			tmp = flags[j];
			tmp[i] = true;
			flags[j+a] &= tmp;
		}
	}
	int total = n;
	rep(i, n) for (int j = k-1; j >= k-arr[i]; j--) if (!flags[j][i]) {
		total--;
		break;
	}
	cout << total << endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i)  cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());
    
    int half = a[0] / 2;
    int mindif = INF;
    int ans = INF;
    for(int i = 1; i < n; ++i){
        if(abs(half - a[i]) < mindif){
            mindif = abs(half - a[i]);
            ans = a[i];
        }
    }
    cout << a[0] << ' ' << ans << '\n';
}

Measured memory_bytes: 640
/*Made by Shivam Solanki*/
#include<bits/stdc++.h> 
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define ll long long int
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<pii> vp;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef set<int> sii;
typedef set<ll> sll;
typedef priority_queue<int> pq;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
typedef queue<int> qii;
#define rep(i,k,n) for (int i = k; i < n; ++i) 
#define repr(i,k,n) for (int i = n; i>=k; --i)
#define repll(i,k,n) for (ll i = k; i < n; ++i) 
#define repllr(i,k,n) for (ll i = n; i >= k; --i) 
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int INF = 1e9+5;
const int MOD = 1e9+7;

void solve(){
    int n,q;
    cin>>n>>q;
    vi a(n,-1);
    bool f=1;
    rep(i,0,q){
        int x,val;
        cin>>x>>val;
        x--;
        if(a[x]==-1 or a[x]==val) a[x]=val;
        else f=0;
        // rep(i,0,n){
        //     cout<<a[i];
        // }
        // cout<<'\n';
    }
    if(f==0){
        cout<<-1;
        return;
    }
    if(a[0]==0 && n!=1)
    {
        cout<<-1;
        return;
    }
    if(a[0]==-1 && n!=1)
    {
        a[0]=1;
    }
    else if(a[0]==-1 && n==1){
        a[0]=0;
    }
    cout<<a[0];
    rep(i,1,n){
        if(a[i]==-1) a[i]=0;
        cout<<a[i];
    }
} 
 
  
int main(){
    // #ifndef ONLINE_JUDGE  
        // freopen("input.txt", "r", stdin); 
        // freopen("output.txt", "w", stdout); 
    // #endif 
    fastio;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
    return 0;
}

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

S = [input() for i in range(N)]

C = [[0]*26 for i in range(N)]

for i in range(N):
    for j in range(len(S[i])):
        C[i][ord(S[i][j])-97]+=1

from collections import defaultdict as dd

dic=dd(int)

for i in range(N):
    dic[" ".join(map(str,C[i]))]+=1

ans = 0

for key in dic:
    ans+=dic[key]*(dic[key]-1)//2

print(ans)

Measured memory_bytes: 123096
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n - 1);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n - 1) cin >> c[i];
    int sum = 0, pre = -2;
    rep(i, n)
    {
        int now = a[i] - 1;
        sum += b[now];
        if (now == pre + 1)
            sum += c[pre];
        pre = now;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
li,lia = [],[]
total = 0
for i in range(5):
    a = input()
    li.append(a)
for i in range(5):
    lia.append(li[i][-1])
lib = [int(s) for s in lia]
b = lib.count(0)
for i in range(b):
    lib.remove(0)
for i in range(5):
    total += (int(li[i])//10+1)*10
if len(lib) >= 1:
    total -= 10*(1+b)
else:
    total -= 10*(b)
if len(lib) >= 1:
    total += min(lib)
if total <= 0:
    print(0)
else:
    print(total)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <tuple>
#include <string>

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  std::string S;
  std::cin >> S;
  if (S.size() % 2 != 0) {
    std::cout << "No\n";
  }
  else {
    for (int i = 0; i < S.size(); i += 2) {
      if (S[i] != 'h' || S[i + 1] != 'i') {
        std::cout << "No\n";
        return 0;
      }
    }
    std::cout << "Yes\n";
  }
  return 0;
}


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

happy_list = [[0, 0, 0]] # n日目にa|b|cを選んだときの幸福のそこまでの最大値
# before_act = -1 # a: 0, b: 1, c: 2
for n in range(N):
    before_happy_a, before_happy_b, before_happy_c = happy_list[-1]
    a, b, c = abc_list[n]
    tmp_happy_a = max(before_happy_b, before_happy_c) + a
    tmp_happy_b = max(before_happy_c, before_happy_a) + b
    tmp_happy_c = max(before_happy_a, before_happy_b) + c
    happy_list.append([tmp_happy_a, tmp_happy_b, tmp_happy_c])

print(max(happy_list[-1]))

Measured memory_bytes: 50052
#include<bits/stdc++.h>
#define ll long long
#define R register
using namespace std;
const int N = 2e6+200;
template <class Ruby> inline void read(Ruby &x)
{
	x=0;
	char ch=getchar(), w=0;
	while(!isdigit(ch))w=(ch=='-'), ch=getchar();
	while(isdigit(ch))x=(x<<1)+(x<<3)+(ch^48), ch=getchar();
	x=w?-x:x;
}

int main()
{
	char s;
	cin>>s;
	cout<<(char)(s+1);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=200005;
int n;
char s[N];
int dp[N][3];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++)
	{
		dp[i][1]=dp[i-1][2]+1;
		if(s[i]!=s[i-1]) dp[i][1]=max(dp[i][1],dp[i-1][1]+1);
		if(i-2>=0) dp[i][2]=dp[i-2][1]+1;
		if(i-2>=0&&(s[i]!=s[i-1]||s[i-1]!=s[i-2])) dp[i][2]=max(dp[i][2],dp[i-2][2]+1);
	}
	printf("%d",max(dp[n][1],dp[n][2]));
	return 0;
}

Measured memory_bytes: 6200
a, b, c, k = list(map(int, input().split()))

sum = 0
if k-a>=0:
    sum = sum + a*1
    k = k - a
else:
    sum = sum + k
    k = 0
if k>0 and k-b>=0:
    sum = sum + b*0
    k = k -b
else: 
    sum = sum + k
    k = 0
if k>0 and k-c>=0:
    sum = sum + c*(-1)
    k = k - c
elif k>0 and k-c<0:
    sum = sum - k

print(sum)

Measured memory_bytes: 9208