akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

string s;
char c[100000];
int ans = -1;

int main() {
	cin >> s;

	int notxcount = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] != 'x') {
			c[notxcount] = s[i];
			notxcount++;
		}
	}

	bool flag = true;
	for (int i = 0; i < notxcount / 2; i++) {
		if (c[i] != c[notxcount - 1 - i])flag = false;
	}

	//cout << "a" << endl;
	if (flag) {
		ans = 0;
		//中心を見つける
		int left = 0, right = s.length()-1;
		for (int i = 0; i < notxcount / 2 + notxcount % 2;i++) {
			while (s[left] == 'x')left++;
			left++;
			while (s[right] == 'x')right--;
			right--;

		}
		left--;
		right++;
		//cout << "left:" << left << " right:" << right << endl;

		while (left >= 0 || right <= s.length() - 1) {
			//cout << "left:" << left << " right:" << right << endl;
			//cout << "s[left]:" << s[left] << " s[right]:" << s[right] << endl;
			if (left < 0 && right <= s.length() - 1 || left >= 0 && right > s.length() - 1) {//どっちかが出ていた場合
				//cout << "パターン1" << endl;
				if (left >= 0) {
					ans += left;
					if (s[left] == 'x')ans++;
					left = 0;
				}
				else if (right <= s.length() - 1) {
					ans += (s.length() - 1 - right);
					if (s[right] == 'x')ans++;
					right = s.length()-1;
				}
			}else if(s[left] != s[right]) {//どっちかがxだった場合
				//cout << "パターン2" << endl;
				if (s[left] == 'x') {
					while (s[left] == 'x') {
						left--;
						ans++;
					}
				}
				else if(s[right] == 'x'){
					while (s[right] == 'x') {
						right++;
						ans++;
					}
				}
			}
			left--;
			right++;
			//cout << ans << endl;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 512
import java.util.*;
public class Main {
	public static void main(String[] args)  {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong(), m = sc.nextLong();
		if(n>m) {
			long tmp = n;
			n = m;
			m = tmp;
		}
		long ans = 0;
		if(n==1&&m==1) {
			System.out.println(1);
			return;
		}
		if(n==1) {
			ans = m-2;
			System.out.println(ans);
			return;
		}
		
		long t = n * 2 + (m-2) * 2;
		ans = n * m - t;
		System.out.println(ans);
	}
}


Measured memory_bytes: 23760
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>

using namespace std;

long long int a(long long int x) {
	if (x == 1) {
		return 1;
	}
	return x * a(x - 1);
}

int main() {
	int n;
	cin >> n;
	cout << a(n) << endl;
}




Measured memory_bytes: 3076
var lines=[];
var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
reader.on('line', function (line) {
  lines.push(line);
});
reader.on('close', function () {
  main(lines);
});

function main(lines) {
  const words = lines.slice(1).map(s => s.trim());
  const isOk = shiritori(words);
  console.log(isOk ? 'Yes' : 'No'); 
}

function shiritori(words) {
  const exists = [];
  let isOk = true;
  for (let word of words) {
    if (exists.length > 0) {
      const previous = exists[exists.length - 1];
      if (previous.slice(-1) !== word.slice(0, 1) || exists.some(e => e === word)) {
        isOk = false;
        break;
      } else {
        exists.push(word); 
      }
    } else {
      exists.push(word);  
    }
  }
  return isOk;
}


Measured memory_bytes: 7756
#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 n; ll k;
    cin >> n >> k;

    vector<int> a(n+10);
    rep(i, n) cin >> a[i];
    
    vector<int> s;  //index回目に訪れた町を記録
    vector<int> ord(n+10, -1);  //訪れたときのワープ回数を記録
    int circulation, leg;
    {
        int v = 1;
        while (ord[v] == -1)
        {
            ord[v] = s.size();
            s.push_back(v);
            v = a[v-1];
        }    
        
        circulation = s.size() - ord[v];
        leg = ord[v];
    } 
    if (k < leg)  cout << s[k] << endl;
    else {
        k -= leg;
        k %= circulation;
        cout << s[leg+k] << endl;
    }
    return 0;
}

Measured memory_bytes: 5828
#include<stdio.h>

int main(){
	
	int w,i,m,r;
	
	while(1){
		scanf("%d",&w);
		
		if(w==-1) break;
		
		m=1150;
		r=125;
		
		for(i=11;i<=w;i++){
			if(i>20 && i<=30) r=140;
			else if(i>30) r=160;
			m+=r;
		}
		
		printf("%d\n",4280-m);
	}
	
return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int main()
{
    int k;
    string s;
    cin >> k;
    cin >> s;
    
    if (s.size() <= k){
        cout << s << endl;
    }
    else {
        for (int i = 0;i < k;i++){
            cout << s[i];
        }
        cout << "..." << endl;
    }
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

signed main() {
	int A, B, C;
	cin >> A >> B >> C;

	int minDif = LLONG_MAX;

	minDif = min(minDif, abs(A * B * (C / 2) - A * B * (C - (C / 2))));
	minDif = min(minDif, abs(A * C * (B / 2) - A * C * (B - (B / 2))));
	minDif = min(minDif, abs(C * B * (A / 2) - C * B * (A - (A / 2))));

	cout << minDif << endl;

    return 0;
}


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

int main(){
  char n[3];
  int ans=0;
  cin >> n[0] >> n[1] >> n[2];
  if(n[1] == 'R'){
    if(n[0] == 'R' && n[2] == 'R'){
      ans = 3;
    } else if(n[0] == 'R' || n[2] == 'R'){
      ans = 2;
    } else {
      ans = 1;
    }
  } else if(n[0] == 'R' || n[2] == 'R'){
    ans = 1;
  }
  cout << ans << endl;
}


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

//諸機能
#pragma region MACRO 
#define putans(x)  std::cerr << "[ answer ]: " ; cout << (x) << endl
#define dputans(x) std::cerr << "[ answer ]: "; cout << setprecision(40) << (double)(x) << endl
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define RREP(i,n,a) for(int i=(int)(n-1); i>= a; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,n,0)
#define all(a) begin((a)),end((a))
#define mp make_pair
#define exist(container, n) ((container).find((n)) != (container).end())
#define equals(a,b) (fabs((a)-(b)) < EPS)
#ifdef _DEBUG //ファイルからテストデータを読み込む
std::ifstream ifs("data.txt");
#define put ifs >>
#else //ジャッジシステムでいい感じにやる
#define put cin >>
#endif
#pragma endregion
//デバッグなどの支援
#pragma region CODING_SUPPORT
#ifdef _DEBUG
#define dbg(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; }
#define dbg2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg(var1); }
#define dbg3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg2(var1, var2); }
#define dbgArray(a,n) {std::cerr << (#a) << "=";  rep(i,n){std::cerr <<(a[i])<<",";} cerr<<endl;} 
#else
#define dbg(var0) {}
#define dbg2(var0, var1) {}
#define dbg3(var0, var1, var2) {}
#define dbgArray(a,n) {}
#endif 
#pragma endregion 
//typedef（書き換える、書き足す可能性ある）
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii; typedef pair<string, string> pss; typedef pair<int, string>pis;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
#pragma endregion
//諸々の定数(書き換える可能性ある)
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-10)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(2*1e9)
#pragma endregion

int main() {
	int n; put n;
	int sumIndex = 0;
	int sum = 0;
	int k = n;
	rep(i, n) {
		if (sum + i + 1 >= n) {
			sum += i + 1;
			break;
		}
		sum += i + 1;
		sumIndex++;
	}
	vi set;
	while (sumIndex >= 0) {
		if (k > sum - ( sumIndex + 1 )) {
			k -= sumIndex + 1;
			set.push_back(sumIndex + 1);
		}
		sum -= sumIndex + 1;
		sumIndex--;
	}
END:
	reverse(set.begin(), set.end());
	rep(i, set.size() - 1) {
		cout << set[i] << " ";
	}
	cout << set[set.size() - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
l=list(map(int,input()))

def dfs(i,s,sum):
    if i==3:
        if sum==7:
            print(s+'=7')
            exit()
    else:
        dfs(i+1,s+'-'+str(l[i+1]),sum-l[i+1])
        dfs(i+1,s+'+'+str(l[i+1]),sum+l[i+1])
    return -1

dfs(0,str(l[0]),l[0])

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

const ld pi = 3.141592653589793;

ll n, k, p[1005];

int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }

  sort(p, p + n);

  ll ans = 0;
  for (int i = 0; i < k; i++) {
    ans += p[i];
  }

  cout << ans << endl;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};
const int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const string dir8[8] = {"U", "RU", "R", "RD", "D", "LD", "L", "LU"};

// Self settings
// clang-format off
#define MAX_N 100000
#define MAX 100000
#define INFTY (1<<30)
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(a * x, a * y); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x * x + y * y; } bool operator<(const Point& p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point& p) const { return fabs(x - p.y) < EPS && fabs(y - p.y) < EPS; } };
typedef Point Vector;
double norm(Vector a) { return a.x * a.x + a.y * a.y; }
double abs(Vector a) { return sqrt(norm(a));}
double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }
struct Segment { Point p1, p2; };
typedef Segment Line;
// clang-format on

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  REP(i, n) cin >> a[i];
  priority_queue<int> q;
  REP(i, n) q.push(a[i]);
  int sum = 0;
  REP(i, n) sum += a[i];

  for (int i = 0; i < m; i++) {
    int aa = q.top();
    q.pop();
    if (aa < (double)sum / (4 * m)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define mp make_pair
#define M 1000000007
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
const int N=2e5+5;
double f;
int main(){
	scanf("%lf",&f);
	f/=(double)3;
	f=f*f*f;
	printf("%0.10lf\n",f);
}	

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
int main(){
  int A, B;
  cin >> A >> B;
  int socket=1;
  int ans=0;
  while(socket<B){
    socket+=A-1;
    ans++;
  }
  cout << ans <<endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
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; }
const ll INF = 1LL << 60;
int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    int ans = 0;
    rep(i,n){
        if(!i){
            ans += h[i];
        }else{
            ans += max(0,h[i]-h[i-1]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;

int main()
{
    int64_t sx, sy, tx, ty;
    std::cin >> sx >> sy >> tx >> ty;

    for (auto i = sy; i < ty; ++i) {
        std::cout << "U";
    }
    for (auto i = sx; i < tx; ++i) {
        std::cout << "R";
    }

    for (auto i = sy; i < ty; ++i) {
        std::cout << "D";
    }
    for (auto i = sx; i < tx; ++i) {
        std::cout << "L";
    }

    std::cout << "L";
    for (auto i = sy; i <= ty; ++i) {
        std::cout << "U";
    }
    for (auto i = sx; i <= tx; ++i) {
        std::cout << "R";
    }
    std::cout << "D";
    std::cout << "R";
    for (auto i = sy; i <= ty; ++i) {
        std::cout << "D";
    }
    for (auto i = sx; i <= tx; ++i) {
        std::cout << "L";
    }
    std::cout << "U" << std::endl;


    return 0;
}


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

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

  if (1 + k <= a) {
    cout << k + 1 << endl;
    return 0;
  }

  long long sum;

  if (a + 2 < b) {
    int x = k - (a - 1);
    int c = x / 2;
    sum = a + (long long)(b - a) * c + (x % 2);
  } else {
    sum = k + 1;
  }

  cout << sum << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static PrintWriter out;

    public static void main(String[] args) throws IOException {
        out = new PrintWriter(new OutputStreamWriter(System.out));
        CF_Reader in = new CF_Reader();
        int n = in.intNext();

        long[] adds = new long[n];
        long[] subs = new long[n];

        for (int i = 0; i < n; i++) {
            long height = in.longNext();
            long addNum = i + height;
            long subNum = i - height;
            if (addNum < n) adds[(int) addNum]++;
            if (subNum >= 0 && subNum < n) subs[(int) subNum]++;
        }
        long count = 0;
        for (int i = 0; i < n; i++) count += adds[i] * subs[i];
        out.println(count);

        out.close();
    }

    static class CF_Reader {
        BufferedReader br;
        StringTokenizer st;

        public CF_Reader() throws IOException {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine().trim());
            return st.nextToken();
        }

        long longNext() throws IOException {
            return Long.parseLong(next());
        }

        int intNext() throws IOException {
            return Integer.parseInt(next());
        }

        double doubleNext() throws IOException {
            return Double.parseDouble(next());
        }

        char charNext() throws IOException {
            return next().charAt(0);
        }

        public int[] nextIntArray(final int n) throws IOException {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = intNext();
            return a;
        }

        public long[] nextLongArray(final int n) throws IOException {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = longNext();
            return a;
        }

        String line() throws IOException {
            return br.readLine().trim();
        }
    }
}


Measured memory_bytes: 56724
f = open(0)
N, M, L = map(int, f.readline().split())
A = [list(map(int, f.readline().split())) for i in range(N)]
B = [list(map(int, f.readline().split())) for i in range(M)]
C = [[0]*L for i in range(N)]
for i in range(N):
    for j in range(L):
        C[i][j] = str(sum(A[i][k]*B[k][j] for k in range(M)))
for line in C:
    print(*line)



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

using namespace std;

int main()
{

    string a;
    string b;
    cin >> a;
    cin >> b;

    int ans = 0;
    for (int i = 0; i < a.size(); i++)
    {
        ans += a[i] == b[i];
    }

    cout << ans;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int a[100];
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int j = 0; j < (n - 1) / 2 + 1; j++) {
		int tmp;
		tmp = a[j];
		a[j] = a[n - 1 - j];
        a[n - 1 - j] = tmp;
	}
	for (int k = 0; k < n-1; k++) {
		cout << a[k] << ' ';
	}
	cout << a[n-1] << endl;
 	return 0;
}



Measured memory_bytes: 3084
import sys
input=sys.stdin.readline

def main():

    N = int(input())
    I = []
    for _ in range(N):
        x,y,h = map(int, input().split())
        I.append((x,y,h))

    I = sorted(I, key=lambda x:x[2], reverse=True)
    for cx in range(101):
        for cy in range(101):
            H = -1
            b = True
            for i in I:
                if i[2] > 0:
                    h = abs(i[0]-cx) + abs(i[1]-cy) + i[2]
                    if H == -1:
                        H = h
                    if H != h:
                        b = False
                        break
                else:
                    if abs(i[0]-cx) + abs(i[1]-cy) < H:
                        b = False
                        break
            if b:
                print(cx, cy, H)
                return

if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef long double ld;

ll niz[100005];
ll a[100005];
ll dod[100005];

ll n, m, v, p;

bool check(int ind){
    for(int i=1; i<=n; i++) a[i] = niz[i];
    a[ind] += m;
    int veci = 0;
    ll ost = 1LL*m*(v-1);
    for(int i=1; i<=n; i++){
        dod[i] = 0;
        if(a[i] > a[ind]){
            veci++;
            dod[i] = min(ost, m);
            a[i] += dod[i];
            ost -= min(ost, m);
        }
        else{
            dod[i] += min(min(ost, m), a[ind] - a[i]);
            ost -= dod[i];
            a[i] += dod[i];
        }
    }
    //for(int i=1; i<=n; i++) cout << a[i] << " ";
    //cout << endl;
    if(veci >= p) return 0;
    if(!ost) return 1;
    //cout << "Ostalo " << ost << endl;
    vector <ll> vec;
    for(int i=1; i<=n; i++){
        if(i == ind) continue;
        vec.push_back(dod[i]);
    }
    sort(vec.begin(), vec.end());
    for(auto c : vec){
        if(ost <= 0) break;
        if(c < m){
            veci++;
            //cout << c << endl;
            ost -= min(ost, m-c);
        }
        if(ost <= 0) break;
    }
    if(ost || veci >= p) return 0;
    return 1;
}

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

	cin >> n >> m >> v >> p;
	for(int i=1; i<=n; i++){
        cin >> niz[i];
	}
	sort(niz+1, niz+1+n);
	//for(int i=1; i<=n; i++) cout << niz[i] << " ";
	//cout << endl;
    //check(3);
	//return 0;
    int l=1, r=n, res=0;
    while(l <= r){
        int mid = (l+r)/2;
        if(check(mid)){
            r = mid-1;
            res = mid;
        }
        else l = mid+1;
    }
    cout << n-res+1;
    return 0;
}


Measured memory_bytes: 4528
import sys,random

rand = random.randint

def prime(n):
	if n == 2:
		return True
	if n < 2 or n & 1 == 0:
		return False
	d = (n-1) >> 1
	while d & 1 == 0:
		d >>= 1
	
	for i in range(3):
		a = rand(1,n-1)
		t = d
		y = pow(a,t,n)
		while t != n-1 and y != 1 and y != n-1:
			y = pow(y,2,n)
			t <<= 1
		if y != n-1 and t & 1 == 0:
			return False
	return True

a = [prime(i) for i in range(1000000)]

for s in sys.stdin:
	i = int(s)
	print(a[:i+1].count(True))

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

int main() {
  long long N;
  cin >> N;
  long long ans = 0;
  long long div = 10;
  
  if (N % 2 == 0) {
    while (div <= N) {
      ans += N / div;
      div *= 5;
    }
  }
  
  cout << ans << endl;

}
  


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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n,k;cin>>n>>k;
  vector<char> t(k);
  for(int i=0;i<k;i++){
    cin>>t[i];
  }
  while(1){
    string s = to_string(n);
    bool ok=true;
    for(int i=0;i<k;i++){
      if(count(s.begin(), s.end(), t[i])>0)ok=false;
    }
    if(ok){
      cout<<s<<endl;
      return 0;
    }
    n++;
  }


  return 0;
}


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

