akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>

using namespace std;
using Int = long long;
typedef pair<int,int> Pi; typedef pair<Int,Int> Pl;
constexpr int mod = 1e9+7;
constexpr int INF32 = numeric_limits<int>::max();
constexpr Int INF64 = numeric_limits<Int>::max();
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rer(i,l,r) for(int(i)=(l); (i)<(r); ++(i))
#define rep(i,n) rer(i,0,n)
#define gnr(i,l,r) for(int (i)=(r)-1; (i)>=(l); --(i))
#define pri(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(i,n-1)cout<<a[i]<<' '; if(n)cout<<a[n-1]<<'\n';}
#define prip(p) cout<<(p).fi<<' '<<(p).se<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,x,y,q;
string s,sb;
bool ok;
char cf,cb;

int main(){
  cin.tie(nullptr); ios::sync_with_stdio(0);
  //cout<<fixed<<setprecision(20);
  
  cin>>s; reverse(ALL(s)); pri(s);
}


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

int main()
{
    int A, B, C;
    scanf("%d %d %d", &A, &B, &C);
    if (A==5 and B==5 and C==7)
    {
        printf("YES");
    }
    else if (A == 7 and B==5 and C==5)
    {
        printf("YES");
    }
    else if (A==5 and B==7 and C==5)
    {
        printf("YES");
    }
    else
    {
        printf("NO");
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    Long N = sc.nextLong(), w=(long)Math.sqrt(N), t, min=N+1;
    for(int i=1; i<=w; i++) {
      if(N % i ==0) {
        t = i + N/i;
        if(t<min) min = t;
      }
    }
    System.out.println(min-2);
  }
}

Measured memory_bytes: 35440
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

struct Coord {
    Int x;
    Int y;
};
double CalcDist(Coord first, Coord second) {
    return sqrt((first.x - second.x) * (first.x - second.x) + (first.y - second.y) * (first.y - second.y));
}
double CalcDistSum(vector<Coord>& coords, vector<Int>& coordId) {
    Int size = (Int)coordId.size();
    double ret = 0;
    for (Int i = 0; i < size - 1; ++i) {
        ret += CalcDist(coords[coordId[i]], coords[coordId[i + 1]]);
    }
    return ret;
}
Int Factorial(Int n) {
    if (n == 1) {
        return 1;
    } else {
        return n * Factorial(n - 1);
    }
}

void PermutationLoop(Int n, vector<Coord>& coords) {
    vector<Int> v(n);
    for (Int i = 0; i < n; ++i) {
        v[i] = i;
    }

    double sum = 0;
    do {
        sum += CalcDistSum(coords, v);
    } while (std::next_permutation(v.begin(), v.end()));
    cout << fixed << setprecision(10) << sum / (double)Factorial(n) << endl;
}


int main(void) {
    Int n;
    cin >> n;
    vector<Coord> coords(n);
    for (Int i = 0; i < n; ++i) {
        cin >> coords[i].x >> coords[i].y;
    }
    PermutationLoop(n, coords);
    return 0;
}


Measured memory_bytes: 3784
#include <stdio.h>
#define BUFMAX 10
#define DAYSEC 86400
#define HOURSEC 3600
#define MINSEC 60

int main(){
    char buf[BUFMAX];
    int t,h,m,s;

    fgets(buf,BUFMAX,stdin);
    buf[BUFMAX-1] = '\0';
    sscanf(buf,"%d", &t);
    h = t / HOURSEC;
    m = (t % HOURSEC) / MINSEC;
    s = t % MINSEC;
    printf("%d:%d:%d\n",h, m, s);
    return 0;
}

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

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

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

