akhauriyash/Code-Regression huggingface dataset:
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
ArrayDequeではpopとpushはStackと同じ操作になる
//import static java.lang.System.*; はしばらく使わなそう(使うとしてもexit(0)のためだけ)←return;でよさそう
最後にout.flush()またはout.close()をするのを忘れずに！
Point2D p2d=new Point2D.Double(d1,d2);
*/
//入力終了→Ctrl+D
import java.util.*;
import java.io.*;
import java.awt.*;
import java.awt.geom.Point2D;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        int n = sc.nextInt();
        int[] x=new int[n];
        int[] y=new int[n];
        for (int i = 0; i < n; i++) {
            x[i]=sc.nextInt();
            y[i]=sc.nextInt();
        }
        HashMap<Point,Integer> map=new HashMap<>();
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                Point p=new Point(x[i]-x[j],y[i]-y[j]);
                map.put(p,map.getOrDefault(p,0)+1);
            }
        }
        int maxi=0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if(i==j)continue;
                Point p=new Point(x[i]-x[j],y[i]-y[j]);
                maxi=max(maxi,map.get(p));
            }
        }
        out.println(n-maxi);
        out.close();
    }

    static PrintWriter out = new PrintWriter(System.out);

    static class sc {
        static Scanner s = new Scanner(System.in);

        static String next() {
            return s.next();
        }

        static String nextLine() {
            return s.nextLine();
        }

        static int nextInt() {
            return Integer.parseInt(s.next());
        }

        static long nextLong() {
            return Long.parseLong(s.next());
        }

        static double nextDouble() {
            return Double.parseDouble(s.next());
        }

        static boolean hasNext() {
            return s.hasNext();
        }

        static boolean hasNextInt() {
            return s.hasNextInt();
        }

    }

}

Measured memory_bytes: 23764
#coding: utf-8

N = int(input())
S = [list(input()) for _ in range(2)]

num  = 0

itr = zip(S[0], S[1])
c1, c2 = itr.__next__()

if c1 == c2:
    prev = 1 
    num = 3
else:
    prev = 2 
    num = 6
    itr.__next__()

for c1, c2 in itr:
    if c1 == c2:
        # vertical
        if prev == 1:
            num *= 2
            num %= 1000000007
        prev = 1 
    else:
        # horizonal
        if prev == 1:
            num *= 2
        else:
            num *= 3
        num %= 1000000007
        itr.__next__()
        prev = 2

print(num)


Measured memory_bytes: 9196
from collections import Counter

N= int(input())
S = input()

cnt = Counter(S[1:])["E"]
ret = cnt
for i in range(1, N):
    if S[i] == "E":
        cnt -= 1
    if S[i-1] == "W":
        cnt += 1
    ret = min(ret, cnt)
print(ret)

