akhauriyash/Code-Regression huggingface dataset:
import sys
import copy

def main():
  input = sys.stdin.readline
  n, k = map(int, input().split())
  a = [int(x)-1 for x in input().split()]
  key = [copy.deepcopy(a) for _ in range(61)]
  for i in range(60):
    for j in range(n):
      key[i+1][j] = key[i][key[i][j]]
  
  i = 0
  now = 0
  while k > 0:
    if k%2:
      now = key[i][now]
    k //= 2
    i += 1
  
  print(now+1)
  
if __name__ == "__main__":
  main()

Measured memory_bytes: 212568
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;


int main() {
    int n, a[105];
    cin >> n;
    for (int i = 0; i < n; i++)cin >> a[i];
    sort(a, a + n, greater<int>());
    int Alice = 0, Bob = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0)Alice += a[i];
        else Bob += a[i];
    }
    cout << Alice - Bob << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
using namespace std;

int main() {
    int N, cnt[8] = {0}, more = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        if (a < 3200) {
            cnt[a / 400] = 1;
        } else {
            more++;
        }
    }
    int sum = 0;
    rep(i,0,8){
        sum += cnt[i];
    }
    cout << max(1, sum) << " " << sum + more << endl;
}

Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(dead_code)]
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn input<T: FromStr>(&mut self) -> T {
        self.read().unwrap()
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.input()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: usize = sc.input();
    let m: usize = sc.input();
    let k: usize = sc.input();
    let ax: Vec<usize> = sc.vec(n);
    let bx: Vec<usize> = sc.vec(m);

    let mut aacc = vec![0; n + 1];
    let mut bacc = vec![0; m + 1];

    for i in 0..n {
        aacc[i + 1] = ax[i] + aacc[i];
    }
    for i in 0..m {
        bacc[i + 1] = bx[i] + bacc[i];
    }

    let mut cnt = 0usize;
    for i in 0..=n {
        let time = aacc[i];
        if time <= k {
            let rest = k - time;
            let idx = bacc.upper_bound(&rest);
            let idx = if idx == 0 { 0 } else { idx - 1 };
            cnt = std::cmp::max(cnt, i + idx);
        }
    }
    println!("{}", cnt);
}

trait BinarySearch<T> {
    fn lower_bound(&self, key: &T) -> usize;
    fn upper_bound(&self, key: &T) -> usize;
}

use std::cmp::Ordering;
impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, key: &T) -> usize {
        let mut ng = -1;
        let mut ok = self.len() as i64;
        while (ok - ng).abs() > 1 {
            let mid = (ok + ng) / 2;
            match key.cmp(&self[mid as usize]) {
                Ordering::Less | Ordering::Equal => {
                    ok = mid;
                }
                Ordering::Greater => {
                    ng = mid;
                }
            }
        }
        ok as usize
    }

    fn upper_bound(&self, key: &T) -> usize {
        let mut ng = -1;
        let mut ok = self.len() as i64;
        while (ok - ng).abs() > 1 {
            let mid = (ok + ng) / 2;
            match key.cmp(&self[mid as usize]) {
                Ordering::Less => {
                    ok = mid;
                }
                Ordering::Equal | Ordering::Greater => {
                    ng = mid;
                }
            }
        }
        ok as usize
    }
}


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

#define pb push_back
#define pob pop_back
#define mp make_pair
#define f first
#define s second

typedef long long ll;
const ll Inf = 1e18;
const ll mod = 1e9 + 7;

void solve(){
	int x,a;
	cin>>x>>a;
	if(x<a) cout<<0;
	else cout<<10;
}

int main(){
	ios_base::sync_with_stdio(0);
  cin.tie(0);
	solve();
}


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

using namespace std;

int main(void){
    int n, x;
    cin >> n >> x;
    int l[n];
    for(int i = 0; i < n; i++)cin >> l[i];
    int sum = 1, now = 0;
    for(int i = 0; i < n; i++){
        now += l[i];
        if(now <= x)sum++;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int h, n; std::cin >> h >> n;
    std::vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) std::cin >> a[i] >> b[i];
    std::vector<int> dp(h + 2, 1e9);
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < h; j++) {
            dp[std::min(h, j + a[i])] = std::min(
                dp[std::min(h, j + a[i])], dp[j] + b[i]);
        }
    }
    std::cout << dp[h] << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define INF (1e9)