int main(){
    int n;
    cin >> n;
    vector<pii> s(n),l(n);
    rep(i,n){
        int a,b;
        cin >> a >> b;
        s[i] = make_pair(b,a);
    }
    rep(i,n){
        int c,d;
        cin >> c >> d;
        l[i] = make_pair(c,d);
    }
    sort(l.begin(),l.end());
    int ans = 0;
    rep(i,n){
        sort(s.rbegin(),s.rend());
        rep(j,s.size()){
            if(s[j].second < l[i].first && s[j].first < l[i].second){
                ans++;
                s.erase(s.begin() + j);
                break;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_bit(n) for (int bit = 0; bit < (1<<n); ++bit)
#define all(x) (x).begin(),(x).end()
#define ll long long
#define ld long double
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define SP <<" "<<
#define CST(x) cout<<fixed<<setprecision(x)
using namespace std;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vi> Graph;

//条件式 ? 真の場合の文 : 偽の場合の文
//abs(x) = (x の絶対値)
//string S  S,at(i),S += T,S += c,S.size(),S.substr(l)l文字目から最後まで,
///S.substr(l, r)l文字目からl+r-1文字目 n文字目から0個で空列を返せる
//*min_element(all(x)) *max_element(all(x))
//vi x; x.back(),x.front(),x.push_back(),x.pop_back()
//swap(a, b)
//gcd(a, b)最大公約数
//sort(all(x)),reverse(all(x)),sort(x.begin()+l,a.begin()+r)lからrまで
//stack<int> a; a.push(x),a.pop(),a.top(),a.empty()bool
//queue<int> b; b.push(x),b.pop(),b.front(),b.empty()bool,b.size() 要素が小さい順
//priority_queue<int, vector<int>, greater<int>> c,c.top()
//map<int, int> M1; 変数[key] = value; 変数.erase(key); 変数.at(key); 変数.count(key)所属判定　変数.size()
//find(all(x), key)boolソート済みのベクトル
//*lower_bound(all(x),k)以上の最小の要素,*uppper_bound(all(x),k)より大きい最小の要素
//'0'+cnt 数字cntからcharへの変換


int main(){
    vi a(4);
    string s;
    cin >> s;
    rep(i,4){
        a.at(i) = int(s.at(i) - '0');
    }
    rep_bit(3){
        int sum = a.at(0);
        string s="";
        s += (char)('0'+a.at(0));
        rep(i,3){
            if(bit&(1<<i)){
                sum += a.at(i+1);
                s+='+';
                s+=(char)('0'+a.at(i+1));
            }
            else{
                sum -= a.at(i+1);
                s+='-';
                s+=(char)('0'+a.at(i+1));
            }
        }
        if(sum == 7) {
            cout << s << "=7" << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
int main(){
	int n;
	cin >> n;
	vector<long long> input;
	REP(i, n) {
		long long a;
		cin >> a;
		input.push_back(100001LL - a);
	}
	reverse(input.begin(), input.end());
	vector<vector<pair<long long, long long>>> geko;
	vector<pair<long long, long long>> tmp;
	tmp.push_back(make_pair(input[0], 0));
	geko.push_back(tmp);
	for (int i = 1; i < n; ++i) {
		int top = geko.size() - 1;
		int bot = 0;
		while (top - bot > 1) {
			int mid = (top + bot) / 2;
			if (geko[mid][geko[mid].size()-1].first < input[i]) {
				bot = mid;
			}
			else {
				top = mid;
			}
		}
		for (int q = max(0, bot - 1); q <= min((int)geko.size() - 1, top + 1); ++q) {
			if (geko[q][geko[q].size() - 1].first > input[i]) {
				if (q == 0 || geko[q - 1][geko[q - 1].size() - 1].first < input[i]) {
					geko[q].push_back(make_pair(input[i], i));
					continue;
				}
			}
		}
		if (geko[geko.size() - 1][geko[geko.size() - 1].size() - 1].first < input[i]) {
			vector<pair<long long, long long>> tmp;
			tmp.push_back(make_pair(input[i], i));
			geko.push_back(tmp);
		}
	}
	cout << geko.size() << endl;
	return 0;
	for (int i = geko.size()-2; i >= 0; --i) {
		while (geko[i][geko[i].size() - 1].second > geko[i + 1][geko[i + 1].size() - 1].second) {
			geko[i].pop_back();
		}
	}
	long long ans = 0;
	for (int i = 0; i < geko.size(); ++i) {
		ans += (long long)geko[i][geko[i].size() - 1].first;
	}
	cout << 100001LL * (long long)geko.size() - ans << endl;
	return 0;
}


Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
int main(){
  set<int> S;
  int q;
  cin >> q;
  for (int i = 0; i < q; i++){
    int t;
    cin >> t;
    if (t == 0){
      int x;
      cin >> x;
      S.insert(x);
      cout << S.size() << endl;
    }
    if (t == 1){
      int x;
      cin >> x;
      if (S.count(x)){
        cout << 1 << endl;
      } else {
        cout << 0 << endl;
      }
    }
  }
}


Measured memory_bytes: 12380
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

/*
 * x+y>(t - t_1)の場合には不可
 * x+yと(t-t_1)の偶奇が一致していない場合は不可
 */
int main() {
  int n; cin >> n;
  vector<int> T(n), X(n), Y(n);
  loop(i,0,n) cin >> T[i] >> X[i] >> Y[i];
  int prev_t = 0, prev_x = 0, prev_y = 0;
  loop(i,0,n) {
    int t = T[i] - prev_t;
    int x = abs(X[i]-prev_x);
    int y = abs(Y[i]-prev_y);
    if (x+y > t) {
      cout << "No" << endl;
      return 0;
    }
    
    if ((x+y)%2 != t%2) {
      cout << "No" << endl;
      return 0;
    }
    
    prev_t = T[i];
    prev_x = X[i];
    prev_y = Y[i];
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 4220
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

inline int read()
{
    int x=0;char ch=getchar();
    while(ch<'0' || '9'<ch)ch=getchar();
    while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
    return x;
}

const int M=1e5+9;

int m;
int a[M],b[M],top;

int main()
{
    int n=read(),m=read();
    int odd1=-1,odd2=-1;
    for(int i=1;i<=m;i++)
    {
        a[i]=read();
        if(a[i]&1)
        {
            if(odd1==-1)
                odd1=i;
            else if(odd2==-1)
                odd2=i;
            else
            {
                puts("Impossible");
                return 0;
            }
        }
    }

    if(m==1)
    {
        if(a[1]==1)
            printf("1\n1\n1\n");
        else
            printf("%d\n2\n1 %d\n",a[1],a[1]-1);
        return 0;
    }

    if(odd1!=-1)
        swap(a[1],a[odd1]);
    if(odd2!=-1)
        swap(a[m],a[odd2]);

    for(int i=1;i<=m;i++)
        printf("%d%c",a[i]," \n"[i==m]);

    if(a[m]==1)
    {
        printf("%d\n",m-1);
        printf("%d ",a[1]+1);
        for(int i=2;i<m;++i)
            printf("%d ",a[i]);
        puts("");
        return 0;
    }

    b[1]=a[1]+1;
    for(int i=2;i<m;i++)
        b[i]=a[i];
    b[m]=a[m]-1;

    printf("%d\n",m);
    for(int i=1;i<=m;i++)
        printf("%d%c",b[i]," \n"[i==m]);

    return 0;
}

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

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
 
int main() {

    int x;
    cin>>x;
    int i=0;
    do {
        if(IsPrime(x+i)==true) {
            cout<<x+i<<endl;
            break;
        }
        i++;
    }while(1);

 return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
	int a,b,temp1,temp2,c,d;
	while(scanf("%d%d%d%d",&a,&b,&c,&d)!=EOF){
		if(a<c)
		temp1=c;
		else
		temp1=a;
		if(b<d)
		temp2=b;
		else
		temp2=d;
		if(temp2-temp1<=0)
		printf("0\n");
		else
		printf("%d\n",temp2-temp1);
	}
}

Measured memory_bytes: 128
#include <cstdio>

const int mod = 1e9 + 7;
const int MAXN = 2005, MAXS = MAXN * MAXN;

template<typename _T>
void read( _T &x )
{
	x = 0;char s = getchar();int f = 1;
	while( s > '9' || s < '0' ){if( s == '-' ) f = -1; s = getchar();}
	while( s >= '0' && s <= '9' ){x = ( x << 3 ) + ( x << 1 ) + ( s - '0' ), s = getchar();}
	x *= f;
}

template<typename _T>
void write( _T x )
{
	if( x < 0 ){ putchar( '-' ); x = ( ~ x ) + 1; }
	if( 9 < x ){ write( x / 10 ); }
	putchar( x % 10 + '0' );
}

int f[MAXN][MAXN];
int fac[MAXS], ifac[MAXS];
int N, K;

int qkpow( int, int );
int inv( const int a ) { return qkpow( a, mod - 2 ); }
void sub( int &x, const int v ) { x = ( x < v ? x - v + mod : x - v ); }
void add( int &x, const int v ) { x = ( x + v >= mod ? x + v - mod : x + v ); }

int qkpow( int base, int indx )
{
	int ret = 1;
	while( indx )
	{
		if( indx & 1 ) ret = 1ll * ret * base % mod;
		base = 1ll * base * base % mod, indx >>= 1;
	}
	return ret;
}

void init( const int siz )
{
	fac[0] = ifac[0] = 1;
	for( int i = 1 ; i <= siz ; i ++ ) fac[i] = 1ll * fac[i - 1] * i % mod;
	ifac[siz] = inv( fac[siz] );
	for( int i = siz - 1 ; ~ i ; i -- ) ifac[i] = 1ll * ifac[i + 1] * ( i + 1 ) % mod;
}

int C( const int n, const int m ) { return 1ll * fac[n] * ifac[m] % mod * ifac[n - m] % mod; }

int main()
{
	read( N ), read( K );
	if( K == 1 ) { puts( "1" ); return 0; }
	init( N * K );
	for( int i = 0 ; i <= N ; i ++ ) f[i][0] = 1;
	for( int i = 1 ; i <= N ; i ++ )
		for( int j = 1 ; j <= i ; j ++ )
		{
			f[i][j] = f[i - 1][j];
			int t = N * K - i - ( K - 1 ) * ( j - 1 ) - 1;
			add( f[i][j], 1ll * f[i][j - 1] * ( N - j + 1 ) % mod * C( t, K - 2 ) % mod );
		}
	write( f[N][N] ), putchar( '\n' );
	return 0;
}

Measured memory_bytes: 46520
#define LOCAL

#undef _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define MOD 1000000007LL
#define LLINF 100000000000000005LL
#define INF (int)1e9+1
#define pb push_back

// Copied from Gennady-Korotkevich's template

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string)s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(v[i]);
	}
	res += "}\n";
	return res;
}

template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto& x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}\n";
	return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

template <typename A, typename B, typename C, typename D, typename E>
string to_string(tuple<A, B, C, D, E> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + "," + to_string(get<4>(p)) + ")";
}

void debug_out() {
	cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "\n[" << #__VA_ARGS__ << "]:\n", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// End of Gennady-Korotkevich's template 

using llong = long long;
using PII = pair<int, int>;

int main() {
	IOS;
	int n;
	cin >> n;
	vector<llong> a(n);
	vector<llong> pref(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) {
		if (i == 0) pref[i] = a[i];
		else {
			pref[i] = pref[i - 1] + a[i];
			pref[i] %= MOD;
		}
	}
	llong ans = 0;
	for (int i = n - 2; i >= 0; i--) {
		ans += pref[i] * a[i + 1];
		ans %= MOD;
	}
	cout << ans;
}


Measured memory_bytes: 6360
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
main(){
  
  ll n,k;
  cin>>n>>k;
  vector<ll> a(n);
  for(auto&x:a)cin>>x;
  vector<ll> dp(n,(1LL<<50));
  dp[0]=0;
  for(ll i=1;i<n;++i){
    for(ll j=1;j<=k&&(i-j)>=0;++j){
      chmin( dp[i],dp[i-j]+abs(a[i]-a[i-j]) );
    }
  }
  cout<<dp[n-1]<<endl;

}

Measured memory_bytes: 1792
#include <stdio.h>

int main()
{
  int r,c,x,sum,i,j;
  int data[101][101];
  scanf("%d",&r);
  scanf("%d",&c);

  for (i=0;i<r;i++){
    sum=0;
    for (j=0;j<c;j++){
      scanf("%d",&x);
      data[i][j]=x;
      sum+=x;
    }
    data[i][c]=sum;
  }

  for (j=0;j<=c;j++){
    sum=0;
    for (i=0;i<r;i++){
      sum+=data[i][j];
    }
    data[r][j]=sum;
  }

  for (i=0;i<=r;i++){
    for (j=0;j<c;j++){
      printf("%d ",data[i][j]);
    }
    printf("%d\n",data[i][j]);
  }

  return 0;
}

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

int main(){
  string a,b;
  b = "No";
  cin >> a;
  rep(i,3){
    if(a[i] == '7')
      b = "Yes";
  }
  cout << b << endl;    
}

Measured memory_bytes: 3628
def solve(n, acts):
    fa = [0] * n
    fb = [0] * n
    fc = [0] * n
    fa[0] = acts[0][0]
    fb[0] = acts[0][1]
    fc[0] = acts[0][2]

    for i in range(1, n):
        fa[i] = acts[i][0] + max(fb[i-1], fc[i-1])
        fb[i] = acts[i][1] + max(fc[i-1], fa[i-1])
        fc[i] = acts[i][2] + max(fa[i-1], fb[i-1])

    return max([fa[-1], fb[-1], fc[-1]])


def main():
    inp = lambda: [int(x) for x in input().split()]
    n = int(input())
    acts = [inp() for _ in range(n)]
    print(solve(n, acts))


if __name__ == '__main__':
    main()



Measured memory_bytes: 66136
#include <bits/stdc++.h>
using namespace std;
int n,l[15];
int a,b,sum;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>l[i];
		sum+=l[i];
		if(a<l[i])
		{
			a=l[i];
			b=i;
		}
	}
	sum-=a;
	if(a<sum)
	{
		cout<<"Yes";
	}
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define ll long long


ll fibmod(ll n,ll p){
  ll N;
  ll x,y,tx,ty,F0,F1,tF0,tF1,tmp;
  y=0LL;
  x=F0=F1=1LL;
  --n;
  while(n){
    if(n&1){
      tx = x%p;
      ty = y%p;
      tmp=(F1-F0)%p; if (tmp<0)tmp+=p;
      x  = (F1*tx%p+F0*ty%p)%p;
      y  = (F0*tx%p+tmp*ty%p)%p;
    }
    n>>=1;
    tF1=F1%p;
    tF0=F0%p;
    tmp=(F1-F0)%p; if (tmp<0)tmp+=p;
    F1 = (tF1 * tF1 %p + tF0 * tF0 %p)%p;
    F0 = (tF1 * tF0 %p + tF0 * tmp %p)%p;
  }
  return x%p;
}


ll main(){
  ll i,j,a,b,N;
  scanf("%lld",&N);
  for(i=3;N;i+=10){
    if(fibmod(i,i)==i-1){
    printf("%lld ",i);
    --N;
    }
  }
}

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

int somesum(int a){
  string S=to_string(a);
  int sum=0;
  for(int i=0;i<S.size();i++){
    sum=sum+a%10;
    a=a/10;
  }
  return sum;
}

int main(){
  int N,A,B;
  cin>>N>>A>>B;
  int gsum=0;
  for(int i=1;i<N+1;i++){
    int m=somesum(i);
    if(m<=B&&m>=A){
      gsum=gsum+i;
    }
  }
  cout<<gsum<<endl;
}
   
  

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

int main() {
    int N,L;
    cin >> N >> L;
    int ate ;
    if(L<=0 & L > (-1) * N){
        ate = 1 -L;
    }
    else if(L <= (-1) * N){
        ate = N;
    }
    else{
        ate = 1;
    }
    cout << N * L - N + N * (N+1) /2 - L - ate + 1 << endl;
    

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(System.Console.ReadLine());
            string[] temp = System.Console.ReadLine().Split(' ');
            int[] L = new int[N];
            for (int i = 0; i < N; i++)
            {
                L[i] = int.Parse(temp[i]);
            }
            Array.Sort(L);
            Array.Reverse(L);
            int sum = 0;
            for(int i = 1; i < N; i++) {
                sum += L[i];
            }
            if (L[0] < sum) { System.Console.WriteLine("Yes"); }
            else { System.Console.WriteLine("No"); }
        }
    }

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
string s,ss;

int main()
{
	cin>>s>>ss;
	for (int i=s.size()-ss.size();i>=0;i--)
	{
		bool fl=1;
		for (int j=0;j<ss.size();j++)
		{
			if (s[i+j]=='?') 
			continue;
			if (s[i+j]!=ss[j])         
			{
				fl=0;
				break;                
			}
		}
		if (fl)               
		{
		    for (int j=0;j<ss.size();j++) if (s[i+j]=='?') s[i+j]=ss[j];
		    for (int j=0;j<s.size();j++) if (s[j]=='?') s[j]='a';
		    cout <<s;
		    return 0;
		}
	}
	cout <<"UNRESTORABLE";
	return 0;
}

Measured memory_bytes: 3568
// Dāritys Morgho ban Rōvēgrie
// Math = ♥
// Sometimes it is people that no one imagines anything of who do things that no one can imagine
// After all this time? Always

#include <bits/stdc++.h>                        // uncomment before submission
//#include <ext/pb_ds/assoc_container.hpp>		// uncomment before submission
//#include <ext/pb_ds/tree_policy.hpp>			// uncomment before submission
//using namespace __gnu_pbds;					// uncomment before submission
using namespace std;
//<---------------------------------------------------Template----------------------------------------------------------->
#define int long long
#define ll long long
#define ld long double
const int INF = 1e15 + 7;
const int MAX = 1e5 + 7;
const int MOD = 1e9 + 7;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;                  // Vector of long long
typedef vector<vi> vvi;                 // Vector of vi
typedef vector<ii> vii;                 // Vector of pairs
typedef vector<vii> vvii;               // Vector of Vector of pairs
typedef vector<bool> vb;                // Vector of bool
#define pq priority_queue               // Max heap (To convert to min heap, use negative sign before every value)
#define ff first                        // For pairs
#define ss second                       // For pairs
#define pb push_back                    // Pushback to vector
#define mp make_pair                    // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end()   // Mainly used by me in sorting
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//<----------------------------------------------------------------------------------------------------------------------->

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;

    vii a(n + 1);
    for (int i = 1; i <= n; i++) cin >> a[i].ff, a[i].ss = i;
    sort(all(a));

    map<int, int> m;
    int j = n;
    for (int i = n; i > 0; i--)
    {
        j = min(j, a[i].ss);
        m[j] += (a[i].ff - a[i - 1].ff) * (n - i + 1);
    }

    for (int i = 1; i <= n; i++)
        cout << m[i] << endl;

    return 0;
}


Measured memory_bytes: 8960
def main():

    S, T = input().split()
    A, B = map(int, input().split())
    U = input()
    if U == S:
        return " ".join(map(str, [A-1, B]))
    else:
        return " ".join(map(str, [A, B-1]))

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 61620
#include <iostream>
#define no return cout << "NO\n", 0
using namespace std;
const int H = 405;
int f[H], d[H];
bool b[H], c[H];
int getf(int x)
{
	return f[x] == x ? x : f[x] = getf(f[x]);
}
int main()
{
	ios::sync_with_stdio(false);
	int n, h;
	cin >> n >> h;
	for (int i = 0; i <= 2 * h; i++)
		f[i] = i;
	while (n--)
	{
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		int x = (c ? -c : a) + h, y = (d ? d : -b) + h;
		f[getf(x)] = getf(y);
		::d[x]++;
		::d[y]--;
		::b[x] = true;
	}
	for (int i = 0; i < h; i++)
		if (d[i] > 0)
			no;
	for (int i = h + 1; i <= 2 * h; i++)
		if (d[i] < 0)
			no;
	for (int i = 0; i <= 2 * h; i++)
	{
		b[getf(i)] |= b[i];
		if (d[i])
			c[f[i]] = true;
	}
	for (int i = 0; i <= 2 * h; i++)
		if (f[i] == i && !c[i] && b[i])
			no;
	cout << "YES\n";
	return 0;
}

Measured memory_bytes: 256
import math
import sys

n, a, b = [int(w) for w in input().split()]

if a == 0:
    print(0)
    sys.exit()

if a + b >= n:
    print(min(a, n))
    sys.exit()

ans = 0
rep = n // (a + b)

ans += a * rep
n -= (a + b) * rep

ans += (min(a, n))

print(ans)


Measured memory_bytes: 3060
H, W = map(int, input().split())
A = [list(input()) for i in range(H)]
hi_list = []
wj_list = []
for i in range(H):
    c = 0
    for j in range(W):
        if A[i][j] == '.':
            c += 1
    if c == W:
        hi_list += [i]
for j in range(W):
    c = 0
    for i in range(H):
        if A[i][j] == '.':
            c += 1
    if c == H:
        wj_list += [j]

hi_set = set(hi_list)
wj_set = set(wj_list)
for i in range(H):
    if i in hi_set:
        continue
    for j in range(W):
        if j in wj_set:
            continue
        print(A[i][j], end='')
    print()


Measured memory_bytes: 75340
c = [list(map(int,input().split())) for _ in range(3)]

ans = 'Yes'

if not c[0][1] - c[0][0] == c[1][1] - c[1][0] == c[2][1] - c[2][0]:
    ans = 'No'
if not c[0][2] - c[0][1] == c[1][2] - c[1][1] == c[2][2] - c[2][1]:
    ans = 'No'

print(ans)


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

int main() {
    int n;
    std::cin >> n;

    std::vector<std::pair<int, int>> points(n);

    for (int i = 0; i < n; i++) {
        std::cin >> points[i].first >> points[i].second;
    }

    std::sort(points.begin(), points.end());
    for (auto point : points) {
        std::cout << point.first << " " << point.second << std::endl;
    }
}



Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

constexpr ll LNF = 1ll<<60;

constexpr int INF = 1e9+7;

vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    int flag = 0;
    vector<ll> a(n);
    rep(i,0,n) cin >> a[i];
    ll s = 0;
    rep(i,0,n){
        s += a[i]/n;
        if(a[i]>=n) flag = 1;
    }
    ll ans = 0;
    while(flag){
        flag = 0;
        ans += s;
        ll cmp = s;
        s = 0;
        rep(i,0,n){
            a[i] += cmp -(n+1ll)*(a[i]/n);
            s += a[i]/n;
            if(a[i]>=n) flag= 1; 
        }
        debug(a);
        if(flag==0) break;
    }
    cout << ans << endl;
}

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

int W,H,n,x,y;

int main(){

   while(cin>>W>>H>>n){

      int a,L=0,R=W,U=H,D=0;

      while(n--){
         scanf("%d %d %d",&x,&y,&a);
         if(a==1)
            L=max(x,L);
         else if(a==2)
            R=min(x,R);
         else if(a==3)
            D=max(D,y);
         else
            U=min(U,y);
      }

      cout<<max((R-L),0)*max(0,(U-D))<<endl;

   }




return 0;
}


Measured memory_bytes: 256
import collections
n = int(input())
d = [int(i) for i in input().split()]
 
dkaisuu = collections.Counter(d)
 
ans = 1
for i in range(1,max(d)+1): # 1,2,3
    ans *= dkaisuu[i-1]**dkaisuu[i]
if d[0] == 0 and dkaisuu[0] == 1:
    print(ans%998244353)
else:
    print(0)

Measured memory_bytes: 19928
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////



int main(){
    ll a,b,k;
    cin >> a >> b >> k;

    a -= k;
    if(a < 0){
	b += a;
	b = max(b,0LL);
	a = 0;
    }

    PS(a);P(b);
    return  0;
}


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

string S;

int main() {
    cin >> S;

    int N = S.length();
    for (int i = N/2 - 1; i >= 1; i--) {
        string front = S.substr(0, i);
        string back = S.substr(i, i);
        if (front == back) {
            cout << front.length() * 2 << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
# 2020/02/01
# AtCoder Beginner Contest 072 - C

# Input
n = int(input())
a = list(map(int, input().split()))

cntlist = [0] * (10 ** 5 + 2)

# Count

for i in range(n):
    for j in range(-1, 2):
        wk_val = a[i] + j
        if wk_val < 0:
            wk_val = 10**5 + 1

        cntlist[wk_val] = cntlist[wk_val] + 1

ans = max(cntlist)

# Output
print(ans)


Measured memory_bytes: 14004
#include <cstdio>
#include <algorithm>
using namespace std;
const long long INF = 1LL << 60;
int main() {
	int N;
	scanf("%d", &N);
	long long A[N + 1], mx[N + 1], ans = 0;
	for (int i = 0; i <= N; ++i) scanf("%lld", &A[i]);
	if (A[0] <= 1) {
		mx[0] = 1 - A[0];
		for (int i = 1; i <= N; ++i) {
			mx[i] = min(mx[i - 1] * 2, i < 60 ? 1LL << i : INF) - A[i];
			if (mx[i] < 0) {
				printf("-1");
				return 0;
			}
		}
		mx[N] = 0;
		for (int i = N - 1; i >= 0; --i) mx[i] = min(mx[i], mx[i + 1] + A[i + 1]);
		for (int i = 0; i <= N; ++i) ans += mx[i] + A[i];
		printf("%lld", ans);
	} else printf("-1");
	return 0;
}

Measured memory_bytes: 3248
N, M = map(int, input().split())
A = list(map(int, input().split()))
match = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}

dp = [-1 for i in range(N + 1)]

cost = []
for i in range(M):
    cost.append([A[i], match[A[i]]])

dp[0] = 0
for i in range(N):
    for k in range(M):
        if i + 1 - cost[k][1] >= 0:
            dp[i + 1] = max(dp[i + 1], dp[i + 1 - cost[k][1]] + 1)

tmp = 0 #使ったマッチの数
res = ''
cost.sort(key=lambda x: x[0], reverse=True)
for i in range(dp[N]):
    for j in range(M):
        if N - cost[j][1] - tmp >= 0:
            if dp[N - cost[j][1] - tmp] == dp[N - tmp] - 1:
                res = res + str(cost[j][0])
                tmp += cost[j][1]
                break
            
print(res)

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

using namespace std;

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

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

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                b[j][k] = min(b[j][k], b[j][i] + b[i][k]);
            }
        }
    }

    long long res = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            res += b[i][j];
            for (int k = 0; k < n; k++) {
                if (i != k && j != k && b[i][j] == b[i][k] + b[k][j]) {
                    res -= b[i][j];
                    break;
                }
            }
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (a[i][j] > b[i][j]) {
                res = -1;
            }
        }
    }

    cout << res << endl;
}


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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define repU(i,s,t) for(int i = (s); i <= (t); ++i)
#define repD(i,t,s) for(int i = (t); i >= (s); --i)
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define q_ceil(n,d) ((n - 1)/(d) + 1)
#define parity(a,b) (((a)^(b)) & 1 ^ 1)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF_32 = (1 << 30) - 1;
const ll INF_64 = (1LL << 62) - 1;
const int MOD = 1e9 + 7;

