akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int A,B,C,D,E,F,id1,id2;
double res=0;
vector<int> V1,V2;

int main()
{
    cin>>A>>B>>C>>D>>E>>F;
    for(int a=0;a<=30;a++)
        for(int b=0;b<=30;b++)
            if(a*A*100+b*B*100<=F)
                V1.push_back(a*A*100+b*B*100);
    for(int c=0;c<=3000;c++)
        for(int d=0;d<=3000;d++)
            if(c*C+d*D<=F)
                V2.push_back(c*C+d*D);
    for(int i=0;i<V1.size();i++)
        for(int j=0;j<V2.size();j++)
        {
            int t1=V1[i],t2=V2[j];
            if(t1+t2==0)
                continue;
            if(t1+t2<=F&&t1*E>=t2*100&&res*(t1+t2)<=100*t2)
            {
                res=double(100*t2)/double(t1+t2);
                id1=t1+t2;
                id2=t2;
            }
        }
    cout<<id1<<' '<<id2;
}


Measured memory_bytes: 1400
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val a = nextInt()
    val b = nextInt()
    val c = nextInt()
    val d = nextInt()
    println(Math.min(a, b) + Math.min(c, d))
}

fun next() = readLine()!!
fun nextInt() = next().toInt()

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 33556
import java.io.*;
import java.util.*;

public class Main implements Runnable {

    private void solve() throws IOException {

        int N = nextInt();

        long a = 0;
        long b = 0;

        long s = 0;
        long s2 = 0;
        long[] cur = new long[N];
        for (int i = 0; i < N; ++i) {
            cur[i] = nextInt();
            s += cur[i];
            s2 += cur[i];

            if((i + 1 ) % 2 != 0) {
                // pos
                if(s <= 0) {
                    a += Math.abs(s) + 1;
                    s += Math.abs(s) + 1;
                }
                if(s2 >= 0) {
                    b += Math.abs(s2) +1;
                    s2 -= Math.abs(s2) + 1;
                }

            } else {
                if(s >= 0) {
                    a += Math.abs(s) + 1;
                    s -= Math.abs(s) + 1;
                }
                if(s2 <= 0) {
                    b += Math.abs(s2) + 1;
                    s2 += Math.abs(s2) +1;
                }
            }
//            writer.println("s1" + " = " + s + " s2 = " + s2);
        }
//        writer.println(a + " " + b);
        writer.println(Math.min(a,b));
    }




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



    BufferedReader reader;
    //    BufferedReader reader2;
    StringTokenizer tokenizer;
    PrintWriter writer;
    //    BufferedWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
//            reader = new BufferedReader(new FileReader("input.txt"));
            //            reader2 = new BufferedReader(new FileReader("1.in"));
            tokenizer = null;
            writer = new PrintWriter(System.out);
//            writer = new     PrintWriter("output.txt");
//                                                    writer = new BufferedWriter(System.out);
            //                        writer = new BufferedWriter(new OutputStreamWriter(System.out));
            solve();
            reader.close();
            //            reader2.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    short nextShort() throws IOException {
        return Short.parseShort(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }

        return tokenizer.nextToken();
    }

}

Measured memory_bytes: 37028
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		Map<Integer, Integer> bMap = new HashMap<Integer, Integer>();
		for (int i = 0; i < n; i++) {
			bMap.put(i, sc.nextInt());
		}
		int c[] = new int[n - 1];
		for (int i = 0; i < n - 1; i++) {
			c[i] = sc.nextInt();
		}

		int pre = -1;
		int total = 0;
		for (int i = 0; i < n; i++) {
			total += bMap.get(a[i]-1);
			if (a[i] == pre + 1) {
				total += c[pre-1];
			}
			pre = a[i];
		}
		System.out.println(total);
		sc.close();
	}
}


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

int main() {
  int N,L;
  cin >> N >> L;
  int tab = 300;
  int aji=0;
  for(int i=1;i<=N;i++){
    if(abs(tab)>abs(L + i -1))
      tab = L + i -1;
    aji += L + i -1;
  }
  cout << aji-tab << endl;
}




Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
	long a, b, i, c=0;
	scanf("%ld%ld", &a, &b);
	if(( a <= 0 && b >= 0 ) || (a >= 0 && b <=0) ) printf("Zero\n");
	else if( a > 0 && b >0) printf("Positive\n");
	else if((b - a)%2 == 0) printf("Negative\n");
	else printf("Positive\n");
 
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
int main()
{
    int i;
    char O[51],E[51];
    scanf("%s %s",O,E);
    for(i=0;i<strlen(E);i++) printf("%c%c",O[i],E[i]);
    if(strlen(O)>i) printf("%c\n",O[i]);
    else puts("");
    return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        int w = Integer.parseInt(reader.readLine());
        int n = Integer.parseInt(reader.readLine());
        int[] numbers = new int[w];
        for (int i = 0; i < w; i++) {
            numbers[i] = i + 1;
        }
        for (int i = 0; i < n; i++) {
            String[] values = reader.readLine().split(",");
            int a = Integer.parseInt(values[0]);
            int b = Integer.parseInt(values[1]);
            int tmp = numbers[a - 1];
            numbers[a - 1] = numbers[b - 1];
            numbers[b - 1] = tmp;
        }
        for (int i = 0; i < w; i++) {
            out.println(numbers[i]);
        }
    }
}

