akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

/**
 * 0066 Tic Tac Toe
 */
public class Main {

    /** ????????°??? */
    public static int CIRCLE_INDEX = 0;
    /** ???????°??? */
    public static int CROSS_INDEX = 1;

    /** ??? */
    public static char CIRCLE = 'o';
    /** ?? */
    public static char CROSS = 'x';
    /** draw */
    public static char DRAW = 'd';

    public static void main(String[] args) throws IOException {
        for (String[] result : getResults()) {
            System.out.println(judge(result));
        }
    }

    public static List<String[]> getResults() throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String line;
        List<String[]> results = new ArrayList<>();
        while ((line = reader.readLine()) != null) {
            String[] result = createResult(line);
            results.add(result);
        }
        return results;
    }

    // Tic Tac Toe
    public static class WinPattern {

        // Win pattern
        private static final Pattern[] winPattern = { Pattern.compile(".*1.*4.*7.*"), Pattern.compile(".*2.*5.*8.*"),
                Pattern.compile(".*3.*6.*9.*"), Pattern.compile(".*1.*2.*3.*"), Pattern.compile(".*4.*5.*6.*"),
                Pattern.compile(".*7.*8.*9.*"), Pattern.compile(".*1.*5.*9.*"), Pattern.compile(".*3.*5.*7.*") };

        public static Pattern[] getWinPattern() {
            return winPattern;
        }
    }

    public static String[] createResult(String input) {
        StringBuilder o = new StringBuilder("");
        StringBuilder x = new StringBuilder("");
        String[] result = new String[2];
        for (int i = 0; i < input.length(); i++) {
            if (input.charAt(i) == CIRCLE) {
                o.append(i + 1);
            } else if (input.charAt(i) == CROSS) {
                x.append(i + 1);
            }
        }

        result[CIRCLE_INDEX] = o.toString();
        result[CROSS_INDEX] = x.toString();

        return result;
    }

    // Judge
    public static char judge(String[] result) {

        // Check o
        for (Pattern p : WinPattern.getWinPattern()) {
            if (p.matcher(result[CIRCLE_INDEX]).matches()) {
                return CIRCLE;
            }
        }
        // Check x
        for (Pattern p : WinPattern.getWinPattern()) {
            if (p.matcher(result[CROSS_INDEX]).matches()) {
                return CROSS;
            }
        }
        return DRAW;
    }

}

Measured memory_bytes: 24404
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		
		String s = sc.nextLine();
		int[] i = ArrconvAtoi(s);
			
		System.out.println(i[0] * i[1]);

	}
	
    private static int[] ArrconvAtoi(String s) {
        String[] strs = s.split(" ");
        int[] ints = new int[strs.length];
        int i = 0;
 
        for (String st : strs) {
            ints[i] = Integer.parseInt(st);
            i++;
        }
 
        return ints;
    }
}


Measured memory_bytes: 26312
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int a=sc.nextInt();
        int b=sc.nextInt();
        
        System.out.printf("%d %d\n",a*b,2*(a+b));
    }
}



