akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int N, M;
    cin >> N >> M;
    string S;
    cin >> S;

    int seq = N;
    int prev = N+1;
    vi res;
    while(seq>0) {
        int i;
        for(i=max(0, seq-M); i<seq; i++) {
            if(S[i]=='0') break;
            if(i==seq-1) {
                cout << -1 << endl;
                return 0;
            }
        }
        res.pb(seq-i);
        seq = i;
    }

    reverse(ALL(res));

    rep(i, res.size()) cout << res[i] << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a=0,b=0;
  cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  for(int i=0;i<n;i++){
    if(i%2==0)a+=v[i];
    else b+=v[i];
  }
  cout<<abs(b-a)<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
using std::scanf;
using std::printf;

struct Node { int parent, left, right; };

void Preorder(Node tree[], int i) {
  printf(" %d", i);
  if (tree[i].left != -1) { Preorder(tree, tree[i].left); }
  if (tree[i].right != -1) { Preorder(tree, tree[i].right); }
}

void Inorder(Node tree[], int i) {
  if (tree[i].left != -1) { Inorder(tree, tree[i].left); }
  printf(" %d", i);
  if (tree[i].right != -1) { Inorder(tree, tree[i].right); }
}

void Postorder(Node tree[], int i) {
  if (tree[i].left != -1) { Postorder(tree, tree[i].left); }
  if (tree[i].right != -1) { Postorder(tree, tree[i].right); }
  printf(" %d", i);
}

int main() {
  int n;
  scanf("%d", &n);
  Node tree[n];
  for (int i = 0; i < n; ++i) { tree[i].parent = -1; }
  for (int i = 0; i < n; ++i) {
    int id, left, right;
    scanf("%d %d %d", &id, &left, &right);
    tree[id].left = left;
    tree[id].right = right;
    if (left != -1) { tree[left].parent = id; }
    if (right != -1) { tree[right].parent = id; }
  }
  int root;
  for (int i = 0; i < n; ++i) {
    if (tree[i].parent == -1) {
      root = i;
      break;
    }
  }

  printf("Preorder\n");
  Preorder(tree, root);
  printf("\n");
  printf("Inorder\n");
  Inorder(tree, root);
  printf("\n");
  printf("Postorder\n");
  Postorder(tree, root);
  printf("\n");

  return 0;
}

Measured memory_bytes: 2740
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    char[] a = S.toCharArray();
    ArrayList<Character> aa = new ArrayList<>();

	  int ans =0;
      for(int i=0; i<4; i++){
	  if(a[i] == ('+')){
  	   ans++;
      }else{
       ans--;
      }
      }
      System.out.println(ans);
}
}

Measured memory_bytes: 22740
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();

        boolean divisible = false;

        for(int i = 1; i < 10; i++) {
            double divided = (double)N/i;
            int count = 0;
            if(divided%1 == 0 && divided >= 1 && divided <= 9) {
                divisible = true;
            }
        }

        if(divisible) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
}

    }
}

Measured memory_bytes: 21844
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE MagicHash             #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiWayIf            #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}

import           Control.Applicative
import           Control.Exception
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString             as B
import qualified Data.ByteString.Char8       as C
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import qualified Data.Foldable               as F
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import qualified Data.List                   as L
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           GHC.Exts
import           Unsafe.Coerce

main :: IO ()
main = do
    [n, q] <- map read.words <$> getLine :: IO [Int]
    cs <- B.getLine
    lrs <- U.unfoldrN q parseInt2 <$> C.getContents
    putStr.unlines.map show.U.toList $ solve n cs lrs