#define N 20
using namespace std;
typedef pair<int,int> P;
void func(int,int,int);
P Cnt(int,int,int);
int w,h,data[N][N],flag,ans;
int main(){
  int sy,sx;
  while(1){
    cin >> w >> h;
    if(w==0&&h==0) break;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> data[i][j];
	if(data[i][j]==2) sy=i,sx=j;
      }
    }
    ans=INF;
    func(0,sy,sx);
    if(ans!=INF) cout << ans << endl;
    else cout << -1 << endl;
  }
  return 0;
}
void func(int d,int y,int x){
  P r;
  if(d==10) return ;
  flag=0;
  r=Cnt(0,y,x);
  if(r.second==1&&r.first>=1){
    data[y-r.first-1][x]=0;
    func(d+1,y-r.first,x);
    data[y-r.first-1][x]=1;
  }
  else if(flag) ans=min(ans,d+1);
  flag=0;
  r=Cnt(1,y,x);
  if(r.second==1&&r.first>=1){
    data[y][x+r.first+1]=0;
    func(d+1,y,x+r.first);
    data[y][x+r.first+1]=1;
  }
  else if(flag) ans=min(ans,d+1);
  flag=0;
  r=Cnt(2,y,x);
  if(r.second==1&&r.first>=1){
    data[y+r.first+1][x]=0;
    func(d+1,y+r.first,x);
    data[y+r.first+1][x]=1;
  }
  else if(flag) ans=min(ans,d+1);
  flag=0;
  r=Cnt(3,y,x);
  if(r.second==1&&r.first>=1){
    data[y][x-r.first-1]=0;
    func(d+1,y,x-r.first);
    data[y][x-r.first-1]=1;
  }
  else if(flag) ans=min(ans,d+1);
}
P Cnt(int d,int y,int x){
  int dy[4]={-1,0,1,0};
  int dx[4]={0,1,0,-1};
  int cnt=0;
  while(1){
    cnt++;
    y+=dy[d];
    x+=dx[d];
    if(y<0||h<=y||x<0||w<=x) break;
    if(data[y][x]==3){
      flag=1;
      return P(cnt,3);
    }
    if(data[y][x]==1) return P(cnt-1,1);
  }
  return P(0,0);
}

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

int main() {
	int W, a, b;
	cin >> W >> a >> b;
	
  	int ans;
  	if( a < b )ans = b - ( a + W );
 	else ans = a - ( b + W );
  
  	cout << max(ans, 0) << endl;
}

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

const int MAX_N = 50;
int v[MAX_N];

