akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>

#define mod 1000000007

typedef long long ll;

using namespace std;

int comb(int n, int k){
    int i, j;
    vector<vector<int>> tbl(n+1, vector<int>(k+1));
    
    for (i = 0; i <= n; i++){
        tbl[i][0] = 1;
        if (i <= k) {
            tbl[i][i] = 1;
        }
    }
    for (i = 1; i <= n; i++){
        for (j = 1; j <= k; j++){
            tbl[i][j] = tbl[i - 1][j] + tbl[i - 1][j - 1];
            tbl[i][j] %= mod;
        }
    }
    return tbl[n][k];
}

int main() {
    int N, M;
    int i;
    int num;
    ll ans;
    int count;
    vector <int> prime = {2};
    bool f;

    cin >> N >> M;

    count = 0;
    for (i = 3; i <= sqrt(M); i += 2) {
        f = true;
        for (int x : prime) {
            if (i % x == 0) {
                f = false;
                break;
            }
        }
        if (f) {
            prime.push_back(i);
        }
    }

    vector <int> c(prime.size(), 0);
    num = M;
    for (i = 0; i < prime.size(); i++) {
        while (num % prime[i] == 0) {
            c[i]++;
            num = num / prime[i];
        }
    }
    if (num != 1) {
        prime.push_back(num);
        c.push_back(1);
    }

    // for (i = 0; i < prime.size(); i++) {
    //     if (c[i] != 0) {
    //         cout << prime[i] << " " << c[i] << endl;
    //     }
    // }

    ans = 1;
    for (i = 0; i < prime.size(); i++) {
        if (c[i] != 0) {
            ans *= comb(c[i] + N - 1, c[i]);
            ans %= mod;
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main(){
    ll n;
    cin >> n;
    
    ll ans = n; // max

    for(ll i=2;i<=sqrt(n);i++){
        if(n%i==0 and (n/i)+i <ans){
            ans = (n/i)+i;
        }
    }
    if(ans==n){
        ans+=1;
    }
    cout << ans-2 << endl;

    return 0;
}

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

using namespace std;

int main() {
  int N;
  int min = 1e9;
  cin >> N;
  
  for (int i=0; i < N; i++) {
    int A;
    cin >> A;
    int cnt = 0;
    for (;;) {
      if (A % 2 == 0) {
        A /= 2;
        cnt++;
      } else break;
    }
    if (min > cnt) min = cnt;
  }
  
  cout << min << endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	FORR(c,S) {
		if(c=='1') c='9';
		else if(c=='9') c='1';
	}
	cout<<S<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_A&lang=jp

int stk[100005];
int top;

static void push(int x) {
    stk[++top] = x;
}

static int pop() {
    return stk[top--];
}

int main() {

    char str[50];
    int a, b;
    while(scanf("%s", str) != EOF) {
        char c = str[0];
        if (c == '+') {
            a = pop();
            b = pop();
            push(a+b);
        }
        else if (c == '-') {
            a = pop();
            b = pop();
            push(b-a);
        }
        else if (c == '*') {
            a = pop();
            b = pop();
            push(b*a);
        }
        else {
            push(atoi(str));
        }
    }
    cout << pop() << "\n";
    return 0;
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
int main()
{
  	int n,i,ans=0,j,k;
  cin>>n;
  vector<long long int> v(n);
  for(i=0;i<n;i++)
  {
    	cin>>v[i];
  }
  for(i=0;i<n-2;i++)
  {
      for(j=i+1;j<n-1;j++)
      {
          for(k=j+1;k<n;k++)
          {
              if(v[i]+v[j]>v[k] && v[i]+v[k]>v[j] && v[k]+v[j]>v[i] && v[i]!=v[j] && v[i]!=v[k] && v[j]!=v[k]) ans++;
          }
      }
  }
  cout<<ans;
 	return 0;
}


Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

namespace CSharpSpiral {
	class Program {
		static void Main(string[] args) {
			var sw = new StreamWriter(Console.OpenStandardOutput()) {
				AutoFlush=
#if DEBUG
			true
#else
			false
#endif
			};
			Console.SetOut(sw);
			new Program().Solve(new ConsoleInput(
#if DEBUG
			new StreamReader("../../../inputData.txt")
#else
			Console.In
#endif
			, ' '));
			Console.Out.Flush();
		}
		public void Solve(ConsoleInput cin) {
			var N = cin.ReadInt;
			var A = cin.ReadLongArray(N);
			long count = 0;
			int s = 0, e = 0;
			long xor = 0, sum = 0;
			for(s=0; s<N; s++) {
				//P[s,e) == xor(A[s...e])==sum(A[s...e])
				for(; e<=N; e++) {
					if(e==N) break;
					long nextX = xor^A[e], nextS = sum+A[e];
					if(nextX!=nextS) {
						break;
					} else {
						xor=nextX; sum=nextS;
					}
				}
				count+=e-s;
				if(e==s) e=s+1;
				xor^=A[s]; sum-=A[s];
			}
			Console.WriteLine(count);
		}
	}
	static class ExtendClass {
		public static void Swap<T>(this T[] A, int x, int y) {
			var tmp = A[x];
			A[x]=A[y];
			A[y]=tmp;
		}
		public static string Join<T>(this IEnumerable<T> X, string separator = " ") => string.Join(separator, X);
		public static IEnumerable<int> Indices<T>(this T[] X) => Enumerable.Range(0, X.Length);
		public static IEnumerable<int> Indices<T>(this T[,] X, int dim)
			=> Enumerable.Range(0, X.GetLength(dim));
		public static string Join<T>(this T[,] X, string separatorD2 = ",", string separatorD1 = "\n")
			=> X.Indices(0).Select(
				i => X.Indices(1).Select(j => X[i, j]).Join(separatorD2)
			).Join(separatorD1);
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator=separator;
			this._stream=stream;
			inputStream=new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count!=0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i<tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i<N; ++i)
				ret[i]=Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i<N; ++i) ret[i]=ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i<N; ++i) ret[i]=ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i<N; ++i) ret[i]=ReadDouble; return ret; }
		public bool isEOF {
			get { return _stream.Peek()==-1; }
		}
	}
}

