akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main()
{
	int n,i;
	cin>>n;
	for(i=0;i<3;i++)
	{
		int r=n%10;
		if(r==7)
		{
		
		cout<<"Yes";
		return 0;
	}
		
		n=n/10;
	}
	cout<<"No";
}

Measured memory_bytes: 3636
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int d, e, f;
    d = a * x + b * y;
    e = c * max(x, y) * 2;
    f = c * min(x, y) * 2;
    if (x < y) {
      f += b * (y - x);
    } else {
      f += a * (x - y);
    }
    cout << min(d, min(e, f)) << '\n';

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define TDARRAY(int,a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) {if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a, T b) {if(a>b){a=b;return 1;}return 0;}

int n,k,l;
void init(vector<int>& par,vector<int>& height,int n){
    REP(i,n){
        par[i]  = i;
        height[i] = 0;
    }
}
int root(vector<int>& par,vector<int>& height,int x){
    if(par[x]==x){
        return x;
    }else{
        par[x] = root(par,height,par[x]);
        return par[x];
    }
}
bool same(vector<int>& par,vector<int>& height,int x,int y){
    return root(par,height,x)==root(par,height,y);
}
void unite(vector<int>& par,vector<int>& height,int x,int y){
    x = root(par,height,x);
    y = root(par,height,y);
    if(x==y)return;
    if(height[x]<height[y]){
        par[x]=y;
    }else{
        par[y]=x;
        if(height[x]==height[y])height[x]++;
    }
}
int main(){
    cin >> n >> k >> l;
    vector<int> p(k);
    vector<int> q(k);
    REP(i,k){
        int _p,_q;
        cin >> _p >> _q;
        p[i] = _p-1;
        q[i] = _q-1;
    }
    vector<int> r(l);
    vector<int> s(l);
    REP(i,l){
        int _r,_s;
        cin >> _r >> _s;
        r[i] = _r-1;
        s[i] = _s-1;
    }
    
    vector<int> par(n);
    vector<int> height(n);
    vector<int> par2(n);
    vector<int> height2(n);
    
    init(par,height,n);
    init(par2,height2,n);
    
    REP(i,k){
        unite(par,height,p[i],q[i]);
    }
    REP(i,l){
        unite(par2,height2,r[i],s[i]);
    }
    
    vector<pair<P,int>> pr(n);
    Rep(i,n){
        pr[i] = make_pair(make_pair(root(par,height,i), root(par2,height2,i)),i);
    }
    SORT(pr);
    
    vector<int> res(n,0);
    
    int con = 1;
    REP(i,n-1){
        if(pr[i].first==pr[i+1].first){
            con++;
        }else{
            REP(j,con){
                res[pr[i-j].second]+=con;
            }
            con=1;
        }
    }
    REP(j,con){
        res[pr[n-1-j].second]+=con;
    }
    
    REP(i,n){
        put(res[i]);
    }
    return 0;
}



Measured memory_bytes: 8448
# 各位の値を足し算する処理
def sum_each_digit(n):
    total_each_digit = 0
    while n > 0:
        total_each_digit += n % 10
        n //= 10
    return total_each_digit


N, A, B = map(int, input().split())
target_total = 0    # 加算対象の数値の和

for n in range(1, N + 1):

    if A <= sum_each_digit(n) <= B:
        target_total += n

print(target_total)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
char a[1005][1005];
ll dp[1005][1005]={0};

ll solve( int h, int w){
    if(h==1 && w==1) return 1;
    if(h<1 || w<1) return 0;
    if(a[h][w] == '#'){
        return 0;
    }
    if(dp[h][w]!=-1) return dp[h][w];
    ll op1=0,op2=0;
    if(a[h-1][w] != '#')  op1 = solve(h-1,w);
    else op1=0;
    if(a[h][w-1] != '#')  op2 = solve(h,w-1);
    else op2=0;
    
    return dp[h][w] = ( op1+op2 ) %mod;
}
int main() {
    int h,w;
    cin>>h>>w;
    // char a[h][w];
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>a[i][j];
        }
    }
    
    memset(dp,-1,sizeof dp);
    cout<< solve(h,w)<<endl;

    // for(int i=1;i<=h;i++){
    //     for(int j=1;j<=w;j++){
    //         cout<<dp[i][j]<<" ";
    //     }cout<<endl;
    // }
}


Measured memory_bytes: 9216
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner s = new Scanner(System.in);
    Integer n = s.nextInt();
    int a = s.nextInt();
    int b = s.nextInt();
    System.out.println(Math.min(a,b)+" "+Math.max(0,a+b-n));
  }
  }


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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;
ll  a[N];
ll dp[N];