int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int p, q;
    cin >> p >> q;
    v[p-1]++;
    v[q-1]++;
  }
  for (int i = 0; i < n; i++) {
    cout << v[i] << endl;
  }
}

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

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> V(N);
  for (int i = 0; i < N; i++) cin >> V[i];
  nth_element(V.begin(), V.begin() + K, V.end(), greater<int>());
  int answer = accumulate(V.begin(), V.begin() + K, 0);
  cout << answer;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}
	int size(int a) {
		return par[root(a)];
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
int main(){
	int n, k;
	cin >> n >> k;
	hei(int) a(n), ans(n,0);
	rep(i, 0, n)cin >> a[i];
	rep(j, 0, k) {
		rep(i, 0, n) {
			ans[max(0, i - a[i])]++;
			if (i + a[i] + 1 < n)ans[i + a[i] + 1]--;
		}
		rep(i, 1, n)ans[i] += ans[i - 1];
		bool S = true;
		rep(i, 0, n) {
			a[i] = ans[i];
			ans[i] = 0;
		}
		rep(i, 0, n)if (n!=a[i])S = false;
		if (S)break;
	}
		rep(i, 0, n) {
			cout << a[i];
			if (i == n - 1)cout << endl;
			else cout << " ";

		}
	return 0;
}

Measured memory_bytes: 4844
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>

int main(void)
{
	int n;
	int array[100];

	scanf("%d", &n);
	int i = 0;
	while (i < n)
	{
		scanf("%d ", &array[i]);
		i++;
	}
	int j = 0;
	while (j < n)
	{
		if (array[j] % 2 == 0)
		{
			if (!(array[j] % 3 == 0 || array[j] % 5 == 0))
			{
				printf("DENIED");
				return 0;
			}
		}
		j++;
	}
	printf("APPROVED");
	return (0);
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
int main()
{
    LL n,a,b,ans;
    cin>>n>>a>>b;
    if(a>b)swap(a,b);
    if((b-a)&1)
    cout<<(min((n-b+n-a+1)/2,(a-1+b)/2));
    else
       cout<<(b-a)/2;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main ()
{
	long long N,a[150000],b[150000],i,c;
	scanf("%lld",&N);

	for(i=1;i<=N;i++)
	{
		scanf("%lld",&a[i]);
		c=a[i];
		b[c-1]=i;
	}
	
	for(i=0;i<N;i++)
	{
		printf("%lld ",b[i]);
	}
	return 0;
	
}

Measured memory_bytes: 2816
/*
░░░░░░░░░░░░░░░░▄▄█▀▀██▄▄░░░░░░░
░░░░░░░░░░░░░▄█▀▀░░░░░░░▀█░░░░░░
░░░░░░░░░░░▄▀░░░░░░░░░░░░░█░░░░░
░░░░░░░░░▄█░░░░░░░░░░░░░░░█░░░░░
░░░░░░░██▀░░░░░░░▄▄▄░░▄░█▄█▄░░░░
░░░░░▄▀░░░░░░░░░░████░█▄██░▀▄░░░
░░░░█▀░░░░░░░░▄▄██▀░░█████░██░░░
░░░█▀░░░░░░░░░▀█░▀█▀█▀▀▄██▄█▀░░░
░░░██░░░░░░░░░░█░░█░█░░▀▀▄█▀░░░░
░░░░█░░░░░█░░░▀█░░░░▄░░░░░▄█░░░░
░░░░▀█░░░░███▄░█░░░░░░▄▄▄▄█▀█▄░░
░░░░░▀██░░█▄▀▀██░░░░░░░░▄▄█░░▀▄░
░░░░░░▀▀█▄░▀▄▄░▄░░░░░░░███▀░░▄██
░░░░░░░░░▀▀▀███▀█▄░░░░░█▀░▀░░░▀█
░░░░░░░░░░░░▄▀░░░▀█▄░░░░░▄▄░░▄█▀
░░░▄▄▄▀▀▀▀▀█▀░░░░░█▄▀▄▄▄▄▄▄█▀▀░░
░▄█░░░▄██▀░░░░░░░░░█▄░░░░░░░░░░░
█▀▀░▄█░░░░░░░░░░░░░░▀▀█▄░░░░░░░░
█░░░█░░░░░░░░░░░░░░░░░░█▄░░░░░░░
*/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
//#define =1e9 =(int)1e9
const ll mod = 1000000007;
const ll nmax=1000003;
#define int ll
int n, k;
ll ans=1;
vi g[100001];

void dfs(int nod, int p){
    int cnt=1;
    if(p==0) --cnt;
    for(int i: g[nod]){
        if(i!=p){
            ans*=max(0LL, (k-cnt-1));
           // cout<<ans<<" ";
            cnt++;
            ans%=mod;
            dfs(i, nod);
        }
    }
}

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin>>n>>k;
    for(int i=1, x, y; i<=n-1; i++){
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
   // for(int i=1; i<=4; i++){cout<<i<<": ";for(int j: g[i]) cout<<j<<" "; cout<<endl;}
    ans=k;
    dfs(1, 0);
    cout<<ans;
}


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

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

	string ptn = "keyence";
	int n = ptn.size();
	string ans = "NO";
	if( S == ptn ) ans = "YES";
	if( S.substr( 0, n ) == ptn ) ans = "YES";
	if( S.substr( S.size() - n, n ) == ptn ) ans = "YES";
	for( int i = 1; ans == "NO" && i < ptn.size(); i++ ) {
		string s1 = ptn.substr( 0, i );
		string s2 = ptn.substr( i, n - i );
		if( S.substr( 0, i ) == s1 && S.substr( S.size() - (n - i), n - i ) == s2 ) ans = "YES";
	}

	cout << ans << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int player[1010][1010] = {};
    REP(i,N) REP(j,N-1){
        cin >> player[i][j];
        player[i][j]--;
    }
    int ans = 0;
    int cnt[1010] = {};
    int sum = 0;
    int step = 0;
    while(sum < N*(N-1)){
        ans++;
        int tmp = sum;
        int done[1010] = {};
        REP(i,N){
            step++;
            if(cnt[i] > ans) continue;
            if(cnt[i] >= N-1) continue;
            int outside = player[i][cnt[i]];
            if(cnt[outside] < ans){
                if(i == player[outside][cnt[outside]] && !done[i] && !done[outside]){
                    //cout << i+1 << ":" << outside+1 << endl;
                    cnt[i]++;
                    cnt[outside]++;
                    done[i] = true;
                    done[outside] = true;
                    sum += 2;
                }
            }
            else continue;
        }
        if(sum == tmp){
            cout << -1 << endl;
            return 0;

        }
        if(sum >= N*(N-1)) break;
        //cout << ans << endl;
        /*if(step >= 1e8){
            cout << N*(N-1)/2 << endl;
            return 0;
        }*/
    }
    cout << ans << endl;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    ll ans=0;
    REP(i,s.size()){
        ll tmp=0;
        for(int j=i;j<s.size();j++){
            //cout<<s[j]<<endl;
            if(s[j]=='A' || s[j]=='T' || s[j]=='C' || s[j]=='G'){
                tmp++;
                //cout<<tmp<<endl;
            }
            else{
                ans = max(ans,tmp);
                tmp=0;
            }
        }
        ans = max(ans,tmp);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
const int INF = 1 << 30;
using namespace std;
int n, m, ans = 0;
string s, t;
int tra[2001][2], dp[2001][2001][2];
int hanten(int h){
	if (h == 0)
		return 1;
	else
		return 0;
}
int main(){
	cin >> n >> m;
	cin >> s >> t;
	for (int i = 0; i < n; i++){
		if (s[i] == 'I')
			tra[i+1][0] = 1;
	}
	for (int i = 0; i < m; i++){
		if (t[i] == 'I')
			tra[i+1][1] = 1;
	}
	for (int i = 0; i <= n; i++){
		for (int j = 0; j <= m; j++){
			for (int k = 0; k < 2; k++){
				int k2 = hanten(k);
				if (k == tra[i][0] && i){
					if (dp[i-1][j][k2]||k)
					dp[i][j][k] = max(dp[i - 1][j][k2] + 1, dp[i][j][k]);
				}
				if (k2 == tra[j + 1][1] &&j < m){
					if (dp[i][j][k]||k2)
					dp[i][j + 1][k2] = max(dp[i][j][k] + 1, dp[i][j + 1][k2]);
				}
				if (k)
					ans = max(ans, dp[i][j][k]);
				if (k2)
					ans = max(ans, dp[i][j + 1][k2]);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 32504
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    cout << (s < t ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import bisect
n=int(input())
a=sorted(list(map(int,input().split())))
b=list(map(int,input().split()))
c=sorted(list(map(int,input().split())))
sm=0
for i in range(n):
  b1=bisect.bisect_left(a,b[i])
  c1=n-bisect.bisect_left(c,b[i]+1)
  sm+=b1*c1
print(sm)
  

Measured memory_bytes: 105952
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std ;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define mod 1000000007

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int n ;
int arr[500005] ;
string str ;

void solve()
{
    cin >> n ;
    if(n <= 1)
    {
        cout << 0 ;
        return ;
    }
    int ans = 1 ;
    for(int i=1 ; i<=n ; i++)
    {
        ans = (ans*10)%mod ;
    }
    int t1 = 1 ;
    for(int i=1 ; i<=n ; i++)
    {
        t1 = (t1*9)%mod ;
    }
    t1 = (2*t1)%mod ;
    int t2 = 1 ;
    for(int i=1 ; i<=n ; i++)
    {
        t2 = (t2*8)%mod ;
    }
    ans = (ans-t1+mod)%mod ;
    ans = (ans+t2)%mod ;
    cout << ans ;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int tt = 1;
	//cin >> tt ;
	while(tt--)
	{
	     solve() ;
	}
}


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

using namespace __gnu_pbds;
using namespace std;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pii pair<int,int>
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%lld",&t)
#define p(t) printf("%lld\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<pii,vector<pii>,greater<pii> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define spitr set<pii>:: iterator
#define mitr map<int,int>:: iterator

int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}


typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

vector<pair<pii,pii> > v;
vector<int> arr;
int n,m,q;
int ans=0;

void solve(int id,int last)
{
    if(id==n)
    {
        int cur=0;
        for(int i=0;i<q;i++)
        {
            if(arr[v[i].ff.ss]-arr[v[i].ff.ff]==v[i].ss.ff)
                cur+=v[i].ss.ss;
        }
        ans=max(ans,cur);
        return;
    }

    for(int i=last;i<=m;i++)
    {
        arr.pb(i);
        solve(id+1,i);
        arr.pop_back();
    }
}

int32_t main()
{
    fast;
    cin>>n>>m>>q;
    for(int i=0;i<q;i++)
    {
        int a,b,c,d;cin>>a>>b>>c>>d;
        a--,b--;
        v.pb(mp(mp(a,b),mp(c,d)));
    }

    solve(0,1);
    cout<<ans;
}

Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n;
	cin >> n;
	
	vector<ll> a(n);
	map<ll, ll> mp;
	ll sum = 0LL;
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		mp[a[i]]++;
		sum += a[i];
	}
	
	int Q;
	cin >> Q;
	
	vector<ll> b(Q), c(Q);
	for(int i = 0; i < Q; ++i) {
		cin >> b[i] >> c[i];
	}
	
	for(int i = 0; i < Q; ++i) {
		if( mp[b[i]] > 0 ) {
			sum += (c[i] - b[i]) * mp[b[i]];
			ll tmp = mp[b[i]];
			
			mp[b[i]] = 0;
			mp[c[i]] += tmp;
		}
		
		cout << sum << endl;
	}
	
	return 0;
}


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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int x[1005], y[1005];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, d;
    cin >> n >> d;
    two_sat ts(n);
    for (int i=0; i<n; i++) {
        cin >> x[i] >> y[i];
        for (int j=0; j<i; j++) {
            if (abs(x[i] - x[j]) < d)
                ts.add_clause(i, false, j, false);
            if (abs(x[i] - y[j]) < d)
                ts.add_clause(i, false, j, true);
            if (abs(y[i] - x[j]) < d)
                ts.add_clause(i, true, j, false);
            if (abs(y[i] - y[j]) < d)
                ts.add_clause(i, true, j, true);
        }
    }

    if (ts.satisfiable()) {
        cout << "Yes\n";
        auto ret = ts.answer();
        for (int i=0; i<n; i++)
            cout << (ret[i] ? x[i] : y[i]) << "\n";
    } else {
        cout << "No\n";
    }

    return 0;
}


Measured memory_bytes: 3720
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

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

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
















int main(){
    ll n;
    cin >> n;
    vector<ll> a(n), c(n + 1);
    REP(i, n){
        cin >> a[i];
        c[a[i]]++;
    }
    ll sum = 0;
    REP(i, n + 1){
        if(c[i]){
            sum += c[i] * (c[i] - 1) / 2;
        }
    }
    REP(i, n){
        ll cnt = c[a[i]];
        cout << sum - cnt * (cnt - 1) / 2 + ((cnt >= 2)? (cnt - 1) * (cnt - 2) / 2 : 0) << endl;
    }
}

Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
using namespace std;

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

#define fr first
#define sc second
#define rep(i,x) for(int i = 0 ; i < x ; i ++)
#define pb push_back
#define mp1(a,b,c) P1(a,P(b,c))
const int INF = 1000000007;

const int MAX_V_flow = 210;
struct FLOW{
	vector<P1> G[MAX_V_flow];
	bool used[MAX_V_flow];
	
	void init(){
		rep(i,MAX_V_flow)G[i].clear();
	}
	
	void add_edge(int from,int to,int flow){
		G[from].pb( mp1 ( to , flow , G[to].size() ) );
		G[to].pb( mp1 ( from , 0 , G[from].size()-1 ) );
	}
	
	int dfs(int v,int t,int f){
		if(v == t)return f;
		used[v] = true;
		rep(i,G[v].size()){
			if(!used[G[v][i].fr] && G[v][i].sc.fr > 0){
				int d = dfs(G[v][i].fr,t,min(f,G[v][i].sc.fr));
				if(d > 0){
					G[v][i].sc.fr -= d;
					G[G[v][i].fr][G[v][i].sc.sc].sc.fr += d;
					return d;
				}
			}
		}
		return 0;
	}
	
	int flow(int s,int t){
		int ret = 0,d = 1;
		while(d > 0){
			rep(i,MAX_V_flow)used[i] = false;
			d = dfs(s,t,INF);
			ret += d;
		}
		return ret;
	}
}flow;

int n,m;
int a[102][102];
int b[102][102];
int c[102][102];
multiset<int> A[102];

void solve(int j){
	flow.init();
	for(int i = 0 ; i < n ; i ++){
		for(int x: A[i]){
			flow.add_edge(i,n+x/m,1);
		}
	}
	for(int i = 0 ; i < n ; i++){
		flow.add_edge(2*n,i,1);
		flow.add_edge(n+i,2*n+1,1);
	}
	flow.flow(2*n,2*n+1);
	for(int i = 0 ; i < n ; i ++){
		int id;
		for(int t = 0 ; t < flow.G[i].size() ; t ++){
			if(flow.G[i][t].sc.fr == 0){
				id = flow.G[i][t].fr-n;
			}
		}
		for(multiset<int>::iterator itr = A[i].begin() ; itr != A[i].end() ; ++itr){
			if((*itr)/m == id){
				b[i][j] = *itr;
				A[i].erase(itr);
				break;
			}
		}
	}
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i = 0 ; i < n ; i ++){
		for(int j = 0 ; j < m ; j ++){
			scanf("%d",&a[i][j]);
			a[i][j]-=1;
		}
	}
	for(int i = 0 ; i < n ; i ++){
		for(int j = 0 ; j < m ; j ++){
			A[i].insert(a[i][j]);
		}
	}
	for(int j = 0 ; j < m ; j ++)solve(j);
	for(int j = 0 ; j < m ; j ++){
		vector<int> vec;
		for(int i = 0 ; i < n ; i ++){
			vec.push_back(b[i][j]);
		}
		sort(vec.begin(),vec.end());
		for(int i = 0 ; i < n ; i ++){
			c[i][j] = vec[i];
		}
	}
	for(int i = 0 ; i < n ; i ++){
		for(int j = 0 ; j < m ; j ++){
			printf("%d%c",b[i][j]+1,(j==m-1)?'\n':' ');
		}
	}
	for(int i = 0 ; i < n ; i ++){
		for(int j = 0 ; j < m ; j ++){
			printf("%d%c",c[i][j]+1,(j==m-1)?'\n':' ');
		}
	}
}

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

int main(){
  vector<long long> a{2,1};
  int b;
  cin>>b;
  if(b==0)cout<<a[0]<<endl;
  else if(b==1)cout<<a[1]<<endl;
  else{
    for(int i=0;i<b-1;++i){
      a[i%2]+=a[(i+1)%2];
    }
    cout<<a[b%2]<<endl;
  }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main() {
   int c=0;
   int size;
   string x;
   string y;
   cin >> x;
   cin >> y;
   size=x.size();
   for(int i=0;i<size;i++){
   	if(x[i]!=y[i]){
    	 c+=1;
   	}
   }
     cout << c << endl;
     
    return 0;
     
    
}

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

typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;

#define endl '\n'
#define ff first
#define ss second
#define int long long
#define pb push_back
#define f(i,l,r) for(ll i=l;i<=r;i++)
#define rf(i,r,l) for(ll i=r;i>=l;i--)
#define Max 5000001
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define d0(a) cout<<a<<' ';
#define d1(a) cout<<a<<endl;
#define d2(a,b) cout<<a<<' '<<b<<endl;
#define d3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define d4(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
#define d5(a,b,c,d,e) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<endl;
#define d6(a,b,c,d,e,f) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<' '<<f<<endl;

const ll N=1e5+5,mod=1e9+7,bit=61;



signed main()
{
    fast;

    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n,m;
        cin>>n>>m;
        ll h[n+1];
        f(i,1,n)
        {
            cin>>h[i];
        }
        ll ans=0;
        vector<ll> adj[n+1];
        f(i,1,m)
        {
            ll u,v;
            cin>>u>>v;
            adj[u].pb(v);
            adj[v].pb(u);
        }
        f(i,1,n)
        {
            bool pos=1;
            for(auto v:adj[i])
            {
                if(h[v]>=h[i])
                {
                    pos=0;
                    break;
                }
            }
            ans+=(int)pos;
        }
        cout<<ans<<endl;
    }
    return 0;
}


















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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#include <set>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
ll calc(ll A) {

    if (A < 0) return 0;
    ll ans = 0;
    A++;
    for (int i = 0; i < 50; ++i) {
        //周期
        ll loop = (1LL << (i + 1));
        //1の出現回数
        ll cnt = (A / loop) * (loop / 2);

        //端数処理
        cnt += max(0LL,(A % loop) - (loop / 2));
        if (cnt % 2 == 1) {
            ans += 1LL << i;
        }
    }
    return ans;
}
int main(){
    ll A,B;
    cin >> A >> B;
    ll ans = calc(B) ^ calc(A-1);
    cout << ans << endl;

    return 0;
}


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

int main(void){
    int N;
    cin >> N;
    vector<ll> cnt(N+1);
        for(int i = 1; i < sqrt(N); i++){
            for(int j = 1; j <sqrt(N); j++){
                for(int k = 1; k < sqrt(N); k++){
                    int v = i*i + j*j + k*k + i*j + j*k + k*i;
                    if(v <= N) cnt[v]++;
                }
            }
        }
    for(int i=1; i<=N; i++) cout << cnt[i] << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
    using namespace std;
    
    int main(){
        long n , a , b ;
        cin >> n >> a >> b;
        long t;
        t = abs(b - a);
        if(t % 2 == 0){
            cout <<  "Alice"  << endl;
        }else{
            cout <<  "Borys"  << endl;
        }
        
        
        return 0;
    }

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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

void solve() {
  int N, K, L;
  cin >> N >> K >> L;
  UnionFind uf1(N), uf2(N);
  for(int i = 0; i < K; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    uf1.unionSet(a, b);
  }
  for(int i = 0; i < L; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    uf2.unionSet(a, b);
  }
  map<pair<int,int>, int> cnt;
  for (int i = 0; i < N; i++) {
    int r1 = uf1.root(i);
    int r2 = uf2.root(i);
    cnt[{r1, r2}]++;
  }
  for(int i = 0; i < N; i++) {
    int r1 = uf1.root(i);
    int r2 = uf2.root(i);
    cout << cnt[{r1, r2}] << " ";
  }
  cout << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(16);
  solve();
  return 0;
}

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

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

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}


   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};
const ll MAX_N = 16;
ll N;
ll a[MAX_N][MAX_N];
ll dp[1 << MAX_N] = {};

int main(){
  cin >> N;
  REP(i, N){
    REP(j, N){
      cin >> a[i][j];
    }
  }
  //init dp-table
  REP(S, 1 << N){
    REP(i, N){
      REP(j, i){
        if (((S >> i) & 1) & ((S >> j) & 1)) dp[S] += a[i][j];
      }
    }
  }
  REP(S, 1 << N){
    REP(T, S){
      if ((S & T) == T && T < (~T & S)) chmax(dp[S], dp[T] + dp[~T & S]);
    }
  }
  cout << dp[(1 << N) - 1] << endl;
}


Measured memory_bytes: 768
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

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

	    int N=Integer.parseInt(scanner.next());
	    int M=Integer.parseInt(scanner.next());
	    long[] A=new long[N];
	    long[] B=new long[N];
	    Map<Long, Long> map = new HashMap<Long, Long>();


	    for(int i=0; i<N;i++) {
	    	A[i]=Long.parseLong(scanner.next());
	    	B[i]=Long.parseLong(scanner.next());
	    	if (map.containsKey(A[i])) {
	    		map.put(A[i], map.get(A[i]) + B[i]);
	    	} else {
	    		map.put(A[i], B[i]);
	    	}
	    }
	    
	    Arrays.parallelSort(A);
	    
	    long h=0;
	    long c=0;
	    for (int i=0; i<N; i++) {
	    	if (i!=0 && A[i] == A[i-1]) continue;
	    	
	    	long hm = map.get(A[i]);
	    	for (int j = 0; j < hm; j++) {
	    		h++;
	    		c+=A[i];
	    		if (h==M) {
	    			System.out.println(c);
	    			return;
	    		}
	    	}
	    }

	}
}

Measured memory_bytes: 69612
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())

