akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

//BEGIN CUT HERE
template <typename T,typename E>
struct SegmentTree{
  using F = function<T(T,T)>;
  using G = function<T(T,E)>;
  using H = function<E(E,E)>;
  using P = function<E(E,size_t)>;
  int n;
  F f;
  G g;
  H h;
  T ti;
  E ei;
  P p;
  vector<T> dat;
  vector<E> laz;
  SegmentTree(int n_,F f,G g,H h,T ti,E ei,
	      P p=[](E a,size_t b){return a;}):
    f(f),g(g),h(h),ti(ti),ei(ei),p(p){
    init(n_);
  }
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    dat.assign(2*n-1,ti);
    laz.assign(2*n-1,ei);
  }
  void build(int n_, vector<T> v){
    for(int i=0;i<n_;i++) dat[i+n-1]=v[i];
    for(int i=n-2;i>=0;i--)
      dat[i]=f(dat[i*2+1],dat[i*2+2]);
  }
  inline void eval(int len,int k){
    if(laz[k]==ei) return;
    if(k*2+1<n*2-1){
      laz[k*2+1]=h(laz[k*2+1],laz[k]);
      laz[k*2+2]=h(laz[k*2+2],laz[k]);
    }
    dat[k]=g(dat[k],p(laz[k],len));
    laz[k]=ei;
  }
  T update(int a,int b,E x,int k,int l,int r){
    eval(r-l,k);
    if(r<=a||b<=l) return dat[k];
    if(a<=l&&r<=b){
      laz[k]=h(laz[k],x);
      return g(dat[k],p(laz[k],r-l));
    }
    return dat[k]=f(update(a,b,x,k*2+1,l,(l+r)/2),
		    update(a,b,x,k*2+2,(l+r)/2,r));
  }
  T update(int a,int b,E x){
    return update(a,b,x,0,0,n);
  }
  T query(int a,int b,int k,int l,int r){
    eval(r-l,k);
    if(r<=a||b<=l) return ti;
    if(a<=l&&r<=b) return dat[k];
    T vl=query(a,b,k*2+1,l,(l+r)/2);
    T vr=query(a,b,k*2+2,(l+r)/2,r);
    return f(vl,vr);
  }
  T query(int a,int b){
    return query(a,b,0,0,n);
  }
  void update(int k,T x){
    query(k,k+1);//evaluate
    k+=n-1;
    dat[k]=x;
    while(k){
      k=(k-1)/2;
      dat[k]=f(dat[k*2+1],dat[k*2+2]);
    }
  }
};
//END CUT HERE
signed main(){
  int n,q;
  cin>>n>>q;
  SegmentTree<int,int> ch(n,
			  [](int a,int b){return min(a,b);},
			  [](int a,int b){return b;},
			  [](int a,int b){return b;},
			  INT_MAX,INT_MAX,
			  [](int a,int b){return a;});
  ch.build(n,vector<int>(n,INT_MAX));
  for(int i=0;i<q;i++){
    int c,s,t,x;
    cin>>c;
    if(c){
      cin>>s>>t;
      cout<<ch.query(s,t+1)<<endl;
    }else{
      cin>>t>>x;
      ch.update(t,t+1,x);
    }
  }
}


Measured memory_bytes: 5188
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from collections import defaultdict


