akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rev(a,b){return a>b}
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
using namespace std;
int num[100005];
int hand[100005];


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    string str;
    cin>>str;
    int i=0;
    int p = 0;
    while(i<n)
    {
        if(str[i]=='0')
        {
            int cn = 0;
            while(i<n&&str[i]=='0')
            {
                cn++;
                i++;
            }
            num[p]=cn;
            hand[p]=0;
        }
        else
        {
            int cn = 0;
            while(i<n&&str[i]=='1')
            {
                cn++;
                i++;
            }
            num[p]=cn;
            hand[p]=1;
        }
        p++;
    }

    int ans = 0;
    int cn = 0;
    i = 0;
    int l=0;
    if(hand[0]==1){cn+=num[0];i++;}
    while(i<p&&l<k)
    {
            cn+=num[i];
            cn+=num[i+1];
            l++;
            i+=2;
    }
    //if(i<p&&hand[i]==1){cn+=num[i];i++;}
    ans = cn;
    //cout<<ans<<endl;
    int j = 0;
    while(i<p)
    {
        //cout<<j<<' '<<cn<<endl;
            if(hand[j]==0)
            {
                cn-=num[j];
                j++;
            }
            else{
            cn-=num[j];
            cn-=num[j+1];
            j+=2;
            }
        //cout<<"RE"<<' '<<j<<' '<<cn<<' '<<hand[i]<<endl;

            cn+=num[i];
            cn+=num[i+1];
            //cout<<"SDF"<<' '<<num[i]<<' '<<num[i+1]<<endl;
            i+=2;

        ans = max(ans,cn);
        //cout<<j<<' '<<i<<' '<<ans<<' '<<cn<<endl;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1232
/* ex5_3
   kohei_suzuki */

#include <stdio.h>
int main(void){
    int height,width; //行数,列数
    scanf("%d %d",&height,&width);//入力受取

    char square[height][width]; //多次元配列

    //squareの入力受取
    for(int i=0; i<height ;i++){ 
        for(int j=0; j<width ;j++){
            scanf(" %c",&square[i][j]);
        }
    }

    int ture_row[height], ture_col[width];
    //表示する行と表示する列を表す0,1列
    //最終的に1となった行および列を出力する

    //#があった行iを記録(ture_row[i]=1とする)
    for(int i=0; i<height; i++){ 
        ture_row[i]=0;
        for(int j=0; j<width; j++){
            if(square[i][j] == '#'){
                ture_row[i]=1;
            }
        }
    }
    //#があった列iを記録(true_col[j]=1とする)
    for(int j=0; j<=width; j++){
        ture_col[j]=0;
        for(int i=0; i<height; i++){
            if(square[i][j]=='#'){
                ture_col[j]=1;
            }
        }
    }

    //true_row[i]=1かつtrue_col[j]=1ならばsquare[i][j]を出力
    for(int i=0; i<height; i++){
        if(ture_row[i] == 1){
            for(int j=0; j<width; j++){
                if(ture_col[j] == 1){
                    printf("%c",square[i][j]);
                }
            }
            printf("\n"); //行終わりで改行
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <cstdlib>
using namespace std;
int main()
{
	int n, i, j, k, c, d, x;
	char s[1025], t[10][6] = {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> s;
		for (j = x = 0, d = 0; j < strlen(s); j++, d = c)
		{
			c = s[j] - '0';
			if (c == 0 && d != 0)
				cout << t[d-1][x%strlen(t[d-1])];
			else if (d == c)
				x++;
			else
				x = 0;
		}
		cout << endl;
	}
}

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

typedef long long ll;

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

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
    int x, y;
    cin >> x >> y;

    int cnt = 0;
    if (x == y)
    {
        // do nothing.
    }
    else if ((x >= 0 && y < 0))
    {
        cnt = abs(abs(x) - abs(y)) + 1;
    }
    else if (x < 0 && y > 0)
    {
        // if (abs(x) > abs(y))
        // {
        // cnt = y - x;
        // }
        // else
        // {
        cnt = abs(abs(x) - abs(y)) + 1;
        // }
    }
    else
    {
        if (x >= 0)
        {
            if (y >= x)
                cnt = y - x;
            else if (y != 0)
                cnt = (x - y) + 2;
            else
                cnt = (x - y) + 1;
        }
        else
        {
            if (y >= x)
            {
                cnt = y - x;
                // cout << "a" << endl;
            }
            else
                cnt = (x - y) + 2;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


X, t = map(int, sys.stdin.readline().split())
print(max(X - t, 0))

Measured memory_bytes: 63980
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
int main(){
long N, ans=0; cin >> N; long a, b, x[N], y[N], minX=1e10, minY=1e10, maxX=-1e10, maxY=-1e10;
REP(i, N){ 
  cin >> a >> b; x[i]=a-b; y[i]=a+b;
  minX=min(minX, x[i]);minY=min(minY, y[i]);
  maxX=max(maxX, x[i]);maxY=max(maxY, y[i]);
}
ans=max(maxX-minX, maxY-minY);
cout << abs(ans) << "\n";
}

Measured memory_bytes: 6752
#include<bits/stdc++.h>
using namespace std;
queue<long long>q;
int k;
int tot=0;
int main()
{
	cin>>k;
	q.push(1);
	q.push(2);
	q.push(3);
	q.push(4);
	q.push(5);
	q.push(6);
	q.push(7);
	q.push(8);
	q.push(9);
	while(!q.empty())
	{
		long long  x=q.front();
		q.pop();
		//cout<<x<<endl;
		tot++;
		if(tot==k)
		  {
		  	cout<<x<<endl;
		  	return 0;
		  }
	 if(x%10==0)
	   {
	   	   q.push(x*10);
	   	   q.push(x*10+1);
	   }
	else if(x%10==9)
	  {
	  	q.push(x*10+8);
	  	q.push(x*10+9);
	  }
	else 
	  {
	  	q.push(x*10+x%10-1);
	  	q.push(x*10+x%10);
	  	q.push(x*10+x%10+1);
	  }
	}
	
}

Measured memory_bytes: 5108
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main() {
	int k, s;
	cin >> k >> s;
	int ans = 0;
	for (int i = 0; i <= k; i++) {
		for (int j = 0; j <= k; j++) {
			int z = s - i - j;
			if (z >= 0 && z <= k) ans++;
		}
	}
	cout << ans << endl;
}

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

public class Main {
	public static void main(String[] args) {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));


		  try{


			  String ab;
			  String[] strAry;
			  int a=0;
			  int b=0;
              String c;
              int d=0;

              while(true){
            	 
			      ab = input.readLine();
		          strAry = ab.split(" ");
		          a=Integer.parseInt(strAry[0]);
	              b=Integer.parseInt(strAry[2]);
                  c=strAry[1];
                

                  if(c.equals("+")){
            	      d=a+b;
                   }
                 
                  else if(c.equals("-")){
            	      d=a-b;
                  }
                  else if(c.equals("*")){
            	      d=a*b;
                 }
                  else if(c.equals("/")){
            	      d=a/b;
                  }
                  else if(c.equals("?")){
                        break;
                      }
                  System.out.println(d);
              }

		    }catch(IOException e) {   System.out.println("Exception : " + e);
		    }

	}
}

Measured memory_bytes: 24304
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n;
  cin >> n;
  vector<ll>sum(n+1);
  sum[0] = 0;
  REP(i, n){
    cin >> sum[i+1];
    sum[i+1] += sum[i];
  };
  ll ans = 1ll<<60;
  REP(i, n-1) chmin(ans, abs(sum[i+1]-(sum[n]-sum[i+1])));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <vector>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <queue>
#include <climits>
using namespace std;
typedef long long ll;
vector<ll> hs;
int n;
ll a, b;

bool is_enough(ll x) {
  vector<ll> h = hs;
  ll cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (h[i] > x * b) {
      cnt += ceil((double)(h[i] - x * b) / (a - b));
    }
  }
  return cnt <= x;
}

int main() {
  scanf("%d %lld %lld", &n, &a, &b);

  ll ma = 0;
  for (int i = 0; i < n; ++i) {
    ll h;
    scanf("%lld", &h);
    hs.push_back(h);
    ma = max(h, ma);
  }

  ll l = -1, r = ma;
  while (l + 1 < r) {
    ll mid = (l + r) / 2;
    if (is_enough(mid)) {
      r = mid;
    } else {
      l = mid;
    }
  }
  printf("%lld\n", r);
  return 0;
}


Measured memory_bytes: 1908
N = int(input())
H_list = list(map(int, input().split()))
con_cnt = 0
max_con = 0
for i in range(1, N):
    if H_list[i-1]>=H_list[i]:
        con_cnt += 1
    else:
        if max_con < con_cnt:
            max_con = con_cnt
        con_cnt = 0
if max_con < con_cnt:
            max_con = con_cnt
print(max_con)

Measured memory_bytes: 15020
S=input()

ans=[1]*len(S)

for i in range(1,len(S)):
  if S[i-1]==S[i]=='R':
    ans[i+1]+=ans[i-1]
    ans[i-1]=0

for i in range(len(S)-2,0,-1):
  if S[i+1]==S[i]=='L':
    ans[i-1]+=ans[i+1]
    ans[i+1]=0

print(*ans)

Measured memory_bytes: 6400
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

#include "bits/stdc++.h"

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define f first
#define s second
#define uint unsigned int

using namespace std;

int main() {
#define FILE_INPUT 0
#define FILE "coins"
#ifndef DEBUG
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#if FILE_INPUT == 1
#warning "FREOPEN is on"
    freopen(FILE".in", "r", stdin);
    freopen(FILE".out", "w", stdout);
#endif
#endif
    int n, p;
    cin >> n >> p;
    int a[n + 1];
    int cnt = 0;
    ll dp[n + 1][2];
    memset(dp, 0, sizeof(dp));
    if (!p)
        dp[0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        cnt += a[i]%2;
        dp[i][a[i]&1] = 1;
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j < i; ++j) {
            if (a[i]&1)
                dp[i][0] += dp[j][1];
            else
                dp[i][0] += dp[j][0];
            if (a[i]&1)
                dp[i][1] += dp[j][0];
            else
                dp[i][1] += dp[j][1];
        }
    }
    //for (int i = 0; i <= n; ++i) {cout << i << ' ' << dp[i][0] << ':' << dp[i][1] << '\n';}
    ll ans = 0;
    for (int i = 0; i <= n; ++i)
        ans += dp[i][p];
    cout << ans;
    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 data[] = new int[n];
		int min, mini = 0, count = 0, a;
		
		for (int i = 0; i < n; i++) {
			data[i] = scan.nextInt();
		}
		scan.close();
		
		for (int i = 0; i < n - 1; i++) {
			min = data[i];
			for (int j = i + 1; j < n; j++) {
				if (min > data[j]) {
					min = data[j];
					mini = j;
				}
			}
			
			if (min != data[i]) {
				for (int k = mini; k > i; k--) {
					a = data[k - 1];
					data[k - 1] = data[k];
					data[k] = a;
					count++;
				}
			}	
		}
		
		for (int i = 0; i < n; i++) {
			if (i == n - 1) {
				System.out.println(data[i]);
				System.out.println(count);
			} else {
				System.out.print(data[i] + " ");
			}
		}
		
		
	}
}



Measured memory_bytes: 26428
n = int(input())
an = list(map(int,input().split()))

def f(x):
    ans = 0
    count = 0
    for a in an:
        count += a
        if count * x >= 0:
            ans += abs(count)+1
            count = -x
        x *= -1
    return ans


print(min(f(1),f(-1)))


Measured memory_bytes: 14332
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	string s;
	cin >> s;
	s[3] = '8';
	cout << s << endl;
	return 0;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  lint n, a = 0;
  string s;
  cin >> n >> s;
  v2i c(n+1, v1i(3, 0));
  rep(i, n){
    if(s[i] == 'R'){
      c[i+1][0] = c[i][0]+1;
      c[i+1][1] = c[i][1];
      c[i+1][2] = c[i][2];
    }
    else if(s[i] == 'G'){
      c[i+1][0] = c[i][0];
      c[i+1][1] = c[i][1]+1;
      c[i+1][2] = c[i][2];
    }
    else if(s[i] == 'B'){
      c[i+1][0] = c[i][0];
      c[i+1][1] = c[i][1];
      c[i+1][2] = c[i][2]+1;
    }
  }
  rep(i, n){
    if(s[i] == 'R') a += (c[n][1]-c[i][1])*(c[n][2]-c[i][2]);
    else if(s[i] == 'G') a += (c[n][0]-c[i][0])*(c[n][2]-c[i][2]);
    else if(s[i] == 'B') a += (c[n][0]-c[i][0])*(c[n][1]-c[i][1]);
  }
  rep(i, (n-1)/2){
    int t = 0;
    while(t + (i+1)*2 < n){
      if(s[t] != s[t+i+1] && s[t+i+1] != s[t+(i+1)*2] && s[t] != s[t+(i+1)*2]) --a;
      ++t;
    }
  }
  cout << a << endl;
  return 0;
}

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

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

  vector<int> C(26);
  for (int i = 0; i < 26; i++) cin >> C.at(i);

  vector<vector<int>> S(D, vector<int>(26));
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) cin >> S.at(i).at(j);
  }

  // i 日目に開くコンテストのタイプを決める
  vector<int> T(D);
  for (int d = 0; d < D; d++) {
    int type = 1;
    int s_max = 0;
    for (int i = 0; i < 26; i++) {
      if (S.at(d).at(i) > s_max) {
        type = i+1;
        s_max = S.at(d).at(i);
      }
    }
    T.at(d) = type;
  }

  // i 日目に開くコンテストのタイプを出力
  for (int i = 0; i < D; i++) cout << T.at(i) << endl;
}


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