signed main() {
    string s;
    cin >> s;
    int n = sz(s);
    s += "  ";
    for(int i = 0; i < n; i++) {
        if(s[i] == s[i + 1]) {
            cout << i + 1 << " " << i + 2 << "\n";
            return 0;
        }
        if(s[i] == s[i + 2]) {
            cout << i + 1 << " " << i + 3 << "\n";
            return 0;
        }
    }
    cout << "-1 -1\n";
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
#define all(obj) obj.begin(), obj.end()
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);

using namespace std;

typedef unsigned long long ull;
typedef  long long int ll;
constexpr ll bigNum = 1000000007;

signed main()
{
    fast;
    //ここから本体
    ll n;
    cin >> n;
    vector<string> a(n);
    for (int i = 0; i < n; i++)
    {
        string x;
        cin >> x;
        sort(all(x));
        a[i] = x;
    }
    sort(all(a));

    ll ans = 0;
    ll c = 1;
    for (int i = 0; i < n - 1; i++)
    {
        if (a[i] == a[i + 1])
            c++;
        else
        {
            ans += (c * (c - 1)) / 2;
            c = 1;
        }
    }
    ans += (c * (c - 1)) / 2;
    cout << ans << endl;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < b; i++)
using namespace std;

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

    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];

    bool flag = true;
    rep(i, 0, n) {
        if (a[i] % 2 == 0) {
            if (a[i] % 3 == 0) continue;
            if (a[i] % 5 == 0) continue;
            flag = false;
        }
    }

    if (flag) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#[macro_export]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[doc(hidden)]