Measured memory_bytes: 4084
#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;
  vi a(n);
  for(auto&& x:a)cin >> x;
  bool f = false;
  if(is_sorted(a.begin(), a.end()))f = true;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      vi b = a;
      swap(b[i], b[j]);
      if(is_sorted(b.begin(), b.end()))f = true;
    }
  }
  cout << (f ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main( void )
{
	int a, b, c;
	int cou, ans, NumCou;
	
	scanf( "%d %d %d", &a, &b, &c );
	
	cou = 0;

	for( NumCou = 0; NumCou <= b - a; NumCou++ )
	{
		ans = c % ( a + NumCou );
		
		if( ans == 0 )
		{
			cou = cou++;
		}
	}
	
	printf( "%d\n", cou );
	
	return 0;
}

Measured memory_bytes: 596
#include <cstdio>

#define R register
int main()
{
	R int n, p; scanf("%d%d", &n, &p);
	R int a0 = 0, a1 = 0;
	for (R int i = 1; i <= n; ++i)
	{
		R int a;
		scanf("%d", &a);
		a0 += a % 2 == 0;
		a1 += a % 2 == 1;
	}
	printf("%lld\n", a1 == 0 && p == 1 ? 0 : a1 == 0 && p == 0 ? 1ll << n : 1ll << (n - 1));
	return 0;
}

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

int main(){
  string str;
  int h,m,l;

  while(cin >> str){
    if( str == "-")break;
    cin >> m;
    l = str.size();
    for (int i = 0 ; i < m ; i++){
      cin >> h;
      string left = str.substr(0,h);
      string right = str.substr(h, l);
      str =  right + left;
    }
      cout << str << endl;
  }

  return 0;
}

Measured memory_bytes: 1220
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n; cin >> n;
    vector<ll> a(n), b(n), c(n-1);
    REP(i, n) cin >> a[i];
    REP(i, n) cin >> b[i];
    REP(i, n-1) cin >> c[i];

    ll ans = 0;
    REP(i, n) {
        ans += b[a[i]-1];
        if (i && a[i] == a[i-1]+1) {
            ans += c[a[i-1]-1];
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <cstdio>

int n,m;
int a[101];
int b[101][101];
int s[101];

int main(void){
	scanf("%d",&n);
	scanf("%d",&m);
	for(int i=0;i<m;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<m;i++){
		for(int j=1;j<=n;j++){
			scanf("%d",&b[i][j]);
		}
	}
	for(int i=0;i<m;i++){
		int bonus=0;
		for(int j=1;j<=n;j++){
			if(a[i]==b[i][j]){
				s[j]++;
			}else bonus++;
		}
		s[a[i]]+=bonus;
	}
	for(int i=1;i<=n;i++){
		printf("%d\n",s[i]);
	}
	return 0;
}

Measured memory_bytes: 1064
def main():
    k=int(input())
    n=50
    a=k%n
    w=k//n
    if k==0:
        print(2)
        print(1,1)
        return 0
    elif k==1:
        print(2)
        print(2,0)
        return 0
    elif k<n:
        print(k)
        print(*[k]*k)
        return 0
    print(n)
    p=[w+n-1]*n
    for i in range(a):
        p[i]=p[i]+n-a+1
    for i in range(a,n):
        p[i]-=a
    print(*p)
main()

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

using namespace std;
typedef long long ll;


int main(){
    int a, b, c;
    cin >> a >> b >> c;

    int aa = a * a;
    int bb = b * b;
    int cc = c * c;

    if (aa + bb == cc) cout << a * b / 2 << endl;
    else if (aa + cc == bb) cout << a * c / 2 << endl;
    else if (bb + cc == aa) cout << b * c / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
 
long long gcd(int number1,int number2){
	int m = number1;
	int n = number2;
 
	if(number2 > number1){
		m = number2;
		n = number1;
	}
    // m > n
    while(n != 0){
        int r = m % n;
        m = n;
        n = r;
    }
    /*
	while(m != n){
		int temp = n;
		n = m - n;
		m = temp;
	}*/
 
	return m;
}
 
long long lcm(long long number1,long long number2){
    long long temp = gcd(number1,number2);
    //cout << number1 << "  " << number2 << "  " << gcd(number1,number2) << "  " << (number1 / temp) * number2 << endl;
    return (number1 / temp) * number2; 
	//return number1 * number2 / gcd(number1,number2);	
}
 
int count2(int number){
    int n=0;
    while(number % 2 == 0){
        number /= 2;
        n++;
    }
    
    //cout << n << " " << number <<endl;
    return n;
}
 
 
 
int main(){
    int N, M; cin >> N >> M;
    vector<int> A;
    int idx2;
    for(int i = 0; i < N; i++){
        int x; cin >> x;
        if(i == 0) idx2 = count2(x);
        else{
            if(idx2 != count2(x)){
                cout << 0 << endl;
                return 0;
            }
        } 
        A.push_back(x/2);
    }
    //cout << 1 << endl;
    //LCM
    long long LCM = A[0];
    for(int i = 1; i < N; i++){
        if(M < LCM || LCM < 0){
            cout << 0 << endl;
            return 0;
        }
        LCM = lcm(LCM, A[i]);
    }
    //cout << LCM << endl;
    int cnt = 0;
    if(LCM <= M) cnt = 1;
    cout << (M-LCM) / (LCM*2) + cnt << endl;
}

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

int main()
{
	int m, n;
	int j;

	while (1) 
	{
		cin >> m >> n;

		if (m == 0 && n == 0)
		{
			return 0;
		}

		for (int i = 1; i <= m; i++)
		{
			if (i == 1 || i == m)
			{
				for (j = 1; j <= n; j++)
				{
					cout << "#";
				}				
			}
			else
			{
				for (j = 1; j <= n; j++)
				{
					if (j == 1 || j == n)
					{
						cout << "#";
					}
					else
					{
						cout << ".";
					}
				}			
			}
			cout << "\n";
		}
		cout << "\n";
	}
	return 0;
}

Measured memory_bytes: 3080
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
# INF = float("inf")


def f(l):
    ret = 0
    for k in range(len(l)):
        ret += (2 * (k + 1) - len(l) - 1) * l[k]
    return ret % MOD


def main():
    n, m = map(int, input().split())
    x = list(map(int, input().split()))
    y = list(map(int, input().split()))
    ans = f(x) * f(y) % MOD
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 19308
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

typedef struct
{
	double x;
	double y;
} POINT;

POINT v[100];

bool cmp(POINT A, POINT B)
{
	if (A.x == B.x){
		return (A.y < B.y);
	}
	return (A.x < B.x);
}

double dif(double y, double x)
{
	return (sqrt(y * y + x * x));
}

int main()
{
	int m = 0;
	
	while (scanf("%lf,%lf", &v[m].x, &v[m].y) != EOF){
		m++;
	}
	
//	sort(v, v + m, cmp);

/*	
	for (int i = 0; i < m; i++){
		printf("%lf %lf\n", v[i].x, v[i].y);
	}
*/
	
	double S = 0.0;
	
	for (int i = 0; i < m - 1; i++){
		double a = dif(v[0].y - v[i].y, v[0].x - v[i].x);
		double b = dif(v[i].y - v[i + 1].y, v[i].x - v[i + 1].x);
		double c = dif(v[i + 1].y - v[0].y, v[i + 1].x - v[0].x);
		double z = (a + b + c) / 2;
		
//		printf("%lf %lf %lf %lf\n", a, b, c, z);
		
		S += sqrt(z * (z - a) * (z - b) * (z - c));
		
//		printf("%lf\n", S);
	}
	
	printf("%lf\n", S);
	
	return 0;
}

Measured memory_bytes: 1080
n  = int(input())
ai = list(map(int, input().split()))

def short_long_decisions(xs):
    return [ *map(lambda t: t[0] <= t[1], zip(xs[:-1], xs[1:])), False ]

money   = 1000
stocks  = 0
actions = short_long_decisions(ai)

for i, action in enumerate(actions):
    if action:
        stocks += money // ai[i]
        money %= ai[i]

    else:
        money += stocks * ai[i]
        stocks = 0

print(money)

Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define V vector<int>
#define ll long long
using namespace std;


int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    if(k%2 == 0){
        cout << a - b << endl;
    }else{
        cout << b - a << endl;
    }
} 


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        if(A+B==3){
            System.out.println(3);
        }else if(A+B==4){
            System.out.println(2);
        }else{
            System.out.println(1);
        }
    }
}


Measured memory_bytes: 21844
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var a = double.Parse(Console.ReadLine().Trim());
            var h = double.Parse(Console.ReadLine().Trim());
            if (a == 0 && h == 0) break;
            double c = Math.Sqrt(h * h + a * a / 4);
            double ans = a * a + 2 * a * c;
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const ll mod=(1e9)+7;
const int maxn=(5e5)+10;
int n,m,jc[maxn],iv[maxn],ivjc[maxn],ans,tmp;
int C(int x,int y) {
	if (x<y||y<0) return 0;
	return (ll)jc[x]*ivjc[y]%mod*ivjc[x-y]%mod;
}
void update(int &x,int y) { x+=y; if (x>=mod) x-=mod; }
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(m);
	jc[0]=iv[0]=ivjc[0]=jc[1]=iv[1]=ivjc[1]=1;
	for (int i=2;i<maxn;i++) {
		jc[i]=(ll)jc[i-1]*i%mod;
		iv[i]=(ll)(mod-mod/i)*iv[mod%i]%mod;
		ivjc[i]=(ll)ivjc[i-1]*iv[i]%mod;
	}
	for (int i=0;i<=n;i++) {
		tmp=(ll)C(n,i)*C(m,i)%mod*C(m-i,n-i)%mod*C(m-i,n-i)%mod*jc[i]%mod*jc[n-i]%mod*jc[n-i]%mod;
		if (i&1) tmp=mod-tmp;
		update(ans,tmp);
	}
	printf("%d\n",ans);
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 9580
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <functional>
#include <map>
#include <tuple>

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

using namespace std;

typedef long long int lli;
typedef tuple<int,int> Tup;

int main() {
    int N, Z, W; 
    cin >> N >> Z >> W;
    vector<int> A(N);
    REP (i, 0, N) cin >> A[i];
    map<Tup, lli> memo;
    function<lli(int,int,int,int)> rec = [&](int X, int Y, int pos, int turn) -> lli {
        Tup tup = make_tuple(pos, turn);
        if (memo.count(tup)) {
            return memo[tup];
        }
        if (pos >= N) return abs(X - Y);
        lli res = (turn == 1 ? -1LL << 60 : 1LL << 60);
        REP (i, pos, N) {
            lli ans;
            if (turn == 1) {
                ans = rec(A[i], Y, i + 1, turn * -1);
            } else {
                ans = rec(X, A[i], i + 1, turn * -1);
            }
            if (turn == 1) res = max(res, ans);
            else res = min(res, ans);
        }
        return memo[tup] = res;
    }; 
    cout << rec(Z, W, 0, 1) << endl;
    return 0;
}

Measured memory_bytes: 768
import java.util.*;

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

		Scanner sc=new Scanner(System.in);

		int n=sc.nextInt();
		int a=n/100; //百の位
		int b=n/10-a*10; //十の位
		int c=n-a*100-b*10; //一の位


		if(a==9){
			a=1;
		}else{
			a=9;
		}
		if(b==9){
			b=1;
		}else{
			b=9;
		}
		if(c==9){
			c=1;
		}else{
			c=9;
		}


		System.out.println(a+""+b+""+c);

	}
}


