akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class B
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		char[] s = GetString().ToCharArray();

		int[] c = s.Select(x => (int)(x - 'A')).ToArray();
		int[] d = c.Select(x => (x + N) % 26).ToArray();
		char[] t = d.Select(x => (char)(x + 'A')).ToArray();
		WriteLine(new String(t));
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 13780
/*
 * atcoder/abc102_2nd/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/*
 * f(b) = |A_1 - 1 - b| + |A_2 - 2 - b| + ... + |A_N - N - b|
 * f(b)の最小値を求めよ. bは任意の整数.
 *
 * 全項で-bは共通だな。(A_i - i) だけ異なる.
 * 直感的には、A_i - i の中央値をbにすれば最小化するだろうか.
 * 証明が必要だ.
 */
int N;
vector<ll> A, B;
void solve() {
  cin >> N;
  ll a;
  loop(n,0,N) {
    cin >> a;
    A.push_back(a); B.push_back(a - (n + 1));
  }
  sort(B.begin(), B.end());
  ll b = B[B.size()/2];
  ll total = 0;
  loop(n,0,N) {
    total += abs(A[n] - (n+1) - b);
  }
  cout << total << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 3564
n,m=map(int,input().split())
d=[[int(x) for x in input().split()] for y in range(n)]
v=[0]*n
c=[[1,1,1],[1,1,-1],[1,-1,1],[1,-1,-1],[-1,1,1],[-1,1,-1],[-1,-1,1],[-1,-1,-1]]

s=0
for i in range(8):
  for j in range(n):
    v[j]=c[i][0]*d[j][0]+c[i][1]*d[j][1]+c[i][2]*d[j][2]
  v.sort()
  if m!=0:
    s=max(s,sum(v[-m:]))

print(s)


Measured memory_bytes: 3292
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  int a,b;
  vector<vector<int> > li(n+2);
  rep(i,m){
    cin>>a>>b;
    li[a].push_back(b);
    li[b].push_back(a);
  }
  vint pe;
  REP(i,1,n+1){
    pe.push_back(i);
  }
  bool flag;
  ll count=0;
  vector<vector<bool> > fg(10,vector<bool>(10));
  do{
    if(pe[0]!=1){
      break;
    }
    bool flag2=false;
    flag=true;
    rep(i,10){
      rep(j,10){
        fg[i][j]=false;
      }
    }
    int count2=0;
    for(int i=0;i<n-1;i++){
      int si=li[pe[i]].size();
      rep(j,si){
        if(li[pe[i]][j]==pe[i+1] && !fg[pe[i]][j]){
          flag2=true;
          /* fg[pe[i]][pe[i+1]]=true;
             fg[pe[i+1]][pe[i]]=true;*/
          count2++;
          break;
        }
      }
    }
    if(count2==n-1){
      count++;
    }
  }while(next_permutation(all(pe)));
  cout<<count<<'\n';
  return(0);
}  


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

using namespace std;

#define INF 1e9
#define rep(i,a,n) for(ll i=(a);i<(n);i++)
#define repv(i,a,n) for(ll i=(n)-1;i>=a;i--)
#define ll long long int
#define endl "\n"

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

    int n,count = 0;
    cin >> n;
    while(n-- && count < 3) {

    	int a,b;
    	cin >> a >> b;
    	if(a == b) 
    		count++;
    	else
    		count = 0;
    }
    
    if(count == 3)
    	cout << "Yes\n";
    else
    	cout << "No\n";
}



Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
  string a;
  cin >> a;
  int b = a.size(),c,d;
  for(int i = 0;i<b;i++){
    if(a.at(i)=='A'){
      c = i;
      break;
    }
  }
  for(int i = b-1;i>0;i--){
    if(a.at(i)=='Z') {
      d = i;
      break;
    }
  }
  cout << d-c+1;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

const ll MOD=1e9+7;

ll ad(ll x,ll y=0){
  return (x+y)%MOD;
}

ll mlt(ll x,ll y=1){
  return (x*y)%MOD;
}

ll ans(ll* x,ll n){
  ll an=0,s[100010]={};
  Fr(i,n) s[i]=s[i-1]+x[i];
  Fr(i,n) an=ad(an,i*x[i]-s[i]);
  return an;
}