int main(){
    ll n, m; cin >> n >> m;
    priority_queue<ll> pq;
    for(int i = 0; i < n; i++){
        ll mid; cin >> mid;
        pq.push(mid);
    }
    for(int i = 0; i < m; i++){
        ll k = pq.top() / 2;
        pq.pop();
        pq.push(k);
    }
    ll sum = 0;
    while(!pq.empty()){
        sum += pq.top();
        pq.pop();
    }
    cout << sum << endl;
}

Measured memory_bytes: 1400
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val array = readLine()!!.split(" ").map(String::toInt).sortedDescending().dropLast(n)
    var sum = 0L
    for (i in 0 until n) {
        sum += array[i * 2 + 1]
    }
    println(sum)
}




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

int main() {
	ios :: sync_with_stdio(false);
	map <int, int> mp;
	for(int n; cin >> n; )
		mp[n] ++;
	int f = 0;
	for(auto p : mp)
		f = max(f, p.second);
	for(auto p : mp)
		if(f == p.second)
			cout << p.first << '\n';
	return 0;
}

Measured memory_bytes: 3216
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")
MOD = 998244353

# 処理内容
def main():
    N, S = map(int, input().split())
    A = list(map(int, input().split()))

    dp = [[0]*(S+1) for _ in range(N+1)]
    dp[0][0] = 1
    for i in range(N):
        for j in range(S+1):
            dp[i+1][j] += dp[i][j] * 2
            dp[i+1][j] %= MOD
            if j + A[i] > S:
                continue
            dp[i+1][j+A[i]] += dp[i][j]
            dp[i+1][j+A[i]] %= MOD
    
    print(dp[N][S])


