akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.lang.*;
import java.io.*;


public class Main {

    static final int MOD = 1_000_000_007;
    
    public static long addMod(long a, long b){
    	long tmp = (a+b)%MOD;
    	return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long subMod(long a, long b){
    	return addMod(a,-b);
    }
    public static long multMod(long a, long b){
    	long tmp = (a*b)%MOD;
    	return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long powerMod(long a, long x){ //calculate a^x
        if(x<0)return 0;
        if(x==0)return 1;
        if(x%2==0) {
        	long half = powerMod(a,x/2);
        	return multMod(half,half);
        }
        return (a*powerMod(a,x-1)) % MOD;
    }
    public static long inverseMod(long a){
        return powerMod(a,MOD-2);
    }
    public static long divMod(long a, long b){
    	return multMod(a, inverseMod(b));
    }

    public static long[] makeFactorialArray(int size){
        long[] array = new long[size];
        array[0]=1;
        for(int i=1;i<size;i++){
        	array[i]=multMod(array[i-1],i);
        }
        return array;
    }
    public static long[] makeInversedArray(long[] original){
        long[] array = new long[original.length];
        for(int i=0;i<original.length;i++){
        	array[i] = inverseMod(original[i]);
        }
        return array;
    }
    public static long combination(int n, int r, long[] fact, long[] factInv){
        return multMod(fact[n], multMod(factInv[r],factInv[n-r]));
    }
    
/*7 9 3 4
 012345678
0.......!.
1......!..
2.....!...
3....!....
4####.....
5####.....
6####.....
*/
    public static void main(String[] args) {
        
        long[] fact = makeFactorialArray(200001);
        long[] factInv = makeInversedArray(fact);
        
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        
        int h = H-1-A;
        int w = B;
        long ans = 0;
        
        while(h>=0 && w<W){
        	
        	ans = addMod(ans, multMod(combination(h+w,h,fact,factInv),combination(H+W-h-w-2,H-1-h,fact,factInv)));
        	h--;w++;
        }
        
        System.out.println(ans);
        
    }
}


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

int main()
{
    vector<int>vec;
    for(int i=0;i<5;i++)
    {
        int x;
        cin>>x;
        vec.push_back(x);
    }
    for(int i=0;i<5;i++)
    {
        if(vec[i]==0)
        {
            cout<<i+1<<endl;
        }
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;cin >> a >> b;
	cout << (a + b) % 24 << endl;
}


Measured memory_bytes: 256
// Enjoy your stay.

#include <bits/stdc++.h>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

typedef istringstream iss;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

int n,dp[5][1<<15];

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	rep(i,4)dp[i][0] = 1;
	rep2(s,1,INF){
		if(s*s >= 1<<15)break;
		rep(i,4)rep(j,1<<15){
			if(j+s*s >= 1<<15)break;
			dp[i+1][j+s*s] += dp[i][j];
		}
	}
	while(cin>>n && n)cout<<dp[4][n]<<endl;
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#define ALL(a) (a).begin(),(a).end()

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

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

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


long long fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>>que;

int main() {
  // 前処理
  //COMinit();
  ll A,B,C;
	
  cin>>A>>B>>C;
  if(A==B){
    if(A==C){
      cout<<"Yes"<<endl;
    return 0;
    }
  }


  cout<<"No"<<endl;
  return 0;
 
}

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

const int mod = 998244353;
long long n, k, a, b, ans = 0, fact[300010];
long long power(long long a, int n) {
	if(n == 0) return 1;
	if(n == 1) return a;
	long long b = power(a, n/2);
	b = (b*b) % mod;
	if(n&1) b = (b*a) % mod;
	return b;
}

long long C(int k, int n) {
	if(n < k) return 0;
	return (fact[n] * power(fact[k] * fact[n-k] % mod, mod - 2)) % mod;
}

int main() {
	scanf("%lld%lld%lld%lld", &n, &a, &b,  &k);
	fact[0] = 1;
	for(int i = 1; i <= n; i++) fact[i] = (fact[i-1]*i) % mod;
	for(int i = 0; i <= k/a; i++) {
		if((k - i*a) % b == 0) {
			int j = (k - i*a)/b;
			ans = (ans + C(i, n)*C(j, n) % mod) % mod;
 		}
	}
	printf("%lld", ans);
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}




#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


  








int main() {
  int n,m;
  cin >> n >> m;
  ll a[n+1],b[n+1],c[m+1],d[m+1];
  rep (i,n){
    cin >> a[i] >> b[i];
  }
  rep (i,m){
    cin >> c[i] >> d[i];
  }
  rep (i,n){
    ll mini=INF,ans=-1;
    rep (j,m){
    ll dis = abs(a[i]-c[j])+abs(b[i]-d[j]);
    if (mini>dis){
     // cout << a[i] << " " << c[j] << " " << b[i] << " " << d[i] << endl;
    mini = min(dis,mini);
    ans = j+1;
    //cout << dis << endl;
    }
    }
    cout << ans << endl;
    //cout << endl;
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  vi A(N);
  rep(i,N) {
    cin >> A[i];
  }
  sort(rng(A));
  cout << A.back()-A[0] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector> // vectorを使うためにインクルードする
using namespace std;

int main() {
	vector<int> bm; 
	vector<int> am; 
	int n;
	int m;
	int c;
	scanf("%d%d%d", &n, &m, &c);
	int ncopy = n;
	int mcopy = m;

	int ans = 0;
	int sum = 0;

	for (int i = 0; i < m; i++) {
		int x;
		scanf("%d", &x);
		bm.push_back(x);
	}

	for (int j = 0; j < n; j++) {
		for (int i = 0; i <= m; i++) {
			if (i == m ) {
				sum += c;
				if (sum > 0) {
					ans += 1;
				}
				am.clear();
				sum = 0;
			}
			else {
				int x;
				scanf("%d", &x);
				am.push_back(x);
				sum += am[i] * bm[i];
			}
		}
	}
	printf("%d", ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long   ll;
int main()
{
    string a,b;
    ll c=0;
    cin>>a;
    b=a;
    ll l=a.length();
    reverse(a.begin(),a.end());
    for(ll i=0;i<l;i++){
        if(a[i]!=b[i])
            c++;
    }
    cout<<c/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

ll rep_pow(ll a, ll b){//繰り返し2乗法
    if(b==0) return 1;
    else if(b%2==0){
        ll memo = rep_pow(a, b/2);
        return memo*memo%mod;
    }else{
        return rep_pow(a, b-1)*a%mod;
    }
}
ll nCr(ll n, ll r){//mod逆元使ったnCr
    ll ret=1;
    rep(i,r){
        ret *= n-i;//分子
        ret %= mod;
        ret *=rep_pow(r-i, mod-2);//mod逆元によりr!で割ると同値
        ret %= mod;
    }
    return ret;
}
ll gcd(ll a, ll b){if(b==0) return a; return gcd(b, a%b);}
bool isPrime(int x){
    if(x==1) return false;
    else if(x==2) return true;
    else if(x%2==0) return false;
    for(int i=3;i<=sqrt(x);i+=2){
        if(x%i==0){
            return false;
        }
    }
    return true;
}

int main(){
    fast_io
    
    string s;
    cin>>s;
    bool flag=true;
    for(int i=0;i<s.size();i+=2){
        if(s[i]=='h'&&s[i+1]=='i') {}
        else flag=false;
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


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

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N;

  std::string s;
  
  std::cin >> N;

  std::map<std::string, int> map;

  for (int i = 0; i < N; i ++) {
    std::cin >> s;

    map[s] ++;
  }

  int cp = 0;

  for (const auto& kv : map)
    cp = std::max(kv.second, cp);

  std::vector<std::string> a;

  for (const auto& kv : map)
    if (kv.second == cp)
      a.push_back(kv.first);

  std::sort(ALL(a));

  for (const auto& i : a)
    std::cout << i << std::endl;

  return 0;
}


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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  int c=0;
  int x;
  while(n){
     x=n%10;
     n=n/10;
     if(x==7){
      c++;
     }
  }
  if(c>0){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
}


Measured memory_bytes: 3624
program MakingTriangle
!
      implicit none 
      integer(8) :: i,j,k
      integer(8) :: N
      integer(8),allocatable,dimension(:) :: L
      integer(8) :: ans
!
      read(*,*) N
      allocate(L(N))
      read(*,*) (L(i),i=1,N)
      i=1
      call quicksort(N,L,i,N)
      ans = 0
!
      do i=1,N-2
        do j=i+1,N-1
          if(L(i) /= L(j) ) then
            do k=j+1,N
              if(L(j) /= L(k)) then
              if(L(i)+L(j) > L(k)) ans = ans+1
              end if
            end do
          end if
        end do
      end do
!
      write(*,*) ans
!
      end program MakingTriangle
!-------------------------------------------------
      recursive subroutine quicksort(n,x,l,r)
!-------------------------------------------------
! Variables I/O
!-------------------------------------------------
! n     ...  the number of data (IN) : integer
! x(i)  ...  data (INOUT) : integer
! l     ...  the smallest label in a sorted region
!            (compute label)
! r     ...  the largest label in a sorted region
!            (compute label)
!-------------------------------------------------
! Variables (The others)
!-------------------------------------------------
! c     ...  the average of l and r : (l+r)/2
! ls    ...  the smallest label in a sorted region
!            (Input label)
! i     ...  the largest label in a sorted region
!            (Input label)
!-------------------------------------------------
! Contain
!-------------------------------------------------
! Subroutine : swap(a,b) : swaping a for b
!-------------------------------------------------
      implicit none
      integer(8),intent(in) :: n,l,r
      integer(8),dimension(n),intent(inout) :: x
      integer(8) :: c,ls,i
!
      if(l < r) then
        c = (l+r) / 2 ! representative value
        call swap(x(l),x(c))
        ls = l
        do i=l+1,r
          if(x(i) < x(l)) then
            ls = ls + 1
            call swap(x(ls),x(i))
          end if
        end do
        call swap(x(ls),x(l))
        call quicksort(n,x,l,ls-1)
        call quicksort(n,x,ls+1,r)
      end if
      contains
!-------------------------------------------------
      subroutine swap(a,b)
!-------------------------------------------------
        integer(8),intent(inout) :: a,b
        integer(8) :: w
        w=a
        a=b
        b=w
      end subroutine swap
      end subroutine quicksort
!


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

#define int         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(){
   int a[5],b,c=0,d,e,k,n;
   cin>>n;

  rep(i,0,5)
   { cin>>a[i];}
   sort(a,a+5);
       c+=n/a[0]+bool(n%a[0]);
   cout<<c+4;
}

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
import java.util.AbstractMap;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

        int N=gi();
        int[] X=new int[N];
        int[] Y=new int[N];
        Map<Pair, Integer>map=new HashMap<Pair, Integer>();

        for (int i=0; i<N; i++) {
            X[i]=gi();
            Y[i]=gi();
        }

        for (int i=0; i<N; i++) {
        	for (int j=i+1; j<N; j++) {
                Pair<Integer, Integer> p=new Pair<Integer, Integer>(X[i] - X[j], Y[i]-Y[j]);
                Pair<Integer, Integer> p2=new Pair<Integer, Integer>(X[j] - X[i], Y[j]-Y[i]);
                if(map.containsKey(p)) {
                	map.put(p, map.get(p)+1);
                } else {
                	map.put(p, 1);
                }
                if(map.containsKey(p2)) {
                	map.put(p2, map.get(p2)+1);
                } else {
                	map.put(p2, 1);
                }
            }
        }
        
        int max =0;
        for(Integer i: map.values()) {
        	if(i>max) {
        		max=i;
        	}
        }

        System.out.println(N-max);
	}

	public static class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> implements Comparable<Pair<K, V>> {
		/** serialVersionUID. */
	    private static final long serialVersionUID = 6411527075103472113L;

	    public Pair(final K key, final V value) {
	        super(key, value);
	    }

		@Override
		public int compareTo(Pair<K, V> o) {

			Comparable key = (Comparable)this.getKey();
			Comparable key2 = (Comparable)o.getKey();

			return key.compareTo(key2);
		}

	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 40016
n,a,b=map(int,input().split())
s=list(input())

ac=0
fc=0

for i in range (n):
  if s[i]=='a' and ac<a+b:
    ac+=1
    print ('Yes')
  elif s[i]=='b' and ac<a+b and fc<b:
    ac+=1
    fc+=1
    print ('Yes')
  else:
    print ('No')

Measured memory_bytes: 4708
N = int(input())
A = list(map(int, input().split()))
A_e = []

for i in range(N):
    if A[i]%2 == 0:
        A_e.append(A[i])


cnt = 0
for j in range(len(A_e)):
    if (A_e[j]%3 == 0) or (A_e[j]%5 == 0):
        cnt += 1
    else:
        cnt = cnt

if cnt == len(A_e):
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;
#define MAX_N 735477
#define MOD 1000000007
typedef long long ll;
bool broken[MAX_N];

int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int a;
    cin >> a;
    broken[a] = true;
  }

  vector<ll> ans(N + 1);
  ans[0] = 1;
  broken[1] ? ans[1] = 0 : ans[1] = 1;
  for (int i = 2; i < N + 1; i++) {
    ans[i] = ans[i - 1] + ans[i - 2];
    ans[i] %= MOD;
    if (broken[i]) ans[i] = 0;
  }

  cout << ans[N] % MOD << endl;
  return 0;
}

Measured memory_bytes: 1152
while True:
    a,b,c = input().split()
    a = int(a)
    c = int(c)
    if b=='+':
        print(a+c)
    elif b == '-':
        print(a-c)
    elif b == '*':
        print(a*c)
    elif b == '/':
        print(a//c)
    else:
        break


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

int main() {
  int h,w,n; cin>>h>>w>>n;
  vector<int> v;
  graph g(h,vector<int>(w));
  int c=0, k=0;
  rep(i,h){
    rep(j,w){
      if(c==0){cin>>c;k++;}
      g[i][j]=k; c--;
    }
  }
  rep(i,h){
    rep(j,w){
      if(i%2==0){
        cout<<g[i][j]<<" ";        
      }
      if(i%2==1){
        cout<<g[i][w-1-j]<<" ";        
      }
      if(j==w-1)cout<<endl;
    }
  }
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    vector<vector<int>> x(3,vector<int> (3,0));
    cin >> x[0][0] >> x[0][1] >> x[1][1];
    for (int i = 0; i <= 300; i++) {
        auto t = x;
        t[0][2] = i - t[0][0] - t[0][1];
        t[2][1] = i - t[1][1] - t[0][1];
        t[2][2] = i - t[1][1] - t[0][0];
        t[1][2] = i - t[2][2] - t[0][2];
        t[2][0] = i - t[2][1] - t[2][2];
        t[1][0] = i - t[2][0] - t[0][0];
        auto f = [](vector<vector<int>> &t){
            int s = t[0][0] + t[0][1] + t[0][2];
            for (int i = 0; i < 3; i++) {
                int sum = 0;
                for (int j = 0; j < 3; j++) {
                    sum += t[i][j];
                }
                if(sum != s) return false;
            }
            for (int i = 0; i < 3; i++) {
                int sum = 0;
                for (int j = 0; j < 3; j++) {
                    sum += t[j][i];
                }
                if(sum != s) return false;
            }
            if(s != t[0][2] + t[1][1] + t[2][0]) return false;
            return true;
        };
        if(f(t)){
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    cout << t[j][k] << (k==2?"\n":" ");
                }
            }
            return 0;
        }
    }
    return 0;
}


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

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

using namespace std;

const int INF = 1 << 21;

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

	if (A < 1 || A > 9 || B < 1 || B > 9) {
		cout << -1 << endl;
	}
	else {
		cout << A * B << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define NIL -1
int P[10000],L[10000],R[10000],B[10000];
int getDegree(int x){
    int a=0;
    if(L[x]!=NIL)a++;
    if(R[x]!=NIL)a++;
    return a;
}
int getDepth(int y){
    int b=0;
    while(P[y]!=NIL){
        y=P[y];
        b++;
    }
    return b;
}
int getHeight(int z){
    int c=0;
    int d=0;
    if(R[z]!=NIL){
        c=getHeight(R[z])+1;
    }
    if(L[z]!=NIL){
        d=getHeight(L[z])+1;
    }
    if(c>d)return c;
    else return d;
}
int main()
{
    int i,n,s,l,r;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        P[i]=NIL;
        L[i]=NIL;
        R[i]=NIL;
        B[i]=NIL;
    }
for(i=0;i<n;i++){
    scanf("%d%d%d",&s,&l,&r);
    L[s]=l;
    R[s]=r;
    if(l!=NIL)P[l]=s;
    if(r!=NIL)P[r]=s;
    B[l]=r;
    B[r]=l;
}
for(i=0;i<n;i++){
printf("node %d: ",i);
printf("parent = %d, ",P[i]);
printf("sibling = %d, ",B[i]);
printf("degree = %d, ",getDegree(i));
printf("depth = %d, ",getDepth(i));
printf("height = %d, ",getHeight(i));
if(P[i]==NIL)printf("root\n");
else if (L[i]==NIL&&R[i]==NIL)printf("leaf\n");
else printf("internal node\n");
}
    return 0;
}


Measured memory_bytes: 2056
#include <iostream>
#include <math.h>

#define N 1000000
using namespace std;

int arr[N];

//エラトステネスの篩
void Eratosthenes(int a){
	for(int i = 0; i < N; i++){
		arr[i] = 1;
	}
	for(int i = 2; i < sqrt(N); i++){
		if(arr[i]){
			for(int j = 0; i * (j + 2) < N; j++){
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for(int i = 2; i < N; i++){
		if(arr[i] and i >= a){
			//cout << i << endl;
            cout << i << endl;
            return;
		}
	}
}

void normal(){
	for(int i = 1; i <= N; i++){
		int count = 0;
		for(int j = 1; j <= i; j++){
			if(i % j == 0){
				count++;
			}
			if(count > 2){
				break;
			}
		}
		if(count == 2){
			//cout << i << endl;
		}
	}
}

//素数
int main(int argc, char const *argv[]){
    int a;
    cin >> a;
	Eratosthenes(a);
	return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=500010;

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

    ll k,a,b;
    cin>>k>>a>>b;
    int f=0;
    for(ll i=a;i<=b;++i){
        if(i%k==0){f=1;}
    }
    if(f){cout<<"OK";}
    else{cout<<"NG";}

    return (0);
}


Measured memory_bytes: 3620
import sys,collections
q=collections.deque();input()
for s in sys.stdin:
 if"n"in s:q.appendleft(s.split()[1])
 elif"F"in s:q.popleft()
 elif"L"in s:q.pop()
 else:
  try:q.remove(s.split()[1])
  except:pass
print(*q)


Measured memory_bytes: 69736
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int mod = 1000000007;
        int N = sc.nextInt();
        int[] T = new int[N];
        int[] A = new int[N];
        int[] r = new int[N];
        int[] l = new int[N];
        long ans = 1;
        for(int i = 0; i < N; i++){
            T[i] = sc.nextInt();
        }
        for(int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        for(int i = 0; i < N; i++){
            if(i == 0){
                l[i] = 1;
            } else {
                if(T[i] > T[i-1]) {
                    l[i] = 1;
                    if(T[i] > A[i])
                        ans = 0;
                } else
                    l[i] = T[i-1];
            }
        }
        for(int i = N-1; i >= 0; i--){
            if(i == N-1){
                r[i] = 1;
            } else {
                if(A[i] > A[i+1]){
                    r[i] = 1;
                    if(A[i] > T[i])
                        ans = 0;
                } else
                    r[i] = A[i+1];
            }
        }
        sc.close();

        if(T[N-1] != A[0]){
            ans = 0;
        } else {
            for(int i = 0; i < N; i++){
                ans = (ans*Math.min(l[i], r[i]))%mod;
            }
            
        }
        System.out.println(ans);

    }
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    string s;
    ll k;
    cin >> s >> k;
    ll n = s.size();
    for(i = 0;i < n;++i){
        ll tmp = (26 - (s.at(i) - 'a'))%26;
        if(tmp <= k){
            k -= tmp;
            s.at(i) = 'a';
        }
    }
    k %= 26;
    s.back() += k;
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 3728
n = int(input())
a = [int(i) for i in input().split(" ")]

odds = [i for i in a if i % 2 == 0]
result = "APPROVED"
for i in odds:
  if i % 3 != 0 and i % 5 != 0:
    result = "DENIED"
    break
print(result)

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

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

  string ans = "No";
  for (int t = 0; t <= x; t++) {
    int k = x - t;
    if (t * 2 + k * 4 == y) {
      ans = "Yes";
      break;
    }
  }

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

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

using ll=long long;
using vll=vector<ll>;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;

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

    int n, m;
    cin >> n >> m;
    vi likes(m);
    for (int i=0; i<n; ++i) {
        int k;
        cin >> k;
        for (int j=0; j<k; ++j) {
            int aij;
            cin >> aij;
            ++likes[aij-1];
        }
        /*string l;
        getline(cin, l);
        istringstream ls(l);
        int aij;
        while (ls >> aij)
            ++likes[aij-1];*/
    }
    int cnt = 0;
    for (int i=0; i<m; ++i)
        cnt += (likes[i] == n);
    cout << cnt << "\n";
}


Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <unordered_map>

using namespace std;
#define debug(x) cout << #x << ": " << x << endl
typedef long long ll;

void solve() {
    int N;
    cin >> N;
    unordered_map<string, int> m;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        m[s]++;
    }

    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;

}

int main() {
    // int t;
    // cin >> t;
    // while (t--)
    solve();
}

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

const int INF = 1e18;

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

  int n;
  cin >> n;

  vector<int> a(n);
  bool zero = false;
  int one = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if(a[i] == 0) zero = true;
  }

  if(zero) {
    cout << 0 << '\n';
    return 0;
  }

  int ans = 1;
  for (int i = 0; i < n; i++) {
    if(ans > INF / a[i]) {
      ans = -1;
      break;
    }
    ans *= a[i];
  }

  cout << ans << '\n';
  return 0;
}

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

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

/***** MAIN *****/
signed main() {
  int n;
  scanf("%d", &n);

  int tmp, nums[n];
  int max = 0, second = 0;
  REP(i,n) {
    scanf("%d", &tmp);
    nums[i] = tmp;
    if(tmp >= max) {
      second = max;
      max = tmp;
    } else if(tmp >= second) {
      second = tmp;
    }
  }

  REP(i,n) {
    if(nums[i] == max) {
      cout << second << endl;
      continue;
    }
    cout << max << endl;
  }
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f;
const int MAXN=1e5+5;
int a[MAXN];
int G[105][105];

int main()
{
    int h,w;
    while(scanf("%d%d",&h,&w)!=EOF)
    {
        int n;
        cin>>n;
        for(int i=1;i<=n;++i)
            scanf("%d",&a[i]);
        int cnt=1;
        for(int i=1;i<=h;++i)
        {
            if(i&1)
            {
                for(int j=1;j<=w;++j)
                {
                   if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}
                   else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}
                }
            }else
            {
                for(int j=w;j>=1;--j)
                {
                    if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}
                    else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}
                }
            }
        }
        for(int i=1;i<=h;++i)
        {
            for(int j=1;j<=w;++j)
            {
                if(j!=w) printf("%d ",G[i][j]);
                else printf("%d\n",G[i][j]);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

#include <atcoder/segtree>

int op(int a, int b) {
	return max(a, b);
}

int e() {
	return -INF;
}

int V;

bool f(int x) {
	return x < V;
}

int main() {
	int N, Q;
	cin >> N >> Q;
	atcoder::segtree<int, op, e> seg(N);
	REP(i, N) {
		int a;
		scanf("%d", &a);
		seg.set(i, a);
	}
	
	while (Q--) {
		int t, a, b;
		scanf("%d %d %d", &t, &a, &b);
		if (t == 1) seg.set(a - 1, b);
		else if (t == 2) printf("%d\n", seg.prod(a - 1, b));
		else {
			V = b;
			printf("%d\n", seg.max_right<f>(a - 1) + 1);
		}
	}
	return 0;
}


Measured memory_bytes: 6060
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;

string str;

int main()
{
    int n = 0;
    cin >> str;

    for (auto i : str) {
        if (i == 'o') {
            n++;
        }
    }

    if ((15 - str.size()) + n >= 8) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    
}


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

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

	int s1 = s/100;
	int s2 = s%100;
	if(1 <= s1 && s1 <= 12 && 1 <= s2 && s2 <= 12){
		cout << "AMBIGUOUS" << endl;
	}else if(1 <= s1 && s1 <= 12){
		cout << "MMYY" << endl;
	}else if(1 <= s2 && s2 <= 12){
		cout << "YYMM" << endl;
	}else{
		cout << "NA" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import numpy as np

N, M = [int(i) for i in input().split()]
X = [int(i) for i in input().split()]
X.sort()
arr = np.array(X)

X_sort = np.diff(arr, n= 1).tolist()
X_sort.sort(reverse=True)
if N >= M:
    print(0)
else:
    print(sum(X_sort[N-1:]))


Measured memory_bytes: 22312
#include <cstdio>
#include <algorithm>
#include <string>
#include <utility>

bool restorable(std::string &s, const std::string &t, size_t oft) {
  for (size_t i=0; i<t.length(); ++i) {
    if (i >= s.length()) return false;
    if (s[oft+i] != '?' && s[oft+i] != t[i]) return false;
  }

  for (size_t i=0; i<t.length(); ++i)
    if (s[oft+i] == '?')
      s[oft+i] = t[i];

  for (size_t i=0; i<s.length(); ++i)
    if (s[i] == '?')
      s[i] = 'a';

  return true;
}

int main() {
  char buf[64];
  scanf("%s", buf);
  std::string S=buf;
  scanf("%s", buf);
  std::string T=buf;

  for (size_t i=S.length(); i--;)
    if (restorable(S, T, i))
      return !printf("%s\n", S.c_str());

  printf("UNRESTORABLE\n");
  return 0;
}


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

//------------------- mod ----------------------
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

//----------------combination---------//
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main()
{
    // input
    int n, m;
    ll k;
    cin >> n >> m >> k;

    // solve
    combination C(n*m);
    mint ans = 0;
    for(ll d=1; d<m; d++) ans += d*(m-d)*n*n;
    for(ll d=1; d<n; d++) ans += d*(n-d)*m*m;
    ans *= C(n*m-2,k-2);

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

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
    int64_t a, b, x;
    cin >> a >> b >> x;

    auto t = 2 * (a * a * b - x) / (double)a / a / a;
    if (t * a >= b) {
        t = a * b * b / 2.0 / x;
    }

    cout << setprecision(10) << atan(t) / M_PI * 180.0 << endl;
}

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

int main(){
  int n,k;
  string s;
  cin >>n >>s >>k;
  rep(i,n){
    if(s[i]!=s[k-1]) s[i] = '*';
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict as dd
from itertools import accumulate as ac
from itertools import product as pr

N,W=map(int,input().split())
d=dd(list)
for _ in range(N):
  w,v=map(int,input().split())
  d[w].extend([v])
d=dict(d)
for i in d.keys():
  d[i].sort(reverse=True)
  d[i]=[0]+list(ac(d[i]))

l=[]
key=list(d.keys())
for val in pr(*map(enumerate,d.values())):
  weight=sum(map(lambda x,y:x*y[0],key,val))
  value=sum(map(lambda x:x[1],val))
  if weight<=W:
    l.extend([value])

print(max(l))

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

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var k = int.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var h = Array.ConvertAll(line, long.Parse);
        if (k >= n) { Console.WriteLine(0); goto exit; }
        var ans = h.OrderByDescending(x => x).Skip(k).Sum((x => x));
        Console.WriteLine(ans);
    exit:;
    }
}


Measured memory_bytes: 39680
memo = dict()


def calc(n):
    if n == 0:
        return 0
    if n == 1:
        return d
    if n in memo:
        return memo[n]

    ret = min(n * d,
              a + calc(n//2) + (n % 2) * d,
              a + calc((n+1)//2) + ((2 - (n % 2)) % 2) * d,
              b + calc(n//3) + (n % 3) * d,
              b + calc((n+2)//3) + ((3 - (n % 3)) % 3) * d,
              c + calc(n//5) + (n % 5) * d,
              c + calc((n+4)//5) + ((5 - (n % 5)) % 5) * d)

    memo[n] = ret
    return ret


t = int(input())
for i in range(t):
    n, a, b, c, d = map(int, input().split())
    print(calc(n))
    memo = dict()


Measured memory_bytes: 10788
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
hoge = [list(map(int, input().split())) for _ in range(N)]
C_m = [C for _ in range(M)]

out = []
res = 0
for i in range(N):
  for j in range(M):
    res += (hoge[i][j]* B[j])
  out.append((res+C) > 0)
  res = 0

  
print(sum(out))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 1000005
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define P pair<int,int> 
#define INF 1000000000
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
	int h,n;
    cin>>h>>n;
    ll ans=(ll)h*n;
    ans=(ans+1)/2;
    if(h<2||n<2) ans=1;
    OUT(ans);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
w = list(map(int,input().split()))
A = dict(zip(sorted(w), w))
min_value = min(A)
A = {k:v for k,v in A.items() if k != v or k == min_value}
totalcost = 0

while len(A) > 1:
    i_move_count = 0
    i = min_value
    if min_value == A[min_value]:
        i = min([v for v in A if v != min_value])

    while A[i] != i:
        j = A[i]
        A[i] = A[j]
        A.pop(j)
        i_move_count += 1
        totalcost += j

    if i != min_value:
        A.pop(i)

    totalcost += min((i * i_move_count), ((min_value * i_move_count) + (min_value + i) * 2))

print(totalcost)


Measured memory_bytes: 5788
#include <iostream>
using namespace std;
#include<string.h>
#include<set>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include <cstdio>
#include <cstdlib>
#include<stack>
#include<vector>
const int MAX = 1e5;
int a[MAX+10];
int b[MAX+10];
int c[MAX+10];
int dabiao()
{
    memset(a,1,sizeof(a));
    int len=0;
    for(int i=2;i<=MAX;i++)
    {
        if(a[i])
            b[len++]=i;
        for(int j=0;j<len;j++)
        {
            if(i*b[j]>=MAX)
                break;
            a[i*b[j]]=0;
            if(i%b[j]==0)
                break;
        }
    }
}
int dabiao1()
{
    dabiao();
    a[1]=0;
    a[0]=0;
    int sum=0;
    memset(c,0,sizeof(c));
    for(int i=1;i<=MAX;i++)
    {
        if(a[i]==0||a[(i+1)/2]==0)
            c[i]=c[i-1];
        else
        {
            c[i]=c[i-1]+1;
            //cout<<i<<endl;
        }

    }
}
int main()
{
    dabiao1();
    int n,m,t;
    cin>>t;
    while(t--)
    {
        cin>>n>>m;
        cout<<c[m]-c[n-1]<<endl;
    }
}


Measured memory_bytes: 1408
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
int n,k;
ll MOD,f[2][155][155][155],g[155][155];
int main()
{
	scanf("%d%d%lld",&n,&k,&MOD);
	if(k%2==0)
	{
		k/=2;
		g[0][0]=1;
		for(int i=1;i<=n;i++)
		{
			for(int j=0;j<=k;j++)
			{
				g[i-1][j]%=MOD;
				g[i][j+1]+=g[i-1][j];
				g[i][0]+=g[i-1][j];
			}
		}
		ll ans1=0,ans2=0;
		for(int i=0;i<=k;i++)ans1+=g[n/2][i];
		for(int i=0;i<=k;i++)ans2+=g[(n+1)/2][i];
		ans1%=MOD;
		ans2%=MOD;
		printf("%lld\n",ans1*ans2%MOD);
		return 0;
	}
	f[0][0][0][0]=1;
	for(int i=1;i<=n;i++)
	{
		bool flag=i&1;
		for(int x=0;2*x-1<=i;x++)
		  for(int y=0;2*y<=i;y++)
		    for(int k=0;k<=n;k++)
		      f[flag][x][y][k]=0;
		for(int x=0;2*x-1<i;x++)
		for(int y=0;2*y<i;y++)
		{
			f[!flag][x][y][0]%=MOD;
			f[!flag][x][y][i]%=MOD;
			for(int k=i+1;k<=n;k++)
			{
				f[!flag][x][y][k]%=MOD;
				if(flag)
				{
					f[flag][x+1][y][k]+=f[!flag][x][y][k];
					f[flag][0][y][k&1?0:k]+=f[!flag][x][y][k];
				}
				else
				{
					f[flag][x][y+1][k]+=f[!flag][x][y][k];
					f[flag][x][0][k&1?k:0]+=f[!flag][x][y][k];
				}
			}
			if(flag)f[flag][0][y][0]+=f[!flag][x][y][i]+f[!flag][x][y][0];
			else f[flag][x][0][0]+=f[!flag][x][y][i]+f[!flag][x][y][0];
			if(flag)
			{
				if(y>=k/2+1&&i-2*x+k<=n)f[flag][x+1][y][i-2*x+k]+=f[!flag][x][y][0];
				else if(x>=k/2+1&&y&&i-1-2*y+2+k<=n)f[flag][x+1][y][i-1-2*y+2+k]+=f[!flag][x][y][0];
				else f[flag][x+1][y][0]+=f[!flag][x][y][0];
			}
			else
			{
				if(x>=k/2+1&&i-2*y+k<=n)f[flag][x][y+1][i-2*y+k]+=f[!flag][x][y][0];
				else if(y>=k/2+1&&x&&i-1-2*x+2+k<=n)f[flag][x][y+1][i-1-2*x+2+k]+=f[!flag][x][y][0];
				else f[flag][x][y+1][0]+=f[!flag][x][y][0];
			}
		}
//		printf("%d:\n",i);
//		for(int x=0;2*x-1<=i;x++)
//		{
//			for(int y=0;2*y<=i;y++)
//			{
//				printf("(");
//				for(int k=0;k<n;k++)
//				  printf("%lld ",f[flag][x][y][k]);
//				printf("%lld) ",f[flag][x][y][n]);
//			}
//			printf("\n");
//		}
	}
	bool flag=n&1;
	ll ans=0;
	for(int x=0;2*x-1<=n;x++)
	  for(int y=0;2*y<=n;y++)
	    for(int k=0;k<=n;k++)
	      ans+=f[flag][x][y][k];
	printf("%lld\n",ans%MOD);
	return 0;
}

Measured memory_bytes: 31872
N, M=map(int, input().split())
#s = [input().split() for i in range(Q)]

ans=[]

H = input().split()

for i in range(M):
    road=input().split()
    if int(H[int(road[0])-1])>int(H[int(road[1])-1]):
        ans.append(int(road[1]))
    elif int(H[int(road[0])-1])==int(H[int(road[1])-1]):
        ans.append(int(road[0]))
        ans.append(int(road[1]))
    else:
        ans.append(int(road[0]))

print(N-len(set(ans)))

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

using namespace std;

using Weight=long long;
struct Edge{
    int src,dst;
    Weight weight;
    Edge(int src,int dst,Weight weight):
    src(src),dst(dst),weight(weight){}
};

auto operator < (const Edge &e,const Edge &f){
    if(e.weight!=f.weight)return e.weight>f.weight;
    else if(e.src!=f.src)return e.src<f.src;
    else return e.dst<f.dst;
}

using Edges=vector<Edge>;
using Graph=vector<Edges>;

pair<Weight,int>sweep(int p,int v,const Graph &g){
    pair<Weight,int> r(0,v);
    for(auto e:g[v]){
        if(e.dst!=p){
            pair<Weight,int> t=sweep(v,e.dst,g);
            t.first+=e.weight;
            if(r.first<t.first)r=t;
        }
    }
    return r;
}

Weight double_sweep(const Graph &g,int s){
    pair<Weight,int> r=sweep(-1,s,g);
    pair<Weight,int> t=sweep(-1,r.second,g);
    return t.first;// (r.second, t.second) is farthest pair.
}

int main(){
    int n;
    cin>>n;
    Graph g(n);
    for(int i=1;i<n;++i){
        int s,t;
        Weight w;
        cin>>s>>t>>w;
        g[s].emplace_back(s,t,w);
        g[t].emplace_back(t,s,w);
    }
    cout<<double_sweep(g,0)<<endl;
    return 0;
}
//be checked by AOJ(GRL-5-A)

Measured memory_bytes: 17548
N=int(input())

num_end_dic={}
for i in range(1,N+1):  
  digit_i=len(str(i))
  head=i//(10**(digit_i-1))
  tail=i%10
  
  if tail==0:
    continue
  elif (head,tail) not in num_end_dic:
    num_end_dic[(head,tail)]=1
  else:
    num_end_dic[(head,tail)]+=1
  
#print(num_end_dic)
answer=0
for h,t in num_end_dic:
  if (t,h) in num_end_dic:
    answer+=num_end_dic[(h,t)]*num_end_dic[(t,h)]

print(answer)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define NMAX 200005
#define MOD 998244353

using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll pref_sum[NMAX],dp[NMAX];
pll intervals[NMAX];
ll query(ll l, ll r){
    if(r<0) return 0;
    return pref_sum[r]-(l>0?pref_sum[l-1]:0);
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll n,k;
    cin>>n>>k;
    for(ll i=0;i<k;i++)
        cin>>intervals[i].first>>intervals[i].second;
    dp[0]=pref_sum[0]=1;
    for(ll i=1;i<n;i++){
        for(ll j=0;j<k;j++){
            dp[i]+=query(i-intervals[j].second,i-intervals[j].first);
            dp[i]=(dp[i]+MOD)%MOD;
        }
        pref_sum[i]=(pref_sum[i-1]+dp[i])%MOD;
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 6764
from sys import setrecursionlimit as srl; srl(10**7)
rr = lambda: int(raw_input())
rrm = lambda: map(int, raw_input().split())

YES,NO = "APPROVED","DENIED"
def solve(N, A):
    for x in A:
        if x % 2 == 0:
            if x % 3 and x % 5:
                return NO
    return YES

    
print solve(int(rr()), rrm())


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

int main(void){
    int n, y;
    cin >> n >> y;
    for(int a=0; a<=n; a++){
        for(int b=0; b<=n-a; b++){
            int c = n-a-b;
            if(a*10000 + b*5000 + c*1000 == y){
                cout << a << " " << b << " " << c << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int W,H,x,y,r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if( (x+r)<=W && (y+r)<=H && x>=r && y>=r){
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 2100