Measured memory_bytes: 9364
import java.util.Scanner;

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

	private static void solve() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		sc.close();

		int count = 0;
		boolean flag = true;
		while (flag) {
			flag = false;
			for (int i = n - 1; i > 0; i--) {
				if (a[i] < a[i - 1]) {
					int tmp = a[i - 1];
					a[i - 1] = a[i];
					a[i] = tmp;
					count++;
					flag = true;
				}
			}
		}

		for (int i = 0; i < n; i++) {
			System.out.print(a[i]);
			if (i != n - 1) {
				System.out.print(" ");
			}
		}
		System.out.print("\n");
		System.out.println(count);
	}
}

Measured memory_bytes: 26416
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*2
#define REP(i,n) for(long long i = 0;i < n;++i)
int griding[1000][1000] = {};
long long bebe[40][5] = {};
long long costing[50][50] = {};
int main() {
#define int long long
	int n, c;
	cin >> n >> c;
	REP(i, c) {
		REP(q,  c) {
			cin >> costing[i][q];
		}
	}
	REP(i, n) {
		REP(q, n) {
			cin >> griding[i+1][q+1];
			griding[i+1][q+1]--;
			bebe[griding[i+1][q+1]][(i + q + 2) % 3]++;
		}
	}
	long long ans = 100000000000;
	for (int i = 0; i < c; ++i) {
		long long a = 0;
		for (int q = 0; q < c; ++q) {
			a += bebe[q][2] * costing[q][i];
		}
		for (int q = 0; q < c; ++q) {
			long long b = 0;
			for (int j = 0; j < c; ++j) {
				b += bebe[j][0] * costing[j][q];
			}
			if (i != q) {
				for (int j = 0; j < c; ++j) {
					if (i != j && q != j) {
						long long d = 0;
						for (int t = 0; t < c; ++t) {
							d += bebe[t][1] * costing[t][j];
						}
						ans = min(ans, a + b + d);
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX_N = 9;
vector<int> v[MAX_N];
int n, m;
int ans = 0;

void dfs(vector<bool> fl, int id)
{
    bool ch = true;
    for (int i = 1; i < fl.size(); i++)
    {
        ch &= fl[i];
    }
    if (ch)
    {
        ans++;
        return;
    }
    for (int i = 0; i < v[id].size(); i++)
    {
        if (fl[v[id][i]] == false)
        {
            fl[v[id][i]] = true;
            dfs(fl, v[id][i]);
            fl[v[id][i]] = false;
        }
    }
    return;
}

int main()
{
    cin >> n >> m;
    vector<bool> flag(n + 1);
    for (int i = 0; i <= n; i++)
    {
        flag[i] = false;
    }
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    flag[1] = true;
    dfs(flag, 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
  int N;
  cin >> N;
  ll ans = (ll)N*(N-1)/2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
 
class Main {
  public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str = br.readLine();
     
    String[] strAry = str.split(" ");
     
    int x = Integer.parseInt(strAry[0]);
    int y = Integer.parseInt(strAry[1]);
    int z = Integer.parseInt(strAry[2]);
    
    int i, cnt = 0;
    
    for(i = x; i <= y; i++){
    	if(z % i == 0)
     		cnt++;
    }
    System.out.println(cnt);
  }
}

Measured memory_bytes: 24460
#include<bits/stdc++.h>
using namespace std;
string s;
char ans[200007][7];
char anss[200007][7];
int main(){
    cin>>s;
    int n=s.size();
    int sta=0;
    int cnt=1;
    int flag=0;
    ans[cnt][0]=s[0];
    for(int i=1;i<n;++i){
        if(s[sta]==s[i]&&flag==0){
            if(i+1<n){
                cnt++;
                flag=1;
                i++;
                ans[cnt][0]=s[i-1];
                ans[cnt][1]=s[i];
            }
            else{
                if(i==1){
                    cnt--;
                    flag=2;
                }
            }
        }
        else if(s[sta]!=s[i]&&flag==0){
            cnt++;
            sta=i;
            ans[cnt][0]=s[i];
        }
        else if(flag==1){
            cnt++;
            sta=i;
            flag=0;
            ans[cnt][0]=s[i];
        }
    }
    /*if(flag==2){
        sta=n-1;
        int cntt=1;
        flag=0;
        anss[cntt][0]=s[n-1];
        for(int i=n-2;i>=0;--i){
            if(s[sta]==s[i]&&flag==0){
                if(i>0){
                    cntt++;
                    flag=1;
                    i--;
                    anss[cntt][0]=s[i+1];
                    anss[cntt][1]=s[i];
                }
                else{
                    if(i==n-2)
                        cntt--;
                }
            }
            else if(s[sta]!=s[i]&&flag==0){
                cntt++;
                sta=i;
                anss[cntt][0]=s[i];
            }
            else if(flag==1){
                cntt++;
                sta=i;
                flag=0;
                anss[cntt][0]=s[i];
            }
        }
        cnt=max(cnt,cntt);
    }*/
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 1924
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	nums := scanNums(n)
	abssum := 1000
	for i:= 0; i<n;i++{
		suma := 0
		sumb := 0
		for j:= 0; j<i;j++{
			suma += nums[j]
		}
		for j:= i; j<n;j++{
			sumb += nums[j]
		}
		abs := int(math.Abs(float64(suma - sumb)))
		if abssum > abs{
			abssum = abs
		}
	}
	fmt.Print(abssum)
}

func scanNums(len int) (nums []int) {
    var num int
    for i := 0; i < len; i++ {
        fmt.Scan(&num)
        nums = append(nums, num)
    }
    return
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll double
#define fr(a,b) for(int i = a; i < b; i++)
#define mod 1000000007
#define triplet pair<int,pair<int,int>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

ll dp[301][301][301];
ll solve(int one, int two, int three, int& n)
{
    if(one < 0 || two < 0 || three < 0)
        return 0;
    if(three == 0 && two == 0 && one == 0)
        return 0;

    if(dp[one][two][three] > 0)
        return dp[one][two][three];

    int remaining = one + two + three;
    ll exp_val = n+one*solve(one-1,two,three,n) + two*solve(one+1,two-1,three,n) +
                    three*solve(one,two+1,three-1,n);

    return dp[one][two][three] = exp_val/remaining;
}

int main(){
    int i,j,t,n,m,p,k;
    //fast_io;
    //cin>>t;
    t=1;
    while(t--)
    {
        cin>>n;
        int one=0,two=0,three=0;

        fr(0,n){
            int x;
            cin >> x;
            if(x == 1)one++;
            else if(x == 2)two++;
            else three++;
        }

        memset(dp, -1, sizeof dp);
        cout<<fixed<<setprecision(9)<<solve(one,two,three,n);
    }
    return 0;
}


Measured memory_bytes: 216796
#include <iostream>
#include <string>

using namespace std;

bool contains(const string& s, const string& p) {
  for (size_t i = 0; i < s.size(); ++i) {
    bool m = true;
    for (size_t j = 0; j < p.size(); ++j) {
      int k = j + i;
      if (j + i >= s.size()) {
        k = j + i - s.size();
      }
      if (s[k] != p[j]) {
        m = false;
        break;
      }
    }
    if (m) {
      return true;
    }
  }
  return false;
}

int main() {
  string s, p;
  cin >> s;
  cin >> p;

  if (contains(s, p)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#define FOR(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
using namespace std;

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

	int S, F, L;
	bool FF = false, LF = false;

	cin >> S;

	F = S / 100;
	L = S % 100;

	if (F >= 13 || F == 0) {
		FF = true;
	}
	if (L >= 13 || L == 0) {
		LF = true;
	}

	if (FF == false && LF == false)
	{
		cout << "AMBIGUOUS" << endl;
	}
	else if (FF == false && LF == true) {
		cout << "MMYY" << endl;
	}
	else if (FF == true && LF == false) {
		cout << "YYMM" << endl;
	}
	else if (FF == true && LF == true)
	{
		cout << "NA" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import itertools
N,C=map(int,input().split())
D=[[int(i) for i in input().split()] for i in range(C)]
c=[[int(i)-1 for i in input().split()] for i in range(N)]
X=[[] for i in range(3)]
for i in range(N):
    for j in range(N):
        X[(i+j)%3].append(c[i][j])
for i in range(3):
    X[i].sort()
Z=[[0 for i in range(C)] for j in range(3)]
for i in range(3):
    for j in X[i]:
        Z[i][j]+=1
#iwakan
I=[[0 for i in range(C)] for j in range(3)]
for i in range(3):
    for j in range(C):
        for k in range(C):
            I[i][j]+=Z[i][k]*D[k][j]
S=itertools.permutations(range(C),3)
ans=10**9
for sg in S:
    tmp=0
    for i in range(3):
        tmp+=I[i][sg[i]]
    if ans>tmp:
        ans=tmp
print(ans)


Measured memory_bytes: 7836
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

const int MAX_N = 100;

int main(int argc, char const *argv[])
{
	int n, idx=0;
	ll X[MAX_N], Y[MAX_N], h[MAX_N];
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> X[i] >> Y[i] >> h[i];
		if (h[i]>0) idx = i;
	}
	ll H, cx, cy;
    for (int x = 0; x < 101; ++x)
    {
    	for (int y = 0; y < 101; ++y)
    	{
    		bool tf = true;
    		H = h[idx] + abs(X[idx] - x) + abs(Y[idx] - y);
    		for (int i = 0; i < n and tf; ++i)
    		{
    			if (h[i] == max(H - abs(X[i] - x) - abs(Y[i] - y), (ll)0)) continue;
    			else tf = false;
    		}
    		if (tf)
    		{
    			cx = x; cy = y;
    			cout << cx << ' ' << cy << ' ' << H << endl;
    			return 0;
    		}
    	}
    }
	return 0;
}

Measured memory_bytes: 256
// Crt. 2020-01-08  16:06:51
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#define N 1000006
using namespace std;
const int Mod = 1e9 + 7;

inline void inc(int &x, int y) {
    x += y; if (x >= Mod) x -= Mod;
}

inline int MOD(int x) {
    return x >= Mod ? x - Mod : x;
}

int n, f[N], sum[N];

int main(){
#ifdef LOCAL_JUDGE
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif

    cin >> n;
    f[0] = sum[0] = f[1] = 1, sum[1] = 2;
    for (int i = 2; i <= n; ++i)
        f[i] = MOD(sum[i - 1] + Mod - f[i - 2]),
        sum[i] = MOD(sum[i - 1] + f[i]);

    int ans = 0;

    for (int i = 0; i <= n - 2; ++i)
        inc(ans, 1ll * f[i] * (n - 1) % Mod * (n - 1) % Mod);

    //cout <<"!"<< ans << endl;

    for (int i = 0; i <= n - 1; ++i)
        inc(ans, 1ll * f[i] * min(n - 1, i + 1) % Mod);

    //cout << "@"<<ans<<endl;

    //inc(ans, 1ll * f[n - 1] * (n - 1) % Mod);

    //cout <<"#"<< ans << endl;

    inc(ans, f[n]);

    cout << ans << endl;

	return 0;
}

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

int n;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	map<int, int> cnt;
	for(int i = 0; i < n; i++){
		int val;
		cin >> val;
		cnt[val]++;
	}
	int num[2] = {0, 0};
	for(auto &i : cnt) num[i.second % 2]++;
	if(num[0] % 2 == 1) cout << (int)cnt.size() - 1 << '\n';
	else cout << (int)cnt.size() << '\n';
	return 0;
}

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

int main(){
	int n;
  	cin>>n;
  	long long a=1,b=1;
  	for(int lp=0;lp<n;lp++){
    	long long xa,xb,x;
	    cin>>xa>>xb;
      	x=max(a/xa+!!(a%xa),b/xb+!!(b%xb));
      	a=xa*x, b=xb*x;
    }
    cout<<a+b<<endl;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

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

    private void run() {
        Scanner stdIn = new Scanner(System.in);

        while(stdIn.hasNext()){
            int m = stdIn.nextInt();
            int n = stdIn.nextInt();

            int p = m;
            int s = 0;
            int t = 0;
            int tmpP = m;
            int cnt = 0;

            while(true){
            	cnt++;
                m = m*10%n;
                p = (p*10%n)*10%n;
                if(m==p){
                    break;
                }
            }
            if(p!=0){
            	p = tmpP%n;
                s = 1;
                while(m!=p){
                    s++;
                    m = m*10%n;
                    p = p*10%n;
                }
                p = p*10%n;
                t = s;
                while(m!=p){
                    t++;
                    p = p*10%n;
                }
            }
            if(s==0&&t==0){
//                System.out.printf("%s\n", String.valueOf(tmpP*1.0/n).substring(2));
            	BigDecimal bg = new BigDecimal(tmpP*1.0/n).setScale(cnt, BigDecimal.ROUND_HALF_UP);
            	String str = bg.toString().substring(2);
            	System.out.println(str);
            }
            else{
                for(int i=0;i<t;i++){
                    System.out.print(tmpP*10/n);
                    tmpP = tmpP*10%n;
                }
                System.out.println();
            }
            if(s!=0&&t!=0){
                for(int i=1;i<=t;i++){
                    if(i>=s){
                        System.out.print("^");
                    }
                    else{
                        System.out.print(" ");
                    }
                }
                System.out.println();
            }
        }
    }
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
ll x[10], y[10];

double dist(ll i, ll j) {
  double dx = x[i] - x[j];
  double dy = y[i] - y[j];
  return pow(dx * dx + dy * dy, 0.5);
}

int main() {
  ll n, cnt = 0;
  cin >> n;
  vector<ll> v(n);
  for (int i = 0; i < n; ++i) cin >> x[i] >> y[i];
  double ans = 0;

  rep(i, n) for (int j = i + 1; j < n; ++j) ans += dist(i, j);

  cout << setprecision(16) << ans / n * 2 << endl;
  return 0;
}


Measured memory_bytes: 4144
////////////////////////////////////////////////////////////////
//
//    (☝ ՞ਊ ՞)☝ << Be accept!!
//
//    C++ format for competitive professional v1.0
//
//    GCC is recommendation.
//
////////////////////////////////////////////////////////////////

#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<time.h>
#include<random>
#include<thread>
#include<boost/multiprecision/cpp_int.hpp>

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

using ll = long long;
using namespace std;
using namespace boost::multiprecision;

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

int inline setup(void) {//set
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	return 0;
}
int lenght(char* str){//getcharlengh
	int i = 0;
	while (str[i]) {
		i++;
	}
	return i;
}
int gcd(long long a, long long b) {
	if (a < b)return gcd(b, a);
	long long r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
void func(int *a) {
	
	cout << a[0] << endl;

}
int main(int argc, const char* argv[]) {
	setup();

	char word;
	cin >> word;
	cout << (char)((int)word + 1) << endl;

	Be accept
}


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

int main(){
    int N;
    cin >> N;
    vector<int>v(N);
    for (int i = 0; i < N; i++){
        cin >> v.at(i);
    }
    sort(v.begin(), v.end());
    int nagai = v.at(N-1);
    int hoka = 0;
    for (int i = 0; i < N-1; i++){
        hoka += v.at(i);
    }
    if (hoka > nagai) {
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.par =[i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

n,m,k=map(int,input().split())
A=UnionFind(n)

friend=[0 for i in range(n+1)]
blocked={i:[] for i in range(1,n+1)}
for i in range(m):
    a,b=map(int,input().split())
    friend[a]+=1
    friend[b]+=1
    A.union(a,b)
    
    
for j in range(k):
    x,y=map(int,input().split())
    
    blocked[x].append(y)
    blocked[y].append(x)
    
for i in range(1,n+1):
    A.find(i)
    
parent=A.par

howmany={i:0 for i in range(n+1)}

for i in range(1,n+1):
    x=parent[i]
    howmany[parent[i]]+=1
    
#howmanyに同じグループが何個あるか

lists=[]
for i in range(1,n+1):
    sums=howmany[parent[i]]-1-friend[i]
    for some in blocked[i]:
        if parent[i]==parent[some]:
            sums-=1
    lists.append(sums)
print(*lists)   

Measured memory_bytes: 50432
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 5, M = 1e9 + 7;
long double P = 3.14159265358979323846;
int main()
{
    long double a, b, x, ans;
    cin >> a >> b >> x;
    x /= (a * a);
    if (b < 2 * x)
        ans = atan(2 * (b - x) / a) * (180 / P);
    else
        ans = atan((b * b) / (2 * a * x)) * (180 / P);
    cout << setprecision(18) << ans;
}


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

using namespace std;

int main(){
	vector<pair<int,pair<int,int>>>v;
	for(int i=1;i<150;++i){
		for(int j=i+1;j<=150;++j){
			v.push_back(make_pair(i*i+j*j,make_pair(i,j)));
		}
	}
	sort(v.begin(),v.end());
	int h,w;
	while(cin>>h>>w,h){
		int a=h*h+w*w;
		bool flag=0;
		for(auto x:v){
			if(flag){
				cout<<x.second.first<<" "<<x.second.second<<endl;
				break;
			}
			if(x.first==a && x.second.first==h){
				flag=1;
			}
		}
	}
}

Measured memory_bytes: 3196
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n; cin >> n;
    vl a(n);
    ll M = 0;
    ll maxcount = 0;
    ll maxindex;
    rep(i,n){
        cin >> a[i];
        if(a[i] == M) {
            maxcount++;
        }
        if(a[i] > M){
            M = a[i];
            maxcount = 1;
            maxindex = i;
        }
    }
    if(maxcount > 1){
        rep(i,n) cout << M << endl;
    }else{
        rep(i,n){
            if(i == maxindex){
                ll m=0;
                rep(j,n){
                    if(j == maxindex) continue;
                    m = max(a[j],m);
                }
                cout << m << endl;
            }else{
                cout << M << endl;
            }
        }
    }
}

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

int main() {
  int N;
  string S;
  int ans = 0;

  cin >> N >> S;

  //文字列を長さの分までループして調査する

  rep(i,N-2) {
    if (S.substr(i,3) == "ABC") ++ans;
  }

  cout << ans << endl;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  if(a < b && b < c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

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

const ll mod = 998244353LL;

int A,B,C,D;

#define MAX 3010
char f[MAX][MAX];
set<string> bf_S;

void dfs(int a,int b) {
  if( a > C || b > D ) return;
  if( a == C && b == D ) {
    string s = "";
    rep(i,C) rep(j,D) s += f[i][j];
    bf_S.insert(s);
    return;
  }
  // H
  rep(x,b) {
    char tmp = f[a][x];
    f[a][x] = '#';
    dfs(a+1,b);
    f[a][x] = tmp;
  }
  // W
  rep(y,a) {
    char tmp = f[y][b];
    f[y][b] = '#';
    dfs(a,b+1);
    f[y][b] = tmp;
  }
}

ll bf() {
  rep(i,C+1) rep(j,D+1) f[i][j] = '.';
  bf_S.clear();
  dfs(A,B);
  return bf_S.size();
}

ll dp[3110][3110];
ll idea2() {
  memset(dp,0,sizeof dp);
  dp[A][B] = 1;
  REP(y,A,C+1) {
    REP(x,B,D+1) {
      ll v1 = ( dp[y-1][x] * x ) % mod;
      ll v2 = ( dp[y][x-1] * y ) % mod;
      ll v3 = ( dp[y-1][x-1] * (x-1) ) % mod;
      v3 = ( v3 * ( y - 1 ) ) % mod;
      ll v4 = ( v1 + v2 ) % mod;
      ll v5 = ( v4 - v3 ) % mod;
      while( v5 < 0 ) { v5 += mod; v5 %= mod; }
      dp[y][x] += v5 ;
      dp[y][x] %= mod;
      while( dp[y][x] < 0 ) { dp[y][x] += mod; dp[y][x] %= mod; }
    }
  }
  /*
  rep(y,C+1) {
    rep(x,D+1) {
      cout << "dp[" << y << "][" << x << "] = " << dp[y][x] << endl;
    }
  }
  */
  return dp[C][D];
}

void solve() {
  //ll idea_cnt = idea();
  ll idea_cnt = idea2();
  //puts("----");
  //ll cnt = bf();
  /*
  for(auto s : bf_S) {
    assert( (int)s.size() == C*D );
    rep(i,C) {
      rep(j,D) {
	cout << s[j+i*D];
      } puts("");
    }puts("");
  }
  */
  /*
  puts("@@@@@");
  cout << "WRONG CASES---" << endl;
  for(auto s : idea_S) {
    if( bf_S.count(s) ) continue;
    rep(i,C) {
      rep(j,D) {
	cout << s[j+i*D];
      } puts("");
    }puts("");
  }
  puts("!!!!!");
  cout << "WRONG CASES sukunai---" << endl;
  for(auto s : bf_S) {
    if( idea_S.count(s) ) continue;
    rep(i,C) {
      rep(j,D) {
	cout << s[j+i*D];
      } puts("");
    }puts("");
  }
  */
  //cout << "Answer: " << cnt << endl;
  //cout << "Idea  : " << idea_cnt << endl;
  cout << idea_cnt << endl;
}

int main() {
  cin >> A >> B >> C >> D;
  solve();
  return 0;
}


Measured memory_bytes: 79196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  
  int X,Y; cin>>X>>Y;
  cout<<X+Y/2<<endl;
  return 0;
}


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

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

  int n; cin >> n;
  int cnt = 0;
  for(int i = 0; i < n; i++) {
  	int t; cin >> t;
  	while(t > 0 && t % 2 == 0) {
  		cnt++;
  		t /= 2;
  	}
  }
  cout << cnt << endl;
	return 0;
}	


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(int a, int b){
   return b ? GCD(b, a%b) : a;
}

int LCM(int a, int b){
   return (a * b)/(GCD(a, b));
}

int main(){
   int n, k;
   cin >> n >> k;
   string s;
   cin >> s;

   for(int i = 0; i < s.size(); i++){
      if(i == k-1){
         s[i] = tolower(s[i]);
      }
   }

   cout << s << endl;

   return 0;
}

Measured memory_bytes: 256
#ライブラリインポート
from collections import defaultdict

INF = float("inf")
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	S = list(input())
	N = len(S) + 1
	L = [INF] * N
	for i in range(N - 2):
		if S[i] == ">" and S[i + 1] == "<":
			L[i + 1] = 0
	if S[0] == "<":
		L[0] = 0
	if S[-1] == ">":
		L[-1] = 0

	for i in range(N - 1):
		if S[i] == "<" and L[i] != INF:
			L[i + 1] = L[i] + 1
	for i in range(N - 1):
		if S[-1 - i] == ">" and L[-1 - i] != INF:
			if L[-2 - i] == INF:
				L[-2 - i] = L[-1 - i] + 1
			else:
				L[-2 - i] = max(L[-1 - i] + 1, L[-2 - i])
	print(sum(L))

if __name__ == '__main__':
	main()

Measured memory_bytes: 99304
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

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

typedef vector<int> vi;

int main() {
	while (true) {
		int n, m, score[1001];
		vi v;
		cin >> n >> m;
		if (n == 0 && m == 0) break;
		REP(i, n) scanf("%d", &score[i]);
		score[n++] = 0;

		REP(i, n) FOR(j, i, n) if (score[i] + score[j] <= m)
			v.push_back(score[i] + score[j]);

		sort(v.begin(), v.end());
		unique(v.begin(), v.end());

		int ans = 0;
		REP(i, v.size()) {
			vi::iterator it = upper_bound(v.begin(), v.end(), m - v[i]);
			if (it != v.begin())
				ans = max(ans, *(it - 1) + v[i]);
		}

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

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

#define MAXLEN 2*10000


int mycmp(const void* aa, const void* bb) {
	const unsigned int* a = aa;
	const unsigned int* b = bb;
	if (*a > *b) {
		return 1;
	} else if (*a < *b) {
		return -1;
	} else {
		return 0;
	}
}

int main(void) {
	size_t n;
	scanf("%zu", &n);

	/* 以下はstack overflow を起こすのでmallocで動的に確保しよう*/
	/*
	unsigned int as[MAXLEN], bs[MAXLEN];
	for (size_t i = 0; i < MAXLEN; i++) {
		as[i] = -1;
		bs[i] = -1;
	}
	*/

	unsigned int* as = malloc(sizeof(unsigned int) * n);
	unsigned int* bs = malloc(sizeof(unsigned int) * n);

	for (size_t i = 0; i < n; i++) {
		scanf("%u %u", as+i, bs+i);
	}

	qsort(as, n, sizeof(unsigned int), mycmp);
	qsort(bs, n, sizeof(unsigned int), mycmp);

	unsigned int ans;
	
	if (n % 2 == 1) {
		unsigned int a, b;
		a = as[(n-1)/2];
		b = bs[(n-1)/2];
		ans = b - a + 1;
	} else {
		unsigned int a0, a1, b0, b1;
		a0 = as[(n-1)/2];
		a1 = as[n/2];
		b0 = bs[(n-1)/2];
		b1 = bs[n/2];
		ans = b0 - a0 + b1 - a1 + 1;
	}
	
	printf("%u\n", ans);
	//fprintf(stderr, "OK!\n");
	return 0;
}


Measured memory_bytes: 4092
while True:
	count=0
	num=list(map(int,input().split()))
	if num[0]==0 and num[1]==0:
		break
	else:
		for i in range(1,num[0]):
			for j in range(i+1,num[0]+1):
				for k in range(j+1,num[0]+1):
					if i+j+k==num[1] and i!=j and j!=k and k!=i:
						count+=1
	print(int(count)) 


Measured memory_bytes: 5596
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin >> s;

    for (int i = 0 ; i < s.size() ; i++){
        if (((i % 2 == 0)&&(s[i] == 'L'))||((i % 2 == 1)&&(s[i] == 'R'))){cout << "No" <<endl ; return 0;}
    }

    cout << "Yes" <<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

int main(){
	LL a,b,c;
	LL i,j,k;
	cin>>a>>b;
	if(b-a>=2019){
		cout<<0<<endl;
		return 0;
	}
	b%=2019,a%=2019;
	if(a>=b){
		cout<<0<<endl;
		return 0;
	}
	c=2019;
	for(i=a;i<=b;i++){
		for(j=i+1;j<=b;j++){
			k=(i*j)%2019;
			if(k<c)c=k;
		}
	}
	cout<<c<<endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val s = readLine()!!
  var ans = BooleanArray(n)
  
  for (i in 0..3) {
    (0..1).forEach { ans[it] = (i shr it and 1 == 1) }
    for (j in 0 until n) {
      ans[(j + 2) % n] = (ans[j] xor ans[(j + 1) % n] xor (s[(j + 1) % n] == 'o'))
    }
    if ((0..1).all { ans[it] == (i shr it and 1 == 1) }) {
      println(ans.map { if (it) 'S' else 'W' }.joinToString(""))
      return
    }
  }
  
  println(-1)
}


Measured memory_bytes: 39224
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	final static PrintStream so = System.out;
	final static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int n = sc.nextInt();
		
		int k = sc.nextInt();
		int[] a = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
		String[] b = new String[k];
		for (int i = 0; i < k; i++) {
			b[i] = sc.next();
		}
		
		int min = Integer.MAX_VALUE;
		
		for (int i5: a) {
			for (int i4: a) {
				for (int i3: a) {
					for (int i2: a) {
						loop: for (int i1: a) {
							int test = i5*10000 + i4*1000 + i3*100 + i2*10 + i1;
							String ts = String.valueOf(test);
							for (int i = 0; i < k; i++) {
								if (ts.contains(b[i])) {
									continue loop;
								}
							}
							if (test >= n) {
								min = Math.min(min, test);
							}
						}
					}
				}
			}
		}
		so.println(min);
	}
}


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

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

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

void primeFactor(ll val, map<ll,ll> &primeList){
  if(val<1){
    return;
  }
  for(int i=2;i*i<val;i++){
    while(val%i==0){
      primeList[i]++;
      val/=i;
    }
  }
  if(val!=1){
    primeList[val]=1;
  }
  return;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
ll near(ll val, ll d){
  if(val<0){
    return val+d;
  }else{
    return val-d;
  }
}

ll far(ll val, ll d){
  if(val<0){
    return val-d;
  }else{
    return val+d;
  }
}
int main() {
  int n;cin>>n;
  vector<int> l(n);
  for(int i=0;i<n;i++){
    cin>>l[i];
  }
  sort(all(l));
  int ans=0;
  if(n<3){
    cout<<ans<<endl;
    return 0;
  }
  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
      for(int k=j+1;k<n;k++){
        if(l[i]==l[j]||l[j]==l[k]||l[k]==l[i]){
          continue;
        }
        if(l[i]+l[j]>l[k]){
          ans++;
        }
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

const ll MOD=1e9+7;

ll ad(ll x,ll y=0){
  return (x+y)%MOD;
}

ll mlt(ll x,ll y=1){
  return (x*y)%MOD;
}

int main(){
  ll n,q,l,r,ac[100010]={};
  string s;
  cin>>n>>q>>s;
  Fr(i,n){
    ac[i+1]=ac[i];
    if(s[i-1]=='A'&&s[i]=='C') ac[i+1]++;
  }
  fr(i,q){
    cin>>l>>r;
    if(ac[l]>ac[l-1]){
      cout<<ac[r]-ac[l]<<endl;
    }
    else cout<<ac[r]-ac[l-1]<<endl;
  }
}

Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            c[i] = sc.nextInt();
        }
        Arrays.sort(a);
        Arrays.sort(b);
        Arrays.sort(c);

        long[] bc = new long[n];
        {
            int j = 0;
            for (int i = 0; i < n; i++) {
                while (j < n && b[i] >= c[j]) {
                    j++;
                }
                bc[i] = n - j;
            }
        }
        long ret = 0;

        for (int i = n-1; i > 0; i--) {
            bc[i-1] += bc[i];
        }
        {
            int j = 0;
            for (int i = 0; i < n; i++) {
                while (j < n && a[i] >= b[j]) {
                    j++;
                }
                ret += j < n ?bc[j] : 0;
            }
        }
        System.out.println(ret);
    }
}




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

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

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

    int n; cin>>n;
    int ans=0;

    for(int i=1; i<=n; i++) {
        for(int j=1; j<=n; j++) {
            for(int k=1; k<=n; k++) {
                ans+=gcd(i, gcd(j, k));
            }
        }
    }

    cout<<ans;

}


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

int main(){
  int x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;

  int e1_x= x2- x1;
  int e1_y= y2- y1;
  int e2_x= -e1_y;
  int e2_y=  e1_x;

  int x3= x2+ e2_x;
  int y3= y2+ e2_y;
  int x4= x1+ e2_x;
  int y4= y1+ e2_y;

  cout << x3 <<" "<< y3 <<" "<< x4 <<" "<< y4 << endl;
}

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

typedef long long ll;

int main() {
    int A, B, ans = 0;
    cin >> A >> B;
    for (int i = A; i <= B; i++) {
        string s = to_string(i);
        bool f = true;
        rep(i, 2) {
            if (s[i] != s[4 - i]) f = false;
        }
        if (f) ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
N, W = map(int, input().split())
v = []
w = []
for _ in range(N):
    value, weight = map(int, input().split())
    v.append(value)
    w.append(weight)

dp = [[0] * (W + 1) for _ in range(N+1)]


for i in range(N):
    for j in range(W+1):
        
        if j < w[i]:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j],
                             dp[i+1][j-w[i]] + v[i]
                             )    
print(dp[N][W])



Measured memory_bytes: 15688
N = int(input())

def order2(x):
  if x > 0 :
    k = 0
    check = 0
    while check == 0 :
      s = 0
      for i in range(0, k+1, 2):
        s += (-2)**i
        ans = i
      if s >= x:
        check = 1
      k += 2
  elif x < 0 :
    k = 1
    check = 0
    while check == 0 :
      s = 0
      for i in range(1, k+1, 2):
        s += (-2)**i
        ans = i
      if s <= x:
        check = 1
      k += 2
  return ans

if N!= 0 :


  l = [] 
  a = N
  i = order2(N)
  while i >= 0:
    if a == 0 :
      l.append('0')
    if a > 0 and (-2)**i >0 :
        s = 0
        for j in range(0, i, 2):
          s += (-2)**j
        if a > s :
          l.append('1')
          a -= (-2)**i
        else :
          l.append('0')
    elif a > 0 and (-2)**i < 0:
        l.append('0')
    elif a < 0 and (-2)**i > 0:
        l.append('0')
    elif a < 0 and (-2)**i < 0:
        s = 0
        for j in range(1, i, 2):
          s += (-2)**j
        if a < s :
          l.append('1')
          a -= (-2)**i
        else :
          l.append('0')
    i -= 1

  print(''.join(l))

else :
  print(0)

Measured memory_bytes: 3188
//-------------------------------------------
//-               Train Fare                -
//-                                         -
//-       autumn_eel niha katemasen!        -
//-------------------------------------------

#include<iostream>
#include<functional>
#include<queue>
#include<deque>
#include<vector>
#include<algorithm>
using namespace std;

void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (true) {
		k = getchar_unlocked();
		if (k < '0') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
inline void writeln(int x) {
	int s = 0; char f[7];
	while (x) {
		f[s++] = x % 10;
		x /= 10;
	}
	if (!s) f[s++] = 0;
	while (s--) putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}
#pragma warning(disable:4996)
int n, m, q, a[200003], b[200003], c[200003], d[200003], e[100003], f[100003], g[100003], dist[100003], E[200003];
vector<pair<int, int> > z[100003]; vector<int> x[100003];
vector<int>D[100003];
int main() {
	reader(&n); reader(&m); reader(&q);
	fill(d, d + m + 1, 1 << 30);
	for (int i = 1; i <= m; i++) { reader(&a[i]), reader(&b[i]); f[a[i]]++; f[b[i]]++; }
	for (int i = 1; i <= q; i++) reader(&c[i]), d[c[i]] = i;
	for (int i = 1; i <= n; i++) { x[i].resize(f[i]); }
	for (int i = 1; i <= m; i++) {
		x[a[i]][g[a[i]]] = b[i]; g[a[i]]++;
		x[b[i]][g[b[i]]] = a[i]; g[b[i]]++;
	}
	fill(dist, dist + n + 1, -1); dist[1] = 0;
	queue<int> Q1; Q1.emplace(1);
	while (!Q1.empty()) {
		int a1 = Q1.front(); Q1.pop();
		for (int i : x[a1]) {
			if (dist[i] == -1) {
				dist[i] = dist[a1] + 1;
				Q1.emplace(i);
			}
		}
	}
	for (int i = 1; i <= m; i++) {
		if (dist[a[i]] > dist[b[i]]) z[a[i]].emplace_back(make_pair(b[i], d[i]));
		if (dist[b[i]] > dist[a[i]]) z[b[i]].emplace_back(make_pair(a[i], d[i]));
	}
	for (int i = 1; i <= n; i++) D[dist[i]].push_back(i);
	e[1] = (1 << 30);
	for (int i = 1; i < n; i++) {
		for (int j : D[i]) {
			for (pair<int, int>k : z[j]) {
				e[j] = max(e[j], min(e[k.first], k.second));
			}
		}
	}
	for (int i = 2; i <= n; i++) {
		if (e[i] < 300000) E[e[i]]++;
	}
	for (int i = 1; i <= q; i++) {
		E[i] += E[i - 1];
		writeln(E[i]);
	}
	return 0;
}

Measured memory_bytes: 23600
n,m=map(int, input().split())
table = [0]*m
c = 0
for i in range(n):
    ans = list(map(int, input().split()))
    for j in range(1,len(ans)):
        table[ans[j]-1] += 1
for i in range(m):
    if table[i] == n:
        c += 1
print(c)



Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <limits>
#include <map>

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

using namespace std;
using p = pair<int, int>;
using ll = long long;

vector< vector<int> > memo;

int gcd(int a, int b, int c) {
	int min_num = (a > b) ? b : a;
	if (min_num > c) min_num = c;
	while (min_num != 1) {
		if (a % min_num == 0 && b % min_num == 0 && c % min_num == 0) break;
		min_num--;
	}
	return min_num;
}

int gcd(int a, int b) {
	int m = (a < b) ? a : b;
	while (m != 1) {
		if (a % m == 0 && b % m == 0)break;
		m--;
	}
	return m;
}

int main() {
	int n;
	ll ans = 0;
	cin >> n;
	rep(i, n) {
		rep(j, n) {
			int gcd_ij = gcd(i+1, j+1);
			rep(k, n) {
				ans += gcd(gcd_ij, k+1);
			}
			
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split()) 
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

x = ins()
s = []
for c in x:
  s.append(c)
  while len(s)>1 and s[-2]=='S' and s[-1]=='T':
    s.pop()
    s.pop()
print(len(s))


Measured memory_bytes: 51936
#include<cstdio>


int main(void)
{
	int n, x;

	while(scanf("%d%d", &n, &x)==2)
	{
		int ans=1;
		int p=0;

		for(int i=0;i<n;i++)
		{
			int l;
			scanf("%d", &l);
			p+=l;
			if(p<=x) ans++;
		}
		printf("%d\n", ans);
	}

	return 0;
}


Measured memory_bytes: 128