akhauriyash/Code-Regression huggingface dataset:
#c
N,Q = map(int,input().split())
S=input()

old=S[0]
cnt=0
rui = [0]*N
for i in range(1,N):
    now = S[i]
    if old=="A" and now=="C":
        cnt+=1
    old=now
    rui[i]=cnt    

for i in range(Q):
    l,r = map(int,input().split())
    print(rui[r-1]-rui[l-1])

Measured memory_bytes: 77256
/* # */

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <deque>
#include <map>
#include <iomanip>
#include <functional>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cstring>
//#pragma warning(disable:4996)

using namespace std;


/** Type Define **/
typedef long long int           ll;
typedef pair<int, int>          pii;
typedef pair<ll, ll>            pll;
typedef vector<string>          vs;
typedef vector<bool>            vb;
typedef vector<int>             vi;
typedef vector<long long>		vl;
typedef vector<vi>              vvi;
typedef vector<vl>				vvl;
typedef vector<char>            vch;
#define		it(x)  x.begin() 
#define		all(x)  x.begin(), x.end()
#define		pb(x)   push_back(x)
constexpr int           inf = 0x3f3f3f3f;
constexpr long long 	INF = 9123456789123456789;
constexpr long long     MOD = 1000000007LL;
/*************************************************/
void sol() {
    string s, t;
    cin >> s >> t;
    int cnt(0), len(s.length());
    for (int i = 0; i < len; i++)
        if (s[i] != t[i]) cnt++;
    cout << cnt << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cin.tie(nullptr);
    int T(1);
    while (T--)
        sol();


    return 0;
}

Measured memory_bytes: 3788
l = list(map(int,input().split()))
A = l[0];
B = l[1];

if(A%B == 0):
    print(-1)
else:
    xa = A*2;

    while ((xa%B == 0) and (xa < 10**18)):
        xa += A;

    if(xa > 10**18):
        print(-1);
    else:
        print(xa);

Measured memory_bytes: 3060
/* #                          */

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <deque>
#include <map>
#include <iomanip>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cstring>
//#pragma warning(disable:4996)

using namespace std;


/** Type Define **/
typedef long long int           ll;
typedef pair<int, int>          pii;
typedef pair<ll, ll>            pll;
typedef vector<string>          vs;
typedef vector<bool>            vb;
typedef vector<int>             vi;
typedef vector<long long>		vl;
typedef vector<vi>              vvi;
typedef vector<vl>				vvl;
typedef vector<char>            vch;
#define		it(x)  x.begin() 
#define		all(x)  x.begin(), x.end()
#define		pb(x)   push_back(x)
constexpr int           inf = 0x3f3f3f3f;
constexpr long long 	INF = 9123456789123456789;
constexpr long long     MOD = 1000000007LL;
/*************************************************/
int N;

void sol() {

}

