akhauriyash/Code-Regression huggingface dataset:
package main
import (
	"fmt"
)
func main(){
	var n int
	fmt.Scan(&n)
	var ap, bp int
	for i:=0; i<n; i++{
		var a, b string
		fmt.Scan(&a, &b)
		if a>b{
			ap+=3
		}else if a<b{
			bp+=3
		}else{
			ap+=1
			bp+=1
		}
	}
	fmt.Println(ap, bp)
}


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

int main() {
  int A, B;
  cin >> A >> B;
  
  if (A >= 13) {
  	cout << B << endl;
  }
  
  else if (A >= 6) {
  	cout << B / 2 << endl;
  }
  
  else {
  	cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll, ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // Emily <3
  int l, r;
  cin >> l >> r;
  if (r - l > 2025) {
    cout << 0 << nl;
  } else {
    //brute force
    ll ans = INF;
    for (ll i = l; i <= r; ++i) {
      for (ll j = i+1; j <= r; ++j) {
        ans = min(ans, (i*j) % 2019);
      }
    }
    cout << ans << nl;
  }
  
  cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int N, T;
	cin >> N >> T;
	int minc = INF;
	for( int i = 0; i < N; ++i ){
		int c, t;
		cin >> c >> t;
		if( t <= T ){
			minc = min( minc, c );
		}
	}
	if( minc == INF ){
		cout << "TLE" << endl;
	} else {
		cout << minc << endl;
	}
	return 0;
}

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

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll p,q,r;
  cin >> p >> q >>r;
  ll a=max(max(p,q),r);
  cout << p+q+r-a << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
int binary(int,int,int *);
int main(){
  int i,n,s[100000],cnt=0,t[50000],q;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&s[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&t[i]);
    cnt+=binary(n,t[i],s);
  }
  printf("%d\n",cnt);
  return 0;
}
int binary(int n,int t,int *s){
  int mid,left,right;
  right=n;
  left=0;
  while(right>left){
    mid=(right+left)/2;
    if(s[mid]==t)return 1;
    else if(s[mid]>t)right=mid;
    else if(s[mid]<t)left=mid+1;
  }
  return 0;
}


Measured memory_bytes: 2292
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int count = 0;

		int num500 = scan.nextInt();
		int num100 = scan.nextInt();
		int num50 = scan.nextInt();
		int xYen = scan.nextInt();

		for(int i = 0; i <= num500; i++) {
			for(int j = 0; j <= num100; j++) {
				for(int k = 0; k <= num50; k++) {
					if(500 * i + 100 * j + 50 * k == xYen)
						count++;
				}
			}
		}

		System.out.println(count);
		scan.close();
	}

}

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

    using namespace std;

    int main()
    {
        int n,even=0,count=0;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++)cin>>a[i];
        for(int i=0;i<n;i++){
            if(a[i]%2==0){even++;
                if(a[i]%3==0||a[i]%5==0)count++;

            }
        }if(even==count&&even!=0)cout<<"APPROVED";
        else if(even==count&&even==0)cout<<"APPROVED";
        else cout<<"DENIED";
        return 0;
    }

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;

class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        Map<Integer, Integer> map = new HashMap<>();
        int n = sc.nextInt();
        int k = sc.nextInt();
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            if (map.containsKey(a)) {
                map.put(a, map.get(a) + 1);
            } else {
                map.put(a, 1);
            }
        }
        if (k >= map.size()) {
            System.out.println(0);
            return;
        }
        List<Integer> list = new ArrayList<Integer>(map.values());
        Collections.sort(list);
        int count = list.size();
        int num = 0;
        for(int a : list){
            num += a;
            count--;
            if(count <= k){
                System.out.println(num);
                return;
            }
        }
    }
}

Measured memory_bytes: 100912
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 2009
#define mod 998244353
ll n,m,arr[sz],brr[sz],k,l,crr[sz],t,i,j;
char c[sz];
vector<ll>v;
int main()
{
 scanf("%lld",&n);
 l=__gcd(360ll,n);
 l=360ll/l;
 printf("%lld\n",l);
 return 0;
}