Measured memory_bytes: 32340
import math
num = input()
x =  [int(s) for s in input().split()]
sum = 0
for i in range(len(x)-2):
    center = x[i+1]
    three = [x[i], x[i+1], x[i+2]]
    if(x[i+1] == int(sorted(three)[1])):
        sum += 1
        
print(sum)
            

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
  char now='A';
  char x,y;  
  int a,b;
  int t,i;
  while((scanf("%c,%c",&x,&y))!=EOF){
    if(now==x){
      now=y;
    }else if(now==y){
      now=x;
    }
  }
  printf("%c\n",now);
  return 0;
}

Measured memory_bytes: 544
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static String anser ="No";

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int[] card = new int[9];
		for (int i = 0; i < 9; i++) {
			card[i] = scan.nextInt();
		}

		int n = scan.nextInt();
		int[] number = new int[n];

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

		ArrayList<Integer> machedNum = new ArrayList<>();

		for (int i = 0; i < 9; i++) {
			for (int j = 0; j < n; j++) {
				if (card[i] == number[j]) {
					machedNum.add(i+1);
					break;
				}
			}
		}

		checkBingo(machedNum,1,2,3);
		checkBingo(machedNum,4,5,6);
		checkBingo(machedNum,7,8,9);
		checkBingo(machedNum,1,4,7);
		checkBingo(machedNum,2,5,8);
		checkBingo(machedNum,3,6,9);
		checkBingo(machedNum,1,5,9);
		checkBingo(machedNum,3,5,7);

		System.out.println(anser);

	}

	private static void checkBingo(ArrayList<Integer> array, int a, int b, int c) {

		if (array.contains(a) && array.contains(b) && array.contains(c)) {
			anser = "Yes";
		}

	}

}


Measured memory_bytes: 20948
def b_sort(ca)
  c = ca.dup
  s = 0
  c.sort_by{|i| [i[1], s += 1]}
end

def s_sort(ca)
  c = ca.dup
  c.size.times do |i|
    m = i
    i.upto(c.size - 1) do |j|
      if c[j][1] < c[m][1]
        m = j
      end
    end
    c[m], c[i] = c[i], c[m]
  end
  c
end

gets
a = gets.split.map! do |e|
  e =~ /(\w)(\d+)/
  [$1, $2.to_i]
end
b, c = [b_sort(a), s_sort(a)].map do |d|
  d.map(&:join).join(' ')
end
puts b
puts 'Stable'
puts c
puts b == c ? 'Stable' : 'Not stable'

Measured memory_bytes: 8752
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

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


void solve(long long N, long long K, std::vector<long long> P, std::vector<long long> C){
    ll ans = -1e18;
    rep(i,N){
        ll score = 0;
        vector<ll> mp(N+1, -1);
        ll p = P[i] - 1;
        ll c = C[p];
        ll cnt = 0;
        rep(j,N){
            if(mp[p] != -1 || j >= K) break;
            cnt++;
            mp[p] = cnt;
            p = P[p] - 1;
            score += c;
            c = C[p];
            ans = max(ans, score);
        }
        if(mp[p] != -1 && score > 0){
            ll l = mp[i];
            p = P[i] - 1;
            c = C[p];
            ll tot = 0;
            rep(j,l){
                tot += c;
                p = P[p] - 1;
                c = C[p];
                ll e = (K - (j + 1)) / l;
                ll t = tot;
                t += score * e;
                ans = max(ans, t);
            }
        }
        
    }
    cout << ans << endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> P(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&P[i]);
    }
    std::vector<long long> C(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&C[i]);
    }
    solve(N, K, std::move(P), std::move(C));
    return 0;
}


Measured memory_bytes: 3804
#coding: utf-8

import math
a, b, C = map(float, input().split())
rdC = math.radians(C)

h = b * math.sin(rdC)
S = a * h / 2