def solve():
    n = int(input())
    v = [int(i) for i in input().split()]
    d1 = defaultdict(int)
    d2 = defaultdict(int)
    for i in range(n):
        if i % 2 == 0:
            d1[v[i]] += 1
        else:
            d2[v[i]] += 1
    rd1 = defaultdict(list)
    rd2 = defaultdict(list)
    for k, v in d1.items():
        rd1[v].append(k)
    for k, v in d2.items():
        rd2[v].append(k)
    a1 = [i for i in sorted(rd1.keys(), reverse=True)]
    a2 = [i for i in sorted(rd2.keys(), reverse=True)]
    ans = n
    la1 = len(a1) - 1
    la2 = len(a2) - 1
    for h in range(3):
        for i in range(3):
            aa1 = rd1[a1[min(h, la1)]]
            aa2 = rd2[a2[min(i, la2)]]
            s1 = set(aa1)
            s2 = set(aa2)
            if len(s1) > 1 or len(s2) > 1 or (s1 - s2) or (s2 - s1):
                ans = min(
                    ans, (n // 2) - a1[min(h, la1)] + (n // 2) - a2[min(i, la2)])
            else:
                ans = min(ans, (n // 2) - a1[min(h, la1)] + (n // 2) - a2[min(i, la2)]
                          + min(a1[min(h, la1)], a2[min(i, la2)]))
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 107524
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
	int a[5];
	for(int i=0;i<5;i++) cin>>a[i];
	sort(a,a+5,greater<int>());
	for(int i=0;i<5;i++){ 
		cout<<a[i];
		if(i!=4)cout<<" ";
	}
	cout<<endl;
}

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

using namespace std;

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

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

    reverse(S.begin(), S.end());
    for(int i = 0; i < 4; i++) reverse(divide[i].begin(), divide[i].end());

    bool can = true;
    for(int i = 0; i < S.size(); ){
        bool can2 = false;
        for(int j = 0; j < 4; j++){
            if(S.substr(i,divide[j].size()) == divide[j]){
                can2 = true;
                i += divide[j].size();
            }
        }
        if(!can2){
            can = false;
            break;
        }
    }

    if(can) cout << "YES" << endl;
    else cout << "NO" << endl;
}

    


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

using namespace std;
using ll=long long;
const ll mod = 1e9 + 7;
int dy[] = {1, -1, 0, 0};
int dx[] = {0, 0, 1, -1};

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

    vector<ll> a(3*N);
    ll ans=0;
    for(int i = 0; i < 3*N; ++i) {
      cin>> a[i];
    }
    sort(a.begin(),a.end());
    for(int i = 0; i < N; ++i) {
        ans+=a[2*i+N];
    }

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


Measured memory_bytes: 2560
function Main(input) {
  var inputs = input.split("\n");
  var n_m = inputs[0].split(" ").map(e => parseInt(e, 10));
  var town = [];
  for (var i = 0; i < n_m[0]; i++) {
    town.push(0);
  }
  var roads;
  for (var i = 1; i <= n_m[1]; i++) {
    roads = inputs[i].split(" ").map(e => parseInt(e, 10));
    town[roads[0] - 1]++;
    town[roads[1] - 1]++;
  }
  for (i of town) {
    console.log(i);
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,h[110],ans=0;

inline bool check()
{
	rep(i,n) if(h[i]>0) return false;
	return true;
}

int main()
{
	cin>>n;
	rep(i,n) cin>>h[i];
	while(true)
	{
		if(check()) break;
		ans++;
		bool ok=false;
		rep(i,n)
		{
			if(h[i]>0) h[i]--,ok=true;
			else if(ok) break;
		}
	}
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
	      Scanner sc = new Scanner(System.in);
	      int n = sc.nextInt();
	      Integer[] card = new Integer[n];
	      int alice = 0;
	      int bob = 0;
	      for(int i=0; i<n; i++) {
	  		card[i] = sc.nextInt();
	  	}
	      Arrays.sort(card, Comparator.reverseOrder());;
	      for(int i=0; i<n; i++) {
	    	  if(i%2 == 0) {
	    		  alice += card[i];
	    	  }
	    	  else {
	    		  bob += card[i];
	    	  }
	      }
	      System.out.println(alice - bob);
	}
}

Measured memory_bytes: 21460
/*
                        Author: Ankit Kaul
**********************Code Belongs to Respective Author Only************************************
*/
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include <bits/stdc++.h>
#define endl       '\n'
#define PI          3.141592653589
#define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define int         long long int
#define inf         INT_MAX
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
using namespace std;
int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
    int result=1;
    while(n>0)
        {   if(n % 2 ==1)
            result=(result * x)%M;
            x=(x*x)%M;
            n=n/2;
        }
    return result%M;
}      
bool isPrime(int n)
    {
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
    }
int inv(int a,int m)
{   return power(a,m-2);
}
int lcm(int a,int b)
{   return a*b/(gcd(a,b));
}
signed main()
{   jaldi
    string str;
    cin>>str;
    int q;
    cin>>q;
    deque<char> dq;
    for(auto i: str)
    dq.pb(i);
    bool z=0;
    while(q--)
    {   int x;
        cin>>x;
        if(x==1)
        z=z^1;
        else
        {   int y;
            char ch;
            cin>>y>>ch;
            if((y==2)^z)
            dq.pb(ch);
            else
            dq.push_front(ch);
        }
    }
    if(z)
    reverse(dq.begin(),dq.end());
    for(auto i: dq)
    cout<<i;
}



Measured memory_bytes: 976
N = int(input())
A = list(map(int, input().split()))


def is_even(n: int) -> bool:
    if n % 2 == 0:
        return True
    else:
        return False


def div_by_2(n: int) -> int:
    return n // 2


ans = 0
while all(map(is_even, A)):
    ans += 1
    A = list(map(div_by_2, A))
print(ans)


Measured memory_bytes: 3060
import java.util.*;

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

		for(int i=0;i<n;i++){
			String s = sc.next();
			int p = 0;
			int q = 0;
			int r = 0;
			int count = 0;
			
			for(int j=0;j<s.length();j++){
				q = p;
				p = s.codePointAt(j)-48;

				if(p==0){
					if(q==1){
						if(count%5==1) r = 46;
						else if(count%5==2) r = 44;
						else if(count%5==3) r = 33;
						else if(count%5==4) r = 63;
						else r = 32;
					}else if(q==7){
						r = 112+(count-1)%4;
					}else if(q==8){
						r = 116+(count-1)%3;
					}else if(q==9){
						r = 119+(count-1)%4;
					}else{
						r = 91 + q*3 + (count-1)%3;
					}
					if(q!=0) System.out.print((char)r);
					count=0;
				}else{
					count++;
				}		
			}
			System.out.println();
		}
		
	}	
}

