akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline

def make_Graph(N, edges):#頂点の名前はi - 1で受け付ける
    graph = [ [] for i in range(N)]
    for edge in edges:
        a, b, c = edge
        graph[a].append((b,c))
        graph[b].append((a,c))
    return graph

def BFS(N, graph, start):
    Q = []
    V = []
    prev = [None] * N
    dd = [float("inf")] * N
    Q.append(start)
    dd[start] = 0
    while len(V) < N:
        a = Q.pop(0)
        V.append(a)
        for b, c in graph[a]:
            if b != prev[a]:
                Q.append(b)
                prev[b] = a
                dd[b] = dd[a] + c
    return dd

def DFS(N, graph, a, p, d):
    dd[a] = d
    for b, c in graph[a]:
        if b == p or dd[b] != 0:
            continue
        else:
            DFS(N, graph, b, a, d + c)

N = int(input())

sys.setrecursionlimit(1000000)

graph = [ [] for i in range(N)]
for i in range(N-1):
    a, b, c = (int(j) for j in input().split())
    graph[a-1].append((b-1,c))
    graph[b-1].append((a-1,c))

Q, K =(int(i) for i in input().split())
dd = [0] * N

DFS(N, graph, K-1, -1, 0)

for i in range(Q):
    x, y = (int(a) for a in input().split())
    print(dd[x-1] + dd[y-1])

Measured memory_bytes: 201648
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  int start;
  int K;
  if(s[0] == '1'){
    K = 2*k+1;
    start = 1;
  }else{
    K = 2*k+1;
    start = 0;
  }
  vector<int> con(n+100001,0);
  int j = 1;
  con[0] = 0;
  con[1] = 1;
  for(int i = 1;i < n;i++){
    if(s[i] == s[i-1])con[j]++;
    else{
      ++j;
      con[j]++;
    }
  }
  int max,sum;
  sum = 0;
  max = 1;
  for(int l = start;l < K+start && l < j+1;l++){
    sum += con[l];
  }
  max = sum;
  for(int i = start;i <= j;i += 2){
    if(i == start){
    }else{
      sum -= con[i-1] + con[i-2];
      sum += con[i+K-1] + con[i+K-2];
      if(max < sum) max = sum;
    }
  }
  cout << max << endl;
}

Measured memory_bytes: 1280
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

var N int
var as []int
var sums []int

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &N)

	as = make([]int, N)
	sums = make([]int, N)
	for i := 0; i < N; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d", &as[i])
		if i == 0 {
			sums[i] = as[i]
		} else {
			sums[i] = sums[i-1] + as[i]
		}
	}

	ans := math.MaxInt64
	left, right := 0, 2
	for mid := 1; mid < N-2; mid++ {
		left = moveLeft(left, mid, sums[mid])
		right = moveRight(right, mid, sums[mid])
		s := make([]int, 4)
		s[0] = sums[left]
		s[1] = sums[mid] - sums[left]
		s[2] = sums[right] - sums[mid]
		s[3] = sums[N-1] - sums[right]
		m := max(s...) - min(s...)
		//fmt.Println(left, mid, right, "->", s, m)
		ans = min(ans, m)
	}
	fmt.Println(ans)
}

func moveLeft(index, mid int, sum int) int {
	leftf := func(index, sum int) int {
		return sum/2 - sums[index]
	}
	for index < mid-1 && leftf(index, sum) > 0 {
		index++
	}
	if index > 1 && abs(leftf(index-1, sum)) < abs(leftf(index, sum)) {
		index--
	}
	return index
}

func moveRight(index, mid int, sum int) int {
	rightf := func(index, sum int) int {
		return (sums[N-1]-sums[mid])/2 - (sums[index] - sums[mid])
	}
	for index < N && rightf(index, sum) > 0 {
		index++
	}
	if index > mid+1 && abs(rightf(index-1, sum)) < abs(rightf(index, sum)) {
		index--
	}
	return index
}

func min(ns ...int) int {
	ret := math.MaxInt64
	for _, n := range ns {
		if n < ret {
			ret = n
		}
	}
	return ret
}

func max(ns ...int) int {
	ret := math.MinInt64
	for _, n := range ns {
		if n > ret {
			ret = n
		}
	}
	return ret
}

func abs(n int) int {
	if n >= 0 {
		return n
	}
	return -n
}


Measured memory_bytes: 9728
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    int ans = n * m;

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



Measured memory_bytes: 3088
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N=in();
	auto S=vecin(N);

	int M=in();
	auto T=vecin(M);

	out(lexicographical_compare(ALL(S),ALL(T)) ?1:0);
	return 0;
}


Measured memory_bytes: 3156
from collections import deque

section = raw_input( )
area = 0
depthPosArr = deque( )
depthPosPoolArr = deque( )

for ipos, ground in enumerate( section ):
	if "\\" == ground:
		depthPosArr.append( ipos )
	elif "/" == ground:
		if len( depthPosArr ):
			jpos = depthPosArr.pop( )
			pool =  ipos - jpos
			area += pool

			while len( depthPosPoolArr ):
				preJPos, prePool = depthPosPoolArr.pop( )
				if jpos <= preJPos:
					pool += prePool
				else:
					depthPosPoolArr.append( ( preJPos, prePool ) )
					break
			depthPosPoolArr.append( ( jpos, pool ) )