Measured memory_bytes: 26356
#include<iostream>
#include <math.h>
#include <string>
#define int long long int
using namespace std;
signed main()
{
    int A,B;
    cin >> A >> B;
    string s;
    cin >> s;
    if(s[A]=='-')
    {
        int i,c1=0,c2=0;
        for(i=0;i<A;i++)
        {
            if(s[i]>='0'&&s[i]<='9')
                c1++;
        }
        for(i=A+1;i<s.length();i++)
        {
            if(s[i]>='0'&&s[i]<='9')
                c2++;
        }
        if(c1==A && c2==B)
            cout << "Yes";
        else
            cout << "No";
    }
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>
#include <map>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint>> que;
//priority_queue<llint> q;

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

llint h,n;
llint dp[10005];
llint a[1005],b[1005];

void solve(){
  cin >> h >> n;
  for(int i=0;i<n;i++)cin >> a[i] >> b[i];
  for(int i=0;i<=h;i++)dp[i]=inf;
  dp[0]=0;
  for(int i=0; i<n;i++){
    for(int j=0;j<=h;j++){
      chmin(dp[min(j+a[i],h)],dp[j]+b[i]);
    }
  }
  cout << dp[h] << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 384
//#include<stdio.h>
//void acm(int a,int b)
//{
//    int ans=0;
//    int rest;
//    int x;
//    for(int i=a; i<=b; i++)
//    {
//        rest=0;
//        x=i;
//        while(i!=0)
//        {
//            rest*=10;
//            rest+=i%10;
//            i/=10;
//        }
//        if(rest==x)
//            ans++;
//    }
//    printf("%d\n",ans);
//}
//int main()
//{
//    int a,b;
//    scanf("%d%d",&a,&b);
//    acm(a,b);
//    return 0;
//}
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[20],t[20];
long long dp[20][20][2];
long long dfs(int pos,int sta1,int s,int limit)
{
    if(!sta1)
        return s;
    if(!limit && dp[pos][sta1][s] != -1)
        return dp[pos][sta1][s];
    int n = limit?a[sta1]:9;
    long long ans = 0;
    for(int i=0;i<=n;i++)
    {
        t[sta1] = i;
        if(pos == sta1 && i == 0)
            ans+= dfs(pos-1,sta1-1,s,limit&&i==n);
        else if(s && sta1 <= (pos+1)/2)
            ans += dfs(pos,sta1-1,t[pos-sta1+1]==i,limit&&i==n);
        else
            ans += dfs(pos,sta1-1,s,limit&&i==n);
    }
    if(!limit)
        dp[pos][sta1][s] = ans;
    return ans;
}
long long cal(long long x)
{
    int pos = 0;
    while(x)
    {
        a[++pos] = x % 10;
        x /= 10;
    }
    return dfs(pos,pos,1,1);
}

int main()
{
    memset(dp,-1,sizeof(dp));
    int cas = 1;
        long long a,b;
        scanf("%lld%lld",&a,&b);
		if(a>b)swap(a,b);
        printf("%lld\n",cal(b) - cal(a-1));
    return 0;
}


Measured memory_bytes: 256
class SegTree:
    def __init__(self, a, func):
        self.n = 2**(len(a) - 1).bit_length()
        self.f = func
        self.d = [0] * (2 * self.n - 1)
        self.d[self.n - 1:self.n - 1 + len(a)] = a
        for i in reversed(range(self.n - 1)):
            self.d[i] = self.f(self.d[2 * i + 1], self.d[2 * i + 2])

    def update(self, i, v):
        i += self.n - 1
        self.d[i] = v
        while i:
            i = (i - 1) // 2
            self.d[i] = self.f(self.d[2 * i + 1], self.d[2 * i + 2])

    def query(self, l, r):
        assert l <= r
        l += self.n
        r += self.n
        s = self.d[l - 1]
        while l < r:
            if l & 1:
                s = self.f(s, self.d[l - 1])
                l += 1
            if r & 1:
                r -= 1
                s = self.f(s, self.d[r - 1])
            l //= 2
            r //= 2
        return s

def main():
    N = int(input())
    S = [1 << (ord(s) - 97) for s in input()]
    T = SegTree(S, lambda x, y: x | y)

    Q = int(input())
    for _ in range(Q):
        t, a, b = input().split()
        if t == '1':
            T.update(int(a) - 1, 1 << (ord(b) - 97))
        else:
            print(bin(T.query(int(a) - 1, int(b))).count('1'))

main()


Measured memory_bytes: 80536
#include <stdio.h>
int main(void){
  int i,n;
  double x=0;
  scanf("%d\n",&n);
  for (i=0;i<n;i++){
    double a;
    char b[4];
    scanf("%lf%s\n",&a,&b);
  	if (b[0]=='J')x+=a;
    else x+=a*380000.0;
  }
  printf("%lf",x);   
  return 0;
}

Measured memory_bytes: 128
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static int[][] map;
	static int[][] directions8= {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
	static int[][] directions4= {{-1,0},{1,0},{0,-1},{0,1}};
	static int ans;
	static int[] parent;//union-find用
	static int[] rank;//union-find用

	public static void main(String[] args) throws IOException {
		//		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		//		String W	 = in.readLine();
		//		int num = Integer.parseInt(W.split(" ")[0]);

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();

		int[] A = new int[N];

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

		for(int i = 0;i<N-K ; i++) {
			if(A[i+K]> A[i] ) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}




		System.out.println();
	}

	//BFS用に二つの配列を足し算する
	static int[] addArrayElms(int[] a, int[] b) {
		int[] c = new int[a.length];
		for(int i = 0; i < a.length; i++) {
			c[i] = a[i] + b[i];
		}
		return c;
	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
		return b == 0 ? a: gcd(b, a % b);
	}
	public static long gcd(long a, long b) {
		return b == 0 ? a: gcd(b, a % b);
	}

	//Union-Find用の配列を要素数nで初期化
	static void ufInit(int n){
		parent = new int[n];
		rank = new int[n];
	}

	//Union-Findの要素の最上位の親（グループ名）を返す
	static int ufFind(int a) {
		if(parent[a]==a) {
			return a;
		}else {
			return ufFind(parent[a]);
		}
	}

	//Union-Find木を連結する
	static void ufUnite(int a, int b) {
		a = parent[a];
		b = parent[b];

		if(a==b) {
			return;
		}
		if(rank[a] > rank[b]){
			parent[b]=a;
		}else {
			parent[a]=b;
			if(rank[a]==rank[b]) {
				rank[b]++;
			}
		}
	}

	static boolean ufSame(int a, int b) {
		return ufFind(a)==ufFind(b);
	}
}


Measured memory_bytes: 67324
import java.io.*;

class Main{
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int output = 0;
        try{
            String[] keyboardInput = br.readLine().split(" ");
            int K = Integer.parseInt(keyboardInput[0]);
            int S = Integer.parseInt(keyboardInput[1]);
            for(int x = 0; x <= K; x++){
                for(int y = 0; y <= K; y++){
                    if(S - x - y >= 0 && S - x - y <= K){
                        output++;
                    }
                }
            }
            System.out.println(output);
        } catch(IOException e){
            System.out.println(e.getMessage());
        }
    }
}

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

#define rep(i, a, b) for (int i = a, i##end = b; i <= i##end; ++i)
#define per(i, a, b) for (int i = a, i##end = b; i >= i##end; --i)
#define rep0(i, a) for (int i = 0, i##end = a; i < i##end; ++i)
#define per0(i, a) for (int i = (int)a-1; ~i; --i)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define chkmax(a, b) a = max(a, b)
#define chkmin(a, b) a = min(a, b)
#define x first
#define y second

typedef long long ll;

struct Point { double x, y; };
Point operator + (Point a, Point b) { return (Point){a.x + b.x, a.y + b.y}; }
Point operator - (Point a, Point b) { return (Point){a.x - b.x, a.y - b.y}; }
Point operator * (double k, Point a) { return (Point){k * a.x, k * a.y}; }
double dot(Point a, Point b) { return a.x * b.x + a.y * b.y; }
double cross(Point a, Point b) { return a.x * b.y - a.y * b.x; }
double disc(Point a) { return sqrt(dot(a, a)); }

Point P1, P2;
int q;

Point Projection(Point P1, Point P2, Point P3) {
	Point vec1 = P2-P1, vec2 = P3-P1; 
	vec1 = dot(vec1, vec2) / dot(vec1, vec1) * vec1;
	return vec1 + P1;
}

int main() {
	scanf("%lf%lf%lf%lf", &P1.x, &P1.y, &P2.x, &P2.y);
	scanf("%d", &q);
	while (q--) {
		Point P3; scanf("%lf%lf", &P3.x, &P3.y);
		Point P = Projection(P1, P2, P3), _P = 2*P-P3;
		printf("%.10lf %.10lf\n", _P.x, _P.y);
	}
	return 0;
}


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

using namespace std;

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

void SelectionS(int N, vector<int> &A, int &c){
  rep(i, N){
    int minj = i;
    for(int j = i; j < N; j++){
      if(A.at(j) < A.at(minj)){
        minj = j;
      }
    }
    if(minj!=i){
      swap(A.at(i), A.at(minj));
      c++;
    }
  }
}

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

  vector<int> A(N);
  rep(i, N){
    cin >> A.at(i);
  }

  int counter = 0;

  SelectionS(N, A, counter);

  rep(i, N){
    cout <<A.at(i);

    if(i != N-1) cout << " ";
    else cout << endl;
  }

  cout << counter << endl;
}