Measured memory_bytes: 19868
#include <bits/stdc++.h>
typedef long long ll;
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
using namespace std;
ll dp[105][100005];
int main()
{
	//ios::sync_with_stdio(0);
	//cin.tie(0);
    ll n, w;
    cin >> n >> w;
    ll wt[n], val[n];
    for(int i = 0; i < n; i++) cin >> wt[i] >> val[i];
    for(ll idx = 0; idx <= n; idx++){
        for(ll j = 0; j <= w; j++){
            if(j== 0 || idx == 0) dp[idx][j] = 0;
            else if(j>= wt[idx-1])dp[idx][j] = max(dp[idx-1][j], dp[idx-1][j-wt[idx-1]] + val[idx-1]);
            else{
                dp[idx][j] = dp[idx-1][j];
            }
        }
    }
    cout << dp[n][w] <<"\n";
	return 0;
}

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

#define MAX 101
#define BLACK 0
#define GRAY 1
#define WHITE 2
#define INF (1<<30)

int graph[MAX][MAX];
int n;

// プロトタイプ宣言
int prim();
// ここまで

int main(){
	cin>>n;

	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>graph[i][j];
		}
	}
	cout<<prim()<<endl;


	return 0;
}




//---------------------- 
int prim(){
	int from;
	int color[MAX];
	int d[MAX];
	int p[MAX];

	for(int i=0;i<MAX;i++){
		color[i]=WHITE;
		d[i]=INF;		
		p[i]=-1;
	}
	d[0]=0;

	while(1){
		int minCost=INF;
		from=-1;

		for(int i=0;i<n;i++){
			if(color[i]!=BLACK && d[i]<minCost){
				minCost=d[i];
				from=i;
			}
		}
		if(from == -1) break;

		color[from]=BLACK;
		for(int to=0;to<n;to++){
			if(color[to]!=BLACK && graph[from][to]!=-1){
				if(graph[from][to]<d[to]){
					d[to]=graph[from][to];
					p[to]=from;
					color[to]=GRAY;
				}
			}
		}
	}

	int sum=0;
	for(int i=0;i<n;i++){
		// if(p[i]!=-1){
		// 	sum += graph[i][ p[i] ];
		// }
		if(d[i]!=INF){
			sum+=d[i];
		}
	}

	return sum;
}



Measured memory_bytes: 3120
def main():
    a = int(input())
    b = int(input())
    c = int(input())
    x = int(input())
    ans = 0

    for i in range(a+1):
        for j in range(b+1):
            for k in range(c+1):
                # print(x, i*500+j*100+k*50)
                if i*500+j*100+k*50 == x:
                    ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39920
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <functional>
#define bogo_sort std::sort
#define bozo_sort std::stable_sort
#define alles(obj) obj.begin(), obj.end()
#define elif else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo std::cout <<
#define read std::cin >>
#define endl std::endl
#define fin << '\n'
#define bash push_back
#define makePair std::make_pair
#define _ << ' ' <<
// type-define
#define Stack std::stack
#define Queue std::queue
#define Set std::set
#define PQueue std::priority_queue
#define Vector std::vector
#define Pair std::pair
#define Map std::map
#define Greater std::greater
using String = std::string;
using llong = long long;
using boolean = bool;
using Pii = Pair<int, int>;
using Vi = Vector<int>;
using Vii = Vector<Pii>;
// utils
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    llong power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    llong power ( llong x, llong n ) { return power( x, n, 1000000007 ); }
    llong gcd ( llong x, llong y ) { return x % y ? gcd( y, x % y ) : y; }
    llong lcm ( llong x, llong y ) { return ( x / gcd(x, y) * y ); }
    llong abs ( llong n ) { return ( n < 0 ) ? -n : n; }
    boolean chmax ( llong &a, llong b ) { return a<b ? a=b, true : false; }
    boolean chmin ( llong &a, llong b ) { return b<a ? a=b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) { 
        return ( x >= 0 && y >= 0 && x < w && y < h ); }
}

namespace Rlyeh {

    int n;
    double p[3200];
    double dp[3200][3200];

    signed call_of_Cthulhu( signed datum ) {

        read n;
        for ( int i = 1; i <= n; i++ ) {
            read p[i];
        }
        dp[0][0] = 1.0f;
        for ( int i = 1; i <= n; i++ ) {
            for ( int j = 0; j <= n; j++ ) {
                if ( j ) dp[i][j] += dp[i-1][j-1] * p[i];
                dp[i][j] += dp[i-1][j] * (1.0f - p[i]);
            }
        }
        double ans = 0;
        for ( int i = n/2 + 1; i <= n; i++ ) {
            ans += dp[n][i];
        }

        printf("%.9lf\n", ans);

        return 0;
    }
}

signed main(){/*std::cin.tie(0); std::ios::sync_with_stdio(false);*/ int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}