int main(){
  ll n,m,x[100010],y[100010];
  cin>>n>>m;
  Fr(i,n) cin>>x[i];
  Fr(i,m) cin>>y[i];
  cout<<mlt(ans(x,n),ans(y,m))<<endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef priority_queue<string, vector<string>, less<string> > QUE_string;
typedef priority_queue<double, vector<double>, less<double> > QUE_double;
typedef priority_queue<char, vector<char>, less<char> > QUE_char;
typedef priority_queue<int, vector<int>, less<int> > QUE_int;
const int MAX = pow(10, 5)+1;
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> A(N), B(N);
  vector<vector<int>> vec(MAX, vector<int>());
  //map<int, QUE_int> mp;
  //map<int, int> mp;
  QUE_int can_work_que;//i日目にやってよい仕事の報酬を入れていく
  for(int i=0; i<N; i++){
    //cin >> A.at(i) >> B.at(i);
    int a, b;
    cin >> a >> b;
    vec.at(a).emplace_back(b);
    //mp[a].emplace(b);
    //if(mp[a]<b) mp[a] = b;
  }
  
  //ちゃんと取得できたか確認
  /*for(int i=0; i<5; i++){
    cout << "i: " << i << " : " ;
    for(int j=0; j<vec.at(i).size(); j++){
      cout << vec.at(i).at(j) << " ";
    }
    cout << endl;
  }*/
  
  //答えを求める
  int ans = 0;
  for(int i=1; i<=M; i++){//1~M日目までループ
    //cout << "vec.at("<< i<<").size():  " <<vec.at(i).size() <<  endl;
    for(int j=0; j<vec.at(i).size(); j++){
      //cout << " i: " << i << " j: " << j << endl;
      can_work_que.push(vec.at(i).at(j));
    }
    //cout << " i: " << i << endl;
    if(can_work_que.empty()) continue;//これやらんと終了コード139になるよ
    ans += can_work_que.top();//i日目にやっていい仕事の中の最大の報酬をやる    
    //cout << "get!!: " <<can_work_que.top() << " ans: " << ans << endl;
    can_work_que.pop();//やった仕事は二度とやれないので削除
  }
  cout << ans << endl;
}



Measured memory_bytes: 6400
//Link : https://atcoder.jp/contests/keyence2019/tasks/keyence2019_e

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 200000
#define inf 2000000000000000000
int A[N];
pair<ll,int> seg1[N*4],seg2[N*4];

int n;
ll d;
void init(int pos,int l,int r) {
    if(l==r) {
        seg1[pos] = make_pair((ll)l*d + A[l],l);
        seg2[pos] = make_pair(-(ll)l*d + A[l],l);
        return;
    }
    int mid = (l+r)/2;
    init(pos*2,l,mid);
    init(pos*2+1,mid+1,r);
    seg1[pos] = min(seg1[pos*2],seg1[pos*2+1]);
    seg2[pos] = min(seg2[pos*2],seg2[pos*2+1]);
}
pair<ll,int> query(pair<ll,int> *seg,int pos,int l,int r,int ql,int qr) {
    if(r<ql || qr<l) {
        return make_pair(inf,0);
    }
    if(ql<=l && r<=qr) {
        return seg[pos];
    }
    int mid = (l+r)/2;
    return min(query(seg,pos*2,l,mid,ql,qr),query(seg,pos*2+1,mid+1,r,ql,qr));
}

ll solveSeg(int l,int r,ll leftValue,ll rightValue) {
    if(l>r) {
        return 0;
    }
    ll ret = 0;
    int index = -1;ll value = inf;
    pair<ll,int> q = query(seg1,1,0,n-1,l,r);
    index = q.second;
    value = q.first + leftValue;
    q = query(seg2,1,0,n-1,l,r);
    int tindex = q.second;
    if(q.first + rightValue < value) {
        value = q.first + rightValue;
        index = q.second;
    }
    ll u = min(rightValue, A[index] + d*index);
    ll v = min(leftValue,  A[index] - d*index);
    ret += solveSeg(l,index-1,leftValue,u)
        +  solveSeg(index+1,r,v,rightValue) + value;
    return ret;
}
void solve() {
    scanf("%d %lld",&n,&d);
    int minIndex = -1,minValue = 2e9;
    for(int i=0;i<n;++i) {
        scanf("%d",&A[i]);
        if(A[i]<minValue) {
            minValue  = A[i];
            minIndex = i;
        }
    }
    init(1,0,n-1);
    printf("%lld\n",solveSeg(0,minIndex-1,inf,minIndex*d + A[minIndex])
                    + solveSeg(minIndex+1,n-1,-minIndex*d + A[minIndex],inf)
    );
}

int main() {
    //freopen("input.txt","r",stdin);
    solve();
    return 0;
}


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

const int MAXN = 8000;
long long kai[MAXN+1];
long long inv[MAXN+1];
long long mod = 1e9+7;
long long mp(long long a, long long b) {
    long long res = 1;
    for (; b; b >>= 1) {
        if (b & 1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}
void init() {
    kai[0] = 1;
    for (long long i = 1; i <= MAXN; i++) kai[i] = kai[i - 1] * i % mod;
    inv[MAXN] = mp(kai[MAXN], mod-2);
    for (long long i = MAXN; i >= 1; i--) inv[i - 1] = inv[i] * i % mod;
}
long long calc(long long n, long long k) {
    if (n < k) return 0;
    return (kai[n] * inv[k]) % mod * inv[n - k] % mod;
}

int n;
ll a[200010], b[200010];
ll dp[4010][4010];
int main() {
    init();
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        dp[2000-a[i]][2000-b[i]]++;
    }
    for (int i = 0; i <= 4000; i++) {
        for (int j = 0; j <= 4000; j++) {
            dp[i+1][j] += dp[i][j];
            dp[i+1][j] %= mod;
            dp[i][j+1] += dp[i][j];
            dp[i][j+1] %= mod;
        }
    }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ans += dp[a[i]+2000][b[i]+2000];
        ans %= mod;
        ans += mod - calc(2 * a[i] + 2 * b[i], 2 * a[i]);
        ans %= mod;
    }
    cout << ans * inv[2] % mod << endl;
    return 0;
}

