akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+2;
string s,p;
ll a[6];
int main()
{
    ft
    ll t,i,j,n,m,l,r,c,x;
    cin>>n;
    p="MARCH";
    for(i=0;i<n;i++)
    {
        cin>>s;
        for(j=0;j<5;j++)
        {
            if(s[0]==p[j])
            {
                a[j]++;
                break;
            }
        }
    }
    r=0,l=0;
    for(i=0;i<5;i++)
    {
        if(a[i]>0)
        {
            r+=a[i];
            l++;
        }
    }
    if(l<3)
    {
        cout<<"0\n";
    }
    else
    {
        l=r*(r-1)*(r-2);
        l/=6;
        for(i=0;i<5;i++)
        {
            if(a[i]>2)
            {
                c=a[i]*(a[i]-1)*(a[i]-2);
                c/=6;
                l-=c;
                c=a[i]*(a[i]-1);
                c/=2;
                l-=(c*(r-a[i]));
            }
            else if(a[i]>1)
            {
                c=a[i]*(a[i]-1);
                c/=2;
                l-=(c*(r-a[i]));
            }
        }
        cout<<l<<"\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  map<int,int> mp;
  for(int i=2;i<=n;i++){
    int j=2,k=i;
    while(k>1){
      if(k%j==0){
        k/=j;mp[j]++;
      }else{
        j++;
      }
    }
  }
  long long ans=1;
  for(auto c:mp){
    ans*=(c.second+1);
    ans%=1000000007;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 100005;
vector<long long> a;
int main(){
	int sum = 0;
	int p;
	scanf("%d", &p);
	for(long long i = 1; i < 10; i++){
		a.push_back(i);
	}
	for(long long i = 0; a.size() < p + 1 ;i++){
		long long n = a[i];
		long long mod = n % 10;
		if(mod == 0){
			a.push_back(n * 10);
			a.push_back(n * 10 + 1);
		}else if(mod == 9){
			a.push_back(n * 10 + 8);
			a.push_back(n * 10 + 9);
		}else{
			a.push_back(n * 10 + mod - 1);
			a.push_back(n * 10 + mod);
			a.push_back(n * 10 + 1 + mod);
		}
	}
	printf("%lld", a[p - 1]);
	
	
	return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}



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

  int x=s.size();

  if(s[x-1]=='s') s+="es";
  else s+='s';

  cout<<s;

return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int count = 0;

    for (int i = 0; i < n; i++) {
      int ai = sc.nextInt();
      if (k <= ai) {
        count++;
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 48780
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long

using namespace std;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int N;
int K;
int Q;

int main () {
  scanf("%d%d%d", &N, &K, &Q);

  int arr[1000000];
  Rep(i, Q) {
    int tmp; 
    scanf("%d", &tmp);
    arr[i] = tmp - 1;
  }

  vector<int> point(N, K);

  Rep(i, Q) {
    int tmp = arr[i];
    point[tmp]++;
  }

  Rep(i, N) {
    if ((point[i] - Q) > 0) {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
  }
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

signed main(){

	string ans ="CODEFESTIVAL2016";
	string s;
	cin>>s;

	lli cnt=0;
	REP(i,0,16){
		if(s.at(i)!=ans.at(i))cnt++;
	}
	cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

long long n,a,b;

int main()
{
	cin >> n >> a >> b;
	if (a % 2 == b % 2)
		cout << (b - a) / 2 << endl;
	else
		cout << min(((a - 1) + (b - 1) + 1) / 2,((n - a) + (n - b) + 1) / 2) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
const ll N=500001;
ll n,q,c[N],l[N],r[N],a[N],b[N],ans[N];
vector<pair<ll,ll>> x[N];

void add(ll x,ll v){
  for(int i=x;i<=n;i+=i&(-i))
    b[i]+=v;
}

int sum(ll x){
  ll v=0;
  for(int i=x;i>0;i-=i&(-i))v+=b[i];
  return v;
}

int main(){
  cin>>n>>q;
  for(int i=1;i<=n;i++)cin>>c[i];
  for(int i=1;i<=q;i++){
    cin>>l[i]>>r[i];
    x[r[i]].push_back({l[i],i});
  }
  for(int i=1;i<=n;i++){
    if(a[c[i]])add(a[c[i]],-1);
    a[c[i]]=i;
    add(i,1);
    for(auto [d,e]:x[i])ans[e]=sum(i)-sum(d-1);
  }
  for(int i=1;i<=q;i++)cout<<ans[i]<<endl;
}


Measured memory_bytes: 51996
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>

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

typedef long long ll;

int main(){
	int i, a, b, c, d, n=1000000;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	rep(i,n){
		c -= b;
		if(c<=0) {
			puts("Yes");
			return 0;
		}
		a -= d;
		if(a<=0){
			puts("No");
			return 0;
		}
	}
}

Measured memory_bytes: 1644
#include<stdio.h>
#define N 100

int n,a[N][N],d[N],f[N],color[N];

int dfs_init(){
    for(int i;i<n;i++)
        color[i]=d[i]=f[i]=0;
}

void dfs(int u){
    static int t=0;
    color[u]=1;
    d[u]=++t;
    for(int v=0;v<n;v++){
        if(a[u][v] && color[v]==0) dfs(v);
    }
    color[u]=2;
    f[u]=++t;
}

int main(){
  int i,j,v,k;
  scanf("%d",&n);
  int u[n];
  for(i=0;i<n;i++)
    for(j=0;j<n;j++)a[i][j]=0;

  for(i=0;i<n;i++){
    scanf("%d %d",&u[i],&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      a[i][v-1]=1;
    }
  }
  /*for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j!=0) printf(" %d",a[i][j]);
      else     printf("%d",a[i][j]);
    }
    printf("\n");
  }
  
  printf("\n");*/
  
  
  dfs_init();
  for(i=0;i<n;i++)
      if(!color[i]) dfs(u[i]-1);
  
  for(i=0;i<n;i++) printf("%d %d %d\n",u[i],d[i],f[i]);
  
  return 0;
}


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

vector<int> dp(100000, -1);
int minCost(vector<int> &stones, int dest){
  	dp[0] = 0;
  	dp[1] = abs(stones[1] - stones[0]);
	for(int i=2;i<=dest;i++){
      dp[i] = min(abs(stones[i]-stones[i-1]) + dp[i-1],
                  abs(stones[i]-stones[i-2]) + dp[i-2]);
    }
  	return dp[dest];
}



int main(){
  int n;
  cin>>n;
  vector<int> vec;
  for(int i=0;i<n;i++){
    int temp;
    cin>>temp;
    vec.push_back(temp);
  }
  vector<int> dp(vec.size(), -1);
  cout<<minCost(vec, vec.size()-1)<<endl;
}

Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
#include<map>
#include<set>
#include<typeinfo>
using namespace std;

const double pi=4*atan(1.0);

constexpr long long mod=static_cast<long long>(1e9+7);

using cWeightEdges=vector<vector<pair<int,int>>>;
using cEdges=vector<vector<int>>;

int main(){
	int T;
	cin>>T;
	while(T--){
		long long N,D;
		cin>>N>>D;
		long long ans=127*(N-1);
		if(N%2)ans+=D;
		else ans+=127-D;
		cout<<ans<<endl;
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
// ABC099_C

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    cin >> n;
    
    int ans = n;
    for(int i = 0; i <= n; i++) {
        int t = i;
        int cc = 0;
        
        while(t > 0) {
            cc += t % 6;
            t /= 6;
        }
        
        t = n - i;
        while(t > 0) {
            cc += t % 9;
            t /= 9;
        }
        
        if(ans > cc) {
            ans = cc;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
n, t = gets.split.map(&:to_i)
ary  = gets.split.map(&:to_i)

ans  = t
prev = 1E10

for i in 1 .. n - 1
  ans += t
  if ary[i] - ary[i - 1] < t
    ans -= (t - (ary[i] - ary[i - 1]))
  end
end

puts ans


Measured memory_bytes: 16004
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	int time[210][2];
	int a[101][2];
	int i,j,n,k,c=0,s=0;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>time[i][0]>>time[i][1];
	}
	cin>>k;
	for(i=0;i<k;i++){
		cin>>a[i][0]>>a[i][1];
	}
	c=n;
	for(i=0;i<k;i++){
		for(j=0;j<n;j++){
			if(time[j][0]==a[i][0]&&time[j][1]==a[i][1]){
				s=1;
			}
		}
		if(s==0){
			time[c][0]=a[i][0];
			time[c][1]=a[i][1];
			c++;
		}
		s=0;
	}
	//cout<<c<<endl;
	for(i=0;i<c;i++){
		for(j=c-1;j>i;j--){
			if(time[i][0]>time[j][0]||time[i][0]==time[j][0]&&time[i][1]>time[j][1]){
				swap(time[i][0],time[j][0]);
				swap(time[i][1],time[j][1]);
			}
		}
	}
	for(i=0;i<c;i++){
		if(i>0){
			cout<<" ";
		}
		if(time[i][1]<10){
			printf("%d:0%d",time[i][0],time[i][1]);
		}
		else{
			printf("%d:%d",time[i][0],time[i][1]);
		}
	}
	cout<<endl;
	return 0;
}

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

int main(){
    unsigned long M, K;
    cin >> M >> K;
    if(M == 1)puts(K ? "-1" : "0 0 1 1");
    else if(1 << M <= K)puts("-1");
    else{
        cout << K << " ";
        for(unsigned long i = 0; i < 1 << M; ++i)if(i ^ K)cout << i << " ";
        cout << K;
        for(unsigned long i = 1UL << M; i;)if(--i ^ K)cout << " " << i;
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define eps 1e-6
#define ll long long
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
//#define int long long
#define MEM(x,y) memset(x,y,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define fi first
#define se second
#define endl "\n"
#define pii pair<int,int>
#define fi first
#define se second
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll Max(ll a,ll b){return a>=b?a:b;}
ll Min(ll a,ll b){return a<=b?a:b;}
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res,t;res=1;t=a%c;while(b){if(b&1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
using namespace std;
//head file

int main()
{
    int n;
    cin>>n;
    int a[n];
    rep(i,0,n)
    cin>>a[i];
    ll sum=0;
    rep(i,1,n)
    {
        if(a[i]-a[i-1]<0)
        {
            sum+=a[i-1]-a[i];
            a[i]=a[i-1];
        }
    }
    cout<<sum;
}


Measured memory_bytes: 4376
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	int n,x;
	cin>>n>>x;
	vector<int>a(n);
	rep(i,n){
		cin>>a[i];
	}
	ll ans=0;
	rep(i,n-1){
		int t=a[i]+a[i+1];
		if(t>x){
			int dis=t-x;
			ans+=dis;
			if(a[i+1]>=dis){
				a[i+1]-=dis;
			}else{
				dis-=a[i+1];
				a[i+1]=0;
				a[i]-=dis;
			}
		}
	}
	cout<<ans<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)
int main(){
    ll N;
    cin >> N;

    ll sum = 0;
    ll lastdigit = 0;
    ll num = 0;
    while (N > 0) {
        sum += N % 10;
        num ++;
        lastdigit = N % 10;
        N /= 10;
    }

    sum = max(sum, lastdigit - 1 + (num-1)*9);

    cout << sum << endl;

    
}


Measured memory_bytes: 256
def main():
    from heapq import heappush, heappop
    import sys
    readline = sys.stdin.buffer.readline
    MOD = 10**9 + 7
    N = int(readline())
    edge = [[] for _ in range(N)]
    for i in range(N-1):
        a, b = (int(i) for i in readline().split())
        edge[a-1].append(b-1)
        edge[b-1].append(a-1)
    dp = [[1]*2 for _ in range(N)]
    from collections import deque
    G_color = ['WHITE' for _ in range(N)]
    G_distance = [float('inf') for _ in range(N)]
    G_parent = ['NIL' for _ in range(N)]

    def bfs(G, s):
        leaves = []
        G_color[s] = 'GRAY'
        G_distance[s] = 0
        Q = deque()
        Q.append(s)
        while Q:
            u = Q.popleft()
            has_child = False
            for v in G[u]:
                if G_color[v] == 'WHITE':
                    G_color[v] = 'GRAY'
                    G_distance[v] = G_distance[u] + 1
                    G_parent[v] = u
                    has_child = True
                    Q.append(v)
            G_color[u] = 'BLACK'
            if not(has_child):
                heappush(leaves, (-G_distance[u], u))
        return leaves

    leaves = bfs(edge, 0)
    seen = [False]*N
    while leaves:
        _, leaf = heappop(leaves)
        par = G_parent[leaf]
        if par == 'NIL':
            continue
        dp[par][0] *= dp[leaf][1]
        dp[par][1] *= (dp[leaf][0]+dp[leaf][1])
        dp[par][0] %= MOD
        dp[par][1] %= MOD
        if seen[par]:
            continue
        heappush(leaves, (-G_distance[par], par))
        seen[par] = True
    print((dp[0][0]+dp[0][1]) % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 103968
object Main extends App {
  val Array(a, b, c, x) = Iterator.continually(io.StdIn.readLine.toInt)
    .take(4).toArray

  val ans = {
    for {
      i <- 0 to a
      c500 = 500*i
      if c500 <= x
      j <- 0 to b
      rem = x - c500 - 100*j
      if rem >= 0 && rem % 50 == 0 && rem / 50 <= c
    } yield true
  }.size

  println(ans)
}

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

int main(){
  int n,x;cin>>n>>x;
  vector<int> children(n);
  for (int i=0;i<n;++i) cin >> children.at(i);
  sort(children.begin(),children.end());
  int j=0;
  // int sum=0;
  // for (int i=0;i<n;++i) sum += children[i];
  // if(sum<x){
  //   cout << n-1<<endl;
  //   return 0;
  // }

  while (x>0){
    x -= children[j];
    ++j;
    if (n==j) break;
  }
  if(x==0) cout << j;
  else     cout << j-1;
  cout << endl;

  return 0;
}


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

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


Measured memory_bytes: 3088
#include <stdio.h>

int main(void)
{
	int in[100];
	int out[100];
	int i, j, k;
	
	k = 0;
	j = 0;
	while (scanf("%d", &i) != EOF){
		if (i == 0){
			j--;
			out[k] = in[j];
			k++;
		}
		else {
			in[j] = i;
			j++;
		}
	}
	for (i = 0; i < k; i++){
		printf("%d\n", out[i]);
	}
	
	return (0);
}

Measured memory_bytes: 600
S = input()
count=0
if S[0]=="A":
  for i in range(2,max([len(S)-1,3]),1):
    if S[i]=="C":
      count+=1
      idx=i
  if count==1:
    s=S[1:idx]+S[idx+1:]
    if s==s.lower():
      print("AC")
    else:
      print("WA")
  else:
    print("WA")
else:
  print("WA")

Measured memory_bytes: 3188
#include <iostream>

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

int selectionSort(int *a, int n) {
  int cnt = 0;
  rep(i, n) {
    int min = i;
    for (int j = i; j < n; j++) {
      if (a[j] < a[min])
        min = j;
    }

    if (min == i)
      continue;

    int temp = a[i];
    a[i] = a[min];
    a[min] = temp;
    cnt++;
  }

  return cnt;
}

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

  int a[n];
  rep(i, n) std::cin >> a[i];

  int cnt = selectionSort(a, n);

  rep(i, n) {
    std::cout << a[i];
    if (i == n - 1)
      std::cout << '\n';
    else
      std::cout << ' ';
  }

  std::cout << cnt << '\n';

  return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
int n,k;
int a[2003],num[2003],ha[2003];
long long ans=0;
const long long MOD=1e9+7; 
int main(){
	cin>>n>>k;
	for (int i=0;i<n;i++)
		cin>>a[i];
	for (int i=0;i<n;i++){ 
		for (int j=0;j<n;j++) if (a[i]>a[j]) num[i]++;
	}
	for (int i=0;i<n;i++){
		for (int j=i+1;j<n;j++) if (a[i]>a[j]) ha[i]++;
	}
	for (int i=0;i<n;i++){
		ans+=1ll*k*(k-1)/2%MOD*num[i]%MOD+1ll*k*ha[i]%MOD;
		ans%=MOD;
	}
	cout<<ans;
}

Measured memory_bytes: 256
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

int main(void) {
    int A,B,C;
    cin>>A>>B>>C;

    cout<<max({A,B,C})-min({A,B,C})<<endl;


}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <cassert>
#include <cfloat>
#include <climits>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}
bool ok[10];
int main() {
	int N,K;
	cin >> N >> K;
	int D;
	for (int i = 0; i < 10; i++) {
		ok[i] = true;
	}

	for (int i = 0; i < K; i++) {
		cin >> D;
		ok[D] = false;
	}
	int a = 10;
	int n = 1;
	while (true) {
		if (!ok[(n % a) / (a / 10)]) {
			n += a/10;
		}
		else {
			a = a * 10;
			
		}
		if (a/10 > n) {
			if (n >= N) {
				break;
				
			}
			else {
				n++;
				a = 10;
			}
		}
	}
	cout <<n << endl;
	return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
dp = [0]*(n+1)
for _ in range(m):
    a, b = (int(x) for x in input().split())
    if a == 1:
        dp[b] += 1
    if b == n:
        dp[a] += 1
for i in dp:
    if i == 2:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')

Measured memory_bytes: 48932
#include<bits/stdc++.h>
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000001
#define MAXN        200000005
#define mod         1000000007
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k,sum=0,x;
    cin>>n>>k;
    while(n--){
        cin>>x;
        if(x>=k){
            sum++;
        }
    }
    cout<<sum;
}

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

int Q;
int rev_cnt = 0;
string S, SF, SR;

void input_init(void) {
	cin >> S >> Q;
	SF = "";
	SR = "";
}

void solve(void) {
	int T, F;
	char C;
	for (int i = 0; i < Q; ++i) {
		cin >> T;
		if (T == 1)
			++rev_cnt;
		else {
			cin >> F >> C;
			if (F == 1) {
				if (rev_cnt % 2 == 0)
					SF += C;
				else
					SR += C;
			}
			else {
				if (rev_cnt % 2 == 0)
					SR += C;
				else
					SF += C;
			}
		}
	}
}

void out_ans(void) {
	if (rev_cnt % 2 == 0) {
		reverse(SF.begin(), SF.end());
		cout << SF << S << SR << '\n';
	}
	else {
		reverse(SR.begin(), SR.end());
		reverse(S.begin(), S.end());
		cout << SR << S << SF << '\n';
	}
}

int main(void) {
	input_init();
	solve();
	out_ans();
	return 0;
}


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

#pragma region Macros
using ll = long long;
#define int ll
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
#define IOS\
    ios::sync_with_stdio(false);\
    cin.tie(0);\
    cout.tie(0);
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SORT(name) sort(name.begin(), name.end())
#define RSORT(name)\
    SORT(name);\
    reverse(all(name));
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
template <class T> inline void print(T x){ cout << x << '\n';}
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; }

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
#pragma endregion

#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const int MOD = 1000000007;
const int MAX_N = 100010;

signed main() {
    IOS;

    int x;
    cin >> x;
    if(x == 0) { print(1); }
    else { print(0); }

    return 0;
}


Measured memory_bytes: 3608
import sys
sys.setrecursionlimit(500000)

def dfs(c,l,d):
    if c == 0:
        ans[0] = min(ans[0],d)
        return
    for i in range(r):
        if seen[i]:continue
        seen[i] = True
        if l == -1:dfs(c-1,i,0)
        else:dfs(c-1,i,d+dp[R[l]-1][R[i]-1])
        seen[i] = False

n,m,r = map(int,input().split())
R = list(map(int,input().split()))
dp = [[0 if i == j else float("Inf") for i in range(n)] for j in range(n)]
for i in range(m):
    x,y,z = map(int,input().split())
    dp[x-1][y-1] = z
    dp[y-1][x-1] = z
for k in range(n):
    for i in range(n):
        for j in range(n):
            dp[i][j] = min(dp[i][j],dp[i][k]+dp[k][j])
ans = [float("Inf")]
seen = [False]*r
dfs(r,-1,0)
print(*ans)

Measured memory_bytes: 75608
def main():
    n = int(input())
    s = input()
    # Positions for each character.
    rs = s.count('R')
    gs = s.count('G')
    bs = s.count('B')
    ans = rs * gs * bs

    # `i, j` を決めれば， `k = j + (j-i)`。 `j-i = k-j` の組合わせを引く。
    for j in range(n):
        for i in range(j):  # i < j
            k = j + (j - i)
            if k >= n:
                continue
            if s[i] == s[j]:
                continue
            if s[i] == s[k]:
                continue
            if s[j] == s[k]:
                continue

            # `j-i = k-j` かつRGB。
            ans -= 1

    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 9156
def FloorSum(n,m,a,b):
    ret = 0
    while True:
        if a>=m:
            ret += (n-1)*n*(a//m)//2
            a%=m

        if b>=m:
            ret += n*(b//m)
            b%=m

        y = (a*n+b)//m
        x = y*m-b

        if y==0:
            return ret

        ret += (n-(x+a-1)//a)*y
        n = y
        b = (a-x%a)%a
        m,a = a,m

T = int(input())

for i in range(T):
    n,m,a,b = list(map(int,input().split()))
    print(FloorSum(n,m,a,b))

Measured memory_bytes: 70024
#include<iostream>
#include<cstring>
using namespace std;
string a,b="CF";
int al,bl;

int main(){
    getline(cin,a);
    al=a.length();
    for(int i=0;i<al;i++)
        if(a[i]==b[bl]){
            bl++;
            if(bl==2)
                break;
        }
    if(bl==2) cout<<"Yes";
    else cout<<"No";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <functional> 
#include <vector>

using namespace std;

int main(){

    string s,t;
    cin >> s;
    cin >> t;

    int slen = s.size();
    int tlen = t.size();

    if(slen < tlen){
        cout << "UNRESTORABLE";
        return 0;
    }

    for(int i=slen-tlen;i>=0;i--){
        for(int l=0,cnt = 0;l<tlen;l++){
            if(s[i+l] == '?') cnt++;
            if(s[i+l] == t[l]) cnt++;
            if(cnt == tlen){
                for(int m=0;m<i;m++){
                    if(s[m] == '?') cout << 'a';
                    if(s[m] != '?') cout << s[m];
                }
                cout << t;
                for(int m = 0;m<slen-tlen-i;m++){
                    if(s[m+i+tlen] == '?') cout << 'a';
                    if(s[m+i+tlen] != '?') cout << s[m+i+tlen]; 
                }
                return 0;
            }
        }
    }

    cout << "UNRESTORABLE";

    return 0;
}

Measured memory_bytes: 256
// Problem : E - Gluttony
// Contest : AtCoder - AtCoder Beginner Contest 144
// URL : https://atcoder.jp/contests/abc144/tasks/abc144_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 200005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
int n,k;
int a[maxn],f[maxn];
int check(int mid)
{
	int t =k;
	rep(i,0,n)
	{
		int x = a[i]*f[i];
		if(x > mid)
		{
			int r = mid/f[i];
			int diff = a[i]-r;
			if(diff > t)
			return false;
			t -= diff; 
		}
	}
	return true;
}
void solve()
{
	cin >> n >> k;	
	rep(i,0,n)
	cin >> a[i];
	rep(i,0,n)
	cin >> f[i];
	sort(a,a+n);
	sort(f,f+n,greater<int> ());
	int start = 0, end = (int)1e12,ans;
	while(start <= end)
	{
		int mid = (start+end)/2;
		if(check(mid))
		{
			ans = mid;
			end = mid-1;
		}
		else start= mid+1;
	}
	cout << ans;
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 6756
#include <iostream>
#include <set>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n + 1);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  struct node_t {
    int st, en, low, ord;
    set<int> qs;
  };
  vector<node_t> dp(n + 1);
  int k;
  cin >> k;
  for (int i = 0; i < k; ++i) {
    int a, b;
    cin >> a >> b;
    dp[a].qs.insert(i);
    dp[a].st += 1;
    dp[b].qs.insert(i);
    dp[b].en += 1;
  }
  int o = 0;
  bool f = true;
  vector<pair<int, int>> ans;
  auto dfs = [&](auto &dfs, int v, int p) -> void {
    auto &dv = dp[v];
    dv.ord = dv.low = ++o;
    for (auto e : g[v]) {
      if (e == p)
        continue;
      auto &de = dp[e];
      if (de.ord != 0) {
        if (de.ord < dv.ord) {
          if (dv.low > de.ord)
            dv.low = de.ord;
          ans.emplace_back(v, e);
        }
      } else {
        dfs(dfs, e, v);
        if (de.ord == de.low && de.st > 0) {
          if (de.en > 0)
            f = false;
          ans.emplace_back(e, v);
        } else {
          ans.emplace_back(v, e);
        }
        dv.st += de.st;
        dv.en += de.en;
        if (dv.qs.size() < de.qs.size())
          swap(dv.qs, de.qs);
        for (int x : de.qs) {
          if (dv.qs.count(x)) {
            dv.qs.erase(x);
            dv.st -= 1;
            dv.en -= 1;
          } else {
            dv.qs.insert(x);
          }
        }
      }
    }
  };
  dfs(dfs, 1, 0);
  if (f) {
    cout << "Yes" << endl;
    for (auto &e : ans)
      cout << e.first << ' ' << e.second << endl;
  } else {
    cout << "No" << endl;
  }
}



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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if(A==B && B==C) cout << "No" << endl;
  else if(A!=B && B!=C && A!=C) cout << "No" << endl;
  else cout << "Yes" << endl;
}

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

#define ll long long

using namespace std;


int x,k;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>k>>x;
    if (k*500>=x){
        cout<<"Yes";
    }
    else cout<<"No";




    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int A, B; std::cin >> A >> B;
  fin(A*B);
  return 0;
}


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

#ifdef LOCAL
	#define de(x) cout<<#x<<"="<<x<<endl
	#define rff freopen("input.txt","r",stdin)
#else
	#define de(x)
	#define rff
#endif

#define itr(x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define For(i,n) for (int i=1;i<=(int)(n);i++)
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define all(x) (x).begin(),(x).end()
#define PQ priority_queue
#define pii pair<int,int>
#define vi vector <int>
#define ll long long
#define pb push_back
#define mp make_pair
#define re return
#define se second
#define fi first
const int INF=0x7fffffff;
const int MAXN=+3;

struct num{
	int even;
	int odd;
	int n;
}a[100005];

int n,ans;
int f1,n1,s1,f2,n2,s2;

bool cmp1(num a,num b){
	re a.odd>b.odd;
}

bool cmp2(num a,num b){
	re a.even>b.even;
}

int main(){
	int t;
	cin>>n;
	ans=n;
	For(i,100000){
		a[i].n=i;
	}
	rep(i,n){
		cin>>t;
		if (i%2){
			a[t].even++;
		}else{
			a[t].odd++;
		}
	}
	sort(a+1,a+100001,cmp1);
	f1=a[1].odd;
	n1=a[1].n;
	s1=a[2].odd;
	sort(a+1,a+100001,cmp2);
	f2=a[1].even;
	n2=a[1].n;
	s2=a[2].even;
	if (n1!=n2){
		ans-=f1+f2;
	}else{
		ans-=max(f1+s2,f2+s1);
	}
	cout<<ans;
	re 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int n,opt[100005];
int c[20] = {1,6,36,216,1296,7776,46656,9,81,729,6561,59049};
int main(){
	cin >> n;
	for(int i = 1;i <= n;i++){
		opt[i] = i;
		for(int j = 0;j < 12;j++)
			if (i >= c[j]) opt[i] = min(opt[i],opt[i - c[j]] + 1);		
	}
	cout << opt[n] << endl;
	return 0;		
}

Measured memory_bytes: 3768
use std::io::Write;

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };

    let s2 = {
        let mut s2 = String::new();
        std::io::stdin().read_line(&mut s2).unwrap();
        s2.trim_right().to_owned()
    };
    let k: usize = s2.parse().unwrap();

    // else
    // 同じ文字で分割、数えて配列に
    //
    // if 最初と最後が同じ文字だったら
    // がんばる
    // else
    // 掛け算すればおわり

    let count_vec = chars_count(&s);
    debugln!("{}", s);
    debugln!("{:?}", count_vec);

    // if 全部同じ文字だったら
    if count_vec.len() == 1 {
        println!("{}", (count_vec[0] * k) / 2);
        return;
    }

    // if 最初と最後が同じ文字だったら
    let len = s.len();
    if &s[0..1] == &s[(len - 1)..len] {
        // がんばる
        // このときcount_vecの長さは3以上
        debugln!("Same");
        let first = count_vec.first().unwrap();
        let last = count_vec.last().unwrap();
        let rest = &count_vec[1..(count_vec.len() - 1)];

        let result = rest.iter().map(|x| x / 2).sum::<usize>() * k
            + (first / 2) + (last / 2) + ((first + last) / 2) * (k - 1);
        println!("{}", result);
    } else {
        // 掛け算すればおわり
        let result = count_vec.iter().map(|x| x / 2).sum::<usize>() * k;
        println!("{}", result);
    }
}

fn chars_count(s: &String) -> Vec<usize> {
    let mut count_vec: Vec<usize> = vec![];
    let mut count = 0;
    let mut prev_c = ' ';
    for c in s.chars() {
        // 最初の文字のとき
        if prev_c == ' ' {
            prev_c = c;
            count = 1;
            continue;
        }

        if prev_c == c {
            count += 1;
            continue;
        }

        prev_c = c;
        count_vec.push(count);
        count = 1;
    }
    count_vec.push(count);

    count_vec
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
 
const int N = 1e5 + 5;
 
int n, m, k;
int x11, y11, x2, y2;
int dx[4]={-1, +1, 0, 0};
int dy[4]={0, 0, +1, -1};
vector<vector<char> > a;
vector<vector<int> > vis, ways, dist;
 
void bfs(int x, int y)
{
	queue<pair<int, int> > q;
	q.push({x, y});
	vis[x][y] = 1;
	dist[x][y] = 0;
	while(!q.empty())
	{
		int x=q.front().first;
		int y=q.front().second;
		q.pop();
		for(int dir=0;dir<4;dir++)
		{
			for(int len = 1; len <= k; len++)
			{
				int nx=x+dx[dir] * len;
				int ny=y+dy[dir] * len;
				if(nx<1 || ny<1 || nx>n || ny>m)
					break;
				if(vis[nx][ny] && dist[x][y] + 1 > dist[nx][ny])
					break;
				if(a[nx][ny] == '@')
					break;
				if(vis[nx][ny])
					continue;
				dist[nx][ny]=dist[x][y]+1;
				vis[nx][ny]=1;
				q.push({nx, ny});
			}
		}
	}
}
 
int32_t main()
{
	IOS;
	cin >> n >> m >> k;
	cin >> x11 >> y11 >> x2 >> y2;
	a = vector<vector<char> > (n + 1, vector<char> (m + 1));
	vis = ways = dist = vector<vector<int> > (n + 1, vector<int> (m + 1, 0));
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			cin >> a[i][j];
	bfs(x11, y11);
	if(!vis[x2][y2])
		cout << -1;
	else
		cout << dist[x2][y2];
	return 0;
}


Measured memory_bytes: 32476
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
#define maxn 10100

struct N
{
    int n1, n2, cost;
}e[maxn];

int fa[maxn];

bool cmp(N a, N b)
{
    return a.cost<b.cost;
}

void init()
{
    for(int i=0; i<maxn; i++)
        fa[i]=i;
}

int find1(int x)
{
    if(x==fa[x])
        return x;
    fa[x]=find1(fa[x]);
    return fa[x];
}

int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)&&(n||m))
    {
        init();
        for(int i=0; i<m; i++)
            scanf("%d%d%d",&e[i].n1,&e[i].n2,&e[i].cost);
        sort(e,e+m,cmp);
        int num=0;
        for(int i=0; i<m; i++)
        {
            int a=find1(e[i].n1);
            int b=find1(e[i].n2);
            if(a==b)
                continue;
            fa[a]=fa[b];
            num++;
            if(num==(n+1)/2)
            {
                cout << e[i].cost << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 1388
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  int n, k;
  while (~scanf("%d %d", &n, &k)) {
    if ((n|k) == 0)
      break;

    vector<int> a(n);
    for (int i = 0; i < n; ++i)
      scanf("%d", &a[i]);

    for (int i = 1; i < n; ++i)
      a[i] += a[i-1];

    int ans = a[k-1];
    for (int i = k; i < n; ++i)
      ans = max(ans, a[i]-a[i-k]);

    printf("%d\n", ans);
  }
  return 0;
}

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

public class Main {
    int n, l;
    String[] ss;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        l = sc.nextInt();
        ss = new String[n];
        for (int i = 0; i < n ; i++) {
            ss[i] = sc.next();
        }
        solve();
    }

    void solve() {
        Arrays.sort(ss);
        for (int i = 0; i < n; i++) {
            System.out.print(ss[i]);
        }
        System.out.println();
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 23380
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;

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

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

	if (a == b)
		cout << "Draw" << "\n";
	else if (a > b)
	{
		if (b == 1)
			cout << "Bob" << "\n";
		else
			cout << "Alice" << "\n";
	}
	else if (a < b)
	{
		if (a == 1)
			cout << "Alice" << "\n";
		else
			cout << "Bob" << "\n";
	}
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] arr = new int[N];
        for(int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);

        int count = 0;
        for(int i = 0; i < N-1; i++) {
            if(arr[i] == arr[i+1]) {
                count++;
            }
        }
        if(count == 0) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 64100
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#define INF (long)1e9
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int A[n + 1];
	for(int i = 1; i <= n; i++)
	{
		cin >> A[i];
	}
	int pos = 1, cnt = 0;
	vector<int> vec(4, 0);
	while(1)
	{
		pos = A[pos];
		cnt++;
		if(pos == 2)
		{
			cout << cnt << endl;
			return 0;
		}
		if(cnt > n) break;
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long int  ll;
typedef pair<ll, ll> P;

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template< typename S, typename T >
inline void chmax(S &a, const T &b) { if(a < b) a = b; }
 
template< typename S, typename T >
inline void chmin(S &a, const T &b) { if(a > b) a = b; }
 

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

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
	if(n==0) return (ll)1;
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
ll modinv(ll a, ll m) {
	if(m==0)return (ll)1;
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


////////////////////////////////////////////////////////////////////

int main(){
ll n;
cin>>n;
ll a[n+1];

for(int i=1;i<=n;i++){
	cin>>a[i];
}

sort(a+1,a+n+1,greater<ll>());

ll ans=a[1];
for(ll i=3;i<=n;i++){
ll k=(i+1)/2;
ans+=a[k];
}
cout<<ans<<endl;


return 0;
}




Measured memory_bytes: 5192
#include<iostream>
#include<algorithm>
using namespace std;
int dp[3200][3200],a[3200],b[3200];
signed main() {
	int n, t, s;
	cin >> n >> t >> s;
	for (int i = 1; i <= n; i++)cin >> a[i] >> b[i];

	int ans = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= t; j++) {
			dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			if (j >= b[i] && (j - b[i] >= s||j <= s))
				dp[i][j] = max(dp[i-1][j-b[i]]+a[i],dp[i][j]);
			ans = max(ans, dp[i][j]);
		}
	}
	cout << ans<< endl;
}

Measured memory_bytes: 40632
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
int main()
{
  int a,b,c;
  while(cin>>a>>b>>c)
  {
    int g;
    if(a>b) g=gcd(a,b);
    else g=gcd(b,a);
    //cout<<g<<endl;
    vector<int> v;
    for(int i=g;i>0;i--)
    {
        if(g%i==0) v.push_back(i);
        //if(v.size()>=c) break;
    }
    cout<<v[c-1]<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
const int MOD = 1e9 + 7, N = 5e5 + 10;
const int LINF = LLONG_MAX;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a;
    long double b;
    cin >> a >> b;
    long double c = a*b;
    cout << (int)c;
    return 0;
}
 

Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
int n,k;
int dp[200009][3],arr[200009][3];
int bt(int x,int pre)
{
    if(x==n)return 0;
    if(dp[x][pre]!=-1)return dp[x][pre];
    int &ret=dp[x][pre];
    for(int i=0;i<3;i++)
    {
        if(pre==i)continue;
        ret=max(ret,bt(x+1,i)+arr[x][i]);
    }
    return ret;
}
int main()
{
    memset(dp,-1,sizeof(dp));
    cin>>n;
    for(int i=0;i<n;i++)cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    cout<<max(bt(0,0),max(bt(0,1),bt(0,2)));
}


Measured memory_bytes: 11904
// ConsoleApplication3.cpp : アプリケーションのエントリ ポイントを定義します。
//

#include "bits/stdc++.h"

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

using namespace std;


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

	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	cout << a[n - 1] - a[0] <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
vector<ll> V;
priority_queue<ll> Q;

bool cmp(ll a,ll b) {
    return a > b;
}
int main() {
    ll n, x, sum = 0, u;

    cin >> n;

    for(int i = 1; i <= n; ++i)
        cin >> x, V.push_back(x);

    sort(V.begin(),V.end(),cmp);

    Q.push(V[0]);
    for(int i = 1; i < V.size(); ++i) {
        u = Q.top(), sum += u, Q.pop();
        Q.push(V[i]), Q.push(V[i]);
        //printf("%d -> %d %d\n",u,V[i],V[i]);
    }

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

Measured memory_bytes: 7964