akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <complex>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;

int length(const string& s,int begin,int end)
{
	ll res=0;
	for(int i=begin;i<end;i++){
		if(isdigit(s[i])){
			int r=0;
			while(isdigit(s[i]))
				r=r*10+s[i++]-'0';
			if(s[i]=='('){
				int j=i;
				for(int k=0;j<s.size();j++){
					if(s[j]=='(') k++;
					if(s[j]==')') k--;
					if(k==0) break;
				}
				res+=(ll)r*length(s,i+1,j);
				i=j;
			}
			else
				res+=r;
		}
		else
			res++;
		res=min<ll>(res,INFTY);
	}
	return res;
}

char solve(const string& s,int index,int ci)
{
	for(;ci<s.size();){
		if(isdigit(s[ci])){
			int r=0,i=ci;
			while(isdigit(s[i]))
				r=r*10+s[i++]-'0';
			if(s[i]=='('){
				int j=i;
				for(int k=0;j<s.size();j++){
					if(s[j]=='(') k++;
					if(s[j]==')') k--;
					if(k==0) break;
				}
				int len=length(s,i+1,j);
				if((ll)r*len>index)
					return solve(s,index%len,i+1);
				else{
					index-=r*len;
					ci=j+1;
				}
			}
			else{
				if(r>index)
					return s[i];
				else{
					index-=r;
					ci=i+1;
				}
			}
		}
		else{
			if(index==0)
				return s[ci];
			else{
				index--;
				ci++;
			}
		}
	}
	return '0';
}

int main()
{
	for(string s;cin>>s && s!="0";){
		int index; cin>>index;
		cout<<solve(s,index,0)<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <math.h>
//using namespace std;
//#define int long long
//#define REP(i,a,b,c) for(int i=a;i<=b;i+=c)
//const int N = 1e5+5;//maximum size of the array
const int maxE=1e9+7;//maximum element possible in our array

using namespace std;

int main(){ 
	long long n,k;cin>>n>>k;
	vector<long long> a(n);	
	vector<long long> dp(n,maxE);
	for(int i=0;i<n;i++)cin>>a[i];
	dp[0]=0;
	for(long long i=0;i<n;i++){
		for(long long j=i+1;j<=i+k;j++){
			if(j<n){
				dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]));
			}
		}
	}
	cout<<dp[n-1];
	return 0;
} 

Measured memory_bytes: 4788
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
    int N;
    cin >> N;

    vector<int> A(N - 1);
    vector<int> ansA(N);
    for (int i = 0; i < N - 1; i++) {
        cin >> A.at(i);
        ansA.at(A.at(i) - 1) += 1;

    }

    for (int i = 0; i < N; i++) {
        cout << ansA.at(i) << endl;
    }

    return 0;
}

Measured memory_bytes: 4468
import java.util.*;
import java.util.ArrayList;
import java.util.List;

public class Main{
  public static void main(String[] arg){
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    List<String> list = new ArrayList<>();
    for(int i = 0;i < H; i++){
      list.add(sc.next());
    }
    for(int j = 0; j < H; j++){
      String ans = list.get(j);
      System.out.println(ans);
      System.out.println(ans);
    }
  }
}


Measured memory_bytes: 23508
// https://atcoder.jp/contests/abc163/tasks/abc163_a

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

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

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

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

const ld PI = 3.141592653589793238462643383279;

void solve() {
  ll R;
  cin >> R;

  ld res = 2 * PI * R;
  cout << fixed << setprecision(20) << res << endl;
}


Measured memory_bytes: 3864
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N);
  for (int i = 0; i < N; i++)
    cin >> A[i];
  for (int i = 0; i < N; i++)
    cin >> B[i];
  for (int i = 0; i < N; i++)
    cin >> C[i];
  sort(A.begin(), A.end());
  sort(C.begin(), C.end());
  long ans = 0;
  for (int i = 0; i < N; i++)
  {
    long count1, count2;
    if (A[N - 1] < B[i])
      count1 = N;
    else if (B[i] < A[0])
      count1 = 0;
    else
      count1 = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
    if (B[i] < C[0])
      count2 = N;
    else if (C[N - 1] < B[i])
      count2 = 0;
    else
      count2 = C.end() - upper_bound(C.begin(), C.end(), B[i]);
    ans += count1 * count2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define INF ((1LL<<62)-(1LL<<31))
#define min(p,q)((p)<(q)?(p):(q))

//ワーシャルフロイド
//頂点数（と隣接行列）を引いて全点間最短距離を返す
//O(V^3)
//*
ll cost[110][110];
ll dddd[110][110];
void waasharuhuroido(ll n){
	rep(i,0,n)rep(j,0,n)dddd[i][j]=cost[i][j];//辺が無いところはINFにする前処理が必要
	rep(k,0,n)rep(i,0,n)rep(j,0,n)dddd[i][j]=min(dddd[i][j],dddd[i][k]+dddd[k][j]);
	rep(k,0,n)rep(i,0,n)rep(j,0,n){
		if(dddd[i][j]>dddd[i][k]+dddd[k][j]){
			puts("NEGATIVE CYCLE");
			exit(0);
		}
	}
}
//*/

int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	rep(i,0,n)rep(j,0,n)if(i!=j)cost[i][j]=INF;
	rep(_,0,m){
		int x,y;
		ll c;
		scanf("%d%d%lld",&x,&y,&c);
		cost[x][y]=c;
	}
	waasharuhuroido(n);
	rep(i,0,n){
		rep(j,0,n){
			if(dddd[i][j]>2e9)printf("INF%c",j==n-1?10:32);
			else printf("%lld%c",dddd[i][j],j==n-1?10:32);
		}
	}
}