Measured memory_bytes: 3096
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<tuple>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll c[25];
ll dp[555555];
int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> c[i];
	}
	for (int i = 0; i <= n; i++) {
		dp[i] = inf;
	}
	dp[0] = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < m; j++) {
			if (i >= c[j]) {
				dp[i] = min(dp[i], dp[i - c[j]] + 1);
			}
		}
	}
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 3488
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(x, y) x = max(x, y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
  string s; cin >> s;
  int n = s.size();
  vector<vector<mint>> dp(100005, vector<mint>(2, 0));
  dp[0][0] = 1;
  rep(i, n){
    { //a+b=0
      if(s[i] == '0'){
        dp[i + 1][0] = dp[i][0];
        dp[i + 1][1] = dp[i][1];
      }
      else{
        dp[i + 1][1] = dp[i][1] + dp[i][0];
      }
    }
    { //a+b=1
      if(s[i] == '0'){
        dp[i + 1][1] += dp[i][1]*2;
      }
      else{
        dp[i + 1][0] += dp[i][0]*2;
        dp[i + 1][1] += dp[i][1]*2;
      }
    }
  }
  cout << dp[n][0] + dp[n][1] << endl;
  return 0;
}


Measured memory_bytes: 8804
#include "bits/stdc++.h"
using namespace std;
 
#define OUT(x)  cerr << #x << " = " << x << endl;
#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define pll     pair<long long, long long>
#define ll      long long
 
int n;
vector<int> g[202020];
bool fav[202020];
int far[202020];
int second_farthest[202020];
int closest[202020];
bool in_fav[202020];
long long ans = 0;
 
static const int INF = 0x3f3f3f3f;
 
void dfs1(int v, int prev) {
        if (fav[v]) in_fav[v] = true;
        for (auto u : g[v]) if (u != prev) {
                dfs1(u, v);
                in_fav[v] |= in_fav[u];
                far[v] = max(far[v], far[u] + 1);
        }
}
 