a1 = b * math.cos(rdC)
a2 = a - a1
e = math.sqrt(a2 ** 2 + h ** 2)
L = a + b + e

print(S)
print(L)
print(h)


Measured memory_bytes: 5700
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal

INF = 1 << 50

def eval(start, CSF):
    N = len(CSF)+1
    queue = []
    heappush(queue, (0, start))
    while queue:
        time, current = heappop(queue)
        #print(f'time : {time}, current : {current}')
        if current == N-1:break
        for i in range(current, current+1):
            c,s,f = CSF[i]
            first_s = s + c * (current-i)
            if time <= first_s:
                next_leave = first_s
            else:
                next_leave = first_s + math.ceil((time - first_s) / f) * f
            #print(f'i : {i}, c/s/f : {c}/{s}/{f}, next_leave : {next_leave}')
            heappush(queue, (next_leave + c, current+1))
    return time

def run():
    N = int(sysread())
    CSF = []
    for i in range(N-1):
        c,s,f = map(int, sysread().split())
        CSF.append((c,s,f))

    for i in range(N-1):
        print(eval(i, CSF))
    print(0)
    

if __name__ == "__main__":
    run()

Measured memory_bytes: 9528
public class Main {
	public static void main(String[] args) {
		try (java.util.Scanner sc = new java.util.Scanner(System.in)) {

			while (true) {
				int H = sc.nextInt();
				int W = sc.nextInt();
				if (H == 0 && W == 0) {
					break;
				}

				for (int h = 0; h < H; h++) {
					for (int w = 0; w < W; w++) {
						System.out.print("#");
					}
					System.out.println();
				}
				System.out.println();
			}
		}
	}
}


Measured memory_bytes: 32556
#include <stdio.h>

