akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

int main() {
  int n, k;
  cin >> n >> k;
  int ans = 0;
  rep (i, n) {
    int h;
    cin >> h;
    if (h >= k) ans++;
  }
  cout << ans << endl;
}


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

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S, std::string T){
    bool isOk = true;
    rep(i,T.size()-1){
        if(S[i] != T[i]) isOk = false;
    }
    if(isOk) cout << YES << endl;
    else cout << NO << endl;
}


int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 3644
let _ =
    let p = Scanf.scanf "%d %d %d\n" (fun a b c ->
        List.sort compare [a;b;c]) in
    let f = function
        true -> print_endline "YES"
        | false -> print_endline "NO" in
    f ((List.nth p 0) == 5 && (List.nth p 1) == 5 && (List.nth p 2) == 7)




Measured memory_bytes: 384
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.*;

public class Main{
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int m1 = sc.nextInt();
		int d1 = sc.nextInt();
		int m2 = sc.nextInt();
		int d2 = sc.nextInt();
		if (m1 != m2) {
			System.out.println(1);
		} else {
			System.out.println(0);
		}
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 21204
import java.util.*;
import java.io.*;

class Main {
	public static void main(String[] args) throws IOException {
		setIO();

		st = nl();
		long X = nlg(st), K = nlg(st), D = nlg(st);
		
		if (X < 0) X = -X;
		
		if (X / D < K) {
			boolean b = (K - X / D) % 2 == 1;
			X %= D;
			if (b) X -= D;
		} else {
			X -= K * D;
		}
		
		out.println(Math.abs(X));
		
		f.close();
		out.close();
	}

	static BufferedReader f;
	static PrintWriter out;
	static StringTokenizer st;

	static int ni(StringTokenizer st) {
		return Integer.parseInt(st.nextToken());
	}

	static int ni() throws IOException {
		return Integer.parseInt(f.readLine());
	}
	
	static long nlg(StringTokenizer st) {
		return Long.parseLong(st.nextToken());
	}

	static long nlg() throws IOException {
		return Long.parseLong(f.readLine());
	}

	static StringTokenizer nl() throws IOException {
		return new StringTokenizer(f.readLine());
	}

	static int[] nia(int N) throws IOException {
		StringTokenizer st = nl();
		int[] A = new int[N];
		for (int i = 0; i < N; i++)
			A[i] = ni(st);
		return A;
	}

	static void setIn(String s) throws IOException {
		f = new BufferedReader(new FileReader(s));
	}

	static void setOut(String s) throws IOException {
		out = new PrintWriter(new FileWriter(s));
	}

	static void setIn() {
		f = new BufferedReader(new InputStreamReader(System.in));
	}

	static void setOut() {
		out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	}

	static void setIO(String s) throws IOException {
		setIn(s + ".in");
		setOut(s + ".out");
	}

