akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

string q[]={"Vacant","Male","Female"};


int main(){
  int n; cin >>n;
  int a=0,b=n-1;
  print(a); flush(cout);
  string s; cin >>s;
  if(s==q[0]) return 0;
  int aj=(s==q[1]);
  print(b); flush(cout);
  cin >>s;
  if(s==q[0]) return 0;
  int bj=(s==q[1]);
  while(1){
    int m=(a+b)/2;
    print(m); flush(cout);
    cin >>s;
    if(s==q[0]) return 0;
    int mj=(s==q[1]);
    if((m-a)%2==(mj+aj)%2){
      a=m; aj=mj;
    }else{
      b=m; bj=mj;
    }
  }
}


Measured memory_bytes: 852
//#define MYDEBUG
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <algorithm>
#include <queue>
#include <set>
#include <cstdio>
#include <unordered_map>

#ifdef MYDEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
using namespace std;

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
	out << "[";
	size_t last = v.size() - 1;
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i];
		if (i != last)
			out << ",";
	}
	out << "]";
	return out;
}

int main() {
	int n;
	string s;
	cin >> n >> s;
	//s="abc", s[0]='a', s[1]='b'
	//i=0 to N-1
	//	if s[i]=='I' ++
	//	else --
	int x = 0;
	int m = 0;
	debug(x);
	for (int i = 0; i < n; ++i) {
		if (s[i] == 'I')
			x++;
		else
			x--;
		if (m < x)
			m = x;
		//printf("x:%d, m:%d, i:%d, s[%d]:%c\n", x, m, i, i, s[i]);
	}
	cout << m << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n,m,l;
    int i,j,k;
    int a[110][110],b[110][110];
    long int c[110][110]={0};
    scanf("%d %d %d",&n,&m,&l);
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(i=0;i<m;i++){
        for(j=0;j<l;j++){
            scanf("%d",&b[i][j]);
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            for(k=0;k<m;k++){
                c[i][j]+=a[i][k]*b[k][j];
            }
            if(j!=0){
                printf(" ");
            }
            printf("%ld",c[i][j]);
        }
        putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int n;
    ll z, w;
    cin >> n >> z >> w;
    ll a[n];
    rep(i, n) {
        cin >> a[i];
    }
    ll ans = abs(a[n - 1] - w);
    if (n > 1) ans = max(ans, abs(a[n - 1] - a[n - 2]));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int main () {
  int n, m;
  cin >> n >> m;
  if(n >= m) {
    cout << 0;
    return 0;
  }
  vector<int> x(m);
  rep(i,m) cin >> x.at(i);
  sort(x.begin(),x.end());
  vector<int64_t> y(m-1);
  rep(i,m-1) {
    y.at(i) = abs(x.at(i+1) - x.at(i));
  }
  sort(y.begin(),y.end());
  reverse(y.begin(),y.end());
  int p=0;
  for(int i=n-1;i>0;i--) {
    y.at(p) = 0;
    p++;
  }
  int64_t ans = 0;
  rep(i,m-1) 
    ans += y.at(i);
  cout << ans;
}

Measured memory_bytes: 1408
package main

import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

func Solve() {
  var N int
  var A []int
  NextInt(&N)
  NextIntSlice(&A)
  B := append([]int{300}, A...)
  B = append(B, 0)
  C := 1000
  D := 0
  for i := 1; i <= N; i++ {
    if B[i - 1] >= B[i] && B[i] < B[i + 1] {
      D = C / B[i]
      C -= B[i] * D
    }
    if B[i - 1] < B[i] && B[i] >= B[i + 1] {
      C += B[i] * D
      D = 0
    }
  }
  Write(C)
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntSlice(A *[]int) {
  L := strings.Split(NextLine(), " ")
  if len(L) == 1 && L[0] == "" {
    (*A) = make([]int, 0)
    return
  }
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatSlice(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  if len(L) == 1 && L[0] == "" {
    (*A) = make([]float64, 0)
    return
  }
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(S ...interface{}) {
  fmt.Fprintln(writer, S...)
}
func WriteIntSlice(A []int) {
  B := make([]interface{}, len(A))
  for i, a := range A { B[i] = a }
  fmt.Fprintln(writer, B...)
}
func Output() {
  _ = writer.Flush()
}

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

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;
const int N = 2e5+5;

int dp[N];
signed main(){
	fastio
	int n,k;
	cin >> n >> k;
	
	int a[n];
	for(auto &x : a) cin >> x;
	for(int i = 0; i <= k;i++){
		for(auto x : a){
			if(i >= x) dp[i] |= !(dp[i-x]);
		}
	}
	cout << (dp[k] ? "First" : "Second") << "\n";
}


Measured memory_bytes: 4424
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A = 512

def main(N, V, W, v, L):
    def precompute(N, V, W):
        U = 10**5 + 10
        dp = np.zeros((A, U), np.int32)
        for v in range(1, min(A, N + 1)):
            p = v // 2
            dp[v] = dp[p]
            dp[v, W[v]:] = np.maximum(dp[v, W[v]:], dp[p, :-W[v]] + V[v])
            for i in range(1, U):
                dp[v][i] = max(dp[v][i], dp[v][i - 1])
        return dp

    dp = precompute(N, V, W)
    values = np.empty(A, np.int32)
    weights = np.empty(A, np.int32)

    def solve(i, lim, values, weights, dp):
        if i < A:
            return dp[i][lim]
        values[0] = 0
        weights[0] = 0
        p = 0
        while i >= A:
            for j in range(1 << p):
                values[j + (1 << p)] = values[j] + V[i]
                weights[j + (1 << p)] = weights[j] + W[i]
            p += 1
            i >>= 1
        best = 0
        for n in range(1 << p):
            if weights[n] > lim:
                continue
            x = dp[i][lim - weights[n]] + values[n]
            best = max(best, x)
        return best

    Q = len(v)
    for i in range(Q):
        x = solve(v[i], L[i], values, weights, dp)
        print(x)

        
if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('main', '(i4,i4[:],i4[:],i4[:],i4[:])')(main)
    cc.compile()
    exit()

from my_module import main

N = int(readline())
stdin = np.array(read().split(), np.int32)
V = np.zeros(N + 1, np.int32)
W = np.zeros(N + 1, np.int32)
V[1:] = stdin[:N + N:2]
W[1:] = stdin[1:N + N:2]
query = stdin[N + N + 1:]
v, L = query[::2].copy(), query[1::2].copy()

main(N, V, W, v, L)


Measured memory_bytes: 234740
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()

a = 1; t = T[0] + K; c = 1
for i in range(1,N):
    if T[i]>t or c+1>C:
        a += 1; t = T[i] + K; c = 1
    else:
        c += 1
print(a)


Measured memory_bytes: 13296
#include <bits/stdc++.h>
#define For(i, l, r) for(register int i = (l), _end_ = (int)(r); i <= _end_; ++i)
#define Fordown(i, r, l) for(register int i = (r), _end_ = (int)(l); i >= _end_; --i)
#define Set(a, v) memset(a, v, sizeof(a))
using namespace std;

bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
   int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar() ) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar() ) x = (x<<1) + (x<<3) + (ch ^ '0');
    return x * fh;
}

int n;
priority_queue<int> P;
int s[2], cur;

int main () {
	cin >> n;
	For (i, 1, n) P.push(read());
	while (!P.empty() ) {
		s[cur] += P.top();
		P.pop();
		cur ^= 1;
	}
	cout << s[0] - s[1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

int main()
{
	int  I, O, T, J, L, S, Z;
	std::cin >> I >> O >> T >> J >> L >> S >> Z;
	uint64_t res = 0;
	res += (I/2)*4/2;
	res += O*2/2;
	res += (J/2)*4/2;
	res += (L/2)*4/2;
	if((I>0 && J>0 && L>0)
	 && ((I %2)+(J %2)+(L %2) >= 2)){
		res += 6/2;
		if((I %2)+(J %2)+(L %2) >= 3){
		}
		else{
			res -= 4/2;
		}
	}
	std::cout << res << std::endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll N;
    cin >> N;

    ll highest = 0;
    ll H;
    ll ans = 0;
    rep(i, N){
        cin >> H;
        if(H >= highest){
            ans++;
            highest = H;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3592
from collections import defaultdict

n,m=map(int,input().split(' '))
paths=defaultdict(list)
for _ in range(m):
    a,b=map(int,input().split(' '))
    paths[a].append(b)
    paths[b].append(a)

parents=[1]
visited=[0]*(n+1)
visited[1]=1

def children(parents):
    children=[]
    for p in parents:
        for c in paths[p]:
            if visited[c]==0:
                children.append(c)
                visited[c]=p
    return children

while True:
    parents=children(parents)
    if parents==[]:
        break
print('Yes')
for i in range(2,n+1):
    print(visited[i])

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

int solve() {
	int n;
	cin >> n;
	int a[n];
	int i;
	for (i = 0; i < n; i++)cin >> a[i];
	if (n == 0)return 0;
	if (n == 1)return 0;
	int dp[n];
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	for (i = 2; i < n; i++) {
		dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]) , dp[i - 2] + abs(a[i] - a[i - 2]));
	}

	return dp[n - 1];
}




int32_t main() {
	std::ios::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
	cout << solve();
	return 0;
}

Measured memory_bytes: 4388
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;


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

	cout << (n + 2 * d) / (2 * d + 1) << endl;
}


Measured memory_bytes: 256
//int he name of god
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
int N,W;
const int maxn=2e5+7;
int w[maxn];
int v[maxn];
int dp[200][maxn];

int32_t main(){
    cin>>N>>W;
    for(int i=1;i<=N;i++){
        cin>>w[i]>>v[i];
    }
    int ans=0;
    dp[0][0]=0;
    for(int j=0;j<=W;j++){
        for(int i=1;i<=N;i++){
            if(j>=w[i]){
                dp[i][j]=max(dp[i-1][j] ,(j-w[i]<0 ? v[i]: dp[i-1][j-w[i]]+v[i]));
            }
            else{
                dp[i][j]=dp[i-1][j];
            }
            ans=max(ans,dp[i][j]);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 160512
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		int sum = 0;
		for (int i = 0; i < s.length(); i++) {
			sum += Integer.parseInt("" + s.charAt(i));
		}

		System.out.println(Integer.parseInt(s) % sum == 0 ? "Yes" : "No");

		sc.close();
	}
}


Measured memory_bytes: 23124
def solve(n, k, AB):
    AB.sort(key=lambda ab: ab[0])
    count = 0
    ret = -1
    for a, b in AB:
        count += b
        if k <= count:
            ret = a
            break
    return ret

_n, _k = map(int, input().split())
_AB = [list(map(int, input().split())) for _ in range(_n)]
print(solve(_n, _k, _AB))

Measured memory_bytes: 29144
#include <iostream>
#include <vector>
#define N_NUM 100000

std::vector<long long> amount(N_NUM+1,0);

int main() {
    int N;
    std::cin >> N;
    long long Sum = 0;
    for(int i=1;i<N+1;i++){
        int A_i;
        std::cin >> A_i;
        amount[A_i] ++ ;
        Sum += A_i;
    }

    int Q;
    std::cin >> Q;
    for(int i=0;i<Q;i++){
        int B_i,C_i;
        std::cin >> B_i >> C_i;
        Sum -= B_i*amount[B_i];
        Sum += C_i*amount[B_i];
        amount[C_i] += amount[B_i];
        amount[B_i] = 0;
        std::cout << Sum << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3792
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
int dig(int n){
    int cnt = 0;
    if(n == 0)
        cnt = 1;
    while(n){
        ++cnt;
        n /= 10;
    }
    return cnt;
}
void solve(){
    int n, m;
    cin>>n>>m;
    vector<pair<int, int>> vec(m);
    for(int i = 0; i < m; i++)
        cin>>vec[i].first>>vec[i].second;
    for(int i = 0; i < 1000; i++){
        bool f = true;
        for(auto itr : vec){
            int digit = i/pow(10, n-itr.first);
            digit %= 10;
            if(digit != itr.second){
                f = false;
                break;
            }
        }
        if(f && dig(i)==n){
            cout<<i;
            return ;
        }
    }
    cout<<"-1";
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 3764
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();    
        int N, M;
        {int[] a = r.ii(); N = a[0]; M = a[1];}
        boolean[] x = new boolean[N];
        boolean[] y = new boolean[N];
        for(int i = 0; i < M; i++){
            int[] z = r.ii();
            if(z[0] == 1)
                x[z[1]-1] = true;
            else if(z[1] == N)
                y[z[0]-1] = true;
        }
        for(int i = 0; i < N; i++){
            if(x[i]&&y[i]){
                println("POSSIBLE");
                return;
            }
        }
        println("IMPOSSIBLE");
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 49748
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static int mod =1000000007;
	public static void main(String[] args) {
		String S=sc.next();
		int v=753;
		
		int minV=0;
		for(int i=0;i+2<S.length();i++) {
			String a="";
			a=a+S.charAt(i)+S.charAt(i+1)+S.charAt(i+2);
			//p(a);
			if(i==0)minV=Math.abs(v-Integer.parseInt(a));
			else minV=Math.min(minV, Math.abs(v-Integer.parseInt(a)));
			//p("   "+Math.abs(v-Integer.parseInt(a)));
		}
		p(minV);
		}

	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 22608
from bisect import bisect_left, bisect_right

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
total = 0
for num in b:
    a_pos = bisect_left(a, num)
    c_pos = bisect_right(c, num)
    total += a_pos * (len(c) - c_pos)
print(total)

Measured memory_bytes: 23136
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		StringBuilder sb = new StringBuilder();

		for(int i=0;i<line.length();i++) {
			char c = line.charAt(i);
			if(Character.isUpperCase(c)) {
				c=Character.toLowerCase(c);
				sb.append(c);
			}else if(Character.isLowerCase(c)) {
				c=Character.toUpperCase(c);
				sb.append(c);
			}else if(!(Character.isAlphabetic(c))){
				sb.append(c);
			}else if(Character.isWhitespace(c)) {
				sb.append(" ");
			}
		}
		System.out.println(sb);
	}
}


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

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> costs(n+1);
  vector<vector<int>> rec(n+1, vector<int>(m+1));
  for (int i = 1; i <= n; ++i) {
    int c;
    cin >> c;
    costs[i] = c;
    for (int j = 1; j <= m; ++j) {
      int d;
      cin >> d;
      rec[i][j] = d;
    }
  }
  int limit = 1 << n;
  int mn = INT_MAX;
  vector<int> algs(m, 0);
  for (int v = 1; v < limit; v++) {
    int cost = 0;
    fill(algs.begin(), algs.end(), 0);
    for (int i = 0; i < n; i++) {
      if(v & (1 << i)) {
        cost += costs[i+1];
        for (int j = 1; j <= m; ++j) {
          algs[j-1] += rec[i+1][j];
        }
      }
    }
    bool cando = true;
    for(int j = 0; j < m; ++j) {
      if (algs[j] < x) {
        cando=false;
        break;
      }
    }
    if (cando) mn = min(mn, cost);
  }
  if (mn == INT_MAX) cout << -1 << endl;
  else cout << mn << endl;
  return 0;
}


Measured memory_bytes: 3628
from collections import Counter

n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
d = [x[:] for x in a]
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        l = []
        s = d[i][j]
        for k in range(n):
            if k == i or k == j:
                continue
            dist = d[i][k] + d[k][j]
            if dist == s:
                ans -= s
                break
            d[i][j] = min(d[i][j], dist)
for i in range(n):
    if a[i] != d[i]:
        print(-1)
        exit()
an = 0
for i in range(n):
    an += sum(a[i])
print(an // 2 + ans)

Measured memory_bytes: 44764
#include<stdio.h>
#include<stdlib.h>

void output(int *,int);

int main(void){
  int N,key;
  int *data;
  int i,j;

  scanf("%d",&N);

  data=(int *)malloc(N*sizeof(int));

  for(i=0;i<N;i++) scanf("%d",&data[i]);

  output(data,N);

  for(i=1;i<N;i++){
    key=data[i];
    j=i-1;
    while(j>=0 && data[j]>key){
      data[j+1]=data[j];
      j--;
    }
    data[j+1]=key;
    
    output(data,N);
  }

  free(data);

  return 0;
}


void output(int *data,int N){
  int i;

  printf("%d",data[0]);
  for(i=1;i<N;i++){
    printf(" %d",data[i]);
  }
  printf("\n");
}

Measured memory_bytes: 604
#include <iostream>
#include <limits>
#include <map>
#include <set>
#include <tuple>
#include <vector>
 
template <class... Ts> using tuple_t = std::tuple<Ts...>;
template <class T, class U> using map_t = std::map<T, U>;
template <class T, class U> using pair_t = std::pair<T, U>;
template <class T> using vector_t = std::vector<T>;
template <class T> using set_t = std::set<T>;
 
int min(vector_t<int> nums) {
  int min_ = std::numeric_limits<int>::max();
  for (auto &i : nums)
    if (min_ > i)
      min_ = i;
  return min_;
}
 
int max(vector_t<int> nums) {
  int max_ = std::numeric_limits<int>::min();
  for (auto &i : nums)
    if (max_ < i)
      max_ = i;
  return max_;
}
 
int main() {
  int A, B, C;
  std::cin >> A >> B >> C;
  std::cout << max({A, B, C}) - min({A, B, C}) << std::endl;
  return 0;
}

Measured memory_bytes: 256
from collections import deque
def bfs():
  d=[[float("inf")]*m for _ in range(n)]
  dx=[1,0,-1,0]
  dy=[0,1,0,-1]
  
  que=deque([])
  que.append((0,0))
  d[0][0]=0

  while que:
    p = que.popleft()
    if p[0]==n-1 and p[1]==m-1:
      break
    for i in range(4):
      nx=p[0]+dx[i]
      ny=p[1]+dy[i]
      if 0 <= nx < n and 0 <= ny < m and c[nx][ny] != "#" and d[nx][ny] == float("inf"):
                # 移動できるならキューに入れ、その点の距離を p からの距離 +1 で確定する
                que.append((nx, ny))
                d[nx][ny] = d[p[0]][p[1]] + 1
  return d[n-1][m-1]

n, m = map(int, input().split())
c = [list(input()) for i in range(n)]

count=0
for i in range(n):
  for j in range(m):
    if c[i][j]=="#":
      count+=1
g=bfs()
if 0<g<float("inf"):
  print(n*m-g-1-count)
else:
  print(-1)

Measured memory_bytes: 40688
n, m, r = gets.split.map(&:to_i)

if r - n * m < 0
    puts 0
    exit
end

a = n - 1 + r - n * m
b = n - 1
ans = 1 # aCb

b.times {|i| ans *= a - i}
b.times {|i| ans /= (i + 1)}
puts ans

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

vector<int> par;
vector<int> unirank;//parは親、unirankは木の深さ

void init(int n){
    for(int i = 0; i < n; i++) {
        par.push_back(i);
        unirank.push_back(0);
    }
}//初期化

int find(int x){
    if(par[x] == x){
        return x;
    }
    else{
        return par[x] = find(par[x]);
    }
}//木の根を求める

void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y) return;

    if(unirank[x]<unirank[y]){
        par[x]=y;
    }
    else{
        par[y]=x;
        if(unirank[x]==unirank[y]) unirank[x]++;
    }
}//xとyの属する集合を併合

bool same(int x,int y){
    return find(x) == find(y);
}//xとyが同じ集合に属するかどうか

int main() {
    int n,m;cin >> n >> m;
    init(n);
    for(int i = 0; i < m; i++) {
        int a,b;cin >> a >> b;
        a--,b--;
        if(!same(a,b)){
            unite(a,b);
        }
    }

    for(int i = 0; i < n; i++) {
        find(i);
    }
    vector<int> ans(n);
    for(int i = 0; i < n; i++) {
        ans[par[i]]++;
    }
    sort(ans.begin(),ans.end());
    reverse(ans.begin(),ans.end());
    cout << ans[0] << endl;
    return 0;
}

Measured memory_bytes: 5864
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int q = sc.nextInt();
		int[] l = new int[q];
		int[] r = new int[q];
		for(int i = 0 ; i < q ; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		}
		// エラトステネスの篩で素数を調べる
		int[] sosuu = new int[100010];
		for(int i = 3 ; i <= 100000 ; i++) {
			boolean ok = true;
			for(int j = 2 ; j * j <= i ; j++) {
				if(i == j) continue;
				if(i % j == 0 || ((i + 1) / 2) % j == 0) ok = false;
			}
			if(ok) sosuu[i]++;
		}
		int[] cnt = new int[100010];
		for(int i = 2 ; i < cnt.length ; i++) {
			cnt[i] = cnt[i - 1] + sosuu[i];
		}
		for(int i = 0 ; i < q ; i++) {
			System.out.println(cnt[r[i]] - cnt[l[i] - 1]);
		}
	}
}


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

using namespace std;

signed main() {
	int n; cin >> n;
	for (int c = 1; c <= n; ++c) {
		if ((int)(c * 1.08L) == n) {
			cout << c << endl;
			exit(0);
		}
	}
	cout << ":(" << endl;
	return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define  long          long long
# define  all(vc)       vc.begin(),vc.end()
# define  allr(vc)      vc.rbegin(),vc.rend()
# define  pb            push_back
# define  fi            first 
# define  se            second
# define  pi            pair <long, long>  
# define  lcm(a, b)     (a * b) / __gcd(a, b)  
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        using namespace std;
void read(){freopen("input.txt" , "r" , stdin );freopen("output.txt", "w" , stdout );}
void solve(){
	long n, d, res = 0;
	cin >> n;
	map <string, long> mp;
	for (int i = 0; i < n; ++i){
		string s;
		cin >> s;
		mp[s] ++;
	}
	cout << "AC x "  << mp["AC"]  << '\n';
	cout << "WA x "  << mp["WA"]  << '\n';
	cout << "TLE x " << mp["TLE"] << '\n';
	cout << "RE x "  << mp["RE"]  << '\n';
} 
int32_t main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); 
        cout << fixed << setprecision(9);
        long T = 1;
        //cin >> T;
        while( T-- ){
            solve();
            cout<<'\n';
        }
cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
} 													