int main() {
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cin.tie(nullptr);
    cin >> N;

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

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define rep(i,x) for(int (i)=1;(i)<=(x);(i)++)
#define repp(i,x,y) for(int (i)=(x);(i)<=(y);(i)++)
#define forn(i,x) for(int (i)=0;(i)<(x);(i)++)
#define foreach(i,x) for(auto (i):(x))
using namespace std;
typedef pair<int,int>pii;
int n,ans;
int a[200010];
int main(){
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	int ans=0;
	for(int h=(1<<30);h>0;h>>=1){
		for(int i=0,j=n-1;i<j;i++){
			if(a[i]!=-1){
				while(j>i&&(a[j]==-1||a[i]+a[j]>h))j--;
				if(j>i&&a[j]!=-1&&a[i]+a[j]==h)ans++,a[i]=a[j]=-1;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int
pos(char c, char *s)
{
	int i;

	for (i = 0; s[i] != '\0'; i++)
		if (c == s[i])
			break;

	return i;
}

#define SUITE_NUM 4
#define CARD_NUM 13

int
main(void)
{
	int i, j, n, p, x;
	char s[4];
	int a[SUITE_NUM+1][CARD_NUM+1] = {};
	char name[] = "SHCD";

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%s %d", s, &x);
		p = pos(s[0], name);
		a[p][x] = 1;
	}

	for (i = 0; i < SUITE_NUM; i++)
		for (j = 1; j <= CARD_NUM; j++)
			if (!a[i][j])
				printf("%c %d\n", name[i], j);

	return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
const int MOD = 1e9 + 7;

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	//GRID number of paths
	int m, n;
	cin >> m >> n;
	vector<vector<char>> grid(m, vector<char> (n)) ;
	for (int i = 0; i < m; i++)
		for (int j = 0; j < n; j++)
			cin >> grid[i][j];

	vector<vector<long long>> dp(m, vector<long long> (n, 0));
	dp[0][0] = 1;
	for (int i = 0; i < m; i++)
		for (int j = 0; j < n; j++)
			if (grid[i][j] != '#') {
				if (i > 0) dp[i][j] = dp[i][j] % MOD + dp[i - 1][j] % MOD;
				if (j > 0) dp[i][j] = dp[i][j] % MOD + dp[i][j - 1] % MOD;
			}

	cout << (dp[m - 1][n - 1] % MOD	) << endl;
}

Measured memory_bytes: 12140
import java.io.PrintWriter;
import java.util.*;

public class Main {
    PrintWriter out = new PrintWriter(System.out);
    final long mod = 1000000000 + 7;

    public static void main(String[] args) {
        Main main = new Main();
        System.out.println(main.solve());
    }

    long solve() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        TreeMap<Integer, Integer> tree = new TreeMap<>();
        for(int i=0;i<n;i++){
            int a = sc.nextInt();
            Integer key = tree.lowerKey(a);
            if(key!=null) deleteFrom(tree,key);
            addTo(tree, a);
        }
        long ans = 0;
        for(Map.Entry<Integer,Integer> e: tree.entrySet()){
            ans += e.getValue();
        }
        return ans;
    }
    void addTo(TreeMap<Integer,Integer> map, int x){
        Integer val = map.get(x);
        if(val==null){
            map.put(x,1);
        } else{
            map.put(x,val+1);
        }
    }
    void deleteFrom(TreeMap<Integer, Integer> map, int x){
        Integer val = map.get(x);
        if(val==null) return;
        if(val==1) map.remove(x);
        else map.put(x,val-1);
    }
}


Measured memory_bytes: 64820
n,k,c=map(int,input().split())
s=input()
x,y=[0]*n,[0]*n
work1,work2=[],[]
last=-10**9;cnt=0
for i in range(n):
    if s[i]=="o" and i-last>c:
        cnt+=1
        last=i
        work1.append(i)
    if cnt==k: break

nextw=10**9;cnt=0
for i in range(n-1,-1,-1):
    if s[i]=="o" and nextw-i>c:
        work2.append(i)
        cnt+=1
        nextw=i
    if cnt==k: break

work2.reverse()
for i in range(k):
    if work1[i]==work2[i]: print(work1[i]+1)

Measured memory_bytes: 61216
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>

using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main(){
  int a[3][3];
  int d[3][3] = {0};
  int n;
  vector<int> b;

  REP(i, 3) {
    REP(j, 3) {
      cin >> a[i][j];
    }
  }

  cin >> n;

  REP(i, n) {
    int val; cin >> val;
    REP(j, 3) {
      REP(k, 3){
        if (a[j][k] == val) {
          d[j][k] = 1;
        }
      }
    }
  }

  bool ans = false;
  int cnt = 0;

  REP(i, 3) {
    cnt = 0;
    REP(j, 3) {
      cnt += d[i][j];
      if (cnt == 3) ans = true;
    }
  }

  REP(i, 3) {
    cnt = 0;
    REP(j, 3) {
      cnt += d[j][i];
      if (cnt == 3) ans = true;
    }
  }

  cnt = 0;
  REP(i, 3) {
    cnt += d[i][i];
    if (cnt == 3) ans = true;
  }

  cnt = 0;
  REP(i, 3) {
    cnt += d[i][2 - i];
    if (cnt == 3) ans = true;
  }

  cout << ( ans ? "Yes" : "No" ) << endl;

  return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string n;
    cin >> n;
    if(n[0]=='9'||n[1]=='9')cout << "Yes" << "\n";
    else cout << "No" << "\n";

    return 0;
}

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

#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define endl "\n" 
#define all(c) c.begin(),c.end()
#define present(c,element) (c.find(element)!=c.end())
#define cpresent(c,element) (find(c,element)!=c.end())
typedef vector<int> vi;
typedef vector<ll> vll;
ll mod=1e9+7;


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

int test=1;
//cin>>test;
while(test--)
{

	int n,k,d,a;
	cin>>n>>k;
	int s[n]={0};
	for(int i=0;i<k;i++)
	{
		cin>>d;
		for(int j=0;j<d;j++)
		{
			cin>>a;
			a--;
			s[a]++;
		}
	}
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]==0)cnt++;
	}
	cout<<cnt;
	
}
return 0;
}









Measured memory_bytes: 3608
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    if (solve(N)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }

  public static boolean solve(int N) {
    int a = N % 4;
    switch (a) {
      case 0:
        return true;
      case 1:
        return N >= 21;
      case 2:
        return N >= 14;
      case 3:
        return N >= 7;
    }
    throw new IllegalArgumentException();
  }
}


Measured memory_bytes: 21972
R, G, B, N = map(int, input().split())
R_max = N // R + 1
G_max = N // G + 1
B_max = N // B + 1
ans = 0
for i in range(0, R_max):
    for j in range(0, G_max):
        #for k in range(0, B_max):
            #if i * R + j * G + k * B == N:
        #a, b = divmod(N - (i * R + j * G), B)
        if (N - (i * R + j * G)) % B == 0 and (N - (i * R + j * G)) >= 0:
            #print('ans', i, j)
            ans += 1
print(ans)