void dfs2(int v, int ma, bool par_fav, int prev) {
        vector<pair<pii, bool>> children;
        children.push_back(mp(mp(0, -1), false));

        for (auto u : g[v]) {
                if (u == prev) children.push_back(mp(mp(ma + 1, u), par_fav));
                else children.push_back(mp(mp(far[u] + 1, u), in_fav[u]));
        }

        vector<pii> fav_children;
        for (auto c : children) if (c.second) fav_children.push_back(mp(c.first.first, c.first.second));

        sort(all(fav_children));
        if (fav_children.empty()) closest[v] = INF;
        else closest[v] = fav_children[0].first;

        sort(all(children), greater<pair<pii, bool>>());
        second_farthest[v] = children[1].first.first;

        for (auto u : g[v]) if (u != prev) { 

                int maa = children[u == children[0].first.second ? 1 : 0].first.first;

                bool par_f = fav[v] || par_fav;
                if (!in_fav[u]) par_f |= !fav_children.empty();
                else par_f |= fav_children.size() > 1;

                ans += (maa < far[u] && par_f) || 
                       (maa > far[u] && in_fav[u]) || 
                       (maa == far[u] && (par_f || in_fav[u]));

                dfs2(u, maa, par_f, v);
        }
}
 
int main() {
        cin >> n;
        for (int i = 0; i < n - 1; i ++) {
                int a, b;
                cin >> a >> b;
                a --, b --;
                g[a].push_back(b);
                g[b].push_back(a);
        }
        string s;
        cin >> s;                                            
        for (int i = 0; i < n; i ++) fav[i] = s[i] == '1' ? true : false;
        dfs1(0, -1);
        dfs2(0, 0, fav[0], -1);
        for (int i = 0; i < n; i ++) {
                if (fav[i]) ans += 1 + second_farthest[i];
                else ans += max(0, 1 + (second_farthest[i] - closest[i]));
        }
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 54660
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long N, A, B;
    scanf("%lld%lld%lld", &N, &A, &B);
    if((B-A)%2==0) printf("%lld\n", (B-A)/2);
    else printf("%lld\n", min(A+B-1, 2*N-A-B+1)/2); 
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main {

  public static int left(int i) {
    return i * 2 + 1;
  }

  public static int right(int i) {
    return i * 2 + 2;
  }

  public static void buildMaxHeap(int[] A) {
    for (int i = A.length - 1; i >= 0; i--) {
      maxHeapify(A, i);
    }
  }

  public static void maxHeapify(int[] A, int i) {
    int l = left(i);
    int r = right(i);
    int largest;
    if (l < A.length && A[l] > A[i])
      largest = l;
    else
      largest = i;
    if (r < A.length && A[r] > A[largest])
      largest = r;
    if (largest != i) {
      int temp = A[i];
      A[i] = A[largest];
      A[largest] = temp;
      maxHeapify(A, largest);
    }
  }

  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int[] A = new int[n];
    for (int i = 0; i < n; i++) {
      A[i] = s.nextInt();
    }
    s.close();
    buildMaxHeap(A);
    for (int i = 0; i < n; i++) {
      System.out.print(" " + A[i]);
    }
    System.out.println();
  }
}




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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N; cin >> N;
    vector<ll> P(N), Q(N);
    rep(i, N){cin >> P.at(i);}
    rep(i, N){cin >> Q.at(i);}

    // use std::next_permutation
    vector<ll> v; rep(i, N){v.push_back(i+1);}
    ll a, b, i = 0;
    do {
        if (v == P){a = i;}
        if (v == Q){b = i;}
        i++;
    } while (next_permutation(v.begin(), v.end()));
    cout << abs(a - b) << endl;
}

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


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

int main()
{
    ll n,k,i,j,ans=0;
    cin>>n>>k;
    ll r,ss,p;
    cin>>r>>ss>>p;
    string s;
    cin>>s;
    for(i=0;i<n;i++)
    {
              if(s[i]==s[i-k] && i>=k){
                    s[i]='A';
              }
              else{
                    if(s[i]=='r')ans+=p;
                    if(s[i]=='s') ans+=r;
                    if(s[i]=='p') ans+=ss;
              }
    }
    cout<<ans;
}


Measured memory_bytes: 3744
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>

using namespace std;

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

typedef vector<int> vi;

set<int> prime;
void eratos(int n)
{
	vi isprime(n+1, 1);
	isprime[0] = isprime[1] = 0;
	reep(i, 2, n+1){
		if(isprime[i]){
			for(int j=i*2; j<=n; j+=i)
				isprime[j] = 0;
		}
	}

	rep(i, n+1){
		if(isprime[i])
			prime.insert(i);
	}
}

int main()
{
	eratos(50000);

	int n;
	while(scanf("%d", &n), n){
		int cnt = 0;
		for(set<int>::iterator itr = prime.begin(); itr != prime.end() && *itr*2<=n; ++itr){
			cnt += prime.count(n-*itr);
		}
		printf("%d\n", cnt);
	}

	return 0;
}

Measured memory_bytes: 1040
program test 
implicit none

integer(8) :: i,j,k,l,m,n,a,b,ans,ans2

read(*,*) n

ans2 = 0

do m = 1,n

if(mod(m,2) == 1) then

ans = 0

do i = 1,m
if(mod(m,i) == 0) then
ans = ans + 1
endif
enddo

if(ans == 8) then
ans2 = ans2 + 1
endif

endif

enddo

write(*,*) ans2

end program

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll M = 1e9 + 7;
int si[] = {-1, 0, 1, 0};
int sj[] = {0, -1, 0, 1};

