akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using Graph = vector<vector<int>>;


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    REP(i, n){
        cin >> x[i];
    }
    sort(x.begin(), x.end());
    ll cost = 1000000001;
    FOR(i, x[0], x[n-1]+1){
        int p = i;
        ll sum = 0;
        REP(j, n){
            sum += (p - x[j]) * (p - x[j]);
        }
        cost = min(cost, sum);
    }
    cout << cost << endl;

}



Measured memory_bytes: 3612
# from collections import deque

N, M = map(int, input().split())
L = [[] for _ in range(N+1)]
for _ in range(M):
    a, b = map(int, input().split())
    L[a].append(b)
    L[b].append(a)

ans = [0]*(N+1)
now = [1]
# next = deque()
next = []
 
while len(now):
    # print('now', now)
    for x in now:
        for y in L[x]:
            if (ans[y] == 0):
                ans[y] = x
                next.append(y)
    now = next.copy()
    # now.popleft()
    next = []
 
print("Yes")
for x in range(2, N+1):
    print(ans[x])

Measured memory_bytes: 96520
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

string a[4] = {"dream","dreamer","erase","eraser"};
bool dp[100001];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	string s; cin>>s;
	dp[0] = 1;
	for(int i = 1; i <= s.length(); i++)
	{
		for(int j = 0; j < 4; j++)
		{
			int len = a[j].length();
			int l = i - len;
			if(l<0) continue;
			//cerr<<i<<' '<<l<<' '<<s.substr(i-len,len)<<'\n';
			if(s.substr(i-len,len)==a[j])
			{
				dp[i]|=dp[l];
			}
		}
		//cerr<<i<<' '<<dp[i]<<'\n';
	}
	if(dp[int(s.length())]) cout<<"YES\n";
	else cout<<"NO\n";
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;

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

    rep(i,0,2000){
        if((i*108/100 == i+a) && (i*110/100 == i+b)){
            ans = i;
            break;
        }
        if(i==100)ans = -1;
    }

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 256
//Volume2-0242
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

class Ward implements Comparable<Ward>{
	public String s;
	public int    cnt = 1;

	Ward(String s){
		this.s = s;
	}

	public int compareTo(Ward w){
		int ret;
		ret = w.cnt - this.cnt;
		if(ret == 0){
			ret = this.s.compareTo(w.s);
		}
		return ret;
	}

	public boolean equals(Object obj){
		Ward w = (Ward)obj;
		return this.s.equals(w.s);
	}
}

public class Main {

	public static void main(String[] args){

		//declare
		final int END = 0;

		ArrayList<Ward>  in  = new ArrayList<Ward>();
		Ward     wrd;
		int      n,idx,max;
		String   ward,k;
		String[] s;

		//input
        Scanner sc = new Scanner(System.in);
        while(true){
            n = Integer.parseInt(sc.nextLine());
            if(n==END){break;}
            in.clear();
            while(n-- > 0){
            	s = sc.nextLine().split("\\s");
            	for(int i=0;i<s.length;i++){
            		wrd = new Ward(s[i]);
            		if((idx = in.indexOf(wrd)) != -1){
            			in.get(idx).cnt++;
            		} else {
            			in.add(wrd);
            		}
            	}
            }
            k = sc.nextLine();

            Collections.sort(in);

            max = 0;
            for(int i=0;i<in.size() && max<5;i++){
            	ward = in.get(i).s;
            	if(ward.startsWith(k)){
            		if(max>0){
            			System.out.print(" ");
            		}
            		System.out.print(ward);
            		max++;
            	}
            }
            if(max == 0){
            	System.out.print("NA");
            }
            System.out.println();
        }
	}
}

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

int n;
double x,sum=0.0;
string s;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x>>s;
		if(s=="JPY"){
			sum+=x;
		}
		else{
			sum+=(x*380000.0);
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
// finish date: 2018/01/15
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int i=a;i<b;i++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000

vector<vector<int>> b, c, field;


int mul(int a, int b) {
    return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod);
}

int factorial(int n) {
    int ans = 1;
    FOR(i, 1, n + 1) {
        ans = ans * i;
    }
    return ans;
}


int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> d(N, vector<int>(N, INF));
    vector<int> a(M), b(M), c(M);
    rep(i, M) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
        d[a[i]][b[i]] = c[i];
        d[b[i]][a[i]] = c[i];
    }
    rep(i, N) d[i][i] = 0;
    rep(k, N) {
        rep(i, N) {
            rep(j, N) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    vector<int> isMinD(M, false);
    rep(i, N) {
        rep(j, M) {
            if (d[i][a[j]] + c[j] == d[i][b[j]]) {
                isMinD[j] = true;
            }
        }
    }
    int count = 0;
    rep(i, M) if (!isMinD[i]) count++;
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
n,ma,mb=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
suma=0;sumb=0
for i in range(n):
  suma+=l[i][0]
  sumb+=l[i][1]
dp=[[[float('inf') for i in range(sumb+1)] for j in range(suma+1)] for i in range(n+1)]
dp[0][0][0]=0
for i in range(n):
  for j in range(suma):
    for k in range(sumb):
      dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k])
      if j+l[i][0]<=suma and k+l[i][1]<=sumb:
        dp[i+1][j+l[i][0]][k+l[i][1]]=min(dp[i+1][j+l[i][0]][k+l[i][1]],dp[i][j][k]+l[i][2])