Measured memory_bytes: 132152
///*****************************************************///
///*.......................Faiyaj Bin Amin............................*///
///*...................................................................*///
///*.........................KUET CSE 2K17......................*///
///*...................................................*///
///*****************************************************///

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define fastio      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define ret return
#define rep(q, i, n) for(int q=i; q<n; q++)
#define forn(i, n) for(int i=0; i<n; i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define ll long long
#define pb push_back
#define em emplace_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define ff first
#define ss second
#define pii pair<int,int>
#define pdd pair<double, double>

#define see(x)        cerr<< __LINE__ << ": " << (#x) << " is "<< (x) <<'\n';
#define seecontent(v) for(auto x : v) { cout << x << " ";} cout << "\n\n";

#define PI 2*acos(0.0)
#define lcm(a, b)  ((a / __gcd(a, b) ) * b)

#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)

#define mx 100005
#define INF 1e18
#define MOD 1000000007
#define MIN 0

//template <typename T>  using orderedSet =
//    tree<T, null_type, less_equal<T>,
//    rb_tree_tag, tree_order_statistics_node_update>; //find_by_order, order_of_key


/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0}; // Directional
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

/**------------------------------------BITMASK------------------------------------------**/
//int Change(int N, int pos){return N= N^(1<<pos);}
//bool Check(int N, int pos){return (bool)(N &(1<<pos));}  /// check bit 0 or 1
/**-----------------------------------------------------------------------------------------------**/

//using namespace __gnu_pbds;
using namespace std;

int main()
{
    fastio;

    ll n;
    cin>>n;

    ll a[n+1], b[n];

    forn(i, n+1)
    {
        cin >> a[i];
    }
    forn(i, n)
    {
        cin >> b[i];
    }

    ll cnt=0;
    forn(i, n)
    {
        ll val = min( (ll) a[i], (ll) b[i]);
        cnt += val;
        b[i]-=val;
        a[i]-=val;

        ll val2 = min( (ll) a[i+1], (ll) b[i]);
        cnt += val2;
        b[i]-=val2;
        a[i+1]-=val2;
    }

    cout<< cnt << "\n";

    return 0;
}

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