Measured memory_bytes: 2112
// Crt. 2019-12-08  12:05:35
// Stt. 2019-12-08  15:06:05
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#define N 200005
using namespace std;
const int INF = 0x3f3f3f3f;

int n, K, w[N], dep[N], L[N], R[N];
int tot, fir[N], nxt[N << 1], to[N << 1];

inline void addE(int u, int v) {
    nxt[++tot] = fir[u], fir[u] = tot, to[tot] = v;
}

void check(int u, int p, int d) {
    dep[u] = d;
    if (w[u] != INF && (w[u] % 2 + 2) % 2 != d)
        puts("No"), exit(0);
    for (int i = fir[u]; i; i = nxt[i])
        if (to[i] != p) check(to[i], u, d ^ 1);
}

void merge(int &l, int &r, int ll, int rr) {
    l = max(l, ll), r = min(r, rr);
    if (l > r) puts("No"), exit(0);
}

void dfs(int u, int p) {
    if (w[u] != INF) return L[u] = R[u] = w[u], void();
    L[u] = -INF, R[u] = INF;
    for (int i = fir[u], v; i; i = nxt[i]) {
        v = to[i];
        if (v == p) continue;
        dfs(v, u);
        merge(L[u], R[u], L[v] - 1, R[v] + 1);
    }
}

void dfs2(int u, int p) {
    if (p) {
        if (L[u] <= w[p] - 1 && w[p] - 1 <= R[u]) w[u] = w[p] - 1;
        if (L[u] <= w[p] + 1 && w[p] + 1 <= R[u]) w[u] = w[p] + 1;
        if (w[u] == INF) puts("No"), exit(0);
    }
    for (int i = fir[u]; i; i = nxt[i])
        if (to[i] != p && w[to[i]] == INF) dfs2(to[i], u);
}

inline int Abs(int x) { return x < 0 ? -x : x; }

void getok(int u, int p) {
    if (p && Abs(w[p] - w[u]) != 1) puts("No"), exit(0);
    for (int i = fir[u]; i; i = nxt[i])
        if (to[i] != p) getok(to[i], u);
}

int main() {
#ifdef LOCAL_JUDGE
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif

    cin >> n;
    for (int i = 1, v, u; i < n; ++i)
        scanf("%d%d", &u, &v), addE(u, v), addE(v, u);

    memset(w, 0x3f, sizeof w);

    cin >> K;

    int tmp = 1;
    for (int i = 1, u, x; i <= K; ++i)
        scanf("%d%d", &u, &x), w[u] = x, tmp = u;

    check(tmp, 0, w[tmp] & 1);

    for (int i = 1; i <= n; ++i) {
        if (w[i] ^ INF) continue;
        dfs(i, 0);
        w[i] = ((L[i] % 2 + 2) % 2 == dep[i]) ? L[i] : L[i] + 1;
        if (w[i] > R[i]) return puts("No"), 0;
        dfs2(i, 0);
    }

    getok(1, 0);

    puts("Yes");
    for (int i = 1; i <= n; ++i)
        printf("%d\n", w[i]);

    return 0;
}


Measured memory_bytes: 11776
#include<bits/stdc++.h>
using namespace std;
const int MOD=1e9+7,inv2=5e8+4,SHIFT=2333;
inline int poww(long long x,int y)
{
	long long ret=1;
	while(y)
	{
		if(y&1)ret*=x,ret%=MOD;
		x*=x,x%=MOD;
		y>>=1;
	}
	return ret;
}
int n;
long long dp[5555][5555];
long long fac[11111],invfac[11111];
int x[233333],y[233333];
inline int c(int a,int b)
{
	return fac[a]*invfac[b]%MOD*invfac[a-b]%MOD;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>x[i]>>y[i];
	fac[0]=1;
	for(int i=1;i<=8000;i++)fac[i]=fac[i-1]*i%MOD;
	invfac[8000]=poww(fac[8000],MOD-2);
	for(int i=8000;i>=1;i--)invfac[i-1]=invfac[i]*i%MOD;
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		dp[-x[i]+SHIFT][-y[i]+SHIFT]++;
	}
	for(int i=-2000+SHIFT;i<=2000+SHIFT;i++)
		for(int j=-2000+SHIFT;j<=2000+SHIFT;j++)
			dp[i][j]+=dp[i-1][j]+dp[i][j-1],dp[i][j]%=MOD;
	for(int i=1;i<=n;i++)
	{
		ans+=dp[x[i]+SHIFT][y[i]+SHIFT];
	}
	for(int i=1;i<=n;i++)ans=(ans-c(2*x[i]+2*y[i],2*x[i])+MOD)%MOD;
	ans%=MOD;
	cout<<ans*inv2%MOD<<endl;
	return 0;
}