int main(void)
{
	int i,j,h,w;
	
	while(1){
		scanf("%d %d",&h,&w);
		if(h==0&&w==0) break;
		
		for(i=0;i<h;i++){
			if(i%2!=0){
				for(j=0;j<w;j++){
					if(j%2!=0) printf("#");
					else printf(".");
				}
			}
			if(i%2==0){
				for(j=0;j<w;j++){
					if(j%2==0) printf("#");
					else printf(".");
				}
			}
			
			printf("\n");
		}
		
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define int ll

int n;
int ans=0;
int a[1000];

signed main(){
  cin>>n;
  rep(i,n){
    cin>>a[i];
  }

  bool b =true;
  while(b){
    int i=0;
    b=false;
    
    while(i<n){
      while(a[i]==0&&i!=n) i++;
      if(a[i]){
        ans++;
        b=true;
        while(a[i]&&i!=n){
          a[i]--;
          i++;
        }
      }
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<cstdio>

using namespace std;

long long int c[10][10];

int first(int n)
{
    while(n>9)
    {
        n/=10;
    }
    return n;
}

int last(int n)
{
    return n%10;
}

void build(int n)
{
    for(int i=1;i<=n;i++)
    {
        c[first(i)][last(i)]++;
    }
}

long long int ans()
{
    long long int cnt=0;
    for(int i=0;i<=9;i++)
    {
        for(int j=0;j<=9;j++)
        {
            cnt+=c[i][j]*c[j][i];
        }
    }
    return cnt;
}

int main()
{
    int n;
    scanf("%d",&n);
    build(n);
    printf("%lld\n",ans());
    return 0;
}


Measured memory_bytes: 128
N = int(input())
C = input()
# WとRの数が等しくなるところ？
white_ruisekiwa = [0]
for i in range(N):
    if C[i] == "W":
        white_ruisekiwa.append(white_ruisekiwa[-1]+1)
    else:
        white_ruisekiwa.append(white_ruisekiwa[-1])

red_ruisekiwa = [0]
for i in range(N-1, -1, -1):
    if C[i] == "R":
        red_ruisekiwa.append(red_ruisekiwa[-1]+1)
    else:
        red_ruisekiwa.append(red_ruisekiwa[-1])

# print("白の累積わ : ", white_ruisekiwa)
# print("赤の累積わ : ", red_ruisekiwa)

for i in range(N):
    if white_ruisekiwa[i] == red_ruisekiwa[N-i]:
        print(white_ruisekiwa[i])
        exit()
else:
    print(0)


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

using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b;
    c=a;
    while (a>0)
    {
        a--;
        cout<<b-a<<" ";
    }
    while (a<c-1)
    {
        a++;
        cout<<b+a<<" ";
    }
    return 0;
}


Measured memory_bytes: 256
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

import numpy as np
# import scipy as scp

# 入力の受け取り
n,d = map(int,input().split())
arr = np.array([])
for _ in range(n):
    arr = np.append(arr,np.array(input().split(),dtype=np.int64))

arr = arr.reshape(n,-1)

ans = 0
for i in range(n):
    for j in range(i+1,n):
        num = np.sqrt(sum((arr[i] - arr[j])**2))
        if num % 1 == 0:
            ans +=1
        else:
            continue

print(ans)
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する



Measured memory_bytes: 12424
n, k = map(int,input().split())
mod = 10 ** 9 + 7

ans = 0
for i in range(k, n+2):
    min_i = (i-1) * i // 2
    max_i = i * (2*n - i + 1) // 2
    ans += max_i - min_i + 1
    ans %= mod

print(ans)

Measured memory_bytes: 9180
#include<iostream>
#include <functional>
#include<algorithm>
using namespace std;

int main() {
	int a[100];
	int b = 0;
	int c = 0;
	int n;
	cin >> n;
	for (int i = 0;i < 100;i++)
		a[i] = 0;
	for (int i = 0;i < n;i++)
		cin >> a[i];
	sort(a, a + 100, greater<int>());
	for (int i = 0;i < 100;i += 2)
	{
		b+= a[i];
	}

	for (int i = 1;i < 100;i += 2)
	{
		c+= a[i];
	}

	cout << (b - c) << '\n';






	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) b.rbegin(),v.rend()
typedef long long ll;
//isPrime
//modpow modinv
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  vector<vector<pair<int,int>>> p(n);
  rep(i,n){
    int a;
    cin >> a;
    rep(j,a){
      int x,y;
      cin >> x >> y;
      x--;
      p.at(i).push_back(make_pair(x,y));
    }
  }
  int res=0;
  for(int bit=0; bit<(1<<(n)); bit++){
    bool exist = true;
    rep(i,n){
      if(!(bit&(1<<i))){
        continue;
      }else{
        for(auto xy : p[i]){
          int x = xy.first;
          int y = xy.second;

          if(y==1&&!(bit&(1<<x))) exist=false;
          if(y==0&&(bit&(1<<x))) exist=false;
        }
      }
    }
    if(exist){
      int count=0;
      rep(i,n){
        if(bit&(1<<i)) count++;
      }
      res=max(res,count);
    }
  }
  cout << res << endl;
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

ll factorial(ll n){
  if(n == 0) return 1;
  return (n * factorial(n - 1)) % MOD;
}
int main(){
  ll n, m; cin >> n >> m;
  ll ans = (factorial(n) * factorial(m) * max(0ll, 2 - abs(n - m))) % MOD;
  cout << ans << endl;
}

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


int main(){
  string S;
  cin >> S;
  for(int ii=S.size()/2-1; ii>=0; ii--){
    if(S.substr(0, ii) == S.substr(ii, ii)){
      cout << ii*2 << endl;
      return 0;
    }
  }
  return 0;
}

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

LL dp[105][MAXN];

int main()
{
	int n, w, wei, val;
	cin >> n >> w;
	
	fill(dp[0]+1, dp[0]+MAXN, -LLONG_MAX);
	
	for (int i = 1; i <= n; i++)
	{
		cin >> wei >> val;
		
		copy(dp[i-1], dp[i-1]+w, dp[i]); // ¤W¦æªº¸ê®Æáàµ§¦Ü¦¹ 
		
		for (int j = wei; j <= w; j++)
		{
			dp[i][j] = max(dp[i-1][j], dp[i-1][j-wei]+val);
		}
	}

    /*for (int i = 1; i <= n; i++)
    {
    	for (int j = 1; j <= w; j++)
    	{
    		cout << dp[i][j] << ' ';
		}
		cout << "\n";
	}*/
	
	cout << *max_element(dp[n]+1, dp[n]+w+1) << "\n";
}

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

int main() {
    ll n;
    cin>>n;
    ll k;
    cin>>k;
    ll a[n];
    if(k>n)
    {
        k=n;
    }
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll dp[n];
    for(ll i=0;i<n;i++)
    {
        dp[i]=INT_MAX;
    }
    ll i=0;
    for(;i<k;i++)
    {
        dp[i]=abs(a[i]-a[0]);
    }
    for(;i<n;i++)
    {
        for(ll j=i;(j>=(i-k));j--)
        {
            dp[i]=min(dp[i],dp[j]+abs(a[j]-a[i]));
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

int main(){
  int N,H,W;
  scanf("%d%d%d",&N,&H,&W);
  int A;
  int B;
  int count = 0;
  for(int i = 0;i < N;i++){
    scanf("%d%d",&A,&B);
    if(A >= H && B >= W)count++;
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int,int> pii;
using namespace std;
using ll = long long;


int main(){
    int n;
    cin >> n;
    vector<double> probs(n);
    rep(i,n) cin >> probs[i];
        
    vector<vector<double>> dp(n+1,vector<double>(n+1,0.0));
    dp[0][0] = 1.0;
    
    // steps
    for(int i = 1; i <= n; i++){
        double p = probs[i-1]; // head
        // counts
        for(int j = 0; j <= n; j++){
            if (j-1 >= 0)dp[i][j] += p*dp[i-1][j-1]; //head;
            dp[i][j] += (1.0-p)*dp[i-1][j]; //tail 
        }
    }
    
    
    // for(int i = 0; i <= n; i++){
    //     for(int j = 0; j <= n; j++){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    
    double tailp = 0.0;
    rep(i,n/2+1){
        tailp += dp[n][i];
    }

    double ans = 1.0 - tailp;
    
    printf ("%.20f",ans);
    
    
    
}




Measured memory_bytes: 72704
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <string.h>
#include <string>
#include <complex>

using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
#define Rep(i,n) for(int i = 1; i <= n; ++i)
#define lowbit(x) ((x)&(-x))
//#pragma comment(linker,"/STACK:1024000000,1024000000")
#define eps 1e-2
#define sqr(x) ((x)*(x))
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef complex<double>cp;
template<class T>inline void rread(T&num){
    num=0;T f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
    num*=f;
}
const ll inf = 1e18;
const int maxn = 1e6 +10, mod = 1e9 + 7;
const double pi = acos(-1);
ll gcd (ll a, ll b)
{return ( a ? gcd(b%a, a) : b );}
void exgcd(ll a,ll b,ll &d,ll& x,ll& y)
{
    if(!b){d=a;x=1;y=0;}
    else {exgcd(b,a%b,d,y,x);y-=x*(a/b);}
}
cp power(cp a, int n)
{cp p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n)
{ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod)
{ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
//head
ll n,m,r;
bool judge(ll x)
{
    ll d = max(0ll,x-n);
    if(m-2*x-d*2>=0)return true;
    else return false;

}
int main()
{

    while(~scanf("%lld%lld",&n,&m))
    {

        ll l=0,r = 1e18;
        while(r-l>1)
        {
            ll mid  = (l+r)/2;
            if(judge(mid))l = mid;
            else r = mid;
        }
        printf("%lld\n",l);


    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int C = 3e5 + 7;
const int N = C << 1;
const int BASE = C;
const int MOD1 = 1000 * 1000 * 1000 + 7;
const int MOD2 = 1000 * 1000 * 1000 + 9;
int mod1(int n) {
    return (n % MOD1 + MOD1) % MOD1;
}   
int mod2(int n) {
    return (n % MOD2 + MOD2) % MOD2;
}   
int x[N], pw1[N], pw2[N];
void add1(int &a, int b) {
    a = mod1(a + b);
}   
void add2(int &a, int b) {
    a = mod2(a + b);
}   
int fp1(int a, int p) {
    int ans = 1, c = a;
    for (int i = 0; (1ll << i) <= p; ++i) {
        if ((p >> i) & 1) ans = mod1(ans * c);
        c = mod1(c * c);
    }   
    return ans;
}   
int dv1(int a, int b) {
    return mod1(a * fp1(b, MOD1 - 2));
}   
int fp2(int a, int p) {
    int ans = 1, c = a;
    for (int i = 0; (1ll << i) <= p; ++i) {
        if ((p >> i) & 1) ans = mod2(ans * c);
        c = mod2(c * c);
    }   
    return ans;
}   
int dv2(int a, int b) {
    return mod2(a * fp2(b, MOD2 - 2));
}   
int pref1[N], pref2[N];
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    pw1[0] = 1;
    for (int i = 1; i < N; ++i) pw1[i] = mod1(pw1[i - 1] * BASE);
    pw2[0] = 1;
    for (int i = 1; i < N; ++i) pw2[i] = mod2(pw2[i - 1] * BASE);
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 0; i < n; ++i) {
        pref1[i + 1] = pref1[i];
        pref2[i + 1] = pref2[i];
        x[i + 1] = x[i];
        if (s[i] == '<') --x[i + 1];
        else if (s[i] == '>') ++x[i + 1];
        else if (s[i] == '+') {
            add1(pref1[i + 1], pw1[x[i + 1] + C]);
            add2(pref2[i + 1], pw2[x[i + 1] + C]);
        }
        else {
            add1(pref1[i + 1], -pw1[x[i + 1] + C]);
            add2(pref2[i + 1], -pw2[x[i + 1] + C]);
        }
    }
    int ans = 0;
    map <pair <int, int>, int> d;
    for (int i = n; i >= 0; --i) {
        pair <int, int> w;
        if (x[i] < 0) {
            w.first = mod1(pref1[i] + dv1(pref1[n], pw1[-x[i]]));
            w.second = mod2(pref2[i] + dv2(pref2[n], pw2[-x[i]]));
        }
        else {
            w.first = mod1(pref1[i] + mod1(pref1[n] * pw1[x[i]]));
            w.second = mod2(pref2[i] + mod2(pref2[n] * pw2[x[i]]));
        }
        ans += d[w];
        d[{pref1[i], pref2[i]}]++;
    }   
    cout << ans << '\n';
}

Measured memory_bytes: 52116
#include <stdio.h>

int main(void)
{
	int x, y;
	int A;

	while (1)
	{
		scanf("%d%d", &x, &y);
		if ((x == 0) && (y == 0))
		{
			break;
		}
		if (x > y)
		{
			A = x;
			x = y;
			y = A;
			printf("%d %d\n", x, y);
		}
		else
		{
			printf("%d %d\n", x, y);
		}
		
	}
	return 0;
}


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

using namespace std;

int main(){
    int A, B;
    cin >> A >> B;
    if (A + B == 5){
        cout << 1 << endl;
    }else if (A + B == 4){
        cout << 2 << endl;
    }else if (A + B ==3){
        cout << 3 << endl;
    }
    return 0;
}

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

int main(int argc, char *argv[])
{
	int i;
	int result = 0;
    char str[8];

	cin >> str;
    for (i = 0; i < 4; i++) {
		if (str[i] == '+') {
			result++;
		} else {
			result--;
		}
	}

	cout << result << endl;
	
	return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func main() {
	n := readInt()
	ans := 1
	for i := 2; i <= n; i++ {
		ans = ans * i % 1000000007
	}
	fmt.Println(ans)
}


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

int64_t MOD;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

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

    vector<int> C(N-1);
    for(int i=0; i<N-1; i++) C[i] = min(1+i, N-i);

    static int64_t dp[5001];
    dp[0] = 1;
    for(int i=0; i<N-1; i++) for(int j=0; j+C[i]<=N; j++) add(dp[j+C[i]], dp[j]);
    
    int64_t ans = 0;
    for(int j=0; j<=N; j++) add(ans, dp[j]*(N-j));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// This is the template example file for programming//
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
typedef pair<int, int > Pii;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
#define pb push_back
#define rs resize 
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define repll(i, a, b) for(ll i=(a); i<(b); i++)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define COUT(a) cout << a << endl
#define ALL(a) (a).begin(),(a).end()
const long long int mod = 1e9 + 7;

ll lcm(ll x,ll y){
  ll a=x,b=y,r;
  if(x<y) swap(x,y);
  r=x%y;
  while(r!=0) x=y,y=r,r=x%y;
  return a/y*b;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false); 
    int a,b;
    cin >> a >> b;
    ll res = lcm(a,b);
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <limits.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
 
int main()
{
    ios::sync_with_stdio(false);
    int N, r, i;
    int min=INT_MAX, ans=INT_MIN;
     
    cin >> N;
    rep(i,N) {
        cin >> r;
        if(r-min > ans) ans = r-min;
        if(r < min) min = r;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1196
#include <iostream>
using namespace std;
int main() {
  char y1, y2, y3;
  char t1, t2, t3;
  cin >> y1 >> y2 >> y3;
  cin >> t1 >> t2 >> t3;
  
  int count = 0;
  if (y1 == t1) {
    count++;
  }
  if (y2 == t2) {
    count++;
  }
  if (y3 == t3) {
    count++;
  }
  
  cout << count << 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;
  	long long W;
  	cin >> N >> W;
  	vector<long long> ar(N), we(N);
	for(int i = 0; i < N; ++i) {
		cin >> we[i] >> ar[i];
	}
  	long long dp[N + 1][W + 1];
  	memset(dp, 0, sizeof dp);
  	for(int i = 1; i <= N; ++i) {
  		for(int w = 1; w <= W; ++w) {
  			if(w >= we[i - 1]) {
  				dp[i][w] = max(ar[i - 1] + dp[i - 1][w - we[i - 1]], dp[i - 1][w]);
  			} else {
  				dp[i][w] = dp[i - 1][w];
  			}
  		}
  	}
  	cout << dp[N][W] << '\n';
	return 0;
}

Measured memory_bytes: 79232
import math
n,m = map(int,input().split())
s = input()
t = input()
lcm = int(n*m/math.gcd(n,m))
if (n-1)//(lcm//m) == 0:
  if s[0] == t[0]:
    print(lcm)
  else:
    print(-1)
else:
  for i in range((n-1)//(lcm//m)):
    if s[i*(lcm//m)] != t[i*(lcm//n)]:
      print(-1)
      exit()
    elif i == (n-1)//(lcm//m)-1:
      print(lcm)

Measured memory_bytes: 9184
l = list(input())
a = False
b = False
c = False


if l[0] == 'R':
	a = True
if l[1] == 'R':
	b = True
if l[2] == 'R':
  	c = True
    
if a and b and c:
  	print(3)
elif (a and b) or (b and c):
  	print(2)
elif a or b or c:
  	print(1)
else:
  	print(0)

Measured memory_bytes: 8924
#include<bits/stdc++.h>
using namespace std;
 
#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
 
int main(){
  ll i, j;
  ll n, k;
  cin >> n;
  bool result = false;
  for(i = 0; i <= 25; i++)
    for(j = 0; j <= 15; j++)
      if(n == 4 * i + 7 * j)
        result = true;
  if(result)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
 
  return 0;
}

Measured memory_bytes: 256
package main

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

var n, a, b, c int
var ans []string

func main() {
	fmt.Scan(&n, &a, &b, &c)

	var sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	ss := make([]string, n)
	for i := range ss {
		sc.Scan()
		ss[i] = sc.Text()
	}

	ans = make([]string, 0)
	for i := 0; i < n; i++ {
		switch ss[i] {
		case "AB":
			if a == 1 && b == 1 && c == 0 {
				if i < n-1 {
					switch ss[i+1] {
					case "AB":
						choose("A", "AB")
					case "AC":
						choose("A", "AB")
					case "BC":
						choose("B", "AB")
					}
				} else {
					choose("A", "AB")
				}
			} else {
				if a < b {
					choose("A", "AB")
				} else {
					choose("B", "AB")
				}
			}
		case "AC":
			if a == 1 && b == 0 && c == 1 {
				if i < n-1 {
					switch ss[i+1] {
					case "AB":
						choose("A", "AC")
					case "AC":
						choose("A", "AC")
					case "BC":
						choose("C", "AC")
					}
				} else {
					choose("A", "AC")
				}
			} else {
				if a < c {
					choose("A", "AC")
				} else {
					choose("C", "AC")
				}
			}
		case "BC":
			if a == 0 && b == 1 && c == 1 {
				if i < n-1 {
					switch ss[i+1] {
					case "AB":
						choose("B", "BC")
					case "AC":
						choose("C", "BC")
					case "BC":
						choose("B", "BC")
					}
				} else {
					choose("B", "BC")
				}
			} else {
				if b < c {
					choose("B", "BC")
				} else {
					choose("C", "BC")
				}
			}
		}
		if a < 0 || b < 0 || c < 0 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
	for i := range ans {
		fmt.Println(ans[i])
	}
}

func choose(t, m string) {
	ans = append(ans, t)
	switch m {
	case "AB":
		switch t {
		case "A":
			a++
			b--
		case "B":
			a--
			b++
		}
	case "AC":
		switch t {
		case "A":
			a++
			c--
		case "C":
			a--
			c++
		}
	case "BC":
		switch t {
		case "B":
			b++
			c--
		case "C":
			b--
			c++
		}
	}
}


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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		StringBuilder sb = new StringBuilder();
		for(int i = 0;i < 20;i++){
			sb.append("#");
		}
		String sepalator = sb.toString();
		sb = null;
		
		Building[] buildings = new Building[4];
		for(int i = 0;i < buildings.length;i++){
			buildings[i] = new Building();
		}
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		for(int i = 0;i < n;i++){
			String[] tmp = br.readLine().split(" ");
			int building = Integer.parseInt(tmp[0]);
			int floor = Integer.parseInt(tmp[1]);
			int room = Integer.parseInt(tmp[2]);
			int visitor = Integer.parseInt(tmp[3]);
			buildings[--building].add(floor, room, visitor);
		}
		for(int i = 0;i < buildings.length;i++){
			buildings[i].write();
			if(i >= buildings.length - 1)
				break;
			System.out.println(sepalator);
		}
	}

}

class Building {

	Floor[] floors;
	{
		floors = new Floor[3];
		for (int i = 0; i < floors.length; i++) {
			floors[i] = new Floor();
		}
	}

	public void add(int floor, int room, int visitor) {
		floors[--floor].add(room, visitor);
	}
	
	public void write(){
		for(int i = 0;i < floors.length;i++){
			floors[i].write();
		}
	}

	private class Floor {
		int[] people;
		{
			people = new int[10];
			for (int i = 0; i < people.length; i++) {
				people[i] = 0;
			}
		}

		public void add(int room, int visitor) {
			people[--room] += visitor;
		}
		
		public void write(){
			StringBuilder sb = new StringBuilder();
			for(int i = 0;i < people.length;i++){
				sb.append(" ");
				sb.append(people[i]);
			}
			System.out.println(sb.toString());
		}
	}
}

Measured memory_bytes: 19240
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    long A, B, C;
    scan(A, B, C);

    if (A == B)
    {
        C.writeln();
    }
    else if (A == C)
    {
        B.writeln();
    }
    else
    {
        A.writeln();
    }
}


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

int main(){
    int n;
    cin >> n;
    vector<int> num(n);
    rep(i,n){
        cin >> num[i];
    }
    bool t;
    int cnt = 0;
    rep(j,n){
        t = true;
        if (num[j] == 1){
            t = false;
        }
        else if (num[j] == 2){
            t = true;
        }
        else if (num[j] % 2 == 0){
            t = false;
        }
        else{
            for (int l = 3; l <= sqrt(num[j]); l += 2){
                if (num[j] % l == 0){
                    t = false;
                    break;
                }
            }
        }
        if (t){
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3116
n = gets.chop.to_i

n.times do
  xa, ya, ra, xb, yb, rb = gets.chop.split(" ").map { |s| s.to_f }
  #p [xa, ya, ra, xb, yb, rb].join(", ")

  od2 = (xa - xb) ** 2 + (ya - yb) ** 2
  rp2 = (ra + rb) ** 2
  rm2 = (ra - rb) ** 2

  ans = 1

  if od2 > rp2
    ans = 0
  elsif od2 < rm2
    ans = (ra > rb) ? 2 : -2
  end

  puts ans
end

Measured memory_bytes: 6136
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);

        int N = s.nextInt();
        HashSet<String>set = new HashSet<>();

        for (int i = 0; i < N; i++) {
            String str = s.next();
            set.add(str);
        }

        System.out.println(set.size());
    }
}

Measured memory_bytes: 77012
#include <stdio.h>
int main(void) {

	int a[6], i;
	for (i = 1; i <= 5; i++) {
		scanf("%d", &a[i]);
	}
	for (i = 1; i <= 5; i++) {
		if (a[i] == 0) {
			printf("%d", i);
		}
	}
}

Measured memory_bytes: 1728
def bb088():
    n = int(input())
    an = list(map(int, input().split()))
    an.sort()

    a = 0
    b = 0
    for i in range(n-1, -1, -2):
        a += an[i]
        if i-1 >= 0:
            b += an[i-1]

    print(a-b)

bb088()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
#define show(x) cout << #x << " is " << x << "\n";
typedef vector<ll> vi;
#define fi first
#define se second
const ll inf = 9e18;
const ll mod = 1e9 + 7;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

//const ll N = 1e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

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

	ll l, r;
	cin>>l>>r;
	if(r-l > 2019) cout<<0<<"\n";
	else{
		ll ans=2019;
		for(ll i=l;i<=r;i++){
			for(ll j = i+1;j<=r;j++){
				ans = min(ans, (i*j)%2019);
				if(ans==0){
					cout<<0<<"\n";
					return 0;
				}
				
			}
		}
		cout<<ans<<"\n";
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
//const ll MOD=1000000007LL;
const ll MOD=998244353;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}


struct dsu {
	public:
		dsu() : _n(0) {}
		dsu(int n) : _n(n), parent_or_size(n, -1) {}

		int merge(int a, int b) {
				assert(0 <= a && a < _n);
				assert(0 <= b && b < _n);
				int x = leader(a), y = leader(b);
				if (x == y) return x;
				if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
				parent_or_size[x] += parent_or_size[y];
				parent_or_size[y] = x;
				return x;
		}

		bool same(int a, int b) {
				assert(0 <= a && a < _n);
				assert(0 <= b && b < _n);
				return leader(a) == leader(b);
		}

		int leader(int a) {
				assert(0 <= a && a < _n);
				if (parent_or_size[a] < 0) return a;
				return parent_or_size[a] = leader(parent_or_size[a]);
		}

		int size(int a) {
				assert(0 <= a && a < _n);
				return -parent_or_size[leader(a)];
		}

		std::vector<std::vector<int>> groups() {
				std::vector<int> leader_buf(_n), group_size(_n);
				for (int i = 0; i < _n; i++) {
						leader_buf[i] = leader(i);
						group_size[leader_buf[i]]++;
				}
				std::vector<std::vector<int>> result(_n);
				for (int i = 0; i < _n; i++) {
						result[i].reserve(group_size[i]);
				}
				for (int i = 0; i < _n; i++) {
						result[leader_buf[i]].push_back(i);
				}
				result.erase(
						std::remove_if(result.begin(), result.end(),
													 [&](const std::vector<int>& v) { return v.empty(); }),
						result.end());
				return result;
		}

	private:
		int _n;
		// root node: -1 * component size
		// otherwise: parent
		std::vector<int> parent_or_size;
};

int main(){

	ll N,Q;
	cin >> N >> Q;

	dsu uf(N+2);

	FOR(q,0,Q){
		ll a,b,t;
		cin >> t >> a >> b;
		if(t){
			cout << uf.same(a,b) << endl;
		}else{
			uf.merge(a,b);
		}
	}

}



Measured memory_bytes: 4056
#include <stdio.h>

int a[33];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		int k;
		scanf("%d",&k);
		for(int j=0;j<k;j++){
			int t;
			scanf("%d",&t);
			a[t]++;
		}
	}
	int ans=0;
	for(int i=0;i<31;i++)ans+=a[i]==n;
	printf("%d",ans);
}

Measured memory_bytes: 128
#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++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	int a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	vector<int> ws;
	{
		rep(i,3001) rep(j,3001){
			int w = (i*a+j*b)*100;
			if(w<=f) ws.pb(w);
		}
		sort(all(ws));
		ws.erase(unique(ws.begin(),ws.end()),ws.end());
	}
	vector<int> ss;
	{
		rep(i,3001) rep(j,3001){
			int w = (i*c+j*d);
			if(w<=f) ss.pb(w);
		}
		sort(all(ss));
		ss.erase(unique(ss.begin(),ss.end()),ss.end());
	}
	int bw = 1, bs = 0;
	for(int w:ws) for(int s:ss) if(w+s<=f){
		if(w+s==0) continue;
		if(w/100 * e < s) continue;
		if(bw*s>=bs*w){
			bw = w;
			bs = s;
		}
	}
	cout<<bw+bs<<" "<<bs<<endl;
}


Measured memory_bytes: 1400
import sys
s = input()
al = 'abcdefghijklmnopqrstuvwxyz'
count = 0
start = -1
end = -1
for ai in al:
    for j in range(len(s)):
        if s[j]==ai:
            if count<0:
                count=1
                start = j+1
            else:
                count+=1
            
        else:
            count-=1
        if start>0and start-1<j and count>0:
            print(start, j+1)
            sys.exit()
print(-1, -1)
        

Measured memory_bytes: 41196