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

using namespace std;


int odd[1000];
int even[1000];
int max=0;
map<int,int> m;

int main(){
    int N;
    cin >>N;
    int Omax1=0,Omax2=0,Emax1=0,Emax2=0;
map<int,int> o;
map<int,int> e;
int n,l,Oans1,Oans2,Eans1,Eans2;
    for(int i=1;i<=N/2;i++){
        cin >> n;
        o[n]++;
        if(Omax1<o[n]){
            Omax1=o[n];
            Oans1=n;
        }
        else if(Omax2<o[n]){
             Omax2=o[n];
            Oans2=n;
        }
        cin >> l;
        e[l]++;
        if(Emax1<e[l]){
            Emax1=e[l];
            Eans1=l;
        }
        else if(Emax2<e[l]){
             Emax2=e[l];
            Eans2=l;
        }
    }

    if(Oans1==Eans1){
    cout <<min(N-Omax1-Emax2,N-Omax2-Emax1)<<endl;
    }
    else
    cout <<N-Omax1-Emax1<<endl;
    
    /*
cout <<Oans1 <<" "<<Oans2<<endl;
cout <<Eans1 <<" "<<Eans2<<endl;
*/
 return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
using P=pair<int,int>;
int main(){
  int a,b,c;cin>>a>>b>>c;
  if(a<=c && b>=c) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math
import heapq
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
# list(map(int, input().split()))

N = int(input())
H = list(map(int, input().split()))

X = [H]
ans = 0
while True:
    newX = []
    for group in X:
        f = min(group)
        ans += f
        A = [(h - f) for h in group]
        temp = []
        for a in A:
            if a == 0:
                if len(temp) > 0:
                    newX.append(temp)
                    temp = []
                continue
            temp.append(a)
        if len(temp) > 0:
            newX.append(temp)

    if len(newX) == 0:
        break
    X = newX
print(ans)


Measured memory_bytes: 68120
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>

using namespace std;

#define gettime printf("\nTime : %0.3lf\n",clock()*1.0/CLOCKS_PER_SEC);
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repp(i,a,b) for(int i=a;i>=b;i--)
#define Set(x,a) memset(x,a,sizeof(x));

#define vs vector<string>
#define vi vector<int>
#define ll long long
#define ff first
#define ss second

struct comp {
       bool operator() (int a,int b) {
            return a>b;
       }
};

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //std::ios::sync_with_stdio(false);
    int n, l, r, m;
    bool seat0man, seatMman;
    string data;
    cin>>n;
    l = 0;
    r = n - 1;
    cout<<"0"<<endl;
    cin>>data;
    if (data[0] == 'V') return 0;
    if (data[0] == 'M') seat0man = true;
    else seat0man = false;
    while (true) {
        m = (l + r) / 2;
        cout<<m<<endl;
        cin>>data;
        if (data[0] == 'V') return 0;
        if (data[0] == 'M') seatMman = true;
        else seatMman = false;
        if ((m % 2 == 0 && seatMman == seat0man) || (m % 2 == 1 && seatMman == !seat0man)) {
            l = m + 1;
        }
        else r = m;
    }
    return 0;
}


Measured memory_bytes: 852
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int a,b;
    cin>>a>>b;
    int g=__gcd(a,b);
    set<int> d;
    for(int i=2;i*i<=g;i++){
        while(g%i==0){
            d.insert(i);
            g/=i;
        }
    }
    if(g>1)d.insert(g);
    cout<<d.size()+1<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
struct Card
	{
		char suit;
		int value;
	};
int main()
{
	int n,i,j,k;
	while(scanf("%d",&n)!=EOF)
	{
		struct Card a[100],b1[100],b2[100],c;
		for(i=0;i<n*2;i++)
		{
			a[i].suit=getchar();
			scanf("%d",&a[i].value);
		}
		for(i=0,j=1;i<n;i++,j+=2)
		{
			b1[i]=a[j];
			b2[i]=a[j];
		}
		for(i=0;i<n;i++)    //冒泡排序
		{
			for(j=n-1;j>i;j--)
			{
				if(b1[j].value<b1[j-1].value)
				{
					c=b1[j];
					b1[j]=b1[j-1];
					b1[j-1]=c;
				}
			}
		}
		for(i=0;i<n;i++)
		{
			if(i==n-1)
			{
				printf("%c%d",b1[i].suit,b1[i].value);
			}
			else
			{
				printf("%c%d ",b1[i].suit,b1[i].value);
			}
		}
		printf("\n");
		printf("Stable\n");

		for(i=0;i<n;i++)    //选择排序
		{
			k=i;
			for(j=i;j<n;j++)
			{
				if(b2[j].value<b2[k].value)
				{
					k=j;
				}
			}
				c=b2[k];
				b2[k]=b2[i];
				b2[i]=c;
		}
		for(i=0;i<n;i++)
		{
			if(i==n-1)
			{
				printf("%c%d",b2[i].suit,b2[i].value);
			}
			else
			{
				printf("%c%d ",b2[i].suit,b2[i].value);
			}
		}
		printf("\n");
		for(i=0,k=0;i<n;i++)
		{
			if(b1[i].suit!=b2[i].suit)
			{
				k++;
			}
		}
		if(k>0)
		{
			printf("Not stable\n");
		}
		else
		{
			printf("Stable\n");
		}
	}
	return 0;
}




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

int main()
{
	string a, b;
	cin >> a >> b;
	int n = a.length();
	int m = b.length();
	vector<vector<int>> dp(n + 1, vector<int> (m + 1, 0));
	
	// dp[i][j] will denote the max. length of lcs till i and j
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m; j++)
		{
			if(a[i - 1] == b[j - 1])
				dp[i][j] = max(dp[i][j], 1 + dp[i - 1][j - 1]);
			else
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
		}
	}
	string s;
	for(int i = n, j = m; i > 0 and j > 0 ; )
	{
		if(dp[i][j] == dp[i][j - 1])
			i, j--;
		else if(dp[i][j] == dp[i - 1][j])
			i--,j;
		else
		{
			s.push_back(a[i - 1]);
			i--;
			j--;
		}
	}
	reverse(s.begin(), s.end());
	cout << s << "\n";
			
	
	return 0;
}