ans=[]
for j in range(suma+1):
  for k in range(sumb+1):
    if j*mb==k*ma and j*j!=0:
      ans.append(dp[n][j][k])
if min(ans)==float('inf'):
  print(-1)
else:
  print(min(ans))

Measured memory_bytes: 102748
li_a = []
ans = 0
N,M = map(int,input().split())
for i in range(N):
    a,b = map(int,input().split())
    li_a +=[[a,b]]
li_a.sort()
for i in range(N):
    if li_a[i][-1] >= M:
        ans += M * li_a[i][0]
        print(ans)
        break
    else:
        ans += li_a[i][-1] * li_a[i][0]
        M -= li_a[i][-1]





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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

ll x, y;

int main() {
	cin >> x >> y;
	if (abs(x-y)>1) cout << "Alice" << ln;
	else cout << "Brown" << ln;
}

Measured memory_bytes: 256
/**
 * Я слил Atcoder Beginner Contest 172, решив всего две задачи!
 * Я не могу апнуть синего!
 * Я постоянно сливаю раунды, либо не решив тупую задачу, либо набрав штрафа!
 * Я постоянно уступаю всем своим друзьям и знакомым в контестах и нахожу этому оправдания!
 * Я постоянно придумываю сложные неверные решения к простым задачам!
 * -------------------------------------------------------------
 * -Решать сложные задачи
 * -Участвовать в контестах
 * -Делать виртуальные соревнования
 * -------------------------------------------------------------
 * Не уберу это, пока не начну нормально решать задачи, а не заниматься ерундой!!!
**/
  
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
typedef long long  ll;
//typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set
// this for long double
#define press_F_to_pay_respect ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define form for(int j=0;j<n;j++) 
#define fore(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define pob pop_back()
#define mp make_pair 
#define sc second 
#define f first 
#define ld long double
#define kek cout<<endl; 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(v) ((v).begin()), ((v).end()) 
#define pob pop_back() 
#define halt {cout<<-1; return 0;}
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const int N = 1010;
const int INF = 1e8;
const ll MOD1=1073741824;
const long double pi=3.1415926535;
using namespace std;
using namespace __gnu_pbds;
typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
string bin_rep(int n)
{
          string s="";
      for(int i=31;i>=0;i--)
   {
           if(n&(1<<i)) s+='1';
           else s+='0';
   }
   return s;
}
int main()
{
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
 press_F_to_pay_respect;
 // cout << fixed << setprecision(12) << ans;
 // string al = "abcdefghijklmnopqrstuvwxyz";
 int n;
 cin>>n;
 ll a,b;
 cin>>a>>b;
 int cnt=0;
 while(n--)
 {
           ll l,r;
           cin>>l>>r;
           if(l>=a && r>=b) cnt++;
 }
 cout<<cnt;
 
    
 
 
 
  // cout <<"Runtime is:"<<clock() * 1.0 / CLOCKS_PER_SEC <<endl;
   return 0;
   
   
 
}

Measured memory_bytes: 3588
package main

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

var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

func nextInts(size int) []int {
	ns := make([]int, size)
	for i := 0; i < size; i++ {
		ns[i] = nextInt()
	}
	return ns
}

func fh(X []int, P int) int {
	var sum int
	for _, x := range X {
		sum += (x - P) * (x - P)
	}
	return sum
}

func main() {
	nextReader = newScanner()
	N := nextInt()
	X := nextInts(N)
	sort.Ints(X)
	l, r := 0, X[N-1]
	for l <= r {
		mid := l + (r-l)/2
		sl, sm, sr := fh(X, mid-1), fh(X, mid), fh(X, mid+1)
		if sl >= sm && sm <= sr {
			fmt.Println(sm)
			break
		} else if sl < sm {
			r = mid - 1
		} else {
			l = mid + 1
		}
	}
}


Measured memory_bytes: 640
n, a, b = map(str, input().split())
h = 0
ans = []

for i in range(1,int(n)+1):
	for j in str(i):
		h += int(j)
	if h >= int(a) and h <= int(b):
		ans.append(int(i))

	h = 0

print(sum(ans))

Measured memory_bytes: 3288
package main

import (
	"fmt"
	"strings"
)

func main() {
	s := readString()
	t := map[string]int{}

	for _, i := range strings.Split(s, "") {
		t[i] = 1
	}

	if len(t) == 2 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}



func readString() string {
	var v string
	fmt.Scanln(&v)
	return v
}

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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  
  int count=0;
  for (int i=0; i<=A;i++){
  	for (int j=0; j<=B; j++){
    	if (0<=(X-500*i-100*j)/50 && (X-500*i-100*j)/50<=C) count++;
    }
  }

  cout << count <<endl;
}


Measured memory_bytes: 256
def isOver(array,x,y):
	return True if (array[0]-x)**2+(array[1]-y)**2 <= 1.01 else False
	