h, w = map(int, input().split())
a = [input()[:-1] for _ in range(h)]

ansX = []
ansY = []

for y in range(h):
    flag = True
    for x in range(w):
        if (a[y][x] == '#'):
            flag = False
    if (flag):
        ansY.append(y)

for x in range(w):
    flag = True
    for y in range(h):
        if (a[y][x] == '#'):
            flag = False
    if (flag):
        ansX.append(x)
#print(ansX, ansY)
for y in range(h):
    if (y in ansY):
        continue
    for x in range(w):
        if (x in ansX):
            continue
        print(a[y][x], end='')
    print('')

Measured memory_bytes: 4468
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+100;
bool vis[maxn][3]={0};
vector<int> G[maxn];
struct node{
	int id,dis;
};
queue<node>q; 
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int a,b;
	for(int i=1;i<=m;i++){
		scanf("%d%d",&a,&b);
		G[a].push_back(b);
	}
	int s,t;
	scanf("%d%d",&s,&t);
	q.push({s,0});
	vis[s][0]=1;
	while(!q.empty()){
		node u=q.front();
		q.pop();
		for(auto i:G[u.id]){
			if(vis[i][2])continue;
			vis[i][2]=1;
			for(auto j:G[i]){
				if(vis[j][1])continue;
				vis[j][1]=1;
				for(auto k:G[j]){
					if(vis[k][0])continue;
					vis[k][0]=1;
					if(k==t){
						printf("%d\n",u.dis+1);
						return 0;
					} 
					q.push({k,u.dis+1});
				}
			}
		}
	}
	printf("-1\n");
}



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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p){
    return o << "(" << p.first << ", " << p.second << ")";
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n; cin >> n;
    vi c(n-1), s(n-1), f(n-1);
    rep(i,n-1) cin >> c[i] >> s[i] >> f[i];

    rep(i,n-1){
        int now = 0;
        REP(j,i,n-1){
            now = max(s[j], (now + f[j] - 1)/f[j]*f[j]);
            now += c[j];
        }
        cout << now << endl;
    }
    cout << 0 << endl;
    return 0;
}

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