Measured memory_bytes: 35584
import java.awt.print.Printable;
import java.util.Scanner;
import javax.sound.midi.SysexMessage;
  
public class Main{      
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int i = 1;
        do{
            int x = i;
            if ( x % 3 == 0 )
            {
                System.out.print(" "+i);
                continue;
            }
            while(true)
                {   
                    if ( x % 10 == 3 )
                    {
                        System.out.print(" "+i);
                        break;
                    }   
                    x /= 10;
                    if (x!=0) continue;
                    else break;
                };
               
        }while ( ++i <= n);
        System.out.println();

        
        
    }
}



Measured memory_bytes: 28924
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
sys.setrecursionlimit(10**7)
# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

N, M = mi()
nos = set(input().split())
#昇順ソート
availables = sorted(list(set(map(str, (0,1,2,3,4,5,6,7,8,9))) - nos))

#方針
#桁数が変われば、(1)0が使える場合は、使える一番低い数字+あとは全部0
#              (2)0が使えない場合は、使える一番低い数字で埋めるだけ
#とはいえ、元々が3桁とかなら全探索で十分
#5桁になると怪しいので、(1)(2)を活かす

#まずは9999までの間に答えがあるかどうか
#N=9999でも、9が嫌いじゃない場合があるから探索する
ans = 0
for i in range(N, 100000):
  if not (set(str(i)) & nos): #使えない(nos)のに使ってる(set内)が無かったら
    ans = i
    break


print(ans)



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

int x, y;