int main() {
  string s;
  cin >> s;
  string x = "CODEFESTIVAL2016";
  int ans = 0;
  rep(i,16) if (s[i] != x[i]) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3616
n = int(input())

if n % 2 == 1:
    ans = 0
else:
    count = 0
    ans = 0
    # for i in range(1, 19):
    #     count = n // (10 ** i)
    #     ans += count
    for j in range(1, 100):
        five = n // (2 * (5 ** j))
        ans += five

    
print(ans)

#124999999999999995
#1000000000000000000
#111111111111111110
#123456790123456788

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100010
#define INF 10000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
    int n;
    IN(n);
    vector<int>a(n);
    REP(i,n){
        IN(a[i]);
    }
    sort(ALL(a));
    int ans=(a[n/2]-a[n/2-1]);
    OUT(ans);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>	n;
  vector<int> data(4);
  for(int i;i<n;i++){
    string s;
    cin>>s;
    if(s=="AC") data.at(0)++;
    if(s=="WA") data.at(1)++;
    if(s=="TLE") data.at(2)++;
    if(s=="RE") data.at(3)++;
  
  }
    cout<<"AC x "<<data.at(0)<<endl;
  cout<<"WA x "<<data.at(1)<<endl;
  cout<<"TLE x "<<data.at(2)<<endl;
  cout<<"RE x "<<data.at(3)<<endl;
}


Measured memory_bytes: 3628
import java.util.*;
public class Main{
	public static void main(String[] args){
      	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	int sum = 0;
      	for(int i = 1; i < n+1; i++){
          	sum+= 800;
          	if(i % 15== 0) sum-=200;
        }
      	System.out.println(sum);
    }
}

Measured memory_bytes: 35812
class Point
  attr_reader :x, :y, :z
  def initialize(x, y, z)
    @x, @y, @z = [x, y, z].map(&:to_f)
  end
  def -(p)
    Point.new(@x - p.x, @y - p.y, @z - p.z)
  end
  def dot(p)
    @x * p.x + @y * p.y + @z * p.z
  end
  def cross(p)
    Point.new(@y * p.z - @z * p.y, @z * p.x - @x * p.z, @x * p.y - @y * p.x)
  end
  def ==(p)
    (@x - p.x).abs < EPS && (@y - p.y).abs < EPS && (@z - p.z).abs < EPS
  end
  def +(p)
    Point.new(@x + p.x, @y + p.y, @z + p.z)
  end
  def distance(p)
    (self - p).abs
  end
  def abs
    Math::sqrt(@x * @x + @y * @y + @z * @z)
  end
  def normalize
    Point.new(@x / abs, @y / abs, @z / abs)
  end
end
EPS = 1e-9
def intersect?(a, b, c, d)
  ab = b - a
  cd = d - c
  n1 = ab.normalize
  n2 = cd.normalize
  work1 = n1.dot(n2)
  work2 = 1.0 - work1 * work1
  ac = c - a
  d1 = (ac.dot(n1) - work1 * ac.dot(n2)) / work2
  d2 = (work1 * ac.dot(n1) - ac.dot(n2)) / work2
  p1 = a + Point.new(d1 * n1.x, d1 * n1.y, d1 * n1.z)
  p2 = c + Point.new(d2 * n2.x, d2 * n2.y, d2 * n2.z)
p *[a, b, c, d]
p [p1.x, p1.y, p1.z]
p [p2.x, p2.y, p2.z]
p a.distance(p1) + b.distance(p1)
p a.distance(b)
p c.distance(p2) + d.distance(p2)
p c.distance(d)
  (p1 == p2) && ((a.distance(p1) + b.distance(p1) - a.distance(b)).abs < EPS) && ((c.distance(p2) + d.distance(p2) - c.distance(d)).abs < EPS)
end
def parallel?(a, b, c, d)
  (b - a).normalize == (d - c).normalize || (b - a).normalize == (c - d).normalize
end
def solve2
  d, e, a, b, c = 5.times.map{Point.new(*gets.split)}
  abde = (e - d).dot((b - a).cross(d - a)).abs
  bcde = (e - d).dot((c - b).cross(d - b)).abs
  cade = (e - d).dot((a - c).cross(d - c)).abs
  abcd = (d - c).dot((b - a).cross(c - a)).abs
  abce = (e - c).dot((b - a).cross(c - a)).abs
  return false if parallel?(a, b, d, e)
  return false if parallel?(b, c, d, e)
  return false if parallel?(c, a, d, e)
  # return intersect?(a, c, d, e) if parallel?(a, b, d, e)
  # return intersect?(b, a, d, e) if parallel?(b, c, d, e)
  # return intersect?(c, b, d, e) if parallel?(c, a, d, e)
  # return intersect?(a, c, d, e) if abde.zero?
  # return intersect?(b, a, d, e) if bcde.zero?
  # return intersect?(c, b, d, e) if cade.zero?
  abde + bcde + cade == abcd + abce
end
puts (solve2 ? "MISS" : "HIT")

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


#define INF 1000000000000