void solve(int testCase){

    scanf("%d" , &n);

    for(int i = 0 ; i < n ; i ++){
            scanf("%lld" , &a[i]);
            dp[i] = INF;
    }

    dp[0] = 0;
    for(int i = 0 ; i < n ; i ++){
            if(i > 0)
                dp[i] = min(dp[i] , dp[i-1] + abs(a[i] - a[i-1]));
            if(i > 1)
                dp[i] = min(dp[i] , dp[i-2] + abs(a[i] - a[i-2]));
    }

    printf("%lld\n" , dp[n-1]);

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


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

int main()
{
    char W[10], T[1005];
    int i, count=0;
    
    scanf("%s", &W);
    while(scanf("%s", &T))
    {
        if (strcmp(T,"END_OF_TEXT") == 0) break;
        //strcmp(str1, str2) 會比較字串 str1 與 str2 的大小，若相同就傳回 0,第一個字串大於第二個字串回傳正值，反之回傳負值。
        for(i = 0; i < strlen(T); i++)
        {
            T[i] = tolower(T[i]); //字母字符轉換成小寫，非字母字符不做出處理
        }
        if(strcmp(W,T) == 0) count++;
    }
    printf("%d\n", count);
    return 0;
}



Measured memory_bytes: 2712
/// However long the night,
///     The dawn will break
/// ICPC next year

#include <bits/stdc++.h>
using namespace std;

const int N = 2e6+5 ;

int n ,m ;
char pat[N], str[N];
int F[N] ,to[N] ;
bool is[N] ;
int vid ,vis[N] ;
long long dp[N] ;

int getNextLen(int len, char c){
  while(len && c != pat[len])
    len = F[len-1];
  if(c == pat[len]) ++len;
  return len;
}

void computeF(){
  for(int i = 1 ; pat[i] ; ++i)
    F[i] = getNextLen(F[i-1], pat[i]);
}

vector<int> search(){
  int len = 0;
  vector<int> res;
  for(int i = 0 ; str[i] ; ++i){
    len = getNextLen(len, str[i]);
    if(!pat[len]) res.push_back(i-len+1);
  }
  return res;
}
long long dfs(int i){
    if(to[i]==-1) return 0;
    if(vis[i]==vid){
        cout << -1 ;
        exit(0) ;
    }
    if(~dp[i]) return dp[i];
    vis[i] = vid ;
    return dp[i] = dfs((to[i]+1)%n) + to[i]-i+1 ;
}
int main(){
    scanf("%s %s", str, pat);
    m = strlen(pat);
    n = strlen(str) ;
    while(n<m){
        for(int i=n;i<n+n;++i) str[i] = str[i-n] ;
        n += n;
    }
    ///for(int i=n;i<n+n;++i) str[i] = str[i-n] ;
    ///n += n;
    for(int i=0;i+1<m;++i) str[n+i] = str[i] ;
    str[n+m] = '\0' ;
    //cout << m << endl ;
    //cout << str << endl << pat << endl ;
    computeF();
    vector<int> sub = search();
    memset(to,-1,sizeof to);
    for(int x : sub) to[x] = x + m - 1 ;
    for(int i=n-1;i-m>=0;--i) if(~to[i-m] && ~to[i]) to[i-m] = to[i] ;

    str[n] = '\0' ;
    long long ans = 0 ;
    memset(dp,-1,sizeof dp);
    for(int i=0;i<n;++i){
        if(to[i]==-1) continue ;
        ++vid ;
        ans = max(ans,dfs(i)/m);
    }
    cout << ans << endl ;
    return 0;
}


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

using namespace std;

char s[100005];
int main() {

    int k, t;
    scanf("%d %d", &k, &t);
    int A[10005];
    for (int i = 0; i < t; ++i) {
        scanf("%d", A + i);
    }
    sort(A, A + t);
    reverse(A, A + t);
    int res = A[0] - 1;
    
    for (int i = 1; i < t; ++i) {
        if (res <= 0) break;
        res -= A[i];
    }
    printf("%d\n", res < 0 ? 0 : res);
        

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ss second
#define ff first
#define Mem(x,val) memset(x,val,sizeof x)
#define pb push_back
#define all(v) v.begin(),v.end()
#define unik(v)  v.erase(unique(v.begin(),v.end()),v.end())
#define cerr(x) cerr << __LINE__ << " th Line : " << #x << " = " << x << "\n"
using namespace std;
typedef pair<int, int> pii;
const ll mod = 998244353;
const int sz = 2 * 1e6 + 10, inf = 1e9 + 10;
ll b;

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


	int n;
	cin >> n;
	ll s = 0;
	for (int i = 1; i <= n; i++)
	{
		if (i%3!=0 && i%5!=0)s+=i;
	}
	cout << s << '\n';

	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
using namespace std;
 
int main() {
	string s,t;
	int counter=0;
	cin>>s>>t;
	if(s[0]==t[0]){
		counter++;
	}
	if(s[1]==t[1]){
		counter++;
	}
	if(s[2]==t[2]){
		counter++;
	}
	cout<<counter;
}

Measured memory_bytes: 3544
#include <bitset>
#include <iostream>
#include <vector>
using namespace std;

const int MAX_ROW = 510;  // to be set appropriately
const int MAX_COL = 64;   // to be set appropriately
struct BitMatrix {
    int H, W;
    bitset<MAX_COL> val[MAX_ROW];
    BitMatrix(int m = 1, int n = 1) : H(m), W(n) {}
    inline bitset<MAX_COL> &operator[](int i) { return val[i]; }
};

int GaussJordan(BitMatrix &A, bool is_extended = false) {
    int rank = 0;
    for (int col = 0; col < A.W; ++col) {
        if (is_extended && col == A.W - 1) break;
        int pivot = -1;
        for (int row = rank; row < A.H; ++row) {
            if (A[row][col]) {
                pivot = row;
                break;
            }
        }
        if (pivot == -1) continue;
        swap(A[pivot], A[rank]);
        for (int row = 0; row < A.H; ++row) {
            if (row != rank && A[row][col]) A[row] ^= A[rank];
        }
        ++rank;
    }
    return rank;
}

int linear_equation(BitMatrix A, vector<int> b, vector<int> &res) {
    int m = A.H, n = A.W;
    BitMatrix M(m, n + 1);
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) M[i][j] = A[i][j];
        M[i][n] = b[i];
    }
    int rank = GaussJordan(M, true);

    // check if it has no solution
    for (int row = rank; row < m; ++row)
        if (M[row][n]) return -1;

    // answer
    res.assign(n, 0);
    for (int i = 0; i < rank; ++i) res[i] = M[i][n];
    return rank;
}