Measured memory_bytes: 3816
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

typedef long long ll;

constexpr int INF = 1e8;
constexpr int MOD = 1e9+7;

int main(void) {
    int i, j;
    REP (i,1,9) REP (j,1,9) printf("%dx%d=%d\n",i,j,i*j);
    return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
 
const ll MOD=1e9+7;
const ll INF=1e18;
 
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};


int data[1005][4];

int main(){
    int n,m,r,q;
    while(true){
        cin >> n >> m;
        if(n + m == 0) break;
        cin >> r;
        for(int i = 0;i < r;i++){
            for(int j = 0;j < 4;j++){
                cin >> data[i][j];
            } 
        }
        vector<P> use[10005];
        for(int i = 0;i < r;i++){
            if(data[i][3] == 0) continue;
            for(int j = i+1;j < r;j++){
                if(data[i][1] == data[j][1] && data[i][2] == data[j][2]){
                    use[data[i][2]].push_back(P(data[i][0],data[j][0]));
                    break;
                }
            }
        }
        cin >> q;
        for(int i_ = 0;i_ < q;i_++){
            int a,b,stu,st,en;
            cin >> st >> en >> stu;
        //    cout << "st:" << st << ", en:" << en << endl;
            int ans = 0;

            for(int i = 0;i < use[stu].size();i++){
                a = use[stu][i].fs; b = use[stu][i].sc;
       //         cout << a << " " << b << endl;
                if(b <= st){ //1
                    continue;
                }else if(a <= st && b > st && b < en){ //2
                    ans += b - st;
                    st = b;
                }else if(a <= st && b >= en){ //3
                    ans += en - st;
                    break;
                }else if(a >= st && b < en){ // 4
                    ans += b - a;
                    st = b;
                }else if(a < en && b >= en){ // 5
                    ans += en - a;
                    break;
                }else{ // 6
                    break;
                }
            }
            cout << ans << endl;
        }

    }
}


