akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200003,INF=1<<30;
int dp[1005][20005];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int H,N;cin>>H>>N;
    for(int i=0;i<=N;i++){
        for(int j=0;j<20005;j++){
            dp[i][j]=INF;
        }
    }
    dp[0][0]=0;
    
    vector<int> A(N),B(N);
    for(int i=0;i<N;i++) cin>>A[i]>>B[i];
    
    for(int i=0;i<N;i++){
        for(int j=0;j<20005;j++){
            dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
            if(j-A[i]>=0) dp[i+1][j]=min(dp[i+1][j],dp[i+1][j-A[i]]+B[i]);
        }
    }
    
    int ans=INF;
    
    for(int j=H;j<20005;j++) ans=min(ans,dp[N][j]);
    cout<<ans<<endl;
}




Measured memory_bytes: 78464
def main(li):
    count = 0
    for i in range(len(li)):
        if li[i] != i + 1:
            count += 1
    if count in [0, 2]:
        return True
    else:
        False


if __name__ == '__main__':
    n = int(input())
    li = list(map(int, input().split()))
    if main(li):
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
const int maxn=1e5+100;
vector<int>g[maxn];
int n;
int main()
{
    //freopen("in.txt","r",stdin);
    scanf("%d",&n);
    int k=-1;
    for(int i=1;i<=n*2;i++){
        if(i*(i-1)==2*n){
            k=i; break;
        }else if(i*(i-1)>2*n){ break;}
    }
    if(k==-1){
        printf("No\n");
    }else{
        printf("Yes\n");
        printf("%d\n",k);
        int t=0;
        for(int i=1;i<=k;i++){
            for(int j=i+1;j<=k;j++){
                ++t;
                g[i].push_back(t);
                g[j].push_back(t);
            }
        }
        for(int i=1;i<=k;i++){
            printf("%d ",g[i].size());
            for(int j=0;j<g[i].size();j++){
                if(j==g[i].size()-1) printf("%d\n",g[i][j]);
                else printf("%d ",g[i][j]);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4608
import itertools
n,m=map(int,input().split())
edge =[[] for i in range(n+1)]
for i in range(m):
  a,b=map(int,input().split())
  edge[a].append(b)
  edge[b].append(a)

all_lis = list(itertools.permutations(list(range(2,n+1))))

def sati(x):
  #xはリスト[4,5,7]
  now=1
  for i in range(n-1):
    if not (x[i] in edge[now]):
      return 0
    now=x[i]
  return 1
ans=0
for i in all_lis:
  ans+=sati(i)
print(ans)

Measured memory_bytes: 74264
#include<stdio.h>

int main(){
	int car[10]={0,0,0,0,0,0,0,0,0,0};
	int a,c=0;
	
	while(~scanf("%d",&a)){
		if(a==0){
			c--;
			printf("%d\n",car[c]);
		}
		else {
			car[c]=a;
			c++;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <math.h>
#include <string>
#include <string.h> 
#include <stdio.h>
#include <algorithm>
using namespace std;
#define MAX 200000
#define REP(i, n) for(int i = 0;i < n;i++)
#define IN2(n,k) scanf("%d%d",&n,&k);

int main(){
    int h,w;
    char a[100];
    IN2(h,w);
    REP(i,h+2){
        if(i==0||i==h+1){
            REP(j,w+2)printf("#");
            printf("\n");
        }
        else {
            scanf("%s",a);
            printf("#%s#\n",a);
        }
    }
    return 0;    
}


Measured memory_bytes: 256
import itertools
import copy

h, w, k = map(int, input().split())
lst = []
for i in range(h):
    ci = list(input())
    lst.append(ci)

ans = 0
for htuple in itertools.product([0, 1], repeat=h):
    temp = copy.deepcopy(lst)
    for i in range(h):
        if htuple[i] == 1:
            temp[i] = ['r'] * w
    for wtuple in itertools.product([0, 1], repeat=w):
        wtemp = copy.deepcopy(temp)
        for j in range(w):
            if wtuple[j] == 1:
                for l in range(h):
                    wtemp[l][j] = 'r'
        current = 0
        for i in range(h):
            for j in range(w):
                if wtemp[i][j] == '#':
                    current += 1
        if current == k:
            ans += 1
print(ans)

Measured memory_bytes: 78364
S = input()
cnt = 0
ans = [0]*len(S)

for i in range(len(S)-1):
    cnt += 1
    if S[i] == 'R' and S[i+1] == 'L':
        r = cnt - int(cnt/2) 
        l = int(cnt/2)
        p = i
        ans[p] += r
        ans[p+1] += l
        cnt = 0
    if S[i] == 'L' and S[i+1] =='R':
        r = int(cnt/2)
        l = cnt - int(cnt/2) 
        ans[p] += r
        ans[p+1] += l
        cnt = 0

ans[p] += int((cnt+1)/2)
ans[p+1] += (cnt+1) - int((cnt+1)/2)

for j in range(len(ans)):
    print(str(ans[j]),end=" ")

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

int32_t main()
{

	int k;
	cin >> k;
	string s;
	cin >> s;
	int n = s.size();
	if (n <= k)
	{
		cout << s << endl;
	} else
	{
		//vector<string>v;
		for (int i = 0; i < k; i++)
		{
			cout << s[i];
		}
		cout << "..." << endl;
	}
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N, K;
    string S;
    cin >> N >> K >> S;
    vector<pair<int, int>> v;
    int prevState = S[0] - '0';
    int num = 0;
    rep(i, 0, N)
    {
        const int state = S[i] - '0';
        if (state == prevState)
        {
            ++num;
        }
        else
        {
            v.push_back(make_pair(prevState, num));
            num = 1;
        }
        prevState = state;

        if (i == N - 1)
        {
            v.push_back(make_pair(prevState, num));
        }
    }

    vector<int> accumulate(v.size() + 1);
    accumulate[0] = 0;
    rep(i, 0, v.size())
    {
        accumulate[i + 1] = accumulate[i] + v[i].second;
    }

    int ans = 0;

    if (v[0].first == 0)
    {
        if ((K - 1) * 2 + 2 < accumulate.size())
        {
            ans = accumulate[(K - 1) * 2 + 2];
        }
        else
        {
            ans = accumulate[accumulate.size() - 1];
        }
    }

    rep(i, 0, v.size())
    {
        if (v[i].first == 1)
        {
            int num = 0;
            if (i + 1 + K * 2 < accumulate.size())
            {
                num = accumulate[i + 1 + K * 2];
            }
            else
            {
                num = accumulate[accumulate.size() - 1];
            }

            num -= accumulate[i];

            chmax(ans, num);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1604
n=int(input())
a= list(map(int, input().split())) 
b= list(map(int, input().split())) 
c= list(map(int, input().split())) 
ans1=0
for i in range(1,n):
    if a[i]==a[i-1]+1:
        ans1+=c[a[i-1]-1]
print(sum(b)+ans1)

Measured memory_bytes: 3064
#include <fstream>
#include <numeric>
#include <unordered_set>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
 
using namespace std;
 
#define ll long long
const int N = (ll)(2e5) + 100;

int a[N + 1];

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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

void solve() {
    int x;cin >> x;
    int l = lcm(2, x);
    cout << l << " ";
}
 
int main() {
    solve();
    return 0;
}

// 41 59 31
// 59 41 31
// 31 41 59


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}
ll lcm(ll a, ll b) {return (a*b)/__gcd(a, b); }



void solve()
{
    ll n, p;
    cin >> n >> p;
    p %= 2;
    ll e = 0, o = 0;
    ll pw[55];
    pw[0] = 1;
    for(ll i = 1; i < 55 ;i++) pw[i] = pw[i-1]*2;

    rep(i, n)
    {
        ll x; cin >> x; x %= 2;
        if(x) o++;else e++;
    }
    ll ans = 0;
    ll k1 = pw[e], k2 = 0;
    if(p)
    {
        if(o == 0) {}
        else k2 = pw[o-1];
    }
    else {
        if(o == 0) {k2 = 1;}
        else if(o > 1)k2 = pw[o-1];
    }
    cout << k1*k2;
}

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


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

using namespace std;
typedef long long ll;

const int N = int(1e5) + 7;
int ANS[N];
void init(){

}

void solve(){
    char c[N];
    scanf("%s", c);
    int n = strlen(c);
    int pos = 0;
    for(;;){
        int left_left, left_right, right_right = pos, right_left = pos;
        while(pos < n-1 && c[pos+1] == 'R'){
            pos++;
            right_right++;
        }
        left_right = ++pos;
        left_left = pos;
        while(pos < n-1 && c[pos+1] == 'L'){
            pos++;
            left_right++;
        }
        int odd, even;
        if(right_right%2 == 1){
            odd = right_right;
            even = left_left;
        }
        else{
            odd = left_left;
            even = right_right;
        }
        for(int i = right_left; i <= left_right; i++){
            if(i%2 == 0) ANS[even]++;
            else ANS[odd]++;
        }
        if(left_right == n-1) break;
        pos++;
    }
    for(int i = 0; i < n; i++)
        printf("%d ", ANS[i]);
}

int main(){
    int test_cases_number = 1;
//    scanf("%d", &test_cases_number);
    for(int i = 0; i < test_cases_number; i++)
        solve();
}


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

namespace AtCoder.ABC121.B
{
    class Program
    {
        static void Rep(int n, Action<int> action) { for (var i = 0; i < n; ++i) { action(i); } }
        static void Rep(int n, int s, Action<int> action) { for (var i = s; i < n; ++i) { action(i); } }

        public static void Main()
        {
            // Solve(3, 2, 2, 1);
            // Solve(5, 5, 2, 3);
            // Solve(2, 4, 2, 4);

            // Solve(2, 3, -10, new int[] { 1, 2, 3 }, new int[,] { { 3, 2, 1 }, { 1, 2, 2 } });

            // return;

            var str1 = Console.ReadLine().Split(' ');
            var N = int.Parse(str1[0]);
            var M = int.Parse(str1[1]);
            var C = int.Parse(str1[2]);
            var str2 = Console.ReadLine().Split(' ');
            var Bs = new int[M];
            Rep(M, i =>
            {
                Bs[i] = int.Parse(str2[i]);
            });
            var As = new int[N, M];
            Rep(N, i =>
            {
                var str3 = Console.ReadLine().Split(' ');
                Rep(M, j =>
                {
                    As[i, j] = int.Parse(str3[j]);
                });
            });
            Solve(N, M, C, Bs, As);
        }

        static void Solve(int N, int M, int C, int[] Bs, int[,] As)
        {
            int count = 0;
            Rep(N, i =>
            {
                var sum = 0;
                Rep(M, j =>
                {
                    sum += As[i, j] * Bs[j];
                });
                if (sum + C > 0)
                {
                    ++count;
                }
            });
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node *Node;
#define NIL NULL

Node root;

Node find(Node u,int k){
  while(u != NIL && k != u->key){
    if(k < u->key)u=u->left;
    else u=u->right;
}
  return u;
}
void insert(int k){

  Node y=NIL;
  Node x=root;
  Node z;

  z=malloc(sizeof(struct node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;

  while(x != NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key < y->key){
      y->left = z;
    }else {
      y->right=z;
    }
  }
}

void inorder(Node u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  char com[20];


  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",com);
    if(com[0]=='f'){
      scanf("%d",&x);
      Node t=find(root,x);
      if(t != NIL)printf("yes\n");
      else printf("no\n");
    }else if(com[0]=='i'){
      scanf("%d",&x);
      insert(x);
    }else if(com[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}




Measured memory_bytes: 20524
main=do
 getLine
 xy<-map(map read.words).lines<$>getContents
 print$f 1 1 xy
f a b[]=a+b
f a b([x,y]:xy)=f(c*x)(c*y)xy where c=max((a+x-1)`div`x)((b+y-1)`div`y)

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

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef complex<double> P;
static const double EPS = 1e-8;
static const int INF = (int)1e8;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) for (int i=0; i<(int)(n); ++i)
#define FOREQ(i,k,n) for (int i=(k); i<=(int)(n); ++i)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FIND(m,w) ((m).find(w)!=(m).end())
int MAX_N = 1000001;
int main(void){
  int dp[MAX_N];
  int dp2[MAX_N];
  vector<int> four;
  REP(i,MAX_N) dp[i] = INF;
  REP(i,MAX_N) dp2[i] = INF;
  dp[0] = 0;
  dp2[0] = 0;
  for(int i=1; i*(i+1)*(i+2)/6<=MAX_N; i++){
    four.push_back(i*(i+1)*(i+2)/6);
  }
  REP(i,four.size())FOR(j,four[i],MAX_N){
    dp[j] = min(dp[j],dp[j-four[i]]+1);
    if(four[i]%2) dp2[j] = min(dp2[j],dp2[j-four[i]]+1);
  }
  int N;
  while(cin>>N,N)cout<<dp[N]<<" "<<dp2[N]<<endl;
  return 0;
}

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

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


signed main() {
  int N, A;
  cin >> N;

  vector<pair<int, int>> vec(N);
  REP(i, N){
    cin >> A;
    vec[i] = make_pair(A, i+1);
  }

  sort(ALL(vec));

  REP(i, N){
    cout << vec[i].second;
    SPBR(i, N);
  }

  return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  int moda=a%b;
  bool ans=false;
  while(1){
    //cout<<moda<<endl;
    if(moda==c){
      ans=true;
      break;
    }
    if(moda==0) break;
    moda=(moda+a)%b;
  }
  if(ans) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int Mod=1e9+7;
int s,f[2001];
int main()
{
	cin>>s;
	f[3]=1;
	for(int i=4;i<=s;i++)
		f[i]=(f[i-3]+f[i-1])%Mod;
	cout<<f[s];
}

Measured memory_bytes: 3644
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	var n, h int
	fmt.Scan(&n, &h)
	a := make([]int, n)
	b := make([]int, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
		sc.Scan()
		b[i], _ = strconv.Atoi(sc.Text())
	}
	amax := a[0]
	for _, e := range a {
		if amax < e {
			amax = e
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(b)))
	ans := 0
	for _, e := range b {
		if amax < e {
			h -= e
			ans++
			if h <= 0 {
				break
			}
		}
	}
	if h > 0 {
		ans += (h + amax - 1) / amax
	}
	fmt.Println(ans)
}


Measured memory_bytes: 4608
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i, n)for(int i=0; i<n; i++)

int main(){
  int X, Y, Z;
  cin >> X >> Y >>Z;

  cout << Z << " "<<X<<" "<<Y<<endl;;



  return 0;
}


Measured memory_bytes: 768
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            sum += a[i];
        }
        Arrays.sort(a);
        for (int i = n - 1; i > n - 1 - m; i--) {
            if (a[i] < (double) sum / (4 * m)) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }

}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

#define INF (1<<(4*4-1))
#define MOD 1000000007


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

   ll N,W;
   cin>>N>>W;
   vector<int>w(N),v(N);
   for(int i=0;i<N;i++)cin>>w[i]>>v[i];

   vector<vector<ll> > dp(N+1,vector<ll>(100001,1<<30));
   dp[0][0] = 0;

   for(int i=1;i<=N;i++){
      for(int j=0;j<=100000;j++){
         if(j-v[i-1]>=0)dp[i][j] = min(dp[i-1][j],dp[i-1][j-v[i-1]]+w[i-1]);
         else dp[i][j] = dp[i-1][j];
      }
   }

   //for(auto it:dp[N])cout<<it<<endl;
   int ans = 0;
   for(int i=0;i<=N;i++){
      for(int j=0;j<=100000;j++){
         if(dp[i][j]<=W){
            //cout<<W<<" "<<dp[i][j]<<" "<<i<<" "<<j<<endl;
            ans = max(ans,j);
         }
      }
   }

   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, x, y, a=1000000000;
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> x;
        y = 0;
        while(x % 2 == 0 && x > 1) {
            y++;
            x /= 2;
        }
        if(y<a) a = y;
    }
    cout << a << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#define REP(i, a, b) for (auto i = (a); i < (b); ++i)
using namespace std;

const int inf = 1e9;
const int N = 600;
bool adj[N][N];
int deg[N];
double E[N][2];

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

	int n, m; cin >> n >> m;

	while(m--) {
		int s, t; cin >> s >> t; --s, --t;
		adj[s][t] = 1;
		++deg[s];
	}

	auto solve = [&](bool b) {
		REP(k, 1, n) {
			int i = n - k - 1;
			E[i][b] = 0;
			REP(j, i + 1, n - 1)
				if (adj[i][j])
					E[i][b] += E[j][b];
			E[i][b] /= deg[i];
			++E[i][b];
		}
	};

	solve(0);
	double ans = E[0][0];

	REP(i, 0, n - 1) {
		if (deg[i] == 1) continue;

		int mxpos; double mx = -1;
		REP(j, i + 1, n)
			if (adj[i][j])
				if (mx < E[j][0]) {
					mxpos = j;
					mx = E[j][0];
				}

		--deg[i]; adj[i][mxpos] = 0;
		solve(1);
		++deg[i]; adj[i][mxpos] = 1;

		ans = min(ans, E[0][1]);
	}

	cout << fixed << setprecision(10) << ans;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) throws IOException {

    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

    while (input.ready()) {
      String data = input.readLine();
      String alterString = "";
      boolean okFlag = false;
      for (int i = 1; i < 27; i++) {
        alterString = getCeaserCipherString(data, i);
        for (String eachString : alterString.split(" ")) {
          if (eachString.equals("the") | eachString.equals("this") | eachString.equals("that")) {
            okFlag = true;
            break;
          }
        }
        if (okFlag) {
          System.out.println(alterString.trim());
          break;
        }
      }
    }
  }

  private static String[] getCeaserCipherString(String[] stringArray, int replaceNum) {
    String[] retStringArray = new String[stringArray.length];
    for (int i = 0; i < stringArray.length; i++) {
      String eachString = stringArray[i];
      String afterString = "";
      char[] charArray = eachString.toCharArray();
      for (char eachChar : charArray) {
        afterString += getCeaserCipherChar(eachChar, replaceNum);
      }
      retStringArray[i] = afterString;
    }
    return retStringArray;
  }

  private static String getCeaserCipherString(String string, int replaceNum) {
    String retString = "";
    char[] charArray = string.toCharArray();
    for (char eachChar : charArray) {
      retString += getCeaserCipherChar(eachChar, replaceNum);
    }
    return retString;
  }

  public static char getCeaserCipherChar(char c, int replaceNum) {
    ArrayList<Character> abcArray = new ArrayList<>(
        Arrays.asList('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
            's', 't', 'u', 'v', 'w', 'x', 'y', 'z'));

    if (c == '.' | c == ' ')
      return c;

    int indexBefor = abcArray.indexOf(c);

    if (indexBefor + replaceNum >= abcArray.size()) {
      return abcArray.get(indexBefor + replaceNum - abcArray.size());
    } else {
      return abcArray.get(indexBefor + replaceNum);
    }
  }
}

Measured memory_bytes: 28008
use proconio::{fastout, input};

const FACT_MAX: usize = 300000;
const MOD: i64 = 998244353;

#[allow(dead_code)]
fn pow_mod(base: i64, power: i64, modulo: i64) -> i64 {
    let mut base = base;
    let mut power = power;
    let mut ans = 1;
    while power > 0 {
        if power & 1 == 1 {
            ans = ans * base % modulo;
        }
        power >>= 1;
        base = base * base % modulo;
    }
    ans
}

thread_local! {
    #[allow(unused)]
    pub static FACT: Vec<i64> = {
        let mut fac: Vec<i64> = vec![1; FACT_MAX+1];

        for i in 1..FACT_MAX+1 {
            fac[i] = (fac[i-1] * i as i64) as i64 % MOD;
        }
        fac
    };

    #[allow(unused)]
    pub static RFACT: Vec<i64> = {
        let mut rfac = vec![1; FACT_MAX+1];
        rfac[FACT_MAX] = FACT.with(|fact| {
            pow_mod(fact[FACT_MAX], MOD-2, MOD)
        });

        for i in (1..FACT_MAX).rev() {
            rfac[i] = (rfac[i+1] * (i+1) as i64) % MOD;
        }
        rfac
    }
}

#[allow(dead_code)]
fn combi(n: usize, m: usize) -> i64 {
    FACT.with(|fact| RFACT.with(|rfact| fact[n] * rfact[n - m] % MOD * rfact[m] % MOD))
}

#[fastout]
fn main() {
    input! {
        (n,m,k): (usize, usize, usize)
    };

    let mut cc = vec![0i64; 3 * 100000];
    cc[1] = m as i64;

    for i in 2..cc.len() {
        cc[i] = cc[i - 1] * ((m - 1) as i64) % MOD;
    }

    let mut ans = 0;

    for i in 0..=k {
        ans += combi(n - 1, n - 1 - i) * cc[n - i];
        ans %= MOD;
    }

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


Measured memory_bytes: 9212
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;


int main(){
  int a,b;
  double t;
  cin >> a >> b >> t;
  int ans = 0;
  double time = a;
  while(time <= t+0.5){
    ans += b;
    time += a;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long area(long long a,long long b){
    long long sa,sb,sc,sbb,scc;
    long long ans=1e9;
    for(int i=1;i<a;i++){
        sa=i*b;
        sb=(a-i)/2*b;
        sc=(a-(a-i)/2-i)*b;
        sbb=(a-i)*(b/2);
        scc=(a-i)*(b-b/2);
        ans=min({ans,max({sa,sb,sc})-min({sa,sb,sc}),max({sa,sbb,scc})-min({sa,sbb,scc})});
    }
    return ans;
}
int main() {
    long long h,w;
    cin >> h >> w;
    long long ans1,ans2;
    ans1=area(h,w);
    ans2=area(w,h);
    cout << min(ans1,ans2) << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //a
  int a;
  string s;
  cin >> a >> s;
  if (a >= 3200) cout << s << endl;
  else cout << "red" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste

// #include "UnionFind.hpp"
// #include "power.hpp"

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> V(N), C(N);
    for (int i = 0; i < N; i++) {
        cin >> V[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> C[i];
    }
    int ans = 0;
    for (int i = 0; i < (1<<N); i++) {
        int value = 0, cost = 0;
        for (int j = 0; j < N; j++) {
            if (i & (1 << j)) {
                value += V[j];
                cost += C[j];
            }
        }
        ans = max(ans, value - cost);
    }
    cout << ans << endl;
}


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

const ll INF = (ll)1e15;

ll f(ll x,ll y){
    return (y-x>=0)?y-x:INF;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x,y;cin>>x>>y;
    ll ans = min(min(f(x,y),f(x,-y)+1),min(f(-x,y)+1,f(-x,-y)+2));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
// 2020-08-24 21:07:14
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, ll>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  int n, a, b;
  cin >> n >> a >> b;
  vector<ll> v(n);
  rep(i, n) cin >> v[i];
  sort(RALL(v));
  int mc = 0;
  ll mv = 0;
  ll last = 1e18;
  auto update = [&](int c, ll w) {
    if(mv * c < w * mc) {
      mc = c;
      mv = w;
      return true;
    }
    return false;
  };
  {
    ll cur = 0;
    rep(i, a) cur += v[i];
    mc = a;
    mv = cur;
    last = v[a-1];
    REP(i, a, b) {
      cur += v[i];
      if(update(i+1, cur)) last = v[i];
    }
    ld ans = ld(mv) / ld(mc);
    cout << fixed << setprecision(6) << ans << '\n';
  }
  if(v[0] == last) {
    ll cnt = 0;
    rep(i, n) cnt += (v[i] == last);
    ll ans = 0, now = 1;
    REPC(i, 1, min(cnt, ll(b))) {
      now = now * (cnt-i+1) / i;
      if(a <= i) ans += now;
    }
    cout << ans << '\n';
  } else {
    ll rem = a, cnt = 0;
    rep(i, n) {
      if(v[i] > last) rem--;
      else if(v[i] == last) cnt++;
      else break;
    }
    ll ans = 1;
    REPC(i, 1, rem) ans = ans * (cnt-i+1) / i;
    cout << ans << '\n';
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3844
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1'000'000'000ll + 7;
//const i64 smod = 998244353ll;
//const i64 inf = 1'000'000'000'000'000'000ll + 7;
//const i64 inf = 1'000'000'007;

const long double eps = 1e-8;

const i64 MAXN = 300'000 + 6;
const i64 MAXM = 502;

i64 n;

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    string s;
    cin >> s;
    for (i64 i = 0; i < s.size(); i++) {
        if (s[i] == '?') {
            s[i] = 'D';
        }
    }

    cout << s << endl;

    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

ll f(ll n){
    ll sum=0;
    for(int i=1;i<=n;i++){
        if(n%i==0) ++sum;
    }
    return sum;
}

int main(void)
{
    ll n,l; cin>>n>>l;
    vector<string> s(n);
    rep(i,n) cin>>s[i];
    sort(all(s));
    string ans;
    rep(i,n) ans+=s[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
import sys
import math

def is_prime(x):
    if x == 2:
        return True

    if (x == 1) or (x % 2 == 0):
        return False

    for i in range(3, math.ceil(math.sqrt(x))+1, 2):
        if x % i == 0:
            return False

    return True
    
if __name__ == '__main__':
    element_number = int(input())

    output = 0
    for x in map(int, sys.stdin.readlines()):
        if(is_prime(x)):
            output += 1

    print(output)

Measured memory_bytes: 8172
import sys
import math

n, d = [ int(x) for x in sys.stdin.readline().split() ]
r = []
for _ in range(n): r.append( [ int(x) for x in sys.stdin.readline().split() ] )

count = 0
for i in range(n):
    ri = r[i]
    for j in range(i+1,n):
        rj = r[j]
        #
        d2 = 0
        for k in range(d):
            d2+= (ri[k]-rj[k])**2
        #
        sq = math.sqrt(d2)
        if abs(int(sq)-sq)<1.e-10: count+=1
#
print( count )

Measured memory_bytes: 3064
//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int ans=0;
    long long  a,b;
    cin>>a>>b;
    if(a<10 && b<10)
        cout<<a*b<<endl;
    else
        cout<<-1<<endl;


}




Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define lp(n) for(int i = 0; i < n; i++)
#define lpp(i, n) for(int i = 0; i < n; i++)

int A[2000001];
int B[2000001];
int C[10001];
using namespace std;
int main() {
    int n;
    scanf("%d", &n);
    
    lp(n) {
      cin >> A[i];
      C[A[i]]++;
    }
    for(int i = 1; i < 10001; i++) C[i] = C[i] + C[i-1];
    for(int i = n-1; i >= 0; i--) {
        B[C[A[i]]] = A[i];
        C[A[i]]--;
    }
    for(int i = 1; i <= n; i++) cout << B[i] << ((i == n)?"\n":" ");
    return 0;
}






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

int main(void) {
  //input
  int A, B;
  cin >> A >> B;
  //calc
  int answer = A > B*2 ? (A-B*2) : 0;
  //output
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>

using namespace std;

int main()
{
    int N,X;
    cin >> N >> X;
    vector<int> donut(N);
    for(int i=0; i<N; i++){
        cin >> donut[i];
        X-=donut[i];
    }
    sort(donut.begin(), donut.end());
    cout << N+X/donut[0];

    return 0;
}

Measured memory_bytes: 632
import sys
input = sys.stdin.readline
H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))
c = [[0] * W for _ in range(H)]
tour = [[0] * W for _ in range(H)]
s = []
s.append([0, 0])
ss = []
ss.append([0, 0])
tour[0][0] = 1
t = 0
counter = 1
while counter < H * W:
  counter += 1
  p = s.pop()
  n = [-1, -1]
  while not (0 <= n[0] < H and 0 <= n[1] < W and tour[n[0]][n[1]] == 0):
    if t == 0:
      n = [p[0] + 1, p[1]]
    elif t == 1:
      n = [p[0], p[1] + 1]
    elif t == 2:
      n = [p[0] - 1, p[1]]
    else:
      n = [p[0], p[1] - 1]
    if 0 <= n[0] < H and 0 <= n[1] < W and tour[n[0]][n[1]] == 0:
      break
    else:
      t = (t + 1) % 4
  s.append(n)
  tour[n[0]][n[1]] = tour[p[0]][p[1]] + 1
  ss.append(n)
#print(tour, ss, c)
for i in range(N):
  for _ in range(a[i]):
    p = ss.pop()
    #print(p)
    c[p[0]][p[1]] = i + 1
for i in range(H):
  print(*c[i])

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

void solve(){
    set<string> st;
    string s;
    cin>>s;
    rep(i,0,sz(s)+1){
        string t;
        int v[26]={0};
        rep(j,0,i){
            t+=s[j];
            v[s[j]-'a']=1;
        }
        rep(j,0,26){
            if(v[j]) continue;
            if('a'+j>s[i]){
                t+='a'+j;
                st.insert(t);
            }
        }
    }
    if(sz(st)) cout<<*st.begin()<<endl;
    else cout<<-1<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define CLR(a,x) memset(a,x,sizeof(a))
#define MP make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pa;
const int maxn=3005,P=1e9+7;

inline ll rd(){
    ll x=0;char c=getchar();int neg=1;
    while(c<'0'||c>'9'){if(c=='-') neg=-1;c=getchar();}
    while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*neg;
}

int N,M,f[maxn][maxn][2];

inline void upd(int &a,int b){a=(a+b)%P;}

int main(){
    //freopen("","r",stdin);
	N=rd(),M=rd();
	for(int i=0;i<=N;i++) f[0][i][i==0]=1;
	for(int i=0;i<M;i++){
		for(int j=0;j<=N;j++){
			for(int k=0;k<=1;k++){
				if(j<N) upd(f[i+1][j+1][k],f[i][j][k]),upd(f[i+1][j][k],f[i][j][k]);;
				if(j>=1) upd(f[i+1][j-1][k|(j==1)],f[i][j][k]),upd(f[i+1][j][k|(j==1)],f[i][j][k]);
			}
		}
	}
	int ans=0;
	for(int i=0;i<=N;i++) upd(ans,f[M][i][1]);
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{  
    ll n;
    cin>>n;
    ll i,j;
    ll a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }

    for(i=0;i<n;i++)
    {
        if(a[i]%2==0)
        {
            if(a[i]%3==0||a[i]%5==0)
            {
                continue;
            }
            cout<<"DENIED\n";
            return;
        }
    }
    cout<<"APPROVED\n";
}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 3628
#include<algorithm>
#include<cstdio>
#include<cstring>

const int Maxv = 100010; 
int l[Maxv << 1], r[Maxv << 1], n; 
long long ans; 

inline int read(){
    int x = 0, f = 1; 
    char ch = getchar(); 
    while (ch < '0' || ch > '9') {
        if (ch == '-') {
            f = -1; 
        }
        ch = getchar(); 
    }
    while (ch >= '0' && ch <= '9') {
        x = (x << 3) + (x << 1) + ch - '0'; 
        ch = getchar(); 
    }
    return x * f; 
}

int main(){
    n = read(); 
    for (int i = 1; i <= n; i++) {
        int L = read(); 
        int R = read(); 
        l[Maxv + R]++; 
        r[Maxv + L]++; 
    }
    l[Maxv]++; 
    r[Maxv]++; 
    for (int i = 1; i < 2 * Maxv; i++) {
        l[i] += l[i - 1]; 
    }
    for (int i = 2 * Maxv - 2; i >= 0; i--) {
        r[i] += r[i + 1]; 
    }
    for (int i = 0; i < 2 * Maxv - 1; i++) {
        ans += std::min(l[i], r[i + 1]) * 2; 
    }
    printf("%lld\n", ans); 
    return 0; 
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<int> a(n);
    REP(i,n) cin>>a[i];
    int ans=0;
    sort(a.begin(),a.end());
    double val=a[n-1]*1.000/2;
    double mi=INF;
    REP(i,n-1){
        if(abs(val-a[i])<mi) chmin(mi,abs(val-a[i])),ans=a[i];
    }
    cout<<a[n-1]<<" "<<ans<<endl;
}


Measured memory_bytes: 640
public class Program
    {
        static void Main(string[] args)
        {
            string[] inputs = System.Console.ReadLine().Split(' ');
            int a = int.Parse(inputs[0]);
            int b = int.Parse(inputs[1]);
            if (a < b)
            {
                System.Console.WriteLine("a < b");
            }
            if (a > b)
            {
                System.Console.WriteLine("a > b");
            }
            if (a == b)
            {
                System.Console.WriteLine("a == b");
            }

        }
    }


Measured memory_bytes: 8884
#include "bits/stdc++.h"

// Begin Header {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

#define all(x) x.begin(), x.end()
#define rep(i, n) for (intmax_t i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (intmax_t i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (intmax_t i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

constexpr size_t    operator""_zu(unsigned long long value) { return value; };
constexpr intmax_t  operator""_jd(unsigned long long value) { return value; };
constexpr uintmax_t operator""_ju(unsigned long long value) { return value; };

constexpr int INF = 0x3f3f3f3f;
constexpr intmax_t LINF = 0x3f3f3f3f3f3f3f3f_jd;

template <class T, class Compare = less<>>
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template <class T, class Compare = greater<>>
using MinHeap = priority_queue<T, vector<T>, Compare>;

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

template <class T>
inline istream& operator>>(istream &is, vector<T> &vec) {
    for (auto &e: vec) {
        is >> e;
    }
    return is;
}

inline void output() { cout << "\n"; }
template <class Head, class... Tail>
inline void output(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) {
        cout << " ";
    }
    output(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e: vec) {
        os << e << delim[&e == &vec.back()];
    }
    return os;
}

template <class T>
inline vector<T> makeVector(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeVector(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeVector<T>(initValue, args...))>(sz, makeVector<T>(initValue, args...));
}

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

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

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

template <class T>
inline T diff(const T &a, const T &b) noexcept {
    return a < b ? b - a : a - b;
}
// End Header }}}

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

    var(intmax_t, H, N);

    vector<intmax_t> a(N);
    input(a);

    intmax_t sum = 0;
    for (const auto e: a) {
        sum += e;
    }

    cout << ((H - sum <= 0) ? "Yes" : "No") << "\n";

    return 0;
}


Measured memory_bytes: 1024
# list: ソート済配列
# n: 参照番号
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

N = int(input())
T = [int(input()) for i in range(N)]
ans = 1

for i in range(N):
    ans = lcm(ans, T[i])

print(ans)


Measured memory_bytes: 3060
// ダイクストラ法
// Dijkstra's Algorithm
// priority_queue
// Single Source Shortest Path 2 単一始点最短経路
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <vector>
using namespace std;

static const int MAX = 10000;
static const int INF = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int, int>> adj[MAX]; //重み付き有向グラフ

void dijkstra() {

    priority_queue<pair<int, int>> PQ;
    int d[MAX], color[MAX];

    for(int i = 0; i < n; i++) {
        d[i] = INF;
        color[i] = WHITE;
    }

    d[0] = 0;
    PQ.push(make_pair(0, 0));
    color[0] = BLACK;

    while (!PQ.empty()) {
        
        pair<int, int> f = PQ.top();
        PQ.pop();
        int u = f.second;

        color[u] = BLACK;

        // 最小値を取り出し、それが最短でなければ無視
        if (d[u] < f.first * (-1)) continue;

        for(int j = 0; j < adj[u].size(); j++) {
            int v = adj[u][j].first;
            
            if (color[v] == BLACK) continue;

            if (d[v] > d[u] + adj[u][j].second) {
                d[v] = d[u] + adj[u][j].second;
                // priority_queueのため-1を掛ける
                PQ.push(make_pair(d[v]*(-1), v));
                color[v] = GRAY;
            }
        }
    }

    for(int i = 0; i < n; i++) {
        cout << i << " " << (d[i] == INF ? -1 : d[i]) << endl;
    }
}

int main() {

    cin >> n;
    int k, c, u, v;

    for(int i = 0; i < n; i++) {
        cin >> u >> k;
        for(int j = 0; j < k; j++) {
            cin >> v >> c;
            adj[u].push_back(make_pair(v, c));
        }
    }


    dijkstra();

    return 0;
}



Measured memory_bytes: 8024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,i,k=1,count=0;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++)
        cin>>arr[i];
    for(i=0;i<n;i++){
        if(arr[i]!=k)
            count+=1;
        else
            k+=1;
    }
    if(k==1)
        cout<<"-1"<<endl;
    else
        cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 1792
def func (S, T, U, N):
  cnt = []
  for i in range(N):
    if S[i] == T[i] and S[i] == U[i]:
      cnt.append(0)
    elif S[i] == T[i] or S[i] == U[i] or T[i] == U[i]:
      cnt.append(1)
    else:
      cnt.append(2)
      
  return cnt


N = int(input())
A = input()
B = input()
C = input()

print(sum(func(A, B, C, N)))

Measured memory_bytes: 3064
S = input()
#a = [int(i) for i in input().split()]
#s = [[int(j) for j in input().split()] for i in range(N)]

res = True
if S[0]!='A':
    res = False
if S[2:-1].count('C')!=1:
    res = False
cnt = 0
for c in S:
    if ord('a')<= ord(c) and ord(c) <= ord('z'):
        cnt+=1
if cnt!=len(S)-2:
    res=False


if res:
    print("AC")
else:
    print("WA")


Measured memory_bytes: 3060