Measured memory_bytes: 176000
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const int MOD = 1e9+7;
const int INF = 1<<30;
const ll LINF = 1LL<<60;

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

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

    cout << a * b << endl;


    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
  string s;
  cin >>s;
  ll ss=s.size();
  ll ans=0,ans1=0;
  for(ll i=0;i<ss;i++){
    if(i%2==0){
      if(s[i]=='0') ans++;
    }
    else{
      if(s[i]=='1') ans++;
    }
  }
  for(ll i=0;i<ss;i++){
    if(i%2==0){
      if(s[i]=='1') ans1++;
    }
    else{
      if(s[i]=='0') ans1++;
    }
  }
  cout <<min(ans,ans1)<<endl;
}


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

int main(){
  int A[3][3];
  int m = -1;
  for (int i=0; i<3; i++){
    for (int j=0; j<3; j++){
      cin >> A[i][j];
      m = min(m, A[i][j]);
    }
  }
  int cnt =0;
  for (int i=0; i<=A[0][0]; i++){
    int a1 = i;
    int b1 = A[0][0]-a1;
    int b2 = A[0][1]-a1;
    int b3 = A[0][2]-a1;
    int a2 = A[1][0]-b1;
    int a3 = A[2][0]-b1;
    if(a1+b2==A[0][1]&&a1+b3==A[0][2]&&a2+b1==A[1][0]&&a2+b2==A[1][1]&&a2+b3==A[1][2]&a3+b1==A[2][0]&&a3+b2==A[2][1]&&a3+b3==A[2][2]){
      cout << "Yes" << endl;
      cnt++;
      break;
    }
  }
  if(cnt==0){
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
"""
int #整数
float #小数

#標準入力
a=input()
a,b=map(int,input().split()) #入力は行ごと
#標準出力
print(a)
ptrint("Hello")
#for
for name in fruits: #fruitの頭から操作
    print(name)
#リスト
list0 = [] #リスト生成
list0 = [1,2,3,4] #初期化
list0 = [0]*10 #[0,0,0,0,0,0,0,0,0,0]
list1 = list(map(int, input().split()))　# 複数の入力をリストに入れる
list1 = list1 + [6, 7, 8] #リストの追加
list2.append(34) #リストの追加　最後に（）内が足される
list.insert(3,10) #リストの追加　任意の位置（追加したい位置,追加したい値）
len(list4) #リストの要素数
max(sa) #list saの最小値
list5.count(2) #リスト内の2の数
abs(a) #aの絶対値
max(a,b) min(a,b) #最大値　最小値

extension_1 = []
for i in range(10):
    extension_1.append(i)
extension_1
#>>> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

comprehension_1= [i for i in range(10)]
comprehension_1
#>>> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
"""
a,b,c = map(int,input().split())
if a==b and b==c:
    print("1")
elif a==b:
    print("2")
elif b==c:
    print("2")
elif a==c:
    print("2")
else:
    print("3")

    

     

Measured memory_bytes: 2940
cards=[[False for i in range(13)] for j in range(4)]

n=int(input())

for i1 in range(n):
    a,b=input().split(" ")
    b=int(b)
    if a=="S":
        cards[0][b-1]=True
    elif a=="H":
        cards[1][b-1]=True
    elif a=="C":
        cards[2][b-1]=True
    elif a=="D":
        cards[3][b-1]=True

for i in range(4):
    for j in range(13):
        if cards[i][j]==False:
            if i==0:
                print("S",j+1)
            elif i==1:
                print("H",j+1)
            elif i==2:
                print("C",j+1)
            elif i==3:
                print("D",j+1)



Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define BIT(n) (1LL<<(n))
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPI(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
int main(void){
    int N;
    cin >> N;
    bool isSame = true;
    int a[N];
    int b[N];
    REP(i,N){
        cin >> a[i] >> b[i];
        if (a[i] != b[i]){
            isSame  =false;
        }
        
    }
    
    if (isSame){
        cout << 0 << endl;
        return 0;
    }
    
    
    ll sum =0;
    int m =INT_MAX;
    REP(i,N){
        if(a[i]<=b[i]){
        }
        else
        {
            m = min(m,b[i]);
        }
        
        sum += b[i];
    }
    
    cout << sum - m<< endl;
    
}
    
    


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, l, r) for (register int i = l; i <= r; i++)
#define per(i, r, l) for (register int i = r; i >= l; i--)
#define srep(i, l, r) for (register int i = l; i < r; i++)
#define sper(i, r, l) for (register int i = r; i > l; i--)
#define maxn 120
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back
using namespace std;

int n;
map<int, vector<pii>> info;
int lis[maxn], cs = 0;

int dist(pii a, pii b){
	return abs(a.fi - b.fi) + abs(a.se - b.se);
}

int main(){
	int x, y, z;
	scanf("%d", &n);
	rep(i, 1, n) {
		scanf("%d%d%d", &x, &y, &z);
		lis[++cs] = z;
		info[z].pb(pii(x, y));
	}
	sort(lis + 1, lis + 1 + cs);
	cs = unique(lis + 1, lis + 1 + cs) - lis - 1;
	pii C; int H;
	rep(i, 0, 100) {
		rep(j, 0, 100) {
			pii now = pii(i, j);
			int nowh = -1;
			per(k, cs, 1){
				if (lis[k]) {
					int d = -1;
					for (auto it = info[lis[k]].begin(); it != info[lis[k]].end(); it++){
						if (d == -1) d = dist(*it, now);
						else if (d != dist(*it, now)) goto fail; 
					}
					if (nowh == -1) nowh = lis[k] + d;  
					else if (nowh != lis[k] + d) goto fail;
				}
				else {
					for (auto it = info[lis[k]].begin(); it != info[lis[k]].end(); it++){
						if (nowh > dist(*it, now)) goto fail; 
					}
				} 
			}
			if (nowh < 1) goto fail;
			C = now; H = nowh; goto done;
			fail:;
		}
	}
	done:; 
	printf("%d %d %d", C.fi, C.se, H);
	return 0;
}

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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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



int main(void)
{
  ll n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  REP(i, n) {
    bool ok = true;
    REP(j, n - i) {
      if(s[i + j] != t[j]) ok = false;
    }
    if(ok) {
      cout << n + i << endl;
      return 0;
    }
  }
  cout << n * 2 << endl;
      

}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> broken(n);
  rep(i,m) {
    int a;
    cin >> a;
    broken[a] = 1;
  }
  vector<int> dp(n+2);
  dp[n] = 1;
  const int mod = 1000000007;
  for(int i = n-1; 0 <= i; i--) {
    if (broken[i]) {
      dp[i] = 0;
      continue;
    }
    dp[i] = (dp[i+1] + dp[i+2])%mod;
  }
  cout << dp[0] << endl;
  return 0;
}

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

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

  int K, S;
  cin >> K >> S;

  int ans = 0;
  for (int x = 0; x <= K; ++x) {
    for (int y = 0; y <= K; ++y) {
      int z = S - x - y;
      if (0 <= z && z <=K) ans++;
    }
  }

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


Measured memory_bytes: 256
N, M = map(int, input().split())
X = list(map(int, input().split()))

if N>=M:
    ans = 0
else:
    X.sort()
    Y = []
    for i in range(M-1):
        Y.append(X[i+1] - X[i])
    Y.sort()
    ans = sum(Y[:M-N])

print(ans)

Measured memory_bytes: 13968
#include <cstdio>
#define LL long long
LL sum;
int gcd(int a,int b){
	return b?gcd(b,a%b):a;
}
int main(){
	int n,a,b,c,d;
	scanf("%d",&n);
	for(a=1;a<=n;a++)
		for(b=1;b<=n;b++)
			for(c=1;c<=n;c++)
				d=gcd(a,b),d=gcd(c,d),sum+=d;
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 1672
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[] nk = new int[2];
    for (int i = 0; i < nk.length; i++){
      nk[i] = sc.nextInt();
    }
    sc.nextLine();
    int[] pn = new int[nk[0]];
	for (int i = 0; i < nk[0]; i++){
      pn[i] = sc.nextInt();
    }
    Arrays.sort(pn);
    int answer = 0;
    for (int i = 0; i < nk[1]; i++){
      answer += pn[i];
    }
    System.out.println(answer);
  }
}