while True:
    mx = 0
    n = int(raw_input())
    if n == 0: break
    seals = [map(float, raw_input().split(",")) for i in range(n)]
    x = 0
    while x < 10.0:
    	y = 0.0
    	while y < 10.0:
    		num = 0
    		for seal in seals:
    			if isOver(seal,x,y):
    				num += 1
    		mx = max(mx,num)
    		y += 0.1
        x += 0.1
    print mx

Measured memory_bytes: 4280
main :: IO ()
main = do
    [h, w, k] <- map read . words <$> getLine
    xs <- sequence $ replicate h getLine 
    let selects = [(hs, ws) | hs <- subs [1..h], ws <- subs [1..w]]
    let res = map (validate xs) selects
    putStrLn $ show $ count k res
        where
            validate xs (hs, ws) = 
                let rm1 = reduce 1 hs xs
                    rm2 = map (reduce 1 ws) rm1
                in count '#' $ concat rm2
            reduce _ _  [] = []
            reduce n hs (x:xs) = if n `elem` hs
                then reduce (n + 1) hs xs
                else x : reduce (n + 1) hs xs
            count _ [] = 0
            count y (x:xs) 
                | x == y = 1 + count y xs
                | otherwise = count y xs

subs :: [a] -> [[a]]
subs [] = [[]]
subs (x:xs) = yss ++ map (x:) yss
    where yss = subs xs
    

Measured memory_bytes: 5000
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		long n=sc.nextLong();
		long m=sc.nextLong();
		long count=0;
		if(2*n<=m){
			count+=n;
			m-=2*n;
			count+=m/4;
		}else{
			count=m/2;
		}
		System.out.println(count);
	}
}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    t.pop_back();
    if(s == t){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3636
import java.util.Scanner;

//Seven Segments
public class Main{

	public static void main(String[] args) {
		String[] seg = {"1111110", "0110000","1101101","1111001","0110011","1011011","1011111","1110010","1111111","1111011"};
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==-1)break;
			String s = "0000000";
			while(n--!=0){
				String t = seg[sc.nextInt()];
				char[] r = new char[7];
				for(int i=0;i<7;i++)r[i]=t.charAt(6-i)==s.charAt(6-i)?'0':'1';
				System.out.println(r);
				s = t;
			}
		}
	}
}

Measured memory_bytes: 12000
#include <math.h>
#define E 0.00000001
#define zero(n) (fabs(n)<E)
main(n,a,b,c,d,p,q,r,D,f){
	for(scanf("%d",&n);n;n--){
		scanf("%d%d%d%d",&a,&b,&c,&d); //fx=ax3+bx2+cx+d
		f=0;if(a<0)a=-a,b=-b,c=-c,d=-d;//,f=1;
		int k[2]={0};//plus,minus
		p=3*a,q=2*b,r=c,D=q*q-4*p*r; //f'x=3ax2+2bx+c D: f'x=0?
		if(D>0){
			double x1=(-q-sqrt(D))/p/2,x2=(-q+sqrt(D))/p/2;
			double y1=a*x1*x1*x1+b*x1*x1+c*x1+d;
			double y2=a*x2*x2*x2+b*x2*x2+c*x2+d;
//printf("--- %f %f %f %f %d\n",x1,x2,y1,y2,!zero(y1)&&!zero(y2)>E&&y1*y2>0);
			if(!zero(y1)&&!zero(y2)>E&&y1*y2>0)goto one;
			if(zero(x1)){
				if(d==0)k[0]=1,k[1]=0;
				else k[0]=2,k[1]=1;
			}else if(zero(x2)){
				if(d==0)k[0]=0,k[1]=1;
				else k[0]=1,k[1]=2;
			}else if(x1>0){
				if(d>0)k[0]=2,k[1]=1;
				else if(d<0)k[0]=3,k[1]=0;
				else k[0]=2,k[1]=0;
			}else if(x2<0){
				if(d>0)k[0]=0,k[1]=3;
				else if(d<0)k[0]=1,k[1]=2;
				else k[0]=0,k[1]=2;
			}else{
				if(d>0)k[0]=2,k[1]=1;
				else if(d<0)k[0]=1,k[1]=2;
				else k[0]=1,k[1]=1;
			}
		}else if(D==0){
			if(d>0)k[0]=0,k[1]=1;
			else if(d<0)k[0]=1,k[1]=0;
		}else{
one:
			if(d>0)k[0]=0,k[1]=1;
			else if(d<0)k[0]=1,k[1]=0;
		}
		printf("%d %d\n",k[f],k[!f]);
	}
	return 0;
}

Measured memory_bytes: 600
"""
AtCoder
    :author: vierbein
"""
from __future__ import absolute_import, division, print_function

# import itertools as it
# import collections
import sys


def pp(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)


A, B = map(int, input().split())