if __name__ == '__main__':
    main()

Measured memory_bytes: 141172
#from collections import Counter
N=int(input())
F=list(int(input().replace(" ",""),2) for i in range(N))
P=list(list(map(int,input().split())) for i in range(N))
ans=-(1<<40)
for bit in range(1,1<<10):
    tmp = 0
    for i in range(N):
        tmp+=P[i][bin(bit&F[i]).count('1')]
    ans = max(ans,tmp)
print(ans)

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

int main() {
  int N;
  cin >> N;
  bitset<10> F[N];
  rep(i,N) {
    rep(j,10) {
      int x;
      cin >> x;
      F[i].set(j,x);
    }
  }
  int P[N][11];
  rep(i,N) rep(j,11) cin >> P[i][j];

  int ans = -INFTY;
  for (int tmp=1; tmp<(1<<10); tmp++) {
    bitset<10> s(tmp);
    int sum = 0;
    rep(i,N) {
      bitset<10> t = (F[i] & s);
      sum += P[i][t.count()];
    }
    if (ans < sum) ans = sum;
  }

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


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<queue>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<unordered_set>
#include<unordered_map>
#define ll long long 
#define lowbit(x) (x)&(-x)
using namespace std;

const int maxn = 1e5 + 100;
int father[maxn];
int getfather(int x)
{
	if (x == father[x]) return x;
	else return father[x] = getfather(father[x]);
}

set<int> s;
int main()
{
	ios::sync_with_stdio(false);
	int N; int M; cin >> N >> M;
	for (int i = 1; i <= N; i++) father[i] = i;
	for (int i = 1; i <= M; i++)
	{
		int a; int b; cin >> a >> b;
		int fa = getfather(a);
		int fb = getfather(b);
		if (fa != fb) father[fa] = fb;
	}

	for (int i = 1; i <= N; i++)
		s.insert(getfather(i));

	cout <<s.size() - 1 << endl;
	return 0;
}

Measured memory_bytes: 7824
n = int(input())
a = list(map(int, input().split()))
ths = [400, 800, 1200, 1600, 2000, 2400, 2800, 3200] 
n_color = [0]*8
n_super = 0
for ai in a:
    for i, th in enumerate(ths):
        if ai < th:
            n_color[i] = 1
            break

    if ai >= 3200:
        n_super += 1

minc = sum(n_color)
maxc = minc + n_super
if minc == 0:
    minc = 1
print(minc, maxc)           

Measured memory_bytes: 3064
//
//  main.c
//  apple pie
//
//  Created by yuta on 2019/05/26.
//  Copyright © 2019 501Software. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[]) {
	
	
	int a,p;
	
	
	// スペース区切りの整数の入力
	scanf("%d %d",&a,&p);

	p = p + (a * 3);
	
	
	
	printf("%d\n",p/2);

	return 0;
}