print( area )
output = []
output.append( len( depthPosPoolArr ) )
for arr in depthPosPoolArr:
	output.append( arr[1] )
print( " ".join( map( str, output ) ) )

Measured memory_bytes: 5260
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

int N;
string S;
long long int J[100001];
long long int O[100001];
long long int I[100001];
long long int fst, fnl;
long long int ans;
long long int bag;

int main() {
	ios::sync_with_stdio(false);
	cin >> N;
	cin >> S;
	S = '0' + S;
	for (int i = 1; i <= N; i++) {
		J[i] = J[i - 1];
		O[i] = O[i - 1];
		I[i] = I[i - 1];
		if (S[i] == 'J') J[i]++;
		else if (S[i] == 'O')O[i]++;
		else I[i]++;
	}
	for (int i = 1; i <= N; i++) {
		if (S[i] == 'O')bag += J[i] * (I[N] - I[i]);
	}
	long long int box = 0;
	for (int i = 1; i <= N; i++) {
		if (S[i] == 'O')box += I[N] - I[i];
	}
	ans = box;
	box = 0;
	for (int i = 1; i <= N; i++) {
		if (S[i] == 'J')box += O[N] - O[i];
	}
	ans = max(ans, box);
	for (int i = 1; i < N; i++) {
		ans = max(ans, J[i] * (I[N] - I[i]));
	}
	cout << ans + bag << endl;
	return 0;
}

Measured memory_bytes: 5664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <random>
#include <cassert>
#include <numeric>
#define ll long long int
#define LL unsigned long long
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;

ll y[10000005];