int main() {
    int T;
    cin >> T;
    vector<bool> ans(T, true);
    for (int t = 0; t < T; t++) {
        int N;
        cin >> N;
        vector<bitset<MAX_COL>> A(N);
        string S;
        for (int i = 0; i < N; i++) {
            unsigned long long val;
            cin >> val;
            A.at(i) = bitset<MAX_COL>(val);
        }
        cin >> S;
        BitMatrix m(N, 64);
        int r = 0;
        for (int i = N - 1; i >= 0; i--) {
            m[r] = A[i];
            int rank = GaussJordan(m);
            if (r < rank) {
                if (S[i] == '1') {
                    ans[t] = false;
                    break;
                }
                r = rank;
            }
        }
    }
    for (auto b : ans) {
        if (b) {
            cout << 0 << endl;
        } else {
            cout << 1 << endl;
        }
    }
}


Measured memory_bytes: 3552
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm> 
using namespace std;



int main() {
	int n, a, b, j = 0, AN=0;
	int A[10010];
	cin >> n >> a >> b;
	for (int i = 1; i <= n; i++) {
		int x=0;
		int I = i;
		while (1) {
			if (I < 10) {
				x += I;
				if (a <= x&&x <= b) {
					A[j] = i;
					j++;
					break;
				}
				else { break; }
			}
			x += I % 10;
			I /= 10;
		}
	}
	for (int i = 0; i < j; i++) {
		AN += A[i];
	}
	cout << AN << endl;



	return 0;
}

Measured memory_bytes: 256
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static void solve() throws Exception {
		int n = scanInt();
		out.println(n * (n - 1) / 2 - n / 2);
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < i; j++) {
				if (i + j == (n & ~1) - 1) {
					continue;
				}
				out.println((j + 1) + " " + (i + 1));
			}
		}
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

Measured memory_bytes: 21588
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if(H==0&&W==0) {
				break;
			}
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					if(i==0||i==H-1) {
					System.out.print("#");}
					else {
						if(j==0||j==W-1) {
						System.out.print("#");}
						else{
							System.out.print(".");
						}
					}
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 37192
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <bitset>
#include<iomanip>//小数点以下を精度良く表示

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define INF 2000000000
#define INF2 1000000000000000000
#define PI 3.1415926535
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> P;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;


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

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
int up(int a, int b) {
    return (a + a % b) / b;
}

void swap(string s) {
    int low = 0;
    int high = s.length() - 1;
    while (low < high) {
        char tmp = s[low];
        s[low] = s[high];
        s[high] = tmp;
        low++;
        high--;
    }
}

template<class T>  T gcd(T a, T b) {
    while (a % b != 0) {
        T tmp = b;
        b = a % b;
        a = tmp;
    }
    return b;
}