Measured memory_bytes: 21844
#include <stdio.h>
#define N 100000
#define Q 50000

int S[N];
int binarySearch(int ,int );

int main(){
  int n,q,i,j,count=0,a;
  int T[Q];

  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]);
  }

  for(i=0;i<q;i++){
    a = binarySearch(T[i],n);
    if(a == 0)count++;
  }

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

  return 0;
}

int binarySearch(int x,int n){
  int left,right,mid;
  
  left = 0;
  right = n;
  while(left < right){
    mid = (left + right)/2;
    if(S[mid] == x){
      return 0;
    }
    else if(x < S[mid]){
      right = mid;
    }
    else {
      left = mid + 1;
    }
  }
  return 1;
}



Measured memory_bytes: 2308
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
ll n, a, b;
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n >> a >> b;
	ll ans = 0;
	if((b-a)%2==0) ans = (b-a)/2;
	else ans = min(a-1, n-b) + 1 + (b-a)/2;
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
c = input()

d = list(c)

i = 0
j = N - 1
result = 0
while True:
    while i < N and d[i] != 'W':
        i += 1
    while j > 0 and d[j] != 'R':
        j -= 1
    if i == N or j == -1 or i >= j:
        break
    d[i] = 'R'
    d[j] = 'W'
    result += 1