ull next_subset(ull s){
	ull tem = s + (s & -s);
	ull btm = (~tem & s) / (s & -s) >> 1;
	return btm | tem;
}


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

	int n,a[100002],b[100002],c,d,m; cin>>n>>m;
	pair<int,int> p[100002];
	rep(i,m){
		cin>>p[i].fir>>p[i].sec;
	}
	sort(p,p + m);
	int r,i = 0,ans = 0;
	while(i < m){
		r = p[i++].sec;
		while(i < m and r > p[i].fir){
			r = min(r,p[i++].sec);
		}
		++ans;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
///HELLO THERE~!
///CREATED BY MD SADMAN MEHEDI SIVAN(IUT CSE[SWE'19])

#include<bits/stdc++.h>
using namespace std;

#define FASTIO          ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define READ            freopen("input.txt","r",stdin);
#define WRITE           freopen("red.txt","w",stdout);

using ll=long long;
using ull=unsigned long long;
const double pi = 2*acos(0.0);
const long long MX = 2e5+7;
vector<long long>v(1000008,1e11);
int main()
{

    FASTIO;

    ll n;
    cin>>n;

    for(ll i=0;i<3*n;i++)
    {
        ll x;
        cin>>x;
        v[i]=x;
    }

    sort(v.begin(),v.end());

    ll sum=0;
    ll count=0;
    for(ll i=3*n-2;;i-=2)
    {
        count++;
        sum+=v[i];
        if(count==n)
            break;
    }


    cout<<sum;

}


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

#define ll long long
#define mod 1000000007

using namespace std;



int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;vector<ll>v[100005];
    cin>>n>>m;map<ll,ll>pos;
    ll p[m+1],y[m+1];
    for(int i=1;i<=m;i++){
        cin>>p[i]>>y[i];
        v[p[i]].push_back(y[i]);
    }
    for(int i=1;i<=n;i++){
        sort(v[i].begin(),v[i].end());
        for(int j=0;j<v[i].size();j++){
            pos[v[i][j]]=j+1;
        }
    }
    for(int i=1;i<=m;i++){
        if(p[i]>=0&&p[i]<=9){cout<<"00000"<<p[i];}
        else if(p[i]>=10&&p[i]<=99){cout<<"0000"<<p[i];}
        else if(p[i]>=100&&p[i]<=999){cout<<"000"<<p[i];}
        else if(p[i]>=1000&&p[i]<=9999){cout<<"00"<<p[i];}
        else if(p[i]>=10000&&p[i]<=99999){cout<<"0"<<p[i];}
        else if(p[i]>=100000&&p[i]<=999999){cout<<p[i];}
        if(pos[y[i]]>=0&&pos[y[i]]<=9){cout<<"00000"<<pos[y[i]];}
        else if(pos[y[i]]>=10&&pos[y[i]]<=99){cout<<"0000"<<pos[y[i]];}
        else if(pos[y[i]]>=100&&pos[y[i]]<=999){cout<<"000"<<pos[y[i]];}
        else if(pos[y[i]]>=1000&&pos[y[i]]<=9999){cout<<"00"<<pos[y[i]];}
        else if(pos[y[i]]>=10000&&pos[y[i]]<=99999){cout<<"0"<<pos[y[i]];}
        else if(pos[y[i]]>=100000&&pos[y[i]]<=999999){cout<<pos[y[i]];}
        cout<<endl;
    }
}


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