Measured memory_bytes: 3228
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define mp make_pair
ll mod = 10e9+7;
ll mod2 = 998244353;

int main(){
    ll a,v;cin>>a>>v;
    ll b,w;cin>>b>>w;
    ll t;cin>>t;
    if (a<b){
        if (a+v*t>=b+w*t){
            cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }else{
        if (a-v*t<=b-w*t){
            cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }
}

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

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define forn(i,n) for(ll i=0;i<n;i++)
#define fore(i,a,b) for(ll i=a;i<=b;i++)
#define ford(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265

/******************************************************************************************************/
void file(){
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
}
/******************************************************************************************************/

const ll nax=2e5+1,mod=1e9+7;



int main(){

    sync
   // file();
    
    int a,b;
    cin>>a>>b;
    cout<<max(a+b,max(a-b,a*b));

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll x;
bool check(ll t)
{
	return t*(t+1)/2>=x;
}
int main(){
	cin>>x;
	ll l=0;
	ll r=x;
	while(l+1<r)
	{
		ll m=(l+r)/2;
		if(check(m)) r=m;
		else l=m;
	}
	cout<<r<<endl;
	return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x(x % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

struct combination {
    vector<mint> fact, ifact;

    combination(int n) : fact(n + 1), ifact(n + 1) {
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }

    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
} comb(100005);

mint f(int n, int k) {
    if (n < 0) return 0;
    // nPk = nCk * k!
    mint res = comb(n, k);
    res *= comb.fact[k];
    return res;
}

vector<pair<ll, ll>> prime_factorize(ll n) {
    vector<pair<ll, ll>> res;
    for (ll p = 2; p * p <= n; p++) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) {
            num++;
            n /= p;
        }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));

    return res;
}

int main() {
    int N;
    cin >> N;
    map<int, int> mp;
    for (int i = 1; i <= N; i++) {
        vector<pair<ll, ll>> primes = prime_factorize(i);
        for (auto p: primes) mp[p.first] += p.second;
    }

    mint ans = 1;
    for (auto p: mp) ans *= (p.second + 1);

    cout << ans.x << endl;
}

Measured memory_bytes: 1792
s = input()

acgt = ("A","C","G","T")
max_len = 0

for i in range(len(s)):
  t_max = 0
  for c in s[i:]:
    if c not in acgt:
      break
    t_max += 1
  max_len = max(t_max,max_len)

print(max_len)

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);
    sort(a.rbegin(),a.rend());
    ll ans = 0;
    int cnt = n - 1;
    rep(i,n){
        int lim = 2;
        if(i == 0) lim = 1;
        rep(j,lim){
            if(cnt > 0){
                ans += a.at(i);
                cnt--;
            }
        }
    }
    cout << ans << endl;
    
    
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int n;
  cin >> n;
  vector<int> a(n);

  int amax = -1;
  int amin = 200;
  map<int, int> mp;
  rep(i, n){
    cin >> a[i];
    chmax(amax, a[i]);
    chmin(amin, a[i]);
    mp[a[i]]++;
  }

  if(amax%2==0){

    if(amin != amax/2){
      cout << "Impossible" << endl;
      return 0;
    }

    if(mp[amin] != 1){
      cout << "Impossible" << endl;
      return 0;
    }

    for(int i = amin+1; i <= amax; i++){
      if(mp[i] < 2){
        cout << "Impossible" << endl;
        return 0;
      }
    }

    cout << "Possible" << endl;
  }else{

    if(amin != (amax+1)/2){
      cout << "Impossible" << endl;
      return 0;
    }

    if(mp[amin] != 2){
      cout << "Impossible" << endl;
      return 0;
    }

    for(int i = amin+1; i <= amax; i++){
      if(mp[i] < 2){
        cout << "Impossible" << endl;
        return 0;
      }
    }
    
    cout << "Possible" << endl;

  }

  return 0;
}


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

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n;
    std::cin >> n;
    std::string s1, s2;
    for (int q=0; q<n; q++) {
        std::cin >> s1 >> s2;
        int m1 = s1.size()+1;
        int m2 = s2.size()+1;
        int* dp = (int*)malloc(m1*m2*sizeof(int));
        for (int i=0; i<m1; i++) {
            dp[i*m2]=0;
        }
        for (int i=0; i<m2; i++) {
            dp[i]=0;
        }
        for (int i=1; i<m1; i++) {
            int leftmax=0;
            for (int j=1; j<m2; j++) {
                dp[i*m2+j] = leftmax;
                if (s1[i-1] == s2[j-1]) {
                    dp[i*m2+j]+=1;
                }
                if (dp[(i-1)*m2+j] > leftmax) {
                    leftmax = dp[(i-1)*m2+j];
                }
                if (dp[i*m2+j] < dp[(i-1)*m2+j]) {
                    dp[i*m2+j] = dp[(i-1)*m2+j];
                }
            }
        }
        int max=0;
        for (int i=0; i<m2; i++) {
            if (dp[(m1-1)*m2+i] > max) {
                max = dp[(m1-1)*m2+i];
            }
        }
        std::cout << max << "\n";
        free(dp);
    }

    return 0;
}


