akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rem(i, m, n) for (int i = m; i < (n); i++)
#define eps (1e-7)
#define inf (1e9)
#define pi (acos(-1))
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    sort(s.begin(), s.end());
    rep(i, n) cout << s[i];

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=2147483647;
const double pi=3.1415926535897932384626;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
int x,y;
int main(){
	x=read(),y=read();
	if(!(y&1)&&y>=2*x&&y<=4*x) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
typedef int64_t ll;

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}


int main() {
    int64_t N, ans = 1, sum = 1;
    cin >> N;

    for (int64_t i = 2; i * i <= N + 100; i++){
        if (i == N){
            break;
        }
        if (N % i == 0){
            int64_t a = N;
            while(a % i == 0){
                a /= i;
            }
            if (a % i == 1){
                ans++;
            }
        }
    }
    auto T = prime_factor(N - 1);
    for (auto y: T){
        sum *= y.second + 1;
    }
    ans += sum - 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
k,a,b = map(int, input().split())

if b -a <= 2:
    print(k+1)
else:
    if (k - a + 1)%2 == 0:
        print(((k - a + 1)//2)*(b -a) + a )
    else:
        print(((k - a)//2)*(b -a) + a + 1 )

Measured memory_bytes: 2940
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<set>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<stack>
#include<tuple>
#include<utility>
#define mod 1000000007;
typedef long long ll;
#define rep(i,n) for(ll i=0; i<n; i++)
using namespace std;

void a(int r, int d, int x){
  static int cnt = 0;
  cnt++;
  if(cnt == 11){
    return;
  }
  cout << r*x-d << endl;
  a(r,d,r*x-d);
}

int main(){
  int r,d,x;
  cin >> r >> d >> x;
  a(r,d,x);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 500000
#define SENTINEL 2000000000

int L[250002], R[250002],count = 0, A[MAX],n;

void merge(int, int, int);
void mergeSort(int, int);

int main()
{
  int i;

  scanf("%d",&n);

  for(i = 0; i < n; i++) {
    scanf("%d",&A[i]);
  }
  mergeSort(0, n);
  for(i = 0; i < n - 1 ; i++) {
    printf("%d ",A[i]);
  }
  printf("%d", A[n - 1]);
  printf("\n");
  printf("%d\n",count);
  return 0;
}


void mergeSort(int left, int right) {
  int mid;
  if(left+1 < right) {
    mid =(left + right) / 2;
    mergeSort(left, mid);
    mergeSort(mid, right);
    merge(left, mid, right);
  }
}
void merge(int left, int mid, int right) {
  int n1,n2,i,j,k;

  n1 = mid - left;
  n2 = right - mid;

  for(i = 0; i < n1; i++) {
    L[i] = A[left+i];
  }

  for(i = 0; i < n2; i++) {
    R[i] = A[mid+i];
  }
  L[n1] = SENTINEL;
  R[n2] = SENTINEL;

  i = 0;
  j = 0;
for(k = left; k < right; k++) {
    if(L[i] <= R[j]) {
      A[k] = L[i];
      i++;
      count++;
    }
    else{
      A[k] = R[j];
      j++;
      count++;
    }
  }
}

Measured memory_bytes: 4508
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define rn(i,n) for(int i=1;i<=n;i++)
#define ll long long
const ll mod=1e9+7;


int main(){
  string s;
  cin>>s;
  int cnt=0;

  if(s.at(0)=='1'){
    for(int i=1;i<s.size();i++){
        if(i%2==1){
          if(s.at(i)=='1'){
            cnt++;
          }
        }
        else if(i%2==0){

          if(s.at(i)=='0'){cnt++;}
        }
        
      }
  }else{
    for(int i=1;i<s.size();i++){
      if(i%2==1){
        if(s.at(i)!='1'){
          cnt++;
        }
      }
      else if(i%2==0){
        if(s.at(i)=='1'){cnt++;}
      }
    }
  }

  cout<<cnt<<endl;

return 0;

}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;

int main(int argc, char** argv) 
{
#ifdef HOME
	if(IsDebuggerPresent())
	{
		freopen("../in.txt", "rb", stdin);
		freopen("../out.txt", "wb", stdout);
	}
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
	string S;
	cin >> S;
	if (S[0] >= 'A' && S[0] <= 'Z')
	{
		cout << 'A' << endl;
	}
	else
	{
		cout << 'a' << endl;
	}
	return 0;
}


Measured memory_bytes: 3560
NUMBERS = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(NUMBERS[K - 1])

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int R, G, B;
  cin >> R >> G >> B;
  int N;
  cin >> N;

  int ans = 0;
  repp(r, 0, 3000) {
    repp(g, 0, 3000) {
      int res = N - r * R - g * G;
      if (res % B != 0 || res < 0)
        continue;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cmath>
  
using namespace std;
  
string s;
int dfs(int l, int r){
    if(l < 0 || r >= s.size()) return 3;
    int d = abs(s[l]-s[r]);
    if(d&&d<3) return 2 + dfs(l-1, r+1);
    return max(dfs(l-1, r), dfs(l, r+1));
}
  
int main(){ 
    cin >> s;
    int r, l = 0;
    while(s[l] != 'i') l++;
    cout << dfs(l-1, l+3) << endl;
      
    return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <vector>

using namespace std;

int main()
{
  int n; cin >> n;
  vector<int> d(n);
  for (int i = 0; i < n; i++) cin >> d[i];
  int sum = 0;
  for (int i = 0; i < n - 1; i++)
    for (int j = i + 1; j < n; j++)
      sum += d[i] * d[j];
  cout << sum << endl;
}

Measured memory_bytes: 3600
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

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

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    string s;
    cin >> s;
    string res;
    for(auto &x : s){
        if(x == 'B'){
            if(SZ(res) > 0) res.pop_back();
        }else{
            res.PB(x);
        }
    }
    cout << res;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 256
/*package whatever //do not write package name here */

import java.io.*;
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 

class Main {
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next(){
            while(st==null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt(){
            return Integer.parseInt(next());
        }
    }
	public static void main (String[] args) {
		FastReader ob = new FastReader();
		int n = ob.nextInt();
		int m = ob.nextInt();
		String a="",b="";
		for (int i=0;i<m ;i++ ) {
		    a+=n;
		}
		for (int i=0;i<n ;i++ ) {
		    b+=m;
		}
		if(n>m){
		    System.out.println(b);
		    return;
		}
		System.out.println(a);
	
	}
}

Measured memory_bytes: 19156
#include <bits/stdc++.h>
#define long long long int
using namespace std;

// @author: pashka

int mod = 1000000007;

struct mint {
    int value;
    constexpr mint() : value() {}
    mint(const long &x) {
        value = normalize(x);
    }
    static long normalize(const long &x) {
        long v = x % mod;
        if (v < 0) v += mod;
        return v;
    }
    bool operator==(const mint &x) { return value == x.value; };
    mint operator+(const mint &x) { return value + x.value; };
    mint operator*(const mint &x) { return (long)value * x.value; };
    void operator+=(const mint &x) { value = normalize(value + x.value);};
    void operator-=(const mint &x) { value = normalize(value - x.value);};
};


int main() {
    ios::sync_with_stdio(false);

    int n, a, b;
    cin >> n >> a >> b;
    if (a < b) swap(a, b);
    vector<vector<mint>> d(n + 1, vector<mint>(n + 1));
    vector<vector<mint>> d2(n + 3, vector<mint>(n + 3));
    vector<vector<mint>> d3(n + 3, vector<mint>(n + 3));
    d[0][0] = 1;
    vector<mint> p2(n + 1);
    p2[0] = 1;
    for (int i = 0; i < n; i++) {
        p2[i + 1] = p2[i] * 2;
    }
    mint res = 0;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
//            cout << i << " " << j << " " << d[i][j].value << "\n";
            d2[i + 1][j] += d2[i][j];
            d3[i + 1][j + 1] += d3[i][j];
            d[i][j] += d2[i][j];
            d[i][j] += d3[i][j];
            if (d[i][j] == 0) continue;
            if (j >= a) {
                res += d[i][j] * p2[n - i];
                continue;
            } else {
                if ((n - i) >= b && j + (n - i) >= a) {
                    res += d[i][j];
                }
            }
            if (i < n) {
                d[i + 1][j + 1] += d[i][j];
            }
            {
                int l = 1;
                int r = min(b, n - i);
                if (r > l) {
                    d2[i + l + 1][1] += d[i][j];
                    d2[i + r + 1][1] -= d[i][j];
                }
            }
            {
                int l = b;
                int r = n - i;
                if (r > l) {
                    d3[i + l + 1][j + l + 1] += d[i][j];
                    d3[i + r + 1][j + r + 1] -= d[i][j];
                }
            }
        }
    }
    cout << res.value << "\n";

    return 0;
}

Measured memory_bytes: 297092
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;cin>>N>>K;
  vector<int>h(N+1);
  for(int i=1;i<=N;i++)cin>>h[i];
  vector<int>dp(N+101,INT_MAX);
  dp[1]=0;
  for(int i=1;i<=N;i++){
    for(int j=1;j<=K;j++){
      dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
    }
  }
  cout<<dp[N]<<endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner in = new Scanner(System.in);
        int a = in.nextInt(), b = in.nextInt(), c = in.nextInt();
        System.out.println(c + " " + a + " " + b);
    }

}


Measured memory_bytes: 23124
// AOJ 0596 (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0596)
#include<cstdio>
#include<algorithm>
#include<limits>
#include<vector>
#include<queue>
#define rep(i,a) for(int i=0;i<(a);++i)

const int MAX_N = 5000, INF = std::numeric_limits<int>::max()>>2;

struct St
{
	int v, cost, rest;

	St( int v, int cost, int rest )
	:	v(v), cost(cost), rest(rest)
	{}

	bool operator< ( const St &s ) const
	{ return cost > s.cost; }
};

int N, K;
int C[MAX_N], R[MAX_N];
std::vector<int> G[MAX_N];

int dp[MAX_N][MAX_N+1];

int main()
{
	scanf( "%d%d", &N, &K );
	rep( i, N )
		scanf( "%d%d", C+i, R+i );

	rep( i, K )
	{
		int A, B;
		scanf( "%d%d", &A, &B );
		--A; --B;
		G[A].push_back(B);
		G[B].push_back(A);
	}

	std::priority_queue<St> pque;
	pque.push( St( 0, C[0], R[0] ) );
	rep( i, N ) rep( j, N+1 )
		dp[i][j] = INF;
	dp[0][R[0]] = C[0];

	while( !pque.empty() )
	{
		St s = pque.top(); pque.pop();
		int v = s.v, c = s.cost, r = s.rest;

		if( v == N-1 )
			break;

		if( dp[v][r] < c )
			continue;

		if( r ) rep( i, G[v].size() )
		{
			int u = G[v][i];

			if( dp[u][r-1] > c )
			{
				dp[u][r-1] = c;
				pque.push( St( u, dp[u][r-1], r-1 ) );
			}
		}

		if( dp[v][R[v]] > dp[v][r]+C[v] )
		{
			dp[v][R[v]] = dp[v][r]+C[v];
			pque.push( St( v, dp[v][R[v]], R[v] ) );
		}
	}

	printf( "%d\n", *std::min_element( dp[N-1], dp[N-1]+N ) );

	return 0;
}

Measured memory_bytes: 99216
a,b,c = map(int,input().split())
count = 0
if a!=b and a!=c: 
    if b!=c: 
        count = 3
    elif b==c: 
        count = 2
else:
    if a==b or a==c:
        count+=1
    if b!=c:
        count+=1
print(count)

Measured memory_bytes: 9024
import java.util.Scanner;

/**
 * @author yoshizaki
 *
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner= new Scanner(System.in);
        long s = scanner.nextLong();
        long ans = 0;
        ans += (s / 500) * 1000;
        s %= 500;
        ans += (s/5) * 5;
        System.out.println(ans);
    }

}


Measured memory_bytes: 21844
chomp (my ($n, $p) = split / /, <STDIN>);
my %h;

factorization($p);
if ($p==1) {
  print "1\n";
} elsif ($n==1) {
  print "$p\n";
} else {
  my $ans = 1;
  for my $k (keys %h) {
    my $v = $h{$k};
    while ($v >= $n) {
      $ans *= $k;
      $v -= $n;
    }
  }
  print "$ans\n";
}
sub factorization {
  my $arg = shift;
  while ($arg % 2 == 0) {
    $h{2}++;
    $arg /= 2;
  }
  for (my $i=3; $i*$i<=$arg; $i+=2) {
    if ($arg % $i == 0) {
      $h{$i}++;
      return ($i, factorization($arg / $i));
    }
  }
  $h{$arg}++ if $arg > 0;
}

Measured memory_bytes: 512
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 998244353
#define reps(i,s,n) for(int i = s; i < n; i++)
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

ll d[100005];
ll e[100005];


int main(){
    ll n;
    cin >> n;
    ll m=0;
    
    rep2(i,n){
        cin >> d[i];
        if(i==1){
            if(d[1]!=0){
                cout<<0<<endl;
                return 0;
            }
        }
        m=max(m,d[i]);
        e[d[i]]++;
    }
    ll ans=1;
    if(e[0]!=1){
        cout<<0<<endl;
        return 0;
    }
    rep2(i,m){
        rep(j,e[i]){
            ans*=e[i-1];
            ans%=998244353;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
def main():
        N = int(input())

        def num2alpha(num):
            if num<=26:
                return chr(64+num)
            elif num%26==0:
                return num2alpha(num//26-1)+chr(90)
            else:
                return num2alpha(num//26)+chr(64+num%26)

        ans = num2alpha(N)

        return ans.lower()

if __name__=="__main__":
        ans = main()
        print(ans)

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

const int mod=1e9+7;

int prime[80000],num;//质数表
bool notprime[1000010];

int n;
int lcm[1000010];
int a[10010];

long long pow(long long x,int y)
{
	long long ans=1;
	while(y)
	{
		if(y&1) ans=ans*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return ans;
}

int main()
{
	//freopen("test.in","r",stdin);
	for(int i=2;i<1000005;i++)
	{
		if(!notprime[i]) prime[num++]=i;
		for(int j=0;j<num;j++)
		{
			int temp=i*prime[j];
			if(temp>1000005) break;
			notprime[temp]=1;
			if(i%prime[j]==0) break;
		}
	}
	int mxp=-1;
	scanf("%d",&n);
	long long lcmm=1;
	for(int i=1,x;i<=n;i++)
	{
		scanf("%d",&a[i]);
		x=a[i];
		for(int j=0;x>1&&prime[j]*prime[j]<=x;j++)
		{
			if(x%prime[j]==0)
			{
				int count=0;
				while(x%prime[j]==0) count++,x/=prime[j];
				lcm[j]=std::max(lcm[j],count);
				mxp=std::max(mxp,j);
			}
		}
		if(x>1)
		{
			int j=std::lower_bound(prime,prime+num,x)-prime;
			lcm[j]=std::max(lcm[j],1);
			mxp=std::max(mxp,j);
		}
	}
	for(int i=0;i<=mxp;i++) if(lcm[i]) lcmm*=pow(prime[i],lcm[i]),lcmm%=mod;
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		ans+=pow(a[i],mod-2)*lcmm%mod;
		ans%=mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3840
#include <stdio.h>

int main(){

  int n,i,j,minj,temp,sum = 0,sita = 0;
  int a[124] = {};
  

  
  scanf("%d",&n);

  for(i = 0;i < n;i++) scanf("%d",&a[i]);
  
  for(i = 0;i <= n - 1;i++){
    minj = i;
    for(j = i;j <= n - 1;j++){
      if(a[j] < a[minj]){
	minj = j;
      }
    }
    // printf("a[i] = %d,a[minj] = %d\n",a[i],a[minj]);
      if(i != minj){
	temp = a[i];
	a[i] = a[minj];
	a[minj] = temp;
	sum++;
      }
  }
  for(i = 0;i < n;i++){
    if(i != n - 1)printf("%d ",a[i]);
    else printf("%d",a[i]);
  }
  printf("\n");
  printf("%d\n",sum);
  return 0;
}

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

int main()
{
    int N;
    int T[105], V[105];
    int maxV[40005];

    cin >> N;
    for ( int i = 0; i < N; i++ ) {
        cin >> T[i];
        T[i] *= 2;
        if ( i > 0 ) {
            T[i] += T[i - 1];
        }
    }
    for ( int i = 0; i < N; i++ ) {
        cin >> V[i];
        V[i] *= 2;
    }
    maxV[T[N - 1]] = 0;
    for ( int i = N - 1; i >= 0; i-- ) {
        int low;
        if ( i == 0 ) {
            low = 0;
        } else {
            low = T[i - 1];
        }
        for ( int t = T[i] - 1; t >= low; t-- ) {
            maxV[t] = min(maxV[t + 1] + 1, V[i]);
        }
    }

    maxV[0] = 0;
    for ( int i = 0; i < N; i++ ) {
        int low;
        if ( i == 0 ) {
            low = 0;
        } else {
            low = T[i - 1];
        }
        for ( int t = low + 1; t <= T[i]; t++ ) {
            maxV[t] = min( { maxV[t - 1] + 1, maxV[t], V[i] } );
        }
    }

    double sum = 0;
    for ( int t = 0; t < T[N - 1]; t++ ) {
        sum += (maxV[t] + maxV[t + 1]) / 2.0;
    }
    printf("%.10f\n", sum / 4.0);

    return ( 0 );
}


Measured memory_bytes: 384
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
const int MOD = 1000000007;


typedef long long int ll; 
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

void floatOutPutSetup(){
    cout << fixed;
    cout << setprecision(10);
}

int main(){
    string s;
    bool a=false,b=false;
    cin>>s;
    rep(i,s.size()){
        if(s[i]=='A')a=true;
        if(s[i]=='B')b=true;
    }
    if(a&&b)cout<<"Yes";
    else cout<<"No";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <math.h>

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

typedef int long long ill;
typedef int long il;

using namespace std;

#define N 100
#define L 100
int n, l;
string s[N];
string ss;
void set();
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n >> l;

    REP(i, n)
    {
        cin >> s[i];
    }
    set();
    cout << ss << endl;
    return 0;
}

void set()
{
    string min;
    min = s[0];
    int flag = 0;
    REP(i, n)
    {
        REP(j, n)
        {
            int k = 0;
            while (min[k] >= s[j][k])
            {
                if (min[k] > s[j][k])
                {
                    min = s[j];
                    flag = j;
                    break;
                }
                k++;
                if (k == n)
                {
                    break;
                }
            }
        }
        ss += min;
        s[flag] = 'z' + 1;
        min = 'z' + 1;
    }
}

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

int n, flag=0, ans=0;
vector<int> bi;

//0~pa-1を長さnで生成、合計pa^n個生成
void bitgen(int len){
  	if(flag) return;

	//生成完了時の処理
	if(len==0){
      	int d=0;
      	vector<int> cnt(10, 0);
      
		/*for(int i=0;i<bi.size();i++){
          cout<< bi[bi.size()-1-i];
        }
      	cout<< endl;*/

		for(int i=0;i<bi.size();i++){
          	d+=bi[bi.size()-1-i]*pow(10, bi.size()-1-i);
          	cnt[bi[bi.size()-1-i]]=1;
          	if(bi[bi.size()-1-i]==0 && cnt[3]+cnt[5]+cnt[7]>0) return;
		}
      	//cout<< "d=" << d <<endl;
      
      	if(n<d){
          	flag=1;
          	return;
        }
      
      	if(cnt[3]*cnt[5]*cnt[7]==1) ans++;
      	//cout<< "#" <<endl;
		return;
	}

  	bi[len-1]=0;
	bitgen(len-1);
  	bi[len-1]=3;
	bitgen(len-1);
  	bi[len-1]=5;
	bitgen(len-1);
  	bi[len-1]=7;
	bitgen(len-1);
}

int main(){

  	string s;
	cin>> n;
  
  	s=to_string(n);

	bi.resize(s.size());
	bitgen(s.size());

	cout<< ans <<endl;

	return 0;
}

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

int main(){
	int N;
  cin>>N;
  int h[N];
  rep(i,N){
  	cin>>h[i];
  }
  ll dp[100100];
  dp[0]=0;
  
  
  for(int i=1;i<N;i++){
  	dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
  
 // rep(i,N)cout<<dp[i]<<" ";
  cout<< dp[N-1];
  
  
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

string get_string(int x) {
	string t = to_string(x);
	while(t.size() < 6) t = "0" + t;
	return t;
}

int main(int argc, char const *argv[])
{
	int n, m; cin >> n >> m;
	vector<int> p(m), y(m); {
		rep(i, m) cin >> p[i] >> y[i];
	}
	vector<pair<int, int>> v[100010]; {
		rep(i, m) {
			v[p[i]].pb(mp(y[i], i));
		}
		rep(i, 100010) sort(all(v[i]));
	}

	vector<string> ans(m); {
		rep(i, 100010) {
			int cnt = 1;
			for (auto u : v[i]) {
				string tmp = get_string(i) + get_string(cnt);
				ans[u.second] = tmp;
				cnt++;
			}
		}
	}

	for (const auto& u : ans) cout << u << endl;

	return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

constexpr int INF = 1e9;
constexpr ll INFLL = 1e18;
constexpr int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    //cout << fixed << setprecision(6);
    string s; cin >> s;

    vi a(3, 0);
    for(char c : s){
        if(c == 'a') a[0]++;
        if(c == 'b') a[1]++;
        if(c == 'c') a[2]++;
    }
    int dist = *max_element(all(a)) - *min_element(all(a));
    
    cout << (dist <= 1 ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

char* days[7] = {
 "Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday"};

                 /*  1   2   3   4   5    6   7   8   9  10  11  12 */
int Month[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};


int main(){
  int i;
  int n, m, d;

  while(scanf("%d %d", &m, &d)==2){
    if(m==0&&d==0)
      break;
    n = 0;
    for(i=0;i<m;i++)
      n += Month[i];
    printf("%s\n", days[(n+d+2)%7]);
  }
  return 0;
}

Measured memory_bytes: 0
import sys
readline = sys.stdin.readline

class UF():
    def __init__(self, num):
        self.par = [-1]*num
        self.comp = [False]*num
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            stack = []
            while self.par[x] >= 0:
                stack.append(x)
                x = self.par[x]
            for xi in stack:
                self.par[xi] = x
            return x
    
    def union(self, x, y):
        rx = self.find(x)
        ry = self.find(y)
        if rx != ry:
            if self.comp[rx] and self.comp[ry]:
                return False
            if self.par[rx] > self.par[ry]:
                rx, ry = ry, rx
            self.comp[rx] |= self.comp[ry]
            self.par[rx] += self.par[ry]
            self.par[ry] = rx
            return True
        elif not self.comp[rx]:
            self.comp[rx] = True
            return True
        return False


N, H, W = map(int, readline().split())

geta = 10**5

Edge = []
for _ in range(N):
    h, w, a = map(int, readline().split())
    h -= 1
    w -= 1
    Edge.append((a, h, geta+w))

Edge.sort(reverse = True)

T = UF(2*geta)

ans = 0
for cost, a, b in Edge:
    if T.union(a, b):
        ans += cost
print(ans)


Measured memory_bytes: 67420
import java.util.*;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		long ans = 0;
		
		for(int i=1;i<=n;i++) {
			if(i%3 !=0 && i%5 !=0) {
				ans += i;
			}
		}
		
		System.out.println(ans);
	}	
}


Measured memory_bytes: 35716
#include <bits/stdc++.h>
using namespace std;
int n;
int a[200001];
int x;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		a[x]++;
	}
	int ans=0;
	for(int i=1;i<=100000;i++){
	    ans=max(ans,a[i]+a[i-1]+a[i+1]);
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 640
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec_raw<>() -> Vec<String> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.to_string()).collect::<Vec<String>>().clone()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    let mut v2 = Vec::new();
    for _ in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        let v = s.trim().split_whitespace()
            .map(|e| e.parse().ok().unwrap()).collect();
        v2.push(v);
    }
    v2
}

fn solve_a(){

    /*let mut str1 = read_vec_raw()[0].clone();
    let str2 = read_vec_raw()[0].clone();
    str1.push_str(&str2);*/

    let vec : Vec<Vec<usize>> = read_vec2(3);
    let n1 = vec[0][0].clone();
    let n2 = vec[1][0].clone();
    let n3 = vec[2][0].clone();


    let result = (n1 - n2) % n3;
    println!("{}",result);

}

fn main (){

    solve_a();
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <functional>
#include <typeinfo>
#include <utility>
#include <tuple>
#include <queue>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define all(arr) (arr).begin(), (arr).end()
#define yn(formula) (formula) ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(formula) (formula) ? (cout << "YES" << endl) : (cout << "NO" << endl)

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pii> vp;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vp> vvp;

constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1ll << 59;
constexpr ll MOD = 1e9 + 7;
constexpr double EPS = 1e-7;
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };

/*<ここから>***********************************************************/



int main()
{
	int N, M;
	cin >> N >> M;
	vvi g(N);
	rep(i, M) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	vi next;
	bool ok = false;
	rep(i, g[0].size()) {
		if (g[0][i] == N - 1) {
			ok = true;
			break;
		}
		next.push_back(g[0][i]);
	}

	if (!ok) {
		rep(i, next.size()) {
			rep(j, g[next[i]].size()) {
				if (g[next[i]][j] == N - 1) {
					ok = true;
					goto ans;
				}
			}
		}
	}

ans:
	if (ok) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;

}


Measured memory_bytes: 12784
import fractions

def main():
    A,B=map(int,input().split())
    gcd = fractions.gcd(A, B)
    ans=[1]
    sqrt=gcd**0.5
    
    #gcdの素因数の個数を求める
    
    while gcd%2==0:
        gcd=gcd//2
        ans.append(2)
    f=3
    while f*f<=gcd:
        if gcd%f==0:
            gcd=gcd//f
            ans.append(f)
        else:
            f+=2
    
    if gcd!=1:
        ans.append(gcd)
        
    print(len(set(ans)))

if __name__=="__main__":
    main()


Measured memory_bytes: 5300
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) std::cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) std::cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) std::cout << x << endl;
#define println(x) std::cout << x << endl;
using namespace std;
// using namespace atcoder;