Measured memory_bytes: 128
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    x=I()
    print(x^1)
    

        
        
        
        
    
if __name__=="__main__":
    main()



Measured memory_bytes: 65452
#include<iostream>
using namespace std;
long xx[1<<17],yy[1<<17],x[1<<17],y[1<<17];
long n,m;
main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>xx[i];
	for(int i=0;i<m;i++)cin>>yy[i];
	for(int i=0;i<n-1;i++)x[i]=xx[i+1]-xx[i];
	for(int i=0;i<m-1;i++)y[i]=yy[i+1]-yy[i];
	long sumx=0,sumy=0,M=1e9+7;
	for(int i=0;i<n-1;i++)sumx=(sumx+(n-1-i)*(i+1)%M*x[i]%M)%M;
	for(int i=0;i<m-1;i++)sumy=(sumy+(m-1-i)*(i+1)%M*y[i]%M)%M;
	cout<<sumx*sumy%M<<endl;
}


Measured memory_bytes: 3840
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

using namespace std;

typedef long long LL;
typedef vector<LL> VL;
#define REPD(i,a,b) for (LL i=(a);i<(b);i++)
#define REP(i,n) REPD(i,0,n)

LL inputValue(){
  LL a;
  cin >> a;
  return a;
};

string inputString(){
  string a;
  cin >> a;
  return a;
};