#define N 10	// üHÌ

int main()
{
	double l[N], v[2];
	double sum[N];
	double position;
	int i;

	while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&v[0],&v[1]) != EOF) {
		sum[0] = l[0];
		for (i = 1; i < N; i++)
			sum[i] = sum[i-1]+l[i];
		position = v[0] * sum[9] / (v[0]+v[1]);
		for (i = 0; i < N; i++)
			if (sum[i]>=position)
				break;
		i++;

		cout<<i<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
# -*- conding: utf-8 -*-
import math
K = int(input())

ans = 0
for a in range(1, K+1):
  for b in range(1, K+1):
    x = math.gcd(a, b)  
    for c in range(1, K+1):
      ans += math.gcd(x, c)
print(ans)

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

#define ll long long
#define ar array

const int mxN=2e5;
int n, m;
ll k, a[mxN+1], b[mxN+1];

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

	cin >> n >> m >> k;
	for(int i=0; i<n; ++i) {
		cin >> a[i+1];
		a[i+1]+=a[i];
	}
	for(int i=0; i<m; ++i) {
		cin >> b[i+1];
		b[i+1]+=b[i];
	}
	int ans=0;
	for(int i=0, j=m; i<=n; ++i) {
		if(a[i]>k)
			break;
		while(a[i]+b[j]>k)
			--j;
		ans=max(i+j, ans);
	}
	cout << ans;
}

