akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

const int N = 1e6 + 10;

int n;
int cnt[N], check[N];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        int x; scanf("%d", &x);
        cnt[x]++;
    }
    for (int i = 1; i < N; i++) if (cnt[i]) {
        for (int j = i * 2; j <= (int)(1e6); j += i)
            check[j] = 1;
    }
    int res = 0;
    for (int i = 1; i < N; i++) if (cnt[i] == 1 && !check[i])
        res++;
    cout << res;
}


Measured memory_bytes: 11576
import sys
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))

if N <= 2:
    print(1)
    sys.exit()

A = [A[0]] + [y for x,y in zip(A,A[1:]) if x != y]
sq = np.diff(A)

ans = 1
flg = 0
prev = sq[0]
for i in range(1, len(sq)):
    if flg==1:
        prev = sq[i]
        flg = 0
        continue
    current = sq[i]
    if (prev * current) > 0:
        continue
    else:
        ans += 1
        prev = current
        flg = 1

print(ans)

Measured memory_bytes: 23140
// Problem: C - Sum of product of pairs
// Contest: AtCoder - AtCoder Beginner Contest 177
// URL: https://atcoder.jp/contests/abc177/tasks/abc177_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)



    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define FAST ios_base::sync_with_stdio(false);cin.tie(0);
    const double EPS = 1e-9;
    const double PI = acos(-1);
    const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
    //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
    //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
    const int dx[] = {0 , 1 , 0 , -1};
    const int dy[] = {1 , 0 , -1 , 0};
    //#define MOD         1000000007LL
    #define MAX         1000005
    const ll MOD = 1000000000 + 7;
    ll mod(ll x)
    {
        return ((x % MOD) + MOD) % MOD;
    }
    
    ll add(ll a , ll b)
    {
        return mod(mod(a) + mod(b));
    }
    
    ll mul(ll a , ll b)
    {
        return mod(mod(a) * mod(b));
    }
    
    
    int main()
    {
        FAST
        int t;
        t = 1;

        while(t--)
        {
           int n ;
           cin >> n;
           
           vector<ll> arr(n + 5 , 0) , sum(n + 5 , 0);
           
           for(int i = 1 ; i <= n ; i++)
           {
               cin >> arr[i];
               sum[i] = arr[i];
           }
           
           for(int i = 1 ; i <= n ; i++)
           {
               sum[i] += sum[i - 1];
               sum[i] %= MOD;
           }
           
           ll s = 0;
           
           for(int i = 1 ; i < n  ; i++)
           {
               s = add(s , mul(arr[i] , sum[n] - sum[i]));
           }
           
           cout << s << endl;
        }
    }



Measured memory_bytes: 6328
#include<bits/stdc++.h>
using namespace std;
long long mod(long long a, long long n, long long x)
{
	long long y=a%x ,odd=1;
	while(n/2)
	{
		if(n&1)
			odd=(odd*y)%x;
		y=(y*y)%x;
		n/=2;
	}
	odd=(odd*y)%x;
	return odd;
}
int main()
{
	long long n;
	cin >> n;
	//cout << mod(22, 4, 4) << "\n";
	long long M=1000000007;
	long long all=mod(10, n, M);
	long long only9_0=mod(9, n, M);
	long long both=mod(8, n, M);
	//cout << all << "\n" << only9_0 << "\n" << both << "\n";
	all=(all- only9_0 + M)%M;
	all=(all- only9_0 + M)%M;
	cout << (all + both)%M;
	return 0;
}

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

int data;
char input1[15];
char input2[15];

void print_ans(int num);
int make(char data[]);

int main(void)
{
    int i, j, k;
    int num1, num2;
    scanf("%d",&data);
    for (k = 0; k < data; k++) {
        scanf("%s %s",input1, input2);
        num1 = make(input1);
        //printf("%d\n",num1);
        num2 = make(input2);
        //printf("%d\n",num2);
        print_ans(num1 + num2);
    }
    return 0;
}

int make(char data[]) 
{
    int i = 0, tmp = 1, ans = 0, len;
    len = strlen(data);
    while (i < len) {
        if ('0' <= data[i] && data[i] <= '9') {
            tmp = data[i] - '0';
            i++;
        } else if (data[i] == 'm') {
            ans += tmp * 1000;
            tmp = 1;
            i++;
        } else if (data[i] == 'c') {
            ans += tmp * 100;
            tmp = 1;
            i++;
        } else if (data[i] == 'x') {
            ans += tmp * 10;
            tmp = 1;
            i++;
        } else if (data[i] == 'i') {
            ans += tmp;
            tmp = 1;
            i++;
        }
    }
    return ans;
}

void print_ans(int num)
{
    int i, tmp, ket;
    while (num) {
        if (num >= 2000) {
            printf("%dm",num / 1000);
            num %= 1000;
        } else if (num >= 1000) {
            printf("m");
            num %= 1000;
        } else if (num >= 200) {
            printf("%dc",num / 100);
            num %= 100;
        } else if (num >= 100) {
            printf("c");
            num %= 100;
        } else if (num >= 20) {
            printf("%dx",num / 10);
            num %= 10;
        } else if (num >= 10) {
            printf("x");
            num %= 10;
        } else if (num >= 20) {
            printf("%dx",num / 10);
            num %= 10;
        } else if (num >= 10) {
            printf("x");
            num %= 10;
        } else if (num >= 2) {
            printf("%di",num / 1);
            num %= 1;
        } else if (num >= 1) {
            printf("i");
            num %= 1;
        }
    }
    puts("");
}
        

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

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

    vector<vector<ll>> dp(51, vector<ll>(2, 0));

    dp[0][0] = 1;

    for(int i = 0; i < n; i++){
        ll a;
        cin >> a;
        if(a % 2 == 0){
            dp[i+1][0] = 2*dp[i][0];
            dp[i+1][1] = 2*dp[i][1];
        }
        else{
            dp[i+1][0] = dp[i][1] + dp[i][0];
            dp[i+1][1] = dp[i][0] + dp[i][1];  
        }
    }
    cout << dp[n][p];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