vector<LL> inputVector(LL a){
  vector<LL> rv;
  REP(i, a){
    LL input;
    cin >> input;
    rv.push_back(input);
  }
  return rv;
}

vector<string> inputVectorString(LL a){
  vector<string> rv;
  REP(i, a){
    string input;
    cin >> input;
    rv.push_back(input);
  }
  return rv;
}
vector<vector<LL>> inputVector2D(LL a, LL b){
  vector<vector<LL>> rv;
  REP(i, a){
    rv.push_back(vector<LL>());
    REP(j, b) {
      LL input;
      cin >> input;
      rv.at(i).push_back(input);
    }
  }
  return rv;
}

#if 0
#define debug(d) debug1(__LINE__,#d, d)
void debug1(LL line, const char* name, vector<LL>& v) {
  cout << line << ":" << name << ":vector<LL>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    cout << v.at(i) << " ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, LL i) {
  cout << line << ":" << name << ":LL " << i << endl;;
}
void debug1(LL line, const char* name, vector<string>& v) {
  cout << line << ":" << name << ":vector<string>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    cout << v.at(i) << " ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, vector<vector<LL>>& v) {
  cout << line << ":" << name << ":vector<vector<LL>>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    REP(j, (LL)v.at(i).size()) {
      cout << v.at(i).at(j) << " ";
    }
    cout << ", ";
  }
  cout << endl;
}
#else
#define debug(n)
#endif

int main(int argc, const char * argv[]) {
	cout.precision(16);
  // source code
  LL m = inputValue();
  LL d = inputValue();
  LL c = 0;
  for (LL mo = 1;mo <= m;mo++) {
    for (LL da = 1;da <= d;da++) {
      if (da/10 < 2) continue;
      if (da%10 < 2) continue;
      if (mo == (da/10) * (da%10)) {
        debug(mo);
        debug(da);
        c++;
      }
    }
  }
  cout << c << endl;


  return 0;
}


Measured memory_bytes: 636
#include <cstdlib>
#include <cstring>
#include <cstdio>

struct Node {

  int key;
  Node *prev, *next;
};

struct Node *nil;


void init() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void insert(int key) {
  //insert element at the beginning of the list
  
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;  //diagram 4.10 on textbook
  x->next = nil->next;
  x->next->prev = x;
  
  nil->next = x;
  x->prev = nil;

}