print(result)

Measured memory_bytes: 10600
def run():
    """ return nCk """

    p = 10**9 + 7
    n, k = [int(i) for i in input().split()]
    if n > k:
        print(0)
        return
    
    table_1 = [1]
    temp = 1
    for nn in range(1, k+1):
        temp = temp * nn
        table_1.append(temp % p)
    # print(table_1)
    table_2 = [pow(t1, p-2, p) for t1 in table_1]
    # print(table_2)
    
    a = table_1[k]
    b = table_2[n]
    c = table_2[k-n] if k>=n else 0
    # print(n, k, a, b, c)
    # print(table_1[n] / (table_1[k] * table_1[n-k]))
    print(a%p * b%p * c%p)
    
if __name__ == "__main__":
    run()




Measured memory_bytes: 5612
/*
  AUTHOR:SOURABH
  CREATED:12:10:19
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<ll , null_type, less< ll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll n,i,l,r,ans=0;
    cin>>n;
    vll a(n);
    fn(i,n)
    cin>>a[i];
    sort(a.begin(),a.end());
    fr(i,n-1)
    {
        l=0,r=i-1;
        W(l<r)
        {
            if(a[l]+a[r]>a[i])
                {ans+=r-l;r--;}
            else
                l++;
        }
    }
    cout<<ans;
    return 0;
}










Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fr first
#define sc second
#define memset(X,Y) memset(X,Y,sizeof X)
#define all(X) X.begin(),X.end()
#define sz size()
#define pb push_back
#define ve vector<int>
#define pii pair < int,int >
#define pll pair < ll,ll >
#define ll long long
#define Graph vector<vector < int > >
#define Fp cout << fixed <<  setprecision(9)
#define Fast  ios::sync_with_stdio(0); cin.tie(0);
using namespace std;
const int M = 1e6+30 , N= 101000 , MOD = 1e9+7 , OO = 1e7;
int m ,n ,k , x, y , dp[N][9] , bla ,c=1,cnt ,ans,sum , a[N][9] , ok=1 ;
int Dp(int i , int ok){

if(i == n) return 0;
if(dp[i][ok]!=-1) return dp[i][ok];
int ret1 =0 , ret2=0;
if(ok==0){
    ret1 = Dp(i+1 , 1) + a[i][1];
    ret2 = Dp(i+1 , 2) + a[i][2];

}
if(ok==1){
    ret1 = Dp(i+1 , 0) + a[i][0];
    ret2 = Dp(i+1 , 2) + a[i][2];

}

if(ok==2){
    ret1 = Dp(i+1 , 1) + a[i][1];
    ret2 = Dp(i+1 , 0) + a[i][0];

}
return dp[i][ok] = max(ret1 ,ret2);

}

int main(){

cin >> n;
for(int i=0;i<n;i++){

    for(int j=0;j<3;j++){

        cin >> a[i][j] ;
    }

}
memset(dp , -1);
cout <<max(Dp(0 , 0) ,max( Dp(0 , 1) , Dp(0 , 2)));
return 0;
}


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

using ll = long long;
using Vi = std::vector<int>;
using Vl = std::vector<ll>;
using Pii = std::pair<int, int>;
using Pll = std::pair<ll, ll>;

constexpr int I_INF = std::numeric_limits<int>::max();
constexpr ll L_INF = std::numeric_limits<ll>::max();

template <typename T1, typename T2>
inline bool chmin(T1& a, const T2& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, const T2& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(const Args&... args) const { print(args...); }
        template <typename T>
        void pvec(const T& vec, size_t sz) const {
            for (size_t i = 0; i < sz; i++)
                std::cout << vec[i] << (i == sz - 1 ? term : sep);
        }
        template <typename T>
        void pmat(const T& mat, size_t h, size_t w) {
            for (size_t i = 0; i < h; i++)
                for (size_t j = 0; j < w; j++)
                    std::cout << mat[i][j] << (j == w - 1 ? term : sep);
        }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(const T& head, const Tail&... tail) const { std::cout << head, print_rest(tail...); }
        template <class T, class... Tail>
        void print_rest(const T& head, const Tail&... tail) const { std::cout << sep << head, print_rest(tail...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    int N;
    cin >> N;
    Vl xs(N), ys(N);
    for (ll i = 0; i < N; i++) {
        ll a, b;
        cin >> a >> b;
        xs[i] = a + b;
        ys[i] = a - b;
    }
    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());

    ll ans = 0;
    chmax(ans, xs[N - 1] - xs[0]);
    chmax(ans, ys[N - 1] - ys[0]);

    prints()(ans);
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    std::cin.tie(nullptr), std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    std::ifstream ifs("./in_out/input.txt");
    std::cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    std::ofstream ofs("./in_out/output.txt");
    std::cout.rdbuf(ofs.rdbuf());
#endif
    std::cout << std::setprecision(18) << std::fixed;
    solve();
    std::cout << std::flush;
    return 0;
}

Measured memory_bytes: 6328
def nCk(n,k,mod=10**9+7):
    if n<k or k<0 or n<0:return 0
    return fact[n]%mod * pow(fact[n-k]*fact[k],mod-2,mod) % mod

mod = 10**9+7
n=int(raw_input())
a=map(int,raw_input().split())
cnt=[0]*(n+1)
for i in xrange(n+1):
    cnt[a[i]]+=1
dnum=0
for i in xrange(n+1):
    if cnt[i]==2:
        dnum=i
        break
idx=[]
fact=[0]*(n+5)
fact[0]=1
for i in xrange(n+1):
    fact[i+1] = (i+1)*fact[i]%mod
for i in xrange(n+1):
    if dnum==a[i]:
        idx.append(i)

y=n-idx[1]
x=idx[0]

for i in xrange(n+1):
    #print nCk(y,i)
    print (nCk(n+1, i+1) - nCk(x+y,i)%mod)%mod


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

int main() {
    int n, m;
    cin >> n;
    cin >> m;
    int coin[m+1];
    rep(i, m+1) {
        if (i > 0) cin >> coin[i];
    }
    int dp[m+1][n+1];
    rep(i, m+1) {
        rep(j, n+1) {            
            if (i == 0) {
                dp[i][j] = 1e9;
                continue;
            }
            if (j == 0) {
                dp[i][j] = 0;
            } else {
                dp[i][j] = dp[i-1][j];
                if (j-coin[i] >= 0) {
                    dp[i][j] = min(dp[i][j], dp[i][j-coin[i]]+1);
                }
            }
            // cout << dp[i][j] << " ";
        }
        // cout << endl;
    }
    cout << dp[m][n] << endl;
}


Measured memory_bytes: 7220
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#define LINE_BUF_SIZE  1024

int main(void) {
  
  int i;
  int number[3];
  int temp;

  scanf("%d %d %d",&number[0],&number[1],&number[2]);
  for(i = 0; i <= 1; i++){
      temp = number[0];
      number[0] = number[i + 1];
      number[i + 1] = temp;
  }
  for(i = 0; i < 3; i++){
      printf("%d ",number[i]);
  }
  
  return 0;
}

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int T,A;
    T = (a - a%d)/d;
    A = (c - c%b)/b;
    if(a%d != 0){
        T++;
    }
    if(c%b != 0){
        A++;
    }

    if(T >= A){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	vi Like(M, 0);
	REP(i, N) {
		int K;
		cin >> K;
		REP(i, K) {
			int a;
			cin >> a;
			a--;
			Like[a]++;
		}
	}
	int ans = 0;
	REP(i, M) {
		if (Like[i] == N)ans++;
	}
	cout << ans << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 504
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

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

            Queue<Long> aQueue = new PriorityQueue<>(N);
            for (int i = 0; i < N; i++) {
                aQueue.add(sc.nextLong());
            }

            long[][] bcList = new long[M][2];
            for (int i = 0; i < M; i++) {
                bcList[i][0] = sc.nextInt();
                bcList[i][1] = sc.nextLong();
            }

            Arrays.sort(bcList, (a, b) -> Long.compare(a[1], b[1]));

            A: for (int i = bcList.length - 1; i >= 0; i--) {
                long[] bc = bcList[i];
                long b = bc[0];
                long c = bc[1];

                for (int j = 0; j < b; j++) {
                    Long a = aQueue.poll();
                    if (a < c) {
                        aQueue.add(c);
                    } else {
                        aQueue.add(a);
                        break A;
                    }
                }
            }

            System.out.println(aQueue.stream().reduce((current, value) -> current + value).get());
        }
    }

}

Measured memory_bytes: 103096
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;
#define ll int64_t
const long MOD = 1e9 + 7;
const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}



int main() {

  long n,m;

  cin >> n >> m;

  // std::vector<long> a(n);
  // std::vector<long> a(n);

  vector<pair<long,long>> ab(n);

  for (int i = 0; i < n; ++i){
    long a,b;
    cin >>a >> b;

    ab[i] = make_pair(a, b);
    // make_pair(a,b);
  }
  

  sort(ab.begin(), ab.end(), [](pair<long,long> &l,pair<long,long> &r){
    return l < r;
  } );
  
  long ans = 0;
  long c = 0;
  long tmp = 0;
  for (int i = 0; i < m; ++i){
    ans += ab[c].first;
    tmp++;
    if (ab[c].second == tmp){
      c++;
      tmp = 0;
    }
  }

  cout << ans << endl;


}




















Measured memory_bytes: 1792
<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
if($a > 0 && $b > 0){
    echo "Positive\n";
}elseif($a * $b <= 0){
    echo "Zero\n";
}else{
    echo (($b - $a) % 2) == 0 ? "Negative\n" : "Positive\n";
}

Measured memory_bytes: 4604
m=int(raw_input())
n=int(raw_input())
A=sorted([map(int,raw_input().split()) for _ in range(n)])
X=[]
while A:
  a1,a2=map(set,zip(*A))
  B=a2-a1
  na=len(A)
  for i in range(na)[::-1]:
    e0,e1=A[i]
    if e1 in B:
      if e1 not in X: X.append(e1)
      del A[i]
X=list(set(range(1,m+1))-set(X))+X[::-1]
for e in X: print e

Measured memory_bytes: 4240
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
if N == 1 and M == 1:
	print(1)
elif N == 1:
	print(M-2)
elif M == 1:
	print(N-2)
else:
	print((N-2)*(M-2))
	

Measured memory_bytes: 5192
#include <cmath>
#include <iostream>
#include <vector>

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

	std::vector<int> a(N);
	int sum = 0;
	for(int i = 0; i < N; i++) {
		std::cin >> a[i];
		sum += a[i];
	}

	const double average = (double)sum / N;

	double mindis = std::abs(a[0] - average);
	int minIndex = 0;
	for(int i = 0; i < N; i++) {
		const double dis = std::abs(a[i] - average);
		if(dis < mindis) {
			mindis = dis;
			minIndex = i;
		}
	}

	std::cout << minIndex << std::endl;

	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import math
Q = int(input())
A = [list(map(int, input().split())) for _ in range(Q)]



def measure(A):
    a,b,c,d = A
    if abs(a-c) < abs(b-d):
        s1, s2 = min([a,c]), max([a,c])
        l1, l2 = min([b,d]), max([b,d])
    else:
        l1, l2 = min([a,c]), max([a,c])
        s1, s2 = min([b,d]), max([b,d])
    min_K = int(math.log(s2-s1+1, 3) + 1)
    max_K = int(math.log(l2-l1+1, 3) + 1)
    for k in list(range(min_K, max_K+1))[::-1]:
        v = 3 ** k
        _l = 3 ** (k-1) + 1
        _h = (3 ** (k-1)) * 2
        c1 = s1//v == s2//v
        c2 = (s1 % v <= _h) & (_l <= s1 % v)
        c3 = (s2 % v <= _h) & (_l <= s2 % v)
        c4 = True
        if (l1 // v) == (l2  // v):
            if (l1 % v < _l) & (l2 % v > _h):
                c4 = True
            else:c4=False
        if ((l1 // v) + 1) == (l2 // v):
            if ((l2 % v < _l) & (l1 % v > _h)):
                c4 = False
        if c1 & c2 & c3 & c4:
            val1 = (s1 % v - _l + 1) + (s2 % v - _l + 1) + (l2 - l1)
            val2 = (_h - s1 % v + 1) + (_h - s2 % v + 1) + (l2 - l1)
            print(min([val1, val2]))
            return None
    print(l2-l1+s2-s1)

if __name__ == '__main__':
    for val in A:
        measure(val)

Measured memory_bytes: 6388
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define range(i,l,h) for(int i=l;i<h;i++)
#define endl '\n'
#define I INT_MAX
#define L INT_MIN
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vi vector<int>
using namespace std;
using std::ios;
constexpr int MOD=1e9+7;
constexpr int mod=998244353;  

int main()
{
  string s;
  cin>>s;
  int n=s.length();
  ll sum=0;
  int i=0;
  while(i<n)
  {
    ll cnt1=0,cnt2=0;
    while(i<n&&s[i]=='<')
    {
      cnt1++;
      i++;
    }
    while(i<n&&s[i]=='>')
    {
      cnt2++;
      i++;
    }

    if(cnt1>cnt2)
    {
      cnt2--;
    }
    else
    {
      cnt1--;
    }
    sum+=(cnt2*(cnt2+1)/2);
    sum+=(cnt1*(cnt1+1)/2);
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 4236
#include<bits/stdc++.h>
using namespace std;
#define RI register int
int read() {
	int q=0,w=1;char ch=' ';
	while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
	if(ch=='-') w=-1,ch=getchar();
	while(ch>='0'&&ch<='9') q=q*10+ch-'0',ch=getchar();
	return q*w;
}
const int N=200005,LIM=524290,inf=0x3f3f3f3f;
int n,V,m;
int bin[21],x[N],L[N],f[LIM],g[LIM],in[21][N],ans[N],mi[N];
vector<int> seg[21];

void prework() {
	seg[m].push_back(0);
	for(RI i=2;i<=n;++i)
		if(x[i]-x[i-1]>V) seg[m].push_back(i-1);
	seg[m].push_back(n);
	//cout<<"V="<<V<<endl;
	//for(RI i=0;i<seg[m].size();++i) cout<<seg[m][i]<<" ";
	//cout<<endl;
	int now=1;
	for(RI i=1;i<seg[m].size();++i)
		while(now<=seg[m][i]) in[m][now]=i,++now;
	//for(RI i=1;i<=n;++i) cout<<in[m][i]<<" ";
	//cout<<endl;
	//cout<<endl;
}
void work1() {
	for(RI i=0;i<bin[m]-1;++i) {
		//cout<<i<<" "<<f[i]<<endl;
		for(RI j=0;j<m;++j)
			if(!(i&bin[j]))
				f[i|bin[j]]=max(f[i|bin[j]],seg[j+1][in[j+1][f[i]+1]]);
	}
	//cout<<bin[m]-1<<" "<<f[bin[m]-1]<<endl;
	//cout<<endl;
}
void work2() {
	for(RI i=0;i<bin[m];++i) g[i]=n+1;
	for(RI i=0;i<bin[m]-1;++i) {
		//cout<<i<<" "<<g[i]<<endl;
		for(RI j=0;j<m;++j)
			if(!(i&bin[j]))
				g[i|bin[j]]=min(g[i|bin[j]],seg[j+1][in[j+1][g[i]-1]-1]+1);
	}
	//cout<<bin[m]-1<<" "<<g[bin[m]-1]<<endl;
	//cout<<endl;
}
void work3() {
	for(RI i=0;i<=n;++i) mi[i]=inf;
	for(RI i=0;i<bin[m];++i)
		mi[f[i]]=min(mi[f[i]],g[(bin[m]-1)^i]);
	for(RI i=n-1;i>=0;--i) mi[i]=min(mi[i],mi[i+1]);
	//for(RI i=0;i<=n;++i) cout<<mi[i]<<" ";
	//cout<<endl;
}

int main()
{
	n=read(),V=read();
	bin[0]=1;for(RI i=1;i<=20;++i) bin[i]=bin[i-1]<<1;
	for(RI i=1;i<=n;++i) x[i]=read();
	prework();while(V) V>>=1,++m,prework();
	work1(),work2(),work3();
	for(RI i=1;i<seg[0].size();++i) {
		int L=seg[0][i-1]+1,R=seg[0][i];
		if(mi[L-1]<=R+1) for(RI j=L;j<=R;++j) ans[j]=1;
	}
	for(RI i=1;i<=n;++i) puts(ans[i]?"Possible":"Impossible");
	return 0;
}

Measured memory_bytes: 26612
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
typedef long long           ll;
#define REP(i, n)           for (ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)       for (ll i = m ; i < (ll)n ; ++i)
#define INF                 (ll)1e15
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef pair<ll, ll>	    P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
// メイン
int main()
{
	string s, t;
	cin >> s >> t;

	set<ll> word[26];
	REP(i, s.size()) {
		int idx = s[i] - 'a';
		word[idx].insert(i);
	}

	ll ans = 0;
	ll tLen = t.size();
	for (ll tCnt = 0;;) {
		ll nowIdx = -1;
		for (; tCnt < tLen; tCnt++) {
			auto &wordOne = word[t[tCnt] - 'a'];
			auto idx = wordOne.lower_bound(nowIdx);
			if (idx == wordOne.end()) {
				break;
			}
			nowIdx = *idx + 1;
		}

		if (nowIdx == -1) {
			ans = -1;
			break;
		}

		if (tCnt == tLen) {
			ans += nowIdx;
			break;
		}

		ans += s.size();
	} 

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


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

int main() {
	int N, A;
	cin >> N;
	vector<int> vec(N);
	for (int i = 0; i < N - 1; i++) {
		cin >> A;
		vec.at(A - 1)++;
	}
	for (int j = 0; j < N; j++) {
		cout << vec.at(j) << endl;
	}
}

Measured memory_bytes: 3968
#include <stdio.h>
int main(void){
    // Your code here!
    long a,b,c,m,r;
    scanf("%ld %ld",&a,&b);
    c = b-a;
    r = 0;
    for(m=1;m<c;m++)
    {
        r += m;
    }
    printf("%ld\n",r-a);
    return 0;
}

Measured memory_bytes: 128
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for(int i=(a);i<(int)(n);i++)
#define repc(i, a, n) for(int i=(a);i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
#define DBG(str) cerr<<(str)<<endl;
int main() {
	string s, t;
	cin >> s >> t;
	int n = s.length();
	if (n == t.length()) {
		rep(i, 0, n) {
			bool is = true;
			rep(j, 0, n) {
				if (s[(j + i) % n] != t[j]) {
					is = false;
					break;
				}

			}
			if (is) {
				cout << "Yes";
				return 0;
			}

		}

	}
	cout << "No";
	return 0;
}





Measured memory_bytes: 256
#pragma region
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std; 
  
typedef long long LL; 
typedef pair<int, int> pii; 
typedef pair<LL, LL> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pii> vii; 
typedef vector<LL> vl; 
typedef vector<vl> vvl; 
typedef map<int,int> mii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
  

double EPS = 1e-9; 
int INF = 1000000005; 
long long INFF = 1000000000000000005LL; 
double PI = acos(-1); 
int mod = 1e9+7;
  
  
#define FOR(a, b, c) for (int(a) = (int)(b); (a) < (int)(c); ++(a)) 
#define FORD(a, b, c) for (int(a) = (int)(b); (a) >= (int)(c); --(a)) 
#define F first 
#define S second 
#define mp make_pair 
#define pb push_back 
#define pqb priority_queue<int>
#define pqs priority_queue<int,vi,greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define ps(x,y) fixed<<setprecision(y)<<x
#define ALL(v) v.begin(), v.end() 
#define SIZE(v) (int)v.size() 
#define SORT(v) sort(ALL(v)) 
#define SORTC(v, c) sort(ALL(v), c)
#define REVERSE(v) reverse(ALL(v)) 
#define SORTA(arr, sz) sort(ALLA(arr, sz)) 
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz)) 
#define test(x) int x; cin>>x; while(x--)
#define endl '\n'

void redir()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void showv(const vector<int> &v){for(auto &i:v) cout << i << " "; cout << endl;}
void showv2(const vector<vector<int>> &v1){for(auto &v:v1) showv(v);}
#pragma endregion


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

    int n, m, a, b;
    cin >> n >> m;

    vvi adj(n);
    vi visit(n,0);
    FOR(i,0,m)
    {
        cin >> a >> b;
        a--;
        b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }

    int maxx = INT_MIN;
    // int ans = 0;

    // cout << n << endl;

    for(int i = 0; i < n; i++)
    {
        int num = 0;
        if (!visit[i] && !adj[i].empty())
        {
            queue <int> q;
            q.push(i);
            visit[i] = 1;
            while(!q.empty())
            {
                auto s = q.front();
                q.pop();
                num++;
                
                for(auto k : adj[s])
                { 
                    if (!visit[k]) 
                    {
                        q.push(k);
                        visit[k] = 1;
                    }
                }
            }
        }
        if (num > maxx) maxx = num;
    }
    if (maxx == 0) maxx = 1;
    cout << maxx << endl;

    return 0; 
} 

Measured memory_bytes: 15604
H, W = map(int, input().split(" "))

status = []
for i in range(H):
    status.append([i for i in input()])

for i in range(H):
    for j in range(W):
        if status[i][j] == "#":
            if i - 1 >= 0:
                if status[i - 1][j] == "#":
                    continue
            if i + 1 <= H -1:
                if status[i + 1][j] == "#":
                    continue
            if j - 1 >= 0:
                if status[i][j - 1] == "#":
                    continue
            if j + 1 <= W -1:
                if status[i][j + 1] == "#":
                    continue
            print("No")
            exit()
print("Yes")

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

int main() {
  int n;cin>>n;
  int a=0,b=0,c=0;
  int an;
  rep(i,n) {
    cin>>an;
    if (an%4==0) a++;
    else if (an%4==2) b++;
    else c++;
  }
  if (a >= n/2) cout << "Yes";
  else if (c <= a) cout << "Yes";
  else cout<<"No";

}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())

void print(bool a)
{
    if (a == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

int main()
{
    string s;
    cin >> s;
    int l = 0, ans = 0;
    rep(i, 0, s.size())
    {
        if (s[i] == 'A' || s[i] == 'G' || s[i] == 'C' || s[i] == 'T')
        {
            l++;
        }
        else
        {
            ans = max(ans, l);
            l = 0;
        }
        if (i == s.size() - 1)
            ans = max(ans, l);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import numpy as np
L,R = map(int, input().split())
if (L//2019!=R//2019) or L%2019==0 or R%2019==0:
  print(0)
elif R-L==1:
  print((L*R)%2019)
else:
  l = L%2019
  r = R%2019
  ## l<r<2019
  a = []
  for i in range(r-l):
    for j in range(r-l-i):
      a.append(((l+i)*(l+i+j+1))%2019)
  print(min(a))


Measured memory_bytes: 84532
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;



int main() {
  ll n; cin >> n;
  ll ans = 0;
  for(int i = 1; i <= n; ++i) {
    if(i < n - i) ++ans;
    else break;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

string a, b;
set<string> can, can_not;
int ans = 0;
int dp[ 4001 ][ 4001 ];

int main() {
	while ( cin >> a ) {
		cin >> b;
		CLR( dp );
		ans = 0;
		if ( a.size() > b.size() ) {
			swap( a, b );
		}
		for ( int i = 0; i < a.size(); i++ ) {
			for ( int j = 0; j < b.size(); j++ ) {
				if ( a[ i ] == b[ j ] ) {
					if ( !i || !j ) {
						dp[ i ][ j ] = 1;
					}
					else {
						dp[ i ][ j ] = dp[ i - 1 ][ j - 1 ] + 1;
					}
				}
				ans = max( ans, dp[ i ][ j ] );
			}
		}
		printf( "%d\n", ans );
		can.clear();
		can_not.clear();
	}
	return 0;
}

Measured memory_bytes: 63744
import java.util.*;

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

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		long prime = (long)1e9 + 7;
		
		boolean[] ok = new boolean[N + 1];
		Arrays.fill(ok, true);
		for(int i = 0; i < M; i++) {
			ok[sc.nextInt()] = false;
		}
		sc.close();
		
		long stair[] = new long[N + 1];
		Arrays.fill(stair, 0);
		stair[0] = 1;
		for(int i = 0; i < N + 1; i++) {
			if(i < N)stair[i + 1] = (stair[i + 1] + ((ok[i + 1])?stair[i]:0)) % prime;
			if(i < N - 1)stair[i + 2] +=  (stair[i + 2] + ((ok[i + 2])?stair[i]:0)) % prime;
		}
		
		System.out.println(stair[N]);
	}
}

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

using namespace std;

typedef long long ll;

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 (a>b) { a=b; return 1; } return 0; }

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

	string s;
	cin >> s;

	if(s[0] >= 'a'){
		cout << "a" << endl;
	}else{
		cout << "A" << endl;
	}
}


Measured memory_bytes: 3608
N, M = map(int, input().split())
L, R = map(int, input().split())
for _ in range(M-1):
    l, r = map(int, input().split())
    if L < l:
        L = l
    if r < R:
        R = r
if R-L+1<=0:
    print(0)
else:
    print(R-L+1)

Measured memory_bytes: 3060