signed main()
 {
   int a,b;
   cin>>a>>b;
   int ans=0;
   rep(i,b-a){
     ans+=i;
   }
   ans-=a;
   cout<<ans;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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 long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}



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

    vector<int>H(N);
    rep(i,N)cin >> H[i];

    int ans = 0;
    int hi = H[0];
    rep(i,N){
        if(hi <= H[i]){
            ans ++;
            hi = H[i];
        }
           
    }
    cout << ans <<endl;
}


Measured memory_bytes: 3544
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0);

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;




int main(){
	int N; cin >> N;
	string S; cin >> S;
	int ans = 0;
	rep(i,10)rep(j,10)rep(k,10){
		int now = 0;
		rep(l,N){
			if(now == 0 && S[l] == i+'0') now++;
			else if(now == 1 && S[l] == j+'0') now++;
			else if(now == 2 && S[l] == k+'0'){
				ans++;
				break;
			}
		}
	}
	cout << ans << endl;
}



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

int64_t gcd(int64_t m, int64_t n) {
    if (m % n) {
        return gcd(n, m % n);
    } else {
        return n;
    }
}

int main() {
    int32_t t;
    cin >> t;
    int64_t a, b, c, d;
    for (int32_t i = 0; i < t; i++) {
        cin >> a >> b >> c >> d;

        if (d < b || a < b) {
            cout << "No" << endl;
        } else {
            int64_t g = gcd(b, d);
            int64_t m = (a - c) % g ? c + (a - c) % g : c + g;
            if (m < b) {
                cout << "No" << endl;
            } else {
                cout << "Yes" << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    ll n;cin>>n;
    vector<pll> v[n+1];
    rep(i,0,n-1){
        ll s,t,w;cin>>s>>t>>w;
        v[s].push_back(make_pair(t,w));
        v[t].push_back(make_pair(s,w));
    }
    queue<ll> q;
    q.push(1);
    bool used[n+1];fill(used,used+n+1,false);
    queue<ll> dis;
    dis.push(0);
    ll d[n+1];
    d[1]=0;
    while(q.size()>0){
        ll now=q.front();q.pop();
        ll nd=dis.front();dis.pop();
        rep(i,0,v[now].size()){
            ll ne=v[now][i].first;
            if(used[ne])continue;
            used[ne]=true;
            q.push(ne);
            d[ne]=nd+v[now][i].second;
            dis.push(d[ne]);
        }
    }
    rep(i,1,n+1){
        if(d[i]%2==0)cout<<0<<endl;
        else cout<<1<<endl;
    }
}


Measured memory_bytes: 9868
n = int(input())

a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a = [d-1 for d in a]
#print(a)
manzoku = 0
jotai = a[0]

for val in a:
    manzoku = manzoku + b[val]
    if jotai +1 == val:
        manzoku += c[val-1]
    jotai = val

print(manzoku)


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

using namespace std;

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

    int strlen = s.length();
    bool isAccepted = false;
    for (int i = 0; i < strlen - 1; i++) {
        if (s[i] == 'A' && s[i + 1] == 'C') {
            isAccepted = true;
        }
    }

    cout << (isAccepted ? "Yes" : "No") << "\n";

    int a;
    cin >> a;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;

int main(){
    int h, w;
    char G[105][105];
    cin >> h >> w;
    vector<bool>row(h, false);
    vector<bool>col(w, false);
    REP(i, h){
        REP(j, w){
            cin >> G[i][j];
            if(G[i][j] == '#'){
                row[i] = true;
                col[j] = true;
            }
        }
    }
    REP(i, h){
        if(row[i]){
            REP(j, w){
                if(col[j]){
                    cout << G[i][j];
                }
            }
            cout << endl;
        }
    }
    return 0;
}



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

using namespace std;
#define _for(i,j,N) for(int i = (j); i < (N);i++)
#define _rep(i,j,N) for(int i = (j); i <= (N);i++)
#define _dec(i,j,N) for(int i = (N-1);i >= 0;i--)
#define _dep(i,j,N) for(int i = (N); i>= 0;i--)
#define ALL(x) x.begin(),x.end()
#define LL long long
#define ULL unsigned LL
#define PB push_back


int main()
{
    int N,K;
    scanf("%d %d",&N,&K);
    printf("%d\n",N-K+1);
    return 0;
}


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

using namespace std;


const long long MOD = (long long)1e9 + 7;

int main()
{
	int h, w;
	cin >> h >> w;
	string a[h];
	for(int i=0;i<h;i++)
		cin >> a[i];
	long long count[h][w];
	memset(count, 0, sizeof(count));
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(a[i][j] == '#') continue;
			if(i == 0 && j == 0)
				count[i][j] = 1;
			else if(j == 0)
				count[i][j] = count[i-1][j];
			else if(i == 0)
				count[i][j] = count[i][j-1];
			else
				count[i][j] = count[i-1][j] + count[i][j-1];
			count[i][j] %= MOD;
		}
	}
	cout << count[h-1][w-1] << "\n";
	return 0;
}


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

typedef long long int ll;

typedef struct couple{
	int len, line;
}Couple;

bool compare(Couple c1, Couple c2){
	return c1.line < c2.line;
}

int main(){
	int n; scanf("%d",&n);
	Couple tab[n];
	for(int i=0;i<n;i++){
		scanf("%d %d",&tab[i].len, &tab[i].line);
	}
	sort(tab, tab+n, compare);
	
	int temps = 0;
	bool yes = true;
	for(int i=0;i<n;i++){
		temps+=tab[i].len;
		if(temps>tab[i].line){
			yes = false;
		}
	}
	printf("%s",yes? "Yes": "No");
}


Measured memory_bytes: 1792
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] an = new int[n];
		int sameNum = 0;
 
		for( int i=0; i<n; i++ ){
			an[i]=sc.nextInt();
		}
		Arrays.sort(an);

		if( n%2 == 1 && an[0] != 0 ){
			System.out.println(0);
			return;
		}
		for( int i=(n-1); i>0; i-=2 ){
			if(an[i-1] != an[i]){
				System.out.println(0);
				return;
			}
		}

		long ans=1;
		for(int i=0; i<n/2; i++){
			ans = 2*ans%1000000007;
		}
		System.out.println(ans);
                return;
	}
}


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

 
 