Measured memory_bytes: 76032
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <unordered_set>
#define fs first
#define sc second
using namespace std;
const int maxn = 1e5+10;
using pii = pair<int,int>;
typedef long long ll;
int F[maxn];
vector<int> B[maxn];
int N,M,K;
int fa[maxn],cnt[maxn],ans[maxn];
void init(){
    for(int i = 1;i<=N;i++) fa[i] = i;
}
int find(int x){
    if(x != fa[x])
        fa[x] = find(fa[x]);
    return fa[x];
}
void join(int x,int y){
    int fx = find(x),fy = find(y);
    if(fx != fy){
        fa[fx] = fy;
    }
}
int main(){
    cin>>N>>M>>K;
    init();
    while(M--){
        int a,b;
        scanf("%d %d",&a,&b);
        F[a]++,F[b]++;
        join(a,b);
    }
    for(int i = 1;i<=N;i++) find(i);
    for(int i = 1;i<=N;i++) ++cnt[fa[i]];
    while(K--){
        int a,b;
        scanf("%d %d",&a,&b);
        B[a].push_back(b);
        B[b].push_back(a);
    }
    for(int i = 1;i<=N;i++){
        int total = cnt[fa[i]] - 1;
        total -= F[i];
        for(auto b:B[i]){
            if(find(i) == find(b))
                total -= 1;
        }
        printf("%d ",total);
    }

    return 0;
}

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

#define F                      first
#define S                      second
#define pb                      push_back
#define endl                    '\n'
#define all(x)                  x.begin(),x.end()
#define pii                     pair<int,int>
#define pll                     pair< long long int, long long int> 
#define fast                    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define SZ(x)                   ((int)x.size())

#define FOR(i,a,b)              for(int i = a; i < b; ++i)
#define REV(i,a,b)              for(int i = a; i >= b; --i)
#define FORE(i,a,b)             for(int i = a; i <= b; ++i)

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve();

int main()
{
        fast;
        solve();
}


void solve() {
        int h,w;
        cin >> h >> w;
        const long MOD = 1e9 + 7;
        long dp[h+1][w+1];
        char arr[h][w];
        FOR(i,0,h) FOR(j,0,w) {
                cin >> arr[i][j];
        }
        memset(dp,0,sizeof(dp));
        dp[0][1] = 1;
        FOR(i,1,h+1) {
                FOR(j,1,w+1) {
                        if(arr[i-1][j-1] == '#') {
                                dp[i][j] = 0;
                                continue;
                        }
                        dp[i][j] = 0;
                        dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD;
                }
        }
        cout << dp[h][w] << endl;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

// Description: グラフの型定義
// Verifyed: Many Diffrent Problem

//Appropriately Changed
using edge = struct {int to;};
using G = vector<vector<edge>>;

//Appropriately Changed
void add_edge(G &graph, int from, int to) {
	graph[from].push_back({to});
	graph[to].push_back({from});
}

const int vmax = 100010;
int sub[vmax],par[vmax],depth[vmax];

int dfs(const G &graph,int v,int p,int d){
	sub[v]=1,par[v]=p,depth[v]=d;

	for(auto &e:graph[v]){
		if(e.to==p) continue;
		sub[v]+=dfs(graph,e.to,v,d+1);
	}

	return sub[v];
}

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

	G graph(n);
	rep(i,n-1){
		int a,b;
		cin >> a >> b;
		add_edge(graph,a-1,b-1);
	}


	dfs(graph,0,-1,0);

	int cur = n-1;
	const int total = (depth[n-1]-1)/2;
	rep(loop,total) cur = par[cur];

	const int white = sub[cur];
	const int black = n - white; 

	if(black>white)
		puts("Fennec");
	else
		puts("Snuke");


	return 0;
}

Measured memory_bytes: 14720
import heapq as hp

n,m = map(int,input().split())
list = [[int(i) for i in input().split()] for i in range(n)]
temp = [0]
ans = 0
a = 0
j = 0
list = sorted(list)

for i in range(1,1+m):
  for j in range(a,len(list)):
    if list[j][0] == i:
      hp.heappush(temp,-list[j][1])
    else:
      a = j
      break
  if len(temp) > 0:
    ans -= hp.heappop(temp)
print(ans)

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

int main(){
  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
    string s;
  	cin >> s;
    if(s == "Y"){
      cout << "Four" << endl;
      break;
    }else if(i == (N - 1)){
      cout << "Three" << endl;
    }
  }
}

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

#define ll long long

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

    int i,j = 0;
    string s,t;
    cin >> s >> t;
    for(i=0; i<s.length(); ++i){
        if(s[i]!=t[i])
            ++j;
    }
    cout << j;

    return 0;
}


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

typedef long long LL;
typedef long double LD;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;
typedef pair < LD, LD > PDD;

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
template < typename _T > inline void _DBG(const char *s, _T x) { cerr << s << " = " << x << "\n"; }
template < typename _T, typename... args > void _DBG(const char *s, _T x, args... a) { while(*s != ',') cerr << *s++; cerr << " = " << x << ','; _DBG(s + 1, a...); }