int main() {
	cin>>x>>y;
	for(int i = 0; i <= x; i++) {
		if(2*i + 4*(x - i) == y) {
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	int k;
	string S;
	cin>>S;
	int win=0;
	int fail=0;
	for (k=0;k<S.length();k++){
		if (S[k]=='o'){
			win++;
		}else{
			fail++;
		}
	}
	if (fail>=8){
		cout<<"NO"<<endl;
		return 0;
	}
	if (k==15 && win<8){
		cout<<"NO"<<endl;
		return 0;
	}
	if (win+(15-k)>=8){
		cout<<"YES"<<endl;
		return 0;
	}
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: i64 = iter.next().unwrap().parse().unwrap();
    let a: i64 = iter.next().unwrap().parse().unwrap();
    let b: i64 = iter.next().unwrap().parse().unwrap();
    let c: i64 = iter.next().unwrap().parse().unwrap();
    let d: i64 = iter.next().unwrap().parse().unwrap();
    let e: i64 = iter.next().unwrap().parse().unwrap();
    let p = [a,b,c,d,e];
    let m = p.iter().min().unwrap();
    
    println!("{}", (n - 1) / m + 1 + 4);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int h;
	cin >> h;
	vector<int> n(h);
	rep(snip_i, h) cin >> n.at(snip_i);
	rep(i, h){
		cout << "node " << i + 1 << ": key = " << n.at(i) << ", ";
		if(i != 0) cout << "parent key = " << n.at((i+1)/2-1) << ", ";
		int l = (i+1)*2-1, r = (i+1)*2;
		if(l < h) cout << "left key = " << n.at(l) << ", ";
		if(r < h) cout << "right key = " << n.at(r) << ", ";
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3104
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>
#include<queue>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))


int main(){
	int t,b[4]={0};
	char s[9];
	while(~scanf("%d,%s",&t,s)){
		if(s[1]=='B')b[2]++;
		else if(s[0]=='A')b[0]++;
		else if(s[0]=='B')b[1]++;
		else b[3]++;
	}
	rep(i,4)printf("%d\n",b[i]);
	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

ll dp[10101][100][2];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int d;
    string s;
    cin >> s >> d;
    int n = s.size();
    dp[0][0][0] = 1LL;

    for (int i = 0; i < n; i++)
    {
        int lim = s[i] - '0';
        for (int j = 0; j < d; j++)
        {
            // 桁を自由に決めてよいとき(flg==1)
            for (int k = 0; k < 10; k++)
            {
                (dp[i + 1][(j + k) % d][1] += dp[i][j][1]) %= MOD;
            }
            // 桁が制限されている時(flg==0)
            for (int k = 0; k <= lim; k++)
            {
                if (k == lim)
                {
                    (dp[i + 1][(j + k) % d][0] += dp[i][j][0]) %= MOD;
                }
                else
                {
                    (dp[i + 1][(j + k) % d][1] += dp[i][j][0]) %= MOD;
                }
            }
        }
    }

    cout << ((dp[n][0][0] + dp[n][0][1]) % MOD - 1LL + MOD) % MOD << endl;
}


Measured memory_bytes: 15872
length = int(input())
target = [int(n) for n in input().split(" ")]
splitter = target[-1]
border = 0
for i, n in enumerate(target):
    if n <= splitter:
        target[i], target[border] = target[border], target[i]
        border += 1
target[border - 1] = [splitter]
print(*target)

Measured memory_bytes: 18384
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
LL pw[87];

LL dfs(int i, LL d, int fg) {
   if (i == 0) return d == 0 ? 1 : 0;
   if (i == 1) return d == 0 ? 10 : 0;
   LL D = (10 - (d % 10)) % 10;
   //printf("i = %d d = %lld D = %lld\n", i, d, D);
   LL c = 9 - D + 1 - fg;
   d = d - pw[i - 1] * D + D;
   return c * dfs(i - 2, abs(d) / 10, 0);
}

int main() {
    LL D;
    while (~scanf("%lld", &D)) {
          LL ans = 0;
          pw[0] = 1;
          for (int i = 1; i <= 18; i++) {
              pw[i] = pw[i - 1] * 10;
          }
          for (int i = 1; i <= 18; i++) {
              ans += dfs(i, D, 1);
          }
          printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int H = scanner.nextInt();
    int W = scanner.nextInt();
    char a[][] = new char[H][W];
    boolean h[] = new boolean[H];
    boolean w[] = new boolean[W];

    scanner.nextLine();
    for (int i = 0; i < H; i++) {
      String line = scanner.nextLine();
      for (int j = 0; j < W; j++) {
          a[i][j] = line.charAt(j);
          if ( a[i][j] == '#') {
              h[i] = w[j] = true;
          }
      }
    }
    for (int i = 0; i < H; i++) {
      if (h[i] == false) {
        continue;
      }
      for (int j = 0; j < W; j++) {
        if (w[j] == false) {
          continue;
        }
        System.out.printf("%c", a[i][j]);
      }
      System.out.println("");
    }
  }
}

Measured memory_bytes: 29712
#include <bits/stdc++.h>
using namespace std;
#define N 3010
int S[N][N],C[N][N];
inline int read() {
    int x=0;
    char ch=getchar();
    while (!isdigit(ch)) ch=getchar();
    while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
    return x;
}
int mod=0;
inline int pls(int x,int y) {
    int w=x+y;
    return w>=mod?w-mod:w;
}
inline void add(int &x,int y) {
    x+=y;
    if (x<0) x+=mod;
    if (x>=mod) x-=mod;
}
inline int tim(int x,int y) {
    long long w=1LL*x*y;
    return w>=mod?w%mod:w;
}
inline void mul(int &x,int y) {
    long long w=1LL*x*y;
    x=(w>=mod?w%mod:w);
}
inline int _pow(int x,int y,int p) {
    long long ans=1;
    while (y) {
        if (y&1) ans=ans*x%p;
        x=1LL*x*x%p,y>>=1;
    }
    return ans;
}
int main() {
    int n=read();mod=read();
    S[0][0]=C[0][0]=1;
    for (int i=1;i<=n+1;i++) {
        C[i][0]=1;
        for (int j=1;j<=n+1;j++) {
            C[i][j]=pls(C[i-1][j],C[i-1][j-1]);
            S[i][j]=pls(S[i-1][j-1],tim(j,S[i-1][j]));
        }
    }
    int w=-1,Ans=0;
    for (int i=0;i<=n;i++) {
        w*=-1;
        int ans=0;
        int Pow=_pow(2,n-i,mod),p=1;
        for (int j=0;j<=i;j++) {
            add(ans,tim(S[i+1][j+1],p)),mul(p,Pow); 
        }
        mul(ans,tim(C[n][i],_pow(2,_pow(2,n-i,mod-1),mod)));
        add(Ans,ans*w);
        // printf("%d\n",_pow(2,Pow,mod-1));
        // printf("%d ",ans*w);
    }// puts("");
    cout<<Ans<<endl;
    return 0;
}

Measured memory_bytes: 70912
#include<bits/stdc++.h>
#define ll long long
#define dl double
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()

using namespace std;

int main()
{
    ll t,n,m,i,j,k,x,y,u,v,l,r,ta,tb,count1=0,count2=0;
    string s;
    cin >> s;
    if(s.length()>=3)
    for(i=0;i<s.length()-1;i++)
    {
       if((s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')&& i <s.length()-2)
        {
            count2++;
            count1 += count2;
            i+=2;
        }
        else if(s[i]=='B' && s[i+1] == 'C')
        {
            count1 += count2;
            i +=1;
        }
        else if(s[i]=='A')
        {
            count2++;
        }
        else
        {
            count2=0;
        }

    }

    cout << count1;
    return 0;

}


Measured memory_bytes: 640
import itertools
import sys

def findRoot(uf,value):
  if uf[value]==None:
    return value
  else:
#経路圧縮
    uf[value]=findRoot(uf,uf[value])
    return uf[value]


sys.setrecursionlimit(50000)
n,m=[int(x) for x in input().split(' ')]

uf=[None]*n
b=[]
s=[1]*n
r=[]

for x in range(0,m):
  b.append([int(x)-1 for x in input().split(' ')])

for x in b[::-1]:
  r1=findRoot(uf,x[0])
  r2=findRoot(uf,x[1])

  if r1==r2:
    r.append(0)
  else:
    r.append(s[r1]*s[r2])
#木の結合
    uf[r2]=r1
    s[r1]+=s[r2]

for x in itertools.accumulate(r[::-1]):
  print(x)


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

int bubbleSort( int A[], int N) {
    int i = 0, j;
    int count = 0;
    bool flag = 1;
    while ( flag) {
        flag = 0;
        for ( j = N - 1; j >= i+1; j--) {
            if ( A[j] < A[j-1]) {
                swap(A[j], A[j-1]);
                flag = 1;
                count++;
            }
        
        }
        i++;
    }
    return count;
}

int main() {
    int i, N;
    int A[100];
    int count;
    cin >> N;
    for ( i = 0; i < N; i++) cin >> A[i];
    
    count =  bubbleSort(A, N);
    
    for ( i = 0; i < N; i++) {
        if ( i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << count << endl;
    

    return 0;

}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

const int M = 1e9+7;

using namespace std;

main()
{
    fast;
    int i,j;
    string s;
    cin>>s;
    for (i=0;i<s.size();i++)
    {
        if (s[i]=='A')
            break;
    }
    for (j=s.size()-1;j>=0;j--)
    {
        if (s[j]=='Z')
            break;
    }
    cout<<j-i+1<<endl;
}


Measured memory_bytes: 720
n,k=map(int,input().split())
l=[0 for i in range(20)]
m=[2**i for i in range(20)]
for i in range(n):
    for j in range(20):
        if m[j]*(i+1)>=k:
            l[j]+=1
            break
for i in range(19):
    l[i+1]+=l[i]*2
print(l[19]/(m[19]*n))

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

const int MAX=200005;
const ll MOD=1000000007;
int a[MAX],b[MAX],n,idx=-1,idxk=-1;
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf(" %d",&a[i]);
    sort(a,a+n);
    for(int i=0;i<n-1;i++) {
        int t=min(a[i],a[n-1]-a[i]);
        if(t>=idxk) idxk=t,idx=i;
    }
    printf("%d %d\n",a[n-1],a[idx]);
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

template<typename T>
inline T up(const T& l, const T& r) {//SegmentTreeのupdate関数
    T res;
    res = min<T>(l,r);
    return res;
}

template<typename T>
class SegmentTree {
public:
    vector<T> seg;
    int sz = 1;
    T unit;
    //T (*up)(const T& l,const T& r);
    SegmentTree(int n, T unit = 0) {
        this->unit = unit;
        //int sz = 1;
        while (sz < n) sz <<= 1;
        seg.resize(sz * 2, unit);
        //up = &up1;
    }
    void set(const int& k, const T& x) {//左からk番目の葉にxを代入する
        seg[sz - 1 + k] = x;
    }
    T get(const int& k) {//左からk番目の葉を得る
        return seg[sz - 1 + k];
    }
    void update(int k, const T& v) {// k 番目の値をvに変更
        k += sz - 1;
        seg[k] = v;
        while (k > 0) {
            k = (k - 1) / 2;
            seg[k] = up(seg[2 * k + 1], seg[2 * k + 2]);
        }
    }
    T query(int a, int b, int k, int l,int r) {//[a,b)のupの合成を求める(a,b,0,0,sz)のように使う
        if (r <= a || b <= l) {
            return unit;
        }
        if (a <= l && r <= b) {
            return seg[k];
        }
        else {
            T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return up(vl, vr);
        }
    }
};

int main(){
    int n;
    ll x;
    cin >> n >> x;
    vector<ll> a(n*2);
    REP(i,n){
        cin >> a[i];
        a[i+n] = a[i];
    }
    SegmentTree<ll> sg(n*2,LLONG_MAX);
    Rep(i,n){
        sg.update(i,a[i]);
        sg.update(i+n,a[i+n]);
    }
    ll res = LLONG_MAX;
    Rep(k,n){
        ll cost = k*x;
        int sz = sg.sz;
        Rep(j,n){
            if(j-k<0){
                cost+=sg.query(j-k+n,j+1+n,0,0,sz);
            }else{
                cost+=sg.query(j-k,j+1,0,0,sz);
            }
        }
        chmin(res,cost);
    }
    put(res);
    return 0;
}



Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int h, w;
bool a[3000][3000];
int tate[3000][3000];
int yoko[3000][3000];
int b[3000][3000];
int c[3000][3000];
signed main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < w; j++) {
			if (s[j] == '#') {
				a[i][j] = 0;
			}
			else {
				a[i][j] = 1;
			}
		}
	}
	for (int i = h - 1; i >= 0; i--) {
		for (int j = w - 1; j >= 0; j--) {
			if (!a[i][j]) continue;
			yoko[i][j] = 1;
			if (j < w - 1) yoko[i][j] += yoko[i][j + 1];
			tate[i][j] = 1;
			if (i < h - 1) tate[i][j] += tate[i + 1][j];
		}
	}
	int ans = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (!a[i][j]) continue;
			b[i][j] = 1;
			if (i > 0) b[i][j] += b[i - 1][j];
			c[i][j] = 1;
			if (j > 0) c[i][j] += c[i][j - 1];
			ans = max(ans, b[i][j] + c[i][j] + tate[i][j] + yoko[i][j] - 3);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 200576
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    vvll d(h, vll(w));
    queue<pll> q;
    rep(i, h) rep(j, w) if(s[i][j] == '#') q.push(make_pair(i, j));
    const ll di[] = {1, -1, 0, 0};
    const ll dj[] = {0, 0, 1, -1};
    while(!q.empty()) {
        pll p = q.front(); q.pop();
        ll i = p.first, j = p.second;
        for(ll k = 0; k < 4; k++) {
            ll ni = i + di[k], nj = j + dj[k];
            if(ni < 0 || h <= ni) continue;
            if(nj < 0 || w <= nj) continue;
            if(s[ni][nj] == '#') continue;
            if(d[ni][nj] > 0) continue;
            d[ni][nj] = d[i][j] + 1;
            q.push(make_pair(ni, nj));
        }
    }
    ll ans = 0;
    rep(i, h) rep(j, w) chmax(ans, d[i][j]);
    cout << ans << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 28404
#include<stdio.h>
#define N 100

int main(){

  int i,j,k,l,A[N],flag = 1,count = 0;

  scanf("%d",&j);

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

  for(i = 0;i < j;i++){
    while(flag == 1){
      flag = 0;
      for(k = j-1;k != 0;k--){
	l = A[k];
	if(A[k] < A[k-1]){
	  A[k] = A[k-1];
	  A[k-1] = l;
	  flag = 1;
	  count++;
	}
      }
    }
    
    //printf("%d",A[i]);
    //if(k != j-1)printf(" ");
  }
  for(i=0;i<j-1;i++)printf("%d ",A[i]);
  printf("%d\n",A[i]);
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2084
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	map<char,bool> ans;
	for(int i=0;i<s.length();i++)
		if(ans.find(s[i])==ans.end())
			ans.insert(make_pair(s[i],true));
	if(ans.size()==2)
		cout<<"Yes\n";
	else	
		cout<<"No\n";			
}

Measured memory_bytes: 256
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def cmb_mod(N, mod=10**9+7):
    N1 = N + 1
    g1 = [0] * N1
    g2 = [0] * N1
    inv = [0] * N1
    g1[0] = g1[1] = g2[0] = g2[1] = inv[1] = 1

    for i in range(2, N1):
        g1[i] = g1[i-1] * i % mod
        inv[i] = -inv[mod % i ] * (mod//i) % mod
        #inv[i] = pow(g1[i-1], mod-2, mod)
        g2[i] = g2[i-1] * inv[i] % mod

    def cmb(n, a):
        if a < 0 or a > n:
            return 0
        return g1[n] * g2[a] * g2[n-a] % mod
    return cmb

def resolve():
    mod = 10**9 + 7
    N = int(input())

    cmb = cmb_mod(N)

    ans = 0
    x8 = 1
    ans = pow(10, N, mod)
    for i in reversed(range(1, N+1)):
        tmp = 2 * cmb(N, i) * x8 % mod
        ans = (ans - tmp) % mod
        x8 = x8*8 % mod

    ans = (ans - x8) % mod

    print(ans)

if __name__ == "__main__":
    resolve()


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


int main(){
  int n;
  int f = 0;
  int s = 0;
  int c = 1;
  cin >> n;
  int a[n];
  for(int i=0; i<n; i++){
    cin >> a[i];
    if(a[i]>f){
      f=a[i];c=1;
    }else{
      if(a[i]>s){
        s=a[i];
      }
    else{
      if(a[i]==f){c++;}
    }


  }
}
  for(int i=0; i<n; i++){
    if(a[i]==f){
      if(c>1){cout << f << endl;}
      else{cout << s << endl;}
    }else{cout << f << endl;}

  }

}


Measured memory_bytes: 2432
from heapq import heappush, heappop
it = lambda: list(map(int, input().strip().split()))


def greedy(A):
    ans = 0
    A.sort(key=lambda x:x[0])
    pq = []
    for k, a, b in A:
        ans += a
        heappush(pq, [a - b, k, a, b])
        while len(pq) > k:
            ans -= heappop(pq)[0]
    return ans


def solve():
    N = int(input())

    prefer_late = []
    prefer_early = []
    for _ in range(N):
        k, a, b = it()
        if a >= b:
            prefer_early.append([k, a, b])
        else:
            prefer_late.append([N - k, b, a])
    
    ans = 0
    ans += greedy(prefer_early)
    ans += greedy(prefer_late)
    print(ans)


T = int(input())
for _ in range(T):
    solve()

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

int partition_sort(int A[],int n){
    int x=A[n-1],i=-1,j=0;
    while(j<n){
    if(A[j]>x){
        j++;
    }
    else{
        i++;
        swap(A[i],A[j]);
        j++;
    }
    }
    return i;
}

int main(){
    int n;
    cin>>n;
    int A[n];
    for(int i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    int s=partition_sort(A,n);
    for(int i=0;i<n-1;i++){
        if(s==i)printf("[");
        printf("%d",A[i]);
        if(s==i)printf("]");
        printf(" ");
    }
    printf("%d\n",A[n-1]);
}




Measured memory_bytes: 3492
def calc(a, b, op)
  return a + b if op == '+'
  return a - b if op == '-'
  return a * b if op == '*'

  a / b if op == '/'
end

def func
  loop do
    a, op, b = gets.split
    break if op == '?'

    a, b = [a, b].map(&:to_i)
    puts calc(a, b, op)
  end
end

func


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

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

using namespace std;

int main(){
	int a,b,k; scanf("%d%d%d",&a,&b,&k);
	rep(i,k){
		if(i%2==0){
			if(a%2==1) a--;
			b+=a/2;
			a/=2;
		}
		else{
			if(b%2==1) b--;
			a+=b/2;
			b/=2;
		}
	}
	printf("%d %d\n",a,b);
	return 0;
}


Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

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

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

ll nCm(ll n, ll m){
    if (m == 0 || m == n)
        return (1);
    else if (m == 1)
        return (n);
    return (nCm(n - 1, m) + nCm(n - 1, m - 1));
}

//-----------------------ここから-----------

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

    vector<ll> l(n + 1);
    l[0] = 2; l[1] = 1;

    for(ll i = 2; i < n + 1; i++){
        l[i] = l[i - 2] + l[i - 1];
    }

    cout << l[n] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <iomanip>
#include <math.h>

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using namespace std;
//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; }
template<class T> inline bool chmin(T a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;
typedef long long int ll ;


#define INF 2000000000


int main() {
 
    ll h;
    cin >> h;
    
    int count = 0 ;
    ll res = 0;
    bool check=true;

    if(h==1){
        cout << 1 << endl;
        return 0;
    }
        
    while(true){

        h=h/2;
        count++;
        if (h<=1) break;
    }
    
    res = pow(2,count) + pow(2,count) -1 ;
    
    //for(int i=0;i<count+1;i++){
    //    res += pow(2,count-i);
    //}
    
    
    cout << res << endl;

}


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

#define pb              push_back
#define pi              acos(-1.0)
#define loop(i,a,n)     for(int i=a;i<n;i++)
#define rloop(i,n,a)    for(int i=n;i>=a;i--)
#define ll              long long int
#define ff              first
#define ss              second
#define pii             pair<ll,ll>
#define sc1(a)          scanf("%d",&a)
#define sc2(a,b)        scanf("%d %d",&a,&b)
#define sc3(a,b,c)      scanf("%d %d %d",&a,&b,&c)
#define all(v)          v.begin(),v.end()
#define ms(a,b)         memset(a,b,sizeof a)
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define fileout         freopen("output.txt","w",stdout)
#define filein          freopen("input.txt","r",stdin)
#define inf             2e9+5
#define Q               int q;cin>>q;while(q--)
#define check           cout<<"HI"<<endl;

//int x[]= {-1,0,0,1};
//int y[]= {0,-1,1,0};

using namespace std;

int main()
{
    int n;
    ll s = 0;
    cin >> n;
    int a[n+5];
    loop(i,0,n-1)sc1(a[i]);
    for(int i = 1 ; i <n-1; i++)
    {
        s+=min(a[i],a[i-1]);
    }
    s+=a[0]+a[n-2];
    cout<<s<<endl;
}













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

int main(){
    string S,T;
    cin>>S;
    cin>>T;

    bool ans = false;
    for(int i=0;i<S.size();i++){
        if(S==T){
            ans = true;
            break;
        }
        S = S.back() + S.substr(0,S.size()-1);
    }
    if(ans){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll,int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const int N = 200005;

ll dp[N], sum[N], v[N];

void solve(){
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> v[i];
	sum[1] = v[1];
	for(int i = 3; i <= n; i+=2)
		sum[i] = v[i] + sum[i-2];
	for(int i = 2; i <= n; i++){
		if(i&1){
			dp[i] = max(dp[i-2] + v[i], dp[i-1]);
		} else {
			dp[i] = max(dp[i-2] + v[i], sum[i-1]);
		}
	}
	cout << dp[n] << endl;
}

int main(){
	fastio;
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 8292
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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








int main(){
    std::string N; std::cin >> N;
    int a(0);
    for(int i(0), i_len(N.length()); i < i_len; ++i){
        (a += N[i] - '0') %= 9;
    }
    std::cout << (a ? "No" : "Yes") << std::endl;
    return 0;
}


Measured memory_bytes: 3692
N = int(input())
yakusuu = []

for i in range(1, int(N**0.5) + 1):
    if N % i == 0:
        yakusuu.append(i - 1)
        yakusuu.append(N // i - 1)
retval = 0
for y in yakusuu:
    if y == 0:
        continue
    if N // y == N % y:
        retval += y

print(retval)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
constexpr ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll N,A,B;
    cin >> N >> A >> B;
    if((B-A)%2 == 0){
        cout << (B-A)/2 << "\n";
    }else{
        cout << min(A+(B-A)/2,N-B+1+(B-A)/2) << "\n";
    }
}

Measured memory_bytes: 3656
import java.util.*;
public class Main
{
    public static void main(String [] args)
    {
        Scanner sc = new Scanner(System.in);
        String s = sc.next(); int [] a = new int [s.length()]; int n = s.length();
        for (int i = 0; i < s.length(); i++) {
            a[i] = Integer.parseInt(s.substring(i, i+1));
        }
        Map<Integer, Integer> stor = new HashMap<>(); int cur = 0;
        stor.put(0, 1); long ans = 0; int cur10 = 1;
        for (int i = n-1; i >= 0; i--) {
            cur = (a[i] * cur10 + cur) % 2019;
            cur10 = (cur10 * 10) % 2019;
            stor.put(cur, stor.getOrDefault(cur, 0) + 1);
            if (stor.get(cur) >= 2) {
                ans += stor.get(cur) - 1;
            }
        }
        System.out.println(ans);
    }




}

Measured memory_bytes: 55808
#include <iostream>

using namespace std;

int main()
{ int h , n , i , sum =0 ;
cin>>h;
cin>>n;
while (n>0 ){
    cin>>i;
    sum= sum + i;
    n=n-1;}
if (h<=sum ){
        cout<<"Yes";
}
else {cout<<"No";}

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
int d[1000][1000];
int pw(int n,int k){
  int res=1;
  while(k){
    if(k&1)res*=n;res%=MOD;
    n*=n;n%=MOD;
    k>>=1;
  }
  return res;
}
//main
signed main(){
  int N,M;cin>>N>>M;
  std::vector<int> v(M),p(M);
  memset(d,0,sizeof(d));
  for(int i=0;i<M;i++){
    cin>>v[i];
    for(int j=0;j<v[i];j++)cin>>d[i][j];
  }
  for(int i=0;i<M;i++)cin>>p[i];
  int ans=0;
  for(int i=0;i<pw(2,N);i++){
    int out=0;
    for(int j=0;j<M;j++){
      int l=0;
      for(int k=0;k<v[j];k++){
        if((i>>(d[j][k])-1)&1)l++;
      }
      if(l%2!=p[j])out++;
    }
    if(out==0)ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int mod= 1e9+7;
int main() 
{

    int n,m,maxi=0;
    cin>>n>>m;
    vector<vector<char>> a;
    string s;

    for(int i=0;i<n;i++)
    {
        cin>>s;
        vector<char> temp(s.begin(),s.end());
        a.push_back(temp);
    }
    //cout<<"haha";
    vector<vector<int> > dp(n+1,vector<int>(m+1,0));
    //cout<<a.size()<<" "<<a[0].size();
    int i=0;
    while(i<n && a[i][0]=='.')
    {
        dp[i+1][1]=1;
        i++;
    }
    i=0;
    while(i<m && a[0][i]=='.')
    {
        dp[1][i+1]=1;
        i++;
    }
   // cout<<"haha";
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if((i==1|| j==1) && dp[i][j]==1) continue;
            if(a[i-1][j-1]=='.')
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
        }
    }
    cout<<dp[n][m];
}

Measured memory_bytes: 8484
#include<stdio.h>
#include<ctype.h>
main(){
  char ch,j;
  int num,i;
  int counter[26]={};
  while(scanf("%c",&ch)!=EOF){
    if(isupper(ch)) ch=tolower(ch);
    num=ch-'a';
    if(num>=0&&num<26) counter[num]++;
  }
  for(i=0;i<26;i++){
    j='a'+i;
    printf("%c : %d\n",j,(int)counter[i]);
  }
  return 0;
}

Measured memory_bytes: 548
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
from scipy.sparse.csgraph import floyd_warshall
n,m,L=map(int,input().split())
A=[[INF]*n for _ in range(n)]
for _ in range(m):
    a,b,c=map(int,input().split())
    a-=1; b-=1
    A[a][b]=A[b][a]=c
A=floyd_warshall(A)
B=[[INF]*n for _ in range(n)]
for i in range(n):
    for j in range(n):
        if(A[i][j]<=L): B[i][j]=1
B=floyd_warshall(B)
Q=int(input())
for _ in range(Q):
    s,t=map(int,input().split())
    s-=1; t-=1
    print(int(B[s][t])-1 if(B[s][t]!=INF) else -1)

Measured memory_bytes: 17940
#include<stdio.h>
long long IN(void)
{
  long long x=0;short f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
void sub(void)
{
  int N=IN(),S[200],sz=0;long long A[200],x,y[200],z;
  for(int i=0;i<N;i++){A[i]=IN();}
  for(int i=0;i<N;i++){S[i]=getchar()-'0';}
  for(int i=N-1;i>=0;i--)
  {
    x=A[i];
    if(sz){for(int j=0;j<sz;j++){z=x^y[j];x=(x<z)?x:z;}}
    if(x){if(S[i]){puts("1");return;}y[sz++]=x;}
  }
  puts("0");
}
signed main(void){int T=IN();while(T--){sub();}}

Measured memory_bytes: 1456
package main

import "fmt"

func main() {
	var n, ans int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	for {
		for i := range a {
			if a[i]%2 != 0 {
				fmt.Println(ans)
				return
			}
			a[i] /= 2
		}
		ans++
	}
}


Measured memory_bytes: 512
#include <array>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N, K, x;
  cin >> N >> K;
  int dist = 0;
  for (size_t i = 0; i < N; i++) {
      cin >> x; 
      if (K < x) {
          dist += (x - K); 
      } else {
        dist += (x > (K - x)) ? (K - x) :  x;
      }
  }

  cout << dist * 2;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

int main(){
    long long a, b, c, d, n;
    cin >> a >> b >> c >> d >> n;
    n *= 4;

    b = min(2 * a, b);
    c = min(min(4 * a, 2 * b), c);
    d = min(min(8 * a, 4 * b), min(2 * c, d));

    long long ans = 0;
    ans += n / 8 * d;
    n %= 8;
    ans += n / 4 * c;
    n %= 4;
    ans += n / 2 * b;
    n %= 2;
    ans += n * a;

    cout << ans << endl;
}


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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define MP make_pair
#define PB push_back
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

const int maxn = 155;

class State{
public:
	int s0, s1, mx0, mx1;
	State(int _s0, int _s1, int _mx0, int _mx1): s0(_s0), s1(_s1), mx0(_mx0), mx1(_mx1){}
	bool operator < (const State &o)const{return MP(MP(s0, s1), MP(mx0, mx1)) < MP(MP(o.s0, o.s1), MP(o.mx0, o.mx1));}
};

int n, k, INF;
int f[maxn][maxn];
map<State, int> g[maxn];

inline void uadd(int &x, int y){
	(x += y) %= INF;
	return;
}

inline int mul(int x, int y){
	return 1ll * x * y % INF;
}

inline int solve(int _n, int _k){
	memset(f, 0, sizeof(f));
	f[0][0] = 1;
	FOR(i, 0, _n) REP(j, 0, _k){
		if(j != _k)
			uadd(f[i + 1][j + 1], f[i][j]);
		uadd(f[i + 1][0], f[i][j]);
	}
	int ret = 0;
	//printf("_n = %d _k = %d %d\n", _n, _k, f[_n][_k]);
	REP(i, 0, _k)
		uadd(ret, f[_n][i]);
	return ret;
}

inline int dfs(int pos, int s0, int s1, int mx0, int mx1){
	if(pos == n)
		return (mx0 == n && mx1 == n);
	if(mx0 < pos || mx1 < pos)
		return 0;
	s0 = min(s0, (k >> 1) + 1);
	s1 = min(s1, (k >> 1) + 1);
	State cur = State(s0, s1, mx0, mx1);
	if(g[pos].find(cur) != g[pos].end())
		return g[pos][cur];
	int mx0_ = n, mx1_ = n;
	if(pos % 2 == 0 && s1 * 2 - 1 >= k)
		mx1_ = pos + k - min(k / 2, s0) * 2;
	if(pos % 2 == 1 && s0 * 2 - 1 >= k)
		mx0_ = pos + k - min(k / 2, s1) * 2;
	int s0_ = s0 + (!(pos % 2)), s1_ = s1 + (pos % 2);
	int &ret = g[pos][cur];
	ret = 0;
	uadd(ret, dfs(pos + 1, s0_, s1_, min(mx0, mx0_), min(mx1, mx1_)));
	s0_ = (pos % 2) ? s0 : 0;
	s1_ = (pos % 2) ? 0 : s1;
	uadd(ret, dfs(pos + 1, s0_, s1_, (pos % 2 ? mx0 : n), (pos % 2 ? n : mx1)));
	return ret;
}

int main(){
	scanf("%d%d%d", &n, &k, &INF);
	if(!(k % 2)){
		printf("%d\n", mul(solve(n / 2, k / 2), solve(n - n / 2, k / 2)));
		return 0;
	}
	if(k == 1){
		printf("%d\n", solve(n, 2));
		return 0;
	}
	printf("%d\n", dfs(0, 0, 0, n, n));
	return 0;
}

Measured memory_bytes: 18432
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define F first
#define S second


typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int n; cin >> n;
	VI a(n); rep(i, n)cin >> a[i];
	int q; cin >> q;
	VI k(q); rep(i, q)cin >> k[i];
	rep(i, q) {
		puts(binary_search(all(a), k[i]) ? "1" : "0");
	}
}


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

int main()
{
    int k, x;
    cin >> k >> x;
    for (int i = x - k + 1; i < x + k; i++)
    {
        cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 3596