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

#pragma region template


// -type-
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;


// -const-
const ll MOD = 1000000007;


const ll MAX = (ll)0x3f0000003f000000;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1},
          dy[] = {1, 0, -1, 0, 1, -1, -1, 1};


// -define-
#define F first
#define S second

#define reps(i, k, n) for (int i = (k), i##_len = (n); i < i##_len; ++i)
#define rep(i, n) reps(i, 0, n)
#define all(o) begin(o), end(o)
#define sz(a) ((int)(a).size())
#define debug(x) cerr << x << " (L:" << __LINE__ << ")" << '\n';


// -functions-

inline bool in(string s, string c) {
    return (s.find(c) != string::npos);
}
inline bool in(string s, char c) {
    return (s.find(c) != string::npos);
}

template <class T>
void print(T& x) {
    cout << x << '\n';
}

struct setup_main {
    setup_main() {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(15);
    }
} setup_main_;

#pragma endregion

ll m = 0;
unordered_map<string, int> dic{};
vs ans(0, "");
void solve(long long N, std::vector<std::string> S) {
    for (auto&& str : S) {
        if (dic.count(str) == 0) dic.emplace(str, 0);
        dic[str]++;
    }
    for (auto i : dic) {
        // print(i.first);
        if (i.second > m) {
            ans = {};
            m = i.second;
        }
        if (i.second >= m) {
            ans.push_back(i.first);
        }
    }
    sort(all(ans));
    for (auto& ss : ans) {
        print(ss);
    }
}
signed main() {
    long long N;
    cin >> N;
    std::vector<std::string> S(N);
    for (int i = 0; i < N; i++) {
        std::cin >> S[i];
    }
    solve(N, std::move(S));

    return 0;
}


Measured memory_bytes: 26948
#define SORT(v) sort(v.begin(), v.end())
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <algorithm>
#include <cstdarg>
#include <cstdio>
#include <numeric>

// #include "ane.cpp"

#define INF (int)1e9
#define INFLL (long long)1e18
#define NMAX 200
#define MMAX 200
#define MOD 100000
using namespace std;

// コメントアウトするとdb_printf()を実行しない
#define DEBUG

//
//  ライブラリ
//

// よく使う型のエイリアス
typedef pair<int, int> p;
typedef long long ll;

// よく使う定数[配列]
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// デバッグ用printf
void db_printf(const char* format, ...){
    #ifndef DEBUG
    return;
    #endif
    va_list arg;
    va_start(arg, format);
    vprintf(format, arg);  // コンソールに出力
    va_end(arg);
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// Union-Find Tree
class UnionFindTree{
    struct node{
        int par;
    };
    std::vector<node> T;

    public:
    void init(int num){
        T.resize(num+1);    // ignore T[0]
        for (int i = 1; i <= num; ++i)
        {
            T[i].par = i;
        }
    }
    void unite(int x, int y){
        T[find(y)].par = find(x);
    }
    int find(int x){
        if (T[x].par == x) return x;
        else return T[x].par = find(T[x].par);
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
};

//
// ライブラリ終了
//


ll N,M,K,A,B,C,D,E;
vector<int> dp[26];
string s;
ll ans = 0;

void solve(){
    for (int i = 1; i <= s.size(); ++i)
    {
        int index = s[i-1] - 'a';
        dp[index].push_back(i);
    }
    for (int i = 0; i < 26; ++i)
    {
        for (int j = 1; j < dp[i].size(); ++j)
        {
            if (dp[i][j] - dp[i][j-1] <= 2)
            {
                printf("%d %d\n", dp[i][j-1], dp[i][j]);
                return;
            }
        }
    }
    cout << "-1 -1\n";

}
void debug(){
    // デバッグ用出力
}
void answer(){
    // 解答出力
    // printf("%lld\n", ans);
}
int main(int argc, char const *argv[])
{
    // 入力の読み込み，番兵法

    // Fill(dp, -1);
    cin >> s;
    solve();
    #ifdef DEBUG
    debug();
    #endif
    answer();

    return 0;
}

Measured memory_bytes: 1088
N, M = map(int, input().split())
A = list(map(int, input().split()))

B = []
C = []
BC = []

A.sort()

for i in range(M):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)
    BC.append([b, c])


BC = sorted(BC, key=lambda x: x[1])
BC = BC[::-1]
C = C.sort()

# print(A)
# print(BC)

buff = []
counter = 0
for i in range(M):
    if counter > N*2:
        break
    for j in range(BC[i][0]):
        buff.append(BC[i][1])
        counter += 1
        if counter > N*2:
            break

A = A + buff
A.sort()
A = A[::-1]
print(sum(A[:N]))

Measured memory_bytes: 33644
#include <iostream>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;

int main(){
    long long n, p;
    cin >> n >> p;

    long long num = p;
    map<long long, long long> T;

    for(long long i = 2; i*i <= p; i++){
        if(num % i != 0){
            continue;
        }

        long long count = 0;
        while(num % i == 0){
            count++;
            num /= i;
        }
        T[i] = count;
    }
    if(num != 1){
        T[num] = 1;
    }

    map<long long, long long>::iterator it;
    long long gcd = 1;
    for(it = T.begin(); it != T.end(); it++){
        //printf("it->first %lld it->second %lld\n", it->first, it->second);
        if(it->second >= n){
            gcd *= pow(it->first, it->second/n);
        }
    }

    cout << gcd << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<P,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
ll dp[22][1<<21]={};
int n;
ll a[21][21];
ll reg(int m,int s){
	if(dp[m][s]!=-1)return dp[m][s];
	if(m==n)return 1;
	ll res=0;
	rep(i,0,n){
		if(!((s>>i)&1)&&a[m][i]){
			res+=reg(m+1,s|(1<<i));
			res%=r197;
		}
	}
//	cout<<m<<" "<<s<<" "<<res<<endl;
	return dp[m][s]=res;
}

int main() {
	memset(dp,-1,sizeof(dp));
	cin>>n;
	rep(i,0,n){
		rep(j,0,n)cin>>a[i][j];
	}
	cout<<reg(0,0)<<endl;
	return 0;
}


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

using namespace std;

int main(void){
	string S;
	cin >> S;
	int w = 0;
	for(int i=0;i<S.size();i++){
		if(S[i]=='o')w++;
	}
	int l = 15 - S.size();
	if(l+w>=8){
		cout << "YES" << endl;
	}else cout << "NO" <<endl;
}

Measured memory_bytes: 256
// Name: Kanisht Agarwal Copyright Think before u copy //
//Connect with me at LinkedIn

#include <bits/stdc++.h>
#define mod 1000000007
#define ull unsigned ll
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi acos(-1)
#define nui 100
#define INF 100000000000

#define F(i,a,n) for(ll i=a;i<n;i++)
#define B(i,a,n) for(ll i=n-1;i>=a;i--)
#define tc int t;cin>>t;while(t--)
#define tcf int t;cin>>t;for(int w=1;w<=t;w++)



using namespace std;


ll binpow(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1)
        {
            res *= a;
        }
        a *= a;
        b >>= 1;
    }
    return res;
}