int main() {
    string s;
    long k, ans;
    cin >> s >> k;
    long cnt = 0;
    int same = 1;
    for(int i = 1; i < s.size(); i++){
        if(s.at(i-1) == s.at(i)) same++;
        else {
            cnt += same/2;
            same = 1;
        }   
    }
    if (s.at(0) != s.at(s.size()-1)) {
        cnt += same/2;
        ans = cnt*k;
    }
    else{
        int first = 0;
        for(int i = 0; i < s.size(); i++){
            if (s.at(i) != s.at(s.size()-1)) break;
            else first++;
        }
        if (first == s.size()){
            ans = s.size() * k / 2;
        }
        else{
            cnt -= first/2;
            ans = cnt*k;
            ans += (same+first)/2 * (k-1);
            ans += same/2;
            ans += first/2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import heapq
def main():
    n = int(input())
    a = list(map(int,input().split()))
    a.sort()
    heap = []
    heapq.heappush(heap,-a.pop())
    total = 0
    while a:
        score = -heapq.heappop(heap)
        total += score
        temp = -a.pop()
        heapq.heappush(heap,temp)
        heapq.heappush(heap,temp)
    print(total)



if __name__ == '__main__':
    main()


Measured memory_bytes: 31660
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    long long solve(vector<long long>& A) {
        int n = A.size();
        long long X = 0;
        for (auto x : A) {
            X ^= x;
        }

        vector<long long> LB;
        auto add = [&](long long x) {
            for (auto y : LB) {
                x = min(x, x ^ y);
            }
            if (x == 0) {
                return;
            }
            LB.push_back(x);
            for (int i = (int) LB.size() - 1; i > 0; --i) {
                if (LB[i] > LB[i - 1]) {
                    swap(LB[i], LB[i - 1]);
                }
            }
        };

        auto getMax = [&]() {
            long long res = 0;
            for (auto x : LB) {
                res = max(res, res ^ x);
            }
            return res;
        };

        for (auto x : A) {
            add(x & (~X));
        }

        long long res = (getMax() << 1) + X;
        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<long long> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    Solution sol;
    cout << sol.solve(A) << "\n";

    return 0;
}

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

int main(){

    int L, R, d;
    cin >> L >> R >> d;

    int ans = 0;
    for (int i = L; i <= R; i++) if (i % d == 0) ans++;

    cout << ans << endl;

    return 0;
}

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

#define rep(i, n) for (int i = 1; i < (int)(n); i++)

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

    int N;
    cin >> N;
    
    string s;   
    cin >> s;
    string S(1, s[0]);
    rep(i, N) {;
        if (s[i] != s[i-1]) {
            S.push_back(s[i]);
        }
    }
    cout << S.size();
    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
  string s; cin >> s;
  
  function<bool(string)> check = [](string s){
    string agct = "AGCT";

    for(const auto& c: s){
      if(agct.find(c) == string::npos) return false;
    }

    return true;
  };

  int ans = 0, n = (int)s.length();
  REP(i, n)FOR(j, i, n){
    if(check(s.substr(i, j-i+1))) ans = max(ans, j-i+1); 
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<ll>;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    vector<pair<ll, ll>> v;
    for (int i = 0; i < n; ++i)
    {
        ll x, y;
        cin >> x >> y;
        v.emplace_back(x, y);
    }
    sort(all(v));
    vector<ll> sufmin(n), sufmax(n);
    for (int i = 0; i < n; ++i)
    {
        sufmin[i] = v[i].second - v[i].first;
        sufmax[i] = v[i].second + v[i].first;
    }
    for (int i = n - 2; i >= 0; --i)
        sufmax[i] = max(sufmax[i], sufmax[i + 1]);
    for (int i = n - 2; i >= 0; --i)
        sufmin[i] = min(sufmin[i], sufmin[i + 1]);

    ll sol = 0;
    for (int i = 0; i < n; ++i)
    {
        auto [x, y] = v[i];
        sol = max(sol, max(abs(y - sufmin[i]), abs(y - sufmax[i])) - x);
    }
    cout << sol;
}


Measured memory_bytes: 9484
#include <bits/stdc++.h>
using namespace std;
long n,k;
string s,kq="";
int main()
{
  cin>>s;
  for(long i=0;i<s.size();i++)
  {
      if(s[i]=='0') kq+='0';
      if(s[i]=='1') kq+='1';
      if(s[i]=='B')
        if(kq.size()!=0) kq.erase(kq.size()-1,1);
  }
  cout<<kq<<endl;
}


Measured memory_bytes: 256
import java.io.*;

public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader bf =new BufferedReader(new InputStreamReader(System.in));
		String[] d = new String[6];
		double[] p = new double[7];
		int n=Integer.parseInt(bf.readLine());
		while(n-->0){
			d=bf.readLine().split(" ");
			for(int i=0;i<6;i++)p[i]=Double.parseDouble(d[i]);
			p[6]=Math.sqrt((p[0]-p[3])*(p[0]-p[3])+(p[1]-p[4])*(p[1]-p[4]));
			if(p[6]>p[2]+p[5]){
				System.out.println("0");
			}else if(p[2]-p[5]>p[6]){
				System.out.println("2");
			}else if(p[5]-p[2]>p[6]){
				System.out.println("-2");
			}else{
				System.out.println("1");
			}
		}
	}
}

Measured memory_bytes: 9784
# ABC105B - Cakes and Donuts
n = int(input())

if n % 4 == 0 or n % 7 == 0:
    print('Yes')
elif n < 4:
    print('No')
else:
    while n > 7:
        n -= 4
        if n % 4 == 0 or n % 7 == 0:
            print('Yes')
            break
    else:
        print('No')

Measured memory_bytes: 3060
using System;
using System.Linq;

namespace exawizards2019
{
    class Program
    {
        static void Main(string[] args)
        {
            var ABC = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var A = ABC[0];
            var B = ABC[1];
            var C = ABC[2];

            if (A <= 0 || B <= 0 || C <= 0)
            {
                Console.WriteLine("No");
                return;
            }

            if (A == B && B == C)
            {
                Console.WriteLine("Yes");
                return;
            }

            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13396
#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 Would
#define you
#define please

//いろいろ方法あるんやなぁ

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


	int X, Y, Z, K;
	cin >> X >> Y >> Z >> K;
	ll A[1000], C[1000];
	vector<ll> AB;
	rep(i, X) cin >> A[i];
	rep(i, Y) {
		ll B;
		cin >> B;
		rep(j, X) AB.pb(A[j] + B);
	}
	sort(AB.begin(), AB.end());
	rep(i, Z) cin >> C[i];
	sort(C, C + Z);
	reverse(C, C + Z);

	ll L = 3;
	ll R = 30000000000;
	while (L < R) {
		ll H = (L + R + 1) / 2;
		ll kazu = 0;
		ll goukei = 0;
		for (int i = max(0, X * Y - K); i < X * Y; i++) {
			while (kazu < Z && AB[i] + C[kazu] >= H) kazu++;
			goukei += kazu;
		}
		if (goukei >= K) L = H;
		else R = H - 1;
	}

	vector<ll> kotae;
	for (int i = max(0, X * Y - K); i < X * Y; i++) {
		ll kazu = 0;
		while (kazu < Z && AB[i] + C[kazu] >= L) kazu++;
		rep(q, kazu) {
			if (C[q] + AB[i] > L) kotae.pb(C[q] + AB[i]);
			else break;
		}
	}

	sort(kotae.begin(), kotae.end());
	reverse(kotae.begin(), kotae.end());
	int kaita = 0;
	for (ll k : kotae) {
		co(k);
		kaita++;
	}
	for (int i = kaita; i < K; i++) co(L);

	Would you please return 0;
}

Measured memory_bytes: 10604
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl

signed main(){
    int N;
    string A,B,C;
    cin >> N >> A >> B >> C;
    int Ans=0;
    REP(i,N){
        if(A[i]==B[i]&&B[i]==C[i]){
            Ans+=0;
        }else if(A[i]!=B[i]&&B[i]!=C[i]&&C[i]!=A[i]){
            Ans+=2;
        }else{
            Ans++;
        }
    }
    cout << Ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int S = stdIn.nextInt();
		int h,m,s;
			h = S / 3600;
			m = ( S - h * 3600 ) / 60;
			s = S - h * 3600 - m * 60;
		System.out.println(h + ":" + m + ":" + s);
	}

}

Measured memory_bytes: 26084
n,m,a,b = map(int,input().split())

x = list(map(int,input().split()))
x = max(x)

y = list(map(int,input().split()))
y = min(y)
i = x
ans = ''


for i in range(a+1,b):
  # X<z<yという区間を満たしていない ので誤りその条件を付け加えるなら...
  if x<i and i<=y:
    ans = 1
if ans:
  print('No War')
else:
  print('War')

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

int main(){
	string S;
	cin>>S;
	int K;
	cin>>K;
	vector<string>arr;
	for(int i=1;i<=5;++i){
		for(int j=0;j+i<=S.length();++j){
			string tmp=S.substr(j,i);
			bool add=true;
			for(int k=0;k<arr.size();++k){
				if(arr[k]==tmp)add=false;
			}
			if(add==true)arr.push_back(tmp);
		}
	}
	/*
	for(int i=0;i<arr.size();++i){
		cout<<arr[i]<<" ";
	}
	cout<<endl;
	*/
	sort(arr.begin(),arr.end());
	cout<<arr[K-1]<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
  int main() {
    string N;
    cin >> N ;

      if ( (N.at(0) == N.at(1) && N.at(0) == N.at(2)) || (N.at(1) == N.at(2) && N.at(1) == N.at(3))  ){
        cout << "Yes" << endl;
      }
    else {
        cout << "No" << endl;
     }
  }

Measured memory_bytes: 384
n,k=map(int,input().split())
p = list(map(int,input().split()))
def ex_even(a):
    return (a+1)/2
def ex_odd(b):
    return b//2 + 1
s = sum(p[0:k])
s_max = sum(p[0:k])
for i in range(n-k):
    s = s-p[i] + p[i+k]
    s_max = max(s_max,s)
if s_max % 2 == 0:
    print(ex_even(s_max) + 0.5*(k-1))
else:
    print(ex_odd(s_max) + 0.5*(k-1))


Measured memory_bytes: 24812
import java.util.*;
public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int N = sc.nextInt(), M = sc.nextInt();
	    int min = 0, max = 100000;
	    for (int i=0; i<M; i++) {
	        int l = sc.nextInt(), r = sc.nextInt();
	        min = Math.max(min,l);
	        max = Math.min(max,r);
	    }
	    int ans = Math.max(max - min + 1,0);
		System.out.println(ans);
	}
}

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

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define endl "\n"

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

int main() {
    {
        _time time(disable);
        _i64 d, a = 90, temp_d, temp_a; _f64 x = 0, y = 0;
        scanf("%ld,%ld", &temp_d, &temp_a);
        while(!(temp_d == 0 && temp_a == 0)) {
            d = temp_d;
            x += (_f64)d * cos(M_PI / 180 * a);
            y += (_f64)d * sin(M_PI / 180 * a);
            a -= temp_a;
            scanf("%ld,%ld", &temp_d, &temp_a);
        }
        printf("%ld\n%ld\n", (_i64)x, (_i64)y);
    }
    return 0;
}


Measured memory_bytes: 3472
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

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

	int res = inf;
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;

		for (int j = 0; a > 0; a /= 2, j++)
		{
			if (a % 2)
			{
				res = min(res, j);
				break;
			}
		}
	}

	cout << res << endl;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()