#[macro_export]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[doc(hidden)]
#[macro_export]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [usize1; n-1],
    }

    let mut g = vec![vec![]; n];

    for i in 1..n {
        g[a[i-1]].push(i);
    }

    let ans = dfs(0, None, &g);
    println!("{}", ans);
}

use std::cmp::max;

fn dfs(u: usize, prev: Option<usize>, g: &Vec<Vec<usize>>) -> i64 {
    let mut tmp = vec![];

    for &v in g[u].iter() {
        if Some(v) == prev {
            continue;
        }
        let t = dfs(v, Some(u), g);
        tmp.push(t);
    }
    tmp.sort();
    tmp.reverse();

    let mut ret = 0;
    for i in 0..tmp.len() {
        ret = max(ret, 1 + tmp[i] + i as i64);
    }

    // dbg!((u, ret));

    ret
}


Measured memory_bytes: 35964
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  cin >>N;
  
  int ans;
  
  int s=0;
  int A;
  cin >>A;
  
  while(A%2==0){
    A/=2;
    s++;
  }
  
  int t=0;
  
  for(int i=1; i<N; i++){
    cin >>A;
    
    while(A%2==0){
      A/=2;
      t++;
    }
    
    if(s!=t){
      if(s>t)
        ans=t;
      else
        ans=s;
      
      t=0;
    }
    
  }

  cout <<ans<<endl;

}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;