res = max(A + B, A - B, A * B)
print(res)

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

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

  vector<int> data(N);
  for(int i=0; i<N; i++){
    cin >> data.at(i);
  }

  int cumgcd= data.at(0);
  for(int i=0; i<N; i++){
    cumgcd= gcd(cumgcd, data.at(i));
  }

  if(cumgcd != 1){
    cout << "not coprime" << endl;
  }
  else{
    constexpr int Vmax= 1'000'000;
    vector<int> smallest_factors(Vmax+1);
    iota(smallest_factors.begin(), smallest_factors.end(), 0);
    for(int p=2; p<= Vmax; p++){
      if(smallest_factors.at(p)==p){
        for(int m= 2*p; m<= Vmax; m+=p){
          if(smallest_factors.at(m)==m){
            smallest_factors.at(m)= p;
          }
        }
      }
    }

    bool pairwise_coprime= true;
    unordered_set<int> factors;
    for(auto num:data){
      unordered_set<int> factors_num;
      while(num > 1){
        int p= smallest_factors.at(num);
        factors_num.insert(p);
        num/= p;
      }

      for(auto p:factors_num){
        if(factors.count(p)){
          pairwise_coprime= false;
          break;
        }
        else{
          factors.insert(p);
        }
      }
      
      if(!pairwise_coprime){ break; }
    }

    string ans= pairwise_coprime ? "pairwise coprime"
                                 : "setwise coprime";
    cout << ans << endl;
  }
}