template<class T> T lcm(T a, T b) {
    if (a == b) return b;
    T g = gcd(a, b);
    return (a / g) * b;
}


int n, k;

ll f(ll x, ll y) {
    return (x + y) * (y - x + 1) / 2;
}

ll sub(ll a) {
    ll small = f(0,a-1);
    ll large = f(n - a + 1,n);
    return large - small + 1;
}

int main() {
    cin >> n >> k;
    ll ans = 0;
    for (int i = k; i <= n+1; i++) {
        ans = (ans+sub(i)+MOD) % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <cstdio>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;
int main(){
    int x,a;
    cin >> x >> a;
    if(x<a){
        cout<<0<<endl;
    }else{
        cout<<10<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int n,m,k[11],a[11][11],p[11],res[11],cnt=0;
bool ch(int ans[])
{
    //for (int i=1;i<=n;i++) cout << ans[i] << " ";
    //cout << "\n";
    for (int i=1;i<=m;i++)
    {
        int on=0;
        for (int j=1;j<=k[i];j++)
            if (ans[a[i][j]]==1) on++;
        if (on%2!=p[i]) return false;
    }
    return true;
}
void batr(int i)
{
    //cout << "i: " << i << "\n";
    if (i==n+1) {if (ch(res)) cnt++;return;}
    for (int j=0;j<=1;j++)
    {
        //cout << "j: " << j << "\n";
        res[i]=j;
        batr(i+1);
    }
}
int main()
{
    //freopen("C.INP","r",stdin);
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin >> n >> m;
    for (int i=1;i<=m;i++)
    {
        cin >> k[i];
        for (int j=1;j<=k[i];j++) cin >>a[i][j];
    }
    for (int i=1;i<=m;i++) cin >> p[i];
    batr(1);
    cout << cnt;
}


Measured memory_bytes: 256
a, b = map(int, input().split(' '))

lst = []
for i in range(1, 10):
    for j in range(10):
        for k in range(10):        
            lst.append(int(str(i)+str(j)+str(k)+str(j)+str(i)))

cnt = 0
for x in lst:
    if a <= x and x <= b:
        cnt += 1
        
print(cnt)

Measured memory_bytes: 3064
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in)
							.useDelimiter("[,\\s+]");

	public static void main(String[] args){
	int r = 0;
	int d = 0;
		while(scan.hasNext()){

			int a = scan.nextInt();
			int b = scan.nextInt();
			int c = scan.nextInt();
			if((double)c == Math.hypot((double) a, (double) b)){
				r++;
			}
			if(a == b){
				d++;
			}
		}
		System.out.printf("%d\n", r);
		System.out.printf("%d\n", d);
	}
}

Measured memory_bytes: 26236
S=[0]*100010
S[1]=1
S[2]=1
for i in range(3,100010):
    S[i]=(S[i-2]+S[i-1])%1000000007

N,M=map(int,input().split())
if M==0:
    ans=1
    print(S[N+1])
    exit()
T=[]
for i in range(M):
    T.append(int(input()))
    if i>=1:
        if T[i]-1==T[i-1]:
            print(0)
            exit()

U=[]
U.append(T[0])
for i in range(1,M):
    U.append(T[i]-T[i-1]-1)

U.append(N-T[M-1])

ans=1
for i in range(len(U)):
    ans=(ans*S[U[i]])%1000000007
print(ans)


Measured memory_bytes: 9480
#include <iostream>
#include <cmath>

using namespace std;

int prime(int a){
    int sqt = sqrt(a);
    int *array = new int[a+1];
    array[1] = 1;
    array[2] = 0;
    array[3] = 0;
    if(a >= 4){
        for(int i = 2; i <= sqt; i++){
            for(int j = 2; j*i <= a; j++){
                array[i*j] = 1;
            }
        }
    }
    int count = 0;
    for(int i = 1; i <= a; i++){
        if(array[i] == 0) count++;
    }
    return count;
}

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

Measured memory_bytes: 59980
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        v_s: [i64; n],
        c_s: [i64; n],
    }
    let mut d_s = vec![];
    for i in 0..n {
        d_s.push(v_s[i] - c_s[i]);
    }
    d_s.sort();
    let mut ans = 0;
    for d in d_s {
        if d > 0 {
            ans += d;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<stdio.h>
#define MAX 100000

int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i + 1;
}

int main(){
  int n,i,A[MAX + 1];

  scanf("%d",&n);
  for(i = 1 ; i <= n ; i++){
    scanf("%d",&A[i]);
  }
  for(i = 1 ; i <= n ; i++){
    printf("node %d: ",i);
    printf("key = %d, ",A[i]);
    if(parent(i) >= 1)printf("parent key = %d, ",A[parent(i)]);
    if(left(i) <= n)printf("left key = %d, ",A[left(i)]);
    if(right(i) <= n)printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2036
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

signed main() {
	int n, m; cin >> n >> m;
	vector<vector<string>> res(n);
	for (int i = 0; i < m; ++i) {
		int p; string s;
		cin >> p >> s; --p;
		res[p].push_back(s);
	}
	int ac, pe; ac = pe = 0;
	for (auto resi : res) {
		int cnt = 0;
		for (auto si : resi) {
			if (si != "AC") ++cnt;
			if (si == "AC") {
				++ac; pe += cnt;
				break;
			}
		}
	}
	cout << ac << " " << pe << endl;
	return 0;
}

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll inf = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/


int main(){
    fIO

    int n;
    cin >> n;

    cout << (n + 1) / 2 - 1;
}








Measured memory_bytes: 256
from collections import deque
n, m = map(int, input().split())
path = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    path[a-1].append(b-1)
    path[b-1].append(a-1)
visited = [-1] * n
ans = [-1] * n
queue = deque([0])
while queue:
    pos = queue.popleft()
    visited[pos] = 1
    ll = path[pos]
    for l in ll:
        if visited[l] == -1:
            if ans[l] == -1:
                ans[l] = pos + 1
                queue.append(l)
print("Yes")
for i in range(1, n):
    print(ans[i])

Measured memory_bytes: 99036
while true
  n_r = gets.split(' ').map {|i| i.to_i}
  n = n_r[0]
  r = n_r[1]
  break if n == 0 && r == 0
  p_cs = []
  r.times do |_|
    p_cs << gets.split(' ').map {|i| i.to_i} 
  end

  place_of_top = 1
  until p_cs.empty?
    p_c = p_cs.pop
    p = p_c[0]
    c = p_c[1]
    case place_of_top
    when 1..c
      place_of_top += p - 1
    when (c+1)..(p + c - 1)
      place_of_top -= c
    end
  end
  puts n + 1 - place_of_top
end

Measured memory_bytes: 8732
using System;

namespace _1356
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            string s = "";
            while (true)
            {
                string a = Console.ReadLine();
                if (string.IsNullOrEmpty(a)) break;
                string[] x = a.Split();
                s += string.Join("",x);
            }           
            for (int i = 0; true; i++)
            {
                string now = i.ToString();
                if (s.IndexOf(now) < 0)
                {
                    Console.WriteLine(i);
                    break;
                }
            }
        }
    }
}


Measured memory_bytes: 9812
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll modpow(ll a, ll n, ll mod_) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod_;
        a = a * a % mod_;
        n >>= 1;
    }
    return res;
}