#ifdef LOCAL
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0) cout
#endif

// ********************** CODE ********************** //

const int N = 17;

int n;
LL T[N];

int main()
{
    _upgrade
    cin >> n;
    LL ans = 1, ans2 = 1;
    for(int i = 0; i < n; i++)
    {
        cin >> T[i];
        ans *= 3;
        if(T[i] & 1) ans2 *= 1;
        else ans2 *= 2;
    }
    cout << ans - ans2 << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
const double PI = 3.14159265359;
int main()
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    double rad = PI * c / 180;
    double s = a * b * sin(rad) / 2;
    double d = sqrt(a * a + b * b - 2 * a * b * cos(rad));
    double l = a + b + d;
    double h = b * sin(rad);
    printf("%.8lf\n %.8lf\n %.8lf\n", s, l, h);
    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
typedef pair<int, int> P;

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

  vector<int> gtime(N);
  vector<P> gxy(N);
  rep(i,N){
    cin >> gtime.at(i);
    cin >> gxy.at(i).first >> gxy.at(i).second;
  }

  int gtpry, ggpry;//ゴール時間のパリティとゴール座標のパリティ；
  int sx = 0, sy = 0;
  int stime = 0;
  int gx, gy;

  bool flag = true;
  int dist;

  rep(i, N){
    gx = gxy.at(i).first; gy = gxy.at(i).second;

    dist = abs(gx-sx)+abs(gy-sy);
    gtpry = (gtime.at(i) - stime)%2;
    ggpry = dist%2;

    if((ggpry != gtpry) || dist > (gtime.at(i) - stime)){
      flag = false;
      break;
    }

    stime = gtime.at(i);
    sx = gx; sy = gy;
  }

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 4552
import sys
from heapq import heappush, heappop
#input = sys.stdin.readline

def main():
    n=int(input())
    a=list(map(int,input().split()))
    s=0
    ans=[0]*n
    flg=1
    for i in range(n):
        s+=flg*a[i]
        flg*=-1
    flg=1
    for i in range(n):
        ans[i]=abs(s)
        s=s-2*a[i]*flg
        flg*=-1
    print(' '.join(map(str,ans)))
  
if __name__ == '__main__':
    main()

Measured memory_bytes: 19272
import sys

#f = open("input.txt", 'r')
f = sys.stdin
n = ''


n = f.readline().replace('\n','')
S = set(map(int, f.readline().replace('\n','').split()))
q = f.readline().replace('\n','')
T = set(map(int, f.readline().replace('\n','').split()))

print(len(S & T))




Measured memory_bytes: 16604
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=1<<29,MOD=1e9+7;

int main(){
	int n;
	char a[5000];
	rep(i,26) a[i]='a'+i;
	rep(i,26) a[i+26]='A'+i;
	rep(i,26) a[i+52]='a'+i;
	rep(i,26) a[i+78]='A'+i;
	while(cin>>n&&n){
		int k[n];
		rep(i,n) cin>>k[i];
		string s; cin>>s;
		for(int i=0;i<s.size();i++){
			int j=i%n;
			int x=s[i]-'A';
			if(x>26){
				int y=s[i]-'a';
				s[i]=a[y+52-k[j]];
			}else{
				s[i]=a[x+78-k[j]];
			}
		}
		cout<<s<<endl;
	}
	return 0;
}


Measured memory_bytes: 3180
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define PUT(x) cout << x << endl
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };

int a[100000] = {};
int b[100000] = {};

int main(void)
{

	ll n, h;
	cin >> n >> h;

	for (ll i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}

	//最大のA
	ll max_a = *max_element(a,a+n);

	sort(b,b+n);

	reverse(b,b+n);

	ll total_b = 0,answer = 0;

	for (ll i = 0; i < n; i++) {
		if (total_b >= h) {
			break;
		}
		if (max_a < b[i]) {
			total_b+=b[i];
			answer++;
		}
		else {
			break;
		}
	}

	cerr << total_b << endl;
	if (total_b < h) {
		h -= total_b;
		answer += (h + max_a - 1) / max_a;
	}

	cout << answer << endl;


	return 0;
}



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

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

    int a, odd = 0, even = 0;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a % 2 == 0) {
            even++;
        } else {
            odd++;
        }
    }
    if ((odd % 2 + ((odd / 2 + even > 0) ? 1 : 0)) == 1) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int n = sc.nextInt();
        int[] num = new int[w];
        for(int i = 0; i < w; i++){
            num[i] = i+1;
        }
        for(int i = 0; i < n; i++){
            String str = sc.next();
            String[] ab = str.split(",");
            int a = Integer.parseInt(ab[0]) - 1;
            int b = Integer.parseInt(ab[1]) - 1;
            int tmp = num[a];
            num[a] = num[b];
            num[b] = tmp;
        }
        for(int i = 0; i < w; i++){
            System.out.println(num[i]);
        }
    }
}