vector<ll> fact;

void calcFact(ll n, ll mod) {
    fact.assign(n+1, 1);
    repi(i, n+1) {
        fact[i] = fact[i-1] * i % mod;
    }
}

ll mpow(ll x, ll n, ll mod){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mod;
        x = x*x % mod;
        n = n >> 1;
    }
    return ans;
}

ll combination(ll n, ll a, ll mod) {
    if (n < a) {
        return 0;
    }

    ll X = fact[n];
    ll Y = fact[a];
    ll Z = fact[n-a];
    ll iY = mpow(Y, mod - 2, mod);
    ll iZ = mpow(Z, mod - 2, mod);

    ll res = X * iY % mod;
    res = res * iZ % mod;

    return res;
}

ll P(ll n, ll a, ll mod) {
    if (n < a) {
        return 0;
    }

    ll X = fact[n];
    ll Z = fact[n-a];
    ll iZ = mpow(Z, mod - 2, mod);

    ll res = X * iZ % mod;

    return res;
}

void Main()
{
    ll n, M;
    cin >> n >> M;
    
    ll mod = 7+1e9;
    calcFact(M+1, mod);

    ll res = 0;
    rep(i, n+1) {
        if (i % 2 == 0) {
            res += P(M-i, n-i, mod) * combination(n, i, mod) % mod;
        }
        else {
            res -= P(M-i, n-i, mod) * combination(n, i, mod) % mod;
        }
        res = (res + mod) % mod;
    }

    res = res * P(M, n, mod) % mod;
    put(res);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 7172
#include <bits/stdc++.h>
using namespace std;
#define int long long
void run();
signed main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(13); run(); }
mt19937 rng(random_device{}());

