akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for (long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for (long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                           \
    (upper_bound((V).begin(), (V).end(), X) - \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                             \
    {                                        \
        cerr << #v << ':';                   \
        for (auto xv : v) cerr << xv << ' '; \
        cerr << endl;                        \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
    return a > b;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* library */

/* main */

signed main() {
    ll N;
    cin >> N;
    vl d(N);
    for (auto &x : d) cin >> x;
    sort(ALL(d));
    ll ans = 0;
    FOR(i, 0, 100001) {
        ll tmp = d.end() - lower_bound(ALL(d), i);
        if (tmp * 2 == N) ans += 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
n = int(input())
vl = list(map(int, input().split()))

zero_d = {}
one_d = {}
for i,v in enumerate(vl):
    if i%2 == 0:
        zero_d.setdefault(v,0)
        zero_d[v] += 1
    else:
        one_d.setdefault(v,0)
        one_d[v] += 1

zero_l = sorted(zero_d.items(), reverse=True, key=lambda x:x[1])
one_l = sorted(one_d.items(), reverse=True, key=lambda x:x[1])


zero_l.append((-1,0))
one_l.append((-1,0))

zero_cnt = (n+1)//2
one_cnt = n//2
if zero_l[0][0] != one_l[0][0]:
    ans = n - zero_l[0][1] - one_l[0][1]
else:
    ans1 = n - zero_l[0][1] - one_l[1][1]
    ans2 = n - zero_l[1][1] - one_l[0][1]
    ans = min(ans1,ans2)

print(ans)

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

//Function Macros:
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main()
{
    int A, B;
    cin >> A >> B;
    int ans = 0;
    ans += max(A, B);
    if (A > B)
        A--;
    else
        B--;
    ans += max(A, B);
    cout << ans << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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 long long ll;
typedef pair<int, int> P;

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    ll X, Y;
    cin >> X >> Y;

    int ans = 1;
    while (X * 2 <= Y) {
        ans++;
        X *= 2;
    }

    cout << ans << endl;
}

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

#define endl "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)

int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) {
        if (b & 1) res = (res * a) % m;
        a = (a * a) % m; b >>= 1;
    } return res;
}

int now() {
    return chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now()
    .time_since_epoch()).count();
}

int32_t main() { fastio;
    time_t start = now();

    string s; cin >> s;
    if (s == "AAA" or s == "BBB") {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    cerr << "TIME => " << now() - start << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;
#define pi 3.1415926

int a[(int)2e5][11];

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && a != c && b != c)
        cout << "Yes";
    else if(a == c && a != b && b != a)
        cout << "Yes";   
    else if(c == b && a != c && b != a)
        cout << "Yes";
    else
        cout << "No";
    
}

    

		


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
#include <cstring>

using namespace std;

string s;

int main(){
	cin>>s;
	int l=s.size();
	cout<<s[0]<<l-2<<s[l-1]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
map<int,int>d;
int main(void){
    int n,m;
    cin>>n;
    for(int i=0;i<n;i++){
        int num;
        cin>>num;
        d[num]++;
    }
    cin>>m;
    for(int i=0;i<m;i++){
        int num;
        cin>>num;
        if(d[num]==0){
            cout<<"NO"<<endl;
            return 0;
        }
        d[num]--;
    }
        cout<<"YES"<<endl;
        return 0;
    
}

Measured memory_bytes: 9600
/*
 
                              Jai Shree Krishna !!
                                 Radhe Radhe !!
                                 
             उद्यमेन हि सिद्ध्यन्ति कार्याणि न मनोरथैः। नहि सुप्तस्य सिंहस्य मुखे प्रविशन्ति मृगाः।।
             
*/
   
   
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
typedef long long ll;
#define loop(i,n)  for(int i=0;i<n;i++)
#define ford(i,a,b) for(int i=b;i>=a;i--)
#define read(a) int a; cin >>a;
#define readarr(a,n) int a[n] ; for(int i=0;i<n;i++) cin >> a[i];
#define readmat(a,n,m) int a[n][m]; for(int i=0;i<n;i++) for(j=0;j<m;j++) cin >> a[i][j];
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define pi pair<int,int>
#define vii vector<vector<int>>
#define sti set<int>
#define vpi vector<pair<int,int>>
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define printmat(a,n,m) for(int i=0;i<n;i++) {for(j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define endl "\n"
#define mp make_pair
const ll inf = 1e18;
const ll mod = 1e9 + 7;
 
// vii ans;
// void allPossibleSubset(int arr[],int n)
// {
// 	int  count = pow(2,n);
// 	// The outer for loop will run 2^n times to print all subset .
// 	// Here variable i will act as a binary counter
// 	for (int i = 0; i < count; i++)
// 	{
// 		// The inner for loop will run n times , As the maximum number of elements a set can have is n
// 		// This loop will generate a subset
// 		vi v;
// 		for (int j = 0; j < n; j++)
// 		{
// 			// This if condition will check if jth bit in binary representation of  i  is set or not
// 			// if the value of (i & (1 << j)) is greater than 0 , include arr[j] in the current subset
// 			// otherwise exclude arr[j]
// 			if ((i & (1 << j)) > 0)
// 				v.pb(arr[j]);
// 		}
// 		ans.pb(v);
// 	}
	
// }

signed main()
{
 
    fast;
    int n,k;
    cin >> n >> k;
    vi a(n+1);
    for(int i=1;i<=n;i++){
    	cin >> a[i];
    }
    int s=a[1];
    
    vector<bool>  vis(n+1);
    vis[1]=1;
    int r=0;
    while(r<k){
    	if(!vis[s])
    	{
    		// cout<<s<<" ";
    		vis[s]=true;
    		int pr=s;
    		s=a[s];
    		r++;
    		if(r==k){
    			s=pr;
    			break;
    		}
    	}
    	else {
    		break;
    	}
    }
    // cout<<endl;
     //cout<<k<<endl;
    if(k==r) cout<<s<<endl;
    else{
    	k-=(r+1);
    	vector<int> vs(n+1);
    	int y=0;
    	vector<int> path;
    	while(1){
    		if(!vs[s]){
    			path.pb(s);
    			vs[s]=true;
    			s=a[s];
    			y++;
    		}
    		else
    		break;
    	}
    	int b = k%y;
    	cout<<path[b]<<endl;
    }
    return 0;
}
 
/* Pooja Yadav */

Measured memory_bytes: 8368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll a, b, c;
    cin>>a>>b>>c;
    ll ans = 1e18;
    ans = min(ans, (a&1)*b*c);
    ans = min(ans, (b&1)*a*c);
    ans = min(ans, (c&1)*a*b);
    cout<<ans<<'\n';

}


Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(datN) = readLine.split(" ").map(_.toLong)

    def makeDivisor(n: Long): Vector[Long] = {
      //for(i <- 1 to (math.sqrt(n).toInt + 1) if(i % 2 == 0)) yield i
      ((1 to (math.sqrt(n).toInt)).filter(i => n % i == 0)).map(_.toLong).toVector
    }
    val divN = makeDivisor(datN)

    def countDigit(a: Long): Int = {
      a.toString.split("").filterNot(_ == "").length
    }
    val ans = divN.foldLeft(100000)((acc, dat) =>
      math.min(acc, math.max(countDigit(dat), countDigit(datN / dat)))
    )

    println(ans)
  }
}


Measured memory_bytes: 33328
N,M = map(int, input().split())
piys = [[] for _ in range(N)] 
for i in range(M):
    p, y = map(int, input().split())
    piys[p-1].append((y,i))
    
ans = [None]*M
for p,iys in enumerate(piys):
    iys.sort()
    for k,(y,i) in enumerate(iys):
        ans[i] = "%06d%06d" % (p+1,k+1)
 
for i in ans:
    print(i)

Measured memory_bytes: 35892
n,k,c = map(int,input().split())
s = [True if i == "o" else False for i in input()]
front = [0] * n
back = [0] * n
count = 0

day = 0
while day < n:
    if s[day]:
        front[day] = 1
        day += c+1
        count += 1
    else:
        day += 1

day = n-1
while day >= 0:
    if s[day]:
        back[day] = 1
        day -= c+1
    else:
        day -= 1
if count == k:
    for i in range(n):
        if front[i] == 1 and back[i] == 1:
            print(i+1)

Measured memory_bytes: 9380
import java.io.*;

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

	BufferedReader br =
	 new BufferedReader(new InputStreamReader(System. in));

	String str = br.readLine();
	int x = Integer.parseInt(str);

	System.out.println( x*x*x );
 
 }
 }

Measured memory_bytes: 24364
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
public class Main{
	 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int max = 0;
		for(int i = 1; i <= n-1; i++) {
			int c = i;
			int count = 0;
			for(char j = 'a'; j <= 'z'; j++) {
				boolean l = false;
				boolean r = false;
				for(int k = 0; k < c; k++) {
					if(s.charAt(k)==j){
						l = true;
						break;
					}
				}
				for(int k =c; k < n; k++) {
					if(s.charAt(k)==j){
						r = true;
						break;
					}
				}
				if(l&&r) count++;
			}
			max = Math.max(max, count);
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 36232
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

typedef pair<int, int> pii;

struct Data {
	int x, y, cnt;
	Data() {}
	Data(int x, int y, int cnt) : x(x), y(y), cnt(cnt) {}
};

int n, m, p, q, r;

int main() {
	while (cin >> n, n) {
		cin >> m >> p >> q >> r;
		p--; q--;
		
		vector<Data> data;
		data.push_back(Data(0, n, r));
		
		REP(i, m) {
			int x, y;
			scanf("%d %d", &x, &y);
			
			vector<pii> res[3]; // ???????????§??????, r??\???????????°
			
			int c[3] = {x, y - x, n - y};
			pii pos = pii(0, 0); // i,j  data???i?????????j?????§??????
			
			REP(i, 3) {
				int cnt = c[i];
				
				while (cnt > 0) {
					int len = data[pos.first].y - data[pos.first].x;
					int diff = min(cnt, len - pos.second);
					
					res[i].push_back(pii(diff, max(0, min(data[pos.first].cnt - pos.second, diff))));
					
					cnt -= diff;
					pos.second += diff;
					
					if (pos.second == len)
						pos = pii(pos.first + 1, 0);
					
				}
			}
			
			data.clear();
			int cnt = 0;
			for (int i = 2; i >= 0; i--) {
				REP(j, res[i].size()) {
					data.push_back(Data(cnt, cnt + res[i][j].first, res[i][j].second));
					cnt += res[i][j].first;
				}
			}
		}
		
		int ans, pos = 0;
		while (data[pos].y <= p) pos++;
		
		ans = max(0, data[pos].cnt - (p - data[pos].x));
		
		if (data[pos].y > q) {
			ans = min(ans, q - p + 1);
		}
		else {
			pos++;
			while (data[pos].y <= q) ans += data[pos++].cnt;
			ans += min(data[pos].cnt, q - data[pos].x + 1);
		}
		
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3272
N = int(input())
A = W = T = R = 0
for i in range(N):
  S = input()
  if S == "AC":
    A+=1
  elif S == "WA":
    W +=1
  elif S =="TLE":
    T +=1
  else:
    R +=1
for judge, c in zip(["AC","WA","TLE","RE"],[A,W,T,R]):
  print(judge+" x "+ str(c))

Measured memory_bytes: 9204
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll

#include <bits/stdc++.h>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace std;
const long long N=200005, INF=2000000000000000000;
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    string s,t;
    cin>>s>>t;
    int n=s.size(), m=t.size();
    s=' '+s;
    t=' '+t;
    int dp[n+1][m+1];
    fill(dp, 0);
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(s[i]==t[j])
            {
                if(dp[i-1][j-1]==dp[i-1][j])
                dp[i][j]=max(dp[i][j], dp[i-1][j]+1);
                else
                dp[i][j]=max(dp[i][j], dp[i-1][j]);
                if(dp[i-1][j-1]==dp[i][j-1])
                dp[i][j]=max(dp[i][j], dp[i][j-1]+1);
                else
                dp[i][j]=max(dp[i][j], dp[i][j-1]);
            }
            else
            dp[i][j]=max({dp[i][j], dp[i-1][j], dp[i][j-1]});
        }
    }
    char ch[dp[n][m]+1];
    ch[0]=' ';
    int ind=dp[n][m],i=n,j=m;
    while(i>0&&j>0)
    {
        if(s[i]==t[j])
        {
            ch[ind]=s[i];
            ind--;i--;j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
        i--;
        else
        j--;
    }
    for(int i=1;i<=dp[n][m];i++)
    cout<<ch[i];
    if(dp[n][m]==0)
    cout<<ch[0];
}

Measured memory_bytes: 70656
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cctype>
#include<string>
using namespace std;

string toUpper(string s) {
	string t = s;
	for (int i = 0; i < s.size(); i++) {
		t[i] = toupper(s[i]);
	}
	return t;
}


int main()
{
	int cnt = 0;
	string W, temp;
	cin >> W;
	W = toUpper(W);
	while (1) {
		cin >> temp;
		if (temp == "END_OF_TEXT")break;
		temp = toUpper(temp);
		if (temp == W)cnt++;
	}
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 3176
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(declaim (ftype (function * (values (vector (integer 0 #.most-positive-fixnum)) &optional))
                enum-divisors))
(defun enum-divisors (x)
  "Enumerates all the divisors of X. Note that the returned vector is NOT
sorted."
  (declare ((integer 0 #.most-positive-fixnum) x))
  (let* ((sqrt (isqrt x))
         (res (make-array (isqrt sqrt) ; FIXME: sets the initial size to x^1/4
                          :element-type '(integer 0 #.most-positive-fixnum)
                          :fill-pointer 0)))
    (loop for i from 1 to sqrt
          do (multiple-value-bind (quot rem) (floor x i)
               (when (zerop rem)
                 (vector-push-extend i res)
                 (unless (= i quot)
                   (vector-push-extend quot res)))))
    res))

(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (let* ((n (read))
         (divs (enum-divisors n)))
    (println
     (loop for d across divs
           for m = (- d 1)
           for a = (floor n d)
           when (< a m)
           sum m))))

#-swank(main)


Measured memory_bytes: 19040
#include<iostream>
#include<string>
#include <cmath>
#include <ctype.h>
using namespace std;
int a, b, c, d;
int main() {
    cin >> a >> b >> c >> d;
    if(a*b>=c*d) cout << a*b<< endl;
    else cout << c*d << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>
#include <map>
#include<cmath>
#include<queue>

typedef long long ll;
using namespace std;
#define mod 10007
#define rep(i,n) for(ll i=0;i<n;i++)
#define out(s) cout << s << endl
string s;
ll c0=0,c1=0;
int main(){
    cin >> s;
    for(char c:s){
        if(c=='0')c0++;
        if(c=='1')c1++;
    }
    ll ans=min(c0,c1);
    cout << 2*ans << endl;
    return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void Calc()
    {
        cin = new Scanner();

        int N = cin.nextInt();
        int M = cin.nextInt();

        //int[] flags = new int[N];

        int left = 0;
        int right = int.MaxValue;

        bool flag = true;

        for (int i = 0; i < M; ++i)
        {
            int L = cin.nextInt();
            int R = cin.nextInt();
            if (left < L) { left = L; }
            if (right > R) { right = R; }

            if (right < left)
            {
                flag = false;
                break;
            }
        }

        int ans = 0;

        if (flag)
        {
            ans = right - left + 1;
        }

        WriteLine(ans);
    }
}

public static class StringExtension
{
    public static char GetChar1(this string str, int indexOneBase)
    {
        return str[indexOneBase - 1];
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


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

int main(){
    string s;
    cin >>s;
    int N = s.size();
    map<char, bool> checker;  //アルファベットごとにあるんかないんかを記録するmapを拵える。
    for(char x = 'a'; x<='z'; x++){
        checker[x] = false;
    }
    for(char c: s){
        checker[c] = true;
    }
    bool notexists = true; //登場しないヤツがいないか
    for(char c = 'a'; c <= 'z'; c++){
        if(checker[c] == false){
            cout << c << endl;
            notexists = false;
            break;
        }
    }
    if(notexists) cout << "None" << endl;
}

Measured memory_bytes: 512
smallLargeOrEqual :: Ord a => [a] -> String
smallLargeOrEqual [a, b] | a < b = "a < b"
                         | a > b = "a > b"
                         | a == b = "a == b"

main = putStrLn . smallLargeOrEqual . map (read :: String -> Int) . words =<< getLine

Measured memory_bytes: 3456
#include <stdio.h>

int main(void)
{
	
	double r,m,s; 
	scanf("%lf",&r);
	((0<r)&&(r<=10000));
	s=r*r*3.1415926535897932384626;
	m=2*r*3.1415926535897932384626;
	printf("%f %f\n",s,m);
	
	return 0;
}

Measured memory_bytes: 648
N = int(input())
*A, = map(int,input().split())

Y = [1000] * N

for i in range(N):
    a = A[i]
    y = Y[i]
    n = y//a
    for j in range(i+1,N):
        b = A[j]
        Y[j] = max(Y[j],y + (b-a)*n,y)

print(Y[-1])

Measured memory_bytes: 9132
#include <iostream>
using namespace std;
int n,m,i,j,x,num[100005],cnt[5];
string st;
int main()
{
	ios::sync_with_stdio(0);
	cin>>n;
	for (i=1;i<=n;i++)
	{
		cin>>x;
		while (x%2==0&&num[i]<2)
		{
			num[i]++;
			x/=2;
		}
		cnt[num[i]]++;
	}
	if (cnt[2]+1>=cnt[0]+((bool)(cnt[1]))) cout<<"Yes"; else cout<<"No";
	return 0;
}

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;
ll a[maxn];
ll cnt[maxn];
void run_case()
{
    int n;
    cin >> n;
    ll sum = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        sum += 1ll * a[i];
        cnt[a[i]]++;
    }
    int q;
    cin >> q;
    while (q--)
    {
        int b, c;
        cin >> b >> c;
        sum = sum - cnt[b] * b + cnt[b] * c;
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << sum << "\n";
    }
    //cout << sum << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 5152
from functools import reduce

def main():
    mod = 10 ** 9 + 7

    X, Y = map(int, input().split())

    b = (2 * X - Y) // 3
    a = (-X + 2 * Y) // 3

    if (X + Y) % 3 != 0 or a < 0 or b < 0:
        print(0)
        quit(0)

    n, k = a + b, a
    k = min(k, n - k)
    mod_mul = lambda a, b: a * b % mod
    numer = reduce(mod_mul, range(n - k + 1, n + 1), 1)
    denom = reduce(mod_mul, range(1, k + 1), 1)

    print(numer * pow(denom, mod - 2, mod) % mod)

main()


Measured memory_bytes: 3572
#include<stdio.h>

int main(void)
{
	char c[1024];
	gets(c);
	char *p=&c[0];
	char *q=p;
	int len=0;
	char *w[1024];
	int n=0;
	while(1){
		if(*p==','||*p==' '||*p=='.'||*p=='\n'||*p==EOF){
			char tmp=*p;
			if(2<len&&len<7){
				w[n]=q;
				*p='\0';
				n++;
			}
			if(tmp=='\n'||tmp==EOF){
				break;
			}
			len=0;
			p+=sizeof(char);
			q=p;
		}else{
			len++;
			p+=sizeof(char);
		}
	}
	printf("%s",w[0]);
	for(int i=1;i<n;i++){
		printf(" %s",w[i]);
	}printf("\n");
	return 0;
}

Measured memory_bytes: 940
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

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

int ab(int a, int b){return a>b?a-b:b-a;}

char ans[5][6];
int main(void){
	int n, k, i, j;
	char s[5001];
	scanf("%s%d", s, &k);
	n=strlen(s);
	int len=0;

	for(i=0; i<n; i++){
		for(j=1; j<=k; j++){
			int l=strnlen(s+i, j);
			char str[10];
			strncpy(str, s+i, l); str[l]=0;

			if(len==0 || strcmp(str, ans[0])<0){
				strcpy(ans[4], ans[3]);
				strcpy(ans[3], ans[2]);
				strcpy(ans[2], ans[1]);
				strcpy(ans[1], ans[0]);
				strcpy(ans[0], str);
				len++;
			}else if(strcmp(str, ans[0])==0){
			}else if(len==1 || strcmp(str, ans[1])<0){
				strcpy(ans[4], ans[3]);
				strcpy(ans[3], ans[2]);
				strcpy(ans[2], ans[1]);
				strcpy(ans[1], str);
				len++;
			}else if(strcmp(str, ans[1])==0){
			}else if(len==2 || strcmp(str, ans[2])<0){
				strcpy(ans[4], ans[3]);
				strcpy(ans[3], ans[2]);
				strcpy(ans[2], str);
				len++;
			}else if(strcmp(str, ans[2])==0){
			}else if(len==3 || strcmp(str, ans[3])<0){
				strcpy(ans[4], ans[3]);
				strcpy(ans[3], str);
				len++;
			}else if(strcmp(str, ans[3])==0){
			}else if(len==4 || strcmp(str, ans[4])<0){
				strcpy(ans[4], str);
				len++;
			}
		}
	}
	printf("%s\n", ans[k-1]);
}


Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int N = Integer.parseInt(scan.next());
		int M = Integer.parseInt(scan.next());
		System.out.println((long)((1900*M + 100*(N-M))*Math.pow(2, M)));
	}
}

//end

Measured memory_bytes: 21588
# include <cstdio>
# include <iostream>

using namespace std;

int n;
long long a[10005],b[10005],u,d;

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i)
		scanf("%lld",&a[i]);
	for (int i=1;i<=n;++i)
		scanf("%lld",&b[i]);
	for (int i=1;i<=n;++i)
	{
		if(a[i]<b[i]) u+=(b[i]-a[i])/2;
		else d+=a[i]-b[i];	
	}
	if(u>=d) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 384
#include<iostream>

#include <math.h>
using namespace std;
int main() {
	int N,D;
	cin>>N>>D;
	int x, y;
	int count = 0;
	for (int i = 0; i < N; i++) {
		cin >> x>>y;
		double result = sqrt(pow(x, 2) + pow(y, 2));
		if (result <= D) {
			count++;
		}
	}
	cout << count;
	
	
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif

using namespace std;

constexpr int MAX_N = 200;
constexpr long long mod = 1000000007;
long long dp[MAX_N + 1][MAX_N + 1][MAX_N + 1]; // idx, team, place

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

	int n;
	cin >> n;

	vector<char> c(n);
	for(auto &e : c) cin >> e;
	c.erase(remove(begin(c), end(c), '-'), end(c));
	n = c.size();

	dp[0][0][0] = 1;
	for(int i = 0; i < n; ++i) {
		if(c[i] == 'U') {
			for(int j = 0; j <= i; ++j) {
				for(int k = 0; k <= i; ++k) {
					dp[i + 1][j + 1][k + 1] += dp[i][j][k];
					dp[i + 1][j + 1][k + 1] %= mod;

					if(j) {
						dp[i + 1][j][k] += j * dp[i][j][k];
						dp[i + 1][j][k] %= mod;
					}
				}
			}
		}
		else {
			assert(c[i] == 'D');
			for(int j = 0; j <= i; ++j) {
				for(int k = 1; k <= i; ++k) {
					dp[i + 1][j][k] += k * dp[i][j][k];
					dp[i + 1][j][k] %= mod;

					if(j) {
						dp[i + 1][j - 1][k - 1] += j * k * dp[i][j][k];
						dp[i + 1][j - 1][k - 1] %= mod;
					}
				}
			}
		}
	}
	cout << dp[n][0][0] << endl;

	return EXIT_SUCCESS;
}

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

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

  string s;
  cin >> s;

  if (s.size() > 2) {
    reverse(s.begin(), s.end());
  }
  cout << s << endl;

  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve();
        }

        public void Solve()
        {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList().OrderBy(n => n).ToList();
            MyUtility.PutYN(input[0] == 5 && input[1] == 5 && input[2] == 7);
        }
    }

    public class MyInputStream
    {
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(char separator = ' ')
        {
            this.separator = separator;
            inputStream = new Queue<string>();
        }

        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = Console.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; i++)
            {
                inputStream.Enqueue(tmp[i]);
            }
            return inputStream.Dequeue();
        }
        public string ReadLine()   { return Console.ReadLine(); }
        public int    ReadInt()    { return int.Parse(Read()); }
        public long   ReadLong()   { return long.Parse(Read()); }
        public double ReadDouble() { return double.Parse(Read()); }
    }

    public class MyUtility
    {
        /// <summary>2値を入れ替える</summary>
        public static void Swap<T>(ref T m, ref T n)
        {
            T tmp = m;
            m = n;
            n = tmp;
        }

        public static void PutYN(bool f)
        {
        	Console.WriteLine(f ? "YES" : "NO");
        }
    }
}

Measured memory_bytes: 13396
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int main()
{
  int a, b, c, d, X, Y;
  int D, G;
  //char s[101][101]={};
  char sv[101]={};
  char ss[101]={};
//  char s_temp[101]={};
  char t[101]={};
//  char s[10000000000000000001]={};
  char s[2][100001]={};
  int len=0;
  int N, M;
//  int A[1000000001]={};
  int A[1001]={};
//  long int A[1001]={};
  int B[1001]={};
  int C[20000]={};
  int i,j,k;
  int flag=0;
  int tmp=0;
  int min=0;
  int cnt=0;
  int ans=0;
  int max=0;
  int max_o=0;
  int max2_o=0;
  int max_o_num=0;
  int max_e=0;
  int max2_e=0;
  int max_e_num=0;
//  int ans=0;
  int str_len=0;
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  int ans_o[100001]={};
  int ans_e[100001]={};
  min=1001;
  scanf("%d %d", &a, &b);
  for(i=0;i<a;i++){
    scanf("%d %d", &A[i], &B[i]);
    if(min>=A[i]){
      if(b>=B[i]){
        min=A[i];
        flag=1;
      }
    }
  }
  if(flag==0)   printf("TLE\n");
  else          printf("%d\n",min);
  
return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)
ll R1, C1, R2, C2;
ll i,j,k;
ll Fa[2020202];

ll moddiv(ll a,ll b){
    a %= MOD;
    b %= MOD;
    for(ll m=MOD-2;m>0;m/=2){
        if(m&1){
            a=a*b%MOD;
        }
        b=b*b%MOD;
    }
    return a;
}

ll f(const ll& a,const ll& b){
    return moddiv(Fa[a + b], Fa[a] * Fa[b]);
    
}
int main(){
    scanf("%lld%lld%lld%lld", &R1, &C1, &R2, &C2);
    Fa[0] = 1;
    fornum(i,0,2010101){
        Fa[i + 1] = Fa[i] * (i + 1) % MOD;
    }
    ll ans = 0;
    
    ans = f(R2 + 1, C2 + 1) - f(R1, C2 + 1) - f(R2 + 1, C1) + f(R1, C1);
    ans = (ans + MOD * MOD) % MOD;
    printf("%lld", ans);


    return 0;
}

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

#define ll long long int
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define sep(i,b,a) for(ll i=b-1;i>=a;i--)
#define hell (ll)(1e9+7)

using namespace std;
/*
ll help(ll i,ll sum,ll totw)
{
    if(totw>tot||i==n)
        return sum;
    if(dp[i][totw]!=-1)
        return dp[i][totw];
    return dp[i][totw]=max(help(i+1,sum,totw),help(i+1,sum+v[i],totw+w[i]));
}*/

void solve()
{
    ll n,tot;
    cin>>n>>tot;
    ll w[n],v[n],dp[n+1][tot+1];
    memset(dp,0,sizeof dp);
    rep(i,0,n)
        cin>>w[i]>>v[i];
    rep(i,0,n+1)
    {
        rep(j,0,tot+1)
        {
            if(i==0||j==0)
                dp[i][j]=0;
            else
            dp[i][j]=w[i-1]>j?dp[i-1][j]:max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
        }
    }
    cout<<dp[n][tot]<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 79232
n, m = map(int, input().split())
ans = 0

q = []
for i in range(m):
    q.append(list(map(int, input().split())))

p = list(map(int, input().split()))

for s in range(2**n):
    judge = True
    for i in range(m):
        cnt = 0
        for j in range(1, len(q[i])):
            w = q[i][j]
            if s>>(w-1) &1 == 1:
                cnt += 1
        if cnt % 2 != p[i]:
            judge = False
    if judge:
        ans += 1
print(ans)

Measured memory_bytes: 41712
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn solve(n: i32) -> bool {
    if (n / 10) % 111 == 0 {
        return true;
    }
    if (n % 1000) % 111 == 0 {
        return true;
    }
    false
}

fn main() {
    input! {
        n: i32,
    }
    if solve(n) {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2132
#include <iostream>
using namespace std;
 
int main(){
	long long a[51]={0},n;
	cin>>n;
	for(long long i=1;i<=50;i++)
		a[i]=(n/50)+i-1;
	n%=50;
	for(long long i=1;i<=n;i++){
		for(int j=1;j<=50;j++)
			a[j]--;
		a[i]+=51;
	}
	cout<<50<<endl;
	for(int i=1;i<50;i++)
		cout<<a[i]<<" ";
	cout<<a[50];
	return 0;
}

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

#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair< int,int>
#define pll pair< ll,ll >
#define vi vector<int>
#define ss second
#define ff first
#define vii vector<pii>
#define vll vector<pll>
#define vl vector<ll>
#define vb vector<bool>
#define f(i,a,b) for(i = a;i < b;i++)
#define rf(i,a,b) for(i = a;i >= b;i--)
//template<class T> void print_data(T& a){ for(auto it : a) cout << it << " "; cout << endl; }

int main(){
	std::ios::sync_with_stdio(false);
	int i,j,n;
	cin >> n;
	vi a(n);
	f(i,0,n)
		cin >> a[i];

	int sum = abs(a[0]);
	f(i,0,n){
		if(i == n - 1)
			sum += abs(a[i]);
		else
			sum += abs(a[i+1] - a[i]);
	}

	f(i,0,n){
		int prev,next,cur = a[i];
		if(i == 0) prev = 0;
		else prev = a[i-1];
		if(i != n- 1) next = a[i+1];
		else next = 0;
		int tmp = sum;
		tmp -= abs(prev - cur);
		tmp -= abs(next - cur);
		tmp += abs(next - prev);
		cout << tmp << "\n";
	}
	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 100000 + 5;
struct node{
	int parent,left,right,sib,dep,degree,height;
}tree[maxn];
void setDep(int u,int d){
	tree[u].dep = d;
	if(tree[u].left != -1)setDep(tree[u].left,d+1);
	if(tree[u].right != -1)setDep(tree[u].right,d+1);
}
int setHeight(int u){
	int h1 = 0,h2 = 0;
	if(tree[u].left != -1)
		h1 = 1 + setHeight(tree[u].left);
	if(tree[u].right != -1)
		h2 = 1 + setHeight(tree[u].right);
	return tree[u].height = (h1>h2?h1:h2);
}
int main()
{		
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;++i){
		tree[i].parent = tree[i].left = tree[i].right= tree[i].dep = tree[i].sib = -1;
		tree[i].degree = tree[i].height = 0;
	}
	
	int id,l,r,rootid;
	for(int i=0;i<n;++i){	
		scanf("%d %d %d",&id,&l,&r);
		tree[id].left = l;
		tree[id].right = r;
		if(l!=-1){tree[l].parent = id;tree[id].degree++;tree[l].sib = r;}
		if(r!=-1){tree[r].parent = id;tree[id].degree++;tree[r].sib = l;}
		
	}	
	
	for(int i=0;i<n;++i)if(tree[i].parent == -1){rootid = i;break;}	
	setDep(rootid,0);
	
	setHeight(rootid);
	
	for(int i=0;i<n;++i){
		printf("node %d: parent = %d, sibling = %d, ",i,tree[i].parent,tree[i].sib);
		printf("degree = %d, depth = %d, height = %d, ",tree[i].degree,tree[i].dep,tree[i].height);
		
		if(tree[i].parent==-1)printf("root\n");
		else if(tree[i].left != -1 || tree[i].right != -1)printf("internal node\n");
		else printf("leaf\n");
	}
	return 0;
}

Measured memory_bytes: 3204
from collections import defaultdict

n = int(input())
l_list = [int(x) for x in input().split()]

d = defaultdict(int)
for l in l_list:
    d[l] += 1

n = len(d)
l_list = sorted(d.keys())
ans = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        for k in range(j + 1, n):
            a, b, c = l_list[i], l_list[j], l_list[k]
            if a + b <= c:
                continue
            ans += d[a] * d[b] * d[c]
print(ans)

Measured memory_bytes: 9336
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

string ac = "AC";
string wa = "WA";

int main(){
    string s;cin>>s;
    int n = s.size();

    if(s[0] != 'A'){
        cout << wa << endl;
        return 0;
    }

    int cnt = 0;
    for(int i=2;i<=n-2;i++){
        if(s[i]=='C') cnt++;
    }
    if(cnt != 1){
        cout << wa << endl;
        return 0;
    }

    rep(i,n) if(s[i]!='A' and s[i]!='C'){
        if('a' > s[i] or s[i]>'z'){
            cout << wa << endl;
            return 0;
        }
    }
    cout << ac << endl;
}


Measured memory_bytes: 256
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0};
int dy[8]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------
ll n,m,r; ll ans=INF; bool color[10]; vector<ll>R(10); ll cnt=0;
ll c[250][250];
void warshall_floyd(){
   // cout<<n<<endl;
    for(int k=0;k<n;k++)
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
                chmin(c[i][j],c[i][k]+c[k][j]);
}
void dfs(int cnt,int las,int dist){
    if(cnt==r){
        if(ans>dist)ans=dist;
        return;
    }
    for(int i=0;i<r;i++){
        if(!color[i]){
            color[i]=true;
            if(las==-1)dfs(cnt+1,i,0);
            else dfs(cnt+1,i,dist+c[R[las]][R[i]]);
            color[i]=false;
        }
    }
}
//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    cin>>n>>m>>r;
   
   
    for(int i=0;i<10;i++)
        color[i]=0;
    for(int i=0;i<250;i++)
        for(int j=0;j<250;j++)
            c[i][j]=INF;
   
    for(int i=0;i<r;i++){
        cin>>R[i];
        R[i]--;
    }
    
    for(int i=0;i<m;i++){
        ll a,b,cc;cin>>a>>b>>cc;
        a--;b--;
        c[a][b]=cc;c[b][a]=cc;
    }
    
    warshall_floyd();
 
    dfs(0,-1,0);
    
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 768
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Dice d;
		int n;
		
		while(true){
			n = sc.nextInt();
			if(n == 0){
				break;
			}
			
			d = new Dice();
			for(int i=0;i<n;i++){
				d.moveDice(sc.next());
				d.addTop();
			}
			System.out.println(d.getSum());
		}
	}
}

class Dice{
	int[] num,tmp;
	int sum;
	
	Dice(){
		num = new int[6];
		num[0] = 1;
		num[1] = 2;
		num[2] = 3;
		num[3] = 5;
		num[4] = 4;
		num[5] = 6;
		tmp = new int[6];
		sum = 1;
	}
	
	public void addTop(){
		sum += num[0];
	}
	
	public int getSum(){
		return sum;
	}
	
	public void moveDice(String str){
		if(str.equals("North")){
			moveNorth();
		}else if(str.equals("East")){
			moveEast();
		}else if(str.equals("South")){
			moveSouth();
		}else if(str.equals("West")){
			moveWest();
		}else if(str.equals("Right")){
			moveRight();
		}else if(str.equals("Left")){
			moveLeft();
		}
	}
	
	public void moveNorth(){
		setTmp();
		num[0] = tmp[1];
		num[1] = tmp[5];
		num[3] = tmp[0];
		num[5] = tmp[3];
	}
	
	public void moveEast(){
		setTmp();
		num[0] = tmp[4];
		num[2] = tmp[0];
		num[4] = tmp[5];
		num[5] = tmp[2];
	}
	
	public void moveSouth(){
		setTmp();
		num[0] = tmp[3];
		num[1] = tmp[0];
		num[3] = tmp[5];
		num[5] = tmp[1];
	}
	
	public void moveWest(){
		setTmp();
		num[0] = tmp[2];
		num[2] = tmp[5];
		num[4] = tmp[0];
		num[5] = tmp[4];
	}
	
	public void moveRight(){
		setTmp();
		num[1] = tmp[2];
		num[2] = tmp[3];
		num[3] = tmp[4];
		num[4] = tmp[1];
	}
	
	public void moveLeft(){
		setTmp();
		num[1] = tmp[4];
		num[2] = tmp[1];
		num[3] = tmp[2];
		num[4] = tmp[3];
	}
	
	public void setTmp(){
		for(int i=0;i<6;i++){
			tmp[i] = num[i];
		}
	}
}

Measured memory_bytes: 25348