Measured memory_bytes: 26188
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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




int main() {

	ll x, y;
	cin >> x >> y;

	ll ans = 0;

	if (x == 1) { ans += 300000; }
	if (x == 2) { ans+=200000; }
	if (x == 3) { ans += 100000; }

	if (y == 1) { ans += 300000; }
	if (y == 2) { ans += 200000; }
	if (y == 3) { ans += 100000; }

	if (x == 1 && y == 1) { ans += 400000; }

	cout << ans;
	
	system("PAUSE");
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gc2d(ll a,ll b) { return b?gc2d(b,a%b):a;}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k;cin >> k;
    long long sum = 0;
    for (int i = 1;i <=k;++i){
        for (int j = 1;j <= k;++j){
            for (int jj = 1;jj <=k;++jj){
                sum += gc2d(gc2d(i,j),jj);
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3612
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);

void main()
{
    // 1*2*3*4*5*6 == 2^^4 * 3^^2 * 5

    // 1*
    // 2*
    // 3*
    // 2*2*
    // 5*
    // 2*3
    auto n = lread();
    long[long] aa;
    foreach (i; 1 .. n + 1)
    {
        long[long] tmp = factorize(i);
        // writeln(tmp);
        foreach (key, value; tmp)
        {
            aa[key] = aa.get(key, 0) + value;
        }
    }
    // writeln(aa);
    long ans = 1;
    foreach (key, value; aa)
    {
        ans = ans % (10 ^^ 9 + 7) * (value + 1) % (10 ^^ 9 + 7);
    }
    writeln(ans);
}

long[long] factorize(long n)
{
    long tmp = n;
    long[long] aa;
    foreach (x; 2 .. n * n + 100)
    {
        if (tmp < x)
        {
            if (tmp != 1)
                aa[tmp] = aa.get(tmp, 0) + 1;
            return aa;
        }
        while (tmp % x == 0)
        {
            aa[x] = aa.get(x, 0) + 1;
            tmp /= x;
        }
    }
    writeln(tmp);
    assert(0);
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
const ll  big =2e5+5;
pair <int,int> p[1005];
ll a[1005],b[1005];

int main()
{ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
ll a,b,c,d;
cin>>a>>b>>c>>d;
ll k=0;
bool p=true;
while(p){
if(k%2==0){
    c-=b;
    k++;
    if(c<=0){cout<<"Yes";return 0;}
}
else{
     a-=d;
    k++;
    if(a<=0){cout<<"No";return 0;}
}}

    return 0;
}

Measured memory_bytes: 3584
sx,sy,tx,ty = gets.chomp.split.map(&:to_i)
width = tx - sx
height = ty - sy
result = "U" * height + "R" * width + "D"*height + "L"*width + "L" + "U" * (height + 1) + "R" * (width + 1) + "D" + "R" + "D" * (height + 1) + "L" * (width + 1) + "U"
puts result

Measured memory_bytes: 3836
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define FOR(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

#include <numeric>

int main(){
	ll N;
	cin >> N;
	vint A(N,999999999), B(N-1);
	FOR(i, N - 1) {
		cin >> B[i];
	}
	FOR(i, N-1) {
		A[i] = min(A[i],B[i]);
		A[i + 1] = min(A[i + 1], B[i]);
	}

	int sum = accumulate(A.begin(), A.end(),0	);
	cout << sum << endl;	
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
int main(){
	int N;
	int a[2][101];
	cin >> N;
	fill(a[0], a[2], 0);
	for(int i = 0; i < 2; i++){
		for(int j = 1; j <= N; j++){
			cin >> a[i][j];
		}
	}
	for(int i = 2; i <= N; i++){
		a[0][i] += a[0][i - 1];
		a[1][i] += a[1][i - 1];
	}
	int ans = 0;
	for(int i = 1; i <= N; i++){
		int sum = a[0][i] + (a[1][N] - a[1][i - 1]);
		if(sum > ans) ans = sum;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int i,j,mem,n,x,count;
	
	scanf("%d %d",&n,&x);
	
	int ai[n];
	
	for(i=0;i<n;i++){
		scanf("%d",&ai[i]);
	}
	
	for(i=0;i<n;i++){
		for(j=i;j<n;j++){
			if(ai[i] >ai[j]){
				mem = ai[i];
				ai[i] = ai[j];
				ai[j] = mem;
			}
		}
	}
	
	count=0;
	
	for(i=0;(x>0)&&(i<n);i++){
		x=x-ai[i];
		count++;
	}
	
	if(x!=0)	count--;
	
	printf("%d",count);
	return 0;
}

Measured memory_bytes: 128
s=int(input())
fa=0
fb=0
if s//100>12 or s//100==0:fa+=1
if s%100>12 or s%100==0:fb+=1
if fa==1 and fb==1:print('NA')
elif fa==1 and fb==0:print('YYMM')
elif fa==0 and fb==1:print('MMYY')
else:print('AMBIGUOUS')

Measured memory_bytes: 3060
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

string S;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> S;
  map<char, bool> mp;

  for (int i = 0; i < (int)S.length(); i++) {
    if (mp.count(S[i]) > 0) {
      cout << "no" << endl;
      return 0;
    }
    mp[S[i]] = true;
  }
  cout << "yes" << endl;

  return 0;
}


Measured memory_bytes: 888
/* monkukui 競技プログラミング用のテンプレート  (ここから) */
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using Graph = vector<vector<int>>;
using Wgraph = vector<vector<pair<int, long long int>>>;
constexpr long long int INF = 1001001001001001LL;
constexpr long long int MOD = 1000000007LL;
constexpr double PI = 3.1415926535897932;
constexpr long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
constexpr long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

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;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = 1; i <= (n); i++)
#define DREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define SREP(i,s,t) for(int i = s; i < t; i++)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define PB push_back

/* monkukui 競技プログラミング用のテンプレート (ここまで)*/

int main(){
  
  int n; cin >> n;
  vector<vector<pair<int, int>>> info(n);
  for(int i = 0; i < n; i++) {
    int a; cin >> a;
    for(int j = 0; j < a; j++) {
      int x, y; cin >> x >> y;
      x--;
      info[i].push_back({x, y});
    }
  }

  int ans = 0;
  for(int bit = 0; bit < (1 << n); bit++) {
    bool ok = true;
    // 正直者の証言だけを聞いて，矛盾がないか確認
    for(int i = 0; i < n; i++) {
      if(!(bit >> i & 1)) continue;
      for(int j = 0; j < info[i].size(); j++) {
        int x = info[i][j].first;
        int y = info[i][j].second;
        
        if(y == 1) {
          // x は正直者
          if(!(bit >> x & 1)) ok = false;
        } else {
          // x は不審者
          if(bit >> x & 1) ok = false;
        }
      }
    }
    
    if(ok) {
      int tmp = 0;
      for(int i = 0; i < n; i++) {
        if(bit >> i & 1) tmp++;
      }
      ans = max(ans, tmp);
    }
  }

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


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

using namespace std;

const int MOD = 1000000007;

int main() {
    int N;
    cin>>N;
    string S;
    cin>>S;
    int a[S.size()];
    for (int i = 0; i < S.size(); i++) {
        a[i]=S[i]-'A';
        a[i]+=N;
        a[i]%=26;

    }
    string ans="";
    for(int i=0;i<S.size();i++){
        ans+=(char)(a[i]+'A');
    }
    cout<<ans<<endl;



}





Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n,m; cin>>n>>m;
	map<int,int> mp;
	rep(i,0,n){
		int k; cin>>k;
		rep(j,0,k){
			int a; cin>>a;
			mp[a]++;
		}
	}
	int ans=0;
	rep(i,1,m+1){
		if(mp[i]==n)ans++;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3628
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);


	int n;
	cin >> n;
	vector<int> d(n);
	for(int i = 0; i < n; ++i) {
		cin >> d[i];
	}
	sort(d.begin(), d.end());
	int ans = d[n / 2] - d[n / 2 - 1];
	cout << ans << endl;
}

Measured memory_bytes: 3728
#include<iostream>
#include<stdio.h>
#include<vector>
#include<ctype.h>
#include<string>
#include<cmath>
#include<string.h>
#include<sstream>
#include<limits.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;

//最大公約数
int gcd(int a,int b){
    return b ? gcd(b,a%b):a;
}

//最小公倍数
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}

//素数判定
bool isPrime(int x){
    if(x<2)return 0;
    else if(x==2)return 1;
    if(x%2==0)return 0;
    for(int i=3;i*i<=x;i+=2){
        if(x%i==0)return 0;
    }
    return 1;
}

//桁ごとの足し算
int digsum(int n){
    int res=0;
    while(n>0){
        res+=n%10;
        n/=10;
    }
    return res;
}

//約数列挙
vector<int> enum_div(int n){
    vector<int> ret;
    for(int i=1;i*i<=n;++i){
        if(n%i==0){
            ret.push_back(i);
            if(i*i !=n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

//累乗の計算とあまり,0で累乗そのまま出力
long long modpow(long long a,long long n,long long mod){
    if(mod==0)mod=__LONG_LONG_MAX__;
    long long res=1;
    while(n>0){
        if(n & 1)res=res*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res;
}

int N;
int ans=0;
int main(){
    cin>>N;
    vector<ll> L(N);
    for(int i=0;i<N;++i){
        cin>>L[i];
    }
    for(int i=0;i<N;++i){
        for(int j=i;j<N;++j){
            if(L[j]==L[i])continue;
            for(int k=j;k<N;++k){
                if(L[k]==L[i] || L[k]==L[j])continue;
                if(abs(L[i]-L[j]) < L[k] && L[k] < L[i]+L[j]){
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
typedef long long ll;
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define rf(i,a,b) for(ll i=a; i>=b; i--)
typedef std::vector<long long > vi ;
#define F first
#define S second
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define PB push_back
#define MP make_pair
#define PI 3.14159265358979323846
#define all(a) a.begin(),a.end()
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define endl '\n'
#define show(a) for(auto el:a)cout<<el<<" "
const ll INF=LLONG_MAX/2;
const ll N=2e5+1;
#define yesno(f) yes(f);no(f);
#define yes(f) if(f)cout<<"YES\n";
#define no(f) if(!f)cout<<"NO\n";
using  namespace std;
ll a[200005],k,n,sum=0;
ll check(ll x)
{
    ll ans=0,kk=k;
    if(x==0)
    {
    if(sum>kk)
    return 0;
    else
    return 1;
    
    }
    rf(i,n-1,0)
    {
        if(a[i]<x)
        break;
        if(kk<0)
        {
            ans=1;
            break;
        }
        if(a[i]%x==0)
        kk=kk-a[i]/x+1;
        else 
        {
            kk=kk-a[i]/x;
        }

    }
    if(ans==1||kk<0)
    return 0;
    else
    return 1;
}
int main()
{
    fast;
   ll t;
    t=1;
   while(t--)
   {
       ll i,j=0,d;
       std::cin >> n>>k;
       fr(i,0,n)
       {
           std::cin >> a[i];
           sum=sum+2*a[i];
       }
       sort(a,a+n);
       ll r=*max_element(a,a+n),l=1,ans1=1000000007;
       while(l<=r)
       {
           ll mid=(l+r)/2;
           if(check(mid))
           {
               ans1=min(ans1,mid);
               r=mid-1;
           }
           else
           l=mid+1;
       }
       cout<<ans1<<"\n";
   }
}

Measured memory_bytes: 5208
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline bool read(ll &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
char c[1010],s[1010],a[1010];
int main(){
int a,b;
char op;
scanf("%d %c %d",&a,&op,&b);
if (op=='+') write(a+b);
else write(a-b);
}

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

int main() {
	int N;
	long long p;
	long long aa;
 	double a0;
 	int a2;
 	int a5;
	vector<vector<int>> x(25, vector<int>(25));
	p=0;

	cin >> N;

   	rep(i,N) {
		cin >> a0;
		aa=a0*1e9+0.5;
   		rep(j,19) {
	        a2=j;
			if (aa%2>0) break;
			aa/=2;
		}
   		rep(j,19) {
	        a5=j;
			if (aa%5>0) break;
			aa/=5;
		}
	   	rep2(i1,18-a2,20) {
		   	rep2(j1,18-a5,20) p+=x.at(i1).at(j1);
		}
		x.at(a2).at(a5)++;
	}

	cout << p << endl;
	return 0;
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N,M;
    Scd2(N,M);

    int a,b;
    vii A;
    Rep(i,N){
        Scd2(a,b);
        A.push_back(pii(a,-b));
    }

    sort( A.begin(), A.end() );

    priority_queue<int> p;

    int ans = 0;

    int i = 0;
    Repe(j,M+1,1){
        while( i < N && A[i].first == j ) p.push(-A[i++].second);
        if( p.empty() ) continue;
        ans += p.top();
        p.pop();
    }

    printf ("%d\n", ans );


    return 0;
}



Measured memory_bytes: 1908
using System;
class Program {
    static void Main (string[] args) {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        if (a > b) {
            Console.WriteLine(new String(input[1][0], a));
        } else {
            Console.WriteLine(new String(input[0][0], b));
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define ma 100000000
#define mod 1000000007
#define Nmax 1000000000000
using namespace std;

int main()
{
    IOS;
    string s,t;cin>>s>>t;
    int n=(int)s.size();
    int m=(int)t.size();
    int dp[n+1][m+1];
    memset(dp,0,sizeof dp);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i-1]==t[j-1]) dp[i][j]=max(max(dp[i-1][j],dp[i][j-1]),dp[i-1][j-1]+1);
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    string res="";
    int i=n,j=m;
    while(i && j){
        if(dp[i][j]==dp[i-1][j]) i--;
        else if(dp[i][j]==dp[i][j-1]) j--;
        else{res+=s[i-1];i--;j--;}
    }
    reverse(res.begin(),res.end());
    cout<<res;
    return 0;
}


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

int main() {
    long long N;
	cin >> N;
	long long a = N/500;
	long long b = (N-(500 * a))/5;
	long long ret = 1000 * a + 5 * b;
	cout << ret << endl;
    return 0;
}



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

int main()
{
	string card;
	int h,m;
	while(1){
		cin >> card;
		if(card == "-") break;
		cin >> m;
		for(int i = 0;i < m;i++){
			cin >> h;
			string left = card.substr(0,h);
			string right = card.substr(h,card.length() - h);
			card = right + left;
			}
			cout << card << endl;
			}
			return 0;
			}

Measured memory_bytes: 3188