ll fermat_inv(ll y) {return binpow(y, mod - 2);}

ll cal(int n)
{
    ll ct = 0;
    for (int i = 1; i <= sqrt(n); i++)
    {
        if (n % i == 0)
        {
            if ((n / i) != i)
            {
                ct += 2;
            }
            else
            {
                ct++;
            }
        }
    }
    return ct;
}

int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //Problem A:

    int n, m, k;
    cin >> n >> m >> k;
    ll ans = 0;
    int a[n], b[m];
    F(i, 0, n)
    {
        cin >> a[i];
    }
    F(i, 0, m)
    {
        cin >> b[i];
    }
    vector<ll>va(n + 1, 0);
    vector<ll>vb(m + 1, 0);

    F(i, 1, n + 1)
    {
        va[i] = (a[i - 1] + va[i - 1]);
    }
    F(i, 1, m + 1)
    {
        vb[i] = (b[i - 1] + vb[i - 1]);
    }
    /*for (auto i : vb)
    {
        cout << i << " ";
    }
    cout << "\n";
    for (auto i : va)
    {
        cout << i << " ";
    }*/
    ll j = m;
    F(i, 0, n + 1)
    {
        if (va[i] > k)
            break;
        while (vb[j] > k - va[i])
            j--;
        ans = max(ans, i + j);
    }
    cout << ans << "\n";

    return 0;


}







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

namespace ABC160
{
    class A
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            if (s[2] == s[3] && s[4] == s[5]) Console.WriteLine("Yes");
            else Console.WriteLine("No");


        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
	string s,ss="";
	int k=0;
	cin >> s;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='B')
		{
			k--;
			if(k<0)
			k=0;
		}
		else
		ss[k++]=s[i];
	}
	for(int i=0;i<k;i++)
	cout << ss[i];
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<climits>
#include<algorithm>
#include<numeric>
#include<iomanip>
#include<map>
#include<set>
#include<random>
#include<cassert>
using namespace std;
#define ll long long int
#define ld long double
const ll Mod = 1000000007;
ll CaseN=1;
const ld PI = 22/7.0;

bool mycmp(string s,string t)
{
if(s.size()<t.size())
{
return true;	
}		
return false;
}