const ll MAX_SIZE = 200005;
array<ll, MAX_SIZE> fac, inv, finv;
void finit() {
    // combination init
    fac[0] = 1;
    for (ll i = 1; i < MAX_SIZE; i++) fac[i] = fac[i - 1] * i % MOD;
    finv[MAX_SIZE - 1] = modpow(fac[MAX_SIZE - 1], MOD - 2, MOD);
    for(ll i = MAX_SIZE - 1; i > 0; i--) finv[i - 1] = finv[i] * i % MOD;
    
    //inv init
    repe(i, 1, MAX_SIZE) inv[i] = modpow(i, MOD - 2, MOD);
}

ll perm(ll a, ll b) { return fac[a] * finv[a - b] % MOD; }

ll comb(ll a, ll b) { return fac[a] * finv[b] % MOD * finv[a - b] % MOD; }


using P = pair<ll, ll>;
ll dp[3005];

inline P diff(P p1, P p2){
    return {p1.first - p2.first, p1.second - p2.second};
}

int main() {
    init();
    finit();
    ll H, W, N;
    cin >> H >> W >> N;
    H--, W--;

    vc<P> A(N + 1);
    rep(i, N) cin >> A[i].first >> A[i].second, A[i].first--, A[i].second--;
    A[N] = {H, W};
    sort(all(A), [](P p1, P p2) { return (p1.first != p2.first ? p1.first < p2.first : p1.second < p2.second); });

    dp[0]= 1;
    rep(i, N + 1){
        dp[i] = comb(A[i].first + A[i].second, A[i].first);
        rep(j, i){
            P d = diff(A[i], A[j]);
            if (d.second < 0) continue;
            (dp[i] += MOD - dp[j] * comb(d.first + d.second, d.first) % MOD) %= MOD;
        }
    }

    cout << dp[N] << endl;
}

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