int main() {
    int n,d,x,cnt = 0; cin >> n >> d >> x;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    rep(i,n){
        int I = 1;
        while(I <= d){
            cnt++;
            I += a[i];
        }
    }
    cout << cnt + x << endl;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h> 
using namespace std; 
#define rep(i,a,b)		for(long int i=a;i<=b;i++)
#define MOD 1e9+7
string a,b;
int main() 
{ 
	ios::sync_with_stdio(false);
    cin.tie(NULL); 
    cin>>a>>b;
    int n=a.length();
    bool ans = false;
    for(int i=0;i<a.size();i++)
    {
    	if(a==b)
    	{
    		ans = true;
    		break;
    	}
    	b=b.back()+b.substr(0,b.size()-1);
    }
    if(ans)
    	cout<<"Yes";
    else
    	cout<<"No";
}
	

Measured memory_bytes: 3580
import math
X = int(input())
Y = X
x = 1
y = 0
K = 1
while x != 0 or y != 0:
    x = round(x + math.cos(math.radians(X)),6)
    y = round(y + math.sin(math.radians(X)),6)
    X = X + Y 
    K += 1
print(K)

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n;
  string s;
  cin >> n >> s;

  vvll m(3);
  rep(i, n) {
    if (s[i] == 'R') {
      m[0].push_back(i);
    } else if (s[i] == 'G') {
      m[1].push_back(i);
    } else {
      m[2].push_back(i);
    }
  }

  ll ans = m[0].size() * m[1].size() * m[2].size();

  FORm(r, m[0]) {
    FORm(g, m[1]) {
      ll v = *r - *g;
      if (binary_search(all(m[2]), *r + v)) {
        ans--;
      }
      if (binary_search(all(m[2]), *g - v)) {
        ans--;
      }

      if (v % 2 == 0) {
        if (binary_search(all(m[2]), (*r + *g) / 2)) {
          ans--;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

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

const long long MOD = 1e9 + 7;
const int INF = 1e9;
const double EPS = 1e-9;

int main() {
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  int max_water = 0;
  int max_sugar = 0;
  double max_nodo = 0;
  for (int i = 0; i * 100 <= F; i += A) {
    for (int j = 0; (i + j) * 100 <= F; j += B) {
      if (i + j == 0) continue;
      int water = (i + j) * 100;
      int sugar = water / 100 * E;
      for (int k = 0; k <= F - water && k <= sugar; k += C) {
        for (int l = 0; k + l <= F - water && k + l <= sugar; l += D) {
          double nodo = (double)(k + l) / (double)(water + k + l);
          if (nodo >= max_nodo) {
            max_nodo = nodo;
            max_water = water;
            max_sugar = k + l;
          }
        }
      }
    }
  }
  cout << max_water + max_sugar << " " << max_sugar << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.IntStream;

public class Main {


	public static void main(String[] args) {
		new Main().execute();
	}

	public void execute() {
		Scanner sc = new Scanner(System.in);
		final int N =sc.nextInt();
		final int M = sc.nextInt();
		boolean[][] edges = new boolean[N][N];
		for (int i=0; i<M; i++){
			int from = sc.nextInt() -1;
			int to = sc.nextInt() - 1;
			edges[from][to] = edges[to][from] = true;
		}
		int [] path = IntStream.range(0, N).toArray();
		int count =0;
		do {
			if(path[0] !=0){
				continue;
			}
			boolean goodPath = true;
			for(int i=0; i<path.length-1; i++){
				if(!edges[path[i]][path[i+1]]){
					goodPath = false;
					break;
				}
			}
			if(goodPath){
				count +=1;
			}
		} while (nextPermutation(path));

		System.out.println(count);

		sc.close();
	}
	private boolean nextPermutation(int [] array) {
		int n = array.length;
		int k = n - 1;

		while (k > 0 && array[k] < array[k - 1]) {
			k--;
		}
		if (k == 0) {
			return false;
		}
		k -= 1;
		int l = n - 1;
		while (l > k && array[l] < array[k]) {
			l--;
		}
		int tmp;
		tmp = array[k];
		array[k] = array[l];
		array[l] = tmp;
		for (int i = k + 1, j = array.length - 1; i < j; i++, j--) {
			tmp = array[i];
			array[i] = array[j];
			array[j] = tmp;
		}
		return true;
	}

}

Measured memory_bytes: 27604
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args){
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
		String front="";
		String back="";
		try {
			r.readLine();
			front = r.readLine();
			back = r.readLine();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		for(int i=0;i<=back.length();i++){
			String test = front + back.substring(back.length()-i, back.length());
			if(test.indexOf(back) != -1){
				System.out.println(test.length());
				return;
			}
		}
	}
}


Measured memory_bytes: 8268
H, W = map(int, input().split())
M = [[0 if s == '.' else '#' for s in input()] for _ in range(H)]

m = ((1, 0), (-1, 0), (0, 1), (0, -1), (-1, -1), (1, 1), (-1, 1), (1, -1))

for i in range(H):
    for j in range(W):
        if M[i][j] == '#':
            for mi, mj in m:
                ni, nj = i+mi, j+mj
                if 0 <= ni < H and 0 <= nj < W and M[ni][nj] != '#':
                    M[ni][nj] += 1
    
for l in M:
    print(''.join(map(str, l)))


Measured memory_bytes: 3064
#include<stdio.h>
 
int main(){
    
    int i,j,n,pn[1000000],jp[1000000];
    while(scanf("%d",&n)!=EOF){
        pn[1]=0;
        for(i=2;i<1000000;i++)jp[i]=1;
        for(i=2;i<1000000;i++){
            if(jp[i]==1){
                pn[i]=pn[i-1]+1;
                for(j=2*i;j<1000000;j+=i)jp[j]=0;
            }
            else pn[i]=pn[i-1];
        }
        printf("%d\n",pn[n]);
    }
    return 0;
}

Measured memory_bytes: 8408
N,A,B=map(int, input().split())
X=list(map(int, input().split()))
ans=0
for i in range(N-1):
 if ((X[i+1]-X[i])*A<=B):
  ans+=(X[i+1]-X[i])*A
 else:
  ans+=B
print(ans)


Measured memory_bytes: 15020
#include <bits/stdc++.h>
#include <math.h>
#define say(a) cout<<a<<endl
#define say1(a,b) cout<<a<<" "<<b<<endl
#define loop(a,b) for(int i=a;i<b;i++)
#define pi 2*acos(0.0)
#define ll long long
#define f first
#define s second
//vector<int> v[200009];
using namespace std;
int mod =1e9;
int main()
{
    int n,sum=0,i;
    cin>>n;
    int a[n-1];
    for(i=0;i<(n-1);i++)
    {
        scanf("%d",&a[i]);
    }if(n==1) sum=2*a[0];
    else
    {
        sum+=a[n-2];
        for(i=(n-2);i>=0;i--)
    {
        if(i==0)
        {
            sum+=a[i];
        }else
        {
            sum+=min(a[i],a[i-1]);
        }
    }}say(sum);
}




Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
// g++ -std=c++11 prac.cpp
ll Max=-1,Min=1e9+1;

int main(){
    ll c,x=0,y=0,n,m,k,w,sum1=0,sum2=0,ans=0;
    string s,t;
    bool f=true;
    cin >> n;
    VI a(n);
    VI b(n);
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n){
        cin >> b[i];
        sum2 += b[i];
    }
    sum1 = a[0];
    Max = sum1 + sum2;

    for(int i=1; i<n;i++){
        sum1 += a[i];
        sum2 -= b[i-1];
        if(Max < sum1 + sum2){
            Max = sum1 + sum2;
        }
    }
    cout << Max << endl;
    return 0;
}



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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  for(int i = 0;i <= b;i++){
    if(i*a%b == c){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,D; cin>>N>>D;
    int x[10][10];
    REP(i,N){
        REP(j,D){
            cin >> x[i][j];
        }
    }

    int ans = 0;
    FOR(i,0,N) FOR(j,i+1,N){
        int s = 0;
        REP(k,D){
            s += (x[i][k]-x[j][k]) * (x[i][k]-x[j][k]);
        }
        dump(i)
        dump(j)
        dump(s)

        bool ok = 0;
        for(int t = 1; t * t <= s; t++){
            if(t*t == s){
                ok = 1;
                break;
            }
        }
        if(ok) ans++;
    }
    cout << ans << endl;

}

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

l = [0 for _ in range(8)]

b = 0

for i in range(N):
    if a[i] >= 3200:
        b += 1
    else:
        l[a[i] // 400] = 1

ans2 = sum(l) + b

ans1 = sum(l)
if ans1 == 0:
    ans1 = 1

print(ans1, ans2)


Measured memory_bytes: 3060
int m,n,P[1000],b[500],r[500],i,j,t;
char C[1000][1000],V[1000];
int h(x,y){return y?h(y,x%y):x;}
int g(x,y){return x>y?h(x,y):h(y,x);}
int match(s){int i=m;for(;i<m+n;i++)if(C[s][i]&&!V[i])if(V[i]=1,P[i]<0||match(P[i]))return P[s]=i,P[i]=s,1;return 0;}
main(){
  for(;scanf("%d%d",&m,&n),m;printf("%d\n",t)){
    memset(&C,0,sizeof(C)),memset(&P,0xff,sizeof(P));
    for(i=0;i<m;i++)scanf("%d",b+i);
    for(j=0;j<n;j++)scanf("%d",r+j);
    for(i=0;i<m;i++)for(j=0;j<n;j++)C[i][j+m]=C[j+m][i]=g(b[i],r[j])>=2;
    for(t=i=0;i<m;i++)memset(&V,0,sizeof(V)),t+=match(i);
  }
  return 0;
}

Measured memory_bytes: 1404
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

signed main() {
	int N, R;
	cin >> N >> R;
	if (N < 10)R += 100 * (10 - N);
	cout << R;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
#include <set>
using namespace std;
          
int main() {
    int n , k , b[10] = {} , d;
    cin >> n >> k;
    for ( int i = 0 ; i < k ; i++ ) {
        cin >> d;
        b[d] = 1;
    }
    for ( int i = n ; i < 100000 ; i++ ) {
        string a = to_string( i );
        bool c = 0;
        int d = i;
        while ( d ) {
            if ( b[d % 10] ) c = 1;
            d /= 10;
        }
        if ( c == 0 ) {
            cout << i;
            break;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pi pair<int, int>
#define F first
#define S second
#define PB push_back
#define EPB emplace_back
#define MP make_pair
#define deb(x) cerr << #x << ":" << x << endl;
#define deba(x) cerr << #x << ":\n"; for(auto i: x) cerr << i << " ";cout << endl;
const int INF = 1e7 + 7, MOD = 998244353;
#define float double
const float EPS = 0.001;
bool feq(float a, float b) { return abs(a - b) < EPS; }
bool fgt(float a, float b) { return a - b > EPS; }
bool flt(float a, float b) { return a - b < EPS; }



int main() {
	fastio();
	int n, k;
	cin >> n >> k;
	ll a[n+1] = {0};
	a[1] = 1;
	a[2] = -1;
	ll ans[n+1];
	int d[k][2];
	for(int i=0; i<k; i++) {
		cin >> d[i][0] >> d[i][1];
	}
	ll r = 0;
	for(int i=1; i<=n; i++) {
		ans[i] = (r%MOD + a[i]%MOD)%MOD;
		r = (r%MOD + a[i]%MOD)%MOD;
		for(int j=0; j<k; j++) {
			int l = i + d[j][0];
			int r = i + d[j][1];
			if(l <= n) a[l] = (a[l]%MOD + ans[i]%MOD)%MOD;
			if(r+1 <= n) a[r+1] = (a[r+1]%MOD - ans[i]%MOD + MOD)%MOD;
		}
	}
	cout << ans[n] << '\n';
	return 0;
}



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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "YES" << endl
#define CNO cout << "NO" << endl
#define SPC(x) cout << fixed << setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
typedef complex<ld> Point;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    bool ok = true;
    rep(i, n - 1) {
        if (a[i] == a[i + 1])
            ok = false;
    }
    if (ok)
        CYES;
    else
        CNO;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <regex>
using namespace std;
int main() {
    char s[11];
    cin >>s;
    regex re("A[a-z]+C[a-z]+");
    if (regex_match(s, re)) {
        cout<<"AC"<<endl;
    } else {
        cout<<"WA"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
M, K = map(int, input().split())
m2 = 2 ** M

s = 0
for i in range(m2):
  s ^= i


ans = [0 for i in range(m2 * 2)]
if K == 0:
  for i in range(m2):
    ans[i] = i
    ans[m2 * 2 - i - 1] = i
    
  print(" ".join(map(str, ans)))
elif K < m2 and s == 0:
  ans[0] = K
  ans[m2] = K
  for i in range(m2 - 1):
    num = i
    if num >= K:
      num += 1
    ans[i + 1] = num
    ans[m2 * 2 - i - 1] = num

  print(" ".join(map(str, ans)))
else:
  print(-1)
  



Measured memory_bytes: 27544
#include "bits/stdc++.h"
using namespace std;

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

const int INF = 1000000007;

int main(void){
	string S,T;
	cin>>S>>T;
	bool can = false;

	S += S;

	for(int i=0;i<S.size();i++){
		if(S.substr(i, T.size()) == T) can = true;
	}

	if(can) printf("Yes\n");
	else printf("No\n");

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int min_val[10];
	fill(min_val,min_val+10,123456789);
	int n;
	cin >> n;
	int sum = 0;
	for(int i=1,val;i<=n;i++) {
		cin >> val;
		min_val[val % 10] = min(min_val[val % 10],val);
		sum += val;
	}
	int ans = (sum % 10 == 0 ? 0 : sum);
	for(int i=0;i<10;i++)
		if((sum - min_val[i]) % 10 != 0)
			ans = max(ans,sum - min_val[i]);
	cout << ans << endl;
	return 0;
}


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


void max_self(ll& a, ll b) {
    a = max(a, b);
}
void min_self(ll& a, ll b) {
    a = min(a, b);
}

const ll INF = 1e18L + 5;

int main() {
    int n, W;
    scanf("%d%d", &n, &W);
    vector<int> weight(n), value(n);
    for(int i = 0; i < n; ++i) {
        scanf("%d%d", &weight[i], &value[i]);
    }
    int sum_value = 0;
    for(int x : value) {
        sum_value += x;
    }
    vector<ll> dp(sum_value + 1, INF); // 0 ... W
    dp[0] = 0;
    // dp[i] - the minimum total weight of items with total value exactly i
    for(int item = 0; item < n; ++item) {
        for(int value_already = sum_value - value[item]; value_already >= 0; --value_already) {
        //~ for(int weight_already = 0; weight_already <= W - weight; ++weight_already) {
            min_self(dp[value_already+value[item]], dp[value_already] + weight[item]);
        }
    }
    ll answer = 0;
    for(int i = 0; i <= sum_value; ++i) {
        if(dp[i] <= W) {
            answer = max(answer, (ll) i);
        }
        //~ min_self(answer, dp[i]);
    }
    printf("%lld\n", answer);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
int n,k,x,t,m;
string s;
vi a,b,c;
int main(){

	cin >> n;
	a.resize(n+5);
	b.resize(n+5);
	c.resize(n+5);
	
	for(int i =0;i<n;i++){
		cin >> a[i]>>b[i]>>c[i];
	}
	vi v;
	v.resize(3,0);
	vector<vector<int>> dp;
	dp.resize(n+5,v);
	for(int i =0;i<n;i++){
		if(!i){
			dp[i][0] = a[i];
			dp[i][1] = b[i];
			dp[i][2] = c[i];
		}else{
			dp[i][0] = max(dp[i-1][1],dp[i-1][2])+a[i];
			dp[i][1] = max(dp[i-1][0],dp[i-1][2])+b[i];
			dp[i][2] = max(dp[i-1][1],dp[i-1][0])+c[i];
				
		}
	}
	cout << max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
	return 0;
}

Measured memory_bytes: 6912
// スタックサイズ: 100MB

#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1e18;
const double EPS = 1e-10;
const ll mod = 1e9 + 7;
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }


ll gcd(ll a, ll b) {
	if (a < b) {
		a ^= b;
		b ^= a;
		a ^= b;
	}
	return b ? gcd(b, a % b) : a;
}


int main() {
	fastio;

	ll N; cin >> N;
	vll A(N);
	rep(i, N) cin >> A[i];

	vll L(N + 1, 0), R(N + 1, 0);
	fori(i, 1, N + 1) L[i] = gcd(L[i - 1], A[i - 1]);
	ford(i, 0, N) R[i] = gcd(R[i + 1], A[i]);

	ll ans = -1;
	rep(i, N) ans = max(ans, gcd(L[i], R[i + 1]));
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <numeric>

using namespace std;

bool isPrime(long long p) {
    if (p < 0) {
        p *= -1;
    }

    if (p == 0 || p == 1) {
        return false;
    } else if (p == 2) {
        return true;
    } else if (p % 2 == 0) {
        return false;
    }
    long long p_sqrt = sqrt(p);
    for (long long i = 3; i <= p_sqrt; i++) {
        if (p % i == 0) {
            return false;
        }
    }
    return true;
}

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

int main() {
    int N;
    cin >> N;
    vector<long long> a(N + 1);
    set<long long> ans;
    long long coef_gcd, tmp;
    coef_gcd = 0;

    for (int i = N; i >= 0; i--) {
        cin >> a[i];
        tmp = a[i];
        if (a[i] != 0) {
            if (tmp < 0) {
                tmp *= (-1);
            }
            if(coef_gcd == 0) {
                coef_gcd = tmp;
            } else {
                coef_gcd = gcd(tmp, coef_gcd);
            }
        }
    }
    
    for (long long i=2; i * i <= coef_gcd; i++) {
        while (coef_gcd % i == 0) {
            ans.insert(i);
            coef_gcd /= i;
        }
    }
    if (coef_gcd != 1) {
        ans.insert(coef_gcd);
    }

    for (long long p = 2; p <= N; p++) {
        if (isPrime(p)) {
            vector<long long> coeff(p, 0);
            coeff[0] = a[0];
            for (int i=1; i <= N; i++) {
                long long idx = i % (p-1) == 0 ? p-1 : i % (p-1);
                coeff[idx] += a[i];
            }
            int flag = 0;
            for (int i=0; i<p; i++) {
                if (coeff[i] % p != 0) {
                    flag = 1;
                    break;
                } 
            }
            if (flag == 0) {
                ans.insert(p);
            }
        }
    }
    
    for (auto it : ans) {
        cout << it << endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int A, B, C, K;
// vector<int> A;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> A >> B >> C >> K;
  // A.resize(N);
  // for (int i = 0; i < N; i++) {
  //   int tmp;
  //   cin >> tmp;
  //   A[i] = tmp;
  // }

  int ans = 0;
  if (K > 0) {
    int cnt = min(K, A);
    ans += cnt;
    K -= cnt;
  }

  if (K > 0) {
    int cnt = min(K, B);
    K -= cnt;
  }

  if (K > 0) {
    int cnt = min(K, C);
    ans -= cnt;
    K -= cnt;
  }

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


Measured memory_bytes: 3176
def contains(n, s):
	r, g, b = 0, 0, 0
	for i in s:
		if i == 'R':
			r += 1
		if i == 'G':
			g += 1
		if i == 'B':
			b += 1
	ans = r * g * b
	for i in range(len(s)):
		for j in range(i + 1, len(s)):
			k = j - i + j
			if k < len(s):
				if (s[i] == 'R' or s[j] == 'R' or s[k] == 'R') and (s[i] == 'G' or s[j] == 'G' or s[k] == 'G') and (s[i] == 'B' or s[j] == 'B' or s[k] == 'B'):
					# print(i, j, k)
					ans -= 1
	return ans


n = int(input())
s = input()
print(contains(n, s))

Measured memory_bytes: 9244
#include<stdio.h>
int main(){
	int a=0;
	int b=0;
	int c=0;
	scanf("%d %d %d\n",&a,&b,&c);
	int max=a;
	if(max<b){
		max=b;
	}
	if(max<c){
		max=c;
	}
	int ans=0;
	int n=max*3-a-b-c;
	if(n%2==0){
		ans=n/2;
	}else{
		ans=(n+3)/2;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>

typedef long long ll;

using namespace std;
const int maxn= 1e5+5;
pair<ll, ll> p[maxn];
int main()
{
	ll n,m;
	cin >> n >> m;
	bool flag = false;
	ll sum = 0;
	for(int i = 1; i <= n; i++){
		cin >> p[i].first >> p[i].second;
	}
	sort(p+1,p+1+n);
	for(int i = 1; i <= n; i++){
		sum += p[i].second;
		if(sum >= m){
			cout << p[i].first << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll  long long
#define ull unsigned long long  
using namespace std;
#define  inf 1e6+18
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mod 1000000007
#define  f1(i,n) for(i=1;i<=n;i++)
#define f0(i,n)  for(i=0;i<n;i++)
#define w(x)   while(x--)
const int maxn=1004;
#define  pq priority_queue
#define  ff first
#define  ss second 
#define pb  push_back
#define lb lower_bound
//Lordvishnu@almighty


int main()
{
	
	fastio;
	int i,j,k,l,n,m;
	cin>>n>>m>>k;
	map<pair<int,int>,int>mp;
	int cntx[n+2]={},cnty[m+2]={};
	for(i=1;i<=k;i++)
	{
		cin>>l>>j;
		cntx[l]++;
		cnty[j]++;
		mp[{l,j}]=1;
	}
	int lx=0,ly=0,mx=0,my=0;
	for(i=1;i<=n;i++)
     {
  			if(lx<cntx[i])
  			{
  				lx=cntx[i];
  				mx=i;
  			}

     }
     for(i=1;i<=m;i++)
     {
     	if(ly<cnty[i])
     	{
     		ly=cnty[i];
     		my=i;
     	}
     }
     l=0;
     l=lx+ly-mp[{mx,my}];
     for(auto it:mp)
     {
     	l=max(l,cntx[it.ff.ff]+cnty[it.ff.ss]-1);
     }
   //  cout<<lx+ly-mp[{mx,my}];
	//cout<<l;
	for(i=1;i<=m;i++)
	{
		l=max(l,cntx[mx]+cnty[i]-mp[{mx,i}]);
	}
	for(i=1;i<=n;i++)
	{
		l=max(l,cntx[i]+cnty[my]-mp[{i,my}]);

	}
	cout<<l;

}
//Lordvishnu@almighty

Measured memory_bytes: 62248
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    char last = s.back();
    s.push_back('2');
    // 1010101...という形で1と0の数を記録していく
    vector<int> x;
    if (s[0] == '0') x.push_back(0);
    int cnt = 0;
    REP(i,n) {
        char now = s[i];
        if (now != s[i+1]) {
            ++cnt;
            x.push_back(cnt);
            cnt = 0;
        }
        else cnt++;
    }
    if (last == '0') x.push_back(0);
    int right = 0;
    int ans = -1;
    int sum = 0;
    for (int left = 0; left < x.size(); ++left) {
        int end = 2*k+left;
        if (left%2 == 1) --end;
        while (right < x.size() && right <= end) {
            sum += x[right];
            //printf("l = %d, r = %d, sum = %d\n", left, right, sum);
            ++right;
        }
        ans = max(ans, sum);
    
        if (right == left) right++;
        sum -= x[left];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1020
import java.util.Arrays;
import java.util.Scanner;
class Main{
	public static void main(String[]$){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),k=s.nextInt();
		long[]a=new long[n+1],b=new long[n+1];
		for(int i=1;i<=n;++i) {
			a[i]=s.nextInt();
			b[i]=a[i]>0?a[i]:0;
		}
		Arrays.parallelPrefix(a,Long::sum);
		Arrays.parallelPrefix(b,Long::sum);
		long r=Long.MIN_VALUE;
		for(int i=0;i<=n-k;++i){
			System.out.println();
			r=Math.max(r,b[i]+b[n]-b[i+k]+Math.max(0,a[i+k]-a[i]));
		}
		System.out.println(r);
	}
}

Measured memory_bytes: 64688
#import random
import numpy as np
def main():
  d=int(input())
  c=np.array(list(map(int,input().split())))
  s=[None]*d
  r0=[None]*d
  r1=[None]*d
  cm=np.array([0]*26)
  cd=np.array([0]*26)
#t=[None]*d
  for i in range(d):
    s[i]=list(map(int,input().split()))
  s=np.array(s)
#for i in range(d):
#  t[i]=int(input())-1
  for j in range(d):  
    #rand = np.random.randint(26, size = 10) 
    #print(np.argmax(s[j])+1)
    r_i=np.argmax(s[j])
    cd=c*cm
    if np.max(cd>s[i][r_i]):
      r_i=np.argmax(cd)
    r0[j]=r_i
    for k in range(26):
      cm[k]+=1
    cm[r_i]=0
  #r_i+=1
  #print(r_i)
  cm=np.array([0]*26)
  cd=np.array([0]*26)  
  rand = np.random.randint(100, size = d) 
  for j in range(d):  
    #print(np.argmax(s[j])+1)
    r_i=r0[j]
    cd=c*cm
    if rand[j]>80:
      r_i=np.argmax(cd)
    r1[j]=r_i
    for k in range(26):
      cm[k]+=1
    cm[r_i]=0
#r0=t
  score0=0
  cm=np.array([0]*26)
  cd=np.array([0]*26)  
  for j in range(d):
    r0_j=r0[j]
    score0+=s[j][r0_j]
    for k in range(26):
      cm[k]+=1
      cm[r0_j]=0
    cd=c*cm
    score0+=-np.sum(cd)
  score1=0
  cm=np.array([0]*26)
  cd=np.array([0]*26)  
  for j in range(d):
    r0_j=r0[j]
    score1+=s[j][r0_j]
    for k in range(26):
      cm[k]+=1
      cm[r0_j]=0
    cd=c*cm
    score1+=-np.sum(cd)
  if score1>score0:
    r0=r1
    score0=score1
  #score1=0
  cm=np.array([0]*26)
  cd=np.array([0]*26)  
  rand = np.random.randint(100, size = d) 
  for j in range(d):  
    #print(np.argmax(s[j])+1)
    r_i=r0[j]
    cd=c*cm
    if rand[j]>75:
      r_i=np.argmax(cd)
    r1[j]=r_i
    for k in range(26):
      cm[k]+=1
    cm[r_i]=0
  
  score1=0
  cm=np.array([0]*26)
  cd=np.array([0]*26)  
  for j in range(d):
    r0_j=r0[j]
    score1+=s[j][r0_j]
    for k in range(26):
      cm[k]+=1
      cm[r0_j]=0
    cd=c*cm
    score1+=-np.sum(cd)
  if score1>score0:
    r0=r1
    score0=score1
  for j in range(d):  
    print(r0[j]+1) 
 
main()
  
    



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

#define ENDL '\n'
#define sayy cout<<"YES"<<ENDL;
#define sayn cout<<"NO"<<ENDL;

int main(){

    int n;
    cin >> n;

    vector<int> v(n);
    for(int i(0); i<n; i++){
        cin >> v.at(i);
    }

    int max(0);
    for(int i(v.size()-1); i>=1; i--){
        int temp(0),j(i);
        while(v[j] <= v[j-1]){
            temp++;
            j--;
        }
        if(temp > max) max = temp;
    }
    cout << max << ENDL;

    return 0;
}

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

#define size 13

int main(){
    int n;
    int num;
    char suit;
    int spade[size]={0}, heart[size]={0}, club[size]={0}, dia[size]={0};
    
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> suit >> num;
        if (suit == 'S'){
            spade[num-1] = 1;
        }
        if (suit == 'H'){
            heart[num-1] = 1;
        }
        if (suit == 'C'){
            club[num-1] = 1;
        }
        if (suit == 'D'){
            dia[num-1] = 1;
        }
    }
    for (int i = 0; i < size; i++){
        if(spade[i] == 0){
            cout << "S " << i+1 << endl;
        }
    }
    for (int i = 0; i < size; i++){
        if(heart[i] == 0){
            cout << "H " << i+1 << endl;
        }
    }
    for (int i = 0; i < size; i++){
        if(club[i] == 0){
            cout << "C " << i+1 << endl;
        }
    }
    for (int i = 0; i < size; i++){
        if(dia[i] == 0){
            cout << "D " << i+1 << endl;
        }
    }
    
}





Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define N 2001
using namespace std;

int ret;
int n;
int L[N];
bool check(int x,int y,int z){
	if(max(max(L[y],L[z]),L[x])<L[x]+L[y]+L[z]-max(max(L[y],L[z]),L[x])) return 1;
	else return 0;
}

int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; i++) scanf("%d",&L[i]);
	sort(L+1,L+n+1);
	if(n<=2) cout<<"0"<<endl;
    for(int i=1; i<=n; i++){
    	for(int j=1; j<i; j++){
    		int sum=L[i]+L[j];
			int r=n,l=i;
			int ans=-1;
			while(l<=r){
				int mid=(l+r)/2;
				if(sum>L[mid]){
					ans=mid;
					l=mid+1;
				}
				else r=mid-1;
			} 
			if(ans!=-1) ret+=ans-i;
		}
	}
	printf("%d",ret);
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		String line;
		String now = "A";
		while ((line = reader.readLine()) != null) {
			if (line.isEmpty())
				break;
			double a = Double.parseDouble(line);
			if(a>91.00)
				builder.append("heavy").append('\n');
			else if(a>81.00)
				builder.append("light heavy").append('\n');
			else if(a>75.00)
				builder.append("middle").append('\n');
			else if(a>69.00)
				builder.append("light middle").append('\n');
			else if(a>64.00)
				builder.append("welter").append('\n');
			else if(a>60.00)
				builder.append("light welter").append('\n');
			else if(a>57.00)
				builder.append("light").append('\n');
			else if(a>54.00)
				builder.append("feather").append('\n');
			else if(a>51.00)
				builder.append("bantam").append('\n');
			else if(a>48.00)
				builder.append("fly").append('\n');
			else
				builder.append("light fly").append('\n');
		}
		System.out.print(builder);
	}
}

Measured memory_bytes: 16904
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define INF 10000000
#define rep(i,a,b) for(int (i)=a;(i)<(int)(b);(i)++)
using ipair = pair<int,int>;
using itpl = tuple<int,int>;

int main(){
    int A,B,C,K;
    cin >> A >> B >> C>> K;
    if(K<=A) cout << K << endl;
    else if(K<=A+B) cout << A << endl;
    else cout << A - (K-A-B) << endl;

}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll a,b,x;
  cin >> a >> b >> x;
  if(a<=x&&x<=a+b) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   string s;
   cin >> s;
   if (s == "ABC")
      cout << "ARC" << endl;
   else
      cout << "ABC" << endl;
   return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N; cin >> N;

	vint P(N), X(N);
	vvint G(N);
	vint dp(N, 0);
	for (int i = 1; i < N; i++) {
		cin >> P[i]; --P[i];
		G[P[i]].push_back(i);
		dp[P[i]] = INF;
	}
	cin >> X;
	
	dp[N-1] = 0;
	for (int u = N-1; u >= 0; u--) {
		vvint dp2(G[u].size()+1, vint(X[u]+1, INF));
		dp2[0][0] = 0;
		for (int i = 0; i < G[u].size(); i++) {
			auto &v = G[u][i];
			if (X[u] >= X[v]) {
				for (int j = 0; j+X[v] <= X[u]; j++) {
					chmin(dp2[i+1][j+X[v]], dp2[i][j] + dp[v]);
				}
			}
			if (X[u] >= dp[v]) {
				for (int j = 0; j+dp[v] <= X[u]; j++) {
					chmin(dp2[i+1][j+dp[v]], dp2[i][j] + X[v]);
				}
			}
		}
		int minv = INF;
		for (int j = 0; j <= X[u]; j++) {
			chmin(minv, dp2[G[u].size()][j]);
		}
		dp[u] = minv;	
	}

	if (dp[0] == INF) {
		cout << "IMPOSSIBLE" << endl;
	} else {
		cout << "POSSIBLE" << endl;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 1332
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
int n,m,i,flag=0;
string s1,s2;
cin>>s1>>s2;
n=s1.size();
m=s2.size();
if(n>m){
    printf("GREATER");
}
else if(n<m){
    printf("LESS");
}
else{
    for(i=0;i<n;++i){
        if(s1[i]>s2[i]){
            flag=1;
            break;
        }
        else if(s1[i]<s2[i]){
            flag=2;
            break;
        }
    }
    if(flag==0){
        printf("EQUAL");
    }
    else if(flag==1){
        printf("GREATER");
    }
    else{
        printf("LESS");
    }
}




    return 0;
}


Measured memory_bytes: 3604
#include<cstdio>
#include<algorithm>

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

using namespace std;

int n,row[10000],col[10000];

bool solve(){
	sort(row,row+n);
	for(int i=n-1;i>=0;i--){
		rep(j,n){
			if(col[j]>0) col[j]--, row[i]--;
		}
		if(row[i]!=0) return false;
	}
	return true;
}

int main(){
	for(;scanf("%d",&n),n;){
		rep(i,n) scanf("%d",row+i);
		rep(j,n) scanf("%d",col+j);
		puts(solve()?"Yes":"No");
	}
	return 0;
}

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

int main(void){
    int n = 0;
    char s[51];
    int ans = 0;

    scanf("%d%s", &n, s);

    for(int i = 0; i < n -2; i++){
        if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C'){
            ans++;
        }
    }

    printf("%d\n", ans);
    
    return 0;

} 


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
using namespace std;

int main(){
    int n;
    long y;
    cin >> n >> y;
    for (int i = 0;i < y/10000+1;i++){
        for (int j=0;j<(y-10000*i)/5000+1;j++){
            int k = n - i - j;
            if (k>=0 && 10000*i+5000*j+1000*k==y){
                cout << i <<" "<< j <<" "<< k;
                return 0;
            }
        }
    }
    cout << -1 <<" "<< -1 <<" "<<-1;
}

Measured memory_bytes: 256
import collections
n = int(input())
a = list(map(int,input().split()))
c = dict(collections.Counter(a))
c = dict(sorted(c.items(),key = lambda x:x[0]))

ans = 0
for i in range(1,10**5):
  cnt = 0
  try:
    cnt += c[i-1]
  except KeyError:
    pass
  
  try:
    cnt += c[i]
  except KeyError:
    pass
    
  try:
    cnt += c[i+1]
  except KeyError:
    pass
    
  ans = max(ans,cnt)  
  
print(ans)  


Measured memory_bytes: 21084