Measured memory_bytes: 11136
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;
int main() {
  int n;
  cin >> n;
  stringstream ss;
  bool* prime = new bool[101];
  for(int i=0;i<101;i++) prime[i] = true;
  prime[0] = false;
  prime[1] = false;
  for(int i=2;i<101;i++){
    if(!prime[i])continue;
    for(int j=i*2;j<101;j+=i){
      prime[j] = false;
    }
  }
  //cout << "prime end" << endl;
  int* table = new int[101];
  for(int i=0;i<101;i++) table[i] = 0;
  for(int i=1;i<n+1;i++){
    int c = i;
    while(c>1){
      for(int j=2;j<101;j++){
        if(prime[j] && c%j==0){
          table[j] ++;
          c /= j;
        }
      }
      //cout << i << endl;
    }
  }
  //cout << "table end" << endl;
  int ans =0;
  int diff = 0;

  int count1=0;
  int count2=0;
  for(int i=0;i<101;i++){
    if(table[i]>=74) count2++;
  }
  diff = count2;
  ans += diff;
  //cout << "74: " << diff << endl;

  count1=0;
  count2=0;
  diff=0;
  for(int i=0;i<101;i++){
    if(table[i]>=4) count2++;
    else if(table[i]>=2) count1++;
  }
  diff += count1*count2*(count2 - 1)/2;
  diff += count2*(count2-1)*(count2-2)/2;
  ans += diff;
  //cout << "2,4,4: " << diff << endl;

  count1=0;
  count2=0;
  diff=0;
  for(int i=0;i<101;i++){
    if(table[i]>=24) count2++;
    else if(table[i]>=2) count1++;
  }
  diff += count1*count2;
  diff += count2*(count2-1);
  ans += diff;
  //cout << "2,24: " << diff << endl;

  count1=0;
  count2=0;
  diff=0;
  for(int i=0;i<101;i++){
    if(table[i]>=14) count2++;
    else if(table[i]>=4) count1++;
  }
  diff += count1*count2;
  diff += count2*(count2-1);
  ans += diff;
  //cout << "4,14 " << diff << endl;

  count1=0;
  count2=0;
  diff=0;
  //for(int i=1;i<n+1;i++){
  //  if(table[i]!=0)cout << i << " : " << table[i] << endl;
  //}
  //cout << table[0] << endl;

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


Measured memory_bytes: 256
#include "iostream"
using namespace std;
 
int main(){
 
  int N;
  int A[200001]={0};
  int ans[200001]={0};
  
  cin >> N;
  
  	for(int i=2; i<=N ;i++){
  		cin >> A[i];
    }
  
	for(int i=2; i<=N ;i++){
	  	ans[A[i]]++;
	}
  
	for(int i=1; i<=N ;i++){  
  		cout << ans[i] <<"\n";
    }
   
  return 0;
}

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

using namespace std;
typedef long long ll;

const int N=2e5+10;
const int mod=998244353;
int n,k,m;
int a[N];
int b[N];
int ans[N];
string s;
int vis[N];
map<int,int> mp;
int used[25];
int cmp(int a, int b){
    return a>b;
}
ll dp[N];
ll pre[N];
struct pp{
    int l;
    int r;
}p[15];
int main()
{

    cin>>n>>k;
    memset(dp,0,sizeof(dp));
    int cou=0;
    for(int i=1;i<=k;i++){
        cin>>p[i].l;
        cin>>p[i].r;
    }
    dp[1]=1;
    pre[1]=1;

    for(int i=2;i<=n;i++){
        for(int j=1;j<=k;j++){
            if(i-p[j].l<1) continue;
            if(i-p[j].r>=1){
                dp[i]=(dp[i]+(pre[i-p[j].l]-pre[i-p[j].r-1]))%mod;
            }
            else{
                dp[i]=(dp[i]+pre[i-p[j].l])%mod;
            }
        }
        pre[i]=(pre[i-1]+dp[i])%mod;
    }
    dp[n]=(dp[n]+mod)%mod;
    cout<<dp[n]<<endl;



}



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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int main() {
	int n = ri();
	int a[n];
	for (int i = 0; i < n; i++) a[i] = ri();
	int64_t sum[n + 1];
	sum[0] = 0;
	for (int i = 0; i < n; i++) sum[i + 1] = sum[i] + a[i];
	int64_t dp[n + 1][n + 1];
	for (int i = 0; i <= n; i++) for (int j = 0; j <= n; j++) dp[i][j] = i + 1 == j ? 0 : 1000000000000000000;
	for (int i = 1; i < n; i++) for (int j = 0; j <= n - i; j++) {
		int r = j + i;
		for (int k = r + 1; k <= n && k - r <= i; k++) dp[j][k] = std::min(dp[j][k], dp[j][r] + dp[r][k] + sum[k] - sum[j]);
		for (int k = j - 1; k >= 0 && j - k <= i; k--) dp[k][r] = std::min(dp[k][r], dp[j][r] + dp[k][j] + sum[r] - sum[k]);
	}
	std::cout << dp[0][n] << std::endl;
	return 0;
}


Measured memory_bytes: 1536
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using namespace std;
using namespace boost::multiprecision;

typedef long long ll;
typedef long double ld;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mis map<int,string>
#define msi map<string,int>
#define mll map<ll,ll>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep1(i,n) for(int i=1; i<=(int)(n); i++)
#define all(c) c.begin(),c.end()
#define srta(a) sort(all(a))
#define srtd(a) sort(all(a),greater<型>())
#define rvs(s) reverse(all(s))
#define psb push_back
#define ppb pop_back
#define isu isupper
#define isl islower
#define lb(a,k) lower_bound(all(a),k)
#define ub(a,k) upper_bound(all(a),k)
#define bs(a,k) binary_search(all(a),k)
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

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

const int I_INF = 1001001001;
const ll LL_INF = 1001001001001001001;
const ld EPS = 0.001;

int main() {
    ll N, K;
    cin >> N >> K;
    vl a(N);
    rep (i, N) cin >> a[i];

    ll s = 0;
    rep (i, K) s += a[i];

    rep (i, N-K) {
        ll s2 = s-a[i]+a[i+K];
        if (s2 > s) cout << "Yes" << endl;
        else cout << "No" << endl;
        s = s2;
    }
}


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

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

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

using namespace std;

int n, ans;
int a[20], b[20], c[19];

int main(){
	cin >> n;
	for(int i = 0; i < n; ++i) cin >> a[i];
	for(int i = 0; i < n; ++i){
		cin >> b[i]; ans += b[i];
	}
	for(int i = 0; i < n - 1; ++i) cin >> c[i];
	
	for(int i = 1; i < n; ++i){
		// 提出時にデバッグは取り除け！
		if(a[i-1] + 1 == a[i]){
			ans += c[a[i-1]-1];
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

template <typename T, typename K> struct P {
	T a; K b;
};
typedef struct {
	vector <int> to;
	bool is_visited = false;
} node;
typedef struct {
	int to;
	int cost;
	P <int, int> change;
} edge;

int main( void ){
	int N; cin >> N;
	string S; cin >> S;
	int l = 0, r = 0;
	rep( i, 0, N ){
		if (S[ i ] == '(')
			l++;
		else {
			if (l > 0)
				l--;
			else
				r++;
		}
	}
	rep( i, 0, r )
		cout << '(';
	cout << S;
	rep( i, 0, l )
		cout << ')';
	cout << endl;

}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	REP(i, k){
		int d;
		cin >> d;
		REP(j, d){
			int in;
			cin >> in;
			in--;
			a[in]++;
		}
	}
	int ans = 0;
	REP(i, n) if(a[i] == 0) ans++;
	cout << ans << endl;
}

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

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

        try{
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

                String str = reader.readLine();
                String[] arr = str.split(" ");

                int a = Integer.parseInt(arr[0]);
                int b = Integer.parseInt(arr[1]);
                int c = Integer.parseInt(arr[2]);

                String sort = null;

                if(b < a && c < a){
                    if(b < c){
                        sort = (b + " " + c + " " + a);
                    }
                    else{
                        sort = (c + " " + b + " " + a);
                    }
                }
                else if(a < b && c < b){
                    if(a < c){
                        sort = (a + " " + c + " " + b);
                    }
                    else{
                        sort = (c + " " + a + " " + b);
                    }
                }
                else if(a < c && b < c){
                    if(b < a){
                        sort = (b + " " + a + " " + c);
                    }
                    else{
                        sort = (a + " " + b + " " + c);
                    }
                }

                System.out.println(sort);

        }catch(IOException e){
            e.printStackTrace();
        }

    }
}

Measured memory_bytes: 24380
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

string f(int x,int y){
  string temp="000000000000";
  rep(i,6){
    temp[5-i]='0'+x%10;
    x/=10;
  }
  rep(i,6){
    temp[11-i]='0'+y%10;
    y/=10;
  }
  
  return temp;
}

int main() {
  int n,m;
  cin>>n>>m;
  pair<int,int> city[100009];
  vector<int> year;
  rep(i,m){
    int p,y;
    cin>>p>>y;
    city[i]=make_pair(p,y);
    year.push_back(y);
  }
  sort(city,city+m);
  
  map<int,string> number;
  vector<int> count(n,0);
  rep(i,m){
    count[city[i].first-1]++;
    int y=city[i].first,x=count[city[i].first-1];
    number[city[i].second]=f(y,x);
  }
  
  rep(i,m)
    cout<<number[year[i]]<<endl;
    
}

Measured memory_bytes: 15992
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

  private static PrintWriter out;

  public static void main(String[] args) {
    Main main = new Main();
    Runtime.getRuntime().addShutdownHook(new Thread(() -> out.close()));
    try {
      main.run(args);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  private void run(String[] arguments) throws Exception {
    MyScanner sc = new MyScanner();
    out = new PrintWriter(new BufferedOutputStream(System.out));

    int n = sc.nextInt();
    //ArrayList<Integer> list = new ArrayList<>();

    HashMap<Integer, Integer> map = new HashMap<>();

    for (int i = 0; i < n; i++) {
      int a = sc.nextInt();
      if (map.containsKey(a)) {
        int counter = map.get(a) + 1;
        map.put(a, counter);
      } else {
        map.put(a, 1);
      }
    }

    List<Integer> list = new ArrayList<>(map.keySet());

    int MAX_A = (int) Math.pow(10, 6);
    int[] checks = new int[MAX_A + 1];
    int ans = 0;

    for (Integer num : list) {
      for (int i = num; i <= MAX_A; i += num) {
        checks[i]++;
      }
    }

    for (Integer number : list) {
      if (checks[number] == 1 && map.get(number) == 1) {
        ans++;
      }
    }

    out.println(ans);
    out.close();

  }

  /*
   * Form: http://codeforces.com/blog/entry/7018
   */
  private class MyScanner {

    BufferedReader br;
    StringTokenizer st;

    MyScanner() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

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

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

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

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }
}


Measured memory_bytes: 70292
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>

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

using namespace std;

typedef long long int lli;

const int mod = 1000000007;

lli calc(int n) {
    lli ans = 1;
    REP (i, 1, n + 1) {
        ans = (ans * i) % mod;
    }
    return ans;
}

int main () {
    int N, M;
    cin >> N >> M;
    if (abs(N - M) > 1) {
        cout << 0 << endl;
        return 0;
    }
    lli n = calc(N);
    lli m = calc(M);
    lli t = (n * m) % mod;
    if (N == M) {
        cout << (t * 2) % mod << endl;
    } else {
        cout << t << endl;
    }
    return 0;
}


Measured memory_bytes: 256
main = do
  s <- getContents
  let v = map (map read . words) . lines $ s
  let w = map solve v
  let x = map (\x-> if x then "YES" else "NO") $ w
  mapM_ putStrLn x

solve::[Double] -> Bool
solve [xa,ya,xb,yb,xc,yc,xd,yd] =
  abs(dot u v) < eps
  where u = (xb-xa, yb-ya)
        v = (xd-xc, yd-yc)
        dot (a,b) (c,d) = a*c + b*d
        eps=1e-11

Measured memory_bytes: 4332
#include<bits/stdc++.h>
#define N 105
using namespace std;
bool dp[N][N*N];

int main(){

  int n, s[N];

  cin>>n;
  
  for(int i=0;i<n;i++) cin>>s[i];

  memset(dp,0,sizeof(dp));
  
  dp[0][0]=1;
  
  for(int i=0;i<n;i++){

    for(int j=N*N-1;j>=0;j--){
      
      if(!dp[i][j]) continue;
      
      dp[i+1][j+s[i]]=1;
      
      dp[i+1][j]=1;
      
    }
    
  }
  
  int ans=0;
  
  for(int i=0;i<N*N;i++)
    if(dp[n][i]&&i%10) ans=max(ans,i);
  
  cout<<ans<<endl;
  
  return 0;
}


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

using namespace std;

int main() {
    // freopen("1.txt", "r", stdin);
    int N;
    cin >> N;

    vector<double> p(N + 1);
    for(int i = 1; i <= N; ++i) cin >> p[i];

    int L = N / 2;
    vector<double> dp(N + 1, 0.0);
    dp[0] = 1.0;

    for(int i = 1; i <= N; ++i) {
        for(int j = i; j >= 0; --j) {
            dp[j] *= (1 - p[i]);
            if(j > 0)
                dp[j] += dp[j - 1] * p[i];
        }
    }
    double res = 0.0;
    for(int i = N; i > L; --i) res += dp[i];
    printf("%.10lf\n", res);
    return 0;
}

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

using namespace std ;

int n , w ;
int weight[ 101 ] , price[ 101 ] ;
long long dp[ 101 ][ 100001 ] ;

void solve()
{
    for( int i = 0 ; i <= w ; i++ )
        dp[ 0 ][ i ] = 0 ;
    for( int i = 0 ; i <= n ; i++ )
        dp[ i ][ 0 ] = 0 ;

    for( int i = 1 ; i <= n ; i++ )
        for( int j = 1 ; j <= w ; j++ )
            if( weight[ i ] <= j )
                dp[ i ][ j ] = max( dp[ i - 1 ][ j ] , dp[ i - 1 ][ j - weight[ i ] ] + price[ i ] ) ;
            else
                dp[ i ][ j ] = dp[ i - 1 ][ j ] ;

    cout << dp[ n ][ w ] << endl ;
}
int main()
{
    cin >> n >> w ;

    for( int i = 1 ; i <= n ; i ++ )
        cin >> weight[ i ] , cin >> price[ i ] ;
    solve() ;
}


Measured memory_bytes: 82504
#include <bits/stdc++.h>
using namespace std ;
using ll=long long ;
int main(){
 int n , k ;
cin >> n >> k ;
int a[n];
for(int i=0 ; i< n ;i++)
{
    cin >>a[i] ;
}
sort(a+0,a+n) ;
ll sum =0 ;
for(int i=0 ; i<k ;i++)
{
    sum+=a[i] ;
}
cout << sum ;
 return 0 ;
}


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

int main(){
 long long N,K,ans,a;
cin>>N;
  ans=0;
  for(int i=0;i<N;i++){
    if((N-i<100000&&N-i>=10000)||(N-i<1000&&N-i>=100)||N-i<10){
      ans++;
    }
  }
      cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
#include <cctype>
#include <iterator>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int h, w;
  cin >> h >> w;
  vector<vector<int>> g(h, vector<int>(w, 0));
  REP(i, h) { REP(j, w) cin >> g[i][j]; }
  vector<pair<P, P>> ans;
  REP(i, h) {
    REP(j, w - 1) {
      if (g[i][j] % 2 != 0) {
        g[i][j]--;
        g[i][j + 1]++;
        ans.push_back({{i + 1, j + 1}, {i + 1, j + 2}});
      }
    }
  }
  REP(i, h - 1) {
    if (g[i][w - 1] % 2 != 0) {
      g[i][w - 1]--;
      g[i + 1][w - 1]++;
      ans.push_back({{i + 1, w}, {i + 2, w}});
    }
  }
  cout << ans.size() << endl;
  REPe(e, ans) {
    cout << (e.first).first << " " << (e.first).second << " "
         << (e.second).first << " " << (e.second).second << endl;
  }

}


Measured memory_bytes: 5236
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, d = MAP()
ans = 0
for i in range(n):
    x, y = MAP()
    if x**2 + y**2 <= d**2:
        ans += 1
print(ans)

Measured memory_bytes: 10304
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(){
    int a,b;cin>>a>>b;
    cout<<(a+b+1)/2<<endl;
}


Measured memory_bytes: 3484
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
char in[210];
int A[210];
int O[210];
int B[210];
int S[210];
int D[210];
vector<int>as;
vector<pair<pair<int,int>,int> >edge;
int dist[210];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++){
		scanf("%s",in);
		int at=0;
		while('0'<=in[at]&&in[at]<='9'){
			A[i]*=10;A[i]+=in[at++]-'0';
		}
		A[i]--;
		if(in[at]=='<'){O[i]=1;at+=2;}
		else if(in[at]=='>'){O[i]=2;at+=2;}
		else {at++;as.push_back(i);}
		while('0'<=in[at]&&in[at]<='9'){
			B[i]*=10;B[i]+=in[at++]-'0';
		}
		B[i]--;
		if(in[at]=='+')S[i]=1;
		at++;
		while('0'<=in[at]&&in[at]<='9'){
			D[i]*=10;D[i]+=in[at++]-'0';
		}
	}
	int ret=-1;
	for(int i=0;i<(1<<(as.size()));i++){
		for(int j=0;j<as.size();j++){
			if(i&(1<<j))O[as[j]]=1;
			else O[as[j]]=2;
		}
		edge.clear();
		for(int j=0;j<b;j++){
			if(O[j]==1&&S[j]==1)edge.push_back(make_pair(make_pair(B[j],A[j]),-D[j]));
			if(O[j]==1&&S[j]==0){
				edge.push_back(make_pair(make_pair(A[j],B[j]),D[j]));
				edge.push_back(make_pair(make_pair(B[j],A[j]),0));
			}
			if(O[j]==2&&S[j]==1)edge.push_back(make_pair(make_pair(A[j],B[j]),-D[j]));
			if(O[j]==2&&S[j]==0){
				edge.push_back(make_pair(make_pair(B[j],A[j]),D[j]));
				edge.push_back(make_pair(make_pair(A[j],B[j]),0));
			}
		}
		for(int j=1;j<a;j++)edge.push_back(make_pair(make_pair(j,0),0));
	//	for(int j=0;j<edge.size();j++)printf("%d -> %d: %d\n",edge[j].first.first,edge[j].first.second,edge[j].second);
		for(int j=0;j<a;j++)dist[j]=999999999;
		dist[0]=0;
		int lastupd=-1;
		for(int j=0;j<a;j++){
			for(int k=0;k<edge.size();k++){
				if(dist[edge[k].first.second]>dist[edge[k].first.first]+edge[k].second){
					lastupd=j;
					dist[edge[k].first.second]=dist[edge[k].first.first]+edge[k].second;
				}
			}
		}
		if(lastupd!=a-1){
			for(int j=0;j<a;j++)ret=max(ret,dist[j]);
		}
	}
	if(ret>99999999)printf("inf\n");
	else printf("%d\n",ret);
}

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