#define fcout cout << setprecision(10)

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

template <typename T>
void debug(vector<T> &vec) {
    for (auto x : vec) {
        cout << x << " ";
    }
    cout << endl;
    return;
}

template <typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

class BFS {
   private:
    int H, W;
    int dx[6] = {0, 1, 0, -1, 1, -1};
    int dy[6] = {1, 0, -1, 0, 1, -1};

   public:
    vector<string> field;
    vector<vector<int>> cost;

    BFS(vector<string> f) : field(f) {
        H = f.size();
        W = f[0].size();
        cost.assign(H, vector<int>(W, -1));
    }

    void bfs(queue<pair<int, int>> starts) {
        queue<pair<int, int>> que = starts;
        while (!que.empty()) {
            auto top = que.front();
            que.pop();
            int ny = top.first, nx = top.second;
            for (int i = 0; i < 6; i++) {
                int tx = nx + dx[i], ty = ny + dy[i];
                if (ty < H && tx < W && ty > -1 && tx > -1) {
                    if (field[ty][tx] == '#') continue;
                    if (cost[ty][tx] == -1) {
                        cost[ty][tx] = cost[ny][nx] + 1;
                        que.push(make_pair(ty, tx));
                    }
                }
            }
        }
    }

    void debug() {
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) cout << cost[i][j] << " ";
            cout << endl;
        }
    }
};