int main() {
  string S;
  cin >> S;
  vector<bool>vec(26,true);
  for(int i=0; i<S.size();i++){
   vec[S[i]-'a'] = false;
  }
  for(int i=0; i<26; i++){
    if(vec[i] == true){
      cout << (char)(i+'a') << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}


Measured memory_bytes: 3784
#include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;

int main(){
	int N,K;
	scanf("%d%d",&N,&K);
	for(int i=0;i<K;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		a=min(a,N-a+1);
		b=min(b,N-b+1);
		int x=min(a,b);
		printf("%d\n",(x-1)%3+1);
	}
}

Measured memory_bytes: 1188
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-12;


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

	long long int N, K;
	cin >> N >> K;
	if (2 * N*K + (2 * N - 1)*(2 * N) / 2 > N*K + 2 * N*N + N * (N - 1) / 2) {
		cout << -1 << endl;
		return 0;
	}
	vector<int>a(N);
	vector<int>b(N);
	vector<int>c(N);
	int cnt = 0;
	for (int i = 0; i < N; i+=2) {
		a[i] = K + cnt++;
	}
	for (int i = 1; i < N; i += 2) {
		a[i] = K + cnt++;
	}
	cnt = 2 * N;
	if (N & 1) {
		for (int i = N - 1; i >= 0; i -= 2) {
			b[i] = K + --cnt;
		}
		for (int i = N - 2; i >= 0; i -= 2) {
			b[i] = K + --cnt;
		}
	}
	else {
		for (int i = N - 2; i >= 0; i -= 2) {
			b[i] = K + --cnt;
		}
		for (int i = N - 1; i >= 0; i -= 2) {
			b[i] = K + --cnt;
		}
	}
	cnt = 2 * N;
	for (int i = 0; i < N; i++) {
		c[i] = K + cnt++;
	}
	for (int i = 0; i < N; i++) {
		cout << a[i] << " " << b[i] << " " << c[i] << endl;
	}

}

Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list> 
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
typedef pair<double, long long> pair_t;
bool comp(const pair_t& a, const pair_t& b) {
	if (a.first == b.first)return  a.second > b.second;
	else {
		return a.first > b.first;
	}
}

int main() {
	string s;
	cin >> s;
	ll q;
	cin >> q;
	list<char>ls;
	vector<ll>kukan(pow(10,6),0);
	vector<pair<ll,char>>pp;
	ll charcnt = 0;
	rep(i, q) {
		ll t;
		cin >> t;
		if (t == 1) {
			kukan[charcnt]++;
		}
		if (t == 2) {
			ll f;
			char c;
			cin >> f >> c;
			pp.push_back(make_pair(f,c));
			charcnt++;
		}
	}
	ll kukanallsum = accumulate(all(kukan),0LL);
	if (kukanallsum % 2 == 1)reverse(all(s));
	rep(i, s.length())ls.push_back(s[i]);
	ll cnt = 0;
	rep(i, pp.size()) {
		cnt += kukan[i];
		if (pp[i].first == 1) {
			if((kukanallsum - cnt)%2==0)ls.push_front(pp[i].second);
			else ls.push_back(pp[i].second);
		}
		else if (pp[i].first == 2) {
			if ((kukanallsum - cnt) % 2 == 0)ls.push_back(pp[i].second);
			else ls.push_front(pp[i].second);
		}
	}
	for (auto itr = ls.begin(); itr != ls.end(); ++itr) {
		cout << *itr;
	}
	cout << endl;
}


Measured memory_bytes: 21356
#include <stdio.h>

int main(void) {
  int a[101],n,min,minpoint,change,i,j,count = 0;
  scanf("%d",&n);
  for(i = 0; i < n; i++)scanf("%d",&a[i]);

  for(i = 0; i < n; i++){
    minpoint = i;
    min = 999;
    for(j = i; j < n; j++){
      if(min > a[j]){
        min = a[j];
        minpoint = j;
      }
    }
    change = a[i];
    a[i] = a[minpoint];
    a[minpoint] = change;
    if(minpoint != i)count++;
  }
  for(i = 0; i < n; i++){
    if(i != 0)printf(" ");
    printf("%d",a[i]);
  }
  printf("\n%d\n",count);
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
#define ll long long
#define P pair<ll,ll>
using namespace std;
bool comparator(P &A,P &B){
	return A.first<B.first;
}
int main(){
	int n,m;
	cin>>n>>m;
	vector<P>arr(n);
	for(int i=0;i<n;i++){
		cin>>arr[i].first>>arr[i].second;
	}
	sort(arr.begin(),arr.end(),comparator);
	ll cost=0;
	int i=0;
	while(i<n && m>0){
		if(m<=arr[i].second){
			cost+=(m*arr[i].first);
			m=0;
		}else{
			cost+=(arr[i].first*arr[i].second);
			m-=arr[i].second;
		}
		i++;
	}
	cout<<cost<<endl;
	return 0;
}

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

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

    if(c=="a" || c=="e" || c=="i" || c=="u" || c=="o"){
        cout << "vowel" << endl;
    }
    else cout << "consonant" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int n;
  cin >> n;
  int sum = 0, maxprice = 0;
  for (int i = 0; i < n; i++) {
    int p;
    cin >> p;
    sum += p;
    maxprice = max(maxprice, p);
  }
  cout << sum - maxprice / 2 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>                                                                                                                                                               
#include <stdlib.h>                                                                                                                                                              
#include <string.h>                                                                                                                                                              
                                                                                                                                                                                 
int main (void) {                                                                                                                                                                
    char s[101];                                                                                                                                                                 
    scanf("%s", s);                                                                                                                                                              
                                                                                                                                                                                 
    int s_len = strlen(s);                                                                                                                                                       
                                                                                                                                                                                 
    for ( int i=0; i<s_len; i++ )                                                                                                                                                
        printf("x");                                                                                                                                                             
    printf("\n");                                                                                                                                                                
                                                                                                                                                                                 
    return EXIT_SUCCESS;                                                                                                                                                         
}

Measured memory_bytes: 128
#include<iostream>

#define MN 1000

int N, M, A, B;
int D[MN];
int disp[MN];

void input(){
	for( int i = 0; i < MN; i++ ){
		disp[i] = 0;
	}
	std::cin >> N >> M >> A >> B;
	for( int i = 0; i < N; i++ ){
		std::cin >> D[i];
	}
	return;
}

int run(){
	int num = 0, num2;
	for( int i = 0; i < N; i++ ){
		if( D[i] >= A ){
			disp[num++] = i;
		}else{
			break;
		}
	}
	if( N-num >= M ){ return num; }
	num2 = num;
	for( int i = num2-1; i >= 0; i-- ){
		if( D[disp[i]] > B ){ break; }
		num--;
	}
	return num;
}

int main(){
	input();
	std::cout << run() << std::endl;
	return 0;
}

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

using namespace std;

const int max_n = 11, inf = 1000111222;

int n, d, x[max_n][max_n];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> d;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < d; ++j) {
            cin >> x[i][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            int q = 0;
            for (int k = 0; k < d; ++k) {
                q += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            int sq = sqrt(q);
            if (sq * sq == q || (sq + 1) * (sq + 1) == q) {
                ++ans;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define ain(i,n,a) for(long long i=0;i<(long long)(n);i++){cin>>a[i];}
#define aout(i,n,a) for(long long i=0;i<(long long)(n);i++){cout<<a[i]<<endl;}
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define vsort(v) sort((v).begin(), (v).end())
#define vrsort(v) sort((v).rbegin(), (v).rend())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 2000000009
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  int i,j,h,w;cin>>h>>w;
  vvll tate(h,vll(w,1));vvll yoko(h,vll(w,1));
  vector<string> s(h);
  ain(i,h,s);
  //caricurate
  rep(i,h){rep(j,w){if(s[i].at(j) =='#'){tate[i][j]=0;yoko[i][j]=0;}}}
  rep(j,w){
    rep(i,h-1){
      if(tate[i][j]*tate[i+1][j]){
        tate[i+1][j]+=tate[i][j];
      }
    }
  }
  
  rep(j,w){
    for(i=h-1;i>0;i--){
      if(tate[i][j]*tate[i-1][j]){
        tate[i-1][j]=tate[i][j];
      }
    }
  }
  
  rep(i,h){
    rep(j,w-1){
      if(yoko[i][j]*yoko[i][j+1]){
        yoko[i][j+1]+=yoko[i][j];
      }
    }
  }
  
  rep(i,h){
    for(j=w-1;j>0;j--){
      if(yoko[i][j]*yoko[i][j-1]){
        yoko[i][j-1]=yoko[i][j];
      }
    }
  }
  ll mx=-19980219;ll nw;
  rep(i,h){
    rep(j,w){
      nw=tate[i][j]+yoko[i][j];
      if(nw>mx){mx=nw;}
    }
  }
  //output
  cout<<mx-1<<endl;
}

Measured memory_bytes: 67200
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("YES\n")
#define ptn printf("NO\n")
//==========================Code here==========================
LL A, B;
int main() {
	cin >> A >> B;
	if ((A - B) & 1) printf("IMPOSSIBLE\n"); else printf("%lld\n", (A + B) / 2);
	return 0;
}

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

int main () {
  int N;
  cin >> N;
  vector<int> X(N), Y(N);
  for (int i = 0; i < N; i++) {
    cin >> X.at(i);
    Y.at(i) = X.at(i);
  }
  sort (Y.begin(), Y.end());
  for (int i = 0; i < N; i++) {
    int a = X.at(i);
    if(a < Y.at(N/2)) cout << Y.at(N/2) << endl;
    else cout << Y.at(N/2-1) << endl;
  }
}
    

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

const int inf = -1000;

int main() {

    int n;
    cin>>n;

    int arr[n];

    for(int i=0;i<n;++i)
        cin>>arr[i];
    sort(arr,arr+n);

    int x = n/2;
    cout<<arr[x]  - arr[x-1];
    return 0;
      }


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
    int k;
    cin>>k;
    string a;
    cin>>a;
    if(a.size()>k)
    {
        string c;
        int j=0;
        while(j<k)
        {
            c=c+a[j];
            j++;
        }
        a=c+"...";
    }
    cout<<a<<endl;

}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
  int n, m; cin >> n >> m;
  priority_queue<int> pq;
  rep(i, n) {
    int a; cin >> a;
    pq.push(a);
  }
  rep(i, m) {
    int p = pq.top(); pq.pop();
    pq.push(p/2);
  }
  ll ans = 0;
  while(!pq.empty()) {
    ans += pq.top(); pq.pop();
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;
const int INF=1001001001;
int main(){
  int A,P;
  cin>>A>>P;
  int ans=(3*A+P)/2;

  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    vector<int> primes;
    primes.PB(2);
    for(int i=3;i<=1000001;i++){
	bool flg = true;
	for(int j=0;primes[j]*primes[j]<=i;j++){
	    if(i % primes[j] == 0) flg = false;
	}
	if(flg) primes.PB(i);
    }
    while(true){
	int ans = 0;
	int n,x;
	cin >> n >> x;
	if(n==0&&x==0) break;
	bool d[1000001] = {false};
	d[0] = true;
	REP(i,n){
	    int a;
	    cin >> a;
	    for(int i=0;i+a<=1e6;i++){
		if(d[i])
		    d[i+a] = d[i];
	    }
	}
	int s = upper_bound(ALL(primes),x) - primes.begin();
	RREP(i,s){
	    if(d[primes[i]]){
		ans = primes[i];
		break;
	    }
	}
	if(ans==0) cout << "NA" << endl;
	else cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2512
#include<cstdio>
#include<cstring>
#define maxn 5050
#define maxm 50005
#define INF 0x3f3f3f3f
inline int read(){
	int r=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){r=(r<<3)+(r<<1)+c-'0';c=getchar();}
	return r*f;
}
int s,t,n,m,head[maxn],pre[maxn],dis[maxn],q[maxn];
bool vis[maxn];
int s_e;
struct E{
	int v,c,w,nxt;
}e[maxm*2];
struct Max_fei{//本人喜欢结构体
	inline void a_e(int u,int v,int c,int w){
		//printf("%d %d %d %d\n",u,v,c,w);
		e[s_e]=(E){v,c,w,head[u]};
		head[u]=s_e++;
		//printf("%d\n",head[10]);
	}
	inline void add(int u,int v,int c,int w){
		//printf("%d %d %d %d\n",u,v,c,w);
		a_e(u,v,c,w);
		a_e(v,u,0,-w);
	}
	inline bool spfa(){
		for(int i=1;i<=n;i++){
			dis[i]=INF;
			vis[i]=false;
		}
		dis[s]=0;
		vis[s]=true;
		q[0]=s;
		int hd=0,tl=1;
		while(hd^tl){
			int u=q[hd++];//循环队列
			hd%=maxn;//printf("%d %d\n",u,head[u]);
			for(int i=head[u];i!=-1;i=e[i].nxt){
				int v=e[i].v;
				if(dis[v]>dis[u]+e[i].w&&e[i].c){//判断水管还能运水吗
					dis[v]=dis[u]+e[i].w;//更新
					pre[v]=i;//记录位置
					if(vis[v])continue;//如果在队里，那就不进队
					vis[v]=true;
					q[tl++]=v;
					tl%=maxn;
				}
			}
			vis[u]=false;
		}
		if(dis[t]==INF)return false;
		return true;
	}
	inline int min(int a,int b){//原谅我的手写min
		return a<b?a:b;
	}
	inline int end(int &flow){//flow求最大流
		int p,u,Min=1e9,ans=0;
		for(u=t;u!=s;u=e[p^1].v){//因为开始值为0，可以用xor来找反边
			p=pre[u];//往前找
			Min=min(Min,e[p].c);//找全部经过水管都能流过的最大流
            
		}
		for(u=t;u!=s;u=e[p^1].v){
			p=pre[u];
			e[p].c-=Min;
			e[p^1].c+=Min;
			ans+=e[p].w*Min;//加费用
		}
		flow+=Min;//加最大流
		return ans;
	}
	inline int solve(int &flow){
		int ans=0;
		while(spfa()){
			//printf("#");
			ans+=end(flow);
		}
		return ans;
	}
}Flow;
int N,M,id;
char ss[55][55];
int idd(int x,int y){return (x-1)*M+y;}
inline void work(){
	scanf("%d%d",&N,&M);s=N*M+1;t=N*M+2;n=N*M+2;m=0;
	for(int i=1;i<=n;i++)head[i]=-1;//初始值为-1，方便xor
	for(int i=1;i<=N;i++)scanf("%s",ss[i]+1);
	for(int i=1;i<=N;i++)
	{
		for(int j=1;j<=M;j++)
		{
			id=idd(i,j);
			if(ss[i][j]=='o')Flow.add(s,id,1,0),m++;
			if(ss[i][j]!='#')Flow.add(id,t,1,0),m++;
			//m+=2;
		}
	}
	for(int i=1;i<=N;i++)
	{
		for(int j=1;j<=M;j++)
		{
			id=idd(i,j);
			if(ss[i][j]=='#')continue;
			if(i+1<=N&&ss[i+1][j]!='#')
			{
				int id2=idd(i+1,j);
				m++;
				Flow.add(id,id2,5000,-1);
			}
			if(j+1<=M&&ss[i][j+1]!='#')
			{
				int id2=idd(i,j+1);
				m++;
				Flow.add(id,id2,5000,-1);
			}
		}
	}
	int flow=0;
	int ans=Flow.solve(flow);
	printf("%d\n",-ans);
}
int main(){
	work();
	return 0;
}

Measured memory_bytes: 1988
fun main(args: Array<String>) {
    val (A, B) = listOfInt()
    val X = Array(100) { CharArray(100) }
    repeat(50) { h->
        repeat(100) { w ->
            X[h][w] = '#'
            X[h + 50][w] = '.'
        }
    }
    var x = 1; var y = 1
    repeat(A - 1) {
        X[y][x] = '.'
        x += 2
        if (x > 100) { x = 1; y += 3 }
    }
    x = 1; y = 51
    repeat(B - 1) {
        X[y][x] = '#'
        x += 2
        if (x > 100) { x = 1; y += 3 }
    }
    println("100 100")
    X.forEach { println(it.joinToString("")) }
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt(d: Int = 0) = listOfString().map { it.toInt() + d }
fun listOfLong(d: Long = 0) = listOfString().map { it.toLong() + d }



Measured memory_bytes: 37752
#include<stdio.h>
#include<iostream>
#include<numeric>
#include<algorithm>
#include<vector>
#include<queue>
#include <iostream>
using namespace std;

#define REP(i,n) for(long long (i)=0;(i)<(n);(i)++)
#define REV(i,n) for(long long (i)=(n-1);(i)>-1;(i)--)
typedef long long ll;

int n,m,d[20],dp[50001];

bool func(int x,int y){
  return x < y;
}

int main(){
  cin >> n >> m;
  REP(i,m) cin >> d[i];
  sort(d,d+m,func);
  fill_n(dp,50001,1 << 30);
  dp[0] = 0;
  REP(i,n+1){
    REP(j,m){
      if(i + d[j] > n)break;
      dp[i + d[j]] = min(dp[i+d[j]],dp[i]+1);
    }
  }
  cout << dp[n] << endl;



  return 0;
}



Measured memory_bytes: 3344
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import fractions
from functools import reduce
from operator import mul
import bisect
import sys
import logging
import heapq
import itertools

logging.basicConfig(level=logging.ERROR)

input = sys.stdin.readline

setrecursionlimit(1000000)


def main():
	n = int(input())
	xy = [list(map(int,input().split())) for _ in range(n)]
	s = 0
	for i in range(n):
		for j in range(n):
			if(i==j): continue
			s+=math.sqrt((xy[i][0]-xy[j][0])**2+(xy[i][1]-xy[j][1])**2)
	print(s/n)

def factorization(n):
	if n<2:
		return []

	arr = []
	temp = n
	for i in range(2, int(-(-n**0.5//1))+1):
		if temp%i==0:
			cnt=0
			while temp%i==0:
				cnt+=1
				temp //= i
			arr.append([i, cnt])

	if temp!=1:
		arr.append([temp, 1])

	if arr==[]:
		arr.append([n, 1])

	return arr

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(numbers):
	return reduce(fractions.gcd, numbers)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

class PriorityQueue():
	def __init__(self):
		self.queue = []
	def push(self,i):
		heapq.heappush(self.queue,-i)
	def pop(self):
		return -1 * heapq.heappop(self.queue)
	def sum(self):
		return -sum(self.queue)

main()


Measured memory_bytes: 5460
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

int main() {
   string s; cin >> s;
   set<char> a;
    for (char i : s) a.insert(i);
    if(a.size() == s.size())print("yes");
    else print("no");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int a, b, c, d; cin >> a >> b >> c >> d;
    int x = c - a;
    int y = d - b;

    rep(i,y) cout << 'U';
    rep(i,x) cout << 'R';
    rep(i,y) cout << 'D';
    rep(i,x) cout << 'L';
    cout << 'L';
    rep(i,y+1) cout << 'U';
    rep(i,x+1) cout << 'R';
    cout << 'D' << 'R';
    rep(i,y+1) cout << 'D';
    rep(i,x+1) cout << 'L';
    cout << 'U' << endl;
}






Measured memory_bytes: 256
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    x = kwargs["x"]
    y = kwargs["y"]
    res = "No"

    if y - 2 * x >= 0 and (y - 2 * x) % 2 == 0 and 4 * x - y >= 0 and (4 * x - y) % 2 == 0:
        res = "Yes"

    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    kwargs["x"], kwargs["y"] = [int(i) for i in cin]

    cout = main(kwargs)
    print(cout)

Measured memory_bytes: 31168
n,m = map(int, input().split())

connect = [[0 for i in range(n)] for j in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    connect[a-1][b-1] = 1
    connect[b-1][a-1] = 1

notbridge = 0


for i in range(n):
    for j in range(n):
        if connect[i][j] == 1:
            connect[i][j] = 0
            connect[j][i] = 0
            stack =[1]
            visited = [1]
            while stack:
                p = stack.pop()
                for k in range(n):
                    if connect[p][k] == 1:
                        if k not in visited:
                            stack.append(k)
                            visited.append(k)
            if len(visited) == n:
                notbridge += 1
            connect[i][j] = 1
            connect[j][i] = 1



print(m-notbridge//2)




Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc =new Scanner(System.in);
	int X=sc.nextInt();
	int Y=sc.nextInt();
	if(X+Y==3) {
		System.out.println(3);
	}else if(X+Y==4) {
		System.out.println(2);
	}else if(X+Y==5) {
		System.out.println(1);
	}
}
}

Measured memory_bytes: 23764
n = int(input())
r = []
for i in range(n):
    s, p = input().split()
    r.append((i + 1, s, int(p)))
r.sort(key=lambda x: x[2], reverse=True)
r.sort(key=lambda x: x[1])
for ri in r:
    print(ri[0])

Measured memory_bytes: 9104
n, m = map(int, input().split())
ps = []
for i in range(m):
    p, y = map(int, input().split())
    ps.append([p, y, i+1])

ps = sorted(ps)
ps

ans = []
count = 1
for i in range(m):
    if (i != 0 and (ps[i])[0] != (ps[i-1])[0]):
        count = 1
    else:
        pass
    ans.append([(ps[i])[2], 1000000*((ps[i])[0]) + count])
    count += 1

ans = sorted(ans)

for i in ans:
    aw = i[1]
    aww = str(aw).zfill(12)
    print(aww)

Measured memory_bytes: 39484
#include<stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  int k;
  while(n>(k*(k+1))/2){
    k++;
  }
  if(n==(k*(k+1))/2){
    puts("Yes");
  }else{
    puts("No");
    return 0;
  }
  int ans[k];
  int tmp,i,j;
  printf("%d\n",k+1);
  for(i=0;i<k;i++){
    printf("%d ",k);
    if(i==0){
      ans[0]=1;
      printf("%d",ans[0]);
      for(j=1;j<k;j++){
        ans[j]=ans[j-1]+j;
        printf(" %d",ans[j]);
      }
      puts("");
      printf("%d ",k);
      tmp=1;
      printf("%d",tmp);
      for(j=1;j<k;j++){
        tmp+=j+1;
        printf(" %d",tmp);
      }
      puts("");
    }else{
      tmp=ans[i];
      printf("%d",tmp);
      for(j=1;j<k;j++){
        if(j<=i)tmp+=1;
        else tmp+=j;
        printf(" %d",tmp);
      }
      puts("");
    }
  }
  return 0;
}


Measured memory_bytes: 1280
//
//  main.cpp
//  ABC162_C
//
//  Created by Kosei on R 2/04/12.
//  Copyright © Reiwa 2 Kosei. All rights reserved.
//

#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#define rep(i, n) for (int i = 1; i <= (n); i++)
#define int long long
#define INF 1e9 + 7
#define cae cout << ans << endl;
#define cye cout << "Yes" << endl;
#define cne cout << "No" << endl;
#define r0 return 0;
using namespace std;
typedef pair<int,int>P;
typedef long long ll;
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
signed main() {
    int k;
    int ans = 0;
    cin >> k;
    rep(i, k) {
        rep(j, k) {
            rep(l, k) {
                int aa = 0;
                aa = gcd(i, j);
                aa = gcd(aa, l);
                ans += aa;
            }
        }
    }
    cae
    r0
}


Measured memory_bytes: 3632
from itertools import *

def sieve(n):
    a = range(n)
    a[:2] = None, None
    for i in range(2, n):
        if i ** 2 >= n: break
        if not a[i]: continue
        for i in range(i ** 2, n, i):
            a[i] = None
    return a

b = sieve(50000)
a = [v for v in b if v]
while True:
    n = int(raw_input())
    if n == 0: break
    ct = 0
    for v in a:
        if v > n / 2: break
        if b[n - v]:
            ct += 1
    print ct

Measured memory_bytes: 8176
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


class BIT:
    def __init__(self, L):
        self.n = len(L)
        self.bit = [0] * (self.n + 1)

    def update(self, idx, x):
        while idx <= self.n:
            self.bit[idx] += x
            idx += idx & (-idx)

    def query(self, idx):
        res = 0
        while idx > 0:
            res += self.bit[idx]
            idx -= idx & (-idx)
        return res

    def sec_sum(self, left, right):
        return self.query(right) - self.query(left - 1)

    def debug(self):
        print(*[self.sec_sum(i - 1, i) for i in range(1, self.n + 1)])


def resolve():
    n, q = map(int, input().split())
    C = list(map(int, input().split()))
    query = []
    for i in range(q):
        l, r = map(int, input().split())
        query.append([l, r, i])
    query.sort(key=lambda x: x[1])

    lastAppeared = [0] * (max(C) + 1)
    prev = query[0][1]
    for i in range(prev):
        lastAppeared[C[i]] = i + 1

    bit = BIT(C + [0])
    for num in lastAppeared:
        if num == 0:
            continue
        bit.update(num, 1)

    res = [0] * q
    for L, R, idx in query:
        if R > prev:
            for j in range(prev, R):
                if lastAppeared[C[j]]:
                    num = lastAppeared[C[j]]
                    bit.update(num, -1)
                lastAppeared[C[j]] = j + 1
                num = lastAppeared[C[j]]
                bit.update(num, 1)
            prev = R
        res[idx] = bit.sec_sum(L, R)
    print(*res, sep="\n")


if __name__ == '__main__':
    resolve()


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

ans = float('inf')
for i in range(N):
  for j in range(N):
    for k in range(N):
      for l in range(N):
        x1= xy[i][0]
        x2 = xy[j][0]
        y1 = xy[k][1]
        y2 = xy[l][1]
        cnt = 0
        if x1 < x2 and y1 < y2:
          for n in range(N):
            if x1 <= xy[n][0] <= x2 and y1 <= xy[n][1] <= y2:
              cnt += 1

          if cnt >= K:
            ans = min(ans, (x2-x1)*(y2-y1))
print(ans)

Measured memory_bytes: 74308
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>

ll INF = 1000000007;


//-----------------//
  #define amin main
//-----------------//
map<pll,ll>vis;

int amin()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t,i,j;
	ll n,m,x;
	cin>>n>>m>>x;
	ll row[n+1]={0};
	ll col[m+1]={0};
	
	ll r = 0;
	ll ri = 0;
	ll rip = 0;
	ll c= 0;
	ll ci= 0;
	ll cip = 0;
	ll ripi = 0;
	ll cipi = 0;
	ll ripii = 0;
	ll cipii = 0;
	for(i=0;i<x;i++)
	{
		ll a,b;
		cin>>a>>b;
		vis[{a,b}]=1;
		row[a]++;
		col[b]++;
		if(row[a]>r)
		{
			r= row[a];
			ripii = ripi;
			ripi = rip;
			rip = ri;

			//rip = ri;
			ri = a;
			

		}
		if(col[b]>c)
		{
			c = col[b];
			cip = ci;
			ci = b;
		}
		

	}
	
	ll ans=  0;
	//cout<<ri<<" "<<rip<<endl;
	//cout<<col[1]<<" "<<col[2]<<" "<<col[3]<<endl;
	for(i=1;i<=m;i++)
	{
		if(vis[{ri,i}]==1)
		{
			ans= max(row[ri]+col[i]-1,ans);
		}
		else
			{
				ans= max(row[ri]+col[i],ans);
			}
		if(vis[{rip,i}]==1)
		{
			ans= max(row[rip]+col[i]-1,ans);
		}
		else
			ans= max(row[rip]+col[i],ans);
		if(vis[{ripi,i}]==1)
		{
			ans= max(row[ripi]+col[i]-1,ans);
		}
		else
			{
				ans= max(row[ripi]+col[i],ans);
			}
			if(vis[{ripii,i}]==1)
		{
			ans= max(row[ripii]+col[i]-1,ans);
		}
		else
			{
				ans= max(row[ripii]+col[i],ans);
			}
			

	}
	ll ans1 = 0;
	for(i=1;i<=n;i++)
	{
		if(vis[{i,ci}]==1)
		{
			ans= max(row[i]+col[ci]-1,ans);
		}
		else
			{
				ans= max(row[i]+col[ci],ans);
			}
		if(vis[{i,cip}]==1)
		{
			ans= max(row[i]+col[cip]-1,ans);
		}
		else
			ans= max(row[i]+col[cip],ans);
		
			

	}
	cout<<max(ans,ans1)<<endl;
	
	
	


	
	return 0;
}

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

int main(){
 string a;
cin>>a;
    if(a=="a"||a=="i"||a=="u"||a=="e"){
    cout<<"vowel"<<endl;
}
  else if(a=="o"){
    cout<<"vowel"<<endl;
  }
  else{
    cout<<"consonant"<<endl;
  }
}


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

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

    for(int i = 0; i < 3; i++)
    {
        if(s[i] == '1')
            s[i] = '9';
        else if(s[i] == '9')
            s[i] = '1';
    }
    cout << s <<endl;

}


Measured memory_bytes: 256