void run() {
    int n, k;
    cin >> n >> k;
    long double p[n];
    long double e[n];
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
        e[i] = (p[i] + 1 ) / 2;
        p[i] = (i ? p[i - 1] : 0) + e[i];
    }
    long double ans = 0;
    for (int i = k - 1; i < n; ++i)
        ans = max(ans, p[i] - p[i - k + 1] + e[i - k + 1]);
    cout << ans << endl;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
#define PI  acos(-1)
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int H,W,N;cin>>H>>W>>N;
  vector<int> arr(N);
  REP(i,0,N)cin>>arr[i];
  vector<vector<int>> G(H,vector<int>(W,1));
  int idx=0;
  REP(h,0,H)REP(w,0,W){
    if(arr[idx]==0){
      idx++;
    }
    G[h][w]=idx+1;
    arr[idx]--;
  }
  // debug(G);
  REP(i,0,H){
    vector<int> tmp=G[i];
    if(i%2==1)reverse(ALL(tmp));
    //debug(tmp);
    REP(w,0,W)cout<<tmp[w]<<" ";
    cout<<"\n";
  }
  cout<<"\n";

}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <string>
#include <string.h>
#include <math.h>
#include <iomanip>
using namespace std;

#define int64 long long
#define pii pair <int64, int64>
#define fr first
#define sc second
#define heap priority_queue
struct piii{
    int64 fr, sc, th;
    bool operator < (const piii &b){
        if (fr != b.fr) return fr < b.fr;
        if (sc != b.sc) return sc < b.sc;
        return th < b.th;
    }
};
///////////////////////////////////////////////
///////////////////////////////////////////////

