akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main ( void )
{
	int n;

	while ( cin >> n )
	{
		for (int i = 0; i < n; ++i)
		{
			string s1, s2, out = "";
			cin >> s1 >> s2;

			reverse(s1.begin(), s1.end());
			reverse(s2.begin(), s2.end());

			int a, b, c, len = min(s1.size(), s2.size());

			for (int j = c = 0; j < len; ++j)
			{
				int x = (s1[j] - '0') + (s2[j] - '0') + c;
				c = x / 10;
				out += (x % 10 + '0');
			}

			string s;

			if (len == s1.size())
				s = s2;
			else
				s = s1;
			
			for (int j = len; j < s.size(); ++j)
			{
				int x = (s[j] - '0') + c;
				c = x / 10;
				out += (x % 10 + '0');
			}

			if ( c )
			{
				out += '1';
			}

			reverse(out.begin(), out.end());
	
			if ( out.size() > 80 )
				cout << "overflow" << endl;
			else
				cout << out << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
void get_z(string s, vector<int> &z)
{
	int L = 0, R = 0;
	int n = s.size();
	for (int i = 1; i < n; i++) {
		if (i > R) {
			L = R = i;
			while (R < n && s[R - L] == s[R])
				R++;
			z[i] = R - L;
			R--;
		} else {
			int k = i - L;
			if (z[k] < R - i + 1)
				z[i] = z[k];
			else {
				L = i;
				while (R < n && s[R - L] == s[R])
					R++;
				z[i] = R - L;
				R--; 
			}
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		string t(s, i);
		int len = t.size();
		vector<int> z(len);
		get_z(t, z);
		for (int j = 0; j < len; j++) {
			if (min(z[j], j) > ans)
				ans = min(z[j], j);
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const  int maxx=1e5+100;
const int INF=99999999;
const int MOD=1e9+7;
typedef long long ll;
int n;
struct node
{
    int r,nextt;
    ll dis;
}s[maxx*2];
ll d[maxx];
int h[maxx];
int cnt;
void add(int a,int b,ll c)
{
    s[cnt].r=b;
    s[cnt].dis=c;
    s[cnt].nextt=h[a];
    h[a]=cnt;
    cnt++;
}
void dfs(int k,int dd)
{
    for(int i=h[k]; i!=-1; i=s[i].nextt){
        int v=s[i].r;
        if(v==dd)  continue;
        d[v]=d[k]+s[i].dis;
        dfs(v,k);
    }
}
int main()
{
    scanf("%d",&n);
    int a,b;
    ll c;
    cnt=0;
    memset(h,-1,sizeof(h));
    memset(d,0,sizeof(d));
    for(int i=0; i<n-1; i++){
        scanf("%d%d%lld",&a,&b,&c);
        add(a,b,c);
        add(b,a,c);
    }
    int m,k;
    scanf("%d%d",&m,&k);
    dfs(k,-1);
    while(m--){
        scanf("%d%d",&a,&b);
        cout<<d[a]+d[b]<<endl;
    }
    return 0;
}

Measured memory_bytes: 10752
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define RFOR(i, a, b) for(int i = a; i >= b; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
const int INF = 1e9;
typedef long long ll;
using namespace std;
int main() {
    int n, m;
    cin >> n;
    string s[n];
    REP(i, n) cin >> s[i];
    cin >> m;
    string t[m];
    REP(i, m) cin >> t[i];
    int ans = 0;
    REP(i, n) {
        int count = 0;
        REP(j, n) {
            if(s[i] == s[j]) count++;
        }
        REP(j, m) {
            if(s[i] == t[j]) count--;
        }
        ans = max(ans, count);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
      string[] input = Console.ReadLine().Split();
      int a = int.Parse(input[0]);
      int b = int.Parse(input[1]);
      int c = int.Parse(input[2]);
      
      if (a==b){
        Console.WriteLine(c);
      }
      else if (a==c){
        Console.WriteLine(b);
      }
      else if (b==c){
        Console.WriteLine(a);
      }
    }
}


Measured memory_bytes: 27484
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

N, M = map(int, input().split())

if N == 1 and M == 1:
    print(1)
    exit()
elif N == 1 or M == 1:
    print(max(N, M)-2)
    exit()

print( (N-2)*(M-2) )


Measured memory_bytes: 2940
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  long double A, B, N;
  cin >> A >> B >> N;
  ll x = min(B - 1, N);
  ll ans = floor((double)(A * x) / B);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3728
#include <stdio.h>

void island(int s[][50],int w, int h,int i, int j){
  s[i][j] = -1;
  if(s[i][j-1] == 1 && 0 <= j-1) island(s,w,h,i,j-1);
  if(s[i][j+1] == 1 && j+1 <= w-1) island(s,w,h,i,j+1);
  if(s[i-1][j] == 1 && 0 <= i-1) island(s,w,h,i-1,j);
  if(s[i+1][j] == 1 && i+1 <= h-1) island(s,w,h,i+1,j);
  if(s[i+1][j+1] == 1 && i+1 <= h-1 && j+1 <= w-1) island(s,w,h,i+1,j+1);
  if(s[i+1][j-1] == 1 && i+1 <= h-1 && 0 <= j-1) island(s,w,h,i+1,j-1);
  if(s[i-1][j+1] == 1 && 0 <= i-1 && j+1 <= w-1) island(s,w,h,i-1,j+1);
  if(s[i-1][j-1] == 1 && 0 <= i-1 && 0 <= j-1) island(s,w,h,i-1,j-1);
}
    
  
 

int main(){

  int s[50][50],i,j,w,h;
  int count;
  
  while(1){
    scanf("%d %d", &w, &h);
    if(w == 0&&h ==0)
      break;

    for(i = 0; i < h; i++){
      for(j = 0; j < w ; j++){
	scanf("%d",&s[i][j]);
      }
    }

    count = 0;
    for(i = 0; i < h ; i++){
      for(j = 0; j < w ; j++){
	if(s[i][j] == 1){
	  island(s,w,h,i,j);
	  count++;
	}
      }
    }

    printf("%d\n", count);
  }

  return 0;
}



Measured memory_bytes: 2040
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    scanf("%d",&n);
    printf("%s\n",n<=999?"ABC":"ABD");
    return 0;
}


Measured memory_bytes: 128
input();a=list(map(int,input().split()))
b1,b2,b4=0,0,0
for i in a:
  if i%2!=0: b1+=1
  elif i%4==0: b4+=1
  else: b2+=1
print('Yes' if b1<=b4 else 'No' if b2 else 'Yes' if b1<=b4+1 else 'No')

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

int main() {
  int64_t N;
  int x;
  char tui;
  string name;
  cin >> N;
  while(N>0){
    N--;
    x= N % 26;
    tui = x+97;
    name += tui;
    N /= 26;
  }
  reverse(name.begin(), name.end());
  cout << name << endl;
}

Measured memory_bytes: 3624
import java.util.*;
public class Main{

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int num0 = sc.nextInt();
        int num1 = sc.nextInt();
        int i;
        int[] list = new int[num0];
        int min = 0;

        for(i = 0;i < num0;i++){
            list[i] = sc.nextInt();
            if(list[i] == 1){
                min = i;
            }
        }

        int ans = (num0 - 1) / (num1- 1) + 1;
        if((num0 - 1) % (num1 - 1) == 0){
            ans -= 1;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 50064
#define _USE_MATH_DEFINES
#include <math.h>
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n,k;
    cin >> n >> k;
    long long int count1 = 0,count2 = 0;
    for(int i = 1;i <= n;i++)
    {
        if(i % k == 0)
        {
            count1++;
        }
        else if(i % k == k / 2)
        {
            count2++;
        }
    }
    if(k % 2 == 0)
    {
        cout << count1 * count1 * count1 + count2 * count2 * count2 << "\n";
    }
    else
    {
        cout << count1 * count1 * count1 << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
// cout << "Case #" << test << ": ";
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
template <typename Mnd> struct segment_tree {
    int sz;
    vector<Mnd> data;
    function<Mnd(Mnd, Mnd)> f;
    Mnd e;
    //サイズだけ指定して初期化
    segment_tree(int _sz, function<Mnd(Mnd, Mnd)> _f, Mnd _e) : f(_f), e(_e) {
        sz = 1;
        while(sz < _sz)
            sz <<= 1;
        data.assign(sz * 2, e);
    }
    //参照渡しなので代入とかもできる
    Mnd &operator[](const int &k) { return data[k + sz]; }
    //木を構築 O(n)
    void build() {
        for(int i = sz - 1; i > 0; i--)
            data[i] = f(data[2 * i], data[2 * i + 1]);
    }
    //更新しつつ木を再構築 O(log n)
    void update(int k, Mnd x) {
        data[k += sz] = x;
        while(k >>= 1)
            data[k] = f(data[2 * k], data[2 * k + 1]);
    }
    //[a,b)でのクエリに答える　O(log n)
    Mnd query(int a, int b) const {
        Mnd l = e, r = e;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if(a & 1)
                l = f(l, data[a++]);
            if(b & 1)
                r = f(r, data[--b]);
        }
        return f(l, r);
    }
};
int main() {
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    segment_tree<int> dpf(
        n, [](int a, int b) { return max(a, b); }, 0);
    segment_tree<int> dpb(
        n, [](int a, int b) { return max(a, b); }, 0);
    for(int i = 0; i < n; i++) {
        if(s[i] == 'o') {
            dpf.update(i, dpf.query(0, i - c) + 1);
        }
    }
    for(int i = n - 1; i >= 0; i--) {
        if(s[i] == 'o') {
            dpb.update(i, dpb.query(i + c + 1, n) + 1);
        }
    }
    for(int x = 0; x < n; x++) {
        if(s[x] == 'o' && dpf.query(0, x) + dpb.query(x + 1, n) >= k) {
            continue;
        } else if(s[x] != 'x') {
            cout << x + 1 << endl;
        }
    }
}


Measured memory_bytes: 5892
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N,T;
	cin >> N >> T;
	vector<int> A(N);
	for(int i=0;i<N;++i){
		cin >> A[i];
	}
	/////
	int LOW = A[0];
	int MAX_val = 0;
	int MAX_count = 0;
	for(int i=1;i<N;++i){
		if( LOW > A[i] ){
			LOW = A[i];
		}else{
			int temp = A[i] - LOW;
			if( MAX_val < temp ){
				MAX_val = temp;
				MAX_count = 1;
			}else if( MAX_val == temp ){
				MAX_count++;
			}
		}
	}
	cout << MAX_count << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


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

class Main {
    public static void main(String args[]) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] ips = br.readLine().split(" ");
        long n = Long.parseLong(ips[0]);
        long k = Long.parseLong(ips[1]);
        if(n >= k)
            n %= k;
        long res = Math.min(n, k-n);
        System.out.println(res);
    }
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<min({a+b,b+c,a+c})<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  for ( ; ; )
  {
    int n;

    scanf ( "%d", &n );
    if ( !( n ) ) break ;
    n = 1000 - n;

    printf ( "%d\n", ( ( n )       / 500 )
                   + ( ( n % 500 ) / 100 )
                   + ( ( n % 100 ) /  50 )
                   + ( ( n %  50 ) /  10 )
                   + ( ( n %  10 ) /   5 )
                   + ( ( n %   5 ) ) );
  }

  return ( 0 );
}

Measured memory_bytes: 0
A, B, C, X, Y = list(map(int, input().split()))
C *= 2

min_cost = float('inf')
for ab in range(max(X + 1, Y + 1)):
    cost = ab * C
    cost += A * max(0, X - ab)
    cost += B * max(0, Y - ab)
    if min_cost > cost:
        min_cost = cost
print(min_cost)


Measured memory_bytes: 9116
// Created by SAMAN on ۷/۳۱/۲۰۲۰ م..
//#pragma GCC target ("avx2")
#pragma GCC optimization ("O2")
#pragma GCC optimization ("unroll-loops") 
#include <iostream>
#include <algorithm>
#include <map>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue> 
#include <vector>
#include <set>
#include <fstream>
#include <cstdlib>
#include <iterator>
#include <cmath>
#include <ctime>
#include <iomanip>
//#warning not there YET
//#error hello
#define lint long long int
#define endl '\n'
#define kill(x) return cout<<x<<'\n', 0;
#define debug(x) cout << #x << " : " << x << '\n'
#define pb push_back
#define ppb pop_back
#define f first
#define se second
#define _ri [i<<1|1]
#define _le [i<<1]  
//# define h m();
typedef long long  ll;
typedef long double ld;

using namespace std;

string s;
ll a,ab,abc,t;
const int mod = 1e9 + 7;
void m(){
	a %= mod;
	ab %= mod;
	abc %= mod;
	t %= mod;
}
int main(){
	//freopen("kn.txt","r",stdin);
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
	cin >> s;
	int n = s.size();
	t = 1;
	for(int i = 0;i < n;i++){
		if(s[i] == 'A' )
			a += t;
		else if(s[i] == 'B' )
			ab += a;
		else if(s[i] == 'C')
			abc += ab;
		if(s[i] == '?'){
			abc *= 3;
			abc += ab;
			ab *= 3;
			ab += a;
			a *= 3;
			a += t;
			t  *= 3;
		}
		m();
	}
	cout<<abc;
	return 0;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    ll ans = 0;
    ll p;
    ll a;
    cin >> p;
    REP(i, n - 1) {
        cin >> a;
        if (a < p) ans += p - a;
        else p = a;
    }
    cout << ans << endl;
}


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

using ll=long long; 

void solve(){
	int n;
	cin>>n;
	vector<double>x(n);
	vector<string>u(n);
	double sum=0;
	for(int i=0; i<n; i++){
		cin>>x[i]>>u[i];
	}
	for(int i=0; i<n; i++){
		double yen=1;
		if(u[i]=="BTC"){
			yen=380000.0;
		}
		sum+=x[i]*yen;
	}
	cout<<sum<<endl;
}

signed main(){
	//while(1)
	solve();
}

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

int main() {
    int n, cnt = 0, maxv = 0;
    cin >> n;
    vector<int> h(n);
    rep(i,n) {
        cin >> h[i];
    }

    for (int i = n-1; i > 0; i--) {
        if (h[i] <= h[i-1]) cnt++;

        if (h[i] > h[i-1]) cnt = 0;
        maxv = max(maxv, cnt);
    }
    cout << maxv << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;

int main()
{
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5])  cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
a,b,c=map(int,input().split())
cnt=0
while a!=b or b!=c or c!=a:
    if max(a,b,c)-min(a,b,c)!=1:
        if a==min(a,b,c):
            a+=2
        elif b==min(a,b,c):
            b+=2
        else:
            c+=2
        cnt+=1
    else:
        if a==max(a,b,c):
            b+=1
            c+=1
        elif b==max(a,b,c):
            a+=1
            c+=1
        else:
            a+=1
            b+=1
        cnt+=1
print(cnt)

Measured memory_bytes: 3188
from itertools import combinations

X = int(input())
for i, j in combinations(range(1000), 2):
    b = i
    a = j
    i = i ** 5
    j = j ** 5
    if j - i == X:
        print(a, b)
        exit()
    if j + i == X:
        print(a, -b)
        exit()


Measured memory_bytes: 9192
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

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

    int ans = n * (n + 1) / 2;
    cout << ans << endl;

    return 0;
}

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

int main() {
  int N;
  double tmp;
  double sum;
  string s;

  cin >> N;

  for (int i=0; i<N;i++) {
    cin >> tmp;
    sum += (1.0 / tmp);
  }
  
  cout << std::setprecision(16) << (1.0 / sum) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[5];
int main() {
	std::ios::sync_with_stdio(false);
	for(int i=0;i<3;i++) cin>>a[i];
	sort(a,a+3);
	cout<<a[2]*10+a[1]+a[0];
	return 0;
}


Measured memory_bytes: 256
export class Main {
  static main(input: string): string {
    const [abq, ...ms] = input.split("\n");
    const [a, b, q] = abq.split(" ").map(Number);
    const mNs = ms.map(Number);
    const ss = mNs.slice(0, a);
    const ts = mNs.slice(a, a + b);
    const xs = mNs.slice(a + b, a + b + q).map((x, i) => [x, i]);
    xs.sort(([x, i], [x2, i2]) => x - x2);
    const result = []
    let si = 0;
    let ti = 0;
    xs.forEach(([x, i]) => {
      let wS = ss[si] < x ? ss[si] : Infinity;
      let eS = Infinity;
      for (let i = si, len = ss.length; i < len; i++) {
        if (ss[i] >= x) {
          eS = ss[i];
          break;
        }
        wS = ss[i];
        si = i;
      }
      let wT = ts[ti] < x ? ts[ti] : Infinity;
      let eT = Infinity;
      for (let i = ti, len = ts.length; i < len; i++) {
        if (ts[i] >= x) {
          eT = ts[i];
          break;
        }
        wT = ts[i];
        ti = i;
      }
      wS = Math.abs(wS - x)
      eS = Math.abs(eS - x)
      wT = Math.abs(wT - x)
      eT = Math.abs(eT - x);
      result [i] = Math.min(
        Math.max(wS, wT),
        Math.max(eS, eT),
        wS * 2 + eT, wS + eT * 2,
        eS * 2 + wT, eS + wT * 2);
    })
    return result.join("\n");
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 95224
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

template <typename T>
class ford_fulkerson {
  public:
    struct edge {
      explicit edge(size_t t, T c, size_t r) : to(t), cap(c), rev(r) {}
      size_t to; T cap; size_t rev;
    };

    explicit ford_fulkerson(size_t v): G(v), used(v) {}
    ~ford_fulkerson() = default;

    void add_edge(size_t from, size_t to, T cap) {
      G[from].emplace_back(to, cap, G[to].size());
      G[to].emplace_back(from, 0, G[from].size() - 1);
    }
    T dfs(size_t v, size_t t, T f) {
      if (v == t) return f;
      used[v] = true;
      for (auto &&e : G[v]) {
        if (used[e.to] || e.cap <= 0) continue;
        T d = dfs(e.to, t, std::min(f, e.cap));
        if (d > 0) {
          e.cap -= d;
          reverse(e).cap += d;
          return d;
        }
      }
      return 0;
    }
    T max_flow(size_t s, size_t t) {
      T flow = 0;
      while (true) {
        std::fill(used.begin(), used.end(), 0);
        T f = dfs(s, t, infty<T>);
        if (f == 0) return flow;
        flow += f;
      }
    }

  private:
    std::vector<std::vector<edge>> G;
    std::vector<bool> used;
    edge &reverse(edge const &e) {
      return G[e.to][e.rev];
    }
};

using namespace std;

void solve(int n, vector<lli> const &as) {
  ford_fulkerson<lli> ff(n+200);
  int destroy = 150, protect = 151;
  lli offset = 0;
  FOR(i, 1, n) {
    if (as[i] > 0) {
      offset += as[i];
      ff.add_edge(protect, i, as[i]);
    } else {
      ff.add_edge(i, destroy, -as[i]);
    }
    for (int j = 2 * i; j <= n; j += i) {
      ff.add_edge(j, i, infty<lli>);
    }
  }
  cout << offset - ff.max_flow(protect, destroy) << endl;
}

int main() {
  // cout << fixed << setprecision(10);

  int N;
  cin >> N;
  vector<lli> as = { 0 };
  REP(i, N) {
    lli a;
    cin >> a;
    as.push_back(a);
  }
  solve(N, as);
  return 0;
}


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

int main() {
    int n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    for (int i = k; i < n; i++)
    {
        if (a[i-k] < a[i]) cout << "Yes" << endl;
        else cout << "No" << endl;
        
    }
    
    return 0;
}

Measured memory_bytes: 4028
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007
using namespace std;
int r1, r2, c1, c2;
ll ans, arr[2000020];
ll g(int, int);
ll f(int, int);
ll cal(ll, int);
int main()
{
	ios::sync_with_stdio(false);
	arr[0] = 1;
	for(int i = 1; i<=2000010; ++i) arr[i] = arr[i-1]*(ll)i%MOD;
    cin>>r1>>c1>>r2>>c2;
	ans = g(r2, c2)-g(r1-1, c2)-g(r2, c1-1)+g(r1-1, c1-1);
	//ans = (ans+MOD)%MOD;
	ans%=MOD;
	if(ans<0) ans+=MOD;
	cout<<ans<<"\n";
}

ll g(int a, int b)
{
	ll sum = 0;
	for(int i = 1; i<=a+1; ++i) 
		//sum+=f(i, b)%MOD;
		(sum+=f(i, b))%=MOD;
	return sum;
}

ll f(int a, int b)
{
	//(a+b)!/a!/b!;
	return arr[a+b]*cal(arr[a], MOD-2)%MOD*cal(arr[b], MOD-2)%MOD;
}

ll cal(ll a,int b) {
	if (b==0) return 1;
	if (b%2==1) return a*cal(a*a%MOD,b/2)%MOD;
	else return cal(a*a%MOD,b/2);
}

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

int reverse(int x) {
  int res = 0;
  while (x > 0) {
    res *= 10;
    res += x % 10;
    x /= 10;
  }
  return res;
}

int main() {
  int a, b;
  cin >> a >> b;
  int res = 0;
  for (int i = a; i <= b; ++i) {
    if (i == reverse(i)) {
      ++res;
    }
  }
  cout << res << endl;
}


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

int main()
{
    int N, M;
    string S;
    cin >> N >> M >> S;

    reverse(S.begin(), S.end());
    vector<bool> over(S.size());
    for (int i = 0; i < over.size(); i++)
    {
        over[i] = S[i] == '0';
    }

    vector<int> ans;
    int current = 0;
    while (current < N)
    {
        int next = current;
        for (int i = 1; i <= M; i++)
        {
            if (over[current + i])
            {
                next = min(N, current + i);
            }
        }
        if (next == current)
        {
            cout << -1 << endl;
            return 0;
        }
        ans.push_back(next - current);
        current = next;
    }
    reverse(ans.begin(), ans.end());
    for (int a : ans)
    {
        cout << a << " ";
    }
    cout << endl;
}


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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

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

    int* H;
    NEW(H,N+1); //Hi→H[i]とする、添字範囲0~N
    for(int i=1;i<=N;i++){
        scanf("%d",&H[i]);
    }

    int count=0;
    int ans=0;

    for(int i=1;i<N;i++){
        if(H[i]>=H[i+1]){ //右隣に移動できる時
            count+=1;
        }
        else{
            if(ans<count){
                ans=count;
            }
            count=0;
        }
    }
    if(ans<count){
        ans=count;
    }

    printf("%d\n",ans);

    return 0;
}

//300点

Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            if (group(in.nextInt()) == group(in.nextInt()))
                out.println("Yes");
            else
                out.println("No");
        }

        int group(int k) {
            if (k == 1 || k == 3 || k == 5 || k == 7 || k == 8 || k == 10 || k == 12)
                return 1;
            if (k == 4 || k == 6 || k == 9 || k == 11)
                return 2;
            if (k == 2)
                return 3;
            assert (false);
            return -1;
        }

    }

    static class InputReader {
        StringTokenizer st;
        BufferedReader br;

        public InputReader(InputStream is) {
            BufferedReader br = new BufferedReader(new InputStreamReader(is));
            this.br = br;
        }

        public String next() {
            if (st == null || !st.hasMoreTokens()) {
                String nextLine = null;
                try {
                    nextLine = br.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                if (nextLine == null)
                    return null;
                st = new StringTokenizer(nextLine);
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 100000000

using namespace std;

int main()
{
    //COMinit();
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,a,b;
    cin>>n>>a>>b;
    if((b-a)%2==0) cout<<"Alice"<<endl;
    else cout<<"Borys"<<endl;

    return  0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    var f = false
    for(i <- 0 until n) {
      val ch = sc.next()
      if(ch.equals("Y")) {
        f = true
      }
    }
    if(f) {
      println("Four")
    } else {
      println("Three")
    }
  }
}


Measured memory_bytes: 25756
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n;
	vector<int> k;
	vector<int> p;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int a, b;
		cin >> a >> b;
		k.push_back(a);
		p.push_back(b);
	}
	vector<int> vec;
	for (int i = 0; i < n; ++i) {
		int a;
		a = k[i] % p[i];
		if (a == 0) {
			a = p[i];
		}
		vec.push_back(a);
	}
	for (int i = 0; i < n; ++i) {
		cout << vec[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3168
// atcoder/abc115/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<int> a(n);
    cin >> a;
    sort(a.begin(), a.end());
    a.back() /= 2;
    int sum = 0;
    each (i, a) sum += i;
    cout << sum << endl;
  }

  return 0;
}


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

using namespace std;

typedef long long ll;
#define fori(i,n) for(int i=0; i<n; i++)
#define itn int 
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vll vector <ll>
#define be(a) (a).begin(), (a).end()
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	int ans=0;
	cin >> n;
	vi p(n);
	fori (i,n) cin >> p[i];
	sort(be(p));
	fori (i,n) {
		if (p[i]!=p[i+1]) ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
std:: vector<int> v(3,0);
int main(){
	while(std::cin >> v[0] >> v[1] >> v[2]){
		std::sort(v.begin(),v.end());
		std::cout << v[0] << " " << v[1]  << " " << v[2] << std::endl;
	}
}


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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(reader.readLine());
        int[] arr = new int[n];
        String[] split = reader.readLine().split(" ");
        for(int i = 0; i <  split.length; i++) {
            arr[i] = Integer.parseInt(split[i]);
        }
        int ans = 0;
        for(int i =0; i < arr.length; i++) {
            for(int j = i + 1; j < arr.length; j++) {
                for(int p = j + 1; p < arr.length; p++) {
                    if(arr[i] == arr[j] || arr[i] == arr[p] || arr[j] == arr[p]) {
                        continue;
                    }
                    if(arr[i] < arr[j] + arr[p] && arr[j] < arr[p] + arr[i] && arr[p] < arr[i] + arr[j]) {
                        ans++;
                    }
                }
            }
        }
        System.out.println(ans);
    }
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    int array[n + 1];
    for(int i = 1;i <= n;i++)
        array[i] = 0;
    for(int i = 1;i <= m;i++){
        int a, b;
        cin >> a >> b;
        array[a]++;
        array[b]++;
    }
    for(int i = 1;i <= n;i++)
        cout << array[i] << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, z, n) for(int64_t i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int64_t INF = 1LL << 60;
//const int INF = 1 << 29;
//const int MODINF = 1000000007;
//const int64_t INF = 998244353;
using namespace std;
int main(){
    string S;
    int N;
    cin >> N >> S;
    rep(i, 0, S.size()){
        char x = S.at(i) + N;
        if (x > 'Z') x -= 26;
        cout << x;
    }
    cout << endl;
}

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

using namespace std;

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

#include "cpp-pyprint/pyprint.h"

#endif

map<ll, ll> prime_factorize(ll N) {
    map<ll, ll> res;
    for (ll i = 2; i * i <= N; ++i) {
        while (N % i == 0) {
            res[i]++;
            N /= i;
        }
    }
    if (N != 1) res[N] = 1;
    return res;
}


void Main() {
    int N;
    cin >> N;
    auto res = prime_factorize(20);
    unordered_map<ll, ll> tar;
    for (int i = 1; i <= N; ++i) {
        for (auto tmp : prime_factorize(i)){
            if (tar.find(tmp.first) != tar.end()){
                tar[tmp.first] += tmp.second;
            }else{
                tar[tmp.first] = tmp.second;
            }
        }
    }
    ll ans = 1;
    for(auto t: tar) {
        ans *= (t.second + 1);
        ans %= MOD;
    }
    cout << ans << endl;
}

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


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

int main(){
    int N;
    cin >> N;
    vector<string> judge(N);
    int AC = 0;
    int WA = 0;
    int TLE = 0;
    int RE = 0;

    rep(i, N) {
        cin >> judge[i];
        if(judge[i] == "AC") AC++;
        else if(judge[i] == "WA") WA++;
        else if(judge[i] == "TLE") TLE++;
        else if(judge[i] == "RE") RE++;
    }

    cout << "AC x " << AC << endl << "WA x " << WA << endl << "TLE x " << TLE << endl << "RE x " << RE << endl;
}

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

int main(){
	int A, B, n;
	n = 0;
	cin >> A >> B;
	for(int i=0; i < 2; i++){
		if(A <= B){
			n = n + B;
			B--;
		}else{
			n = n + A;
			A--;
		}
	}
	cout << n << endl;

	return 0;

}


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

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		int n = fs.nextInt();
		
		int[] aArr = fs.nextIntArr(n);
		
		Status[][] dp = new Status[n+1][2];
		
		dp[0][0] = new Status(0, 1000);
		dp[0][1] = new Status(0, 0);
		for(int i = 1; i <= n; i++) {
			
			int nowKabuka = aArr[i-1];
			// 売る判定
			long maxKane = 0;
			for(int j = 0; j < i; j++) {
				long kane = (long)dp[j][1].kabu * nowKabuka + (long)dp[j][1].kane;
				if(kane > maxKane) {
					maxKane = kane;
				}
			}
			dp[i][0] = new Status(0, maxKane);
			
			// 買う判定
			maxKane = 0;
			for(int j = 0; j < i; j++) {
				if(dp[j][0].kane > maxKane) {
					maxKane = dp[j][0].kane;
				}
			}
			long buyKabu = maxKane/nowKabuka;
			long rest = maxKane - buyKabu * nowKabuka;
			dp[i][1] = new Status(buyKabu,rest);
		}
		
		
		long ans = 1000;
		for(int i = 0; i < n+1; i++) {
			ans = Math.max(ans, dp[i][0].kane);	
		}
		
		System.out.println(ans);
	}

	class Status {
		long kabu;
		long kane;
		
		Status(long kabu, long kane){
			this.kabu = kabu;
			this.kane = kane;
		}
	}
	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 32548
def solution():
    n, m = map(int, input().split())
    if m == 0:
        if n > 1:
            print(10**(n-1))
        else:
            print(0)
        return

    ans = [-1 for i in range(n)]
    for _ in range(m):
        s, c = map(int, input().split())
        if ((s == 1) and (c == 0) and (n > 1)) or (ans[s-1] not in [c, -1]):
            print(-1)
            return
        ans[s-1] = c
    ans = [i if i != -1 else 0 for i in ans]
    if (ans[0] == 0) and (len(ans) > 1):
        ans[0] = 1
    print(''.join(map(str, ans)))

solution()


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

int main() {
    int X;
    cin >>X;
    int ans =X;
    while(true){
        int count =0;
        for(int i=2;i<=ans;i++){
            if(ans%i==0)break;
            else count ++;
        }
        if(count == ans-2)break;
        else ans++;
    }
    cout << ans <<endl;
}

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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SIZE(x) ((ll)(x).size()) 
#define MAX(x) *max_element(ALL(x)) 
#define MIN(x) *min_element(ALL(x)) 
#define ALL(x) (x).begin(),(x).end() 

#define INF 1000000000000 
#define mod 1000000007 
#define MAXR 100000 

#define PB push_back 
#define MP make_pair 
#define F first 
#define S second 

ll gcd(ll a, ll b)
{
   if (a%b == 0){
       return(b);
   }else{
       return(gcd(b, a%b));
   }
}
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
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, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
bool is_prime(ll n){
    int a = sqrt(n);
    if(n == 1 || n == 2 || n == 3) return true;
    else{
        bool frag = true;
        FOR(i, 2, a+1){
            if(n % i == 0) frag = false;
        }
        return frag;
    }
}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int k;
    string s;
    cin >> k;
    cin >> s;
    int l = s.length();
    combination c(l+k);
    mint a = 0;
    REP(i, k+1){
        mint n = mint(26).pow(k-i)*mint(25).pow(i)*c(i+l-1, l-1);
        a += n;
    }
    cout << a << endl;
}

Measured memory_bytes: 35640
#include <bits/stdc++.h>
#define MAX_N 600
#define P 1000000007
using namespace std;
typedef long long lnt;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n, m; lnt ans;
int p[MAX_N+5], c[MAX_N+5][MAX_N+5];
lnt f[MAX_N+5][MAX_N+5], g[MAX_N+5];
void DP(int l, int r) {
	for (int i = l; i <= r; i++)
		if (p[i] && (p[i] < l || p[i] > r)) return;
	int x = c[l][r], y = n-(m<<1)-x; f[l][r] = g[x]%P;
	for (int i = l+1, z; i <= r-1; i++)
		z = c[i+1][r], (f[l][r] += P-f[l][i]*g[z]%P) %= P;
	(ans += f[l][r]*g[y]%P) %= P;
}
int main() {
	read(n), read(m), n <<= 1, g[0] = 1;
	for (int i = 2; i <= n; i += 2)
		g[i] = g[i-2]*(i-1)%P;
	for (int i = 1, u, v; i <= m; i++)
		read(u), read(v), p[p[u] = v] = u;
	for (int i = 1; i <= n; i++)
		for (int j = i; j <= n; j++)
			c[i][j] = c[i][j-1]+!p[j];
	for (int i = 1; i <= n; i++)
		for (int j = i; j <= n; j++) DP(i, j);
	return printf("%lld\n", ans), 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N;
  cin >> N;
  
  long long x=1;
  for(long long i=2; i<=sqrt(N); i++){
    if((N % i) == 0 ) x = i;
  }
  
  long long times;
  times = x + (N / x) -2;
  
  cout << times << endl;
}

Measured memory_bytes: 256
import sys
S = list(input())
T = list(input())
C = {}
for i in range(97, 97+26):
    C[chr(i)] = -1

k = len(T)
for i in range(len(S)):
    if C[S[i]] == -1:
        C[S[i]] = [i]
    else:
        C[S[i]].append(i)

p = 0
now = -1
ans = 0
used = {}
L = {}
for i in range(97, 97+26):
    used[chr(i)] = 0
    if C[chr(i)] == -1:
        L[chr(i)] = 0
    else:
        L[chr(i)] = len(C[chr(i)])

while(True):
    n = T[p]
    if C[n] == -1:
        print(-1)
        sys.exit()
    else:
        if used[n] >= L[n]:
            p -= 1
            for i in range(97, 97 + 26):
                used[chr(i)] = 0
            ans += len(S) - now - 1
            now = -1
        elif C[n][used[n]] >= now:
            ans += C[n][used[n]] - now
            now = C[n][used[n]]
            used[n] += 1
        else:
            used[n] += 1
            p -= 1
    p += 1
    if p == k:
        print(ans)
        break

Measured memory_bytes: 60272
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int r, d, x;
    long long int ans;

    cin >> r >> d >> x;

    ans = x*r - d;
    for (int i = 0; i < 10; i++) {
        cout << ans << endl;
        ans = r*ans-d;
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m,cnt[30],cc[10010];
int id[110][110],tot;
char s[110];
bool ans;
int main() {
	scanf("%d %d",&n,&m);
	for (int i=1;i<=n;i++) {
		scanf("%s",s);
		for (int j=1;j<=m;j++)
			cnt[s[j-1]-'a'+1]++;
	}
	ans=1;
	if (m==1||n==1) {
		int c,d;
		if (m==1) {
			c=n/2;
			d=n%2;
		}
		else {
			c=m/2;
			d=m%2;
		}
		for (int i=1;i<=26;i++) {
			c-=cnt[i]/2;
			cnt[i]%=2;
		}
		for (int i=1;i<=26;i++) {
			if (cnt[i]==1)
				d--;
		}
		if (c!=0||d!=0) ans=0;
	}
	else {
		for (int i=1;i<=n;i++)
			for (int j=1;j<=m;j++) {
				if (id[i][j]>0) continue;
				tot++;
				id[i][j]=id[i][m-j+1]
				=id[n-i+1][j]=id[n-i+1][m-j+1]=tot;
			}
		for (int i=1;i<=n;i++)
			for (int j=1;j<=m;j++)
				cc[id[i][j]]++;
		int c=0,d=0,e=0;
		for (int i=1;i<=tot;i++) {
			if (cc[i]==1)
				d++;
			else if (cc[i]==2)
				c++;
			else e++;
		}
		for (int i=1;i<=26;i++) {
			if (e-cnt[i]/4<0) {
				cnt[i]-=e*4;
				e=0;
				continue;
			}
			e-=cnt[i]/4;
			cnt[i]%=4;
		}
		if (e>0) ans=0;
		for (int i=1;i<=26;i++) {
			if (cnt[i]==4)
				c-=2;
			if (cnt[i]==3)
				c--,d--;
			if (cnt[i]==2)
				c--;
			if (cnt[i]==1)
				d--;
		}
		if (c!=0||d!=0) ans=0;
	}
	if (ans)
		printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

const int N = 1e5 + 10;

int n, m;
vector <int> v, adj[N];
set <int> p[N];
bool mark[N];

void dfs(int u, int k) {
	mark[u] = true;
	p[k].insert(u);
	for (auto x: adj[u])
		if (!mark[x])
			dfs(x, k);
}

int main() {
	ios_base :: sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		a--;
		v.push_back(a);
	}
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		adj[v].push_back(u);
		adj[u].push_back(v);
	}
	for (int i = 0; i < n; i++)
		if (!mark[i])
			dfs(i, i);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int si = p[i].size();
		vector <int> l;
		for (auto x: p[i])
			l.push_back(v[x]);
		for (int j = 0; j < l.size(); j++)
			p[i].erase(l[j]);
		ans += si - p[i].size();
	}	
	cout << ans;
	return 0;
}

Measured memory_bytes: 21368
import java.util.*;
import java.io.*;
public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = Integer.parseInt(sc.next());
        int count=0;
        for(int i=0; i<n; i++){
            if(isPrime(Integer.parseInt(sc.next()))) count++;
        }
        System.out.println(count);

    }
    //素数判定
    public static boolean isPrime(int x){
        if(x == 2) return true;
        if(x < 2 || x % 2 == 0) return false;
        
        int i = 3;
        while(i <= Math.sqrt(x)){
            if(x % i == 0) return false;
            i = i + 2;
        }
        return true;
    }
}



Measured memory_bytes: 41456