solve :: Int -> B.ByteString -> U.Vector (Int, Int) -> U.Vector Int
solve n cs lrs = U.map (uncurry query) lrs
  where
    table :: U.Vector Int
    !table = U.scanl' (+) 0 . U.generate n $ \i ->
        if  | i > 0 -> fromEnum $ B.unsafeIndex cs (i - 1) == 65 && B.unsafeIndex cs i == 67
            | otherwise -> 0
    {-# NOINLINE table #-}

    query l r = U.unsafeIndex table r - U.unsafeIndex table l

-------------------------------------------------------------------------------
type Parser a = C.ByteString -> Maybe (a, C.ByteString)

parseInt :: Parser Int
parseInt = C.readInt . C.dropWhile isSpace

parseInt2 :: Parser (Int, Int)
parseInt2 = runStateT $
    (,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt3 :: Parser (Int, Int, Int)
parseInt3 = runStateT $
    (,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt4 :: Parser (Int, Int, Int, Int)
parseInt4 = runStateT $
    (,,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

Measured memory_bytes: 5756
n = int(input())

dic = {}
for _ in range(n):

    s =input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s]=1

maxdic = max(dic.values())

ans = [i for i in dic if dic[i]==maxdic]
print('\n'.join(sorted(ans)))

Measured memory_bytes: 36712
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#ifdef _debug
#define dout(i) cout << #i << ' ' << i << ' '
#else 
#define dout(i) //
#endif
using ll = long long;
using ull = unsigned long long;
using ul = unsigned;
using db = double;
const int p = 998244353;
const int maxv = 1000001;
int n;
const int maxn = 200001;
int cnt[maxv];
int w[maxv];
ll inv[maxv];
void init(){
	static int minf[maxv], pnum[maxv], plen;
	inv[1] = inv[0] = 1;
	for(int i = 2;i < maxv;++i)inv[i] = (p-p/i) * inv[p % i] % p;
	for(int i = 2;i < maxv;++i){
		if(!minf[i])pnum[plen++] = i, minf[i] = i;
		for(auto &v : pnum){
			if(i * v >= maxv)break;
			minf[i * v] = v;
			if(i % v == 0)break;
		}
	}
	for(int i = 1;i < maxv;++i){
		w[i] = (w[i] + inv[i]) % p;
		for(int j = i + i;j < maxv;j += i)w[j] = (w[j] + p - w[i]) % p;
	}
}
ll res;
void cal(int v){
	// static ll pref[maxn], len;
	// len = 0;
	// for(int i = v;i < maxv;i += v)for(int j = 0;j < cnt[i];++j, ++len)pref[len+1] = (pref[len] + i) % p;
	// for(int i = 1;i < len;++i){
		// res = (res + (p + pref[i]-pref[i-1]) % p * (pref[len] - pref[i]) % p * w[pref[i]-pref[i-1]]) % p;
	// }
	ll sum = 0;
	for(int i = v;i < maxv;i += v)sum = (sum + (i * (ll)cnt[i])) % p;
 	res = (res + sum * sum % p * w[v]) % p;
}
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	init();
	cin >> n;
	ll sum = 0;
	for(int v, i = 0;i < n;++i){
		cin >> v;
		++cnt[v];
		sum = (sum + v) % p;
	}
	for(int i = 1;i < maxv;++i)cal(i);
	cout << (res - sum + p) * inv[2] % p << '\n';
}

Measured memory_bytes: 21632
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    replace(S.begin(), S.end(), ',', ' ');
    cout << S << endl;

    return 0;
}


Measured memory_bytes: 256
char*p,tree[99];
leaf[11];
eval(int*ans){
	memset(ans,0,sizeof(int)*16);
	if(*p=='('){
		int l[16],r[16],i,j;
		p++;
		eval(l);
		p++;
		eval(r);
		p++;
		for(i=0;i<16;i++){
			for(j=0;j<16;j++){
				ans[i&j]+=l[i]*r[j];
				ans[i|j]+=l[i]*r[j];
				ans[i^j]+=l[i]*r[j];
			}
		}
	}else{
		ans[leaf[*p-'0']]=1;
		p++;
	}
}
main(){
	int N,i,ans[16];
	for(;scanf("%[^\n]",tree),*tree!='E';){
		scanf("%d",&N);
		for(i=1;i<=N;i++){
			int a,b,c,d;
			scanf("%d%d%d%d\n",&a,&b,&c,&d);
			leaf[i]=a+b*2+c*4+d*8;
		}
		p=tree;
		eval(ans);
		printf("%d\n",ans[15]);
	}
	exit(0);
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

ll f(unsigned long long n) {
  if (n < 2) {
    return 1;
  } else {
    return n * f(n - 2);
  }
}

int main() {
  ll n;
  cin >> n;
  ll res = 0;
  if (n % 2 == 1) {
    res = 0;
  } else {
    n /= 2;
    ll div = 5;
    while (div <= n) {
      res += n / div;
      div *= 5;
    }
  }
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int MAXN=1010;
int n,fa[MAXN],v[MAXN],dp[5*MAXN],f[MAXN];
vector <int> p[1010];
void dfs (int x) {
    for (int ii=0;ii<p[x].size();ii++) {
        dfs(p[x][ii]);
    }
    memset(dp,0x3f,sizeof(dp));
    dp[0]=0;
    for (int ii=0;ii<p[x].size();ii++) {
        int k=p[x][ii];
        //cout << x << "  " << k << "  " << v[k] << "  " << f[k] << endl;
        for (int i=v[x];i>=0;i--) {
            int tmp=0x3f3f3f3f;
            if (i>=v[k]) {
                tmp=min(tmp,dp[i-v[k]]+f[k]);
            }
            if (i>=f[k]) {
                tmp=min(tmp,dp[i-f[k]]+v[k]);
            }
            dp[i]=tmp;
            //cout << x << "  " << i << "  " << dp[i] << endl;
        }
    }
    for (int i=v[x];i>=0;i--) {
        f[x]=min(f[x],dp[i]);
    }
    return;
}
int main () {
    memset(f,0x3f,sizeof(f));
    scanf("%d",&n);
    for (int i=2;i<=n;i++) {
        scanf("%d",&fa[i]);
        p[fa[i]].push_back(i);
    }
    for (int i=1;i<=n;i++) {
        scanf("%d",&v[i]);
    }
    dfs(1);
    if (f[1]<0x3f3f3f3f) {
        printf("POSSIBLE\n");
    } else {
        printf("IMPOSSIBLE\n");
    }
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int a[100009];
long long b[100009]={0};
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int x;
        scanf("%d",&x);
        a[x]=1;
    }
    b[0]=1;
    if(a[1]!=1)b[1]=1;
    else b[1]=0;
    for(int i=2;i<=n;i++)
    {
        if(a[i]==1)
        {
            b[i]=0;
            continue;
        }

        if(a[i-1]==1)
        {
            b[i]=b[i-2]%1000000007;
        }
        else if(a[i-2]==1)
        {
            b[i]=b[i-1]%1000000007;
        }
        else
        {
            b[i]=(b[i-1]%1000000007+b[i-2]%1000000007)%1000000007;
        }

    }
    printf("%lld\n",b[n]);
    return 0;
}


Measured memory_bytes: 1408
#include<iostream>
using namespace std;
main()
{
	int a,b,g,j,s;
	cin>>a>>b;
	g=a*b;
	j=a+b;
	s=a-b;
	if(g>=j && g>=s)
	{
		cout<<g<<endl;
	}
	else if(j>=g && j>=s)
	{
		cout<<j<<endl;
	}
	else if(s>=j && s>=g)
	{
		cout<<s<<endl;
	}
}


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

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        while True:
            e = input()
            if e == 0:
                break
            m = float('inf')
            for z in range(101):
                tmp = e - z ** 3
                if tmp < 0:
                    continue
                y = int(math.sqrt(tmp))
                x = e - y ** 2 - z ** 3
                m = min(m, x + y + z)
            print m
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

Measured memory_bytes: 4708
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef struct node{
  int key;
  struct node *parent, *left, *right;
}Node;

Node *root,*NIL;

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;
  //zの初期設定
  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;

  if(y == NIL) root = z;
  else{ 
    if(z->key < y->key) y->left = z;
    else y->right = z;
  }
}

int find(Node *u,int k){
  while(u != NIL && k != u->key){
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  if(u != NIL) return 1;
  else return 0;
}
  


void inParse(Node *u){
  if(u == NIL) return;
  inParse(u->left);
  printf(" %d",u->key);
  inParse(u->right);
}

void preParse(Node *u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preParse(u->left);
  preParse(u->right);
}

int main(){
  int i,n,k,findCheck;
  char order[10];
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%s",order);
    if(strcmp(order,"insert") == 0){
	scanf("%d",&k);
	insert(k);
  }
    else if(strcmp(order,"print") == 0){
      inParse(root);
      printf("\n");
      preParse(root);
      printf("\n");
    }
    else if(strcmp(order,"find") == 0){
      scanf("%d",&k);
      findCheck = find(root,k);
      if(findCheck == 1) printf("yes\n");
      else printf("no\n");
    }
  }

  return 0;
}

Measured memory_bytes: 19364
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

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

        vector<int> a(n);
        
        REP(i, n) {
                cin >> a[i];

                if (a[i] % 2 == 0) {
                        if (a[i] % 3 && a[i] % 5) {
                                cout << "DENIED" << endl;
                                return 0;
                        }
                }
        }

        cout << "APPROVED" << endl;

        return 0;
}


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