int main(){
    cout << setprecision(2) << fixed;
    ios::sync_with_stdio(false), cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    int res = 0;
    for (int i = 1; i <= n; i++){
        int val = i, cnt = 0;
        while (val > 0) val /= 10, cnt++;
        res += cnt % 2;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 384
N = int(input().rstrip())
Hs = [int(x) for x in input().rstrip().split()]

max_height = max(Hs)

tot_num=0
for i in range(max_height): #iはチェックする高さ
    temp_num = 0
    continuum=0
    for j in range(0,N):
        if continuum==0 and Hs[j]>i:
            temp_num+=1
            continuum+=1
            continue
        elif Hs[j]>i:
            continuum+=1
            continue
        else:
            continuum = 0
            continue
    tot_num += temp_num


print(tot_num)



Measured memory_bytes: 39280
#include<iostream>
#include<string.h>
#define ll long long int
using namespace std;

int main(){
	ll h,w;
	cin>>h>>w;
	char a[h][w];
	ll c[h][w];
	for(ll i=0; i<h; i++)
		for(ll j=0; j<w; j++){
			cin>>a[i][j];
			if(a[i][j]== '#')
				c[i][j] = 0;
		}
	
	for(ll i=0; i<h; i++){
		for(ll j=0; j<w; j++){
			if(a[i][j] != '#'){
				ll z = 0;
				if(i == 0 && j == 0)
					z = 1;
				if(i != 0)
					z = (z + c[i-1][j])%1000000007;
				if(j != 0)
					z = (z + c[i][j-1])%1000000007;
				c[i][j] = z;
			}
		}
	}
	cout<<c[h-1][w-1];
}

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

const int INF = 1 << 30;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int c = INF, f = -1;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == 'C') c = min(c, i);
        else if (S[i] == 'F') f = max(f, i);
    }
    if (c < f) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    pair<pair<string, int>, int> p[n];
    for (int i = 0; i < n; i++) {
        string city;
        int point;
        cin >> city >> point;
        p[i].first.first = city;
        p[i].first.second = (-1) * point;
        p[i].second = i + 1;
    }
    sort(p, p + n);
    for (int i = 0; i < n; i++) {
        cout << p[i].second << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>

int main(void){
    int A, B, C, X, ans=0;
    std::cin >> A >> B >> C >> X;

    for (int i=0; i<=A; ++i){
        for (int j=0; j<=B; ++j){
            for (int k=0; k<=C; ++k){
                if (500 * i + 100 * j + 50 * k == X) ++ans;
            }
        }
    }

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


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;
typedef tuple<int,int,int> TP;
int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  c *= 2;
  cout << min(max(x, y) * min(a + b, c), min(x, y) * min(a + b, c) + (x < y ? b : a) * abs(x - y)) << endl;
  return 0;
} 

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
bool dpx[2][18002];
bool dpy[2][18002];
ll xaxis=1;
ll xnow=1;
ll ynow=1;
bool beg=true;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;cin>>s;
  ll x,y;cin>>x>>y;
  dpx[0][9001]=true;
  dpy[0][9001]=true;
  for(int i=0;i<s.size();i++){
    ll muki=0;
    while(i<s.size()&&s[i]=='T'){i++;muki++;}
    ll susumu=0;
    while(i<s.size()&&s[i]=='F'){i++;susumu++;}
    if(muki==0&&beg){dpx[xnow][9001+susumu]=true;xnow++;xnow%=2;dpx[xnow][9001]=false;beg=false;i--;continue;}
    beg=false;
    if(muki%2){xaxis++;xaxis%=2;}
    if(xaxis){
      for(int j=0;j<18002;j++){
	if(dpx[(xnow+1)%2][j]){
	  dpx[xnow][j-susumu]=true;
	  dpx[xnow][j+susumu]=true;
	
	  dpx[(xnow+1)%2][j]=false;
	}
      }
      xnow++;xnow%=2;
    }else{
      for(int j=0;j<18002;j++){
	if(dpy[(ynow+1)%2][j]){
	  dpy[ynow][j-susumu]=true;
	  dpy[ynow][j+susumu]=true;
	  dpy[(ynow+1)%2][j]=false;
	}
      }
      ynow++;ynow%=2;
    }
    if(i==s.size())break;
    i--;
  }
  if(dpx[(xnow+1)%2][x+9001]&&dpy[(ynow+1)%2][y+9001])
    cout<<"Yes"<<endl;
  else 
    cout<<"No"<<endl;
  return 0;
}


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