Measured memory_bytes: 38968
import sys

def judge(As):
    print('?', *[A+1 for A in As])
    res = input()
    if res == '-1':
        sys.exit()
    return res[0]

N = int(input())

N2 = 2*N

L, R = 0, N
fL = judge(range(L, L+N))
fR = 'B' if fL == 'R' else 'R'
while R-L > 1:
    mid = (L+R) // 2
    fM = judge(range(mid, mid+N))
    if fM == fL:
        L = mid
    else:
        R = mid

anss = [''] * N2
anss[L] = fL
anss[L+N] = fR

T1s = set(range(L+1, L+N))
T2s = set(range(L+N+1, N2)) | set(range(L))

for i in range(N2):
    if i == L or i == L+N: continue
    if i in T1s:
        anss[i] = judge(T2s | {i})
    else:
        anss[i] = judge(T1s | {i})

print('!', ''.join(anss))


Measured memory_bytes: 3532
N,x = map(int,input().split())
a = sorted(list(map(int,input().split())))

ans = 0
for i in range(N):
    if x >= a[i]:
        ans += 1
        x -= a[i]
    else:
        break
else:
    if x > 0:
        ans -= 1

print(ans)


Measured memory_bytes: 3060
K,X = map(int,input().split())
x = X-K+1
y=  K+X

if 1000000>=y:
   if x>=-1000000:
        for i in range(x,y,1):
            print(i, end=" ")
   else:
        for i in range(-1000000,y,1):
            print (i, end=" ")