long long int arr1[3000][3000];
long long int m=1e9 + 7;
long long int mult[3000][3000];
long long int mult1[3000][3000];
long long int dp[3000],dp1[3000];
void powe(long long int a,long long int B)
{
   if(a==1) return;
   long long int qwer[B][B];
   for (long long int i = 0; i < B; ++i)
   {
      for (long long int j = 0; j < B; ++j)
      {
        qwer[i][j]=arr1[i][j];
      }
   }
   powe(a/2,B);
   
   memset(mult,0,sizeof(mult));
   for(long long int i = 0; i < B; ++i)
        for(long long int j = 0; j < B; ++j)
            for(long long int k = 0; k < B; ++k)
            {
              long long int jkl=(arr1[i][k]%m * arr1[k][j]%m)%m;
                mult[i][j] = (mult[i][j]%m + jkl%m)%m;
            }
    for (long long int i = 0; i < B; ++i)
   {
      for (long long int j = 0; j < B; ++j)
      {
        arr1[i][j]=mult[i][j];
      }
   }        

    if(a%2==1)
    {
        
        memset(mult1,0,sizeof(mult1));
        for(long long int i = 0; i < B; ++i)
        for(long long int j = 0; j < B; ++j)
            for(long long int k = 0; k < B; ++k)
            {
              long long int jkl=(mult[i][k]%m * qwer[k][j]%m)%m;
                mult1[i][j] = (mult1[i][j]%m + jkl%m)%m;
            }
        for ( long long int i = 0; i < B; ++i)
   {
      for (long long int j = 0; j < B; ++j)
      {
        arr1[i][j]=mult1[i][j];
      }
   }

    }

}


int main()
{

    long long int n, k;
    cin >> n >> k;

    for (long long int i = 0; i < n; ++i)
    {
       for (long long int j = 0; j < n; ++j)
       {
          cin >> arr1[i][j];
       }
    }
    
    
    powe(k,n);

    long long int ans = 0;

    for (long long int i = 0; i < n; ++i)
    {
       for (long long int j = 0; j < n; ++j)
       {
          ans += arr1[i][j];
          ans %= m;
       }
    }

    cout << ans;
   
    return 0;
}


Measured memory_bytes: 144768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
int main(){
  ll n;
  cin >> n;
  ll a[n],b[n-1];
  ll sum=0;
  rep(i,n-1){
    cin >> b[i];
  }
  a[0] = b[0];
  a[n-1] = b[n-2];
  rep(i,n-2){
    a[i+1] = min(b[i],b[i+1]);
  }
  rep(i,n){
    sum += a[i];
  }
  cout << sum << endl;

}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	static class Vertex implements Comparable <Vertex> {
		int id, ticket, d0;
		Vertex(int vertex, int ticket, int d0){
			this.id = vertex;
			this.ticket=ticket;
			this.d0 = d0;
		}
//		public boolean equals(Object v) {
//			return this.id == ((Vertex)v).id;
//		}
		public int compareTo(Vertex v) {
			return this.d0 - v.d0;
		}
	}
	
	static int inf = 100000000;
	public static void main(String args[]){
		try(Scanner sc=new Scanner(System.in)){
			while(sc.hasNext()) {
				int c=sc.nextInt();//割引券枚数
				int n=sc.nextInt();//町数
				int m=sc.nextInt();//路線数
				int s=sc.nextInt();//出発地
				int d=sc.nextInt();//目的地
				if(c==0) break;
				int[][] f=new int[n+1][n+1];//料金
				int[][] t=new int[n+1][c+1];//頂点と残っている割引券
				
				for(int i=0; i<m; i++) {
					int a=sc.nextInt();
					int b=sc.nextInt();
					f[a][b]=f[b][a]=sc.nextInt();
				}
				
				for(int i=1; i<=n; i++) {
					for(int j=c; j>=0; j--) {
						t[i][j]=inf;
					}
				}
				t[s][c]=0;
				PriorityQueue<Vertex> pq=new PriorityQueue<Vertex>();
				Vertex[][] vs=new Vertex[n+1][c+1];
//				for(int i=1; i<=n; i++) {
//					for(int j=c; j>=0; j--) {
//						vs[i][j]=new Vertex(i,j, t[i][j]);
//						pq.add(vs[i][j]);
//					}
//				}
				pq.add(new Vertex(s, c, 0));
				
				Map<Integer, Integer> prev=new HashMap<>();
				prev.put(s, 0);
				while(!pq.isEmpty()) {
					Vertex u=pq.remove();
					if(prev.containsKey(u.id)) {
						int keymin=Math.min(prev.get(u.id), u.d0);
						prev.remove(u.id);
						prev.put(u.id, keymin);
					}
					else {
						prev.put(u.id, u.d0);
					}
					for(int i=1; i<=n; i++) {
						if(f[u.id][i]>0) {
							int alt=u.d0+f[u.id][i];
							if(t[i][u.ticket]>alt) {
								t[i][u.ticket]=alt;
								pq.add(new Vertex(i, u.ticket, alt));
							}

							if(u.ticket>0 && t[i][u.ticket-1] > u.d0+f[u.id][i]/2) {
								t[i][u.ticket-1]=u.d0+f[u.id][i]/2;
								pq.add(new Vertex(i, u.ticket-1, u.d0+f[u.id][i]/2));
							}
						}
					}
				}

				int min=inf;
//				for(int i=c; i>=0; i--){
//					min=Math.min(t[d][i], min);
//				}
//				System.out.println(min);
				System.out.println(prev.get(d));
				
			}
		}
	}
} 