#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>

using namespace std;
typedef long long ll;

char c;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;


int main()
{
   FAST/**/
   
   ll n;
   cin>>n;
   
   if(n%2 == 1)
   {
       cout<<0;
       return 0;
   }
   
   ll m1 = n/2;
   n/=2;
   ll curr = n;
   while(curr>0)
   {
       curr/=2;
       m1+=curr;
   }
   ll m2 = 0;
   curr = n;
   
   while(curr>0)
   {
       curr/=5;
       m2+=curr;
   }
   
   cout<<min(m1,m2);
   
   return 0;        
}  
   

Measured memory_bytes: 256
from collections import deque
h,w=map(int,input().split())
ch,cw=map(int,input().split())
dh,dw=map(int,input().split())
s=[list(input()) for i in range(h)]

#幅優先で解く。
dx=[1,0,-1,0]
dy=[0,1,0,-1]
def bfs():
  maze=[[-1]*w for i in range(h)]
  maze[ch-1][cw-1]=0
  qu=deque([])
  qu.append((cw-1,ch-1))
  magic=0
  
  while qu:
    x,y=qu.popleft()
    for i in range(x-2,x+3):
      for j in range(y-2,y+3):
        nx=i
        ny=j
        if 0<=nx<=w-1 and 0<=ny<=h-1 and s[ny][nx]=="." and (maze[ny][nx]==-1 or maze[ny][nx]>maze[y][x]+1):
          qu.append((nx,ny))
          maze[ny][nx]=maze[y][x]+1
    for i in range(4):
      nx=dx[i]+x
      ny=dy[i]+y
      
      if 0<=nx<=w-1 and 0<=ny<=h-1 and s[ny][nx]=="." and (maze[ny][nx]==-1 or maze[ny][nx]>maze[y][x]):
        qu.appendleft((nx,ny))
        maze[ny][nx]=maze[y][x]
  return maze
    