Measured memory_bytes: 40944
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var n     = int.Parse(spl[0]);
        var m     = int.Parse(spl[1]);

        var ary = ToIntArray(input.ReadLine(), n);

        double bo = (double)ary.Sum() / (double)(4 * m);

        int c = 0;
        foreach(var x in ary) {
            if (x >= bo) c++;
        }

        return c >= m ? Yes : No;
    }

    static List<long> ToIntArray(string strs, int n) {
        var ret = new List<long>(n);
        var spl =strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret.Add(long.Parse(spl[i]));
        return ret;
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
inline int read(void){
	int num = 0, f = 1;
	char ch;
	while(!isdigit(ch=getchar())) if(ch == '-') f = -1;
	while(isdigit(ch)) num = num*10 + ch-'0', ch = getchar();
	return num * f;
}
int main()
{
	int k = read(), n = 0, cnt = 0;
	if(!(k % 2)) puts("-1");
	else 
		while(true){
			n = n * 10 + 7;
			cnt++;
			n %= k;
			if(!n){
				printf("%d\n", cnt);
				break;
			}
			if(cnt > k){
				puts("-1");
				break;
			}
		}
	return 0;
}

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

int main() {
    //freopen("input1.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

Measured memory_bytes: 3956
n=int(input())
count=[[0 for i in range(10)] for j in range(9)]
ans=0
num=1
zero=0
for i in range(1,n+1):
    if (10**(zero+1))<=num:
        zero+=1
    a=i//10
    r=i-a*10
    l=i//(10**zero)
    count[l-1][r]+=1
    num+=1
#print(count)
for i in range(1,10):
    for j in range(1,10):
        if i==j:
            continue
        ans+=(count[i-1][j])*(count[j-1][i])
for i in range(1,10):
    ans+=(count[i-1][i]**2)
print(ans)

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

typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 9223372036854775807
#define MOD 1000000007

int main(void){

    ll x;
    cin >> x;

    int cnt = 0;
    ll y = 100ll;
    while (x>y){

        y = y * 1.01;
        cnt++;
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   vector<int> a(n);
   f(i,0,n){
      cin >> a[i];
   }
   int c = 1, len = 0;
   f(i,0,n){
      if(a[i] == c){
         len++;
         c++;
      }
   }
   if(len){
      cout << n-len << '\n';
   }else{
      cout << "-1\n";
   }
   return 0;
}

Measured memory_bytes: 1792
# 累積和
from sys import exit

N, K = map(int, input().split())
S = input()

p = '1'
count = 0
cs = []
for c in S:
    if c != p:
        cs.append(count)
        p = c
        count = 1
    else:
        count += 1
cs.append(count)
if p != '1':
    cs.append(0)

if len(cs) < 2 * K:
    print(N)
    exit()

for i in range(1, len(cs)):
    cs[i] += cs[i - 1]

result = cs[2 * K]
for i in range(2, len(cs) - 2 * K, 2):
    if cs[2 * K + i] - cs[i - 1] > result:
        result = cs[2 * K + i] - cs[i - 1]
print(result)


Measured memory_bytes: 7156
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a, b; cin >> a >> b;
	for (int i = 1; i <= 2000; i++)
	{
		if(i * 8 / 100 == a && i / 10 == b) {
			cout << i << endl;
			return 0;
		}
	}
	cout << "-1" << endl;
	return 0;
}


Measured memory_bytes: 3648
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N;
	cin >> N;
	ll A[200000];
	rep(i, N) {
		double d;
		cin >> d;
		d *= 1000000000;
		A[i] = d + 0.5;
	}
	ll p[20][20] = {};
	ll kotae = 0;
	rep(i, N) {
		int a = 0, b = 0;
		while (A[i] % 2 == 0) {
			a++;
			A[i] /= 2;
		}
		while (A[i] % 5 == 0) {
			b++;
			A[i] /= 5;
		}
		if (a > 18) a = 18;
		if (b > 18) b = 18;
		for (int x = 18 - a; x <= 18; x++) {
			for (int y = 18 - b; y <= 18; y++) {
				kotae += p[x][y];
			}
		}
		p[a][b]++;
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 5256
#include <iostream>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <cstdlib>
#include <iterator>
#include <algorithm>
#include <functional>
#include <random>
#include <bits/stdc++.h>

#include <stdio.h>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <math.h>
#include <ctime>
#include <cstring>
#define INF 1e18
using namespace std;

#define FOR(i,N) for(int i=0;i<N;i++) 
#define COUT(str) cout << str << endl
#define MAX_N 1000
 
//入力
int n,t,a ;
int h[MAX_N+4] = {};
double dis[MAX_N+4] = {};
double ans=INF;
int main() {

	cin >> n >> t >> a;

	FOR(i, n) {
		cin >> h[i];
	}

	FOR(i, n) {
		dis[i] = abs(a-(t - 0.006*h[i]));

		ans = min(ans, dis[i]);
		
	}
	
	FOR(i, n) {
		if (ans == dis[i]) {
			cout << i + 1 << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] R = new int[n];
		for(int i = 0; i < n; i++) {
			R[i] = scan.nextInt();
		}
		scan.close();
		int ans = R[1] - R[0];
		int min = R[0];
		for(int i = 1; i < n; i++) {
			if(min <= R[i]) {
				ans = Math.max(R[i] - min, ans);
			}else {
				min = R[i];
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 71268
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
const int maxn=200010;
int head[maxn],tot;
struct edge
{
	int to,next;	
}e[2*maxn];
void init()
{
	memset(head,-1,sizeof(head));
	tot=0;
}
void addedge(int u,int v)
{
	e[tot].to=v;
	e[tot].next=head[u];
	head[u]=tot++;
} 
int n,ans1,ans2;
int c[maxn];
int dfs(int u,int fa)
{
	if(u==n)	return 0;
	for(int i=head[u];i!=-1;i=e[i].next)
	{
		if(e[i].to==fa)	continue;
		int ret=dfs(e[i].to,u);
		if(ret>=0)
		{
			c[u]=true;
			return ret+1;
		}
	}
	return -1;
}
void dfs1(int u,int fa,int cnt)
{
	if(u==n||cnt==0)	return ;
	for(int i=head[u];i!=-1;i=e[i].next)
	{
		if(e[i].to==fa)	continue;
		if(c[e[i].to]==1)
		{
			c[e[i].to]=1;
			dfs1(e[i].to,u,cnt-1)	;	
		}
	}
}
void dfs2(int u,int fa,int cnt)
{
	if(u==1||cnt==0)	return ;
	for(int i=head[u];i!=-1;i=e[i].next)
	{
		if(e[i].to==fa)	continue;
		if(c[e[i].to]==1)
		{
			c[e[i].to]=0;
			dfs2(e[i].to,u,cnt-1);		
		}
	}
}
void dfs3(int u,int fa)
{
	ans1++;
	for(int i=head[u];i!=-1;i=e[i].next)
	{
		int v=e[i].to;
	//	cout<<v<<endl;
		if(v==fa)	continue ;
		if(c[v]!=0)
			dfs3(v,u);
	}
}
void dfs4(int u,int fa)
{
	ans2++;
	for(int i=head[u];i!=-1;i=e[i].next)
	{
		int v=e[i].to;
		if(v==fa)	continue ;
		if(c[v]!=1)
			dfs4(v,u);
	}
}
int main()
{
	while(scanf("%d",&n)!=EOF)
	{
		init();
		ans1=0;
		ans2=0;
		memset(c,-1,sizeof(c));
		for(int i=1;i<n;i++)
		{
			int u,v;
			scanf("%d%d",&u,&v);
			addedge(u,v);
			addedge(v,u);
		}
		int ans = dfs(1,-1)-1;
		int a=ans/2,b=ans/2;
		if(ans%2==1)
		{
			a+=1;
		}
		c[1]=1;
		c[n]=0;
		dfs1(1,-1,a);
		dfs2(n,-1,b);
		dfs3(1,-1);
		dfs4(n,-1);
		if(ans1>ans2)
		printf("Fennec\n");
		else 
		printf("Snuke\n");
	}	
	return 0;
}

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

int main() {
    int n, ans = 0;
    string s;
    cin >> n >> s;
    for (int i = 0; i < s.size(); i++) {
        while (i < s.size() - 1 && s[i] == s[i + 1]) i++;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
int mod = 1000000007;
long long dp[100005];

int main() {
  int n;
  cin >> n;
  
  int a;
  int aa[n];
  priority_queue<int> pq;
  for(int i = 0;i<n;i++){
    cin >> a;
    aa[i] = a;
    pq.push(a);
  }
  int tmp1,tmp2;
  for(int i = 0;i<n;i++){
    if(aa[i] == pq.top()){
      tmp1 = pq.top();
      pq.pop();
      cout << pq.top() << endl;
      pq.push(tmp1);
    }else{
      cout << pq.top() << endl;
    } 
  }  
}


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

using namespace std;
using ll = long long;

int main() {
    vector<ll> divs(10000001,1);
    for(int i = 2;i < 10000001;++i) {
        for(int j = i;j < 10000001;j+=i) {
            ++divs[j];
        }
    }
    int n;
    cin>>n;
    ll ans=0;
    for(ll i = 1;i <= n;++i) {
        //cerr<<divs[i]<<endl;
        ans+=i*divs[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 81216
package main
import(
  "fmt"
)
func abs(a int) int{
  if a<0{
    return a*-1
  }else{
    return a
  }
}
func main(){
  var n, m int
  fmt.Scan(&n, &m)
  ans:=(n-2)*(m-2)
  fmt.Println(abs(ans))
}


Measured memory_bytes: 512
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

// AOJ 0027
public class Main {

	static Scanner sc = new Scanner(System.in);
	static int M, D;
	static final String[] ss = {
		"Thursday",
		"Friday",
		"Saturday",
		"Sunday",
		"Monday",
		"Tuesday",
		"Wednesday"
	};
	static final int[] is = {
		31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
	};
	
	public static void main(String[] args) {
		while (true) {
			M = sc.nextInt(); D = sc.nextInt();
			if (M == 0 && D == 0) break;
			int ds = 0;
			for (int i = 1; i < M; i++) {
				ds += is[i - 1];
			}
			
			ds += D - 1;
			System.out.println(ss[ds % 7]);
		}

	}
}

Measured memory_bytes: 12000
int max(int a,int b){
    if(a>b)return a;
    else return b;
}

int min(int a,int b){
    if(a<b)return a;
    else return b;
}

#include<stdio.h>
int main(){
    int r[200000],n,maxv=-2000000000,minv;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&r[i]);

    minv=r[0];
    
    for(int i=1;i<n;i++){
        maxv=max(maxv,r[i]-minv);
        minv=min(minv,r[i]);
    }
    printf("%d\n",maxv);
    return 0;
}



Measured memory_bytes: 3504
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define fop(i,m,n) for (int i=(m)-((m)>(n));i!=(n)-((m)>(n));i+=2*((m)<(n))-1)
#define test(x) cout << #x << ' ' << x << endl;
#define eb emplace_back
#define pb push_back
#define mp make_pair 
int MOD = 1e9 + 7;

int main () {
	int n;
	cin >> n;
	int nums[n][n];
	fop (i,0,n) {
		fop (j,0,n) {
			cin >> nums[i][j];
		}
	}
	lli dp[1 << n];
	dp[0] = 1;
	fop (i,1,(1<<n)) dp[i] = 0;
	fop (i,1,(1<<n)) {
		fop (j,0,n) {
			if (i & (1 << j)) {
				dp[i] += dp[i ^ (1 << j)] * nums[__builtin_popcount(i)-1][j];
				dp[i] %= MOD;
			}
		}
	}
	cout << dp[(1 << n) - 1] << endl;
}

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

using namespace std;

const int MOD = 1000000007;
const int MOD_MAX = 200000;
using ll = long long;

ll fact_arr[MOD_MAX], finv_arr[MOD_MAX], inv_arr[MOD_MAX];
void comb_init() {
	fact_arr[0] = fact_arr[1] = 1;
    finv_arr[0] = finv_arr[1] = 1;
    inv_arr[1] = 1;
    for (int i = 2; i < MOD_MAX; i++){
        fact_arr[i] = fact_arr[i - 1] * i % MOD;
        inv_arr[i] = MOD - inv_arr[MOD % i] * (MOD / i) % MOD;
        finv_arr[i] = finv_arr[i - 1] * inv_arr[i] % MOD;
    }
}
class mint {
public:
	ll value;
	
	mint(ll a = 0) : value((a % MOD + MOD) % MOD) {}
	bool operator < (mint a) { return this->value < a.value; }
	bool operator > (mint a) { return this->value > a.value; }
	bool operator <= (mint a) { return this->value <= a.value; }
	bool operator >= (mint a) { return this->value >= a.value; }
	mint& operator += (const mint& a) { if ((this->value += a.value) > MOD) this->value -= MOD; return *this; }
	mint& operator -= (const mint& a) { if ((this->value -= a.value) < 0ll) this->value += MOD; return *this; }
	mint& operator *= (const mint& a) { (this->value *= a.value) %= MOD; return *this; }
	mint operator + (const mint a) const { mint ret(this->value); return ret += a; }
	mint operator - (const mint a) const { mint ret(this->value); return ret -= a; }
	mint operator * (const mint a) const { mint ret(this->value); return ret *= a; }
	mint pow(ll times) const {
		if (!times) return 1;
		mint ret = pow(times >> 1);
		ret *= ret;
		if (times & 1) ret *= *this;
		return ret;
	}
	mint inv() const { return pow(MOD - 2); }
	mint& operator /= (const mint& a) { return (*this) *= a.inv(); }
	mint operator / (const mint a) const { mint ret(this->value); return ret /= a; }
	friend ostream& operator << (ostream& os, const mint& m) { os << m.value; return os; }
};

mint comb(mint n, mint r) { 
	if ( n < r || n < 0 || r < 0) return 0;
	return mint(fact_arr[n.value]) * mint(finv_arr[r.value]) * mint(finv_arr[(n - r).value]);
}
mint hcomb(mint n, mint r) { return comb(n + r - 1, r); }

mint comb_slow(mint n, mint r) {
	if (n < r || n.value < 0 || r.value < 0) return mint(0ll); 
	mint ret = 1ll; 
	if (r > n / 2) r = n - r;
	for (int i = 0; i < r.value; i++) ret = ret * (n - i); 
	for (int i = 0; i < r.value; i++) ret = ret / (i + 1); 
	return ret;
}
mint hcomb_slow(mint n, mint r) { return comb_slow(n + r - 1, r); }

int main() {
  int s; cin >> s;
  if (s <= 2) { 
    cout << 0 << endl;
    return 0;
  }
  comb_init();
  mint ans = 0;
  mint limit = s / 3;
  for (mint k = 1; k <= limit; k += 1) {
    ans += comb(mint(s) - mint(2) * k - 1, k - 1);
  }
  cout << ans << endl;
}

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

int main() {
    int x1, y1, x2, y2;

    cin >> x1 >> y1 >> x2 >> y2;

    int dist_x, dist_y, abs_dist_x, abs_dist_y;
    dist_x = x2 - x1;
    dist_y = y2 - y1;
    abs_dist_x = abs(dist_x);
    abs_dist_y = abs(dist_y);

    int x3, x4, y3, y4;

    x3 = x2 - dist_y;
    y3 = y2 + dist_x;
    x4 = x3 - dist_x;
    y4 = y3 - dist_y;

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl; 
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int N; cin >> N;
	vector<vector<int>> D(N, vector<int>(2));
	for(int i = 0; i < N; i++) cin >> D[i][0] >> D[i][1];
	string ans = "No";
	int cnt = 0;
	for(int i = 0; i < N; i++) {
		if(D[i][0] == D[i][1]) cnt++;
		else cnt = 0;
		if(cnt == 3) {
			ans = "Yes"; break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

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

  vector<int> v(n, 0);
  for(int i = 0; i < n; i++){
    cin >> v[i];
  }

  sort(v.begin(), v.end(), greater<int>());

  int ans = 0;
  for(int i = 0; i < k; i++){
    ans += v[i];
  }
  cout << ans << endl;

  return 0;
}

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

#define f first
#define s second
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define px pair<db, db>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define input(a) for (auto& el : a) cin >> el;
#define output(a) cout << '!'; for (auto& el : a) cout << el << ' '; cout << '\n'; cout.flush();
#define sz(el) int(el.size())
#define sq(a) ((a) * (a))
#define xll bitset<128>
#define xmin(a,b) a = min(a, b)
#define xmax(a,b) a = max(a, b)
#define sun(a) sort(all(a)); a.resize(unique(all(a)) - a.begin());
/**/  /// extra
//#define forn(i,n) for (int i = 0; i < n; ++i)
//#define rforn(i,n) for (int i = n - 1; i >= 0; --i)
#define bn '\n'
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
//#define G vector<vector<pii>>
#define GVE vector<vector<edge>>
#define usi unordered_set<int>
#define usp set<pii>
/**/

using namespace std;

const int INF = 1'000'000'017;
const ll LLINF = 1'000'000'000'000'000'017LL;
const ld inf = 1.0 / 0.0;
const ld eps = 1e-9;
const int MOD = 998244353;

//mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

//uniform_int_distribution<int> uid(l, r); [l, r]
//int x = uid(rng);

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    string s, t;
    cin >> s >> t;
    int cnt = 0;
    for (int i = 0; i < 3; ++i) {
        cnt += (s[i] == t[i]);
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
const int N = 1010101;
V Sieve(N, 0);
V cnt(N, 0);
void precalc() {
	rep(i, N) {
		Sieve[i] = i;
	}
	REP(i, 2, N) {
		if (Sieve[i] == i) {
			for (int j = i + i; j < N; j += i) if (Sieve[j] == j) Sieve[j] = i;
		}
	}
}
void pfact(int x) {
	set<int> st;
	while (x != 1) {
		st.insert(Sieve[x]);
		x /= Sieve[x];
	}
	auto itr = st.begin();
	while (itr != st.end()) cnt[*itr]++, itr++;
}
int main() {
	precalc();
	int n;
	cin >> n;
	int g = 0;
	rep(i, n) {
		int x;
		cin >> x;
		if (i == 0) g = x;
		else g = gcd(g, x);
		pfact(x);
	}
	bool flag = true;
	rep(i, N) {
		if (cnt[i] >= 2) flag = false;
	}
	if (flag) puts("pairwise coprime");
	else if (g == 1) puts("setwise coprime");
	else puts("not coprime");
	return 0;
}

Measured memory_bytes: 10976
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
int main(){
  int a,b,ab,x,y;
  cin >> a >> b >> ab >> x >> y;
  int amin = 0;
  int bmin = 0;
  int abmin = 0;
  amin = min(a,ab * 2);
  bmin = min(b,ab * 2);
  abmin = min(a + b,ab * 2);
  int both = 0;
  both = min(x,y);
  cout << both * abmin + (x - both) * amin + (y - both) * bmin << endl;
  return 0;
}

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

using namespace std ;

int main()
{
    ios_base :: sync_with_stdio(false) ;
    cin.tie(nullptr) ;
    int n ;
    cin >> n ;
    int a[n] ;
    for(int &x : a)
        cin >> x ;
    int cnt = 0 ;
    for(int i = 0 ; i < n ; i++)
        cnt += a[i] - 1 != i;
    if(cnt > 2)
        cout << "NO" ;
    else
        cout << "YES" ;
    return 0 ;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long int L,R;
int ans=2019;
int main(void){
	cin>>L>>R;
	for(long int i=L;i<=R;i++)
		if(i%2019==0){
			cout<<"0";
			return 0;
		}
	for(int i=L%2019;i<R%2019;i++)for(int j=(i+1)%2019;j<=R%2019;j++)ans=min(ans,i*j%2019);
	if(ans==2019)ans=L*(L+1)%2019;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
As = [int(input()) for i in range(N)]

maxim = max(As)
counter = As.count(maxim)

if counter > 1:
    for a in As:
        print(maxim)
else:
    for a in As:
        if a == maxim:
            print(max([i for i in As if i != a]))
        else:
            print(maxim)

Measured memory_bytes: 14196
n = int(input())
d, x = map(int, input().split())

A = []
for i in range(n):
    A.append(int(input()))

t = 0
for i in range(1,d+1):
    for j in A:
        if (i - 1) % j == 0:
            t += 1
print(t + x)

Measured memory_bytes: 38640
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


if __name__ == '__main__':
    S = int(input())

    x1, y1 = 0, 0
    x2, y2 = 1000000000, 1
    x3 = (x2 - S % x2) % x2
    y3 = (S + x3) // x2
    print('{} {} {} {} {} {}'.format(x1, y1, x2, y2, x3, y3))


Measured memory_bytes: 38384
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

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

    struct Shop { large price, count; };
    auto shop = vector<Shop>(n);
    for (auto& i : shop)
        cin >> i.price >> i.count;
    sort(shop.begin(), shop.end(), [](auto&A , auto&B) {
        return (A.price < B.price) || (A.price == B.price && A.count > B.count);
    });
    
    auto have = 0LL;
    auto cost = 0LL;
    for (auto& s : shop) {
        auto want = m - have;
        auto amount = min(want, s.count);
        cost += amount * s.price;
        have += amount;
        if (have >= m) break;
    }

    cout << cost << endl;
    return 0;
}


Measured memory_bytes: 4848
n = int(input())
h = list(map(int, input().split()))
total = 1

for i in range(1, n):
    no_flag = 0
    for j in range(i):
        if h[j] > h[i]:
            no_flag = 1
        else:
            pass
    if no_flag == 0:
        total += 1

print(total)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		int max = 0;
		for (int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
			max = Math.max(max,h[i]);
		}
		int count = 0;
		int ans = 0;
		for (int i = 1; i <= max; i++) {
			count = 0;
			for (int j = 0; j < n; j++) {
				if(h[j]>0) {
					if(j==0) count++;
					else if(h[j-1] == 0) count++;
				}
			}
			for (int j = 0; j < n; j++) {
				if(h[j]>0) h[j]-=1;
			}
			ans += count;
		}
		System.out.println(ans);
		sc.close();
	}
}

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

typedef long long ll;

ll Gcd(ll m, ll n)
{
    ll temp;
    while (m % n != 0)
    {
        temp = n;
        n = m % n;
        m = temp;
    }
    return n;
}

ll Lcm(ll m, ll n)
{
    return m * n / Gcd(m,n);
}

ll multiLcm(vector<ll> v){
    if(v.size()==1){
        return v[0];
    }

    ll a, b, c;
    a = v.back();
    v.pop_back();
    b = v.back();
    v.pop_back();

    c = Lcm(a, b);
    v.push_back(c);

    ll res = multiLcm(v);
    return res;
}

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

    vector<ll> a(N);
    for(int i=0;i<N;i++){
        cin >> a[i];
    }

/*
    ll n = multiLcm(a);
    ll ans = 0;
    for(int i=0;i<N;i++){
        ans += (n-1)%a[i];
        cout << a[i] << " : " << (n-1)%a[i] << endl;
    }
    cout << ans << endl;
*/
    ll ans = 0;
    for(int i=0;i<N;i++){
        ans += a[i]-1;
    }
    cout << ans << endl;
    return 0;
}


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


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

  // 数直線上で左をaとしてしまう
  // どちらを移動させても距離は同じため
  // 実際に動かして表示するならよくない
  if (a > b) swap(a, b);

  // すでに重なっているか
  if (a + w >= b) {
    cout << 0 << endl;
  } else {
    // 重なっていないなら計算
    cout << b - (a + w) << endl;
  }
  
  return 0;
}

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

typedef long double ld;									// XD
#define int long long
#define PB push_back
#define all(x) (x).begin(),(x).end()
#define ii pair <int,int>
#define mii map <int,int>
#define vi vector<int>
#define vii vector< ii >
#define F first
#define S second
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a; i>=b; --i)
#define sz(x) (int)((x).size())
#define mem(a,x) memset(a,x,sizeof(a))
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
inline void io(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int p = 1e9 + 7;
const int mod = p;
const int inf = 1e18;
const int maxn = 2e5+5;

void solve(){
	int n, a, b; cin>>n>>a>>b;
	int ans = ceil(1.0*n/a);
	ans *= b;
	cout<<ans;
}
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0); //io();
    //cout<<setprecision(12);
    int tc=1; //0cin>>tc; //int t = 1; 
    while(tc--){
    	//cout<<"Case #"<<t<<": "; ++t;
        solve();cout<<'\n';
    }
    return 0;
}


Measured memory_bytes: 3760
class ModComb
  def initialize(max, mod)
    @mod = mod
    @fac = Array.new(max + 1)
    @finv = Array.new(max + 1)
    @inv = Array.new(max + 1)
    @fac[0] = @fac[1] = 1
    @finv[0] = @finv[1] = 1
    @inv[1] = 1
    (2..max).each do |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
    end
  end

  def comb(n, k)
    return 0 if n < k
    return 0 if n < 0 || k < 0
    @fac[n] * (@finv[k] * @finv[n - k] % @mod) % @mod
  end
end

N, K = gets.split.map(&:to_i)
MOD = 10 ** 9 + 7
blue = K
red = N - K
comb = ModComb.new(10 ** 5, MOD)
(1..K).each do |k|
  box = k
  puts comb.comb(blue - 1, box - 1) * comb.comb(red + 1, box) % MOD
end


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

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vll;
const int INF = 0x3f3f3f3f;

int main() {
    int H, W;
    int h, w;
    cin >> H >> W >> h >> w;
    cout << H * W - (h * W + H * w - h * w) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
using vec_i=vector<int>;
const int INF = 1e9;

int main(){
  string S;cin>>S;
  int pre=stoi(S.substr(0,2)),suf=stoi(S.substr(2,4));
  bool mmpre=false,mmsuf=false;
  if(0<pre&&pre<=12)mmpre=true;
  if(0<suf&&suf<=12)mmsuf=true;
  if(mmpre&&mmsuf)print("AMBIGUOUS")
  if(mmpre&&!mmsuf)print("MMYY")
  if(!mmpre&&mmsuf)print("YYMM")
  if(!mmpre&&!mmsuf)print("NA")

}


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

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

// array pointer = *a, num of element = n, key key
int lower_bound(int *a, int n, int key){
    int ng, mid, ok;
    ng = -1, ok = n-1;
    while (abs(ok - ng) > 1){
        mid = (ok + ng) / 2;
        if (key <= a[mid]){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    if (a[ok] >= key)return ok;
    return n;
}

//greatest common divisor
unsigned long gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}

unsigned long lcm(unsigned long x, unsigned long y){
    unsigned long g = gcd(x, y);
    return x*y/g;

}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

/*
int struct_ascending_compare(const void *p, const void *q) {
return ((struct_name*)p)->member_name - ((struct_name*)q)->member_name;
}*/

/*unsigned long long pascal[100][100] = {0};
void make_pascal(void){
    for (int i = 0; i < 100; i++){
        pascal[i][0] = 1;
    }
    pascal[1][1] = 1;
    for (int i = 2; i < 100; i++){
        for (int j = 1; j < 100; j++){
           pascal[i][j] = (pascal[i-1][j-1]+pascal[i-1][j]) % mod;
        }
    }
}*/
long long mod = 1000000007;

//x ^ n
long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % mod;
        x = x * x % mod;
    }
    return res;
}

int hindo[100005];

int main(void){
    int n;
    int a;
    int to_eat = 0;
    int to_remain = 0;
    scanf("%d", &n);

    for (int i = 0; i < n; i++){
        scanf("%d", &a);
        if (hindo[a]) to_eat++;
        else{
            hindo[a] = 1;
            to_remain++;
        }
    }
    if (to_eat % 2){
        printf("%d\n", to_remain - 1);
    }else{
        printf("%d\n", to_remain);
    }
    return 0;

}


Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long ll;

const int maxn = 1000010;
const int mod = 1000000007;

ll f[maxn], sum[maxn];

int main()
{
	int n;
	scanf("%d",&n);
	f[1] = sum[1] = n;
	for (int i=2;i<=n;i++)
	{
		f[i] = f[i-1] + (ll)(n-1) * (ll)(n-1);
		if (i>1) f[i] += (ll)(n - max(2,i-1) + 1);
		if (i>3) f[i] += sum[i-3];
		f[i] %= mod;
		sum[i] = (sum[i-1] + f[i]) % mod;
	}
	printf("%lld\n",f[n]%mod);
	return 0;
}


Measured memory_bytes: 15872
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        // 整数の入力
        // final int a = sc.nextInt();
        // 文字列の入力
        // final String s1 = sc.next();
        final int varN = Integer.parseInt(sc.next());
        int lastA = Integer.parseInt(sc.next());
        int presentA = 0;
        long cnt = 0;
        for (int i = 1; i < varN; i++) {
            presentA = Integer.parseInt(sc.next());
            if (presentA < lastA) {
                cnt = cnt + lastA - presentA;
                continue;
            } else {
                lastA = presentA;
            }
        }
        sc.close();

        System.out.println(cnt);
    }
}

Measured memory_bytes: 59312
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cnt=0,mx=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='I')
        {
            cnt++;
        }
        else
        {
            cnt--;
        }
        mx = max(mx,cnt);
    }
    cout<< mx <<endl;
    return 0;
}


Measured memory_bytes: 3580
import java.io.InputStream;
import java.io.PrintStream;
import java.math.BigInteger;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        int a[] = new int[N];
        int b[] = new int[N];
        Tree trees[] = new Tree[N];
        int maxSides = 0;
        for (int i = 0; i < N; i++) {
            trees[i] = new Tree();
        }

        for (int i = 0; i < N-1; i++) {
            a[i] = scan.nextInt() - 1;
            b[i] = scan.nextInt() - 1;
            trees[a[i]].addChild(b[i]);
            trees[b[i]].addChild(a[i]);

            if (maxSides < trees[a[i]].getChildrenNum())
                maxSides = trees[a[i]].getChildrenNum();
            if (maxSides < trees[b[i]].getChildrenNum())
                maxSides = trees[b[i]].getChildrenNum();
        }

        //K
        os.println(maxSides);

        dfs(0, -1, -1, trees);

        for(int i = 0; i < N-1; i++) {
            os.println(trees[a[i]].getChildren().get(b[i]));
        }
    }


    static void dfs(int to, int root, int rootColor, Tree[] trees) {
        if(root >= 0) {
            trees[to].getChildren().put(root, rootColor);
        }
        int color = 1;
        for (Integer child: trees[to].getChildren().keySet()) {
            if (child == root)
                continue;
            if(color == rootColor)
                color++;
            trees[to].getChildren().put(child, color);
            dfs(child, to, color++, trees);
        }

    }


    static class Tree {
        HashMap<Integer, Integer> children = new HashMap<>();//tree番号、color番号

        Tree() {
        }

        void addChild(int num) {
            children.put(num, 0);
        }

        public int getChildrenNum() {
            return children.keySet().size();
        }

        HashMap<Integer, Integer> getChildren() {
            return children;
        }
    }
}

Measured memory_bytes: 117832
N,C,K = map(int,input().split())
T = sorted([int(input()) for _ in range(N)])
ans = 0
for i in range(N):
  if i == 0:
    st=T[i]
    cnt = 1
  else:
    if cnt==C:
      ans += 1
      cnt = 1
      st = T[i]
    else:
      if T[i]-st > K:
        ans += 1
        cnt = 1
        st = T[i]
      else:
        cnt += 1

if cnt >0: ans += 1
print(ans)

Measured memory_bytes: 51032
# coding: utf-8
        
def getEven(N):
    cnt = 0
    while N % 2 == 0:
        cnt += 1
        N /= 2
    return cnt

def solve(Ai, N):
    ans = 0
    for a in Ai:
        ans += getEven(a)
    return ans

if __name__ == "__main__":

    N = int(input())
    Ai = map(int, input().split())
    print(solve(Ai, N))
    


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

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

  if (A <= 5)
    cout << 0 << endl;
  else if (6 <= A && A <= 12)
    cout << B / 2 << endl;
  else
    cout << B << endl;
  return 0;
}

Measured memory_bytes: 3592
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int i = a; i <= (n); ++i)
#define repD(i, a, n) for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a) memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	int n; cin >> n;
	vi s(n); rep(i,n) cin >> s[i];
	ll sum = 0; rep(i,n) sum += s[i];
	sort(all(s));
	if(sum%10 == 0){
		rep(i,n){ 
			if(s[i]%10 != 0){
				sum -= s[i];
				break;
			}
		}
	}
	if(sum%10 == 0)
		cout << 0 << endl;
	else 
		cout << sum << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <math.h>