else:
     if x>=-1000000:
        for i in range(x,1000000,1):
            print(i, end=" ")
     else:
        for i in range(-1000000,1000000,1):
            print (i, end=" ")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int n, m;
    cin >> n >> m;
    int t = 100*(n-m) + 1900*m;
    int num = 1;
    rep(i,m) num *= 2;
    int ans = t * num;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>  // ver2.2.7
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define COUNT(a,i) upper_bound(ALL(a),i)-lower_bound(ALL(a),i)
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define itos to_string
#define stoi stoll
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define cyes cout<<"yes"<<endl
#define cno cout<<"no"<<endl
#define _ <<' '<<
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){if(!a[lY].empty()){Vout(a[lY]);}else cout<<endl;}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define Verr(a) rep(iZ,0,a.size()-1)cerr<<a[iZ]<<' ';cerr<<a.back()<<endl
#define VVerr(a) rep(iY,0,a.size()){if(!a[iY].empty()){Verr(a[iY]);}else cerr<<'.'<<endl;}
#define VPerr(a) rep(iX,0,a.size())cerr<<a[iX].FI<<' '<<a[iX].SE<<endl
#define INF 3000000000000000000  //  3.0*10^18(MAXの1/3くらい)
#define MAX LLONG_MAX
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void press(auto &v){v.erase(unique(ALL(v)),v.end());}  //  圧縮
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}


vector<int> divisor(int n){  //  約数列挙 O(√n)
 Vi r;for(int i=1;i*i<=n;i++){if(n%i==0){r.pb(i);if(i*i!=n)r.pb(n/i);}}sort(ALL(r));return r;}


signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  string s;
  cin >> s;
  int n = s.size();
  Vi a(0);
  int now=0;
  rep(i,0,n){
    if(s[i] == '<' && now >= 0) now++;
    else if(s[i] == '<' && now < 0){
      a.pb(now);
      now = 1;
    }
    else if(s[i] == '>' && now <= 0) now--;
    else if(s[i] == '>' && now > 0){
      a.pb(now);
      now = -1;
    }
  }
  a.pb(now);
  //Verr(a);
  
  now = 0;
  int ans = 0;
  rep(i,0,a.size()){
    if(a[i] >= 0) ans += a[i]*(a[i]+1)/2;
    else {
      if(i==0) ans += abs(a[i])*(abs(a[i])+1)/2;
      else if(a[i-1] < abs(a[i]) ){
        ans -= a[i-1];
        ans += abs(a[i])*(abs(a[i])+1)/2;
      }
      else{
        ans += abs(a[i]+1)*(abs(a[i]+1)+1)/2;
      }
    }
    cerr << ans << endl;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3352
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};
  
int main(){
  
  string s;
  cin>>s;
  int n=s.size();
  if(n==1){
    cout<<1<<endl;
    return 0;
  }
  int k=0;//答え
  string temp;//prev+now
  string pprev="";
  string prev="";
  string now="";
  int index=0;
  while(index<n){
    if(now==""){
      now += s[index];
      index++;
      if(now!=prev){
        //cout<<now<<endl;
        k++;
        pprev = prev;
        prev = now;
        now = "";
      }else{//nowとprevがともに1文字で一致している
        if(index<n){
          now += s[index];
          //cout<<now<<endl;
          pprev = prev;
          prev = now;
          now = "";
          index++;
          k++;
        }else{
          temp = prev+now;
          if(pprev==temp){
            //k++;
          }else{
            break;
          }
        }
      }
    }
  }
  cout<<k<<endl;
        
  return 0;
}

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

vector<bool> alphabet(string s){
    vector<bool> b(26, false);
    for(int i=0; i<s.size(); i++){
        if(!b.at(s.at(i)-'a')){
            b.at(s.at(i)-'a') = true;
        }
    }
    return b;
}

int common(string s, string t){
    int n=0;
    vector<bool> sb=alphabet(s), tb=alphabet(t);
    for(int i=0; i<26; i++){
        if(sb.at(i) and tb.at(i))
            n++;
    }
    return n;
}

int main(){
    int n; string s; cin>>n>>s;
    int ans=0;
    for(int i=1; i<n-1; i++){
        ans = max(ans, common(s.substr(0,i), s.substr(i,n-i)));
    }
    cout<<ans<<endl;
}


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

#define int long long