int main(){
  int n;
  cin >> n;
  vector <string> t(n);/*該当する文字列*/
  vector <int> num(n,0);/*上記に対応するもらえるかねの配列*/
  for(int i=0;i<n;i++){
    string t_n;
    cin >> t_n;
    for(int j=0;j<n;j++){
      if(t.at(j)==t_n){
        num.at(j)++;
        break;
      }else if(t.at(j)==""){
        num.at(j)=1;
        t.at(j)=t_n;
        break;
      }
    }
  }
  
  int m;
  cin >> m;
  for(int i=0;i<m;i++){
    string t_n;
    cin >> t_n;
    for(int j=0;j<n;j++){
      if(t.at(j)==t_n){
        num.at(j)--;
        break;
      }else if(t.at(j)==""){
        break;
      }
    }
  }
  
  int max=0;
  for(int i=0;i<n;i++){
    if(num.at(i)>max){
      max=num.at(i);
    }
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll l,r;
	l=r=0;
	for(ll i=0;i<n;i++){
		char now=s[i];
		if(s[i]==')'){
			if(r!=0){
				r--;
			}
			else{
				l++;
			}
		}
		else{
			r++;
		}
	}
	for(ll i=0;i<l;i++){
		cout << '(';
	}
	cout << s;
	l=r=0;
	reverse(s.begin(),s.end());
	for(ll i=0;i<n;i++){
		char now=s[i];
		if(s[i]=='('){
			if(r!=0){
				r--;
			}
			else{
				l++;
			}
		}
		else{
			r++;
		}
	}	
	for(ll i=0;i<l;i++){
		cout << ')';
	}
	// your code goes here
	return 0;
}


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

int main()
{   
    int n,m=0;
    scanf("%d",&n);
    int a[n+1],b[n+1];
    for(int i=0;i<=n;i++)b[i]=0;
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    for(int i=n;i>n/2;i--){
        if(a[i]==0)continue;
        else{
            b[i]++;
            m++;
        }
    }
    for(int i=n/2;i>=1;i--){
        int tmp=0;
        for(int j=2;j*i<=n;j++){
            tmp+=b[j*i];
        }
        if(tmp%2==a[i])continue;
        else{
            b[i]++;
            m++;
        }
    }
    printf("%d\n",m);
    for(int i=1;i<=n;i++)if(b[i])printf("%d ",i);
    
    return 0;
}


Measured memory_bytes: 2432
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))


class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

"""
example

N = "number of nodes"
uf = UnionFind(N)

for a,b in range(M):
    uf.Unite(a, b)


"""


N, M = LI()
ab = []
for i in range(M):
    a, b = LI()
    a -= 1
    b -= 1
    ab.append((a,b))

uf = UnionFind(N)
for (a, b) in ab:
    uf.Unite(a,b)

cnt = 0
for i in range(N):
    cnt = max(cnt, uf.Count(i))

print(cnt)

Measured memory_bytes: 41036
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll v[100001];
vector<ll>s;
ll n,m;
int main(void){
    v[0]=0;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        v[i+1]=a%m;
    }
    for(int i=0;i<n;i++){
        v[i+1]=(v[i]+v[i+1])%m;
    }
    for(int i=0;i<n;i++){
        s.push_back(v[i+1]);
    }
    sort(s.begin(),s.end());
    for(int i=0;i<=n;i++){
        //cout<<v[i]<<endl;;
    }
    
    
    
    ll y=0,cnt=0,ans=0;
    for(ll x:s){
        //cout<<x<<endl;
        if(y==x){
            cnt++;
        }
        else{
            ans+=cnt*(cnt+1)/2;
            cnt=0;
            y=x;
        }
    }
    if(cnt>0)ans+=cnt*(cnt+1)/2;
    cout<<ans<<endl;
}


Measured memory_bytes: 2168
N = int(input())
cells = list(map(int, input().split()))
count = []
if N == 1:
    print('Yes')
else:
    for i in reversed(range(1, N)):
        if cells[i] <= cells[i - 1] - 2:
            print('No')
            break
        elif cells[i] == cells[i - 1] - 1:
            count.append('o')
            cells[i - 1] = cells[i - 1] - 1
        else:
            count.append('o')
    if len(count) == N - 1:
        print('Yes')

Measured memory_bytes: 14228
fun main(args: Array<String>) {
    val prod = readLine()!!.replace(" ", "").toInt()
    var num = 0
    var pow = 0
    while (pow < prod) {
        pow = num * num
        if (pow == prod) {
            println("Yes")
            return
        }
        num++
    }

    println("No")
}

Measured memory_bytes: 38028
n = int(input())
xys = [list(map(int, input().split())) for _ in range(n)]

# 各クエリのパリティをチェックする
p = sum(xys[0]) % 2
for xy in xys:
    x, y = xy
    if (x + y) % 2 != p: # パリティが異なるクエリが存在するため、達成できない
        print(-1)
        exit()