int main(){
	ll n, c, k; cin >> n >> c >> k;
	ll t[n];
	for(int i = 0; i < n; ++i) cin >> t[i];
	sort(t, t + n);
	ll hito = 1, time = t[0];
	ll ans = 1;
	for(int i = 1; i < n; ++i){
		if(t[i] - time <= k && hito < c){
			++hito;
		}else{
			++ans;
			hito = 1;
			time = t[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
N, K = map(int, input().split())
unlike_list = set(map(str, input().split()))

def judge(num):
    for i in str(num):
        if i in unlike_list:
            return False
    return True

ans = False
while not ans:
    if judge(N):
        ans = True
    else:
        N += 1

print(N)

Measured memory_bytes: 9136
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;

int main(){
	int N;
	int a,b,c,d;
	int tp1,tp2;
	
	scanf("%d",&N);
	scanf("%d %d %d %d",&a,&b,&c,&d);
	tp1=N/a;
	if(N%a!=0)
	tp1++;
	tp2=N/c;
	if(N%c!=0)
	tp2++;
	printf("%d\n",min(tp1*b,tp2*d));
}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


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

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>

#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <chrono>
#include <random>

using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<i64>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<i64, i64>;

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

int main() { 
  int n;
  cin >> n;
  vl a(n+1), b(n);
  for(auto&& x:a)cin >> x;
  for(auto&& x:b)cin >> x;
  i64 res = 0LL;
  for(int i=0;i<n;i++){
    if(b[i] <= a[i]){
      res += b[i];
    }
    else{
      res += min(a[i]+a[i+1], b[i]);
      a[i+1] = max(a[i+1] + a[i] - b[i], 0L);
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
using namespace std;
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second&&a.first<b.first);
}

void solve(){
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    int diffx=tx-sx,diffy=ty-sy;
    for(int i=0;i<diffy;i++){
        cout<<"U";
    }
    for(int i=0;i<diffx;i++)
        cout<<"R";
    for(int i=0;i<diffy;i++)
        cout<<"D";
    for(int i=0;i<diffx;i++)
        cout<<"L";
    cout<<"L";
    for(int i=0;i<=diffy;i++)
        cout<<"U";
    for(int i=0;i<=diffx;i++)
        cout<<"R";
    cout<<"DR";
    for(int i=0;i<=diffy;i++)
        cout<<"D";
    for(int i=0;i<=diffx;i++)
        cout<<"L";
    cout<<"U";
}


int main(){
    /*int t;
    cin>>t;
    while(t--)*/
        solve();


    return 0;
}
































































//1-(3+5-2+(3+19-(3-1-4+(9-4-(4-(1+(3)-2)-5)+8-(3-5)-1)-4)-5)-4+3-9)-4-(3+2-5)-10




















Measured memory_bytes: 3600
#include <iostream>

int main(int argc, char ** argv)
{
  int n;
  std::string s, t, ans;
  ans = "";
  std::cin >> n >> s >> t;

  for (int i = 0; i < n; ++i) {
    std::printf("%c", s.at(i));
    std::printf("%c", t.at(i));
  }

  std::puts("");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <tuple>
#include <algorithm>
#include <array>
using namespace std;
using ll = long long;
#define rep(i,n) for(decltype(n) i=0; i<n; ++i)
#define revrep(i,n) for(decltype(n) i=n-1; n>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;

int main() {
    ll ans=0, N, X, T;
    cin >> N >> X >> T;
    ans = (N + X-1)/X * T;
    cout << ans << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef double db;
typedef vector<long long> vecll;
typedef vector<char> vechar;

int main(){
    st s, ans;
    cin >> s;
    ans = s.at(0);
    ans = ans + to_string(s.size() - 2);
    ans = ans + s.at(s.size() - 1);
    
    cout << ans << endl;
}

Measured memory_bytes: 256
from operator import itemgetter

N = int(input())
AB = sorted([list(map(int,input().split())) for i in range(N)])
CD = sorted([list(map(int,input().split())) for i in range(N)])
inf = float('inf')
ans = 0

for bx, by in CD:
    S = list(filter(lambda n:n[0]<bx, AB))
    S = list(filter(lambda n:n[1]<by, S))
    if len(S) != 0:
        S.sort(key=itemgetter(1))
        AB[AB.index(S[-1])] = [inf, inf]
        ans += 1
print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, x[100000];
int ka[100010];
int ka2[100010];
int cnt[100010];
int cnt2[100010];
int ans;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++)cin >> x[i];
	int k = 1;
	ka[n - 1] = 1;
	for (int i = n - 1; i > 0; i--) {
		k *= i;
		k %= mod;
		ka[i - 1] = k;
	}
	k = 1;
	for (int i = 1; i < n; i++) {
		k *= i;
		k %= mod;
		ka2[i] = k;
	}
	cnt[1] = ka2[n - 1];
	cnt2[1] = 1;
	for (int i = 2; i < n; i++) {
		cnt2[i] = (((cnt2[i - 1] * i) % mod) + ka2[i - 1]) % mod;
		cnt[i] = cnt2[i] * ka[i] % mod;
	}
	for (int i = 1; i < n; i++) {
		ans += (x[i] - x[i - 1])*cnt[i];
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4096
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
//ll dx[4] = {1, 0, -1, 0};
//ll dy[4] = {0, 1, 0, -1};

ll dp[1002][1002] = {};
ll a[1002], b[1002];

int main() {
	ll w, n, cnt = 0;
	while (1) {
		cin >> w;
		if (w == 0) break;
		cnt++;
		cin >> n;
		Fill(dp, 0);
		for (int i = 0; i < n; i++) {
			scanf("%d,%d", &a[i], &b[i]);
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= w; j++) {
				dp[i + 1][j] = dp[i][j];
				if (j >= b[i]) dp[i + 1][j] = max(dp[i][j - b[i]] + a[i], dp[i + 1][j]);
			}
		}
		ll worth = dp[n][w];
		ll sum = 0, tmp = 0;
		for (int i = 1; i <= w; i++) {
			if (dp[n][i] > tmp) {
				sum = i;
				tmp = dp[n][i];
			}
		}
		printf("Case %d:\n", cnt);
		printf("%d\n", worth);
		printf("%d\n", sum);
	}

	return 0;
}



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

const int Max=100010;
int n;
char ch[Max];

int main()
{
	scanf("%s",ch+1);
	n=strlen(ch+1);
	if(n&1)
	{
	  if(ch[1]==ch[n]) cout<<"Second";
	  else cout<<"First";
	}
	else
	{
	  if(ch[1]==ch[n]) cout<<"First";
	  else cout<<"Second";
	}
	return 0;
}

Measured memory_bytes: 384
import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as B
main=mapM_ print.solve.map(unfoldr$B.readInt.B.dropWhile isSpace).B.lines=<<B.getContents
solve=map(foldl' g 0).tails.map(\[c,s,f]->(c,s,f)).tail
g t(c,s,f)=(max t s+f-1)`div`f*f+c

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

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

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

const double EPS = 1e-10;

const int N = 1e+5;
const int Q = 50000;
int n, q;
int s[N], t[Q];

int binary_search(int x) {
  int l = -1;
  int r = n;
  int m;
  while (r-l > 1) {
    m = (l+r)/2;
    if (s[m] == x)
      return m;
    else if (x < s[m])
      r = m;
    else
      l = m;
  }
  return -1;
}

int main() {
  int i;
  scanf("%d ", &n);
  for (i=0; i<n; i++)
    scanf("%d ", s+i);
  scanf("%d ", &q);
  for (i=0; i<q; i++)
    scanf("%d ", t+i);

  int res = 0;
  for (i=0; i<q; i++)
    if (binary_search(t[i]) != -1)
      res++;

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

	return 0;
}

Measured memory_bytes: 1776
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,MAX=0,min=0;
  cin>>N;
  vector<int> a(N),col(8);
  for(int i=0;i<N;i++)
    cin>>a.at(i);
  sort(a.begin(),a.end());
  for(int i=0;i<N;i++){
    if(a.at(i)<3200)	col.at(a.at(i)/400)++;
    else{
      MAX=N-i;
      break;
    }
  }
  for(int i=0;i<8;i++){
    if(col.at(i)>0)	min++;
  }
  cout << max(min,1) << " " << min+MAX << endl;
}


Measured memory_bytes: 256
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
    SELECT SYSIN ASSIGN TO KEYBOARD ORGANIZATION LINE SEQUENTIAL.

DATA DIVISION.
FILE SECTION.
FD SYSIN.
    01 INDATA     PIC X(600000).
WORKING-STORAGE SECTION.
01 LN             PIC X(600000).
01 maxlen         PIC 9(6) VALUE 100000.
01 cur            PIC 9(10) VALUE 1.
01 i              PIC 9(18) VALUE 1.
01 j              PIC 9(18).
01 len            PIC 9(10).
01 H              PIC 9(10).
01 N              PIC 9(6).
01 A              PIC 9(5).
01 accum          PIC 9(10).
01 ans            PIC X(3).

PROCEDURE DIVISION.
  ACCEPT LN.
  UNSTRING LN DELIMITED BY SPACE INTO H N.
  OPEN INPUT SYSIN.
  READ SYSIN INTO LN.
  CLOSE SYSIN.
  PERFORM maxlen TIMES
      PERFORM VARYING j FROM cur BY 1 UNTIL LN(j:1) = SPACE
      END-PERFORM
      COMPUTE len = j - cur
      MOVE LN(cur:len) TO A
      ADD A TO accum
      COMPUTE cur = j + 1
      ADD 1 TO i
  END-PERFORM.
  IF H <= accum
      DISPLAY "Yes"
  ELSE
      DISPLAY "No"
  END-IF.


Measured memory_bytes: 1916
#include <iostream>
using namespace std;
int main(){
  int n,p,data[50],i,d,result;
  while(1){
    cin >> n >> p;
    d=p;
    if(n==0&&p==0) break;
    for(i=0;i<n;i++) data[i]=0;
    i=0;
    while(1){
      if(p>0){
    p--;
        data[i]++;
    if(data[i]==d){
      result=i;
      break;
    }
      }else if(p==0){
        p=data[i];
        data[i]=0;
      } 
      if(i+1==n) i=0;
      else i++;
    }
    cout << result << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <tuple>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
	int n;

	cin >> n;
	vector<tuple<long long, long long, char, long long, string> > a(n);

	for (int i = 0; i < n; i++) {
		long long v, w, d;
		char t;
		string s;
		cin >> v >> w >> t >> d >> s;
		a[i] = make_tuple(v, w, t, d, s);
	}

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

	for (int i = 0; i < n; i++)
		cout << get<0>(a[i]) << " " << get<1>(a[i]) << " " 
			<< get<2>(a[i]) << " " << get<3>(a[i]) << " " 
			<< get<4>(a[i]) << endl;

	return 0;
}


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

int main(){
    int n; cin >> n;
    bool ok = true;
    rep(i,n) {
        int a; cin >> a;
        if(a % 2 == 0 && a % 3 != 0 && a % 5 != 0) ok = false;
    }
    if(ok) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
int k,s;
int ans = 0;
cin>>k>>s;
 
for(int a=0;a<=k;a++){
	for(int b=0;b<=k;b++){
		int c = s-a-b;
		if(c>=0 && c<=k){
			ans++;
		}
 
	}
}
 
cout<<ans<<endl;
 
return 0;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353

vector<vector<ll>> connec(110000);
vector<ll> l1(110000,0);
vector<ll> reached1(110000, false);
vector<ll> reached2(110000, false);
vector<ll> l2(110000,-1);

void dfs1(ll x){
	//cout << "dfs1" << x << endl;
	reached1[x] = true;
	if (connec[x].size()!=0){
		REP(i,connec[x].size()){
			if (reached1.at(connec[x][i])==false){
				//cout << "つながり" << connec[x][i] << endl;
				l1.at(connec[x][i]) = l1.at(x)+1;
				dfs1(connec[x][i]);
			}
		}
	}
	return;
}

void dfs2(ll x){
	//cout << "dfs2" << x << endl;
	reached2[x] = true;
	if (connec[x].size()!=0){
		REP(i,connec[x].size()){
			if (reached2.at(connec[x][i])==false){
				//cout << "つながり" << connec[x][i] << endl;
				if (l1.at(connec[x][i])== l2.at(x)+1){
					l2.at(connec[x][i]) = l2.at(x)+1;
				}
				else{
					l2.at(connec[x][i]) = l2.at(x)+1;
					dfs2(connec[x][i]);
				}
			}
		}
	}
	return;
}


int main(){
	ll n, u, v; cin >> n >> u >> v;
	REP(i,n-1){
		ll a, b; cin >> a >> b;
		connec[a-1].pb(b-1);
		connec[b-1].pb(a-1);
	}
	dfs1(v-1);
	l2.at(u-1) = 0;
	dfs2(u-1);
	ll ans = 0;
	REP(i,n){
		//cout << l1.at(i) << " " << l2.at(i) << endl;
		if (l2.at(i)!=-1 && l1.at(i)>l2.at(i)){
			ans = max(ans,l1.at(i)-1);
		}
		else if (l1.at(i) == l2.at(i)){
			ans = max(ans,l2.at(i));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 13440
#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 <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(true){
        c -= b;
        if (c <= 0){
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;

        if (a <= 0){
            cout << "No" << endl;
            return 0;
        }
    }

    return 0;
}


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

using namespace std;

#define allof(x) (x).begin(), (x).end()

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

const int MAXN = 11;

int D, G;
int point[MAXN];
int P[MAXN], C[MAXN];

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

    cin >> D >> G;

    G /= 100;

    for(int a = 1; a <= D; a++){
        cin >> P[a] >> C[a];
        C[a] /= 100;
    }

    int ans = 1e9;
    for(int state = 0; state < (2 << D); state += 2){
        int tot = 0;
        int solved = 0;
        for(int a = 1; a <= D; a++){
            if(state & (1 << a)){
                solved += P[a];
                tot += P[a] * a + C[a];
            }
        }

        for(int a = D; a >= 1 && tot < G; a--){
            if(state & (1 << a)){
                continue;
            }

            int diff = (G - tot + a - 1) / a;
            solved += min(diff, P[a]);
            tot += min(diff, P[a]) * a;
        }

        ans = min(ans, solved);
    }

    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

string lefthand = "qwertasdfgzxcvb";
string righthand = "yuiophjklnm";

signed main() {
    string s;
    while(cin >> s, s != "#") {
        int prev = -1, ans = 0;
        rep(i,0,s.length()) {
            int cur;
            if(lefthand.find(s[i]) != string::npos) cur = 0;
            else cur = 1;
            if(prev != -1 && prev != cur) ans++;
            prev = cur;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		int[] a = new int[m];
		int[] b = new int[m];
		for (int i = 0; i < m; i++) {
			sa = br.readLine().split(" ");
			a[i] = Integer.parseInt(sa[0]) - 1;
			b[i] = Integer.parseInt(sa[1]) - 1;
		}
		br.close();

		boolean[] ok = new boolean[n];
		for (int i = 0; i < m; i++) {
			if (a[i] == 0) {
				ok[b[i]] = true;
			}
		}
		for (int i = 0; i < m; i++) {
			if (b[i] == n - 1 && ok[a[i]]) {
				System.out.println("POSSIBLE");
				return;
			}
		}
		System.out.println("IMPOSSIBLE");
	}
}


Measured memory_bytes: 60404
def euc(x, y):
	if y == 0: return x
	return euc(y, x%y)

N = int(input())
A = list(map(int, input().split()))
now = A[0]
for i in range(1, N):
	now = (now*A[i])//euc(now, A[i])
print(now)


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

int h,w;
char t[200][200];

int main(){
  while(cin>>h>>w,h||w){
    for(int i=0;i<h;i++){
      cin>>t[i];
    }

    int x=0,y=0;
    bool loopFlg = false;

    while(1){
      int nx = x;
      int ny = y;
      if(t[y][x] == '>') nx++;
      else if(t[y][x] == '<') nx--;
      else if(t[y][x] == '^') ny--;
      else if(t[y][x] == 'v') ny++;
      else if(t[y][x] == '?'){
        loopFlg = true;
        break;
      }
      else{
        break;
      }
      t[y][x] = '?';
      x = nx;
      y = ny;
    }

    if(loopFlg){
      cout<<"LOOP\n";
    }
    else{
      cout<<x<<" "<<y<<endl;
    }
  }
}

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

int main(){
  string S;
  bool good = true;

  cin >> S;

  for (int i = 0; i < S.size(); i++){
    if ((i + 1) % 2 == 0 && S.at(i) == 'R') good = false;
    else if ((i + 1) % 2 != 0 && S.at(i) == 'L') good = false;     
  }

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

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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;}
vector<vector<int>> v(8);
int n;
int func(vector<bool> y,int x,int count){
    vector<bool> w=y;
    w[x]=true;
    int tmp=0;
    if(count==n){
        return 1;
    }
    for(auto& i:v[x]){
        if(!w[i]){
            tmp+=func(w,i,count+1);
        }
    }
    return tmp;
}
int main()
{
    int m;
    cin >> n >> m;
    REP(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    vector<bool> w(n,false);
    int ans=func(w,0,1);
    cout << ans << endl;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
L = []
for _ in range(K):
  l,r = map(int,input().split())
  L.append((l,r))
DP = [0] * N
DP[0] = 1
con = [0] * (N + 1)
con[1] = 1
for i in range(1 , N):
  s = 0
  for l,r in L:
    s += con[max(0 , i - l + 1)] - con[max(0 , i - r)]
  DP[i] = s
  con[i + 1] = (con[i] + DP[i]) % 998244353
  
print(DP[N - 1] % 998244353)

      
      
      


Measured memory_bytes: 25032
//
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

int main(){

    ll a, b, c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b << endl;

    return 0;
}

Measured memory_bytes: 256
/*
		@Author :- Gaurav Bharti
		National Institute of Technology, Jamshedpur.
*/
 
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define empb emplace_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define vii vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define mapii map<int,int> 
#define mapll map<ll,ll>
#define all(a) a.begin(),a.end()
#define test ll t; cin>>t; while(t--)
#define prec(n) fixed<<setprecision(n)
#define jaldibazi ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007




int main(){
	jaldibazi;

	int n; cin >> n;
 	vector<int> v(n);
  	for(int i = 0; i < n; ++i) cin >> v[i];
  	sort(v.begin(), v.end());
  	int ans = 0;
  	for(int i = 0; i < n; ++i){
    	for(int j = i+1; j < n; ++j){
      		for(int k = j+1; k < n; ++k){
        		if((v[i]!=v[j]) and (v[i]!=v[k]) and (v[j]!=v[k])){
            		if(v[i]+v[j] > v[k]) ++ans;
           		}
      		}
    	}
  	}
  	cout << ans;  

	return 0;
}


Measured memory_bytes: 3600
n = int(input())
a = list(map(int, input().split()))

x = [0] * n
x[0] = sum(a) - 2 * sum([a[i] for i in range(1, n, 2)])
for i in range(n - 1):
    x[i + 1] = 2 * a[i] - x[i]

print((' ').join(map(str, x)))

Measured memory_bytes: 19144
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i,N)
  {
    cin >> A[i];
    A[i] --;
  }
  vector<ll> number(N);
  rep(i,N)
  {
    number[A[i]] ++;
  }
  ll sum = 0;
  rep(i,N)
  {
    sum += number[i]*(number[i]-1)/2;
  }
  rep(i,N)
  {
    if(number[A[i]]==1)
    {
      cout << sum << endl;
    }
    else if(number[A[i]]==2)
    {
      cout << sum - 1 << endl;
    }
    else
    {
      cout << sum - number[A[i]]*(number[A[i]]-1)/2 + (number[A[i]]-2)*(number[A[i]]-1)/2 << endl;
    }
    
  }
  return 0;
}


Measured memory_bytes: 5760
#include<iostream>

using namespace std;

int main(){
    int n,x;
    cin >> n >> x;
    int minM = 2000;
    for (int i=0;i<n;i++){
        int m;
        cin >> m;
        x-=m;
        if (m<minM)minM=m;
    }
    cout << n+x/minM << endl;
    return 0;
}


Measured memory_bytes: 256
N, A, B, C = gets.split.map(&:to_i)
S = N.times.map { gets.chomp }

ans = []
counter = Hash.new(0)
counter['A'] = A
counter['B'] = B
counter['C'] = C

N.times do |i|
  s1, s2 = S[i].chars

  if counter[s1] == 0 && counter[s2] == 0
    puts 'No'
    exit
  end

  if i == N - 1
    if counter[s1] < counter[s2]
      counter[s1] += 1
      counter[s2] -= 1
      ans << s1
    else
      counter[s2] += 1
      counter[s1] -= 1
      ans << s2
    end
  else
    if counter[s1] < counter[s2]
      counter[s1] += 1
      counter[s2] -= 1
      ans << s1
    elsif counter[s1] > counter[s2]
      counter[s2] += 1
      counter[s1] -= 1
      ans << s2
    else
      ns1, ns2 = S[i + 1].chars

      if s1 == ns1 && s2 == ns2
        counter[s1] += 1
        counter[s2] -= 1
        ans << s1
      else
        t = ([s1, s2] & [ns1, ns2]).first

        if s1 == t
          counter[s1] += 1
          counter[s2] -= 1
          ans << s1
        else
          counter[s2] += 1
          counter[s1] -= 1
          ans << s2
        end
      end
    end
  end
end

puts 'Yes'
puts ans


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

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		
		int ans = 0;
		for(int i = 1; i <= n; i++) {
			ans += i;
		}
		
		System.out.println(ans);
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 32712
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int[] h = getIntArr(in, n);
		int r = solve(h);
		System.out.println(r);
		in.close();
	}

	private static int solve(int[] h) {
		int[] state = new int[h.length];
		state[1] = Math.abs(h[1] - h[0]);
		for (int i = 2; i < h.length; i++) {
			state[i] = Math.min(state[i - 1] + Math.abs(h[i] - h[i - 1]), state[i - 2] + Math.abs(h[i] - h[i - 2]));
		}
		return state[state.length - 1];
	}

	static String str(int[] a) {
		String[] str = new String[a.length];
		for (int i = 0; i < a.length; i++) {
			str[i] = a[i] + "";
		}
		return String.join(" ", str);
	}

	static int[] getIntArr(Scanner in, int size) {
		int[] arr = new int[size];
		for (int i = 0; i < size; i++) {
			arr[i] = in.nextInt();
		}
		return arr;
	}

	static int[][] getIntArr(Scanner in, int row, int col) {
		int[][] arr = new int[row][];
		for (int i = 0; i < row; i++) {
			arr[i] = getIntArr(in, col);
		}
		return arr;
	}

	static char[] getCharArr(Scanner in, int size) {
		char[] arr = in.next().toCharArray();
		return arr;
	}

	static String[] getStringArr(Scanner in, int size) {
		String[] arr = new String[size];
		for (int i = 0; i < size; i++) {
			arr[i] = in.next();
		}
		return arr;
	}

	static Map<Integer, List<Integer>> getEdges(Scanner in, int size, boolean directed) {
		Map<Integer, List<Integer>> edges = new HashMap<>();
		for (int i = 0; i < size; i++) {
			int from = in.nextInt();
			int to = in.nextInt();
			if (!edges.containsKey(from)) {
				edges.put(from, new ArrayList<Integer>());
			}
			edges.get(from).add(to);
			if (!directed) {
				if (!edges.containsKey(to)) {
					edges.put(to, new ArrayList<Integer>());
				}
				edges.get(to).add(from);
			}

		}
		return edges;
	}
}


Measured memory_bytes: 53204
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <bitset>
#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;


int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		if (t % 2 == 0) {
			if (t % 3 == 0 || t % 5 == 0) {

			}
			else {
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}
	cout << "APPROVED" << endl;
}









Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#pragma warning(disable : 4996) //_CRT_SECURE_NO_WARNINGS

int comp(const void* a, const void* b) {
	return *(int*)a - *(int*)b;
}

int main(void) {
	int K, N;
	int res = 0;
	scanf("%d%d", &K, &N);
	int* list;
	int* distance;
	list = (int*)malloc(sizeof(int) * N);
	distance = (int*)malloc(sizeof(int) * N);
	for (int i = 0;i < N;i++) {
		scanf("%d", &list[i]);
	}
	for (int i = 0;i < N-1;i++) {
		distance[i] = list[i + 1] - list[i];
		res += distance[i];
	}
	distance[N-1] = K - res;
	res = 0;
	qsort(distance, N, sizeof(int), comp);
	for (int i = 0;i < N-1;i++) {
		res += distance[i];
	}
	printf("%d", res);
	free(list);
	list = NULL;
	free(distance);
	distance = NULL;
	return 0;
}

Measured memory_bytes: 2556