akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  string S,T;
  cin>>S>>T;
  ll ans=INF,NS=(ll)S.size(),NT=(ll)T.size();
  
  for(int i=0; i<=NS-NT; ++i){
    ll cnt=0;
    
    for(int j=0; j<NT; ++j){
      if(S[i+j]!=T[j]) cnt++;
    }
    
    chmin(ans,cnt);
  }
  
  co(ans);
  return 0;
}

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

int op(int a, int b) {
    return max(a, b);
}

int e() {
    return 0;
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    segtree<int, op, e> seg(300001);
    for (int i = 0; i < n; i++) {
        int l = a.at(i) - k, r = a.at(i) + k + 1;
        l = max(0, l);
        r = min(r, 300001);
        seg.set(a.at(i), seg.prod(l, r) + 1);
    }
    cout << seg.all_prod() << endl;
}


Measured memory_bytes: 9488
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define PP(m) REP(i, m.size()) cout << m[i] << endl;

int main() {
  vector<long long> dp(31);
  dp[0] = 1;
  dp[1] = 1;
  dp[2] = 2;
  for(int i = 3; i < 31; i++){
    dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
  }

  int n;

  while (cin >> n && n) {
    cout << ceil(dp[n] / 3650) + 1 << endl;
  }
  return 0;
}

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