signed main() {
	int n, q;
	cin >> n >> q;
	vector<int> v[n+1];
	for(int it = 1; it < n; it++) {
		int a, b;
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	vector<int> val(n+1,0);
//	vector<int> ans(n+1,0);
	
	for(int k = 0; k < q; k++) {
		int p, x;
		cin >> p >> x;
		val[p] += x;
	}
	
	vector<bool> vis(n+1,false);
	queue<int> Q;
	Q.push(1);
	vis[1] = true;
	while(!Q.empty()) {
		int r = Q.front();
		Q.pop();
		for(int j = 0; j < v[r].size(); j++) {
			if(vis[v[r][j]]==false) {
				val[v[r][j]] += val[r];
				Q.push(v[r][j]);
				vis[v[r][j]] = true;
			}
		} 
	}
	
	for(int itr = 1; itr <= n; itr++) {
		cout << val[itr] << " ";
	}
	cout << endl;
	return 0;
}

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

int main() {
    string S;
    cin >> S;
    int N = S.size();
    
    
    // 0101 で塗る場合
    int ans = 0;
    for ( int i = 0; i < N; ++i){
        int c = S[i] - '0';
        int c2 = i % 2;
        if ( c != c2 ) ++ans;
    }
    
    int ans2 = 0;
    for ( int i = 0; i < N; ++i){
        int c = S[i] - '0';
        int c2 = (i+1) % 2;
        if ( c != c2 ) ++ans2;
    }
    
    cout << min(ans,ans2) << endl;
    
    return 0;
}


Measured memory_bytes: 3708
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, A: "List[int]"):
    play = N - sum(A)
    print(play if play >= 0 else -1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()


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

typedef long long ll;

int n;
ll Num[111111];
ll Sum[111111];
ll Out1, Out2;



int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) scanf("%lld", &Num[i]);

    for(int i = 1; i <= n; i++){
        Sum[i] = Sum[i - 1] + Num[i];
        if(i % 2 == 0){
            if(Sum[i] >= 0){
                Out1 += (Sum[i] + 1);
                Sum[i] = -1;
            }
        }
        else{
            if(Sum[i] <= 0){
                Out1 += (1 - Sum[i]);
                Sum[i] = 1;
            }
        }
    }

    memset(Sum,0,sizeof(Sum));
    for(int i = 1; i <= n; i++){
        Sum[i] = Sum[i - 1] + Num[i];
        if(i % 2 == 1){
            if(Sum[i] >= 0){
                Out2 += (Sum[i] + 1);
                Sum[i] = -1;
            }
        }
        else{
            if(Sum[i] <= 0){
                Out2 += (1 - Sum[i]);
                Sum[i] = 1;
            }
        }
    }
    printf("%lld\n", min(Out1, Out2));
    return 0;
}


Measured memory_bytes: 1920
import scala.io.StdIn.{readLine,readDouble}

object Main extends App {

  def read():Unit = {
    val n = readDouble
    if(n!=0) {
      val line = readLine.split(" ").map(_.toDouble)
      val avg = line.sum / n

      println(Math.sqrt(line.foldLeft(0d)( (x,y) => x + (y - avg)*(y - avg) )/n))
      read()
    }
  }

  read()
}