using namespace std;

int a,b;


int main() {
  cin >> a;
  cin >> b;
  
  rep1(i,4) {
    if(i != a && i !=b) cout <<i;
  }
  
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define all(v) v.begin(),v.end()
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int,int>;
  
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, count = 0;
    cin >> n;
    int a[105], sum = 0;
    rep(i,n){
      cin >> a[i];
      sum += a[i];
    }
    sort(a,a +n);
    if(sum % 10 == 0){
      rep(i,n){
	if((sum - a[i])%10 != 0){
	  sum -= a[i];
	  break;
	} else {
	  count ++;
	}
      }
    }

    if(count == n){
      sum = 0;
    }
    cout << sum << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int N, K;
    string S;
    cin >> N >> K >> S;
    S[K - 1] += 32;
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long n,ans;
  cin>>n;
  ans=0;
  for(long i=1; i<n+1; i++){
    if(i%3!=0 && i%5!=0){
      ans=ans+i;
    }
  }
  cout<<ans;
}

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

int main() {

    int r;

    cin >> r;

    if(r < 1200){
        cout << "ABC" << endl;
    }
    else if(r < 2800){
        cout << "ARC" << endl;
    }
    else{
        cout << "AGC" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main(){
	int n, d, cnt;
	double dist, s;
	cin >> n >> d;
	double xin;
	vector<vector<double>> x(n);
	for(int i=0; i<n; i++){
		for(int j=0; j<d; j++){
			cin >> xin;
			x[i].push_back(xin);
		}
	}

	cnt = 0;
	for(int i=0; i<n-1; i++){
		for(int j=i+1; j<n; j++){
			s = 0;
			for(int k=0; k<d; k++){
				s += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
			}
			dist = sqrt(s);
			if(ceil(dist) == floor(dist)){
				cnt++;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
S = input()
RES = 0

def countACGT(s):
  res = 0
  res += s.count("A")
  res += s.count("C")
  res += s.count("G")
  res += s.count("T")
  if res == len(s):
    return res
  else:
    return 0

for i in range(len(S)+1):
  for j in range(len(S)+1):
    RES = max(RES,countACGT(S[i:j]))
print(RES)

Measured memory_bytes: 9048
#include <stdio.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int main(void){
    int n;
    scanf("%d",&n);
    int p[n];
    rep(i,n){
        scanf("%d",&p[i]);
    }
    int count = 0;
    for(int i = 1;i < n-1;i++){
        if ((p[i-1] < p[i] && p[i] < p[i+1]) || (p[i-1] > p[i] && p[i] > p[i+1])){
        count++;
        }
    }

    printf("%d",count);
}

Measured memory_bytes: 128
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-05-02 22:48:31
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int flag = 0;
  for (auto e : vec) os << (flag++ ? ", " : "{") << e;
  return os << (vec.empty() ? "{}" : "}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int flag = 0;
  for (auto e : st) os << (flag++ ? ", " : "{") << e;
  return os << (st.empty() ? "{}" : "}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int flag = 0;
  for (auto e : mp) os << (flag++ ? ", " : "{") << e;
  return os << (mp.empty() ? "{}" : "}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin


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

  int n, m, q; cin >> n >> m >> q;

  vector<pair<pair<int, int>, pair<int, int>>> in;

  for (int i = 0; i < q; ++i) {
    int a, b, c, d; cin >> a >> b >> c >> d;
    --a; --b;
    in.emplace_back(make_pair(a, b), make_pair(c, d));
  }

  vector<int> buf(n, -1);

  int64 ans = 0;

  auto dfs = [&](const auto& dfs, int cur, vector<int>& tv) -> void {
    if (tv.back() != -1) {
      debug(tv);
      int64 t = 0;
      for (int j = 0; j < q; ++j) {
        if (tv[in[j].first.second] - tv[in[j].first.first] == in[j].second.first) {
          t += in[j].second.second;
        }
      }
      ans = max(ans, t);
    } else {
      for (int j = tv[cur - 1]; j <= m; ++j) {
        vector<int> v2 = tv;
        v2[cur] = j;
        dfs(dfs, cur + 1, v2);
      }
    }
  };

  for (int i = 1; i <= m; ++i) {
    fill(all(buf), -1);
    buf[0] = i;
    dfs(dfs, 1, buf);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3660
N = gets.to_i
A = gets.split.map(&:to_i)

B = A.map{|a| [a/400, 8].min }.uniq
s = B.size
s -= 1 if B.max == 8
r = A.count{|a| [a/400, 8].min == 8 }

max = s + r
min = s
min = 1 if min == 0

puts "#{min} #{max}"

Measured memory_bytes: 1788