Measured memory_bytes: 67652
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 500

struct Info{
	ll left,right;
};


ll min_dist[NUM][NUM];
ll year_sum[NUM];
int start_planet;
bool visited[NUM];
vector<int> G[NUM];
Info info[NUM];


int main(){

	int N;

	scanf("%d %d",&N,&start_planet);
	start_planet--;

	for(int i = 0; i < N; i++){
		scanf("%d %d",&info[i].left,&info[i].right);
	}

	for(int from = 0; from < N; from++){
		for(int to = 0; to < N; to++){
			scanf("%lld",&min_dist[from][to]);
		}
	}

	//全点対間最短経路を求める
	for(int mid = 0; mid < N; mid++){
		for(int start = 0; start < N; start++){
			for(int goal = 0; goal < N; goal++){
				min_dist[start][goal] = min(min_dist[start][goal],min_dist[start][mid]+min_dist[mid][goal]);
			}
		}
	}

	ll ans = 0;

	for(int i = 0; i < N; i++){
		if(info[i].right >= min_dist[start_planet][i]){
			year_sum[i] = info[i].right-max(info[i].left,min_dist[start_planet][i]);
			visited[i] = true;
		}else{
			visited[i] = false;
		}
	}

	for(int a = 0; a < N; a++){
		for(int i = 0; i < N; i++){
			for(int k = 0; k < N; k++){
				if(visited[i] == true && info[k].right >= info[i].right+min_dist[i][k]){
					year_sum[k] = max(year_sum[k],info[k].right-max(info[k].left,info[i].right+min_dist[i][k])+year_sum[i]);

					visited[k] = true;
					ans = max(ans,year_sum[k]);
				}
			}
		}
	}

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

	return 0;
}



Measured memory_bytes: 5204
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second  
#define endl '\n'
#define pb push_back
#define t_case ll tt; cin>>tt; while (tt--)
#define all(v) v.begin(),v.end()
#define ub(a,x) upper_bound(all(a),x)-a.begin()
#define lb(a,x) lower_bound(all(a),x)-a.begin()
#define fr(a,b,c) for (ll a=b;a<c;a++)
#define take(xx,n) for (int i=0;i<n;i++) cin>>xx[i];
#define take1(xx,n) for (int i=1;i<=n;i++) cin>>xx[i];
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);

int main() 
{
	fastio
	string a="AC",w="WA", t="TLE",r="RE";
	ll A=0,W=0,T=0,R=0; 
	t_case
	{
		ll n,m,q,f=1,d,k,x,y,sum=0,b  ; 
		string str; cin>>str;
		if (a==str) A++;
		else if (w==str) W++;
		else if (t==str) T++;
		else R++;
		//cout<<endl;
	}
	cout<<a<<" x "<<A<<endl;
	cout<<w<<" x "<<W<<endl;
	cout<<t<<" x "<<T<<endl;
	cout<<r<<" x "<<R<<endl;
	return 0;
}



Measured memory_bytes: 3656
#include<cstdio>
#include<algorithm>
using namespace std;

const int p=29;
long long ans;
long long has[100010],s2[15],cf[30];
char s[15];

int main()
{
	int n;
	scanf("%d",&n);
	cf[0]=1;
	for (int i=1; i<=10; i++) cf[i]=cf[i-1]*p;
	for (int i=1; i<=n; i++)
	{
		scanf("%s",s+1);
		for (int j=1; j<=10; j++) s2[j]=s[j]-'a'+1;
		sort(s2+1,s2+11);
		for (int j=1; j<=10; j++)
			has[i]+=cf[j]*s2[j];
	}
	sort(has+1,has+1+n);
	long long x=1;
	for (int i=1; i<n; i++)
		if (has[i]==has[i+1])
		{
			x++;
			if (i==n-1) ans+=x*(x-1)/2;
		}
		else ans+=x*(x-1)/2,x=1;
	printf("%lld",ans);
	return 0;
}

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

// 辺に重みがある場合
using Edge = pair<int, int>; // 辺の行き先と辺の重み
using Graph = vector<vector<Edge>>;

vector<int> color;

void dfs(const Graph &G, int v, int p, int cur) {
    color[v] = cur;
    for(auto e : G[v]) {
        int nv = e.first;
        int w = e.second;
        if(nv == p) continue; // nv が親 p だったらダメ
        
        if(w % 2) dfs(G, nv, v, 1-cur);
        else dfs(G, nv, v, cur);
    }
}

int main() {
    int N; cin >> N;
    
    Graph G(N);
    for(int i = 0; i < N-1; ++i) {
        int a, b, w; cin >> a >> b >> w;
        --a, --b;
        G[a].push_back(Edge(b, w));
        G[b].push_back(Edge(a, w));
    }
    
    color.assign(N, -1);
    dfs(G, 0, -1, 0);
    
    for(int v = 0; v < N; ++v) cout << color[v] << endl;
}


Measured memory_bytes: 9728
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int n,row;
vector<string> str;

int operand(int level) {
    int answer = 0;
    switch (str[row][level]) {
        case '+':
            row++,level++;
            answer = 0;
            while (row < n) {
                if (str[row].size() < level || str[row][level-1] != '.') break;
                answer += operand(level);
            }
            break;

        case '*':
            row++,level++;
            answer = 1;
            while (row < n) {
                if (str[row].size() < level || str[row][level-1] != '.') break;
                answer *= operand(level);
            }
            break;

        default: answer = stoi(str[row].substr(level)); row++;
    }
    return answer;
}