Measured memory_bytes: 45060
#include <stdio.h>
#include <stdlib.h>
__attribute__((always_inline)) __inline__
long long max(long long x,long long y) {
	return ((y-x>>64-1)&(x^y))^y;
}
typedef struct {int w,s,v;}node;
int cmp(const void *a,const void *b){
	return (((node*)a)->w+((node*)a)->s)-(((node*)b)->w+((node*)b)->s);
}
node b[1005];
long long dp[20005],ans;
int main(n)
{
	scanf("%d",&n);
	for (int i=0;i<n;i++)
		scanf("%d%d%d",&b[i].w,&b[i].s,&b[i].v);
	qsort(b,n,sizeof(node),cmp);
	for (int i=0;i<n;i++) for (int j=b[i].s;j>=0;j--)
		dp[j+b[i].w]=max(dp[j+b[i].w],dp[j]+b[i].v);
	for (int i=0;i<=20000;i++) ans=max(ans,dp[i]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 380
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <iomanip>

using namespace std;
typedef long long int ll;

#define REP(i,n) for(int i=0;i<n;i++)
#define EPS (1e-9)
#define INF (1e9 + 1)
#define PI (acos(-1))

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

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

int bekijo(int a, int b) {
	int tmp = 1;
	REP(i, b) tmp *= a;
	return tmp;
}

int N, M;
int P[100010], Y[100010];
pair<int, pair<int, int> > p[100010];
pair<int, pair<int, int> > p2[100010];

int main() {
	cin >> N >> M;
	REP(i, M) {
		cin >> P[i] >> Y[i];
		p[i].first = P[i];
		p[i].second.first = Y[i];
		p[i].second.second = i;
	}
	sort(p, p + M);

	int j = 0;
	REP(i, M)
	{
//		cout << p[i].first << " " << p[i].second.first << " " << p[i].second.second << endl;
		p2[i].first = p[i].second.second;
		p2[i].second.first = p[i].first;
		if (i != 0 && p[i - 1].first != p[i].first) j = 0;
		p2[i].second.second = ++j;
		
	}
	sort(p2, p2 + M);
	REP(i, M) {
		int a = p2[i].second.first, b = p2[i].second.second;
//		cout << p2[i].second.first << " " << p2[i].second.second << endl;
		cout << setfill('0') << right << setw(6) << a;
		cout << setfill('0') << right << setw(6) << b;
		cout << endl;
	}
}

Measured memory_bytes: 4608
s = list(input())
n = len(s)
while len(s) > 1:
    s.pop(-1)
    
    if len(s)%2 == 0:
        s1 = s[0:len(s)//2]
        s2 = s[len(s)//2:]
        # print(s1)
        # print(s2)
        if s1 == s2:
            print(len(s))
            exit()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int N = 2e5 + 5, INF = 0x3f3f3f3f;
inline int read() {
	int x = 0, f = 0; char ch = 0;
	while (!isdigit(ch)) f |= ch == '-', ch = getchar();
	while (isdigit(ch)) x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}
int ans[N];
vector <int> G[N], col[2], mod[3];
void dfs(int x, int c, int fa) {
	col[c].push_back(x);
	for (auto y : G[x]) if (y != fa) dfs(y, c ^ 1, x);
}
void sol(int i, int j) {
	while (!col[i].empty() && !mod[j].empty()) {
		ans[col[i].back()] = mod[j].back();
		col[i].pop_back(), mod[j].pop_back();
	}
}
int main() {
	int n = read();
	for (int i = 1; i < n; i++) {
		int x = read(), y = read();
		G[x].pb(y), G[y].pb(x);
	}
	for (int i = 1; i <= n; i++) mod[i % 3].pb(i);
	dfs(1, 0, 0);
	sol(col[0].size() < col[1].size(), 1), sol(col[0].size() < col[1].size(), 2);
	sol(0, 0), sol(1, 0);
	for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
	return 0;
}     

Measured memory_bytes: 22296
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i=s;i<n;++i)
#define drep(i,s,n) for (int i=n;i>=s;--i)
#define all(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define print(x) cout<<(x)<<endl
using namespace std;
typedef long long ll;

int gcd(int a,int b)
{if (a%b == 0) return(b);
 else          return(gcd(b,a%b));}
int lcm(int a,int b)
{return a*b/gcd(a,b);}
void printv(vector<auto> v) {cout<<'[';rep(i,0,v.size()){cout<<v[i]<<',';}cout<<']'<<endl;}
void printvv(vector<vector<auto>> vv)
{
  cout<<'['<<endl;
  rep(q,0,vv.size()){cout<<'[';rep(p,0,vv.at(q).size())cout<<vv.at(q).at(p)<<',';cout <<']'<<endl;}
  cout<<']'<<endl;
}
void solve(); int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}
int step_x[] = {-1,0,0,1};
int step_y[] = {0,-1,1,0};
ll INF=10e6;
//------------------------------------------------------------
ll A,B,N;
void solve() {
  string S;
  cin>>S;

  if (S=="ABC") print("ARC");
  else print("ABC");

  return;
}


Measured memory_bytes: 3572
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

numbers = Counter(list(range(not N % 2, N, 2)) * 2)
if N % 2:
    numbers[0] = 1
if Counter(A) == numbers:
    print(pow(2, (N // 2), int(10 ** 9 + 7)))
else:
    print(0)


Measured memory_bytes: 18272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int n; cin >> n;
    int ans = 0;
    for(int i=0; i<n; i++){
        int l, r; cin >> l >> r;
        ans += r-l+1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
/************************************************
   Start coding only after you have clear idea. 
*************************************************/

#include <bits/stdc++.h>

#define x first
#define y second
#define pii pair<int,int>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
const int maxm = 2e3+23;
const int maxn = 2e5+35;
int n,m,u,v,fa[maxn];
int find(int x){
    return fa[x] == x ? x : fa[x] = find(fa[x]);
}
int main(){
    scanf("%d %d",&n,&m);
    int ans = n;
    for(int i = 1;i <= n; ++i) fa[i] = i;
    while(m--){
        scanf("%d %d",&u,&v);
        int fu = find(u);
        int fv = find(v);
        if(fu == fv) continue;
        ans -= 1;
        fa[fv] = fu;
    }
    printf("%d\n",ans-1);
    return 0;
}

Measured memory_bytes: 4148
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N, X;
        public void Run()
        {
            {
                var line = Input.ReadIntArray();
                N = line[0];
                X = line[1];
            }

            if (X == 1 || X == 2 * N - 1)
            {
                Console.WriteLine("No");
                return;
            }
            else
            {
                Console.WriteLine("Yes");
            }

            int[] A = new int[2 * N - 1];

            int c = 2;
            for (int i = 0; i < 2 * N - 1; i++)
            {
                if (i == N - 1) A[i] = X;
                else if (i == N - 2) A[i] = 1;
                else if (i == N) A[i] = 2 * N - 1;
                else
                {
                    if (c == X) c++;
                    A[i] = c;
                    c++;
                }

                Console.WriteLine(A[i]);
            }
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 19164
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
template<class T> inline istream& operator >> (istream & c, vector<T> & A) {rep(i, A.size()) c >> A[i];return c;}
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<ll> l(n);
	cin >> l;
	int ans = 0;
	for (int i = 0; i < n - 2; ++i) {
		for (int j = i + 1; j < n - 1; ++j) {
			if (l[i] == l[j]) continue;
			for (int k = j + 1; k < n; ++k) {
				if (l[i] == l[k] || l[j] == l[k]) continue;
				if (l[i] + l[j] > l[k] && l[i] + l[k] > l[j] && l[k] + l[j] > l[i]) ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

struct node {
	int child[2];
	node()
	{
		MEM_1(child);
	}
};
vector<node> trie;
int init()
{
	node x;
	trie.push_back(x);
	return (int)trie.size() - 1;
}
void add(int n, string &s, int i)
{
	if (i == s.length())
	{
		return;
	}
	int c = s[i] - '0';
	if (trie[n].child[c] == -1)
	{
		int next = init();
		trie[n].child[c] = next;
	}
	add(trie[n].child[c], s, i + 1);
}
int n;
ll l,ans;
ll res(ll x)
{
	if(x==0)return 0;
	ll c=1;
	while(x%2==0)
	{
		c*=2;
		x/=2;
	}
	return c;
}
void dfs(int N,int i)
{
	if(trie[N].child[0]==-1)ans^=res(l-i);
	else dfs(trie[N].child[0],i+1);
	if(trie[N].child[1]==-1)ans^=res(l-i);
	else dfs(trie[N].child[1],i+1);
}
int main() {
	SYNC;
	init();
	cin>>n>>l;
	fup(i,0,n-1,1)
	{
		string s;
		cin>>s;
		add(0,s,0);
	}
	dfs(0,0);
	if(ans)cout<<"Alice";
	else cout<<"Bob";
}

Measured memory_bytes: 4320
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <cmath>

using namespace std;

struct vertex{
    int X;
    int Y;
};

int	gcd(int	a, int b){
    while( b ){
        int	m = a % b;
        a = b;
        b = m;
    }
    return a;
}

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

int isPrim(int a){
    if(a==1){
        return 0;
    }
    for(int i=2;i<=(a+1)/2;i++){
        if(a%i==0){
            return 0;
        }
    }
    return 1;
}

void f(int A,int B){
    
}

int main(int argc, const char * argv[])
{
    //std::ios::sync_with_stdio(false);
    //scanf("%s",S);
    //scanf("%d",&N);
    //getline(cin, target);
    //cin >> x >> y;
    //????????????

    int n;
    cin >> n;
    string digits="";
    
    for(int i=0;i<n;i++){
        int d;
        cin >>d;
        stringstream ss;
        ss << d;
        digits = digits + ss.str();
    }
    int i=0;
    while(1){
        stringstream ss;
        ss << i;
        if(string::npos==digits.find(ss.str(),0)){
            break;
        }
        i++;
    }


    cout << i << endl;
    
    //???????????§
    //cout << "ans" << endl;????????????
    //printf("%.0f\n",ans);//?°???°?????\?????¨?????????
    //printf("%.7f",p);
    //printf("%f\n",pow(2,ans.size()));
    
    return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#define ll long long int
#define rep(i,n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair

using namespace std;

ll n,m;
vector<ll> dp;
vector<vector<ll> > e;

ll dfs(int c,int p){
    if(e[c].size() == 0){
        dp[c] = 0;
    }
    else{
        for(int i = 0;i < e[c].size();i++){
            if(e[c][i] != p){
                if(dp[e[c][i]] == -1){
                    dp[c] = max(dp[c],dfs(e[c][i],c) + 1);
                }
                else
                {
                    dp[c] = max(dp[c], dp[e[c][i]] + 1);
                }
            }
        }
    }
    return dp[c];
}

int main(){
    
    int n,m;
    cin >> n >> m;
    e.resize(n);
    int a,b;
    rep(i,m){
        cin >> a >> b;
        a--;b--;
        e[a].pb(b);
    }

    dp.resize(n);
    rep(i,n) dp[i] = -1;

    ll ans = 0;
    int i = 0;

    while(true){
        if(dp[i] == -1){
            ans = max(ans,dfs(i,-1));
        }
        if(i == n-1){
            break;
        }
        i++;
    }

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

Measured memory_bytes: 9216
#!/usr/bin/env python
N = int(input())
temp = []
l = []
for n in range(N):
    temp = input().split()
    l.append([temp[0], int(temp[1]), n+1])
    temp = []

l_sort = sorted(l, key=lambda x:(x[0], -x[1]))
for x in l_sort:
    print(x[2])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n, m;
  cin >> n >> m;
  cout << (n==m ? "Yes" : "No") << newl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n, x, d := scanInt(), scanInt(), scanInt()

	if d == 0 {
		if x == 0 {
			fmt.Fprintln(wr, 1)
		} else {
			fmt.Fprintln(wr, n+1)
		}
		return
	}

	a := map[int]ps{}
	tt := n * (n - 1) / 2

	for i := 0; i <= n; i++ {
		p := i * x % d
		l := i*x/d + i*(i-1)/2
		r := i*x/d + tt - (n-i)*(n-1-i)/2
		a[p] = append(a[p], pii{l, r})
	}

	ans := 0

	for i := range a {
		sort.Sort(a[i])
		l, r := a[i][0].a, a[i][0].b
		for j := 0; j < len(a[i]); j++ {
			if a[i][j].a <= r {
				r = max(r, a[i][j].b)
			} else {
				ans += r - l + 1
				l, r = a[i][j].a, a[i][j].b
			}
		}
		ans += r - l + 1
	}

	fmt.Fprintln(wr, ans)
}

type pii struct{ a, b int }

type ps []pii

func (a ps) Len() int           { return len(a) }
func (a ps) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ps) Less(i, j int) bool { return a[i].a < a[j].a }


Measured memory_bytes: 20352