maze = bfs()
print(maze[dh-1][dw-1])

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

typedef long long ll;
typedef pair<int, int> P;

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    string s; cin>>s;
    int n=s.size();

    for(int i=0; i+1<n; i++){
        if(s[i] == s[i+1]){
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }
    }

    for(int i=0; i+2<n; i++){
        if(s[i] == s[i+2]){
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }

    cout << -1 << " " << -1 << endl;
}

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

public static class Test
{
    public static IEnumerable<S> Scan<T, S>(this IEnumerable<T> ie, S init, Func<S, T, S> predicate)
    {
        var sum = init;
        foreach(var x in ie)
            yield return sum = predicate(sum, x);
    }
    
    public static void Main()
    {
        Console.ReadLine();
        var directions = Console.ReadLine().Select(x => x == 'E' ? 1 : 0).ToArray();
        
        var costs = directions
            .Scan(
                (directions.Sum() << 1) + 1,
                (s, x) => (((s >> 1) + (~s & 1) - x) << 1) + x);
        
        Console.WriteLine(costs.Min() >> 1);
    }
}


Measured memory_bytes: 16736
def mi():
    return map(int, input().split())

def main():
    N, T = mi()
    ct = [map(int, input().split()) for _ in range(N)]
    c, t = [list(i) for i in zip(*ct)]
    m = 10**100
    bl = False
    for i in range(N):
        if t[i] <= T:
            m = min(m, c[i])
            bl = True
    print(m if bl else 'TLE')


if __name__ == '__main__':
    main()

Measured memory_bytes: 38528
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<math.h>
#include<functional>
#include<bitset>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define MOD 998244353LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(int)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	vector<ll> b(n);
	REP(i, n) cin >> b[i];
	vector<ll> ans(n, -1);
	for(ll i = n - 1; i >= 0; i--) {
		ll tmp = b[i], c = 0;
		bool ok = false;
		REP(j, n) {
			if(ans[j] == -1) c++;
			if(c == tmp) {
				ans[j] = b[i];
				ok = true;
				break;
			}
		}
		if(!ok) {
			cout << -1 << endl;
			return 0;
		}
	}
	REP(i, n) {
		if(ans[i] > i + 1) {
			cout << -1 << endl;
			return 0;
		}
	}
	REP(i, n) {
		cout << ans[i] << endl;
	}
	return 0;
}

/* --------------------------------------- */


Measured memory_bytes: 256