Node* listSearch(int key) {

  Node *cur = nil->next;
  while (cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return cur;
}

void deleteNode(Node *t) {
  if (t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

void printlist() {
  Node* cur = nil->next;
  while (cur != nil) {
    if (cur->next == nil) printf("%d", cur->key);
    else printf("%d ", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

int main() {

  int N;
  scanf("%d", &N);
  int L = 1000000;

  //Node[L];
  init();
  for (int i = 0; i < N; i++) {
    char cmd[100];
    int key;

    scanf("%s%d", cmd, &key);

    if (cmd[0] == 'i') insert(key);

    else if (cmd[0] == 'd') {
      if (strlen(cmd) == 6) deleteKey(key);
      else if (strlen(cmd) > 6) {
	if (cmd[6] == 'F') deleteFirst();
	else if (cmd[6] == 'L') deleteLast();
      }
    }
  }
      
  printlist();
}

Measured memory_bytes: 32088
#include <iostream>
using namespace std;
int main(){
  long long int n,a,b,max = -1,ans;
  cin >> n;
  while(n--){
    cin >> a >> b;
    if(max < b ){
      max = b;
      ans = a;
    }else if(max == b && ans > a ){
      ans = a;
    }
  }
  cout << ans << " " << max << endl; 
}

Measured memory_bytes: 1160
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d\n", &slice[i])
	}

	sort.IntSlice(slice).Sort()
	m := map[int]int{}
	for _, j := range slice {
		m[j] = 0
	}

	fmt.Println(len(m))

}


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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int a,b;
	cin>>a>>b;
	cout<<(a%3==0||b%3==0||(a+b)%3==0?"Possible\n":"Impossible\n");
}




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

using namespace std;

int n;
string s;
int k;

int main(void)
{
	cin >> n >> s >> k;
	k--;
	for(int i = 0; i < s.size(); i++){
		if(s[i] != s[k]) s[i] = '*';
	}
	cout << s << endl;
	return 0;
}

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


typedef long long ll;

int main() {
  int n; cin >> n;
  vector<int> la(n);
  for (int &a: la) cin >> a;
  sort(la.begin(), la.end());
  int ans = 0;
  for (int i = 0; i < n-1; ++i) {
    int a = la[i];
    for (int j = i+1; j < n-1; ++j) {
      int b = la[j];
      auto it = lower_bound(la.begin(),la.end(),a+b);
      int id = distance(la.begin(),it);
      ans += id-j-1;
      // cerr << a << " " << b << " " << id << endl;
    }
  }
  cout << ans << endl;
}


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

int main(){
  int K;
  cin >> K;
  int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << a[K-1] << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define all(a) a.begin(),a.end()
#define println printf("\n");
#define readln(x) getline(cin,x);
#define pb push_back
#define endl "\n"
#define INT_INF 0x3f3f3f3f
#define LL_INF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define MOD2 1494318097
#define SEED 131
#define mp make_pair
#define fastio cin.tie(0); cin.sync_with_stdio(0);

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unordered_map<int,int> umii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef pair<int,pii> triple;
typedef int8_t byte;

mt19937 g1(time(0));

int randint(int a, int b){return uniform_int_distribution<int>(a, b)(g1);}
ll randlong(ll a,ll b){return uniform_int_distribution<ll>(a, b)(g1);}

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

//ll fmul(ll a, ll b, ll mod){ll res=0;while(a){if(a&1)res=(res+b)%mod;a>>=1;b=(b<<1)%mod;}return res;}
//ll fpowfast(ll b, ll exp, ll mod){ll res=1;while(exp){if(exp&1)res=fmul(res,b,mod);b=fmul(b,b,mod);exp>>=1;}return res;}
//inline bool rabbin_miller(ll x){if(x%2==0) return false;for(int i=0;i<5;i++){ll rd=randlong(2,x-2);if(fpowfast(rd,x-1,x)!=1)return false;}return true;}

ll A,B,res=1;

ll fmul(ll a, ll b, ll mod){
	ll res = 0;
	while(a){
		if(a&1) res = (res+b)%mod;
		a>>=1;
		b = (b<<1)%mod;
	}
	return res;
}

ll fpowfast(ll b, ll exp, ll mod){
	ll res = 1;
	while(exp){
		if(exp&1) res = fmul(res,b,mod);
		b = fmul(b,b,mod);
		exp>>=1;
	}
	return res;
}

inline bool prim(ll x){
	if(x == 2 || x == 3) return true;
//	if(x%2 == 0) return false;
	for(int i=0; i<30; i++){
		ll rd = randlong(2,x-2);
		if(fpowfast(rd,x-1,x) != 1)
			return false;
	}
	return true;
}

//inline bool prim(ull x){
//	if(x == 2) return true;
//	ull lim = sqrt(x);
//	while(lim*lim < x) lim++;
//	while(lim*lim > x) lim--;
//	for(ull k=2; k<=lim; k++){
//		if(x%k == 0) return false;
//	}
//	return true;
//}

int main(){
	scanf("%lld %lld",&A,&B);
	ll gg = __gcd(A,B);
	ll lim = sqrt(gg);
	while(lim*lim < gg) lim++;
	while(lim*lim > gg) lim--;
	for(ll i=2; i<=lim; i++){
		if(gg%i == 0){
			if(prim(i))
				res++;
			if(i*i != gg && prim(gg/i))
				res++;
		}
	}
	if(prim(gg) && gg != 1) res++;
	printf("%lld\n",res);
}

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

int main(){
    int E,Y;
    cin>>E>>Y;
    if (E == 1) {
      cout<<Y+1867<<endl;
    } else if (E == 2) {
      cout<<Y+1911<<endl;
    } else if (E == 3) {
      cout<<Y+1925<<endl;
    } else if (E == 4) {
      cout<<Y+1988<<endl;
    } 
    if (E == 0) {
      if (Y <=1911) {
        cout<<"M"<<Y-1867<<endl;
      } else if (Y <= 1925) {
        cout<<"T"<<Y-1911<<endl;
      } else if (Y <= 1988) {
        cout<<"S"<<Y-1925<<endl;
      } else if (Y <= 2016){
        cout<<"H"<<Y-1988<<endl;
      }
    }
    return 0;
}


Measured memory_bytes: 3100
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7 #998244353
dir = [(-1,0),(1,0),(0,-1),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"


def main():
    h,w = map(int,ipt().split())
    a = [[int(i) for i in ipt().split()] for j in range(h)]
    b = [[int(i) for i in ipt().split()] for j in range(h)]
    dp = [[set() for j in range(w)] for i in range(h)]

    d = abs(a[0][0]-b[0][0])
    dp[0][0].add(d)
    for i in range(1,h):
        d = a[i][0]-b[i][0]
        for j in dp[i-1][0]:
            dp[i][0].add(abs(j-d))
            dp[i][0].add(abs(j+d))
    for i in range(1,w):
        d = a[0][i]-b[0][i]
        for j in dp[0][i-1]:
            dp[0][i].add(abs(j-d))
            dp[0][i].add(abs(j+d))

    for i in range(1,h):
        for j in range(1,w):
            d = a[i][j]-b[i][j]
            for k in dp[i][j-1]:
                dp[i][j].add(abs(k-d))
                dp[i][j].add(abs(k+d))
            for k in dp[i-1][j]:
                dp[i][j].add(abs(k-d))
                dp[i][j].add(abs(k+d))


    print(min(dp[h-1][w-1]))


    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 547712
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

S = input()

S = S.replace("><", ">,<").split(",")

ans = 0
for t in S:
    a = t.count(">")
    b = t.count("<")
    tmp = max(a, b) + sum(range(a)) + sum(range(b))
    ans += tmp
print(ans)

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

int main(){
  
  int A,T,B;
  
  cin >> A >> T >> B;
  
  if ( A * T >= B ){
    cout << B << endl;
  }
  if ( A * T < B ){
    cout << A * T << endl;
  }
}



Measured memory_bytes: 3620
n = int(input())
a = [int(x) for x in input().split()]

# dp(直前の値を取っている)(最大個数取っている)
dp00 = -10**9
dp01 = 0
dp10 = -10**9
dp11 = 0

for i in range(n):
    if i % 2 == 0:
        dp10 = dp00 + a[i]
        dp00 = max(dp01, dp11)
        dp11 = dp01 + a[i]
    else:
        dp01 = dp11
        dp11 = dp00 + a[i]
        dp00 = max(dp00, dp10)
        if i == 3:
            dp10 = a[i]

if n % 2 == 0:
    print(max(dp01, dp11))
else:
    print(max(dp00, dp10))


Measured memory_bytes: 105300
use proconio::*;

fn run() {
    input! {
        n: usize,
        mut a: [i64; n],
    }
    a.sort();
    let mut ans = 0;
    for (i, x) in a.iter().enumerate() {
        for (j, y) in a.iter().enumerate().take(i) {
            for z in a.iter().take(j) {
                if *x < *y + *z && *x != *y && *y != *z && *z != *x {
                    ans += 1;
                }
            }
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 2192
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;


int main(){
    ll n,x,m;
    cin >> n >> x >> m;
    map<ll,ll> h;
    ll pos=-1;
    ll ans=0;
    ll cnt=0;
    ll len=0;
    if(n<=m){
        ll s=0;
        while(s<n){
            ans+=x;
            x=x*x;
            x%=m;
            s++;
        }
        cout << ans << endl;
        return 0;
    }
    while(true){
        h[x]=cnt;
        ans+=x;
        x=x*x;
        x%=m;
        cnt++;
        if(h.count(x)){
            pos=h[x];
            break;
        }
    }
    len=cnt-pos;
    ll times=(n-cnt)/len;
    ll r=n-cnt-len*times;
    ll tot=0;
    ll sum=0;
    rep(i,len){
        sum+=x;
        x=x*x;
        x%=m;
    }
    rep(j,r){
        tot+=x;
        x=x*x;
        x%=m;
    }
    cout << ans+times*sum+tot << endl;
    return 0;
}

Measured memory_bytes: 6736
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		int C = scanner.nextInt();

		String judge = A + B >= C ? "Yes" : "No";
		System.out.println(judge);
	}

}

Measured memory_bytes: 21844
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    h,w=map(int,input().split())
    A=[input() for _ in range(h)]
    dp=[[0]*w for _ in range(h)] #(i,j)までの経路の総数
    dp[0][0]=1
    mod=10**9+7
    for i in range(h):
        for j in range(w):
            if A[i][j]=="#":continue
            if i>=1 and j>=1:    
                dp[i][j]+=(dp[i-1][j]+dp[i][j-1])%mod
            elif j==0:
                dp[i][j]+=dp[i-1][j]%mod
            else:
                dp[i][j]+=dp[i][j-1]%mod
    print(dp[-1][-1]%mod)

if __name__=='__main__':
    main()

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

int main()
{
  int m, d;
  cin >> m >> d;
  int ans = 0;
  for (int i = 4; i <= m; i++) {
    for (int j = 22; j <= d; j++) {
      int d10 = j / 10;
      int d1 = j % 10;
      if (d1 >= 2 && i == d10 * d1) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll t,dp[20][10][3];

bool judge(ll x){
	int n,i;
	ll ans = 0ll,j,k;
	vector<ll> v;
	fill(dp[0][0],dp[20][0],0ll);
	while(x){
		v.push_back(x%10);
		x /= 10;
	}
	reverse(v.begin(),v.end());
	n = v.l_ength();
	for(i=1; i<v[0]; ++i){
		dp[0][i][1] = 1ll;
	}
	dp[0][0][2] = 1ll;
	dp[0][v[0]][0] = 1ll;
	for(i=1; i<n; ++i){
		for(j=0; j<10; ++j){
			for(k=0; k<10; ++k){
				if(abs(j-k)<2){
					dp[i][j][1] += dp[i-1][k][1];
				}
				dp[i][j][2-(!!j)] += dp[i-1][k][2];
			}
		}
		for(j=0; j<=v[i]; ++j){
			for(k=0; k<10; ++k){
				if(abs(j-k)>1){
					continue;
				}
				dp[i][j][(j<v[i])] += dp[i-1][k][0];
			}	
		}
	}
	for(j=0; j<10; ++j){
		ans += dp[n-1][j][0];
		ans += dp[n-1][j][1];
	}
	return (ans>=t);
}

int main(void){
	ll ok=(ll)(1e10),ng=0ll,med;
	cin >> t;
	while(ok-ng>1ll){
		med = (ok+ng)/2;
		if(judge(med)){
			ok = med;
		}else{
			ng = med;
		}
	}
	cout << ok << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define x first
#define y second
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define endl '\n'


int main()
{
	ll a,b,n;
	cin>>a>>b>>n;
	ll p;
	if(n>=b-1){
		p=b-1;
	}else{
		p=n;
	}
	a*=p;
	cout<<(a/b)<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair
int N, M;
multiset<int> st;
vector<pair<int, int>> v;
int main(){
	cin >> N >> M;
	for(int i=0; i<N; i++){
		int tmp;
		cin >> tmp;
		st.insert(tmp);
	}
	for(int i=0; i<M; i++){
		int B, C;
		cin >> B >> C;
		v.PB(MP(C, B));
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	for(int i=0; i<M; i++){
		for(int j=0; j<v[i].second; j++){
			if(*st.begin() >= v[i].first) break;
			st.erase(st.begin());
			st.insert(v[i].first);
		}
	}
	LL ans = 0;
	for(auto itr=st.begin(); itr!=st.end(); itr++){
		ans += (LL)*itr;
	}
	cout << ans << endl;
}


Measured memory_bytes: 6136
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
#define NUM 100005
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int GCD(int a,int b){int c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
int LCM(int a,int b){return a*b/GCD(a,b);}
int POW(int a,int n){int i;LL x=a;if(n==0)return 1;else if(n==1)return a;else FOR(i,0,n-1){x=x*a;if(x>MOD)x%=MOD;}return (int)x;}
//int cmp(const void* a,const void* b){return *(int*)a-*(int*)b;}

int main() {
  int N,A,B,i,ans=0;
  scanf("%d %d %d",&N,&A,&B);
  
  printf("%d\n",MIN(N*A,B));
	return 0;
}

Measured memory_bytes: 128
///Astalavista Code........~CodeSlayer007
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define Br cout<<endl
#define int long long
#define fe first
#define se second
#define double long double
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define PT(x) cout << (x) << endl
#define last(x)  prev(x.end())
#define PTT(x) cout << (#x) << " is " << (x) << endl
#define lets_go ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int M = 1e9 + 7;
const int N = 2e5 + 10;
const int IM = 1e15 + 37;
const double PI = 3.1415926535897932384;
inline void PP(int n) { cout << n << " ";}
void PV(vi v) { for (int i = 0 ; i < v.size() ; i++) cout << v[i] << " " ; cout << endl;}
void PVV(vii v) {for (int i = 0 ; i < v.size() ; i++) cout << v[i].first << " " << v[i].second << endl;}
void PA(int v[], int n, int x = 0) { for (int i = x ; i < n + x; i++)cout << v[i] << ' ' ; cout << endl;}
void IN(int a[], int n, int x = 0) {for (int i = x; i < n + x; i++)cin >> a[i];}
inline void op() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
// <=================================================================================================================================
// <=================================================================================================================================


signed  main() {
    //op();
    lets_go

    int n;
    cin >> n;
    int dp[n + 10][3];
    dp[0][0] = dp[0][1] = dp[0][2] = 0; 
    for (int i = 1; i <= n; i++){
        cin >> dp[i][0] >> dp[i][1] >> dp[i][2];
    }

    for (int i = 1; i <= n; i++) {
        dp[i][0] += max(dp[i - 1][2], dp[i - 1][1]);
        dp[i][1] += max(dp[i - 1][2], dp[i - 1][0]);
        dp[i][2] += max(dp[i - 1][0], dp[i - 1][1]);
    }
    int ans = max({dp[n][0], dp[n][1], dp[n][2]});
    PT(ans);




    /**/
    return 0;
}

Measured memory_bytes: 5964
#include<bits/stdc++.h>
#define ll long long
#define lowbit(x) ((x)&(-(x)))
#define mid ((l+r)>>1)
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid+1, r
using namespace std;
ll sum = 0;
priority_queue<ll> q;
int n, m;
int main()
{
	ios::sync_with_stdio(false);
	while(q.size()) q.pop();
	cin>>n>>m;
	for(int i = 0; i < n; ++i){
        ll x;cin>>x;
        q.push(x);sum += x;
	}
	while(m--){
        ll x = q.top(); q.pop();
        sum -= x - x/2;
        q.push(x/2);
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 1400