void solve()
{
 
  ll a,b,c;
  bool ans=false;
 cin>>a>>b>>c; 
  if(a+b==c || b+c==a || c+a==b)
  ans = true;
  
  	
	 if(ans)
  {
  cout<<"Yes"<<endl; 
  }
  else
   {
  cout<<"No"<<endl;
  }
 
 
 // cout<<"Case #"<<CaseN<<": ";
   CaseN++;
	// print your ans below;
    
return ;
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)
	{
	solve();	
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int x1, y1, x2, y2;
	cin>>x1>>y1>>x2>>y2;
	int h = y2 - y1;
	int w = x2 - x1;
	for(int i = 0; i < h; i++)
	{
		cout<<"U";
	}
	for(int i = 0; i < w; i++)
	{
		cout<<"R";
	}
	for(int i = 0; i < h; i++)
	{
		cout<<"D";
	}
	for(int i = 0; i < w; i++)
	{
		cout<<"L";
	}
	cout<<"D";
	for(int i = 0; i < w + 1; i++)
	{
		cout<<"R";
	}
	for(int i = 0; i < h + 1; i++)
	{
		cout<<"U";
	}
	cout<<"L";
	cout<<"U";
	for(int i = 0; i < w + 1; i++)
	{
		cout<<"L";
	}
	for(int i = 0; i < h + 1; i++)
	{
		cout<<"D";
	}
	cout<<"R";
	cout<<'\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define fo(i,n) for(int i=0;i<n;i++)
#define eb emplace_back
#define M 1000000007
#define vi vector<int>
#define vlli vector<lli>
#define pi pair<int,int>
#define mp make_pair
#define mapi map<int,int>
int main()
{
  //ios_base::sync_with_stdio(false);
  //cin.tie(NULL);
	int n;
	cin>>n;
	int num,cnt=0;
	for(int i=1;i<=n;i++){
		cin>>num;
		if(i%2!=0 && num%2!=0) cnt++;
	}
	cout<<cnt<<"\n";
	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int ar[100010], N, dp[100010], ans;
int solve(int ind)
{
    if(ind==N-1)
        return 0;
    if(dp[ind]!=-1)
        return dp[ind];
    int ans = solve(ind+1)+abs(ar[ind+1]-ar[ind]);
    if(ind+2<N)
        ans = min(ans,solve(ind+2)+abs(ar[ind+2]-ar[ind]));
    return dp[ind] = ans;
}
int main()
{
    cin >> N;
    memset(dp, -1, sizeof(dp));
    for(int i=0;i<N;i++)
        cin >> ar[i];
    cout << solve(0) << endl;
    return 0;
}


Measured memory_bytes: 9104
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin,(x).end()
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
	int a; cin >> a;
	int b; cin >> b;
	int loop_max = max(a, b);
	repn(i, loop_max) {
		if (abs(a - i) == abs(b - i)) {
			cout << i << endl;
			return;
		}
	}
	cout << "IMPOSSIBLE" << endl;
    return;
}

int main() {
    solve();
    return 0;
}



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

int main() {
    int a[100];
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = n - 1; i >= 0; i--) {
        cout << a[i];
        if (i > 0) {
            cout << " ";
        }
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 3120
#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)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

struct node{
    int l,r;
};
node v[26];
bool nroot[26];
vector<int> preord,inord,postord;
void dfs(int vi){
    preord.pb(vi);
    if(v[vi].l!=-1)dfs(v[vi].l);
    inord.pb(vi);
    if(v[vi].r!=-1)dfs(v[vi].r);
    postord.pb(vi);

}
int main(){
    int n;
    cin>>n;
    int id,l,r,root;
    rep(i,n){
        cin>>id>>l>>r;
        v[id].l=l,v[id].r=r;
        if(l!=-1) nroot[l]=true;
        if(r!=-1) nroot[r]=true;
    }
    rep(i,n)if(!nroot[i]) root=i;
    dfs(root);
    cout<<"Preorder"<<endl;
    rep(i,n) cout<<" "<<preord[i];
    cout<<endl;
    cout<<"Inorder"<<endl;
    rep(i,n) cout<<" "<<inord[i];
    cout<<endl;
    cout<<"Postorder"<<endl;
    rep(i,n) cout<<" "<<postord[i];
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3172
#include<stdio.h>

int main(void)
{
	int N, M;
	scanf("%d%d", &N, &M);
	int A[N], i;
	double sum = 0;
	for (i = 0; i < N; i++) {
		scanf("%d",& A[i]);
		sum += A[i];
	}
	int flag = 0;
	for (i = 0; i < N; i++) {
		if (A[i] >= sum/4/M) flag++;
	}
	if (flag >= M) printf("Yes");
	else printf("No");

	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		if ("SUN".equals(s)) {
			System.out.println(7);
		} else if ("MON".equals(s)) {
			System.out.println(6);
		} else if ("TUE".equals(s)) {
			System.out.println(5);
		} else if ("WED".equals(s)) {
			System.out.println(4);
		} else if ("THU".equals(s)) {
			System.out.println(3);
		} else if ("FRI".equals(s)) {
			System.out.println(2);
		} else if ("SAT".equals(s)) {
			System.out.println(1);
		}
	}
}


Measured memory_bytes: 21716
fun main(args: Array<String>) {

    val points = readLine()?.split(" ").orEmpty()
    val pointS = Pair(points[0].toInt(), points[1].toInt())
    val pointT = Pair(points[2].toInt(), points[3].toInt())

    val distX = Math.abs(pointS.first - pointT.first)
    val distY = Math.abs(pointS.second - pointT.second)

    var pathF1 = ""
    var pathB1 = ""
    var pathF2 = ""
    var pathB2 = ""

    for(i in 1 .. distX) {
        pathF1 += "R"
        pathF2 += "R"
        pathB1 += "L"
        pathB2 += "L"
    }
    for (i in 1 .. distY){
        pathF1 += "U"
        pathF2 = "U$pathF2"
        pathB1 += "D"
        pathB2 = "D$pathB2"
    }

    println(pathF1 + pathB1 + "LU" + pathF2 + "RD" + "RD" + pathB2 + "LU")


}

Measured memory_bytes: 100540
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N; i >= 0; i--)
const ll INF = 1000000000;
const ll mod = 1000000007;
#define PI 3.1415926535
using Graph = vector<vector<int>>;
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;}
bool seen[100000];
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする
 
    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

//dpTable
int dp[100050];

int ans;