int main(){
    int N, ans=0;
    cin >> N;
    vector<pair<int, int>> r(N) ,b(N);
    
    for(int i=0; i<N; i++)
	cin >> r[i].second >> r[i].first;
    for(int i=0; i<N; i++)
	cin >> b[i].first >> b[i].second;
    sort(b.begin(), b.end());
    sort(r.begin(), r.end(), greater<pair<int, int>>());

    for(int i=0; i<N; i++){
	for(int j=0; j<N; j++){
	    if(b[i].first>r[j].second && b[i].second>r[j].first){
		ans++;
		r[j].first = 2e9;
		r[j].second = 2e9;
		break;
	    }
	}
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define break break
#define continue continue
#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
#define vint vector<int>
#define vll vector<ll>
typedef long long ll;

using namespace std;


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

	if(n%2 == 1){
		cout << "No" << endl;
		return 0;
	}
	string t1, t2;
	for(int i=0; i<n/2; i++){
		t1 += str[i];
	}
	for(int i=n/2; i<n; i++){
		t2 += str[i];
	}
	//cout << t1 << endl;
	//cout << t2 << endl;
	if(t1 == t2) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

using namespace std;

int dp[200'005][2];

void solve() {
    string s; cin >> s;
    int n = s.size();
    memset(dp, -1, sizeof dp);
    dp[0][0] = 1;
    for (int i = 1; i < n; i++) {
        dp[i][0] = dp[i-1][1]+1;
        if (s[i] != s[i-1])
            dp[i][0] = max(dp[i][0], dp[i-1][0]+1);

        dp[i][1] = i<3? (i<2?1:2): dp[i-2][0]+1;
        if (i>=3 && (s[i] != s[i-2] || s[i-1] != s[i-3]))
            dp[i][1] = max(dp[i][1], dp[i-2][1]+1);
    }
    int res = max(dp[n-1][0], dp[n-1][1]);
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 2196
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    H, W, K = map(int, input().split())
    C = [list(input()[:-1]) for _ in range(H)]
    black = 0
    for i in range(H):
        for j in range(W):
            if C[i][j] == "#":
                black += 1
    
    ans = 0
    for n in range(2**H):
        for m in range(2**W):
            tmp = black
            used = [[False]*W for _ in range(H)]
            for h in range(H):
                if n & (1 << h):
                    for j in range(W):
                        if C[h][j] == "#" and used[h][j] == False:
                            tmp -= 1
                            used[h][j] = True
            for w in range(W):
                if m & (1 << w):
                    for i in range(H):
                        if C[i][w] == "#" and used[i][w] == False:
                            tmp -= 1
                            used[i][w] = True
            if tmp == K:
                ans += 1
    
    print(ans)


if __name__ == '__main__':
    main()

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

signed main() {
  int a, b; cin >> a >> b;
  string s; cin >> s;

  bool ans = true;
  for(int i = 0; i < a; i++) if(s[i]=='-') ans = false;
  if(s[a]!='-') ans = false;
  for(int i = a+1; i < a+b+1; i++) if(s[i]=='-') ans = false;

  cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define MOD 1000000007
typedef long long ll;

int main(){
  	char str[4];
  	int cnt;
  	scanf("%s", str);
  	for(int i = 0; i < 4; i++){
        if (str[i] == 'o') cnt++;
    }
    printf("%d", 700 + cnt * 100);
	return 0;
}

Measured memory_bytes: 128
//**************************
//*** writer  :  Alex Hu **
//************************

#include<bits/stdc++.h>

using namespace std;

#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mkp make_pair
#define pb push_back
#define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int maxn=1e5+10;

int n,m,cnt,tot,fst[maxn],pnt[maxn<<1],nxt[maxn<<1],ans[maxn],dp[maxn][11];

void add(int x,int y)
{
	pnt[++tot]=y;
	nxt[tot]=fst[x];
	fst[x]=tot;
} 

int main()
{
	scanf("%d%d",&n,&m);
	int x,y;
	rept(i,1,m+1)
	{
		scanf("%d%d",&x,&y);
		add(x,y);
		add(y,x);
	}
	scanf("%d",&cnt);
	rept(i,1,cnt+1)
	{
		scanf("%d%d%d",&x,&y,&ans[i]);
		dp[x][y]=i;
	}
	for (int i=9;i>=0;i--)
	{
		rept(x,1,n+1)
		{
			dp[x][i]=max(dp[x][i],dp[x][i+1]);
			for (int j=fst[x];j;j=nxt[j]) dp[x][i]=max(dp[x][i],dp[pnt[j]][i+1]);
		}
	}
	rept(i,1,n+1) printf("%d\n",ans[dp[i][0]]);
	return 0;
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << ": " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<"| ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e5 + 10;
const int mod = 1e9 + 7;

int n , k;

int32_t main(){
    boost;


    //code
    cin >> n >> k;
    int x = ((n-1)*(n-2))/2;

    if( k > x){
    	cout << -1;
    	return 0;
    }

    set<pair<int,int>> ans;

    
    int diff = (n*(n-1))/2 - k;

    // trace(diff);

    
    for(int i = 1 ; i <= n ; ++i){
    	for(int j = i+1 ; j <= n ; ++j){
    		int a = i , b = j;

    		if(a > b) swap(a,b);

    		ans.insert({a,b});

    		diff -= 1;

    		if(diff == 0)
    			break;
    	}
    	if(diff == 0)
    		break;
    }

    cout << ans.size() << "\n";

    for(auto i : ans){
    	cout << i.first << " " << i.second << "\n";
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
template<class T> inline void chmin(T &a, T b){if(a>=b)a=b;}
template<class T> inline void chmax(T &a, T b){if(a<=b)a=b;}
typedef long long ll;
const int INF = 1e9;

int A, B;

int main(){
    cin >> A >> B;
    if(A==B){
        cout << A + B << endl;
    } else {
        int m = max(A, B);
        cout << m + m - 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a, b,c,d,e;
	scanf("%d %d %d\n", &a, &b,&c);
	scanf("%d",&d);
	if (a > b&&a > c){
		for (e = 0; e < d; e++){
			a*= 2;
		}
		a = a + b + c;
		printf("%d",a);
	}
else if (b > a&&b > c){
		for (e = 0; e < d; e++){
			b*= 2;
		}
		a = a + b + c;
		printf("%d", a);
	}
else if (c > a&&c > b){
	for (e = 0; e < d; e++){
		c*= 2;
	}
	a = a + b + c;
	printf("%d", a);
}
else if (b == a||b == c){
		for (e = 0; e <d; e++){
			b*= 2;
		}
		a = a + b + c;
		printf("%d", a);
	}
else if (c == a){
	for (e = 0; e < d; e++){
		a*=  2;
	}
	a = a + b + c;
	printf("%d", a);
}

}

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

using i64 = long long;
using u64 = unsigned long long;

const int mod = (int)1e9+7;

void __print() {cerr << "]\n";}

template<typename T, typename... V>
void __print(T t, V... v)
{ cerr << t; if(sizeof...(v)) cerr << ", "; __print(v...);}

#define dbg(x...) cerr << "[" << #x << "] = ["; __print(x);


int main()
{
    int n, k;
    string s;
    cin >> n >> k >> s;
    s = "#" + s + "#";
    // n += 2;
    int unhappy = 0;
    for(int i = 1; i <= n; i++) {
        if(s[i] == 'L') unhappy += (s[i-1] != 'L');
        else unhappy += (s[i+1] != 'R');
    }
    unhappy -= k*2;
    unhappy = max(0, unhappy);
    if(!unhappy) unhappy++;
    cout << n - unhappy << "\n";
}


Measured memory_bytes: 3744
import java.io.*;

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int r = Integer.parseInt(line[0]);
        int c = Integer.parseInt(line[1]);
        int[][] sheet = new int[r+1][c+1];

        for(int i = 0; i < r; i++){
            line = br.readLine().split(" ");
            int[] a = new int[c];
            for(int k = 0; k < c; k++){
                a[k] = Integer.parseInt(line[k]);
            }
            for(int j = 0; j < c; j++){
                sheet[i][j] = a[j];
                sheet[r][c] += a[j];
                sheet[i][c] += a[j];
                sheet[r][j] += a[j];
            }
        }

        for(int i = 0; i <= r; i++){
            for(int j = 0; j <= c; j++){
                 System.out.print(sheet[i][j]);
                 if(j != c)
                   System.out.print(" ");
            }
                System.out.print("\n");
        }
    }
}

Measured memory_bytes: 33488
# Problem D - Sum of Large Numbers

# input
N, K = map(int, input().split())

# initialization
up_list = [i for i in range(N+1)] # 昇順リスト
up_sums = [0]*(N+1)
for i in range(N+1):
    if i==0:
        up_sums[i] = up_list[i]
    else:
        up_sums[i] = up_sums[i-1] + up_list[i]
down_list = [i for i in range(N, -1, -1)] # 降順リスト
down_sums = [0]*(N+1)
for i in range(N+1):
    if i==0:
        down_sums[i] = down_list[i]
    else:
        down_sums[i] = down_sums[i-1] + down_list[i]
ans = 0
MOD = 10**9 + 7

# count
tmp_k = K
while tmp_k<=(N+1):
    test_up = up_sums[tmp_k-1]
    test_down = down_sums[tmp_k-1]
    tmp = (test_down - test_up + 1)%MOD
    ans += tmp
    ans = ans % MOD
    tmp_k += 1

# output
print(ans)


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


int main()
{
	int r, c, e, sum, sum2, sheet[101][101];
	cin >> r >> c;

	for (int i = 0;i < r;i++) {
		sum = 0;
		for (int j = 0;j < c;j++) {
			cin >> e;
			sheet[i][j] = e;
			sum += e;
		}

		sheet[i][c] = sum;
	}

	sum2 = 0;
	for (int i = 0;i < c;i++) {
		sum = 0;
		for (int j = 0;j < r;j++) {
			sum += sheet[j][i];
		}

		sheet[r][i] = sum;
		sum2 += sum;
	}

	sheet[r][c] = sum2;

	for (int i = 0;i <= r;i++) {
		for (int j = 0;j <= c;j++) {
			if (j == c) {
				cout << sheet[i][j] << endl;
			}
			else {
				cout << sheet[i][j] << " ";
			}
		}
	}

    return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define fori(i,n) for(int i =0;i<n;i++)
#define pb push_back
#define ll long long
#define int long long
#define F first
#define S second
#define mp make_pair
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout.precision(15);
 
 
int mod = 1e9+7;
 
int pow(int a, int b, int mod) {
    int ans = 1;
    a %= mod;
    while(b) {
        if(b%2) {
            ans *= a;
            ans %= mod;
        }
        b /= 2;
        a *= a;
        a %= mod;
    }
    return ans;
}

int inv(int a) {
    return pow(a,mod-2);
}

int mul (int a,int b) {
    return ((a%mod)*(b%mod))% mod;
}

struct cmp {
    bool operator() (pair<int,int> a, pair<int,int> b) const {
        int x = a.F;
        int y = b.F;
        return x>=y;
    }
};

int pr[200001];

void pre() {
    for(int i = 1; i<200001; i++) {
        int j = i;
        while(j) {
            if(j < i) {
                pr[i] += pr[j];
                break;
            }
            j = j % (__builtin_popcount(j));
            pr[i]++;
        }
    }
}


int32_t main() {
    FAST;
    int t;
    // cin>>t;
    t = 1;
    pre();
    while(t--) {
        int n;
        string p,q;
        cin>>n;
        cin>>p;
        int cnt = 0;
        fori(i,n) {
            cnt += p[i] == '1';
        }
        int pls = 0, mns = 0;
        int pwr = -1;
        for(int i = n-1; i >=0; i--) {
            pwr++;
            if(p[i] == '0') continue;
            pls += pow(2ll, pwr, cnt+1);
            if(cnt != 1) {
                mns += pow(2ll, pwr, cnt-1);
                mns %= (cnt-1);
            }
            pls %= (cnt+1);
        }

        fori(i,n) {
            pwr = n-i-1;
            if(cnt == 1 && p[i] == '1') {
                cout<<"0\n";
                continue;
            }
            int md = p[i] == '1' ? cnt-1 : cnt+1;
            int ans = p[i] == '1' ? mns - pow(2ll, pwr, md) : pls + pow(2ll, pwr, md);
            ans = (ans + 3ll*md) % md;
            cout<<pr[ans]+1<<"\n";
        }

    }
    
    return 0;
}

Measured memory_bytes: 5292
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
from itertools import accumulate #list(accumulate(A))


def segfunc(a,b):
    return a+b

def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]    
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
    
def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res


n, M, Q = mi()

#####単位元######
ide_ele = 0
#num:n以上の最小の2のべき乗
num =2**(n-1).bit_length()
seg=[ide_ele]*2*num

L = [0]*n
init(L)

lrpq = dp2(0, 3, M+Q)

for i in range(M):
    l, r = mi()
    lrpq[i][1] = l-1
    lrpq[i][2] = r-1

for i in range(M, M+Q):
    p, q = mi()
    lrpq[i][0] = i
    lrpq[i][1] = p-1
    lrpq[i][2] = q-1

lrpq = sorted(lrpq, key=lambda x:(x[2], x[0]))

ans = [0]*(Q)

for i in range(M+Q):
    if lrpq[i][0] == 0:
        #L[lrpq[i][1]] += 1
        update(lrpq[i][1], seg[lrpq[i][1]+num-1]+1)
    else:
        ans[lrpq[i][0]-M] = query(lrpq[i][1], lrpq[i][2]+1)

for num in ans:
    print(num)

Measured memory_bytes: 72944
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<complex>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;




const ll INF = 1e18+7;


/******************************************************************************************/


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);

	
	ll n, a, b;
	cin >> n >> a >> b;

	ll mini = LLONG_MAX;

		


	if ((b - a) % 2LL == 0) {
		//偶数の場合
		ll hoge = b-a;
		ll cnt = 0;
		cnt = hoge / 2LL;
		mini = min(mini, cnt);
	}
	else
	{
		ll diff = b - a - 1;
		ll cnt = 0;
		cnt = diff / 2LL;
		mini = min(mini, cnt + a - 1 + 1LL);

		mini = min(mini, cnt + n - b + 1LL);

	}

	cout << mini << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n],b[n],c[n],nowa,nowb,now=0;
	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++) c[i]=i+1;
	do
	{
		bool flag=1;
		now++;
		for(int i=0;i<n;i++)
		{
			if(a[i]!=c[i])
			{
				flag=0;
				break;
			}
		}
		if(flag) nowa=now;
		flag=1;
		for(int i=0;i<n;i++)
		{
			if(b[i]!=c[i])
			{
				flag=0;
				break;
			}
		}
		if(flag) nowb=now;
	}while(next_permutation(c,c+n));
	cout<<abs(nowa-nowb)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int a[1000];
int n;
cin>>n;
int i;
for(i=0;i<=n-1;i++){
    cin>>a[i];
}
int j;
for(j=n-1;j>-1;j--){
    cout<<a[j];
    if(j>0){cout<<" ";}
    if(j==0){cout<<endl;}
}
}



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

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  int H, W, h, w ;
  cin >> H >> W >> h >> w ;
  
  cout << (H-h)*(W-w)<<endl ;
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <utility>
#include <queue>
#include <bitset>
#include <math.h>
#include <numeric>
#include <stack>
#include <iomanip>
using namespace std;
 
#define rep(i,m,n) for(int i=m;i<(int)(n);i++)
#define endl '\n'
typedef long long ll;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    string s,t; cin >> s >> t;
    rep(i,0,n){
        cout<<s[i]<<t[i];
    }
    
}

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

char a, b, c, d;
int A, B, C, D, X, Y;

int main () {
    cin >> a >> b >> c >> d;
    A = a - '0';
    B = b - '0';
    C = c - '0';
    D = d - '0';
    X = A*10 + B;
    Y = C*10 + D;
    if (0<X && X<=12 && 0<Y && Y<=12)
        cout << "AMBIGUOUS" << endl;
    else if (0<X && X<=12)
        cout << "MMYY" << endl;
    else if (0<Y && Y<=12)
        cout << "YYMM" << endl;
    else
        cout << "NA" << endl;    
	return 0;
}

Measured memory_bytes: 256
from collections import deque
from collections import defaultdict
n=int(input())
E=[[] for _ in range(n)]
col=defaultdict(list)
l=[]
for i in range(n-1):
  a,b=map(int,input().split())
  a-=1
  b-=1
  E[a].append(b)
  E[b].append(a)
  col[(a,b)]=-1
  col[(b,a)]=-1
  l.append((a,b))
s=-1
k=-1
for i in range(n):
  if len(E[i])>k:
    k=len(E[i])
    s=i
par=[-1]*n
stack=deque([s])
seen=[-1]*n
seen[s]=1
while stack:
  u=stack.pop()
  if u==s:
    cnt=1
  else:
    cnt=col[(par[u],u)]+1
  for v in E[u]:
    if seen[v]!=1:
      par[v]=u
      seen[v]=1
      if cnt<=k:
        col[(u,v)]=cnt
        cnt+=1
      else:
        col[(u,v)]=1
        cnt=2
      stack.append(v)
print(k)
for a,b in l:
  if col[(a,b)]==-1:
    print(col[(b,a)])
  else:
    print(col[(a,b)])

Measured memory_bytes: 56612
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author ParsaAlizadeh
 */

#include <bits/stdc++.h>
using namespace std;

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

#define all(x)          x.begin(), x.end()
#define kill(x)         return cout << x << endl, 0;
#define X               first
#define Y               second
#define sep             ' '
#define endl            '\n'
#define fastio          ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define file_io         freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
#define ld_io           cout << setprecision(10) << fixed;

#undef pow
ll pow(ll a, ll b, ll mod) {
    if (!b)    return 1;
    if (b & 1) return a * pow(a * a % mod, b / 2, mod) % mod;
    return pow(a * a % mod, b / 2, mod) % mod;
}

const ll MAXN  = 1e5 + 10;
const ll INF   = 8e18;
const ll MOD   = 1e9 + 7; // 998244353;
const ll LOG   = 32;      // log2(1e9)
const ll BLOCK = 320;     // sqrt(1e5)
const ld PI    = acos(-1);
const ld SADAT = 7.84e-17;  // The most important constant ever

ll n;

int main() {
    fastio
    cin >> n;
    cout << n * n * n << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{ int a,b,c,d,e,k;
cin>>a>>b>>c>>d>>e>>k;
if (e-a>k||e-b>k||e-c>k||e-d>k)
{
    cout << ":(";
}
else
    cout << "Yay!";
}


Measured memory_bytes: 256
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<60
#define fs first
#define sc second
#define pb push_back
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;

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

  int n;
  cin >> n;

  vector<int> a(n),b(n);
  REP(i,n) cin >> a[i] >> b[i];
  
  vector<P> tmp(n);
  REP(i,n) tmp[i] = P(a[i]+b[i],i);


  sort(tmp.begin(),tmp.end());
  int ans = 0;
  REP(i,n){
    if(i % 2 == 0) ans += a[tmp[n-1-i].sc];
    else ans -= b[tmp[n-1-i].sc];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3456
// Winners don't quit and Quitters don't win
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mod 998244353
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define mod 1000000007 //1e9+7
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100000

void calc(int n,int m){
  int suma=0,sumb=0;
  int s[SIZE];

  for(int i=0;i<n+m;i++){
    scanf("%d",s+i);
    if(i<n) suma += s[i];
    else sumb += s[i];
  }

  int sum=INF,a=-1,b=-1;
  
  for(int i=0;i<n;i++){

    for(int j=n;j<n+m;j++){
      if(suma+(s[j]-s[i]) == sumb-(s[j]-s[i])){
	if(sum > s[j] + s[i]){
	  a = s[i];
	  b = s[j];
	  sum = a+b;
	}
      }
    }
  }

  if(sum==INF)
    puts("-1");
  else
    printf("%d %d\n",a,b);
  
  
  return;
}

int main(){
  int n,m;
  
  while(1){
    scanf("%d%d",&n,&m);
    if(n==0) break;
    calc(n,m);
  }

  return 0;
}

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

int main() {
  int n;
  double ans;
  cin >> n;
  double a = n;
  if(n%2==0){
    cout << 0.5 << endl;
    return 0;
  }else{
    ans=(n/2+1)/a;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int r = in.nextInt();
		List<Integer> pickUP = new LinkedList<Integer>();
		LinkedList<Integer> cards = new LinkedList<Integer>();
		while (n != 0 && r != 0) {
			cards.clear();
			for (int i = 0; i < n; i++) {
				cards.addFirst(i + 1);
			}
			for (int i = 0; i < r; i++) {
				pickUP.clear();
				int from = in.nextInt() - 1;
				int to = in.nextInt() + from;
				List<Integer> subList = cards.subList(from, to);
				pickUP.addAll(subList);
				subList.clear();
				cards.addAll(0, pickUP);
			}
			System.out.println(cards.peekFirst());
			n = in.nextInt();
			r = in.nextInt();
		}
	}
}

Measured memory_bytes: 13000
#include <iostream>
#include <vector>
#include <climits>
using namespace std;

int main(){
  int br[100][100];
  bool f[100];
  int tr[100];
  int n,m;

  while(1){
    cin>>n>>m;
    if(n==0&&m==0) break;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++)
	br[i][j] = -1;
      tr[i]=INT_MAX;
      f[i]=0;
    }    
    for(int k=0;k<m;k++){
      int a,b,cost;
      cin>>a>>b>>cost;
      br[a][b]=cost;
      br[b][a]=cost;
    }
    int comin=0,r,trmin;
    tr[0] = 0;

    for(int k=0;k<n;k++){
      trmin=INT_MAX;
      for(int i=0;i<n;i++)
	if(f[i]==0 && trmin>tr[i]) r=i,trmin=tr[i];
      //cout << trmin<<endl;
      comin+=trmin;
      f[r]=1;
      for(int i=0;i<n;i++){
	if(f[i]==0 && tr[i]>br[r][i] && br[r][i]!=-1) tr[i]=br[r][i];
      }
    }
    cout <<comin<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
#pragma region Macros
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
using P = pair<ll, ll>;
#define ios\
    ios::sync_with_stdio(false);\
    cin.tie(nullptr);
#define VEC(type, name, size)\
    V<type> name(size);\
    IN(name)
#define VVEC(type, name, h, w)\
    VV<type> name(h, V<type>(w));\
    IN(name)
#define INT(...)\
    int __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LL(...)\
    ll __VA_ARGS__;\
    IN(__VA_ARGS__)
#define STR(...)\
    string __VA_ARGS__;\
    IN(__VA_ARGS__)
#define CHAR(...)\
    char __VA_ARGS__;\
    IN(__VA_ARGS__)
#define DOUBLE(...)\
    DOUBLE __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LD(...)\
    LD __VA_ARGS__;\
    IN(__VA_ARGS__)
template <class T> void scan(T a) { cin >> a; }
void scan(int &a) { cin >> a; }
void scan(long long &a) { cin >> a; }
void scan(char &a) { cin >> a; }
void scan(double &a) { cin >> a; }
void scan(long double &a) { cin >> a; }
void scan(char a[]) { scanf("%s", a); }
void scan(string &a) { cin >> a; }
template <class T> void scan(V<T> &);
template <class T, class L> void scan(pair<T, L> &);
template <class T> void scan(V<T> &a) { for(auto &i : a) scan(i); }
template <class T, class L> void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template <class T> void scan(T &a) { cin >> a; }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) { scan(head); IN(tail...); }
template <class T> inline void print(T x){ cout << x << '\n';}
template <class T> V<T> press(V<T> &x){ 
    V<T> res = x;
    sort(all(res));
    res.erase(unique(all(res)), res.end());
    REP(i, SZ(x)){
        x[i] = lower_bound(all(res), x[i]) - res.begin();
    }
    return res;
}
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
template <typename T> T pow(T a, long long n, T e = 1) {T ret = e; while (n) {if (n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
const ll INF = 1e18;
#pragma endregion

int main(){
    ios;
    INT(n, x, t);
    print(t * Roundup_div(n , x));
}

Measured memory_bytes: 3580
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  string s;
  cin >> s;
  ll ans = 0;
  int n = s.length();
  ll a = 0;
  for(int i = 0; i < n; i++) {
    while(s[i] == 'A') {
      a++;
      i++;
    }
    if(i < n - 1) {
      if(s[i] == 'B' && s[i + 1] == 'C' && a > 0) {
        ans += a;
        i++;
      } else if(s[i] == 'C' || s[i] == 'B') {
        a = 0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3768
#include <stdio.h>
#include <stdlib.h>
int min(int a, int b)
{
  if(a <= b)
  return a;
  else
  return b;
}

int main(void)
{
  int i, j, n, m, c, a[20][20], b[20];
  int count = 0;
  int c1 = 0;
  scanf("%d %d %d", &n, &m, &c);
  for(i = 0; i < m; i++)
  scanf("%d", &b[i]);
  for(i = 0; i < n; i++){
    for(j = 0; j < m; j++)
    scanf("%d", &a[i][j]);
  }
  for(i = 0; i < n; i++){
    for(j = 0; j < m; j++){
      c1 += a[i][j] * b[j];
    }
    c1 += c;
    if(c1 > 0)
    count++;
    c1 = 0;
  }
  printf("%d\n", count);
  return 0;
}

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

int main() {
  double a;
  while(cin>>a) {
    if(a<=48) cout<<"light fly";
    else if(a<=51)cout<<"fly";
    else if(a<=54)cout<<"bantam";
    else if(a<=57)cout<<"feather";
    else if(a<=60)cout<<"light";
    else if(a<=64)cout<<"light welter";
    else if(a<=69)cout<<"welter";
    else if(a<=75)cout<<"light middle";
    else if(a<=81)cout<<"middle";
    else if(a<=91)cout<<"light heavy";
    else cout<<"heavy";
    cout << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
const ll MODA=998244353;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
vector<ll> fac;
vector<ll> finv;
vector<ll> inv;
void COMinit(ll N,ll P){
    rep(i,N+1){
        if(i==0){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else if(i==1){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else{
            fac.push_back(fac.at(i-1)*i%P);
            inv.push_back(P-inv.at(P%i)*(P/i)%P);
            finv.push_back(finv.at(i-1)*inv.at(i)%P);
        }
    }
}

ll COM(ll n,ll k,ll P){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac.at(n)*(finv.at(k)*finv.at(n-k)%P)%P;
}
int main()
{
    ll N;
    cin>>N;
    vector<ll> L(N);
    rep(i,N){
        cin>>L.at(i);
    }
    ll ans=0;
    sort(L.begin(),L.end());
    rep(i,N-2){
        for(ll j=i+1;j<N-1;j++){
            for(ll k=j+1;k<N;k++){
                if(L.at(i)+L.at(j)>L.at(k)&&L.at(i)<L.at(j)&&L.at(j)<L.at(k))ans++;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
module.exports=function(t){var e={};function i(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=0)}([function(t,e,i){i(1)(i(3).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(t,e,i){var n=i(2);t.exports=function(t){for(var e=t[0].split(" "),i=Number(e[0]),r=Number(e[1]),s=[],o=0,u=new n,d=0;d<i;d++){for(var f=t[d+1].split(""),l=0;l<r;l++)"#"==f[l]?u.enq({x:l,y:d,dist:0}):o+=1;s.push(f)}for(;u.size>0;){var c=u.deq();if("."==s[c.y][c.x]||0==c.dist){if("."==s[c.y][c.x]&&(s[c.y][c.x]="#",o-=1),o<=0)return void console.log(c.dist);c.x+1<r&&"#"!=s[c.y][c.x+1]&&u.enq({x:c.x+1,y:c.y,dist:c.dist+1}),c.x-1>=0&&"#"!=s[c.y][c.x-1]&&u.enq({x:c.x-1,y:c.y,dist:c.dist+1}),c.y+1<i&&"#"!=s[c.y+1][c.x]&&u.enq({x:c.x,y:c.y+1,dist:c.dist+1}),c.y-1>=0&&"#"!=s[c.y-1][c.x]&&u.enq({x:c.x,y:c.y-1,dist:c.dist+1})}}}},function(t,e,i){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e4;this.size=0,this.items=[],this.ind=0,this.maxGap=t}enq(t){this.size+=1,this.items.push(t),this.items.size-this.ind>this.maxGap&&(this.items=this.items.slice(this.ind))}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}}},function(t,e){t.exports=require("fs")}]);

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

#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
const long long INF=1e18;
#define lp(i,n) for(int i=0;(i)<(n);i++)
#define lps(i,j,n) for(int i=j;i<(n);i++)
vector<string> v;
vector<string> x;
int vi,xi;

void makev(string s){
  int mode=2;
  int cnt=1;
  if('0'<=s[0]&&s[0]<='9'){
    vi=0;
  }
  else{
    vi=1;
  }
  lp(i,s.size()){
    //cout<<mode<<cnt<<endl;
    if('0'<=s[i]&&s[i]<='9'){
      if(mode==0){
	v.push_back(s.substr(i-cnt+1,cnt-1));
	cnt=1;
	mode=1;
      }
      mode=1;
    }
    else{
      if(mode==1){
	v.push_back(s.substr(i-cnt+1,cnt-1));
	cnt=1;
	mode=0;
      }
      mode=0;
    }
    cnt++;
  }
  {
    v.push_back(s.substr(s.size()-cnt+1,cnt-1));
  }
  return;
}

void makex(string s){
  x.clear();
  int mode=2;
  int cnt=1;
  if('0'<=s[0]&&s[0]<='9'){
    xi=0;
  }
  else{
    xi=1;
  }
  lp(i,s.size()){
    //cout<<mode<<cnt<<endl;
    if('0'<=s[i]&&s[i]<='9'){
      if(mode==0){
	x.push_back(s.substr(i-cnt+1,cnt-1));
	cnt=1;
	mode=1;
      }
      mode=1;
    }
    else{
      if(mode==1){
	x.push_back(s.substr(i-cnt+1,cnt-1));
	cnt=1;
	mode=0;
      }
      mode=0;
    }
    cnt++;
  }
  {
    x.push_back(s.substr(s.size()-cnt+1,cnt-1));
  }
  return;
}

signed main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  makev(s);
  /*
  lp(i,v.size()){
    cout<<v[i]<<endl;
  }
  */
  lp(z,n){
    string sx;
    cin>>sx;
    makex(sx);
    if(vi==0&&xi==1){
      cout<<"+"<<endl;
      continue;
    }
    if(vi==1&&xi==0){
      cout<<"-"<<endl;
      continue;
    }
    else{
      int done=0;
      lp(i,min(v.size(),x.size())){
	if(done==1) break;
	string v2=v[i],x2=x[i];
	//cout<<v2<<" "<<x2<<" "<<xi<<endl;
	if(xi==0){
	  if(v2==x2){
	    xi=1;
	    continue;
	  }
	  if(v2.size()>x2.size()){
	    cout<<"-"<<endl;
	    done=1;
	  }
	  else if(v2.size()<x2.size()){
	    cout<<"+"<<endl;
	    done=1;
	  }
	  else{
	    lp(j,v2.size()){
	      if(v2[j]==x2[j]){
		continue;
	      }
	      else{
		if(v2[j]>x2[j]) cout<<"-"<<endl;
		else cout<<"+"<<endl;
		break;
	      }
	    }
	    done=1;
	  }
	  xi=1;
	}
	else{
	  if(v2>x2){
	    cout<<"-"<<endl;
	    done=1;
	  }
	  if(x2>v2){
	    cout<<"+"<<endl;
	    done=1;
	  }
	  xi=0;
	}
      }
      if(done==1) continue;
      if(v.size()>x.size()){
	cout<<"-"<<endl;
      }
      else{
	cout<<"+"<<endl;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3212
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int m,f,r;
    while( scanf("%d%d%d", &m, &f, &r ) && (m>=0 || f>=0 || r>=0)) {
        if(m<0||f<0) {
            printf("F\n");
        }
        else if(m+f>=80) {
            printf("A\n");
        }
        else if(m+f>=65) {
            printf("B\n");
        }
        else if(m+f>=50) {
            printf("C\n");
        }
        else if(m+f>=30) {
            if(r>=50) {
                printf("C\n");
            }
            else {
                printf("D\n");
            }
        }
        else {
            printf("F\n");
        }
    }

    return 0;
}



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

public class Main {

    public static void main(String[] args) {
        try {
            BufferedReader stdReader = 
                    new BufferedReader( new InputStreamReader(System.in));
            String sStr = stdReader.readLine();

            String[] inputStr = sStr.split(" ");
            int w = Integer.valueOf(inputStr[0]).intValue();
            int h = Integer.valueOf(inputStr[1]).intValue();
            int x = Integer.valueOf(inputStr[2]).intValue();
            int y = Integer.valueOf(inputStr[3]).intValue();
            int r = Integer.valueOf(inputStr[4]).intValue();

            if ( w >= x+r && h >=y+r && (x>0 && y>0)) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }

            stdReader.close();
        } catch (Exception e) {
            System.exit(-1);
        } 
    }
}

Measured memory_bytes: 24476
#include<stdio.h>
#include<iostream>
#include<vector>
#include <fstream>
#include<math.h>
#include <numeric>
#include<algorithm>

using namespace std;

int main(){
    int n;
    int sum;
    int tmp;
    int l;
    cin >> n;
    vector<int> v(n , 0);
    for(int i = 0;i < v.size() ;i++){
        cin >> l ;
        v.at(i)  = l;
    } 
    sum = accumulate(v.begin() , v.end() ,0);
    tmp = *max_element(v.begin() , v.end());
    if(tmp >= sum - tmp){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
}


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

int main() {
    int N,K;
    cin >> N >> K;
    vector <int> price(N);
    
    for(int i=0; i<N; i++){
        int a;
        cin >>a;
        price[i]=a;
    }
    
    sort(price.begin() , price.end());
    int ans=0;
        
    for(int i = 0; i<K; i++){
        ans += price[i];
    } cout<<ans<<endl;
}


Measured memory_bytes: 3604
#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(void)
{
    int n, tmp, count=0;
    vector<int> l;

    cin >> n;
    rep(i, n){
        cin >> tmp;
        l.push_back(tmp);
    }

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

    rep(i, n-2){
        rep2(j, i+1, n-1){
            if(l.at(i)==l.at(j)) continue;
            tmp=l.at(i)+l.at(j);
            rep2(k, j+1, n){
                if(l.at(k)==l.at(i)) continue;
                if(l.at(k)==l.at(j)) continue;
                if(tmp<=l.at(k)) continue;
                if(l.at(j)+l.at(k)<=l.at(i)) continue;
                if(l.at(k)+l.at(i)<=l.at(j)) continue;
                count++;
            }
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3620
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end


N=gets.to_i
parts=array(3)
parts[0]=get_i.sort
parts[1]=get_i.sort
parts[2]=get_i.sort

ans=0
parts[1].each do|p|
  head=-1
  tail=N
  next unless parts[0][0]<p
  while tail-head>1
      mid=head+(tail-head)/2
      if parts[0][mid]<p
          head=mid
      else
          tail=mid
      end
  end
  #p "head:#{head}"
  res=head+1
  head=-1
  tail=N
  next unless parts[2][N-1]>p
  while tail-head>1
      mid=head+(tail-head)/2
      if parts[2][mid]>p
        tail=mid
      else
          head=mid
      end
  end
  #p "tail:#{tail}"
  ans+=res*(N-tail)
  #p ans
end
puts ans

Measured memory_bytes: 30568
import sys

def Not_Divisible(n,p):
    maxp = max(p)
    dp = [[True,0] for _ in range(maxp+1)]
    for a in p:
        dp[a][1]+=1
        t =2
        while a*t <= maxp:
            if dp[a*t][0] == True :
                dp[a*t][0] = False
            t+=1
    k=0
    for d in p:
        if dp[d][1] == 1 and dp[d][0] == True:
            k+=1
    return k


def main():
    input = sys.stdin.readline
    
    inp1 = input().rstrip().split()
    n = int(inp1[0])

    inp2 = input().rstrip().split()
    p = tuple(map(int,inp2))
    print(Not_Divisible(n,p))


if __name__ == '__main__':
    main()

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


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

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  ll temp;
  for(int i=0;i<n;i++) {
    cin >> a[i];
    if(i==0) {
      temp=a[i];
    }
    else {
      temp=gcd(temp,a[i]);
    }
  }
  sort(a.begin(), a.end());
  if(k%temp==0&&k<=a[n-1]) {
    cout << "POSSIBLE" << endl;
  }
  else {
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 1024