//----------------------------MACROS-------------------------------------------------
#define pb insert//                                                                 |
#define eb emplace_back//                                                           |
#define ff first//                                                                  |
#define ss second//                                                                 |
typedef long long int ll;//                                                         |
typedef long double ld;//                                                           |
#define all(a) a.begin(), a.end()//                                                 |
#define show(x) cerr << #x << " is " << x << "\n"//                                 |
#define show2(x, y) cerr << #x << " " << #y << " " << x << " " << y << "\n"//       |
typedef vector<ll> vl;//                                                            |
typedef vector<vl> vvl;//                                                           |
typedef pair<ll, ll> pp;//                                                          |
typedef vector<pp> vp;//                                                            |
typedef map<pp, ll> ipi;//                                                          |
typedef map<pp, char> ipc;//                                                        |
typedef map<ll, ll> ii;//                                                           |
typedef set<ll> sl;//                                                               |
typedef multiset<ll> msl;//                                                         |
typedef map<char, ll> ci;//                                                         |
typedef set<pair<ll, ll>> sp;//                                                     |
const ll mod = 1e9 + 7;//                                                           |
const ll N = 5e5 + 1;//                                                             |
//----------------------------------------------------------------------------------



void solve()
{   
    string s;cin>>s;
    deque<char> q;
    for(auto i:s) q.push_back(i);
    ll query;cin>>query;
    int f=0;
    while(query--){
        ll a;cin>>a;
        if(a==1){
            f^=1;
        }
        else{
            ll b;cin>>b;char c;cin>>c;
            if(b==1){
                if(f) q.push_back(c);
                else q.push_front(c);
            }
            else{
                if(f) q.push_front(c);
                else q.push_back(c);
            }
        }
    }
    string ans;
    for(auto i:q) ans+=i;
    if(f) reverse(all(ans));
    cout<<ans<<"\n";
}
 
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    
    ll t;
    t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    
	return 0;
}

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

int main()
{
  int n;
  vector<int> arr;

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

  int swap_cnt = 0;
  for (int i = 0; i < n; i++) {
    int min_i = i;
    for (int j = i; j < n; j++) {
      if (arr[j] < arr[min_i])
        min_i = j;
    }
    if (i != min_i) {
      swap(arr[i], arr[min_i]);
      swap_cnt++;
    }
  }

  for (int i = 0; i < n; i++)
    cout << arr[i] << (i==n-1?'\n':' ');
  cout << swap_cnt << endl;

  return EXIT_SUCCESS;
}




Measured memory_bytes: 3156
from operator import itemgetter

N, M = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(M)]
ab.sort(key=itemgetter(1))
east_island = ab[0][1]
answer = 1

for i, j in ab:
    if i >= east_island:
        answer += 1
        east_island = j

print(answer)


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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "<" << #__VA_ARGS__ << ">:", debug_out(__VA_ARGS__)
#define INF LLONG_MAX


int main()
{
  ll n, m, c, a, b;
  cin >> n >> m;

  map <ll, vecll> mym;
  vecll ans(n, 0);

  forll(i, 0, m){
	cin >> a >> b;
	mym[a].push_back(b);
	mym[b].push_back(a);
  }
  
  queue <ll> s;
  forll(i, 0, (ll)mym[1].size()){
	if (ans[mym[1][i] - 1] == 0){
	  ans[mym[1][i] - 1] = 1;
	  s.push(mym[1][i]);
	}
  }
  while (not s.empty()){
	ll next = s.front();
	s.pop();
	forll(i, 0, (ll)mym[next].size()){
	  if (ans[mym[next][i] - 1] == 0){
		ans[mym[next][i] - 1] = next;
		s.push(mym[next][i]);
	  }
	}
  }
  cout << "Yes" << endl;
  forll(i, 1, n){
	cout << ans[i] << endl;
  }
}


Measured memory_bytes: 22528
#include <bits/stdc++.h> 
using namespace std; 
#define PI 3.141592653589793238462643383279505