Measured memory_bytes: 7096
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<sstream>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<utility>
#include<queue>
#include<fstream>
using namespace std;
#define PI 3.14159265
long long gcd(long long a, long long b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
  
int main(){
	int n;
	cin>>n;
	int a[n], b[n], c[n-1];
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
		cin>>b[i];
	for(int i=0;i<n-1;i++)
		cin>>c[i];
	int sm=b[a[0]-1];
	for(int i=1;i<n;i++){
		if(a[i]-a[i-1]==1)
			sm+=(b[a[i]-1]+c[a[i-1]-1]);
		else
			sm+=b[a[i]-1];
	}
	cout<<sm;

}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(i, v) for(auto i =  v.begin(); i !=  v.end(); ++i)
#define RFOR(i, v) for(auto i = v.rbegin(); i != v.rend(); ++i)

template<typename T> bool setmin(T & a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T & a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T> ostream & operator<<(ostream & os, const vector<T> & v) {
	os << "[";
	FOR(it, v) {
		if(it != v.begin()) { os << ", "; }
		os << *it;
	}
	os << "]";
	return os;
}
template<typename F, typename S> ostream & operator<<(ostream & os, const pair<F, S> & p) {
	os << "<" << p.FI << ", " << p.SE << ">";
	return os;
}

// ---- ----

int k, s;
int ans;

int main() {
	cin >> k >> s;
	
	incII(i, 0, k) {
	incII(j, 0, k) {
		if(inII(s - i - j, 0, k)) { ans++; }
	}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() {
  int a, b;
  cin >> a >> b;
  cout << a+2 * (b - a) << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		
		if(n==1) {
			System.out.println("Yes\n2\n1 1\n1 1");
			return;
		}
		
		int m=0;
		{
			for(long i=0;i<=n;++i){
				if(i*(i-1)==n*2){
					m=(int)i;
				}
			}
			if(m==0){
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes\n"+m);

		StringJoiner[] sj=new StringJoiner[m];
		Arrays.setAll(sj,i->new StringJoiner(" "));
		{
			String t=String.valueOf(n*2/m);;
			Arrays.stream(sj).forEach(o->o.add(t));
		}

		int p=1;
		for(int i=0;i<m-1;++i){
			for(int j=i+1;j<m;++j){
				String P=String.valueOf(p);
				sj[i].add(P);
				sj[j].add(P);
				++p;
			}
		}
		Arrays.stream(sj).forEach(System.out::println);
	}
}


Measured memory_bytes: 47824
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(int i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 1e18
#define five 100005;
#define six 1000005;
#define prllclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
int main()
{
       string s;
       cin>>s;
       map<char,int> mp;
       fri(i,0,4){
              mp[s[i]]++;
       }
       if(mp.size()==2){
              map<char,int> :: iterator it = mp.begin();
              if(it->sc==2){
                     cout<<"Yes"<<endl;
                     return 0;
              }
       }
       cout<<"No"<<endl;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll INF = 9e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

int h, w, c;

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

int main() {
	cin >> h >> w >> c;
	cout << (h / gcd(h, w))*(w / gcd(h, w))*c << endl;
	return 0;
}


Measured memory_bytes: 3104
N,M,X=map(int,input().split())
A=list(map(int,input().split()))
x = 0
for i in range(X,N+1):
  if i in A:
    x += 1
y = 0
for i in range(X+1):
  if i in A:
    y += 1
print(min(x,y))

Measured memory_bytes: 9184
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
typedef long long ll;
using namespace std;

char c[5][5];
int main() {
    rep(i, 0, 3) {
        rep(j, 0, 3) {
            cin >> c[i][j];
        }
    }
    cout << c[0][0] << c[1][1] << c[2][2] << endl;
}

Measured memory_bytes: 256