if p == 0:
    d = [1]
else:
    d= []

d += [2 ** k for k in range(30 + 1)] # 2 ** 0 から 2 ** 30 まで
m = len(d)

ws = [['' for _ in range(m)] for _ in range(n)]
idx = 0
for xy in xys:
    x, y = xy
    for k in sorted(range(m), reverse=True):
        R = abs(x - d[k]) + abs(y)
        L = abs(x + d[k]) + abs(y)
        U = abs(x) + abs(y - d[k])
        D = abs(x) + abs(y + d[k])

        min_v = min(R, L, U, D)

        if min_v == R:
            ws[idx][k] = 'R'
            x -= d[k]
        elif min_v == L:
            ws[idx][k] = 'L'
            x += d[k]
        elif min_v == U:
            ws[idx][k] = 'U'
            y -= d[k]
        else:
            # if min_v == D:
            ws[idx][k] = 'D'
            y += d[k]
    idx += 1

print(m)
print(*d)
for w in ws:
    print(''.join(w))

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


int main(){
    int n;
    cin >> n;
    vector<pair<string, int>> v(n), ind(n);
    for(int i=0; i<n; i++){
        cin >> v[i].first >> v[i].second;
        v[i].second = -1 * v[i].second;
        ind[i].first = v[i].first;
        ind[i].second = v[i].second;
    }
    sort(v.begin(), v.end());

    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(v[i].first == ind[j].first && v[i].second == ind[j].second) cout << j + 1 << endl;
        }
    }

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    
    long A[1000000];
    long N = 0;
    long n = 0;
    
    cin >> N;
    
    for(long i = 1; i < N; i++)
    {
        cin >> n;
        A[n]++;
    }
    
    for(long i = 1; i <= N; i++)
    {
        cout << A[i] << endl;
    }
    
}

Measured memory_bytes: 5156
#include<iostream>
int main(){int l[99],i,f;for(i=0;i<99;i++)l[i]=0;while(std::cin>>i)l[i-1]++;for(i=0,f=0;i<99;i++)if(f<l[i])f=l[i];for(i=0;i<99;i++)if(l[i]==f)std::cout<<i+1<<"\n";}

Measured memory_bytes: 0
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, parser) => {
        $next
    };

    ($next:expr, $t:ty) => {
        $next(&is_whitespace).parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn main() {
    input! {
        n: usize,
        mut a: [usize; n],
    }

    a.sort();

    let mut t = None;
    let mut i = n - 1;
    loop {
        let mut j = i;
        let mut cnt = 0;
        while a[i] == a[j] {
            cnt += 1;
            if j > 0 {
                j -= 1;
            } else {
                break;
            }
        }
        if cnt >= 2 && t.is_some() {
            println!("{}", a[i] * t.unwrap());
            return;
        } else if cnt >= 4 {
            println!("{}", a[i] * a[i]);
            return;
        } else if cnt >= 2 && t.is_none() {
            t = Some(a[i]);
        }
        i = j;
        if i == 0 {
            break;
        }
    }
    println!("{}", 0);
}


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

long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
}

int main()
{
    int N, index, flag, temp, aind, temp2;
    int A[10005], Apri[10005], prime[1005], yaku[1005], aindex[10005];
    bool asosu;
    long ans1, ans2, ans3;
    long waru = 1000000007;
    cin >> N;
    REP(i, N)
        cin >> A[i];
    prime[0] = 2;
    prime[1] = 3;
    index = 2;
    REP(i, 1000){
        flag = 1;
        REP(j, index){
            if((i+4) % prime[j] == 0){
                flag = 0;
                break;
            }  
        }
        if(flag){
            prime[index] = i+4;
            index++;
        }
    }
    REP(i, index)
        yaku[i] = 0;
    aind = 0;
    REP(i, N){
        flag = A[i];
        REP(j, index){
            temp = 0;
            while(flag > 1){
                if(flag % prime[j] == 0){
                    flag /= prime[j];
                    temp++;
                }else
                    break;
            }
            if(yaku[j] < temp)
                yaku[j] = temp;
        }
        if(flag != 1){
            aindex[aind] = i;
            Apri[aind] = flag;
            aind++;
        }
    }
    //cout << aind << endl;

    set<int> aso;
    REP(i, aind)
        aso.insert(Apri[i]);
    ans3 = 1;
    for(auto itr = aso.begin(); itr != aso.end(); itr++){
        ans3 *= (long)(*itr);
        ans3 %= waru;
    }
    //cout << ans3 << endl;
    temp2 = 0;
    ans1 = 0;
    REP(i, N){
        flag = A[i];
        ans2 = 1;
        REP(j, index){
            temp = 0;
            while(flag > 1){
                if(flag % prime[j] == 0){
                    flag /= prime[j];
                    temp++;
                }else
                    break;
            }
            REP(k, yaku[j] - temp){
                ans2 *= (long)prime[j];
                ans2 %= waru;           
            }
        }
        ans2 *= ans3;
        ans2 %= waru;
        if(aind > 0){
            if(aindex[temp2] == i){
                ans2 *= modinv((long)flag, waru);
                ans2 %= waru;
                temp2++;
            }
        }
        ans1 += ans2;
        ans1 %= waru;
    }
    
    cout << ans1 << endl;
    return 0;
}



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
using Graph = vector<vector<ll>>;
#define all(x) (x).begin(), (x).end() //string の sort とかはこれ
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