int main() {
    int a, b, t;
    cin >> a >> b >> t;
    cout << b * (t / a) << endl;
    return 0;
}

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

using namespace std;

string s;
int a[10];

int main() {
    cin >> s;
    a[0] = (s[0] == 'R');
    for (int i = 1; i < s.size(); i++)
        a[i] = (s[i - 1] == 'R' ? a[i - 1] : 0) + (s[i] == 'R');
    int ans = 0;
    for (int i = 0; i < s.size(); i++)
        ans = max(ans, a[i]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3624
/*
 * A.cpp
 *
 *  Created on: 2017/06/18
 *      Author: jin
 */

#define MYDEBUG
#include <bits/stdc++.h>

#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(w,x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define ull unsigned long long
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
#define EPS = 1e-14;
using std::vector;
using std::cout;
using std::cin;
using std::endl;
using std::max;
using std::min;
using std::swap;
using std::string;
using std::fill;
using std::pair;
using std::sort;
using std::reverse;
using std::pair;
using std::greater;
using std::priority_queue;
using std::ostream;
typedef std::complex<int> P;

template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i] << endl;
  }
  return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last) {
      out << ",";
    }
  }
  out << "]";
  return out;
}

using std::deque;
const int MAX_N = 2 * 100010;
int n;
deque<int> v;
deque<int> b;