int main(){
    string S;
    cin >> S;
    if (S.at(0) == '1') ans++;
    if (S.at(1) == '1') ans++;
    if (S.at(2) == '1') ans++;
    if (S.at(3) == '1') ans++;
    if (S.at(4) == '1') ans++;
    if (S.at(5) == '1') ans++;
    cout << ans << endl;
    return 0;
}

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

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	while ((b != 0) && (d != 0))
	{
		c -= b;
		if (c <= 0)
		{
			cout << "Yes" << endl;
			return 0;
		}

		a -= d;
		if (a <= 0)
		{
			cout << "No" << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <algorithm>
using i64 = long long;

int main() {
    std::string s;
    std::cin >> s;
    std::cout << (std::find(s.begin(), s.end(), '7') != s.end() ? "Yes\n" : "No\n");

    return 0;
}


Measured memory_bytes: 3584
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = getLine >>= putStrLn . take 3

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  string s;
  cin >> s;
  if(s == "AAA" || s == "BBB") cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
def rec(n, current)
  if @dp[current] != -1
    return @dp[current]
  end

  if current == n
    1
  elsif current > n
    0
  else
    @dp[current] = rec(n, current + 1) + rec(n, current + 2) + rec(n, current + 3)
  end
end

def solve(n)
  @dp = Array.new(34, -1)
  sum = rec(n, 0)
  result = ( (sum / 10) + 365 ) / 365
end

def main
  STDIN.each_line{|line|
    n = line.to_i
    if n == 0
      break
    end
    puts solve n
  }
end

main

Measured memory_bytes: 6840
function runLengthEncoding(S)
    D = Tuple{Char, Int}[]
    push!(D, (S[1], 0))
    for s in S
        if D[end][1]==s
            D[end] = (D[end][1], D[end][2] + 1)
        else
            push!(D, (s, 1))
        end
    end
    return D
end
function GatheringChildren()
    S = readline()
    N = length(S)
    RL = runLengthEncoding(S)
    ans = zeros(Int, N)
    now = RL[1][2]
    now_idx = 1
    for n in 1:N
        if n == now
            num1 = RL[now_idx][2]
            num2 = RL[now_idx+1][2]
            re = num1 ÷ 2
            ro = num1 - re
            le = num2 ÷ 2
            lo = num2 - le
            ans[now] = ro + le
            ans[now+1] = re + lo
            if now_idx ≤ length(RL) - 2
                now_idx += 2
                now += RL[now_idx-1][2] + RL[now_idx][2]
            else
                break
            end 
        end
    end
    for a in ans
        print(a," ")
    end
end
GatheringChildren()

Measured memory_bytes: 180364
n, y = map(int, input().split())
# print(n, y)
str = None
for i in range(n+1):
    for j in range(n+1-i):
        # 1000i + 5000j + 10000k =
        # print(i, j)
        k = n-i-j
        if 10000 * i + 5000 * j + 1000 * k == y:
            str = '{} {} {}'.format(i, j, k)
if str is None:
    print(-1,-1,-1)
else:
    print(str)

Measured memory_bytes: 40812
#define		_CRT_SECURE_NO_WARNINGS

#include <cstdio>

#define		MAX		10000

int main()
{
	int		n;

	for (int i = 0; i < MAX; i++)
	{
		scanf("%d", &n);
		if (n == 0) break;
		printf("Case %d: %d\n", i + 1, n);
	}

	return 0;
}

Measured memory_bytes: 2700
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()

int main(){
  ll h, a;
  cin >> h >> a;
  if(h%a==0){
    cout << h / a << endl;
  }
  else{
    cout << 1 + h / a << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int n=sc.nextInt(),k=sc.nextInt(),sum=0;
    int[] x=new int[n];
    for(int i=0;i<n;i++){
      x[i]=sc.nextInt();
      sum+=2*(int)Math.min(x[i],k-x[i]);
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 21716
a, b = map(int, input().split())
if a == b:
    print(a)
else:
    if a % 2 == 0 and b % 2 == 1:
        if (b-a+1) % 4 == 0:
            print(0)
        else:
            print(1)
    elif a % 2 == 0 and b % 2 == 0:
        if (b-a) % 4 == 0:
            print(b)
        else:
            print(b^1)
    elif a % 2 == 1 and b % 2 == 1:
        if (b-a) % 4 == 0:
            print(a)
        else:
            print(a^1)
    elif a % 2 == 1 and b % 2 == 0:
        if (b-a-1) % 4 == 0:
            print(a^b)
        else:
            print((a^b)^1)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
         
using namespace std;
 
#define ll  long long
#define mod 1000000007
#define pb push_back
#define pie 3.141592653589



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

   
    ll i,n,n2,m,t,j,l,r,pos,mpos,f=0,k,p,n1,z,q,x,y,x1,y1,x2,y2,x3,y3,x4,y4;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    vector<ll> dp(n,0);
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(i=2;i<n;i++)
       dp[i]= min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
        
    cout<<dp[n-1];



  return 0;
}

Measured memory_bytes: 1792
miis=lambda:map(int,input().split())

h,w,a,b=miis()
ans=[]
for i in range(b):
  ans.append(['1']*a+['0']*(w-a))
for i in range(h-b):
  ans.append(['0']*a+['1']*(w-a))
for i in ans:
  print(''.join(i))

Measured memory_bytes: 11892
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define vv(T) std::vector<std::vector<T>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

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

	vector<ll> A(n);
	for (int i = 0; i < n; ++i)
		cin >> A[i];
	sort(rall(A));
	ll ans = A[0];
	int j = 1, count = 0;
	for (int i = 2; i < n; ++i)
	{
		ans += A[j];
		++count;
		if (count == 2)
		{
			++j;
			count = 0;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 4820
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define st(vvv) sort(vvv.begin(),vvv.end())
#define rvs(vvv) reverse(vvv.begin(),vvv.end())
int inf = 1000000007;
i64 giant = 4000000000000000000;

using namespace std;

int main() {
	int n;
	cin >> n;
	int ans = 0;
	ff(i, 1, n+1) {
		string a = to_string(i);
		if (a.size() % 2 == 1)ans++;
	}
	cout << ans << endl;
	return 0;
}

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

typedef unsigned long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;

#define INF (int)(1e9)

#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,start,end) for(int i=(start);i<=(end);i++)
#define all(n) begin(n),end(n)

#define DEBUG

int main()
{
	int a, b;
	cin >> a >> b;
	int ans = 6;
	ans -= (a+b);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <utility>

#define DEBUG 0
#define lli long long int

lli max(lli a,lli b){
	return a>=b ? a:b;
}

using namespace std;

int main(){

	lli n,a,b;
	cin >>n>>a>>b;

	lli minAns=0;
	lli maxAns=0;

	if(a==b){
		cout<<1<<endl;
	}else if(a>b){
		cout<<0<<endl;
	}else if(n==1){
		cout<<0<<endl;
	}else if(n==2){
		cout<<1<<endl;
	}else{
		minAns=a+b+a*(n-2);
		maxAns=a+b+b*(n-2);
		cout<<maxAns-minAns+1<<endl;
	}


	return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <algorithm>
#include <string.h>
#include <memory.h>

using namespace std;

typedef long long ll;
int const N = 1e2 + 1, oo = 2e9 + 1;
int n, m, q, k, a[N];
vector<vector<int> > g;

int main() {
	string s;
	cin >> s;
	for(int i = 0; i < s.length(); ++i)
		if(i % 2 == 0)
			cout << s[i];
	cout << endl;

    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


enum DIR{
	North,
	East,
	South,
	West,
};

struct Info{
	Info(int arg_row,int arg_col,int arg_sum_cost,DIR arg_dir){
		row = arg_row;
		col = arg_col;
		sum_cost = arg_sum_cost;
		dir = arg_dir;
	}
	int row,col,sum_cost;
	DIR dir;
};

int H,W;
int min_dist[26];
int diff_row[4] = {-1,0,0,1},diff_col[4] = {0,-1,1,0};
char table[50][51],start[2],goal[2];
DIR dir_array[4] = {North,West,East,South};

bool rangeCheck(int row,int col){
	if(row >= 0 && row <= H-1 && col >= 0 && col <= W-1)return true;
	else{
		return false;
	}
}


int main(){

	scanf("%d %d %s %s",&H,&W,start,goal);

	int start_row,start_col;
	for(int row = 0; row < H; row++){
		scanf("%s",table[row]);
		for(int col = 0; col < W; col++){
			if(table[row][col] == start[0]){
				start_row = row;
				start_col = col;
			}
		}
	}

	for(int i = 0; i < 26; i++)min_dist[i] = BIG_NUM;

	queue<Info> Q;
	min_dist[start[0]-'A'] = 0;

	for(int i = 0; i < 4; i++){
		Q.push(Info(start_row,start_col,0,dir_array[i]));
	}

	int adj_row,adj_col;

	while(!Q.empty()){

		if(table[Q.front().row][Q.front().col] == goal[0]){
			Q.pop();
		}else{

			for(int i = 0; i < 4; i++){

				if(Q.front().dir != dir_array[i])continue; //方向が同じでなければSKIP

				adj_row = Q.front().row+diff_row[i];
				adj_col = Q.front().col+diff_col[i];

				if(rangeCheck(adj_row,adj_col) == false || table[adj_row][adj_col] == '.')continue;
				if(Q.front().dir == North || Q.front().dir == South){
					//printf("縦 adj_row:%d adj_col:%d\n",adj_row,adj_col);
					if(table[adj_row][adj_col] == '-')continue;

				}else{
					//printf("縦 adj_col:%d adj_row:%d\n",adj_row,adj_col);
					if(table[adj_row][adj_col] == '|')continue;
				}

				if(table[adj_row][adj_col] >= 'A' && table[adj_row][adj_col] <= 'Z'){ //ノードに到着
					if(min_dist[table[adj_row][adj_col]-'A'] <= Q.front().sum_cost+1)continue;
					min_dist[table[adj_row][adj_col]-'A'] = Q.front().sum_cost+1;

					for(int k = 0; k < 4; k++){ //方向転換
						Q.push(Info(adj_row,adj_col,min_dist[table[adj_row][adj_col]-'A'],dir_array[k]));
					}

				}else{
					Q.push(Info(adj_row,adj_col,Q.front().sum_cost,Q.front().dir));
				}
			}

			Q.pop();
		}
	}

	printf("%d\n",min_dist[goal[0]-'A']);

	return 0;
}



Measured memory_bytes: 3272
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#define int long long
#define endl '\n'
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U b) { if (a > b) { a = b; return true; } return false; }

constexpr ll mod = 998244353;

template<class T> class segtree {
	int n;
	vector<T> data;
	T id;
	function<T(T, T)> operation;
	function<T(T, T)> update;
public:
	segtree(size_t _n, T _id, function<T(T, T)> _operation, function<T(T, T)> _update)
		:id(_id), operation(_operation), update(_update) {
		n = 1;
		while (n < _n + 2) {
			n *= 2;
		}
		data = vector<T>(2 * n, id);
	}
	void change(int i, T x) {
		i += n;
		data[i] = update(data[i], x);
		while (i > 1) {
			i >>= 1;
			data[i] = operation(data[i << 1], data[i << 1 | 1]);
		}
	}
	T get(int a, int b) {
		T left = id; T right = id;
		a += n; b += n;
		while (a < b) {
			if (a & 1) left = operation(left, data[a++]);
			if (b & 1) right = operation(data[--b], right);
			a >>= 1; b >>= 1;
		}
		return operation(left, right);
	}
	T get_all() { return data[1]; }
	T operator[](int i) { return data[i + n]; }
};

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

	int n;
	cin >> n;
	vector<int> x(n), d(n), y(n);
	vector<P> p(n);
	rep(i, n) {
		cin >> x[i] >> d[i];
		y[i] = x[i] + d[i];
		p[i].first = x[i];
		p[i].second = y[i];
	}
	sort(all(p));
	rep(i, n) {
		x[i] = p[i].first;
		y[i] = p[i].second;
	}
	p.pb(P(INF, INF));
	vector<int> use(n);
	for (int i = 0; i < n; i++) {
		int g = lower_bound(all(x), y[i]) - x.begin();
		use[i] = g - 1;
	}
	segtree<int> seg(n + 2, 0, [](int a, int b) {return max(a, b); }, [](int a, int b) {return b; });
	rep(i, n) seg.change(i, use[i]);
	for (int i = n - 1; i >= 0; i--) {
		int maxv = seg.get(i, seg[i] + 1);
		seg.change(i, maxv);
	}
	vector<int> dp(n + 1);
	dp[n] = 1;
	for (int i = n - 1; i >= 0; i--) {
		dp[i] = dp[i + 1] + dp[seg[i] + 1];
		dp[i] %= mod;
	}
	cout << dp[0] << endl;
}

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

typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

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

  int cnt = 0;
  int maxv = 0;
  for (int i = 1; i < n; i++) {
    if (l[i - 1] >= l[i]) {
      cnt++;
    } else {
      maxv = max(maxv, cnt);
      cnt = 0;
    }
  }
  maxv = max(maxv, cnt);
  cout << maxv << endl;
  return 0;
}


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

using namespace std;

typedef long long int ll;

ll gcd(ll x, ll y)
{
    if (x == 0)
        return y;

    if (y == 0)
        return x;

    return gcd(y, x % y);
}

int main()
{
    int k;

    cin >> k;

    ll ans = 0;

    for (int a = 1; a <= k; a++)
    {
        for (int b = 1; b <= k; b++)
        {
            for (int c = 1; c <= k; c++)
            {
                ll g = gcd(a, b);
                g = gcd(g, c);

                ans += g;
            }
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <algorithm>
using namespace std;

const int M=1e5+5;
char s[M];

int main()
{
	int n;
	scanf("%d%s",&n,s);
	int ans=1;
	for(int i=1;i<n;i++)
		if(s[i]!=s[i-1]) ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
H,W=map(int,input().split())
white=0
S=[]
for _ in range(H):
    s=list(input())
    white+=s.count('.')
    S.append(s)

f=[[0 for i in range(W)] for j in range(H)]

def path(i,j):
    q=[]
    for k in [1,-1]:
        if 0<=i+k<H and f[i+k][j]==0 and S[i+k][j]=='.':
            q.append((i+k,j))
        if 0<=j+k<W and f[i][j+k]==0 and S[i][j+k]=='.':
            q.append((i,j+k))
    return q

flag=False
if S[0][0]=='.' and S[-1][-1]=='.':
    que = path(0,0)
else:
    que = []
f[0][0]=1

l=1
while len(que)>0 and flag==False:
    l+=1
    tmp=[]
    for q in que:
        if f[q[0]][q[1]]==0:
            tmp+=path(*q)
            f[q[0]][q[1]]=1
            if q==(H-1,W-1):
                flag=True
        que=tmp

if flag:
    print(white-l)
else:
    print(-1)


Measured memory_bytes: 42604
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#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 REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}
template<typename T> inline void in(T &e){cin>>e;}
template<typename T> inline void out(T e){cout<<e<<endl;}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;


const int MAX_V = 310;

int d[MAX_V][MAX_V];
int V;
int ans=0;

bool ukai[MAX_V][MAX_V];

void warshall_floyd(){
    for(int k=0;k<V;k++)
        for(int i=0;i<V;i++)
            for(int j=0;j<V;j++){
                if(d[i][j]>d[i][k]+d[k][j]){
                    ans=-1;
                    return;
                }else if(d[i][j]==d[i][k]+d[k][j]){
                    if(k!=i&&k!=j){
                        ukai[i][j]=true;
                    }
                }
            }
                
}

signed main(){
    io();

    cin>>V;
    rep(i,V){
        rep(j,V){
            cin>>d[i][j];
        }
    }

    fill(ukai[0],ukai[V],false);

    warshall_floyd();
    /*
    rep(i,V){
        rep(j,V) cout<<d[i][j]<<" ";

        cout<<endl;
    }
    */
   if(ans==0){
       rep(i,V){
            REP(j,i+1,V) {
                if(!ukai[i][j]) ans+=d[i][j];
            }
       }
   }
   out(ans);

    return 0;
}


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

using namespace std;

int h, w, k, ans;
string c[6];

int main()
{
    cin >> h >> w >> k;
    for(int i = 0; i<h; i++)
        cin >> c[i];
    for(int i = 0; i<(1<<h); i++)
        for(int j = 0; j<(1<<w); j++)
        {
            int cnt = 0;
            for(int k = 0; k<h; k++)
                for(int l = 0; l<w; l++)
                    if((c[k][l]=='#')&&!(i&(1<<k))&&!(j&(1<<l)))
                        cnt++;
            if(cnt==k)
                ans++;
        }
    cout << ans << endl;
}


Measured memory_bytes: 3604
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    ll x = (N / 100) * 111;
    if(x >= N){
        cout << x << endl;
    }else{
        cout << x + 111 << endl;
    }

    return 0;
}

Measured memory_bytes: 3588
N, M = map(int, input().split())
num = [1] * N
possible = [False] * N
possible[0] = True

for i in range(M):
  x, y = map(int, input().split())
  x -= 1; y -= 1
  nx, ny = num[x], num[y]
  if possible[x]:
    possible[y] = True
    if nx == 1:
      possible[x] = False
  
  num[x] -= 1; num[y] += 1

print(sum(possible))

Measured memory_bytes: 4596
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <queue>

using namespace std;

priority_queue < long long > mi, ma;
int n, A[300050];
long long pref[300050], suff[300050];

int main()
{
    scanf("%d", &n);
    for(int i = 0;i < 3 * n;++i)
        scanf("%d", A + i);

    long long sumP = 0;
    for(int i = 0;i < n;++i)
    {
        mi.push(-A[i]);
        sumP += A[i];
        pref[i] = sumP;
    }

    for(int i = n;i < 2 * n;++i)
    {
        if(A[i] > -mi.top())
        {
            int x = -mi.top();
            sumP -= x;
            sumP += A[i];

            mi.pop();
            mi.push(-A[i]);
        }
        pref[i] = sumP;
    }

    long long sumS = 0;
    for(int i = 3 * n - 1;i >= 2 * n;--i)
    {
        ma.push(A[i]);
        sumS += A[i];
        suff[i] = sumS;
    }

    for(int i = 2 * n - 1;i >= n;--i)
    {
        if(A[i] < ma.top())
        {
            int x = ma.top();
            sumS -= x;
            sumS += A[i];

            ma.pop();
            ma.push(A[i]);
        }
        suff[i] = sumS;
    }

    long long ans = -(1LL << 60);
    for(int i = n - 1;i < 2 * n;++i)
    {
        ans = max(ans, pref[i] - suff[i + 1]);
    }

    printf("%lld\n", ans);

//    for(int i = 0;i < 3 * n;++i)
//    {
//        printf("%d ", pref[i]);
//    }
    return 0;
}


Measured memory_bytes: 6388
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin>>N;
  vector<tuple<string,int,int>> vt(N);
  for(int i=0;i<N;i++){
    string s;
    int p;
    cin>>s>>p;
    vt[i]=make_tuple(s,-p,i+1);
  }
  sort(vt.begin(),vt.end());
  
  for(int i=0;i<N;i++)cout<<get<2>(vt[i])<<endl;
}

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

struct Sword {
	int a, b;
};

bool sortb(const Sword &s1, const Sword &s2) {
	return s1.b > s2.b;
}

int main() {
	int n, h;
	cin >> n >> h;
	vector<Sword> swords(n);
	int amax = 0;
	long bsum = 0;
	for (int i = 0; i < n; i++) {
		cin >> swords[i].a >> swords[i].b;
		amax = max(amax, swords[i].a);
		bsum += swords[i].b;
	}
	sort(swords.begin(), swords.end(), sortb);
	long ans = 0;
	for (const Sword &s : swords) {
		if (s.b < amax) break;
		h -= s.b;
		ans++;
		if (h <= 0) {
			cout << ans << endl;
			return 0;
		}
	}
	cout << ans + (h + amax - 1) / amax << endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

typedef unsigned long long UL;
typedef long long LL;
typedef long double LD;
#define LP(i, a, b) for (int i = int(a); i < int(b); i++)
#define LPE(i, a, b) for (int i = int(a); i <= int(b); i++)
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<vector<PII> > WAL;
typedef vector<vector<int> > SAL;
#define Ep 1e-8
#define INF 1e9
#define LINF 1e18

int const MaxSize = 300000 + 5;

int N;
int A[MaxSize];
bool isE;
int ans;

void go(int i) {
	if (i == N) {
		if (isE) {
			ans++;
		}
		return;
	}

	LPE(d, -1, 1)
	{
		bool prevE = isE;

		int cn = A[i] + d;

		if (isE) {
			isE = true;
		} else {
			isE = !(cn % 2);
		}

		go(i + 1);
		isE = prevE;
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	//freopen("/Users/george/A_1.in", "r", stdin);
	cin >> N;

	LP(i, 0, N)
	{
		cin >> A[i];
	}

	LPE(d, -1, 1)
	{
		isE = !((A[0] + d) % 2);
		go(1);
	}

	cout << ans;

	return 0;

}


Measured memory_bytes: 256
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar_unlocked(); while(c==' '||c=='\n') c=getchar_unlocked(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar_unlocked(); } *s='\0'; return len; }

int edge[200000][3];

int qmem[400000][2];

int (*e[100000])[2];
int el[100000];

bool b[100000];
int p[100000];

bool f(int x){
	for(int i=0; i<el[x]; i++){
		int to=e[x][i][0];
		int d=e[x][i][1];
		if(!b[to]){
			p[to]=p[x]+d;
			b[to]=true;
			if(!f(to)) return false;
		}else if(p[to]!=p[x]+d){
			return false;
		}
	}
	return true;
}

int main(void){
	int n=nextint();
	int m=nextint();
	for(int i=0; i<m; i++){
		int A=nextint()-1;
		int B=nextint()-1;
		int C=nextint();
		edge[i][0]=A;
		edge[i][1]=B;
		edge[i][2]=C;
		el[A]++;
		el[B]++;
	}
	int ne=0;
	for(int i=0; i<n; i++){
		e[i]=&qmem[ne];
		ne+=el[i];
		el[i]=0;
	}
	for(int i=0; i<m; i++){
		int A=edge[i][0];
		int B=edge[i][1];
		int C=edge[i][2];
		e[A][el[A]][0]=B;
		e[A][el[A]][1]=C;
		el[A]++;
		e[B][el[B]][0]=A;
		e[B][el[B]][1]=-C;
		el[B]++;
	}
	bool flag=true;
	for(int i=0; i<n; i++){
		if(!b[i] && !f(i)) flag=false;
	}
	puts(flag?"Yes":"No");
}


Measured memory_bytes: 9600
#include <iostream>
using namespace std;
int main()
{
    ios :: sync_with_stdio(false);
    cin.tie(0);
    
    int n,k,x,y;
    
    cin>>n >>k >>x >> y;
    
    long long int ans;
    
    if(n<=k)
    {
        ans=n*x;
    }
    else
    {
        ans=(k*x)+(n-k)*y;
    }
    
    cout <<ans<< "\n";
    
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[] num = new int[4];
    boolean ans = true;
    for (int i = 0; i < 3; i++) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      num[a-1]++;
      num[b-1]++;
      if (num[a-1] > 2 || num[b-1] > 2) {
        ans = false;
      }
    }
    System.out.println(ans ? "YES" : "NO");
  }
}

Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

      int A, B, numOfPalindromic = 0;
      Scanner sc = new Scanner(System.in);
      A = sc.nextInt(); B = sc.nextInt();

      for(; A<=B; A++) if ((A/10000 == A%10) && ((A/1000)%10 == (A%100)/10)) numOfPalindromic++;
      System.out.println(numOfPalindromic);

    }
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())

signed main(){

	lli n;
	cin>>n;

	vector<lli> a(n);
	REP(i,0,n)cin>>a[i];


	lli data[100];
	REP(i,0,100)data[i]=0;

	lli sum=0;
	for(lli i=0;i<n;i++){
		if(i!=0){
			lli next = a[i];
			lli size = i;
			lli two=1;
			for(lli bit=0;bit<61;bit++){

				if(next&(1LL<<bit)){
					sum += two*(size-data[bit]);
				}
				else{
					sum += two*data[bit];
				}

				sum%=MOD;
				two*=2;
				two%=MOD;
			}
		}

		lli now = a[i];
		for(lli bit=0;bit<61;bit++){
			if(now&(1LL<<bit)){
				data[bit]++;
			}
		}
	}
	cout<<sum<<endl;


	return 0;
}

Measured memory_bytes: 2560
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stdio.h>
#define fo(i,a,b)for(int i(a);i<(b);i++)
#define rep(i,n)fo(i,0,n)
using namespace std;
#define pii pair<int,int>
#define ll long long
#define mp make_pair
#define pb push_back
typedef pair<pair<int,int>,int>tri;

char s[500005];
int dp1[500005];
int dp2[500005];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    cin>>s[i];
    for(int i=1;i<=n;i++)
    if(s[i]=='0')dp1[i]=i;
    else dp1[i]=dp1[i-1];
    for(int i=1;i<=n;i++)
    {
        dp2[i]=dp2[i-1];
        if(s[i]=='1')
        {
            if(s[i-1]=='0' && s[i-2]=='1')
            {
                dp2[i]=max(dp2[i],dp2[dp1[i-2]]+i-2-dp1[i-2]);
                dp2[i]=max(dp2[i],dp2[dp1[i-2]+1]+i-2-dp1[i-2]-1);
            }
            if(s[dp1[i]-1]=='1')
            {
                dp2[i]=max(dp2[i],dp2[dp1[i]-2]+i-dp1[i]);
            }
        }
    }
    cout<<dp2[n];
    //system("pause");
    return 0;
}


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

int main(){
    long N;
    long H[100010];
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> H[i];

    long dp[100010];
    for(int i = 0; i < 100010; i++) dp[i] = 0;

    long max_move = 0;
    for(int i = N - 1; i > 0; i--){
        if(H[i] >= H[i + 1]){
            dp[i] = dp[i + 1] + 1;
            max_move = max(max_move, dp[i]);
        } 
        else{
            dp[i] = 0;
        }
    }

    cout << max_move << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b / gcd(a,b);}

int main() {
    int n,a;
    cin >> n >> a;
    if (n%500 == 0 || (n%500 != 0 && n%500 <= a)) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }
}


Measured memory_bytes: 384