int main(void) 
{
    int a, b, h, m;
    cin>>a>>b>>h>>m;

    long double rad = PI * 2 * (
    (long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - 
    (long double)m / 60.0);

    long double rsq = (long double)(a * a + b * b) - (long double)(2 * a *
b) * cosl(rad);

    printf("%20.20Lf\n", sqrtl(rsq));
    return 0;

}

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

int  main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a<b){
    printf("a < b\n");
  }
  else if(a>b){
    printf("a > b\n");
  }
  else if(a==b){
    printf("a == b\n");
  }
  return 0;
}



Measured memory_bytes: 3156
#include <cstdio>

bool hasElement(int s[], int n, int t) {
    int left = 0, right = n;
    while (left < right) {
        int mid = (left + right) / 2;
        if (s[mid] == t) {
            return true;
        }
        if (s[mid] < t) {
            left = mid + 1;
        } else {
            right = mid;
        }
    }
    return false;
}

int main() {
    int n, q;
    scanf("%d", &n);
    int s[n];
    for (int i = 0; i < n; i++) {
        scanf("%d", &s[i]);
    }
    scanf("%d", &q);
    int c = 0;
    for (int i = 0; i < q; i++) {
        int t;
        scanf("%d", &t);
        if (hasElement(s, n, t)) {
            c++;
        }
    }
    printf("%d\n", c);

    return 0;
}


Measured memory_bytes: 2988
#include <stdio.h>

int main(void)
{
    int a, b;
    scanf("%d %d", &a, &b);

    int count = 0;
    int sum = 1;
    while (sum < b) {
        count++;
        sum += (a - 1);
    }
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll a,b,c,d,k;
ll gcd(ll a,ll b){
    if(a<b) gcd(b,a);
    while(a%b){
        ll r=a%b;
        a=b;b=r;
    }
    return b;
}

ll solve(ll n){
    return (n-(n/c)-(n/d)+(n/k));
}
int main(){
    cin>>a>>b>>c>>d;
    k=c*d/gcd(c,d);
    ll ans = solve(b)-solve(a-1);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt();
		int sosu=0;
		boolean it;

		for(int i=0; i<count; i++) {
			int y = sc.nextInt();
			it=isprime(y);
			if(it) {
				sosu += 1;
			}
		}
		System.out.println(sosu);
	}
	public static boolean isprime(int num) {
		if (num < 2) return false;
		else if (num == 2) return true;
		else if (num % 2 == 0) return false;

		double sqrtNum = Math.sqrt(num);
		for (int i = 3; i <= sqrtNum; i += 2)
		{
			if (num % i == 0)
			{

				return false;
			}
		}

		return true;

	}
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define ins insert

// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define debug(a) cerr<<a<<endl
#else
#define debug(a) ;
#endif

using namespace std;

template<class A, class B>
ostream &operator<<(ostream &os, const pair<A,B> &p){return os<<"("<<p.fi<<", "<<p.se<<")";}
template<class A, class B>
istream &operator>>(istream &is, pair<A,B> &p){return is>>p.fi>>p.se;}

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    ll D,T,S; cin>>D>>T>>S;
    debug(D);
    debug(T*S);
    cout<<(D<=T*S?"Yes":"No")<<endl;
	return 0;
}


Measured memory_bytes: 3656
mod = 10**9+7
f = [1]
for i in range(10**5+7):
    f.append(f[-1]*(i+1)%mod)

def comb(n, r,mod=mod):
    return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod

n, k = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)

ans = 0
for i in range(n-k+1):
    ans += (a[i] - a[-1-i]) * comb(n-1-i, k-1)
    ans %= mod
print(ans)


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

int main() {
  
  int a;
  string s;
  cin >> a >> s;
  
  if (a >= 3200) cout << s << endl;
  else cout << "red" << endl;
  
}


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

using namespace std;
int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	int w[n];
	for (int i = 0; i < n; i++) {
		cin >> w[i];
	}
	
	int first = 0;
	int last = n - 1;
	int s1 = 0;
	int s2 = 0;
	while (first <= last) {
		if (w[first] + s1 <= w[last] + s2) {
			s1 += w[first++];
		} else {
			s2 += w[last--];
		}
	}
	int ans = abs(s1 - s2);
	
	cout << ans << endl;
}

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

int main(){
  int A1,A2,A3;
  cin >> A1 >> A2 >> A3;
  int B,C,D;
  B=min(A3-A1,A3-A2),C=min(A2-A1,A2-A3),D=min(A1-A2,A1-A3);
  if(min(B,min(C,D))>=0){
    cout << min(B,min(C,D)) << endl;
  }
  else{
    cout << (-1)*min(B,min(C,D)) << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <cassert>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<pair<long long, long long>> BA(N);
    for(int i=0; i<N; i++)
        cin >> BA[i].second >> BA[i].first;
    sort(BA.begin(), BA.end());
    long cur = 0;
    for(int i=0; i<N; i++){
        cur += BA[i].second;
        if(cur > BA[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3328