void solve() {
  cin >> n;
//  rep(i,0,n)
//  {
//    int a;
//    cin >> a;
//    v.push_back(a);
//    reverse(all(v));
//  }
  int even = (n % 2 == 0 ? 1 : 0);
  rep(i,0,n)
  {
    int a;
    cin >> a;
//    v.push_back(a);
//    reverse(all(v));
    if ((i + even) % 2 != 0) {
      b.push_back(a);
    } else {
      b.push_front(a);
    }
  }

//  rep(i,0,n-1)
//  {
//    cout << v[i] << " ";
//  }
//  cout << v[n - 1] << endl;
  rep(i,0,n-1)
  {
    cout << b[i] << " ";
  }
  cout << b[n - 1] << endl;
}

int main() {
  solve();
}



Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    string s;
    while (cin>>s) {
        std::vector<vector<char>> vec(3,vector<char>(3));
        int count=0;
        for (int i=0;i<3;i++) {
            for (int j=0;j<3;j++) {
                char c=s.at(count);
                vec[i][j]=c;
                count++;
            }
        }
        if (vec[0][0]==vec[0][1]&&vec[0][1]==vec[0][2]&&vec[0][0]!='s'&&vec[0][1]!='s'&&vec[0][2]!='s') {
            cout<<vec[0][0]<<endl;
        } else if (vec[1][0]==vec[1][1]&&vec[1][1]==vec[1][2]&&vec[1][0]!='s'&&vec[1][1]!='s'&&vec[1][2]!='s') {
            cout<<vec[1][0]<<endl;
        } else if (vec[2][0]==vec[2][1]&&vec[2][1]==vec[2][2]&&vec[2][0]!='s'&&vec[2][1]!='s'&&vec[2][2]!='s') {
            cout<<vec[2][0]<<endl;
        } else if (vec[0][0]==vec[1][0]&&vec[1][0]==vec[2][0]&&vec[0][0]!='s'&&vec[1][0]!='s'&&vec[2][0]!='s') {
            cout<<vec[0][0]<<endl;
        } else if (vec[0][1]==vec[1][1]&&vec[1][1]==vec[2][1]&&vec[0][1]!='s'&&vec[1][1]!='s'&&vec[2][1]!='s') {
            cout<<vec[0][1]<<endl;
        } else if (vec[0][2]==vec[1][2]&&vec[1][2]==vec[2][2]&&vec[0][2]!='s'&&vec[1][2]!='s'&&vec[2][2]!='s') {
            cout<<vec[0][2]<<endl;
        } else if (vec[0][0]==vec[1][1]&&vec[1][1]==vec[2][2]&&vec[0][0]!='s'&&vec[1][1]!='s'&&vec[2][2]!='s') {
            cout<<vec[0][0]<<endl;
        } else if (vec[0][2]==vec[1][1]&&vec[1][1]==vec[2][0]&&vec[0][2]!='s'&&vec[1][1]!='s'&&vec[2][0]!='s') {
            cout<<vec[0][2]<<endl;
        } else {
            cout<<"d"<<endl;
        }
    }
}


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