const ll MOD = 1000000007;
const ll INF = 1e18; //1*10^18
const double PI = 3.14159265;

int ctoi(char c)
{
  if (c >= '0' && c <= '9')
  {
    return c - '0';
  }
  return 0;
}

ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }
//最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//最小公倍数

ll powll(ll a, ll n)
{ //O(log n)
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a;
    }
    a = a * a;
    n >>= 1; //(n & 1)=(n % 2 !=0)
  }
  return res;
}

ll modpow(ll a, ll n, ll mod) //O(log n)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a % mod;
    }
    a = a * a % mod;
    n >>= 1; //(n>>=1)=(n/2)
  }
  return res;
}

int ReturnDigit(ll num)
{
  string number = to_string(num);
  return number.length();
}

const ll MAX = 1e6;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() //MODは素数じゃないとだよ！！
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind
{
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N)
  { //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++)
      par[i] = i;
  }

  int root(int x)
  { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y)
  {                   // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry)
      return;     //xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y)
  { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main()
{
  // COMinit();
  // srand((unsigned int)time(NULL));//--> rand()
  ll i, j, k, l, ans = 0;
  ll a, b, n;
  cin >> a >> b >> n;
  n = min(n, b - 1);
  ans = (a * n / b) - a * (n / b);
  cout << ans << endl;
}


Measured memory_bytes: 3640
use proconio::input;
use std::cmp::max;

fn main() {
    input!{
        n: usize,
        a: [usize; n],
    }

    let mut mx = 0;
    let mut ans = 0;

    for &i in a.iter() {
        mx = max(i, mx);
        ans += mx - i;
    }

    println!("{}", ans);
}


Measured memory_bytes: 5572
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
int main(){
    string s;
    cin >> s;
    int n = s.size();

    int cnt = 0;
    for(int i = 0; i < n; ++i){
        //
        //cout << i << ":" << s[i] << endl;
        if(i % 2 == 0 && s[i] == '1'){
            cnt++;
        }
        if(i % 2 == 1 && s[i] == '0'){
            cnt++;
        }
    }

    //
    //cout << "n=" << n << " / cnt=" << cnt << endl;
    //
    cout << min(cnt, n-cnt) << endl;
}

Measured memory_bytes: 512
def primeNumber(a):
  if ( a == 2 or a == 3 or a == 5):
    return True
  elif a % 2 == 0:
    return False
  else:
    b = int(a ** 0.5 + 0.5)
    b = b + 1 if b % 2 == 0 else b

    for b in range(b,2,-2)	:
      if a % b == 0 :
        return False

    return True

cnt = 0
N = int(input())
for i in range(N):
  k = int(input())
  pn = primeNumber(k)
  if pn == True:
    cnt +=1
    
print(cnt)


Measured memory_bytes: 5676
#include<bits/stdc++.h>
using namespace std;
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pb push_back
#define F first
#define S second
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vpp vector<pair<long long,long long>>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define d0(x) cout<<(x)<<" "
#define c1(x) cin>>(x)
#define c2(x,y) cin>>(x)>>(y)
#define c3(x,y,z) cin>>(x)>>(y)>>(z)
#define c4(w,x,y,z) cin>>(w)>>(x)>>(y)>>(z)
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define fo(i,a,b) for(int i=a;i<b;i++)
#define alld(c) (c).rbegin(),(c).rend()
#define alli(c) (c).begin(),(c).end()
#define ll long long
const int M=1e9+7;
const double pyi=3.14159265358979323846;

 
int main()
{
	int n;
	sfi(n);
	double ans= 2*pyi*n;
	d1(ans);
	return 0;
}

Measured memory_bytes: 3852
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;

int main() {
	int X;
	cin >> X;
	int i = X / 100;
	if (i * 100 <= X && X <= i * 105) {
		cout << 1 << endl;
		return 0;
	}

	cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 256