Measured memory_bytes: 6776
//94A
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int A, B, X =0;
    cin >> A >> B >> X;
    if (A<=X){
        if (B>=(X-A)){
            cout << "YES";
        }else{
            cout << "NO";
        }
    }else{
        cout << "NO";
    }
  
}

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

using namespace std;

long long solve(int n, int w, int a[100000][2]){
	long long dp[n+1][w+1];
	for(int i=0; i<=n; i++){
		for(int j=0; j<=w; j++){
			if(i==0 || j==0)
				dp[i][j]=0;
			else if(a[i-1][0] <=j)
				dp[i][j] = max((a[i-1][1] + dp[i-1][j-a[i-1][0]]), dp[i-1][j]);
			else 
				dp[i][j]= dp[i-1][j];
		}
	}
	// for(int i=0; i<n+1; i++){
	// 	for(int j=0; j<w+1; j++){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	return dp[n][w];
	
	
}

int main() {
	int n,w;
	cin>>n>>w;
	int a[n][2];
	for(int i=0; i<n; i++)
		for(int j=0; j<2; j++)
			cin>>a[i][j];
			
	long long ans= solve(n,w,a);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 79104
from collections import deque
N,u,v=map(int,input().split())
u-=1;v-=1
G=[[] for i in range(N)]
for i in range(N-1):
    a,b=map(int,input().split())
    a-=1;b-=1
    G[a].append(b)
    G[b].append(a)
if len(G[u])==1 and G[u][0]==v:
    print(0)
    exit()
distu=[-1 for i in range(N)]
q=deque([])
q.append(u)
while(len(q)>0):
    r=q.pop()
    for p in G[r]:
        if distu[p]!=-1:
            continue
        distu[p]=distu[r]+1
        q.append(p)
distv=[-1 for i in range(N)]
q=deque([])
q.append(v)
while(len(q)>0):
    r=q.pop()
    for p in G[r]:
        if distv[p]!=-1:
            continue
        distv[p]=distv[r]+1
        q.append(p)
dist=[distv[i] if distu[i]<=distv[i] else 0 for i in range(N)]
print(max(dist))


Measured memory_bytes: 30304
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll a[2005];
void pre(){
    a[0]=a[1]=a[2]=1;
    for(int i=3;i<=2000;i++) a[i]=(a[i-3]+a[i-1])%mod;
}
int main()
{
    pre();
    int n;
    cin>>n;
    if(n<3) cout<<0;
    else cout<<a[n-3];
    return 0;
}


Measured memory_bytes: 3656
import sys
N, M = map(int, input().split())
X = sorted(list(map(int, input().split())))
div = [0]*(M-1)
for i in range(M-1):
    div[i] = abs(X[i+1] - X[i])
div = sorted(div,reverse=True)
ans = X[-1] - X[0]
if N >= M:
    print(0)
    sys.exit(0)
ans -= sum(div[:N-1])
print(ans)

Measured memory_bytes: 53928
#include<iostream>
#include <algorithm>
#include <string>
using namespace std;
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
typedef long long ll;
const int INF = numeric_limits<int>::max();
const int MOD = (1e9 + 7);

int main(){
  string S, T;
  bool can = true;
  cin >> S >> T;
  int a[30] = {0}; int b[30] = {0};
  int N = S.size();
  rep(i, N){
    a[S[i] - 'a']++;
    b[T[i] - 'a']++;
  }
  sort(a, a+30); sort(b, b+30);
  rep(i, 30){
    if(a[i] != b[i]) can = false;
  }
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define clr(a, b) memset(a, b, sizeof(a))
#define Error(x) cout << #x << " = " << x << endl
#define iDEBUG freopen("in.txt", "r", stdin)
#define oDEBUG freopen("output.txt","w",stdout)
#define pb push_back
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define MP make_pair
#define hi cout<<"hi\n"
typedef long long ll;

using namespace std;
int gcd(int m, int n) { if((0 == m) || (0 == n)){return 0;} while(m != n){ if(m > n){m -= n;}else{n -= m;} } return m; }
int lcm(int m, int n) { if((0 == m) || (0 == n)){return 0;} return (m / gcd(m, n)) * n; }

int main()
{
    //iDEBUG; //oDEBUG;
    int n, a, b;
    cin >> n;
    vector<pair<int,int> > red(n),blue(n);
 
    for(int i=0; i<n; i++){
        cin >> a >> b;
        red[i] = MP(b,a);
    }
    for(int i=0; i<n; i++){
        cin >> a >> b;
        blue[i] = MP(a,b);
    }
    sort(all(red));
    sort(all(blue));

    vector<int> v(n);
    int idx, ans=0;
    for(int i=0; i<n; i++){
        bool find=false;
        for(int j=0; j<n; j++){
            if(red[j].y<blue[i].x && red[j].x<blue[i].y){
                if(!v[j]){
                    find=true;
                    idx=j;
                }
            }
        }
        if(find){
            ans++;
            v[idx] = 1;
        }
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner in = new Scanner(System.in);

	int taro=0,hanako=0;
	int n = in.nextInt();
	String taro_str,hanako_str;
	int x;
	for(int i=0;i<n;i++){
	    taro_str = in.next();
	    hanako_str = in.next();

	    
	    x=taro_str.compareTo(hanako_str);
	    if(x<0)hanako+=3;
	    else if(x>0)taro+=3;
	    else {
		hanako++;
		taro++;
	    }

	}
	System.out.println(taro + " " + hanako);

    }
}
	


Measured memory_bytes: 30020
#include<stdio.h>

int main(void)
{
   int n,x,i,a[100],s,t;

   scanf("%d %d",&n,&x);

   for(i=0;i<n;i++){
      scanf("%d",&a[i]);
   }

   s=0;
   i=0;
   while(s<=x){
     s=s+a[i];
     i++;
   }

   printf("%d\n",i);

   return 0;
}

Measured memory_bytes: 128
@cnt = 0
def merge(a, left, right)
  left.upto(right-1) do |k|
    @cnt += 1
  end
end

def merge_sort(a, left, right)
  if left + 1 < right
    mid = (left + right) / 2
    merge_sort(a, left, mid)
    merge_sort(a, mid, right)
    merge(a, left, right)
  end
end

n = gets.to_i
nums = gets.split.map(&:to_i)
merge_sort(nums, 0, n)
puts nums.sort * ' '
puts @cnt



Measured memory_bytes: 54256
import Control.Applicative
import Control.Monad
main = solve

solve = do
    ns <- fmap (read :: String -> Int) . words <$> getLine
    let h = ns !! 0
        w = ns !! 1
    drawRectangle h w

drawRectangle :: Int -> Int -> IO ()
drawRectangle h w
    | h == 0 && w == 0 = return ()
    | otherwise = do
        mapM_ (\_ -> putStrLn $ replicate w '#') [1..h]
        putStrLn ""
        solve

Measured memory_bytes: 4104