void solve(int t, int n) {
    vector<string> field(200, string(200, '.'));
    int bias = 100;
    REP(i, n) {
        int x, y;
        cin >> x >> y;
        field[y + bias][x + bias] = '#';
    }

    int sx, sy;
    cin >> sx >> sy;

    BFS bfs(field);
    bfs.cost[bias + sy][bias + sx] = 0;

    queue<pair<int, int>> que;
    que.push(make_pair(bias + sy, bias + sx));
    bfs.bfs(que);

    int ans = 0;
    for (int i = -bias; i < bias; i++) {
        for (int j = -bias; j < bias; j++) {
            if (bfs.cost[i + bias][j + bias] == -1) continue;
            if (bfs.cost[i + bias][j + bias] > t) continue;
            ans += 1;
        }
    }

    cout << ans << endl;
}

int main() {
    int t, n;
    while (cin >> t >> n && t) {
        solve(t, n);
    }

    return 0;
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

ll mypow(ll a, ll b)
{
    ll r = 1ll;
    while(b != 0){
        if(b&1) r = r * a % MOD;
        a = a * a % MOD;
        b /= 2;
    }
    return r;
}

vector<ll> fac;
vector<ll> ifac;

void factorial_init(ll n)
{
    fac.resize(n+1);
    ifac.resize(n+1);
    fac[0] = 1;
    ifac[0] = 1;
    REP(i,n) {
        fac[i+1] = fac[i] * (i + 1) % MOD;
        ifac[i+1] = ifac[i] * mypow(i + 1, MOD - 2) % MOD;
    }
}

ll Combination(ll a, ll b)
{
    if(a == 0 && b == 0) return 1;
    if(a < b || a < 0) return 0;
    ll r = ifac[a-b] * ifac[b] % MOD;
    return r * fac[a] % MOD;
}

int main()
{
    int h, w, a, b;
    cin>>h>>w>>a>>b;
    factorial_init(h+w+10);
    ll ans = 0ll;
    FOR(i,b+1,w+1) {
        ans += Combination(h - a + i - 2, i - 1) * Combination(a + w - i - 1, a - 1);
        ans %= MOD;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3328
from math import sqrt
from bisect import bisect


def main():
    N = int(input())
    factor = {}
    max_count = 1
    while N > 1:
        for i in range(2, int(sqrt(N)) + 1):
            if N % i == 0:
                N = N // i
                if i in factor:
                    factor[i] += 1
                    if max_count < factor[i]:
                        max_count = factor[i]
                else:
                    factor[i] = 1
                break
        else:
            if N in factor:
                factor[N] += 1
                if max_count < factor[N]:
                    max_count = factor[N]
            else:
                factor[N] = 1
            N = 1
    sum_up = [n * (n + 1) // 2 for n in range(max_count + 1)]
    ans = 0
    for prime, count in factor.items():
        ans += bisect(sum_up, count)-1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9228
import sys

while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        sys.exit()
    ans = 0
    for i in range(1, n - 1):
        for j in range(i + 1, n):
            for k in range(j + 1, n + 1):
                if i + j + k == x:
                    ans += 1
    print(ans)


Measured memory_bytes: 5600
def warshall_floyd(e, n):
    d = [[e[j][i] for i in range(n)] for j in range(n)]
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if d[i][k] + d[k][j] < d[i][j]:
                    d[i][j] = d[i][k] + d[k][j]
    # [print(i) for i in d]
    return d

n = int(input())
grid = [list(map(int, input().split())) for i in range(n)]
dgrid = warshall_floyd(grid, n)

ans = [[0 for i in range(n)] for j in range(n)]
for i in range(n):
    for j in range(n):
        if grid[i][j] != dgrid[i][j]:
            print(-1)
            exit()

ans = 0
for i in range(n):
    for j in range(n):
        for k in range(n):
            if i == j or j == k or k == i:
              continue
            if grid[i][k] + grid[k][j] == grid[i][j]:
                dgrid[i][j] = 0

ans = 0
for i in range(n):
    for j in range(i+1, n):
        ans += dgrid[i][j]
print(int(ans))


Measured memory_bytes: 46428
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
	int n;
	map<int,int> numbers;

	while ( cin >> n )
	{
		numbers[n]++;
	}

	int max = 0;

	for ( map<int,int>::iterator it = numbers.begin(); it != numbers.end(); it++ )
	{
		if ( max < (*it).second )
		{
			max = (*it).second;
		}
	}

	for ( map<int,int>::iterator it = numbers.begin(); it != numbers.end(); it++ )
	{
		if ( (*it).second == max )
		{
			cout << (*it).first << endl;
		}
	}

	return 0;
}

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

bool is_prime(int x)
{
	for (int i = 2; i <= sqrt(x); ++i)
		if (x % i == 0)
			return false;
	return true;
}

int main()
{
	int X;
	cin >> X;
	for (int p = X;; ++p)
	{
		if (is_prime(p))
		{
			cout << p << '\n';
			return 0;
		}
	}
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

typedef long long ll;

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const long long INF = 1LL << 60;

bool solve(int x, int y, int z) {
  return (x+y>z and y+z>x and z+x>y);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n; cin>>n;
  
  int res = 0;
  int itr = 0;
  
  map<int, int> mp;
  set<int> st;
  
  rep(i,n) {
    int l; cin>>l;
    
    ++mp[l];
    st.insert(l);
  }
  
  for(auto x : st) {
    
    for(auto y : st) {
      
      if(y==x) continue;
      
      for(auto z : st) {
        
        if(z==x or z==y) continue;
        if (solve(x,y,z)) {
          ++ itr;
          int xc = mp[x];
          int yc = mp[y];
          int zc = mp[z];
          
          res += xc*yc*zc;
        }
      }
    }
  }
  
  if (itr>=6) res = res/6;
  
  cout<<res;
  
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

template<int mod>
struct ModInt {
    int x;

    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }

    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};


const int mod = 1000003;
using modint = ModInt< mod >;

modint mpow(int x, int p){
    if(p == 0) return 1;
    if(p%2 == 0){
        modint t = mpow(x, p/2);
        return t*t;
    }
    return mpow(x, p-1)*x;
}

int main(){
    modint f[2010101];
    f[0] = 1;
    rep(i, 2010000){
        f[i+1] = f[i]*(i+1);
    }

    int q;
    cin >> q;
    rep(i, q){
        int x, d, n;
        cin >> x >> d >> n;
        if(d == 0){
            cout << mpow(x, n) << endl;
            continue;
        }
        modint s = x;
        s /= d;
        modint l = x;
        l /= d;
        l += n-1;
        if(s.x + n - 1 >= mod || s.x == 0){
            cout << 0 << endl;
            continue;
        }
        modint ans = f[l.x] / f[s.x-1];
        ans *= mpow(d, n);
        cout << ans << endl;
    }
}

Measured memory_bytes: 8704
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
#define fst first
#define snd second
using ll = long long;
using I = pair<int, int>;
const ll INF = 1ll << 60;

int main() {
  int N, M;
  while (cin >> N >> M) {
    vector<ll> x(N), y(N), z(N);
    for (int i = 0; i < N; i++) cin >> x[i] >> y[i] >> z[i];
    ll res = -INF;
    for (int m = 0; m < (1 << 3); m++) {
      int xs = ((m >> 0) & 1) ? 1 : -1;
      int ys = ((m >> 1) & 1) ? 1 : -1;
      int zs = ((m >> 2) & 1) ? 1 : -1;
      vector<ll> w(N);
      for (int i = 0; i < N; i++) w[i] = x[i] * xs + y[i] * ys + z[i] * zs;
      sort(w.rbegin(), w.rend());
      res = max(res, accumulate(w.begin(), w.begin() + M, 0ll));
    }
    cout << res << endl;
  }
  return 0;
}


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

int main(){
    int H, W, K;
    cin >> H >> W >> K;
    int C[30][30];
    for(int i=0; i<H; i++) for(int j=0; j<W; j++) scanf(" %1d", &C[i][j]);

    int64_t ans = 0;
    for(int x=0; x<H; x++) for(int y=0; y<W; y++){
        int c[30][30];
        for(int i=0; i<H; i++) for(int j=0; j<W; j++) c[i][j] = C[i][j];
        c[x][y] = 0;

        int64_t base = 0, result = 0;
        while(true){
            int64_t num = 0;
            for(int i=0; i<H; i++){
                int st = 0;
                for(int j=0; j<=W; j++){
                    if(j == W || (j > 0 && c[i][j] != c[i][j-1])){
                        if(j - st >= K){
                            for(int l=st; l<j; l++){
                                num += c[i][l];
                                c[i][l] = 0;
                            }
                        }
                        st = j;
                    }
                }
            }
            if(base > 0 && num == 0) break;
            result += base * num;
            base = base > 0 ? base * 2 : 1;

            for(int j=0; j<W; j++){
                int pos = H-1;
                for(int i=H-1; i>=0; i--){
                    if(c[i][j] > 0){
                        c[pos][j] = c[i][j];
                        if(pos != i) c[i][j] = 0;
                        pos--;
                    }
                }
            }
        }
        ans = max(ans, result);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256