int main() {
    while (cin>>n && n != 0) {
        row = 0;
        str = vector<string>(n);
        for (int i = 0; i < n; i++) cin>>str[i];
        cout<<operand(0)<<endl;
    }
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll x, y;
    cin >> x >> y;

    REP(i, x+1) {
        ll j = x-i;
        if(i*2+j*4 == y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;
  pair<pair<int,int>, int> P1[M]{};
  rep(i,M){
    cin >> P1[i].first.first >> P1[i].first.second;
    P1[i].second = i;
  }
  sort(P1,P1+M);
  int A[M];
  P p[M];
  A[0] = 1;
  p[P1[0].second] = P(P1[0].first.first, A[0]);
  for(int i=1;i<M;i++){
    int w = P1[i].second;
    if(P1[i-1].first.first == P1[i].first.first){
      A[i] = A[i-1] + 1;
    }
    else{
      A[i] = 1;
    }
    p[w] = P(P1[i].first.first, A[i]);
  }
  rep(i,M){
    int keta = 0, Q;
    Q = p[i].first;
    while(Q>0){
      keta++;
      Q /= 10;
    }
    rep(i,6-keta){
      cout << '0';
    }
    cout << p[i].first;
    keta = 0;
    Q = p[i].second;
    while(Q>0){
      keta++;
      Q/=10;
    }
    rep(i,6-keta){
      cout << '0';
    }
    cout << p[i].second << endl;
  }
}

Measured memory_bytes: 6780
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }
inline int safe_mul(const int x, const int y) __attribute__ ((warn_unused_result));


int main() {
//    freopen("in.txt","r", stdin);
//    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int n;
    cin >> n;
    vector<long long> a(n);
    for (auto& x : a)
        cin >> x;

    auto sum = accumulate(begin(a), end(a), 0LL);
    long long ans = sum*2;
    long long pre = 0;
    for (auto x : a) {
        pre += x;
        ans = min(ans, abs(sum - 2*pre));
    }
    cout << ans << endl;
}


Measured memory_bytes: 1920
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	boolean check(TreeSet<int[]> C, int[] S) {
		int[] Sl = C.lower(S);
		if (Sl != null && Sl[1] < S[1]) {
			return true;
		} else {
			return false;
		}
	}

	@SuppressWarnings("unchecked")
	void solve(int N, int[][] S) {
		TreeSet<int[]>[] C = new TreeSet[N];
		for (int i = 0; i < N; ++i) {
			C[i] = new TreeSet<>(new Comparator<int[]>() {
				@Override
				public int compare(int[] o1, int[] o2) {
					if (o1[0] != o2[0]) {
						return Integer.compare(o1[0], o2[0]);
					} else {
						return -Integer.compare(o1[1], o2[1]);
					}
				}
			});
		}
		C[0].add(S[0]);
		int maxLen = 1;
		for (int i = 1; i < N; ++i) {
			int left = -1;
			int right = maxLen;
			while (right - left > 1) {
				int middle = (right + left) / 2;
				if (check(C[middle], S[i])) {
					left = middle;
				} else {
					right = middle;
				}
			}

			if (left + 1 == maxLen) {
				C[left + 1].add(S[i]);
				++maxLen;
				continue;
			} else {
				int[] tmp = C[left + 1].floor(S[i]);
				if (tmp != null && tmp[1] == S[i][1])
					continue;
				tmp = C[left + 1].higher(S[i]);
				while (tmp != null && S[i][1] <= tmp[1]) {
					C[left + 1].remove(tmp);
					tmp = C[left + 1].higher(S[i]);
				}
				C[left + 1].add(S[i]);
			}
		}
		System.out.println(maxLen);
	}

	int nextA(int a, int M) {
		return 36969 * (a & M) + (a >> 16);
	}

	int nextB(int b, int M) {
		return 18000 * (b & M) + (b >> 16);
	}

	int nextVal(int a, int b, int C) {
		return (C & ((a << 16) + b)) % 1000000;
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int m = sc.nextInt();
			int n = sc.nextInt();
			int A = sc.nextInt();
			int B = sc.nextInt();
			if (m == 0 && n == 0 && A == 0 && B == 0)
				break;
			int[][] S = new int[m + n][3];
			for (int i = 0; i < m; ++i) {
				S[i][0] = sc.nextInt();
				S[i][1] = sc.nextInt();
				S[i][2] = sc.nextInt();
			}
			int a = A, b = B, C = ~(1 << 31), M = (1 << 16) - 1;
			for (int i = 0; i < n; ++i) {
				for (int j = 0; j < 3; ++j) {
					a = nextA(a, M);
					b = nextB(b, M);
					S[i + m][j] = nextVal(a, b, C);
				}
			}
			Arrays.sort(S, new Comparator<int[]>() {
				@Override
				public int compare(int[] o1, int[] o2) {
					if (o1[0] != o2[0])
						return Integer.compare(o1[0], o2[0]);
					else if (o1[1] != o2[1]) {
						return -Integer.compare(o1[1], o2[1]);
					} else {
						return -Integer.compare(o1[2], o2[2]);
					}
				}
			});

			int[][] tmp = new int[m + n][2];
			for (int i = 0; i < m + n; ++i) {
				tmp[i][0] = S[i][1];
				tmp[i][1] = S[i][2];
			}
			solve(m + n, tmp);
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 491124
#include<bits/stdc++.h> 
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ll long long
#define fi first
#define se second
#define PB push_back
#define uint unsigned
#define ull unsigned ll 
using namespace std;
const int N=100005;
char s[N];
int n,cnt[N],x[N],y[N];
int SA[N],rk[N],hei[N];
bool cmp(int i,int j,int k,int n){
	return y[i]!=y[j]||((i+k<=n?y[i+k]:-1)!=(j+k<=n?y[j+k]:-1));
}
void build_SA(int n){
	int m=26;
	For(i,0,m) cnt[i]=0;
	For(i,1,n) cnt[x[i]=s[i]-'a'+1]++;
	For(i,1,m) cnt[i]+=cnt[i-1];
	Rep(i,n,1) SA[cnt[x[i]]--]=i;
	for (int k=1;k<n;k<<=1){
		int p=0;
		For(i,n-k+1,n) y[++p]=i;
		For(i,1,n) if (SA[i]>k) y[++p]=SA[i]-k;
		For(i,0,m) cnt[i]=0;
		For(i,1,n) cnt[x[i]]++;
		For(i,1,m) cnt[i]+=cnt[i-1];
		Rep(i,n,1) SA[cnt[x[y[i]]]--]=y[i];
		swap(x,y); m=x[SA[1]]=1;
		For(i,2,n) x[SA[i]]=(m+=(cmp(SA[i],SA[i-1],k,n)));
		if (m==n) break;
	}
}
int K;
int main(){
	scanf("%d%d%s",&n,&K,s+1);
	For(T,1,min(K,20)){
		if (T!=1) reverse(s+1,s+n+1);
		For(i,1,n) s[n+i]=s[n-i+1];
		build_SA(2*n);
		For(i,1,n) if (SA[i]<=n+1){
			int d=SA[i]-1;
			For(j,1,n) s[j]=s[j+d];
			break;
		}
	}
	For(i,1,n)
		putchar(s[i]); 
}
/*
eeaee
aaeee
aaaae

eeaeeeeaee
eeeeaaeeee
eeeaaaaeee
eaaaaaaaae

*/

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

int main(){
	int N, A, B, temp;
  
  	cin >> N >> A >> B;
  
  	temp = N * A;
  
  	if(temp >= B)	cout << B << endl;
  	else	cout << temp << endl;
  
  	return 0;
}

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;
typedef pair<int,int>P;

const int MOD=1000000007;
//~ const int MOD=998244353;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	int a,b,c,d,K;cin>>a>>b>>c>>d>>K;
	int x=a*60+b,y=c*60+d;
	cout<<max(0,(y-x)-K)<<endl;
}

Measured memory_bytes: 3588
#include <math.h>
#include <stdio.h>
#define sqr(x) ((x)*(x))

int main(void)
{
  int n, d;
  int x[10][10];
  int i, j, k;
  int sum, cnt = 0;
  
  scanf("%d %d", &n, &d);
  
  for (i = 0; i < n; i++)
    for (j = 0; j < d; j++)
      scanf("%d", &x[i][j]);
  
  for (i = 0; i < n-1; i++)
    for (j = i+1; j < n; j++) {
      sum = 0;
      for (k = 0; k < d; k++)
        sum += sqr(x[i][k] - x[j][k]);
      
      if (sum == sqr(lround(sqrt(sum))))
        cnt++;
    }
  
  printf("%d", cnt);
  
  return 0;
}


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

using namespace std;
int main()
{
	int n,k;
  	cin>>n>>k;
  	vector<int> arr;
  	for(int i{0};i<n;i++)
    {
    	int a;
      	cin>>a;
      	arr.push_back(a);
     }
	sort(arr.begin(),arr.end());
  	int count{0};
  	for(int i{0};i<k;i++)
    {
    	count=count+arr.at(i);
    }
  	cout<<count;
}

Measured memory_bytes: 3632
from math import log2, ceil
N, K = map(int, input().split())
ans = 0
for i in range(1, N+1):
    if i >= K:
        ans += (1/N)
    else:
        p = K / i
        ans += (1/N)*(1/2)**(ceil(log2(p)))
print(ans)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n,var[4],chs[100100],bck[100100][4];
string str[100100];
void bao(int id){
	if(id==n+1){
		cout<<"Yes"<<endl;
		for(int i=1;i<=n;i++) cout<<(char)(chs[i]+'A'-1)<<endl;
		exit(0);
	}
	int x=str[id][0]-'A'+1;
	int y=str[id][1]-'A'+1;
	if(var[x]>=bck[id][x]){
		var[x]--;
		var[y]++;
		chs[id]=y;
		bao(id+1);
		var[y]--;
		var[x]++;
		return;
	}
	if(var[y]>=bck[id][y]){
		var[y]--;
		var[x]++;
		chs[id]=x;
		bao(id+1);
		var[x]--;
		var[y]++;
		return;
	}
	if(var[x]){
		var[x]--;
		var[y]++;
		chs[id]=y;
		bao(id+1);
		var[y]--;
		var[x]++;
	}
	if(var[y]){
		var[y]--;
		var[x]++;
		chs[id]=x;
		bao(id+1);
		var[x]--;
		var[y]++;
	}
}
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>var[1]>>var[2]>>var[3];
	for(int i=1;i<=n;i++){
		cin>>str[i];
	}
	int xx,yy;
	for(int i=n;i>=1;i--){
		xx=str[i][0]-'A'+1;
		yy=str[i][1]-'A'+1;
		bck[i][1]=bck[i+1][1];
		bck[i][2]=bck[i+1][2];
		bck[i][3]=bck[i+1][3];
		bck[i][xx]++;
		bck[i][yy]++;
	}
	bao(1);
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 16552
#include<stdio.h>
int MAX(int a,int b){return a<b?b:a;}
int main(){
  int n,m,i,t,r,q[410],c[410]={0};
  int d[410][410]={0};
  int a[410]={0};
  scanf("%d %d",&n,&m);
  while(m--){
    scanf("%d %d %d",&t,&r,&i);
    d[t][r]=i;
    c[r]++;
  }
  q[t=0]=0;
  for(r=1;t-r;t++){
    for(i=0;i<n;i++){
      if(d[q[t]][i]==0)continue;
      c[i]--;
      a[i]=MAX(a[i],a[q[t]]+d[q[t]][i]);
      if(c[i]==0)q[r++]=i;
    }
  }
  printf("%d\n",a[n-1]);
  return 0;
}
 

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

signed main() {
  int H, W;
  cin >> H >> W;
  
  vector<vector<char>> C(52, vector<char>(52));
  for( int i = 1; i <= H; i++ ){
    for( int j = 1; j <= W; j++ ){
      cin >> C.at(i).at(j);
    }
  }
  
  for( int i = 1; i <= H; i++ ){
    for( int j = 1; j <= W; j++ ){
      if( C.at(i).at(j) == '#' ){
        if( C.at(i-1).at(j) != '#' && C.at(i+1).at(j) != '#' && C.at(i).at(j-1) != '#' && C.at(i).at(j+1) != '#' ){
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
}

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

int main() {
	int x, y, z,n,k;
	string s;
	cin >>n>>k>> x >> y>>z;
	if(n>=k)cout << k*x + (n - k)*y << endl;
	else cout << x*n << endl;
	return 0;
}

Measured memory_bytes: 256
# AOJ ITP2_8_D: Multi-Map
# Python3 2018.6.24 bal4u

from bisect import bisect_left, bisect_right, insort_left
dict = {}
keytbl = []
q = int(input())
for i in range(q):
	a = list(input().split())
	ki = a[1]
	if a[0] == '0':
		if ki not in dict:
			dict[ki] = []
			insort_left(keytbl, ki)
		dict[ki].append(int(a[2]))
	elif a[0] == '1':
		if ki in dict and dict[ki] != []: print(*dict[ki], sep='\n')
	elif a[0] == '2':
		if ki in dict: dict[ki] = []
	else:
		L = bisect_left (keytbl, a[1])
		R = bisect_right(keytbl, a[2], L)
		for j in range(L, R):
			for k in dict[keytbl[j]]: print(keytbl[j], k)


Measured memory_bytes: 39200
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <typeinfo>
#include <cmath>
#include <numeric>
using namespace std;


int main()
{
    int k;
    bool CanComm = true;
    std::vector<int> A(5);
    for (int i = 0; i < 5; ++i)
    {
        std::cin >> A[i];
    }
    std::cin >> k;
    for (int i = 0; i < 5; ++i)
    {
        for (int j = 0; j < 5; ++j)
        {
            if(abs(A[i] - A[j]) > k) CanComm = false;
        }
    }
    // std::cout << CanComm << "\n";
    if (CanComm == false)
    {
        std::cout << ":(" << "\n";
    }else{
        std::cout << "Yay!" << "\n";
    }
}

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

#define L_MAX (21+9)

void make_flag(int W, int H, char *flag)
{
	int i,j;

	*flag = '+';
	*(flag + W - 1) = '+';
	for (i = 1; i < W-1; i++)
	{
		*(flag + i) = '-';
		*(flag + L_MAX * (H - 1) + i) = '-';
	}

	flag = flag + L_MAX;
	for (i = 1; i < H - 1; i++)
	{
		*flag = '|';
		*(flag + W - 1)='|';

		for (j = 1; j < W - 1; j++)
		{
			*(flag + j) = '.';
		}
		flag = flag + L_MAX;
	}
	*flag = '+';
	*(flag + W - 1) = '+';


}

int main(void)
{


	int W, H;
	char c;

	char flag[L_MAX][L_MAX];

	int i,j;

	cin >> W >> H >> c;

	make_flag(W, H, &flag[0][0]);
	flag[H / 2][W / 2] = c;

	for (i = 0; i < H; i++)
	{
		for (j = 0; j < W; j++)
		{
			cout << flag[i][j];
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3068
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 300005;
#define endl '\n'
#define int ll
#define ld long double
#define all(x) (x).begin(),(x).end()

int32_t main()
{ 
  IOS
  
  int n;
  cin>>n;
  ld pr = 1.0;
  ld a[n];
  for(int i = 0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  for(int i =0 ;i<n;i++){
     pr*=a[i];
    if(pr>(ld)(1e18)){
      cout<<-1<<endl;
      return 0;
    }
  }
  cout<<(ll)pr<<endl;


  
  

}
 

Measured memory_bytes: 5316
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n = list(input())
    if '7' in n:
        print('Yes')
    else:
        print('No')
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 72872
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n;
string s;
map<string, int> ma;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) {
        cin >> s;
        ma[s]++;
    }
    cout << SZ(ma);
    return 0;
}


Measured memory_bytes: 19236
@buffer = ""
def swap(i, j)
  @buffer[i], @buffer[j] = @buffer[j], @buffer[i]
end
def cursor
  @buffer.index("^")
end

def forwardChar
  swap(cursor, cursor+1) unless cursor == @buffer.size-1
end
def forwardWord
  while cursor < @buffer.size-1 && @buffer[cursor+1] == " " do
    swap(cursor, cursor+1)
  end
  while cursor < @buffer.size-1 && @buffer[cursor+1] != " "
    swap(cursor, cursor+1)
  end
end
def backwardChar
  swap(cursor, cursor-1) unless cursor == 0
end
def backwardWord
  while cursor > 0 && @buffer[cursor-1] == " " do
    swap(cursor, cursor-1)
  end
  while cursor > 0 && @buffer[cursor-1] != " "
    swap(cursor, cursor-1)
  end
end
def insert(text)
  @buffer.insert(cursor, text)
end
def deleteChar
  @buffer.slice!(cursor+1) if @buffer[cursor+1]
end
def deleteWord
  return if @buffer[cursor+1, @buffer.size-cursor-1] !~ /[^ ]/
  while cursor < @buffer.size-1 && @buffer[cursor+1] == " " do
    deleteChar
  end
  while cursor < @buffer.size-1 && @buffer[cursor+1] != " " do
    deleteChar
  end
end

gets.to_i.times do
  @buffer = "^"+gets.chomp
  gets.to_i.times do
    case gets.chomp
      when "forward char"
        forwardChar
      when "forward word"
        forwardWord
      when "backward char"
        backwardChar
      when "backward word"
        backwardWord
      when "delete char"
        deleteChar
      when "delete word"
        deleteWord
      when /insert "(.*)"/
        insert($1)
    end
  end
  puts @buffer
end

Measured memory_bytes: 6132
#include<iostream>

using namespace std;

int data[2][1500]={0};

int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>data[0][i];
	}
	for(int i=0;i<m;i++){
		int x;
		cin>>x;
		for(int j=0;j<n;j++){
			if(x>=data[0][j]){
				data[1][j]++;
				break;
			}
		}
	}
	int ma=0;
	int ans=0;
	for(int i=0;i<n;i++){
		if(data[1][i]>ma){
			ma=data[1][i];
			ans=i;
		}
	}
	cout<<ans+1<<endl;
}

Measured memory_bytes: 1168
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
  
int main() {
	// 入力
	ll N;cin>>N;
    double x[N], y[N];REP(i,N)cin>>x[i]>>y[i];
    
	// 解法
    double ans = 0;
    ll devide = 10000;
    REP(i,devide){
        double tmp_x = cos(2 * M_PI * i / devide);
        double tmp_y = sin(2 * M_PI * i / devide);
        double v_x, v_y;v_x=0;v_y=0;
        // printf("%f, %f\n", tmp_x, tmp_y);
        REP(i,N){
            double naiseki = tmp_x*x[i] + tmp_y*y[i];
            if (naiseki>0){
                v_x += x[i];
                v_y += y[i];
            }
        }
        double dist_tmp = v_x*v_x + v_y*v_y;
        if (dist_tmp>ans) ans = dist_tmp;
    }
    ans = pow(ans, 0.5);
	//出力
    printf("%.20f\n", ans);
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
string str[100];
int h,w;
int num;
bool flag;
bool used[100][100];
char moji[100];
int vx[4]={1,0,-1,0};
int vy[4]={0,1,0,-1};
void dfs(int Bit,int depth){
  if(Bit==((1<<num)-1)){
    flag=true;
    return;
  }
  for(int i=0;i<num;i++){
    if(!(Bit&(1<<i))){
      bool used2[100][100]={};
      int lemi=100,lema=0,rimi=100,rima=0;
      for(int j=0;j<h;j++){
	for(int k=0;k<w;k++){
	  if(str[j][k]==moji[i]){
	    used2[j][k]=true;
	    used[j][k]=true;
	    lemi=min(lemi,k);
	    lema=max(lema,k);
	    rima=max(rima,j);
	    rimi=min(rimi,j);
	  }
	}
      }
      bool fll=true;
      for(int j=rimi;j<=rima;j++){
	for(int k=lemi;k<=lema;k++){
	  if(!used[j][k]){
	    fll=false;
	  }
	}
      }
      if(fll)
	dfs(Bit+(1<<i),depth+1);
      for(int j=rimi;j<=rima;j++){
	for(int k=lemi;k<=lema;k++){
	  if(used2[j][k]){
	    used[j][k]=false;
	  }
	}
      }
    }
  }
}
int main(){
  int n;cin>>n;
  for(int i=0;i<n;i++){
    cin>>h>>w;
    num=0;
    for(int i=0;i<55;i++)
      for(int j=0;j<55;j++)
	used[i][j]=false;
    flag=false;
    bool alfa[26]={};
    for(int i=0;i<h;i++){
      cin>>str[i];
      for(int j=0;j<w;j++){
	alfa[str[i][j]-'A']=true;
      }
    }
    int cnt=0;
    for(int i=0;i<26;i++){
      if(alfa[i]){
	num++;
	moji[cnt]=((char)(i+'A'));
	cnt++;
      }
    }
    dfs(0,0);
    if(flag)
      cout<<"SAFE"<<endl;
    else 
      cout<<"SUSPICIOUS"<<endl;
  }
  return 0;
}



Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9)+7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
  vector< pair<ll, ll> > p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    p.push_back(make_pair(i, 0));
    while ((n % i) == 0) {
      n /= i;
      p[i].second += 1;
    }
    p.push_back(make_pair(n, 0));
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
	ll b = MOD, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0) { u += MOD; }
	return u;
}
// 順列
ll permutation(const ll n, const ll m) {
	ll result = 1;
	for (ll i = n; i > n - m; i--) { result = (result * i) % MOD; }
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
	if (x == 0) return 1;
	ll res = repeat_square(n, x/2);
	res = res * res % MOD;
	if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ
ll combination(const ll n, const ll a) {
	ll x = 1, y = 1;
  for(ll i = 0; i < a; i++){
    x = x * (n-i) % MOD;
    y = y * (i+1) % MOD;
  }
  return x * repeat_square(y, MOD-2) % MOD;
}

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

	while(true) {
		C -= B;
		if (C < 1) {
			cout << "Yes" << endl;
			return 0;
		}
		A -= D;
		if (A < 1) {
			cout << "No" << endl;
			return 0;
		}
	}
  return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int R = sc.nextInt();
		int S = sc.nextInt();
		int P = sc.nextInt();
		String T = sc.next();
		long ans = 0;
		Main main = new Main();
		char pastHand = ' ';

		for (int i = 0; i < K; i++) {
			for (int j = i; j < N; j=j+K) {
				char hand = T.charAt(j);
				int let = main.DP(hand, pastHand, R, S, P);
				if (let == 0) {
					pastHand = ' ';
				}else {
					pastHand = hand;
				}
				ans += let;
			}
			pastHand = ' ';
		}

		System.out.println(ans);

	}

	public int DP(char hand,char pastHand,int r,int s,int p) {
		if (hand == pastHand) {
			return 0;
		}
		if (hand == 'r') {
			return p;
		}
		if (hand == 's') {
			return r;
		}
		if (hand == 'p') {
			return s;
		}
		return 0;
	}
}

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

int main() {
    int k=0;
    string a,b;
    cin>>a>>b;
    for(int i=0;i<a.size();i++){ ///string length
        if(a[i]!=b[i]) k++;
    }
    cout<<k;
    return 0;
}

Measured memory_bytes: 3840
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <utility>
#include <string>
#include <vector>
#include <limits>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

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

    if(abs(a - b) % 2 == 0)
        cout << "Alice" << endl;
    else
        cout << "Borys" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define popb(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  int n,a[105]={},mi=1e9,ma=-1;
  cin>>n;
  rep(i,0,n){
    cin>>a[i];
    mi=min(mi,a[i]);
    ma=max(ma,a[i]);
  }
  cout<<ma-mi<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.*;
import java.lang.*; 
import java.util.regex.Pattern;
import java.text.DecimalFormat;
import java.util.stream.IntStream;
public class Main{ 
static int isOn(int S, int j) { return S & (1 << j); }
static int a,b,c;
static int[] dp=new int[4010];
static final int INF=1000000;
static boolean[] prime=new boolean[1000100]; 
public static void main(String[] args)
{ 
Scanner scanner=new Scanner(System.in);
int r=scanner.nextInt();
int D=scanner.nextInt();
int x=scanner.nextInt();
for(int i=0;i<10;i++){
x=r*x-D;
System.out.println(x);}
}
}


Measured memory_bytes: 23888
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {

		Scanner scanner=new Scanner(System.in);

		int n=scanner.nextInt();
		Map<String,Integer> data= new TreeMap<String,Integer>();
		
		for(int i=0;i<n;i++) {
			
			String buf=scanner.next();
			
			if(!data.containsKey(buf)) {
			
				data.put(buf,1);
			}else {
				data.put(buf,data.get(buf)+1);
			}
		}
		
		int m=scanner.nextInt();
		
		for(int i=0;i<m;i++) {
			
			String buf=scanner.next();
			
			if(data.containsKey(buf)) {
				data.put(buf,data.get(buf)-1);
			}
		}
		
		int max=-1;
		
		for(String key:data.keySet()) {
			
			int buf=data.get(key);
			
			if(max<buf) {
				max=buf;
			}
			
		}
		
		
		if(max>0) {
			System.out.println(max);
		}else {
			System.out.println("0");
		}
		scanner.close();

	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<ctime>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<bitset>
#define ll long long 
#define ull unsigned long long 
#define mem(a) memset(a,0,sizeof(a))
#define rint register int 
#define rll register long long 
#define rull register unsigned long long 
#define rchar register char
#define rstring register string 
#define rfloat register float
#define rdouble register double 
#define fio ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define For(i,a,b) for(int i=a;i<b;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define cFor(i,a,b) for(int i=a;i>b;i--)
#define cFOR(i,a,b) for(int i=a;i>=b;i--)
#define lFor(i,a,b) for(ll i=a;i<b;i++)
#define lFOR(i,a,b) for(ll i=a;i<=b;i++)
#define lcFor(i,a,b) for(ll i=a;i>b;i--)
#define lcFOR(i,a,b) for(ll i=a;i>=b;i--)
using namespace std;
int main(){
	double h,w,n;
	cin>>h>>w>>n;
	cout<<ceil(n/max(h,w))<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int count = 0, i;
  char top[4];
  
  scanf("%s", top);
  
  for(i = 0; i < 3; i++){
    if(top[i] == 'o'){
      count++;
    }
  }
  
  printf("%d\n", 700 + 100*count);
  
  return 0;
}

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

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < a.size(); i++){
        cin >> a[i];
    }
    sort(&a[0], &a[n]);
    cout << a[n/2] - a[n/2 - 1] << endl;
    return 0;
}

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

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define lld long long int

int main(){
    int x;
    scanf("%d", &x);
    int f=0;
    for(int i=x; i>1; i--){
        f=0;
        for(int j=2; j*j<=i; j++){
            int y = i;
            while(y>0 && y%j==0){
                y = y/j;
            }
            if(y==1){
                f=1;
                break;
            }
        }
        if(f){
            printf("%d", i);
            break;
        }
    }
    if(f==0){
        printf("1");
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;
using std::lower_bound;
using std::upper_bound;
using std::find_if;
using std::copy;
using std::copy_if;

int n;
vector<int> p;

int main(){
    cin >> n;
    p.push_back(0);
    for(int i=0;i<n;i++){
        int _p;
        cin >> _p;
        p.push_back(_p);
    }

    for(int i=1;i<n;i++){
        if(p[i]==i){
            int x=p[i];
            p[i]=p[i+1];
            p[i+1]=x;
            p[0]++;
        }
    }

    if(p[n]==n){
        p[0]++;
    }

    cout << p[0] << endl;
    return 0;
}



Measured memory_bytes: 892