long long gcd2(long long a,long long b){
	if(b==0)return a;
	else return gcd2(b,a%b);
}

signed main(){
	int K; cin>>K;
	int ans=0;
	for(int a=1;a<=K;a++){
		for(int b=1;b<=K;b++){
			for(int c=1;c<=K;c++){
				ans+=gcd2(a,gcd2(b,c));
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3600
import java.util.Scanner;

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

    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int D = sc.nextInt();

    if ((A + B) > (C + D)){
      System.out.println("Left") ;
    }
    else if ((A + B) < (C + D)) {
      System.out.println("Right");
    }
    else {
      System.out.println("Balanced");

    }
  }
}


Measured memory_bytes: 22996
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sca = new Scanner(System.in);
		int a = sca.nextInt(),b = sca.nextInt(),c = sca.nextInt(),d = sca.nextInt(),e = sca.nextInt(),k = sca.nextInt();
		if(e - a > k) System.out.println(":(");
		else System.out.println("Yay!");
	}
}


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

int main(){
    string s;
    getline(cin, s);
    for(int i = 0;; i++){
        if(s[i] == '\0') break;
        if(islower(s[i])){
            s[i] = (char)toupper(s[i]);
        }
        else if(isupper(s[i])){
            s[i] = (char)tolower(s[i]);
        }
        cout << s[i];
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 3200