#include <string>
#include <map>
#include <functional>
#include <algorithm>
#include <stack> 
#include <iomanip>
#include <stdio.h>
#include <set>
#include <array>
using namespace std; 

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

int main()
{
	long long a, b;
	cin >> a >> b;
	auto g = gcd(a, b);
	cout <<(a * b / g) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=305,mod=998244353;
int n;
char s[N];
int dp[N][N][N];
bool f[N][N][N];
int main()
{
    scanf("%s",s);
    n=strlen(s);
    f[0][0][0]=true;
    for(int i=0;i<n;i++)
        for(int n0=0;n0<=i;n0++)
        for(int n1=0;n1<=i;n1++)
    {
        if(!f[i][n0][n1]) continue;
        f[i+1][n0][n1]=true;
        if(n0&&s[i]=='1')
            f[i+1][n0-1][n1+1]=true;
        if(n1&&s[i]=='0')
            f[i+1][n0+1][n1-1]=true;
        if(i+1<n&&(s[i]=='0'||s[i+1]=='0'))
            f[i+2][n0+1][n1]=true;
        if(i+1<n&&(s[i]=='1'||s[i+1]=='1'))
            f[i+2][n0][n1+1]=true;
    }
    dp[n][0][0]=1;
    ll ans=0;
    for(int i=n;i>=0;i--)
        for(int n0=0;n0<=n;n0++)
        for(int n1=0;n1<=n;n1++)
    {
        if(dp[i][n0][n1]==0) continue;
        if(f[i][n0][n1])
            ans=(ans+dp[i][n0][n1])%mod;
        if(i>0)
        {
            dp[i-1][n0][n1]=(dp[i-1][n0][n1]+dp[i][n0][n1])%mod;
            if(s[i-1]=='1')
                dp[i][n0+1][n1]=(dp[i][n0+1][n1]+dp[i][n0][n1])%mod;
            else
                dp[i][n0][n1+1]=(dp[i][n0][n1+1]+dp[i][n0][n1])%mod;
        }
    }
    ans=(ans+mod-1)%mod;
    printf("%lld\n",ans);
}


Measured memory_bytes: 120668