	static void setIO() {
		setIn();
		setOut();
	}
}


Measured memory_bytes: 32804
#include <bits/stdc++.h>
using namespace std;
unsigned long long a, b;
int main()
{
	cin >> a >> b;
	if (a == 1 || b == 1) {
		cout << 1;
		return 0;
	}
	if (a % 2 == 0 || b % 2 == 0) {
		cout << a * b / 2;
		return 0;
	}
	
	cout << a * b / 2 + 1;
	
}

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

using namespace std;

typedef long long ll;

const int MX = 200011;

int n,k;

ll a[200011],pre[200011];

vector<ll> all;

ll BIT[200011];

void add(int idx , int val){
	while(idx < MX){
		BIT[idx] += val;
		idx += (idx &-idx);
	}
}
ll get(int idx){
	ll res = 0;
	while(idx){
		res += BIT[idx];
		idx -= (idx & -idx);
	}
	return res;
}

int me(ll sum){
	return lower_bound(all.begin(),all.end(),sum) - all.begin() + 1;
}
int main() {
//	freopen("input.txt", "r", stdin);
	scanf("%d%d",&n,&k);
	for (int i = 1; i <= n; ++i){
		scanf("%lld",&a[i]);
		a[i] -= k;
	}
	for (int i = 1 ; i <= n; ++i){
		pre[i] = pre[i-1] + a[i];
		all.push_back(pre[i]);
	}
	sort(all.begin(),all.end());
	all.resize(unique(all.begin(),all.end())-all.begin());
	ll res = 0;
	for (int i = n ; i >= 1 ; i--){
		add(me(pre[i]),1);
		ll got =  get(MX-1) - get(me(pre[i-1])-1);
		res += got;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 6640
def main():
    N, M = map(int, input().split())
    ball = [1] * N
    red = [False] * N
    red[0] = True
    for _ in range(M):
        x, y = map(int, input().split())
        x -= 1
        y -= 1
        ball[x] -= 1
        ball[y] += 1
        if red[x]:
            red[y] = True
        if ball[x] == 0:
            red[x] = False

    ans = 0
    for i in range(N):
        if red[i]:
            ans += 1

    print(ans)




if __name__ == "__main__":
    main()

Measured memory_bytes: 47576
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
    while (1) {
        int h, w;
        cin >> h >> w;
        if (h==0 && w==0) break;
        for (int i = 0; i < h; i++) {
            for (int j = 0;j < w; j++) {
                if ((i + j) % 2 == 1) cout << ".";
                else cout << "#";
            }
            cout << endl;
        }
         cout<<endl;
    }
    return 0;
}


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

#define MOD 10000007
#define f first
#define s second
#define es " "
#define pb push_back
#define endl "\n"
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define ll long long int
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

ll dp[1005][5000];
int n, m;

pair<int, int> v[1005];

ll solve(int obj, int mask){
    if(dp[obj][mask]!=-1){
        return dp[obj][mask];
    }
    if(obj>m && mask<pow(2, n)-1){
        return dp[obj][mask]=INF;
    }
    if(obj>m && mask==pow(2, n)-1){
        return dp[obj][mask]=0;
    }
    int atual=mask|v[obj].f;

    int nao=solve(obj+1, mask);
    int pega=solve(obj+1, atual)+v[obj].s;

    return dp[obj][mask]=min(nao, pega);
}

int main(){
    fastio;
    memset(dp, -1, sizeof(dp));
    int x, k;
    cin >> n >> m;
    for(int i=1; i<=m; i++){
        cin >> v[i].s >> k;
        for(int j=0; j<k; j++){
            cin >> x;
            v[i].f|=(1<<x-1);
        }
        //cout << v[i].f << endl;
    }
    sort(v+1, v+m+1);
    ll resp=solve(1, 0);
    if(resp==INF){
        cout << -1 << endl;
    }else{
        cout << resp << endl;
    }
    return 0;

}

Measured memory_bytes: 39552
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int x; cin>>x;
  vector<bool> a(x*10+1,false);
  vector<int> b;
  for(int i=2; i<=x*10; ++i){
    if(a[i]==false){
      b.push_back(i);
      for(int j=2; i*j<=x*10; ++j) a[i*j]=true;
    }
  }
  cout<<*lower_bound(b.begin(),b.end(),x);
  return 0;
}

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

int main() {

  int a, b;
  cin >> a >> b;

  int v = 0;

  if (b < 10) {
    v = a * 10 + b;
  } else if (b != 100) {
    v = a * 100 + b;
  } else {
    v = a * 1000 + b;
  }

  int v2 = sqrt(v);

  if (v2 * v2 == v) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int n = Integer.parseInt(str[0]);
    long k = Long.parseLong(str[1]);
    str = in.readLine().split(" ");
    long[] h = new long[n];
    long sum = 0;
    for(int i=0; i<n; i++) {
      h[i] = Long.parseLong(str[i]);
    }
    Arrays.sort(h);
    for(int i=0; i<n-k; i++) {
      sum += h[i];
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 67736
#include <bits/stdc++.h>
 
int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N);
  for (auto& e : A) cin >> e;
  auto p = minmax_element(cbegin(A), cend(A));
  int s = *p.first, l = *p.second;
  int x = count(cbegin(A), cend(A), s), y = N - x;
  bool ans = l - s < 2 &&
             (s == l ? s == N - 1 || 2 * s <= N : x < l && 2 * (l - x) <= y);
  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
// typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

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

  int N, L;
  cin >> N >> L;
  vector<int> a(N);
  rep(i, 0, N) { cin >> a[i]; }

  bool f = false;
  int ind = -1;
  rep(i, 1, N) {
    if (a[i - 1] + a[i] >= L) {
      ind=i;
      f = true;
    }
  }
  if (!f) {
    cout << "Impossible" << endl;
    return 0;
  }

  cout<<"Possible"<<endl;
  rep(i,0,ind-1)cout<<i+1<<endl;
  rrep(i,ind,N)cout<<i<<endl;


  return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

#define v(type) vector<type>
#define p(type1, type2) pair<type1 , type2>
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void solve() {
    int s, w;
    cin>>s>>w;
    if(w >= s){
        cout<<"unsafe"<<endl;
    }else cout<<"safe"<<endl;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 3668
n,m,*py=map(int,open(0).read().split())
py = list(zip(py[::2],py[1::2],range(m)))
py.sort()
p = 0
c = 0
for i in range(m):
    if py[i][0] == p:
        c += 1
        py[i] += tuple([c])
    else:
        c = 1
        p = py[i][0]
        py[i] += tuple([1])
py.sort(key=lambda x:x[2])
[print("{:06}{:06}".format(i[0],i[3])) for i in py]

Measured memory_bytes: 33756
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <typeinfo>
#include <math.h>
#include <algorithm>
#include <iostream>
#include <list>
#include <stack>
#include <set>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
using namespace std;
int main() {
	ll n, m, r, R[10], a, b, c, dis[210][210], inf = 1e9;
	for (int i = 0; i < 210; i++) {//距離の初期化
		for (int j = 0; j < 210; j++) {
			dis[i][j] = inf;
		}
		dis[i][i] = 0;
	}
	cin >> n >> m >> r;
	for (int i = 0; i < r; i++)cin >> R[i];
	for (int i = 0; i < m; i++) {
		cin >> a >> b >> c;
		dis[a][b] = min(dis[a][b], c);
		dis[b][a] = dis[a][b];
	}
	for (int k = 1; k <= n; k++) {//ワーシャルフロイド
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				dis[i][j] = min(dis[i][k] + dis[k][j], dis[i][j]);
			}
		}
	}
	sort(R, R + r);
	ll yan, ans = 1e9;
	do {//ねくすとっ☆ぱーみゅてーしょん！！
		yan = 0;
		for (int i = 0; i < r - 1; i++)yan += dis[R[i]][R[i + 1]];
		ans = min(yan, ans);
	} while (next_permutation(R, R + r));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
string sum(int a, int b, int c) {
	if (a + b + c >= 22) {
		string str = "bust";
		return str;
	}
	else {
		string str2 = "win";
		return str2;
	}
}

int main() {
	int a, b, c;
	cin >> a;
	cin >> b;
	cin >> c;
	cout << sum(a, b, c);
}

Measured memory_bytes: 256
def solve(n, m, x):
    if m == 1:
        return 0
    x = list(sorted(x))
    d = [x[i+1] - x[i] for i in range(m-1)]
    d = list(sorted(d))
    k = max(0, len(d) - (n-1))
    return sum(d[:k])

n, m = map(int, input().split())
x = map(int, input().split())
print(solve(n, m, x))

Measured memory_bytes: 13968
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  ll n,k,q;
  cin>>n>>k>>q;
  vector<ll> a(q);
  vector<ll> p(n,0);
  rep(i,q){
    cin>>a[i];
    p[ a[i]-1 ]++;
  }
  rep(i,n){
    //cout << p[i] << endl;
    if( k+p[i]>q ) cout << "Yes" << endl;
    else cout << "No" << endl;

  }


  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}

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

using namespace std;

int main(void) {
    long n;
    cin >> n;
    long u, v;
    cin >> v >> u;
    u--, v--;

    vector<vector<long>> G(n);
    for(int i=0; i<n-1; i++) {
        long a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<long> udis(n), vdis(n);

    {
        auto dfs = [&](auto dfs, long cur, long prev, long c) -> void{
            udis[cur] = c;
            for(auto &v: G[cur]) {
                if(v == prev) continue;
                dfs(dfs, v, cur, c+1);
            }
        };

        dfs(dfs, u, -1, 0);
    }

    long r = 0;
    {
        auto dfs = [&](auto dfs, long cur, long prev, long c) -> void {
            for(auto &v: G[cur]) {
                if(v == prev) continue;

                r = max(r, long(udis[v] - (G[v].size()==1)));
                if(udis[v] <= (c+1)) continue;

                dfs(dfs, v, cur, c+1);
            }
        };
        dfs(dfs, v, -1, 0);
    }
    cout << r << endl;
}


Measured memory_bytes: 10624
#include<stdio.h>
#include<stdlib.h>
int compare_int(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}

int main(void){
	int n;
	int *a;
	int flg = 1;
	scanf("%d", &n);
	a = (int *)malloc(sizeof(int) * n);
	for(int i=0; i<n; i++){
		scanf("%d", &a[i]);
	}
	qsort(a, n, sizeof(int), compare_int);
	for(int j=0; j<n-1; j++){
		if(a[j] == a[j+1]){
			flg = 0;
			break;
		}
	}
	if(flg == 1){
		printf("YES\n");
	} else if(flg == 0){
		printf("NO\n");
	}
	return 0;
}


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

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> vec(n);
    rep(i,n){
        cin >> vec[i];
    }
    sort(vec.begin(),vec.end());
    int ans=0;
    rep(i,k){
        ans+=vec[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;

signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n;ll d; cin >> n >> d;
    d*=d;
    int ans=0;
    rep(i,n){
        ll x,y; cin >> x >> y;
        ll r=x*x+y*y;
        if(r<=d)ans++;
    }
    cout<<ans<<endl;
}



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

int main()
{
  int n,t;
  cin>>n>>t;
  vector<int> v(n);
  for(int &i:v) cin>>i;
  int ans=0,l=0;
  for(int i:v)
  {
    if(l>i)
    {
      ans -= (l-i);
      ans += t;
      l = i+t;
    }
    else
    {
      ans+=t;
      l=i+t;
    }
  }
  cout<<ans;
  
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n, c;
  cin >> n >> c;
  vector<vi> d(c, vi(c)), a(n, vi(n)), cost(c, vi(3, 0));
  rep(i, c) rep(j, c) cin >> d[i][j];
  rep(i, n) rep(j, n) {
    cin >> a[i][j];
    a[i][j]--;
  }
  rep(k, c) rep(i, n) rep(j, n) cost[k][(i + j) % 3] += d[a[i][j]][k];
  int ans = 1e9;
  rep(i, c) rep(j, c) rep(k, c) {
    if(i == j || j == k || k == i) continue;
    int now = cost[i][0] + cost[j][1] + cost[k][2];
    ans = min(ans, now);
  }
  cout << ans << endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N, M;
    cin >> N >> M;
    priority_queue<P> pque;
    rep(i, N) {
        ll a;
        cin >> a;
        pque.push(make_pair(a, 1));
    }
    rep(i, M) {
        ll b, c;
        cin >> b >> c;
        pque.push(make_pair(c, b));
    }
    ll cnt = 0;
    ll ans = 0;
    while (cnt < N) {
        P p = pque.top();
        pque.pop();
        if (p.second + cnt <= N) {
            ans += p.first * p.second;
        } else {
            ans += p.first * (N - cnt);
        }
        cnt += p.second;
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int k, a, b;
    cin >> k >> a >> b;
    bool ok = false;
    for(int i = a; i <= b; i++){
        if(i % k == 0)ok = true;
    }
    cout << (ok ? "OK" : "NG") << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <math.h>
#include <tuple>
#include <string.h>
#include <map>
#include <iomanip>
#include <time.h>
using namespace std;
typedef long long ll;

int n, m;
vector<int> tp, dp;
vector<vector<int>> G;

int dfs(int v) {
    if (dp[v] == -1) {
        int r = 0;
        for (auto &i : G[v]) {
            dfs(i);
            r = max(r, dfs(i) + 1);
        }
        dp[v] = r;
    }
    return dp[v];
}

int main() {
    cin >> n >> m;
    G.assign(n, vector<int>());
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        G[--a].push_back(--b);
    }
    dp.assign(n, -1);

    int ans = 0;
    for (int i = 0; i < n; i++) ans = max(ans, dfs(i));
    cout << ans << endl;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

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


ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
  int x; cin >> x;
  cout << lcm(x,360)/x << endl;
  return 0;
}


Measured memory_bytes: 3588
/*
	  Chase
	   Your
	  Legend

	英雄志逐传奇
*/

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <stdio.h>

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

const int INF = 1e8;

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

	vector<int>b(n - 1);
	rep(i, n - 1) {
		cin >> b[i];
	}

	ll ans = 0;
	if (n == 2) {
		cout << b[0] * 2 << endl;
	}
	else {
		vector<int>a(n);
		a[0] = b[0];
		for (int i = 1; i < n - 1; i++) {
			a[i] = min(b[i], b[i - 1]);
		}
		a[n - 1] = b[n - 2];
		rep(i, n) {
			ans += a[i];
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    int a, b;
    cin >> a >> b;

    int sum = 0;

    for (int i = 1; i <= b - a; i++) sum += i;

    cout << sum - b << endl;
    
    return 0;
}

Measured memory_bytes: 256
from collections import Counter

N=int(input())
S=input()

dup=0
RGB=set(('R','G','B'))

for width in range(N//2+10):
    for i in range(N):
        try:
            if set((S[i],S[i+width],S[i+width*2]))==RGB:
                dup+=1
        except IndexError:
            break

c=Counter(S)
retval=c['R']*c['G']*c['B']-dup
print(retval)


Measured memory_bytes: 9468
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

using namespace std;

ll dp[40][40][40][40];
ll forest[40][40][40][40];

int n;

void mod(int &a){
	a %= (2*n);
	if (a < 0) a += 2*n;
}

ll get_f(int a, int b, int c, int d){
	mod(a), mod(b), mod(c), mod(d);
	//cout << "=====" << a << " " << b << " " << c << " " << d << endl;
	return forest[a][b][c][d];
}

ll get_dp(int a, int b, int c, int d){
	mod(a), mod(b), mod(c), mod(d);
	return dp[a][b][c][d];
}

main(){
#ifdef LOCAL
	freopen("N_input.txt", "r", stdin);
	//freopen("H_output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	char matrix[2*n][2*n];
	for (int i=0; i < 2*n; ++i) for (int j=0; j < 2*n; ++j) cin >> matrix[i][j];
	for (int mx=0; mx < 2*n; mx++) for (int len1=0; len1 <= mx; ++len1) for (int len2=0; len2 <= mx; ++len2){
		if (len1 != mx && len2 != mx) continue;
		for (int a=0; a < 2*n; ++a) for (int c=0; c < 2*n; ++c){
			int b = (a+len1)%(2*n), d = (c+len2)%(2*n);
			if (!(a <= b && b <= c && c <= d)) continue;
			bool good = true;
			vector<int> F, S;
			for (int p=0; p < 2*n; ++p){
				int tut = 0;
				if (a <= b && a <= p && p <= b){
					tut++;
					F.push_back(p);
				}
				if (a > b && (p >= a || p <= b)){
					tut++;
					F.push_back(p);
				}
				if (c <= d && c <= p && p <= d) {
					tut++;
					S.push_back(p);
				}
				if (c > d && (p >= c || p <= d)){
					tut++;
					S.push_back(p);
				}
				if (tut==2) good = false;
			}
			if (!good) continue;
			for (int i=0; i < F.size(); ++i) for (int j=0; j < S.size(); ++j){
				int e = F[i], f = S[j];
				if (matrix[e][f] == '1'){
					ll val1 = 0, val2 = 0;
					if (a==b) val1=1;
					else if (e != a && e != b) val1 = get_f(a, e-1, e+1, b);
					if (c==d) val2=1;
					else if (f != c && f != d) val2 = get_f(c, f-1, f+1, d);
					dp[a][b][c][d] += val1*val2;
				}
				if (e==b && f==c){
					continue;
				}
				else{
					if (e != b && f != c){
						//if (a==1 && b==2 && c==4 && d==5) cout << a << " " << e << " " <<f << " " << d << endl;
						forest[a][b][c][d] += get_dp(a, e, f, d) * get_f(e+1, b, c, f-1);
					}
				}
			}
			forest[a][b][c][d] += dp[a][b][c][d];
		}
	}
	//cout << dp[1][1][3][5] << " " << forest[1][1][3][5] << endl;
	//cout << dp[0][0][1][5] << endl;
	int ans = 0;
	cout << dp[0][0][1][2*n-1];
}

Measured memory_bytes: 38528
type Dice = [Pip]
type Pip = String

main :: IO ()
main = do
    dices <- fmap (map words . tail . lines) getContents
    putStrLn $ if allDifferent dices then "Yes" else "No"

allDifferent :: [Dice] -> Bool
allDifferent [_]    = True
allDifferent (d:ds) = all (not . sameDice d) ds && allDifferent ds

sameDice :: Dice -> Dice -> Bool
sameDice d1 d2 = d1 `elem` allStates d2

allStates :: Dice -> [Dice]
allStates = concatMap allTurns . allTops

allTops :: Dice -> [Dice]
allTops dice = scanl role dice "EESEE"

allTurns :: Dice -> [Dice]
allTurns dice = scanl turn dice "RRR"

turn :: Dice -> Char -> Dice
turn [a,b,c,d,e,f] com
    | com == 'R' = [a,c,e,b,d,f]
    | com == 'L' = [a,d,b,e,c,f]

role :: Dice -> Char -> Dice
role [a,b,c,d,e,f] com
    | com == 'E' = [d,b,a,f,e,c]
    | com == 'N' = [b,f,c,d,a,e]
    | com == 'S' = [e,a,c,d,f,b]
    | com == 'W' = [c,b,f,a,e,d]


Measured memory_bytes: 4064
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, K, XY):
    X = sorted(map(lambda x: x[0], XY))
    RX = X[::-1]
    Y = sorted(map(lambda x: x[1], XY))
    RY = Y[::-1]

    ans = sys.maxsize
    for lx in X:
        for rx in RX:
            if lx > rx:
                break
            for by in Y:
                for ty in RY:
                    if by > ty:
                        break

                    k = 0
                    for x, y in XY:
                        if lx <= x <= rx and by <= y <= ty:
                            k += 1
                    if k >= K:
                        ans = min(ans, (rx-lx)*(ty-by))
                    else:
                        break

    return ans


def main():
    N, K = read_int_n()
    XY = [read_int_n() for _ in range(N)]

    print(slv(N, K, XY))


if __name__ == '__main__':
    main()


Measured memory_bytes: 63464
L=[[[0]*10 for i in range(3)] for j in range(4)]
n=int(input())
for i in range(n):
    b,f,r,v=list(map(int,input().split()))
    L[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(f" {L[i][j][k]}",end="")
        print()
    if i+1 !=4:
        print("#"*20)


Measured memory_bytes: 5632
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

#define MAX_N (100L)
#define MAX_K (100000L)
#define NUM_MOD (1000000007L)

using namespace std;

long dpss[MAX_N + 1][MAX_K + 1], acc_dpss[MAX_N + 1][MAX_K + 2];

int main() {
  // read inputs
  long N, K, as[MAX_N];
  scanf("%ld %ld", &N, &K);
  for (long i = 0; i < N; i++) {
    scanf("%ld", &as[i]);
  }

  // solve dp
  // initialize
  acc_dpss[N][0] = 0;
  for (long j = 0; j <= K; j++) {
    dpss[N][j] = j == 0;
    acc_dpss[N][j + 1] = acc_dpss[N][j] + dpss[N][j];
  }
  // update
  for (long i = N - 1; i >= 0; i--) {
    // calculate dpss[i][j]
    for (long j = 0; j <= K; j++) {
      dpss[i][j] =
          (acc_dpss[i + 1][j + 1] - acc_dpss[i + 1][max(j - as[i], 0L)]) %
          NUM_MOD;
    }
    // calculate acc_dpss[i][j]
    acc_dpss[i][0] = 0;
    for (long j = 0; j <= K; j++) {
      acc_dpss[i][j + 1] = acc_dpss[i][j] + dpss[i][j];
    }
  }
  printf("%ld\n", dpss[0][K]);
}

Measured memory_bytes: 157952
#include <bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; i++)
#define REPR(i,n) for(int i = n; i >= 0; i--)
#define FOR(i,m, n) for(int i = m-1; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値))
//vector<intなど> 変数名(要素数,初期値)
using namespace std;
typedef long long ll;
const int MAX = 510000;
const int INF =2000000000;
const int MOD = 1000000007;
//gcd,lcmセット
ll gcd(ll a, ll b){
   if (a%b == 0) return b;
   else return gcd(b, a%b);
}
ll lcm(ll a, ll b){	
   return a*b/gcd(a, b);
}
int pow_kai(int a, int n){//aのn乗を計算します。
  int x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a;
    }
    a = a*a;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}
// a^n mod を計算する
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;
}
// a^{-1} mod を計算する
ll modInv(ll a, ll mod) {
    return modPow(a, mod - 2, mod);
}

long long fac[MAX], finv[MAX], inv[MAX];

// combinationのテーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
 
bool isPrime(ll x){
    int i;
    if(x < 2)return false;
    else if(x == 2) return true;
    if(x%2 == 0) return false;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return false;
    return true;
}
//dfsではvector<vector<int>> g(n);で◎
int main() {
    //COMinit();
    ll x;
    cin>>x;
    cout<<x/500*1000+x%500/5*5<<endl;
}

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

int main() {
	int n = 0;
	cin >> n;
	vector<long long> nums(n, 0);
	for (int i = 0; i < n; i++) cin >> nums[i];
	vector<long long> sums(n, 0);
	sums[0] = nums[0];
	for (int i = 1; i < n; i++) sums[i] = sums[i - 1] + nums[i];
	long long  res = INT32_MAX;
	for (int i = 0; i < n - 1; i++) res = min(res, abs(sums[i] - (sums[n - 1] - sums[i])));
	cout << res << endl;
}

Measured memory_bytes: 3328
N = gets.chomp.to_i
a = []
N.times do
  a << gets.chomp.to_i
end

sorted = []
a.each do |n|
  # Early return
  if sorted.size == 0
    sorted.push(n)
    next
  end
  
  i = sorted.bsearch_index { |x| x >= n }
  if i == 0
    sorted.unshift(n)
  elsif i == nil
    sorted[sorted.size-1] = n
  else
    sorted[i-1] = n
  end
  
  # p "n: #{n}"
  # p "i: #{i}"
  # p sorted
end

p sorted.size

Measured memory_bytes: 4988
N = int(input())
a = list(map(int,(input().split())))
s = sum(a)
S = [0]*N
p = [0]*N
gap = [100000000000]*N
S[0] = a[0]
for i in range(1,N):
    S[i] = S[i-1] + a[i]
for i in range(N):
    p[i] = s - S[i]
for i in range(N-1):
    gap[i] = abs(S[i]-p[i])
print(min(gap))

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

int main(){
    int n, m, cnt = 0; cin >> n >> m;
    priority_queue<int64_t, vector<int64_t>, greater<>> q;
    vector<pair<int64_t, int>> b(m); int64_t ans = 0;
    for (auto i = 0; i < n; i++) { int a; cin >> a; q.push(a); ans += a; }
    for (auto i = 0; i < m; i++) cin >> b[i].second >> b[i].first;
    sort(b.begin(), b.end(), greater<>());
    for (auto & elm : b) {
        for (auto i = 0; i < elm.second; i++) {
            auto p = q.top(); q.pop();
            if(p < elm.first) { ans = ans - p + elm.first; p = elm.first; q.push(p); cnt++; }
            else break;
        }
        if(cnt > n) break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5872
#include <bits/stdc++.h>
using namespace std;
int main() {
  	bool rev = 0;
	deque<char> s;
  	string init; cin >> init;
  	for (int i = 0; i < init.length(); i++) s.push_back(init[i]);
  	int q; cin >> q;
  	while (q--) {
    	 int t; cin >> t;
      	 if (t == 1) rev = !rev;
      	 else {
         	int front;
            char ins; 
           	cin >> front >> ins;
           	if (front == 1) {
            	if (rev) s.push_back(ins);
              	else s.push_front(ins);
            }
           	else {
              if (!rev) s.push_back(ins);
              	else s.push_front(ins);
            }
         }
    }
  	if (!rev) {
    	for (auto it = s.begin(); it != s.end(); ++it) {
        	cout << *it; 
        }
    }
  	else {
      for (auto it = s.rbegin(); it != s.rend(); ++it) {
        	cout << *it; 
        }
    }
  	cout << endl;
}


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

using namespace std;

int main()
{
	int n,q,i,l,r;
	int b[100005];
	int cum_sum[100005];
	string s;

	cin >> n >> q;
	cin >> s;
	
	b[0] = 0;
	for(i=1; i<n; i++)
	{
		if((s[i-1] == 'A') && (s[i] == 'C'))
			b[i] = 1;
		else
			b[i] = 0;
	}
	
	cum_sum[0] = b[0];
	for(i=1; i<n; i++)
		cum_sum[i] = cum_sum[i-1] + b[i];

	for(i=0; i<q; i++)
	{
		cin >> l >> r;
		l-=1;
		r-=1;
		
		int ans = cum_sum[r] - cum_sum[l-1];
		if (b[l]==1)
			ans--;
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 1792
N, M = list(map(int, input().split()))
L, R = [None] * M, [None] * M
for i in range(M):
    L[i], R[i] = list(map(int, input().split()))

ans = min(R) - max(L) + 1
if ans < 0:
    ans = 0
print(ans)

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

string s;

int main() {
	cin >> s;

	int length = s.length()-2;
	while (true) {
		bool flag = false;

		for (int i = 0; i < length / 2; i++) {
			if (s[i] != s[length / 2 + i]) {
				flag = true;
			}
		}

		if (!flag)break;
		length -= 2;
	}

	cout << length << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
S = input()
T = input()
dicta = defaultdict(set)
dictb = defaultdict(set)
for i in range(len(S)):
    dicta[S[i]].add(T[i])
    dictb[T[i]].add(S[i])

flag = True
for v in dicta.values():
    if len(v) != 1:
        flag = False
for v in dictb.values():
    if len(v) != 1:
        flag = False
if flag:
    print('Yes')
else:
    print('No')
    

Measured memory_bytes: 4016
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#define ll long long
#define oku7 1000000007
using namespace std;
vector<int> v[2000001];

int main(){
	int N, M;
	cin >> N >> M;
	cout << (N - 1)*(M - 1) << "\n";

	

	return 0;
}

Measured memory_bytes: 47104
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n;
	cin>>n;
	long long mx=0;
	long long ans=0;
	while(n--){
		long long a;
		cin>>a;
		mx=max(a,mx);
		ans+=mx-a;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3588
#include <stdio.h>
#include <string>
#include <algorithm>

#define lli long long int

using namespace std;

int main() {
	lli n, temp, ans = 0, cnt;
	char s[15];
	string p[100010];
	scanf("%lld", &n);
	for (lli i = 0; i < n; i++) {
		scanf("%s", s);
		sort(s, s + 10);
		p[i] = s;
	}
	sort(p, p + n);
	for (lli i = 0; i < n; i++) {
		temp = i;
		while (temp + 1 < n) {
			if (p[temp + 1] != p[i])
				break;
			temp++;
		}
		cnt = temp - i + 1;
		ans += (cnt * (cnt - 1) / 2);
		i = temp;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 5760
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

int main()
{
    ll n,t;
    cin >> n >> t;
    vector<pll> a(n);
    rep(i,n){
        cin >> a[i].fi >> a[i].se;
    }
    sort(a.begin(),a.end());
    vector<vector<ll>> dp1(n+1,vector<ll>(6000));
    vector<vector<ll>> dp2(n+1,vector<ll>(6000));
    for(ll i=1;i<=n;i++){
        for(ll j=0;j<=t-1;j++){
            dp1[i][j]=max(dp1[i][j],dp1[i-1][j]); //i品目を注文しないとき
            dp2[i][j]=max(dp2[i][j],dp1[i-1][j]+a[i-1].se);
            dp1[i][j+a[i-1].fi]=max(dp1[i][j+a[i-1].fi],dp2[i][j]);
        }
    }
    ll ans=0;
    for(ll i=0;i<=n;i++){
        for(ll j=0;j<=t-1;j++){
            ans=max(dp2[i][j],ans);
        }
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 281856
#include<bits/stdc++.h>
using namespace std;
int main(){
  int long long A; int long long B; int long long C;
  cin>>A>>B>>C;
  if(A%2!=0||B%2!=0||C%2!=0)
    cout<<0<<endl;
  else if (A==B&&A==C)
    cout<<-1<<endl;
  else {
    int L=A/2; int M=B/2; int N=C/2;
    int Ans=0;
    while(A%2==0&&B%2==0&&C%2==0){
      Ans++;
      A=M+N;
      B=N+L;
      C=M+L;
      L=A/2;
      M=B/2;
      N=C/2;
    }
    cout<<Ans<<endl;
  }
}


Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int A, P;
	cin >> A >> P;
	cout << (3 * A + P) / 2 << endl;

	return 0;
}



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

int main(){
	double n;
	int nn,a[12];
	while(1){
		cin >> n;
		if(n < 0.0) break;
		if(n > 256.0) {
			cout << "NA" << endl;
			continue;
		}
		nn = (int)round(n * 16.0);
		if(abs((double)nn - n * 16.0) > 0.00001) {
			cout << "NA" << endl;
			continue;
		}
		for(int i = 11;i >= 0;i--){
			a[i] = nn % 2;
			nn /= 2;
		}
		for(int i = 0;i < 12;i++){
			cout << a[i];
			if(i == 7) cout << ".";
		}
		cout << endl;
	}
	return 0;
}

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

int main(){
    string s;
    getline(cin,s);
    string q;
    getline(cin,q);
    int q_num = atoi(q.c_str());
    int flag = 0;
    vector<char> ans;
    for(auto si:s){
        ans.push_back(si);
    }
    rep(i,q_num){
        string query;
        getline(cin,query);
        if(query.size()==1){
            flag = 1-flag;
        }
        else{
            if(query[2]=='1'){
                if (flag==0){
                ans.insert(ans.begin(),1,query[4]);
                }else{
                    ans.push_back(query[4]);
                }
            }
            else{
                if(flag==0) ans.push_back(query[4]);
                else ans.insert(ans.begin(),1,query[4]);
            }
        }
    }

    if (flag == 0){
        for(auto anse:ans){
            cout << anse;
        }
        cout << endl;
    }
    else{
        int size;
        size=ans.size();
        for(int i=0;i<size;++i){
            cout<<ans[size-1-i];
        }
        cout << endl;
    }


}

Measured memory_bytes: 1148