Measured memory_bytes: 3748
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdio>
#include <list>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecstr vector<string>
#define vecch vector<char>
#define vecpii vector<pii>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
vector<vector<bool>> done;
int main(){
    int h=in(),w=in(),cnt=0;
    done=vector<vector<bool>>(h,vector<bool>(w,false));
    rep(i,h){
        string s=stin();
        rep(j,w)if(s.at(j)=='#'){
            cnt++;
            done[i][j]=true;
        }
    }
    queue<pair<pair<int,int>,int>> q;
    q.push(make_pair(make_pair(0,0),1));
    while(!q.empty()){
        auto p=q.front();
        q.pop();
        int sx=p.first.first,sy=p.first.second,d=p.second;
        if(sx==h-1&&sy==w-1){
            cout<<h*w-cnt-d<<endl;
            return 0;
        }
        if(sx>0&&!done[sx-1][sy]){
            q.push(make_pair(make_pair(sx-1,sy),d+1));
            done[sx-1][sy]=true;
        }
        if(sy>0&&!done[sx][sy-1]){
            q.push(make_pair(make_pair(sx,sy-1),d+1));
            done[sx][sy-1]=true;
        }
        if(sx<h-1&&!done[sx+1][sy]){
            q.push(make_pair(make_pair(sx+1,sy),d+1));
            done[sx+1][sy]=true;
        }
        if(sy<w-1&&!done[sx][sy+1]){
            q.push(make_pair(make_pair(sx,sy+1),d+1));
            done[sx][sy+1]=true;
        }
    }
    cout<<-1<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
#define NMAX 200000

int main(void){
    int N;
    ll sum, A[NMAX + 1];
    sum = 0;

    cin >> N;
    cin >> A[0];
    
    for (int i = 1; i < N; i++){
        cin >> A[i];
        if (A[i - 1] > A[i]){
            sum += A[i - 1] - A[i];
            A[i] = A[i - 1];
        }
    }
    
    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 5172
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(abs(c - a) <= d || ((abs(b-a) <= d) && (abs(c-b) <= d)) ) cout << "Yes" << endl;
  else cout << "No";
}


Measured memory_bytes: 256
#include<stdio.h>

#define INF 1000000
#define N 100

int m[N][N],p[N],n;

int matrixChainOrder(void)
{
  int i,j,k,l,q;
  for(i=0;i<n;i++)
    {
      m[i][i]=0;
    }
  for(l=2;l<=n;l++)
    {
      for(i=1;i<=n-l+1;i++)
	{
	  j=i+l-1;
	  m[i][j]=INF;
	  for(k=i;k<j;k++)
	    {
	      q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	      m[i][j]=min(m[i][j],q);
	    }
	}
    }
  return m[1][n];
}

int min(int x,int y)
{
  if(x<y) return x;
  else return y;
}

int main()
{
  int i,j,max;
  scanf("%d",&n);
  for(i=1;i<=n;i++)
    {
      scanf("%d%d",&p[i-1],&p[i]);
    }
  
  max=matrixChainOrder();
  printf("%d\n",max);

  return 0;

}

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

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

void next_permutation(int* a, int n){
    int tmp, x=-1, y=-1, z;
    for(int i=n-1; i>0; i--){
        if(*(a+i-1) < *(a+i)){
            x = i-1;
            break;
        }
    }
    if(x==-1){
        return;
    }
    for(int i=n-1; i>=0; i--){
        if(*(a+x) < *(a+i)){
            y = i;
            break;
        }
    }
    tmp = *(a+x);
    *(a+x) = *(a+y);
    *(a+y) = tmp;
    for(int i=x+1; i<n; i++){
        z = n-(i-x);
        if(i < z){
            tmp = *(a+z);
            *(a+z) = *(a+i);
            *(a+i) = tmp;
        }else{
            break;
        }
    }
    return;
}

int main(){
    int n;
    scanf("%d", &n);
    int p[n], q[n], r[n];
    rep(i, 0, n){
        scanf("%d", &p[i]);
        r[i] = i+1;
    }
    rep(i, 0, n){
        scanf("%d", &q[i]);
    }
    int x=1, a=-1, b=-1;
    while(a==-1 || b==-1){
        /*rep(i, 0, n){
            printf("%d ", r[i]);
        }
        printf("\n");*/
        if(memcmp(p, r, sizeof(p))==0){
            a = x;
        }
        if(memcmp(q, r, sizeof(q))==0){
            b = x;
        }
        next_permutation(r, n);
        x++;
    }
    printf("%d", abs(a-b));

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/

const int mx=100010;
const ll mod=1e9+7;

vector<vector<vector<ll>>> dp(110, vector<vector<ll>>(2,vector<ll>(5,0)));
//ll dp[10010][2][110];//dp[i][j][k]:uekara i keta j=ok? k= used not0
string s;
int d;

int main(){
  cin >> s >> d;
  int sz=s.size();
  dp[0][0][0]=1;
  dp[1][0][0]=1;						//0
  dp[1][0][1]=(int)(s[0]-'0')-1;		//1~max-1
  dp[1][1][1]=1;						//max
  for(int idx=1; idx<sz; idx++)rep(k,d+1){				//i==0 ok i==1 ??
      dp[idx+1][0][k+1] += dp[idx][0][k]*9;		//use 1~9
      dp[idx+1][0][k] += dp[idx][0][k];			//use 0
      int maxi=(int)(s[idx]-'0');
      if(maxi!=0){ dp[idx+1][0][k+1] += dp[idx][1][k]*(maxi-1); } //use 1~max-1 to safe
      if(maxi!=0){ dp[idx+1][1][k+1] += dp[idx][1][k];}			//use max      
      else{ dp[idx+1][1][k] += dp[idx][1][k];}
      if(maxi!=0){ dp[idx+1][0][k] += dp[idx][1][k]; }			//use 0      
  }
  ll ans = dp[sz][0][d]+dp[sz][1][d];  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int solve(int n)
{
  int r = 0;
  while(n > 0){
    r += n % 10;
    n /= 10;
  }
  return r;
}

int main()
{
  ll n; cin >> n;
  if(n % solve(n) == 0)cout << "Yes" << endl;
  else cout << "No" << endl;
  system("pause");
}

Measured memory_bytes: 504
n =  int(input())
d = [list(map(int,input().split())) for i in range(n)]
cnt = 0

for i in range(n):
    if d[i][0] == d[i][1]:
        cnt += 1
        if cnt == 3:
            print('Yes')
            break
    else:
        cnt = 0
else:
    print('No')

Measured memory_bytes: 9116
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define M 1000000007
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
const int N = 2e3 + 5;
int main(){
	int D , T , S;
	cin >> D >> T >> S;
	if(S*T >= D)puts("Yes");
	else puts("No");
}	

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <climits>

//find out the use of the below
#include <list>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cassert>

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
vector<vector<LL> > dp(2, vector<LL>((int)1e5+1,INT_MAX));
int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt","w", stdout);
    int n, w;
    scanf("%d%d", &n, &w);
    int w0, v0;
    dp[0][0] = dp[1][0] = 0;
    int ans;
    for (int i = 1; i <=n; ++i){
        ans = 0;
        scanf("%d%d", &w0, &v0);
        for (int j = 1; j <= 1e5; ++j){
            dp[i%2][j] = dp[(i-1)%2][j];
            if (j-v0 >= 0)
                    dp[i%2][j] = min(dp[(i-1)%2][j-v0]+w0,dp[i%2][j]);
            if (dp[i%2][j] <= w)
                ans = max(ans, j);
        }
    }
    cout << ans;
    return 0;
}
/* BEFORE submitting, check for:
 *  1. Integer overflow
 *  2. Float/Double precision errors
 *  3. Array index out of bounds
 *  4. Edge cases.(n=1, n=max, etc.)
 *  5. Time complexity. No TLEs
 */



Measured memory_bytes: 3192
#include <stdio.h>
#include <string>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main(void){
    int a,b;
    cin >> a >> b;
    if(a%3==0||b%3==0||(a+b)%3==0)printf("Possible\n");
    else printf("Impossible\n");
    return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define rep(i,n)  for (int i = 0; i < n; i++)
#define loop(i,a,n)  for (int i = a; i <= n; i++)
#define deb(x) cout << #x << " = " << x <<'\n'
typedef long long ll;

int main(){
    ll n,m;
    cin >> n >> m;
    ll hsl = ((1+n)/2)*((1+m)/2) + ((n/2) * (m/2));
    if (n == 1 || m == 1) hsl = 1;
    cout << hsl << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
                            
#define ll long long
#define ld long double
#define ull unsigned ll
#define ioi exit(0);
 
#define f first
#define s second
 
#define inf (int)1e9 + 7
 
#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
 
#define mp(x,y) make_pair(x,y)
 
#define lb(x) lower_bound(x)
#define ub(x) upper_bound(x)
 
#define pb push_back
#define ppb pop_back
 
#define bitcoin __builtin_popcount
 
#define endl "\n"
 
#define in(x) insert(x)
 
#define sz(x) (int)x.size()
 
#define all(x) x.begin(),x.end()
 
#define pw2(x) (1ll<<x) //2^x
 
#define forit(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); ++it)
 
#define sqr(x) ((x) * 1ll * (x))
 
#define UpdateRandom srand (time(NULL));
 
using namespace std;
 
const int N = (int)5e5 + 7, MOD = (int)1e9 + 7;

string s;

int main(){
		
	NFS
	
	cin >> s;
	
	for(int i=0;i<sz(s);i++)if(s[i]=='?')s[i]='D';

	cout << s << endl;
	
	ioi
}

Measured memory_bytes: 3700
#include <iostream>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <math.h>
#define ll long long
ll gcd(ll a,ll b){
    ll s=1,c;
    while(a&&b){
        if((~a&1)&&(~b&1))
            a>>=1,b>>=1,s<<=1;
        else if(~a&1)a>>=1;
        else if(~b&1)b>>=1;
        else if(a>b)a=a-b;
        else c=b-a,b=a,a=c;
    }
    if(!a)return b*s;
    if(!b)return a*s;
}
using namespace std;
int main(){
	char n;ll cnt=0;
	while(cin>>n){
		cnt+=n-'0';
	}
	if(cnt%9==0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}


Measured memory_bytes: 3632
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn solve(n: i32, t: i32) -> (i32, i32, i32) {
    for x in 0..=n {
        for y in 0..=n {
            let z = n - x - y;
            if z >= 0 && 10000 * x + 5000 * y + 1000 * z == t {
                return (x, y, z);
            }
        }
    }
    (-1, -1, -1)
}

fn main() {
    input! {
        n: i32,
        t: i32,
    }

    let (x, y, z) = solve(n, t);
    println!("{} {} {}", x, y, z);
}


Measured memory_bytes: 2128
//coded by dsingh_24
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pll         pair<long long,long long>
#define vll          vector<long long>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (long long)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
	ios
    ll n,k,i,j,x,mx=0;
    cin>>n>>k;
    ll gcd;
    for(i=0;i<n;i++)
    {
    	cin>>x;
    	if(i==0)gcd=x;
    	else
    	gcd=__gcd(gcd,x);
    	if(x==k)
    	{
    		cout<<"POSSIBLE\n";return 0;
		}
		mx=max(mx,x);
	}
//	cout<<gcd<<endl;
	if(mx<k)
	{
		cout<<"IMPOSSIBLE\n";
	}else
	{
		if(k%gcd==0)cout<<"POSSIBLE\n";
    	else
    	cout<<"IMPOSSIBLE\n";
	}
	return 0;
}


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

using namespace std;

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define flu(i, s, e) for(int i = s; i < e; i++)
#define fld(i, s, e) for(int i = s; i >= e; i--)
#define ll long long
#define pb push_back
#define mk make_pair
#define maxev max_element
#define minev min_element

int main(){
	fast;

	int n, m;
  cin >> n >> m;
  int sum = 0;
  vector<int> a(n);
  flu(i, 0, n) {
    int t;
    cin >> t;
    a[i] = t;
    sum += t;
  }
 
  sort(a.rbegin(), a.rend());
  if(a[m - 1] * 4 * m >= sum) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

	return 0;
}

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


int main()
{
    int K,T;
    cin>>K>>T;
    int maxim=-1;
    for(int i=1;i<=T;i++){
        int x;
        cin>>x;
        if(x>maxim)
            maxim=x;
    }

    if(K-maxim>=maxim-1){
        cout<<"0";
    }
    else{
        cout<<maxim-1-(K-maxim);
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long N = sc.nextInt();

		long M = sc.nextInt();

		String S = sc.next();

		String T = sc.next();

		char[] s = new char[S.length()];

		char[] t = new char[T.length()];

		long gcd = 1;

		boolean flag = false;

		long c = 1;




		for(int i=0;i<S.length();i++) {

			s[i] = S.charAt(i);

		}

		for(int i=0;i<T.length();i++) {

			t[i] = T.charAt(i);

		}

		if(s[0] != t[0] ) {

			System.out.println(-1);

		}else if(S.equals(T)) {

			System.out.println(S.length());


		}else if(S.length() == T.length() && !S.equals(T)) {

			System.out.println(-1);

		}else {


			gcd = gcd(S.length(),T.length());


			long a = S.length() / gcd;

			long  b = T.length() / gcd;

			c = a * b * gcd;


			long  i = 1;

			long  e = a * b;



			while((e/a)<t.length  && (e/b)<s.length ) {


				if(t[(int)(e/a)] != s[(int)(e/b)]) {


					flag = true;

					break;
				}

				i++;

				e = (a * b) * i;



			}



			if(flag == false) {

				System.out.println(c);

			}else {

				System.out.println(-1);
			}


		}




	}

	public static long gcd(int a, int b) {

		if(b==0) return a;

		return gcd(b,a%b);
	}

}


Measured memory_bytes: 26708
n = int(input())
a = list(map(int,input().split()))

def gcd(i,j):
  if i > j:
    i,j = j,i
  j = j % i
  if j != 0:
    return gcd(j,i)
  else:
    return i

g = a[0]
for k in a:
  g = gcd(g,k)
print(g)

Measured memory_bytes: 14252
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

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

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
struct multi {
  ll first;
  ll second;
  ll third;
  multi(ll first, ll second, ll third)
      : first(first), second(second), third(third) {}
};
bool multicomp(const multi &a, const multi &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vl S(N, 0);
  REP(i, N) cin >> S[i];
  ll ans = 0;
  FOR(C, 1, N) {
    ll sum = 0;
    ll L = 0, R = N - 1;
    if ((N - 1) % C == 0) {
      while (L < R) {
        sum += S[L] + S[R];
        ans = max(ans, sum);
        L += C;
        R -= C;
      }
    } else {
      while (L + C < N - 1) {
        sum += S[L] + S[R];
        ans = max(ans, sum);
        L += C;
        R -= C;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int N; cin >> N;
  vector<int> a(N); REP(i, N) cin >> a[i];
  vector<int> ans(N);
  REP(i, N) {
    ans[i] = 0;
  }
  for(int i = N - 1; i >= 0; --i) {
    int tmp = 0;
    for(int k = i; k < N; k = k + (i + 1)) {
      tmp += ans[k];
    }
    if(tmp % 2 != a[i]) {
      ans[i] = 1;
    }
  }

  int num = 0;
  REP(i, N) {
    if(ans[i] == 1) num++;
  }
  cout << num << endl;

  REP(i, N) {
    if(ans[i] == 1) cout << i + 1 << " ";
  }
  cout << endl;
}

Measured memory_bytes: 2432
#include <iostream>
#include <deque>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
using namespace std;

#define rep_h(i) for(int i = 1;i <= h;i++)
#define rep_w(i) for(int i = 1;i <= w;i++)
#define range(i,j) ((1 <= i && i <= h && 1 <= j && j <= w))

int h;
int w;

int fie[510][510];
int ans[510][510];

typedef pair<int,int> P;

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

int main()
{
	cin >> h >> w;
	rep_h(i)
	{
		string s;
		cin >> s;
		rep_w(j)
		{
			if(s[j - 1] == '#')
			{
				fie[i][j] = 1;
			}
		}
	}

	rep_w(j)
	{
		ans[1][j] = 1;
		if(j % 2 == 1)
		{
			ans[h][j] = -2;
		}
		else
		{
			ans[2][j] = -2;
		}
	}
	rep_h(i) rep_w(j)
	{
		ans[i][j] += ans[i - 1][j];
	}


	rep_w(j) rep_h(i)
	{
		if(fie[i][j] == 1)
		{
			ans[i][j] = 0;
		}
	}

	rep_h(i)
	{
		rep_w(j)
		{
			if(ans[i][j] >= 0) cout << "#";
			else cout << ".";
		}
		cout << endl;
	}
	cout << endl;

	rep_h(i)
	{
		rep_w(j)
		{
			if(ans[i][j] <= 0) cout << "#";
			else cout << ".";
		}
		cout << endl;
	}

}



Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, k;
  cin >> n >> k;
  
  int i;
  int ans = 1;
  for (i = 0; i < n; i++) {
    if (ans < k)
      ans *= 2;
    else {
      ans += k;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/


signed main(){
  int q,h,s,d,n;
  cin>>q>>h>>s>>d>>n;
  chmin(s,q*4);
  chmin(s,h*2);
  int ans;
  if(n%2==0){
    chmin(d,s*2);
    ans=d*n/2;
  }else{
    if(d<s*2){
      ans=d*(n/2);
      ans+=s;
    }else{
      ans=s*n;
    }
  }
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 384
using System;

class Program {
  static void Main() {
    string[] s = Console.ReadLine().Split(' ');

    int a = int.Parse(s[0]);
    int b = int.Parse(s[1]);
    if (a >= b) {
      Console.WriteLine(10);
    } else {
      Console.WriteLine(0);
    }
  }
}

Measured memory_bytes: 13140
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

enemy_count=0
for i in range(len(B)):
    if B[i] > A[i]:#B[i]がA[i]より大きい場合
        enemy_count+=A[i]
        if(A[i+1]>B[i]-A[i]):#さらにA[i+1]がB[i]-A[i]より大きい場合。
            A[i+1]-= B[i]-A[i]
            enemy_count += B[i]-A[i]
        else:#A[i+1]がB[i]-A[i]より小さい場合。
            enemy_count+=A[i+1]
            A[i+1]=0
    else:#B[i]がA[i]以下の場合。
        enemy_count+=B[i]
        A[i]-=B[i]

print(enemy_count)


Measured memory_bytes: 18436
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
typedef long long lint;
typedef vector<int>vi;
typedef pair<int,int>pii;
#define rep(i,n)for(int i=0;i<(int)(n);++i)

double deg(const vector<pair<double,double> > &p){
  double pi=acos(-1.0);
  double cx=p[1].first-p[0].first;
  double cy=p[1].second-p[0].second;
  double bx=p[2].first-p[0].first;
  double by=p[2].second-p[0].second;
  double c=sqrt(bx*bx+by*by);
  double alpha2=atan2(cy,cx)-atan2(by,bx);
  if(alpha2<0){
    alpha2+=2*pi;
  }
  if(alpha2>=pi)
    alpha2=2*pi-alpha2;
  double alpha=alpha2/2;
  return alpha;
}

double f(const vector<pair<double,double> > &p){
  vector<pair<double,double> > q(p);
  swap(q[2],q[0]);
  double bx=p[2].first-p[0].first;
  double by=p[2].second-p[0].second;
  double c=sqrt(bx*bx+by*by);
  double alpha=deg(p);
  double beta=deg(q);
  double res=c/(1/tan(alpha)+1/tan(beta)+2);
  //cerr<<"res="<<res<<endl;
  return res;
}


int main(){
  vector<pair<double,double> > p(3);
  rep(i,3){
    double x,y;
    cin>>x>>y;
    p[i]=make_pair(x,y);
  }
  double ma=0;
  rep(i,3){
    vector<pair<double,double> > q(3);
    rep(j,3)q[j]=p[(i+j)%3];
    ma=max(ma,f(q));
  }
  printf("%.15f\n",ma);
}


Measured memory_bytes: 384
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
struct Point{
    LL x,y;
    double v;
    bool operator<(const Point& b)const{
        return v<b.v;
    }
}AA[SIZE];
int main(){
    int N; R(N);
    REP(i,N){
        R(AA[i].x,AA[i].y);
        if(abs(AA[i].x)+abs(AA[i].y))AA[i].v=atan2(AA[i].y,AA[i].x);
        else AA[i].v=-100;
    }
    sort(AA,AA+N);
    REP(i,N)AA[i+N]=AA[i];
    LL an=0;
    REP(i,2*N){
        FOR(len,1,N){
            LL xx=0,yy=0;
            REP(j,len){
                if(i+j>=2*N)break;
                xx+=AA[i+j].x;
                yy+=AA[i+j].y;
                an=max(an,xx*xx+yy*yy);
            }
        }
    }
    W(sqrt(an));
    return 0;
}


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

int solve(int w, int h, int a, int b, int x[], int y[], int map[100][100]);
int main(){
  int a, b, n, i;
  int x[100], y[100];
  int map[100][100];
  while(1){
    memset(map, 0, sizeof(map));
    scanf("%d %d", &a, &b);
    if(a == 0 && b == 0) break;
    scanf("%d", &n);
    for(i = 0; i < n; i++){
      scanf("%d %d", &x[i], &y[i]);
      map[x[i]][y[i]] = 1;
    }
    
    printf("%d\n", solve(1, 1, a, b, x, y, map));
  }
  return 0;
}

int solve(int w, int h, int a, int b, int x[], int y[], int map[100][100]){
  if(w > a || h > b){
    return 0;
  }
  if(map[w][h] == 1){
    return 0;
  }
  if(w == a && h == b){
    return 1;
  }

  return solve(w + 1, h, a, b, x, y, map) + solve(w, h + 1, a, b, x, y, map);
}
	       

Measured memory_bytes: 1076
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>

using namespace std;

typedef pair<int, int> P;
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define _1 first
#define _2 second
#define pb push_back
#define mod 1000000007
#define INF 1050000000

const int maxn = 1e5 + 10;
const int n = 50;

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

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

	vi v;

	int a;
	rep(i, n) {
		cin >> a;
		v.pb(a);
	}	
	rvsort(v);

	ll ans=0;
	rep(i, k) ans += v[i];

	Print(ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    int h, w;
    cin >> h >> w;
    string q[50];
    for (size_t i = 0; i < h; i++) cin >> q[i];

    const int dy[8]={1, 1, 0, -1, -1, -1, 0, 1};
    const int dx[8]={0, 1, 1, 1, 0, -1, -1, -1};
    int counter = 0;
    for (size_t i = 0; i < h; i++)
    {
        for (size_t j = 0; j < w; j++)
        {
            if(q[i][j]=='.'){
                for (size_t k = 0; k < 8; k++)
                {
                    const int ax_y = i+dy[k];
                    const int ax_x = j+dx[k];
                    if(ax_y<0 || h<=ax_y) continue;
                    if(ax_x<0 || w<=ax_x) continue;
                    if(q[ax_y][ax_x]=='#') counter ++;
                }
                q[i][j] = char(counter + '0');
                counter = 0;
            }
        }
    }
    
    for (size_t i = 0; i < h; i++)
    {
        cout << q[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define pb push_back
using namespace std;
int t[501][501];
vector<int>zm;
int x,y;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>y>>x;
    for(int i=0;i<y;++i){
        for(int j=0;j<x;++j){
            cin>>t[i][j];
        }
    }
    for(int i=0;i<y;++i){
        for(int j=0;j<x-1;++j){
            if(t[i][j]%2!=0){
                zm.pb(i+1);
                zm.pb(j+1);
                zm.pb(i+1);
                zm.pb(j+2);
                t[i][j+1]++;
                t[i][j]--;
            }
        }
    }
    for(int i=0;i<y-1;++i){
        if(t[i][x-1]%2!=0){
            zm.pb(i+1);
            zm.pb(x);
            zm.pb(i+2);
            zm.pb(x);
            t[i+1][x-1]++;
            t[i][x-1]--;
        }
    }
    cout<<zm.size()/4<<"\n";
    for(int i=0;i<zm.size();i+=4){
        cout<<zm[i]<<" "<<zm[i+1]<<" "<<zm[i+2]<<" "<<zm[i+3];
        if(i+4<zm.size())cout<<"\n";

    }

}


Measured memory_bytes: 5232
import java.util.*;
public class Main{   
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int k = sc.nextInt();
      int[] h = new int[n];
      int cnt = 0;
      for(int i = 0;i < n;i++){
        h[i]=sc.nextInt();
        if(k<=h[i])cnt++;
      }
      System.out.println(cnt);
    }
    public static int lcm(int x, int y){
      return x*y/gcd(x,y);
    }
    public static int gcd(int x, int y){
      if(x < y)return gcd(y,x);
      if(y==0)return x;
      return gcd(y,x%y);
    }
}

Measured memory_bytes: 48416
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int h, w, n;
vector<string> grid;

class Data
{
public:
    vector<int> p;
    bitset<3> bs;
    Data(vector<int>& p0, bitset<3> bs0){
        p = p0;
        bs = bs0;
    }
    int toInt(){
        int ret = bs.to_ulong();
        for(int i=0; i<n; ++i){
            ret *= h * w;
            ret += p[i];
        }
        return ret;
    }
};

int solve()
{
    string gridLine = accumulate(grid.begin(), grid.end(), string());
    int move[] = {1, -1, w, -w};

    vector<int> start(n), goal(n);
    for(int i=0; i<h; ++i){
        for(int j=0; j<w; ++j){
            int c = grid[i][j];
            if('a' <= c && c <= 'c'){
                start[c-'a'] = i * w + j;
            }else if('A' <= c && c <= 'C'){
                goal[c-'A'] = i * w + j;
            }
        }
    }

    int size = 1 << n;
    for(int i=0; i<n; ++i)
        size *= h * w;

    vector<vector<bool> > check(2, vector<bool>(size, false));
    check[0][Data(start, 0).toInt()] = true;
    check[1][Data(goal, 0).toInt()] = true;
    vector<deque<Data> > dq(2);
    dq[0].push_back(Data(start, 0));
    dq[1].push_back(Data(goal, 0));

    int turn = 0;
    int m = 0;
    int ret = 0;
    for(;;){
        if(m == 0){
            ++ ret;
            turn ^= 1;
            m = dq[turn].size();
        }

        Data d = dq[turn].front();
        dq[turn].pop_front();
        -- m;

        for(int i=0; i<n; ++i){
            if(d.bs[i])
                continue;
            d.bs[i] = true;
            for(int j=0; j<4; ++j){
                d.p[i] += move[j];

                bool ok = true;
                if(gridLine[d.p[i]] == '#')
                    ok = false;
                for(int k=0; k<n; ++k){
                    if(k != i && d.p[k] == d.p[i])
                        ok = false;
                }

                if(ok){
                    int a = d.toInt();
                    if(!check[turn][a]){
                        dq[turn].push_front(d);
                        ++ m;
                        check[turn][a] = true;
                    }
                }

                d.p[i] -= move[j];
            }
            d.bs[i] = false;
        }

        d.bs = 0;
        int a = d.toInt();
        if(!check[turn][a]){
            if(check[turn^1][a])
                return ret;
            dq[turn].push_back(d);
            check[turn][a] = true;
        }
    }
}

int main()
{
    for(;;){
        cin >> w >> h >> n;
        if(w == 0)
            return 0;
        cin.ignore();

        grid.resize(h);
        for(int i=0; i<h; ++i)
            getline(cin, grid[i]);

        cout << solve() << endl;
    }
}

Measured memory_bytes: 50708
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1e9+7;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
#define fs first
#define sc second


const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T>
T ngcd(vector<T> a){
    T res;
    res = a[0];
    for(int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
 
template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

template<typename T>
T nlcm(vector<T> numbers) {
    T res;
    res = numbers[0];
    for (int i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}


// 素数判定
template<typename T>
bool isPrime(T x){
    T i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
};

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}



// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}


using pint = pair<int, int>;
using pll = pair<ll, ll>;


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll x;
    cin >> x;
    ll st = 100;
    ll ans = 0;
    while(st < x){
        st += st / 100;
        ans++;
    }
    print(ans);
}


Measured memory_bytes: 3664
n = gets.to_i
a = gets.split.map(&:to_i).sort
aj = a[0]
1.upto(n-2) do |i|
  t = [a[-1]-a[i],a[i]].min
  c = [a[-1]-aj,aj].min
  aj = a[i] if t > c
end
puts "#{a[-1]} #{aj}"

Measured memory_bytes: 13680
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int a,b,x;
    cin>>a>>b>>x;
    
    if((a<=x)&&((a+b)>=x)){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    return 0;
}


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

int	main() {
	// # of Nodes
	int N;
	cin >>N;
	// Links to connect node a & b
	vector<vector<int>> ab(N+1, vector<int> (0));
	for (int i=1; i<N; i++) {
		int a, b;
		cin >> a;
		cin >> b;
		ab.at(a).push_back(b);
		swap(a, b);
		ab.at(a).push_back(b);
	}
	//
	vector<int> c(N);
	int M=0;
	for (int i=0; i<N; i++){
		cin >>c.at(i);
		M +=c.at(i);
	}
	sort(c.begin(), c.end());
	reverse(c.begin(), c.end());
	//
	M -=c.at(0);
	cout <<M <<endl;
	//
	vector<bool> Ndone(N+1, false);
	vector<int> order(0);
	order.push_back(1);
	Ndone.at(1)=true;
	int ix=0;
	while(true) {
		int NN=order.at(ix);
		int iy=0;
		while(iy!=ab.at(NN).size()) {
			int y=ab.at(NN).at(iy);
			if (!Ndone.at(y)) {
				order.push_back(y);
				Ndone.at(y)=true;
			}
			iy++;
		}
		ix++;
		if (N==ix)
			break;
	}
	vector<int> d(N+1, 0);
	for (int i=0; i<N; i++)
		d.at(order.at(i))=c.at(i);
	for (int i=1; i<=N; i++)
		cout <<d.at(i) <<' ';
	cout <<endl;
	return 0;
};


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define FOR(i, n, m) for (ll i = (n); i < (m); ++i)
#define FORR(i, n, m) for (ll i = (m) - 1; i >= (n); --i) 
#define FORE(x, xs) for (auto &x: (xs))
#define ALL(v) v.begin(), v.end()
#define ZERO(a) memset(a,0,sizeof(a))

const int INF = 1000000009;
const int MOD = 1000000007;
const double EPS = 1e-14;
const double PI = acos(-1);

const int MAX = 2e5;

ll N, x;
ll a[2000][2000];

int main() {
  cin >> N >> x;
  REP (i, N) cin >> a[0][i];

  ll ans = 0;
  REP (i, N) ans += a[0][i];
  FOR (k, 1, N) {
    ll res = x*k;
    REP (i, N) {
      a[k][i] = min(a[k-1][i], a[k-1][(i+1)%N]);
      res += a[k][i];
    }
    ans = min(ans, res);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 31488
from itertools import product
from collections import deque
import numpy as np
class Grid:
    def __init__(self, grid, w=0, h=0, function=lambda x: x):
        self.w = w = w if w else len(grid[0])
        self.h = h = h if h else len(grid)
        dtype = type(function(grid[0][0]))
        self.grid = np.empty((h, w), dtype=dtype)
        for i, row in zip(range(h), grid):
            for j, val in zip(range(w), row):
                self.grid[i][j] = function(val)
    
    def is_valid_x(self, x):
        return 0 <= x < self.w
    def is_valid_y(self, y):
        return 0 <= y < self.h
    def is_valid_xy(self, x, y):
        return self.is_valid_x(x) and self.is_valid_y(y) 
    
    def __iter__(self):
        return iter(self.grid)
    def __repr__(self):
        return '\n'.join([' '.join(map(str, row)) for row in self.grid]) + '\n'
    def __getitem__(self, x):
        return self.grid[x]
    def __setitem__(self, x, val):
        self.grid[x] = val


def dfs(grid, root):
    stack = [root]
    x, y = root
    grid[y, x] = '!'
    while stack:
        x, y = stack.pop()
        yield (x, y)
        for dx, dy in zip([1, 0, -1, 0], [0, 1, 0, -1]):
            nx, ny = x+dx, y+dy
            if grid.is_valid_xy(nx, ny) and grid[ny, nx] == '#':
                stack.append((nx, ny))
                grid[ny, nx] = '!'

h, w = map(int, input().split())
grid = Grid([input() for s in range(h)])

for y, x in product(range(h), range(w)):
    if grid[y, x] == '#':
        if len(list(dfs(grid, (x, y)))) == 1:
            print('No')
            break
else:
    print('Yes')

Measured memory_bytes: 27340