akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  vector<ll int> N(2);
  cin>>N[0]>>N[1];
  int min;
  if(N[0]<N[1]) min=0;
  else min=1;
  double max=(min?sqrt(double(N[1])):sqrt(double(N[0])));
  ll int count=0;
  int check=0;
 
  for(ll int i=1;i<=max;i+=1){
    if(N[0]==1||N[1]==1){
      count++;
      break;
    }
    check=0;
    if(N[min]%i==0){
      for(ll int j=2;j<=(sqrt(double(i)));j+=1){
        if(i%j==0){
          check=1;
          break;
        }
      }
      if((!check)&&(N[!min]%i==0)){
        count++;
      }
    
    check=0;
    for(ll int j=2;j<=(sqrt(double(N[min]/i)));j++){
        if((N[min]/i)%j==0){
          check=1;
          break;
        }
      }
      if((!check)&&(N[!min]%(N[min]/i)==0)){
        count++;
      }
    }
  }
  
  cout<<count;
      

  
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


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

int main(){
  string a,b;
  cin>>a>>b;
  int ans=0;
  for(int i=0;i<3;i++){
  if(a[i]==b[i]){
    ans+=1;
  }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
//#define NDEBUG
 
#include <bits/stdc++.h>
 
#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define F first
#define S second
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}
#define pii pair<int, int>
#define pll pair<ll, ll>
#define modadd(a, b) (((a % MOD) + (b % MOD)) % MOD)
#define modtimes(a, b) (((a % MOD) * (b % MOD)) % MOD)
 
//#define TEST
 
typedef long long ll;
typedef unsigned long long ull;
 
using namespace std;
 
const ll MOD = 1000000007;
const ll MAX = 2147483647;

int main(){
    StarBurstStream

    string s, t;
    cin >> s >> t;

    int ans = 0;
    for(int i = 0; i < s.size(); i++) if(s[i] == t[i]) ans++;
    cout << ans << "\n";


    return 0;
}

Measured memory_bytes: 256
import heapq


X, Y, Z, K = map(int, input().split())

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

heap = []
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

seen = set((0, 0, 0))

heap = [[-(A[0]+B[0]+C[0]), 0, 0, 0]]
for _ in range(K):
    v, i, j, k = heapq.heappop(heap)
    print(-v)
    if i+1 < len(A) and (i+1, j, k) not in seen:
        seen.add((i+1, j, k))
        heapq.heappush(heap, [-(A[i+1]+B[j]+C[k]), i+1, j, k])
    if j+1 < len(B) and (i, j+1, k) not in seen:
        seen.add((i, j+1, k))
        heapq.heappush(heap, [-(A[i]+B[j+1]+C[k]), i, j+1, k])
    if k+1 < len(C) and (i, j, k+1) not in seen:
        seen.add((i, j, k+1))
        heapq.heappush(heap, [-(A[i]+B[j]+C[k+1]), i, j, k+1])

Measured memory_bytes: 4976
<?php
fscanf(STDIN, '%d', $arr[]);
fscanf(STDIN, '%d', $arr[]);
fscanf(STDIN, '%d', $arr[]);
fscanf(STDIN, '%d', $arr[]);
fscanf(STDIN, '%d', $arr[]);

$min = $arr[0] % 10;
$min_i = 0;
foreach ($arr as $i => $v) {
    $d1 = $v % 10;
    $_arr[] = (int)(ceil($v / 10) * 10);
    if ($d1 > 0 && $d1 < $min) {
        $min = $d1;
        $min_i = $i;
    }
}
$_arr[$min_i] = $arr[$min_i];
$ans = array_sum($_arr);
echo $ans . PHP_EOL;

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

using namespace std;

#define loop(i, n) for(int i = 0;i < int(n);i++)
#define rloop(i, n) for(int i = int(n);i >= 0;i--)
#define range(i, a, b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef long long ll;
typedef pair<int, int> pii;


int main() {

#ifndef ONLINE_JUDGE
//    freopen("in.in", "r", stdin);
    //freopen("out.in", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, id = 1;
    cin >> n;
    vector<pair<string, pii> > v(n);
    for (auto &p : v) {
        cin >> p.fr >> p.sc.fr;
        p.sc.sc = id++;
        p.sc.fr *= -1;
    }

    sort(ALL(v));
    loop(i, n)cout << v[i].sc.sc << endl;

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

def check(x, lst, k):
    cnt = 0
    for l in lst:
        cnt += (l - 1) // x
    if cnt  <= k:
        return True
    else:
        return False
    

def main():
    input = sys.stdin.readline
    
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    def check(x):
        cnt = 0
        for l in a:
            cnt += (l - 1) // x
        if cnt  <= k:
            return True
        else:
            return False
    
    ng = 0
    ok = 10 ** 9
    
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if check(mid):
            ok = mid
        else:
            ng = mid
    
    print(ok)


if __name__ == '__main__':
    main()


Measured memory_bytes: 92100
#include <stdio.h>

int main(void){
  int x,y,z;
  int temp;

  scanf("%d%d%d",&x,&y,&z);

  if(x>y){
    temp = x;
    x = y;
    y = temp;
  }

  if(y>z){
    temp = y;
    y = z;
    z = temp;
  }

  if(x>y){
    temp = x;
    x = y;
    y = temp;
  }

  printf("%d %d %d\n",x,y,z);

  return 0;

}

Measured memory_bytes: 596
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Sparsh Sanchorawala
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BBalance solver = new BBalance();
        solver.solve(1, in, out);
        out.close();
    }

    static class BBalance {
        public void solve(int testNumber, InputReader s, PrintWriter w) {
            int n = s.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = s.nextInt();
            int[] pre = new int[n];
            pre[0] = a[0];
            for (int i = 1; i < n; i++)
                pre[i] = pre[i - 1] + a[i];
            int res = Integer.MAX_VALUE;
            for (int i = 0; i < n - 1; i++)
                res = Math.min(res, Math.abs(pre[i] - (pre[n - 1] - pre[i])));
            w.println(res);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

int main() {
  int q;
  double x, xx, e;
  cout.setf(ios::fixed);
  while (cin >> q) {
    if (q == -1) break;
    x = q*0.5;
    while (1) {
      xx = x*x;
      e = xx*x - q;
      if (abs(e) < 1.0e-5 * q) break;
      x = x - e/(3.0*xx);
    }
    cout.precision(6);
    cout << x << endl;
  }
  return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll MOD = 1000000000+7;
ll checkbit(ll n , ll k)
{
    return (n&(1LL<<k));
}
bool comp(string a, string b)
{
  if(a.size()>=b.size())return false;
  else return true;
}
ll BIGMOD(ll x, ll y) {
    if(y == 0)
        return 1;
    ll tmp = BIGMOD(x, y/2);
    if(y%2 == 0)
        return (tmp*tmp)%MOD;
    else
        return (((tmp*tmp)%MOD)*x)%MOD;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
       ll x,k,d;
       cin>>x>>k>>d;
       x=abs(x);
      ll mx=x/d;
      ll ans=0;
      if(mx>=k)
      {
          ans=abs(x-d*k);
      }
      else
      {
         x=x-(mx*d);
         ll t=k-mx;
         if(t&1){ans=abs(x-d);}
         else ans=abs(x);
      }
      cout<<ans;
}


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

using ll = long long int;

ll arr_x[60] = {};
ll arr_y[60] = {};
ll arr_x2[60] = {};
ll arr_y2[60] = {};

int main(void){
    
    int n,k;
    cin >> n >> k;
    
    for(int i = 0; i < n; i++){
        cin >> arr_x[i] >> arr_y[i];
        arr_x2[i] = arr_x[i];
        arr_y2[i] = arr_y[i];
    }
    
    sort(arr_x2,arr_x2+n);
    sort(arr_y2,arr_y2+n);
    
    ll answer = 3000000000*3000000000;
    
    //left
    for(int i0 = 0; i0 < n; i0++){
        //right
        for(int i1 = i0+1; i1 < n; i1++){
            
            //up
            for(int i2 = 0; i2 < n; i2++){
                //down
                for(int i3 = i2+1; i3 < n; i3++){
                    int count = 0;
                    
                    for(int i4 = 0; i4 < n; i4++){
                        if( arr_x2[i1] >= arr_x[i4] && arr_x2[i0] <= arr_x[i4] && arr_y2[i2] <= arr_y[i4] && arr_y2[i3] >= arr_y[i4] ){
                            count++;
                        }
                    }
                    
                    if(count >= k){
                        answer = min(answer , (arr_x2[i1] - arr_x2[i0])*(arr_y2[i3] - arr_y2[i2]));
                    }
                }
            }
        }
    }
    
    cout << answer << endl;
    
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>


int marge ( long *A, long l, long m, long r){

    int c=0;

    long n1, n2;
    long *L, *R;
    long i, j, k;


    n1 = m - l; n2 = r - m;
    
    L = (long*)malloc(sizeof(long)*(n1+1));
    R = (long*)malloc(sizeof(long)*(n2+1));

    for( i=0L; i<n1; i++ ) L[i] = A[l+i];
    for( i=0L; i<n2; i++ ) R[i] = A[m+i];

    L[n1] = LONG_MAX;
    R[n2] = LONG_MAX;


    i=0L; j=0L;
    for( k=l; k<r; k++ ){
        if( L[i] <= R[j] ){
            A[k] = L[i];
            i++;
        }else{
            A[k] = R[j];
            j++;
        }
        c++;
    }

    free( L );
    free( R );

    return c;
}


int margeSort( long *A, long l, long r ){

    long m; // mid
    int c=0;


    if( l+1L < r ){
        m = ( l + r ) /2L;

        c += margeSort( A, l, m );
        c += margeSort( A, m, r );
        c += marge( A, l, m, r );
    }

    return c;
}




int main(){

    long n;
    long *S;
    long i;
    int c;
    
    scanf( "%ld", &n );

    S = (long*)malloc(sizeof(long)*n);

    for( i=0; i<n; i++ ){
        scanf( "%ld", &S[i] );
    }
    
    c = margeSort( S, 0L, n );

    for( i=0L; i<n; i++ ){
        printf( "%ld%c", S[i], ((i+1)<n)?' ':'\n' );
    }
    printf( "%d\n", c);

    free(S);
    return 0;
}



Measured memory_bytes: 9212
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;

int main()
{
	int V,E,R;
	cin >> V >> E >> R;
	vector<vector<pair<int,int>>> G(V);
	vector<ll> D(V,INF);
	for(int i = 0;i<E;i++)
	{
		int s,t,d;
		cin >> s >> t >> d;
		G[s].emplace_back(t,d);
	}

	D[R] = 0;
	for(int i = 0;i<V;i++)
	{
		bool update = false;
		for(int j = 0;j<V;j++)
		{
			//if(update == false)break;
			for(auto k:G[j])
			{
				if(D[k.first]>D[j]+k.second&&D[j]!=INF)
				{
					update = true;
					D[k.first] = D[j] + k.second;
				}
			}
		}
		if(update==false)break;
		if(i==V-3)
		{
			cout<<"NEGATIVE CYCLE"<<endl;
			return 0;
		}
	}
	for(auto i:D)
	{
		if(i==INF)
		{
			cout<<"INF"<<endl;
		}
		else
		{
			cout<<i<<endl;
		}
		
	}
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(0, min(b,d)-max(a,c)) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=3000005,M=1e9+7;
int n,ans,a[10],b[10],fac[N],inv[N];
int ksm(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=x*x%M)
		if (y&1)(ans*=x)%=M;
	return ans;
}
int C(int x,int y){
	if (x<y)return 0;
	return fac[x]*inv[y]%M*inv[x-y]%M;
}
int F(int x,int y){
	if (x<0||y<0)return 0;
	return C(x+y,x);
}
int solve(int x,int y,int xx,int yy){
	int ans=0;
	for (int i=a[3];i<=a[4];i++){
		(ans+=M-(i+b[3]-1)*F(i-x,b[3]-1-y)%M*F(xx-i,yy-b[3])%M)%=M;
		(ans+=(i+b[4])*F(i-x,b[4]-y)%M*F(xx-i,yy-(b[4]+1)))%=M;
	}
	for (int i=b[3];i<=b[4];i++){
		(ans+=M-(a[3]+i-1)*F(a[3]-1-x,i-y)%M*F(xx-a[3],yy-i)%M)%=M;
		(ans+=(a[4]+i)*F(a[4]-x,i-y)%M*F(xx-(a[4]+1),yy-i))%=M;
	}
	return ans;
}
signed main(){
	n=3000000;
	fac[0]=inv[0]=1;
	for (int i=1;i<=n;i++)fac[i]=fac[i-1]*i%M,inv[i]=ksm(fac[i],M-2);
	for (int i=1;i<=6;i++)scanf("%lld",&a[i]);
	for (int i=1;i<=6;i++)scanf("%lld",&b[i]);
	a[1]--;b[1]--;a[6]++;b[6]++;
	for (int i1=1;i1<=2;i1++)
		for (int i2=1;i2<=2;i2++)
			for (int j1=5;j1<=6;j1++)
				for (int j2=5;j2<=6;j2++)
					(ans+=(i1==i2?1:-1)*(j1==j2?1:-1)*solve(a[i1],b[i2],a[j1],b[j2]))%=M;
	printf("%lld\n",(M+ans)%M);
	return 0;
}


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

#define FOR(i,s,e) for(int i=s;i<e;i++)
#define RFOR(i,s,e) for(int i=s;i>=e;i--)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

#define SORT(arr) sort(arr, arr + ARRAY_LENGTH(arr))
#define MAX(arr) *max_element(arr, arr + ARRAY_LENGTH(arr))
#define MAXID(arr) distance(arr,max_element(arr, arr + ARRAY_LENGTH(arr)))
#define MIN(arr) *min_element(arr, arr + ARRAY_LENGTH(arr))
#define MINID(arr) distance(arr,min_element(arr, arr + ARRAY_LENGTH(arr)))
#define NID(arr,x) distance(arr,find(arr, arr + ARRAY_LENGTH(arr),x))




int N,T;


int main(){
	cin >> N >> T;
	int c[N],t[N];
	FOR(i,0,N){
		cin >> c[i] >> t[i];
	}
	if(MIN(t) > T) {
		cout << "TLE" << endl;
		return 0;
	}
	int ans = 99999;
	FOR(i,0,N){
		if(ans > c[i] && t[i] <= T) ans = c[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <string.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
// #include <unordered_map>
// #include <unordered_set>
#include <utility>
#include <vector>

#define pb push_back
#define mp make_pair

#ifdef ONLINE_JUDGE
#define link renamelink
#define next renamenext
#define prev renameprev
#endif

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef long double ld;

inline void EnableFileIO(const string& fileName, bool local = 0) {
  if (fileName.empty()) return;
  if (local) {
    freopen((fileName + ".in").c_str(), "r", stdin);
    freopen((fileName + ".out").c_str(), "w", stdout);
    return;
  }
#ifdef ONLINE_JUDGE
  freopen((fileName + ".in").c_str(), "r", stdin);
  freopen((fileName + ".out").c_str(), "w", stdout);
#endif
}

const int INF = (1 << 30) - 1;
const LL LINF = (1LL << 61) - 1;
const double EPS = 1e-10, PI = acos(-1);

int n, k;

int main() {
  // srand((int)time(0));
  // printf("Hello, world!\n");
  // EnableFileIO("");

  cin >> n >> k;
  int g;
  int mxv = 0;
  for (int i = 0, a; i < n; i++) {
    cin >> a;
    if (!i) {
      g = a;
    } else {
      g = __gcd(a, g);
    }
    mxv = max(mxv, a);
  }
  if (k % g == 0 && k <= mxv) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

#define REP(i,m,n) for(int i=(m); i<(n); i++)
#define RREP(i,n,m) for(int i=(n);i>=(m); i--)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << endl
// #define int long long 

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30)-1);
const ll linf = (1LL<<60);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct mint 
{
  ll x;
  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;
  }
  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;}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    ll ans = linf;
    REP(i,0,max(x,y)+1)
    {
        ll tmp1 = max((x-i),0), tmp2 = max((y-i),0);
        ans = min(ans, a*tmp1 + b*tmp2 + 2*c*i);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    int i;
    cin>>str;
    string jud=str;
    reverse(str.begin(),str.end());//交换
    for(i=0;i<str.size();i++)
    {
        if(str[i]=='b') str[i]='d';
        else if(str[i]=='d') str[i]='b';
        else if(str[i]=='p') str[i]='q';
        else if(str[i]=='q') str[i]='p';
    }
    if(str==jud) printf("Yes");
    else printf("No");
    return 0;
}

Measured memory_bytes: 512
import java.util.*;
 
class Main{
  public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   String a = sc.next(); 
  int ans = 0;
	int q = 0;
   for(int i = 0; i < 3; i++){
    System.out.print(10 - Character.getNumericValue(a.charAt(i)));
   }
  }
}

Measured memory_bytes: 22100
#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;

int main(){
	
	int angka;
	int arr[15][15];
	for (int a=1;a<=9;a++){
		for (int b=1;b<=9;b++){
			arr[a][b] = a*b;
		}
	}
	scanf ("%d",&angka);
	int check = 0;
	for (int a=1;a<=9;a++){
		for (int b=1;b<=9;b++){
			if (arr[a][b] == angka){
				//printf ("[%d %d]\n",arr[a][b],angka);
				check=1;
			}
		}
	}
	
	if (check==1){
		printf ("Yes\n");
	}
	else{
		printf ("No\n");
	}
}


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

#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)

using namespace std;
using ll = long long;
using pos = pair<ll, ll>;

ll x,a,b;

void solve();

int main() {

   solve();
   return 0;

}

void solve() {

    cin >>x>>a>>b;
    if(b-a<=0){
        cout << "delicious";
    }else if(b-a<x+1){
        cout << "safe";
    }else{
        cout << "dangerous";
    }
    cout << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
#define max(a, b) ((a) > (b) ? (a) : (b))

int main()
{
loop:;
  int n, m, i, mem = -1 << 30, ans = -1 << 30;
  scanf("%d", &n);
  if(!n)
    return n;

  for(i = 0; i < n; i++)
  {
    scanf("%d", &m);
    mem = max(mem + m, m);
    ans = max(ans, mem);
  }
  printf("%d\n", ans);
  goto loop;
}

Measured memory_bytes: 600
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
using namespace std;

const long mod = 1000000007;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
long fact(long x) { if (x == 0) return 1; else return((fact(x - 1) * x) % mod); }
long mybase(long N, long B) { if (N == 0) return 0; string S = ""; while (N != 0) { string M = to_string(N % B); N -= N % B; N /= B; S = M + S; }return stol(S); }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	string S; cin >> S;
	long mylen = S.length();

	if (mylen < 26) {
		for (int i = (int)'a'; i <= (int)'z'; i++) {
			bool isused = false;
			for (int j = 0; j < mylen; j++) if (S[j] == (char)i) isused = true;
			if (!isused) { S = S + (char)(i); cout << S << endl; return 0; }
		}
	}
	else {
		if (S == "zyxwvutsrqponmlkjihgfedcba") { cout << -1 << endl; return 0; }
		long last = 25 , change = 25;
		while (S[last - 1] > S[last]) last--;
		while (S[last - 1] > S[change]) change--; //最後の一文字を置き換えればよいわけではない。
        S[last - 1] = S[change];
		S.erase(last, 26 - last);
		cout << S << endl;
	}
}

Measured memory_bytes: 256
def abc044_c():
    import numpy as np
    n, a = map(int, input().split())
    x = list(map(lambda x: int(x) - a, input().split()))  # 平均ターゲット値を引いておく
    x = np.array(x, dtype=np.int64)

    vrange = n * (a + np.max(x))  # 取りうる値の幅(片側), 広めにとってもかまわない
    dp = np.zeros((n+1, 2*vrange+1), dtype=np.int64)  # DPテーブル
    dp[0, vrange] = 1  # 0枚時点で何も選ばずに総和0(平均ターゲット)になる場合を初期値にセット

    for i in np.arange(n):
        # 1つ前のターンを引き継ぐ
        dp[i+1, :] += dp[i, :]
        if 0 < x[i]:
            # x[i]が正の値、1つ前のx[i]個ぶん左側をスライドして持ってくる
            dp[i+1, x[i]:] += dp[i, :-x[i]]
        elif x[i] < 0:
            # x[i]が負の値、1つ前のx[i]個ぶん右側をスライドして持ってくる
            dp[i+1, :x[i]] += dp[i, -x[i]:]
        else:
            # x[i]がゼロ
            dp[i+1, :] += dp[i, :]

    ans = dp[n, vrange] - 1  # 初期値(何も選ばない)の1通りを除く
    print(ans)

if __name__ == '__main__':
    abc044_c()

Measured memory_bytes: 28160
N, K = map(int,input().split())
A = list(map(int,input().split()))
A = [A[k]-1 for k in range(N)]
now = 0
for k in range(70):
    if (K>>k)&1 == 1:
        now = A[now]
    A = [A[A[l]] for l in range(N)]
print(now+1)


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

int main() {
	char a, b, c;
	cin >> a >> b >> c;
	int i=0;
	if (a == '1') {
		i++;
	}
	if (b == '1') {
		i++;
	}
	if (c == '1') {
		i++;
	}
	cout << i << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
n_ = max(a)
r = a[0] if a[0] != n else a[1]
cur = r * (n - r)
for i in a:
    if i != n_:
        x = i * (n_ - i)
        if x > cur:
            r, cur = i, x
print(n_, r)


Measured memory_bytes: 14052
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define MOD 1000000007
#define enld endl
typedef long long ll;
using namespace std;

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

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int H,W,K; cin >> H >> W >> K;
    char c[10][10];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> c[i][j];
        }
    }

    int ans = 0;

    for(int i=0;i<(1<<H);i++){
        for(int j=0;j<(1<<W);j++){
            char copy[10][10];
            for(int i=0;i<10;i++){
                for(int j=0;j<10;j++){
                    copy[i][j] = c[i][j];
                }
            }
            for(int k=0;k<H;k++){
                if(i & (1 << k)){
                    for(int l=0;l<W;l++){
                        copy[k][l] = 'r';
                    }
                }
            }
            for(int k=0;k<W;k++){
                if(j & (1 << k)){
                    for(int l=0;l<H;l++){
                        copy[l][k] = 'r';
                    }
                }
            }

            int cnt = 0;
            for(int k=0;k<H;k++){
                for(int l=0;l<W;l++){
                    if(copy[k][l] == '#') cnt++;
                }
            }
            if(cnt == K) ans++;
        }
    }

    cout << ans << enld;
    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>

int main(int argc, char *argv[]){
  int a,b;
  scanf("%d %d", &a, &b);
  if(a<b)
    printf("a < b\n");
  else if(a>b)
    printf("a > b\n");
  else
    printf("a == b\n");
  return(0);
}


Measured memory_bytes: 2040
#include <iostream>
#include <map>

using namespace std;
typedef long long ll;
const int MAXN = 1e5+10;

ll n, m;
ll a[MAXN];
ll sum[MAXN];
map<ll, ll> cnt;

void solve() {
  for (int i=0;i<n;i++) {
    sum[i+1] = (sum[i] + a[i]) % m;
    cnt[sum[i+1]]++;
  }

  ll ans = 0;
  for (const auto& x : cnt) {
    ans += x.second * (x.second - 1) / 2;
    if (x.first == 0) {
      ans += x.second;
    }
  }
  cout << ans << endl;
}

int main() {
  cin >> n >> m;
  for (int i=0;i<n;i++) {
    cin >> a[i];
  }
  solve();
}


Measured memory_bytes: 5760
n,W=map(int,input().split())
wv=[list(map(int,input().split())) for _ in range(n)]
from collections import Counter
w0=wv[0][0]
d={w0:[0],w0+1:[0],w0+2:[0],w0+3:[0],}
for w,v in wv:
  d[w].append(v)
for i in range(4):
  d[w0+i].sort(reverse=True)
sd={}
for i in range(4):
  tmp=0
  sd[w0+i]=[0]
  for v in d[w0+i]:
    tmp+=v
    sd[w0+i].append(tmp)
ans=0
for i in range(len(d[w0])):
  for j in range(len(d[w0+1])):
    for k in range(len(d[w0+2])):
      for l in range(len(d[w0+3])):
        if w0*i+(w0+1)*j+(w0+2)*k+(w0+3)*l<=W:
          ans=max(ans,sd[w0][i]+sd[w0+1][j]+sd[w0+2][k]+sd[w0+3][l])
print(ans)

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

map<int, int> count;

void prime_factor(int n){
    for(int i=2; i*i<=n; i++){
        while(n%i == 0){
            count[i]++;
            n /= i;
        }
    }
    if(n!=1) count[n]++;
}

int main(){
    int n;
    long long ans = 1;
    const int M = 1000000007;
    cin >> n;
    for(int i=1; i<=n; i++){
        prime_factor(i);
    }
    for(int i=1; i<=n; i++){
        ans *= (count[i] + 1);
        ans %= M;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <string>
#include <algorithm>
#include <vector> 
#include <math.h>
#include <iostream>
using namespace std;
long long mod = 1000000000 + 7;

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

	int k;
	cin >> k;

	string n;
	cin >> n;
	char a, b, c;
	a = 'A';
	b = 'B';
	c = 'C';

	if (n[k - 1] == a) {
		n[k - 1] = 'a';
	}
	else if (n[k - 1] == b) {
		n[k - 1] = 'b';
	}
	else if(n[k - 1] == c){
		n[k - 1] = 'c';
	}


	cout << n << endl;
	return 0;

}


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;
typedef std::queue<long> QI;
#define rep(i,n) for(long i = 0; i < (long)n; ++i)
const double pi = M_PI;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   bool dp[32][128][128];
   void solve() {
      rep(c, 32) rep(i, 128) rep(k, 128) dp[c][i][k] = false;
      std::string ss; scan(ss);
      long n = ss.size();
      rep(i, n) {
         dp[ss[i]-'a'][0][i] = true;
      }
      for(long c = 0; c < 26; ++c) {
         for(long i = 1; i < n; ++i) {
            for(long k = 0; k < n; ++k) {
               dp[c][i][k] = dp[c][i-1][k] or dp[c][i-1][k+1];
            }
         }
      }
      long res = (1LL << 53);
      for(long c = 0; c < 26; ++c) {
         for(long i = 0; i < n; ++i) {
            bool flag = true;
            for(long k = 0; k < n-i; ++k) {
               if( not dp[c][i][k] ) { flag = false; break; }
            }
            if( flag ) res = std::min(res, i);
         }
      }
      printf("%ld\n", res);
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}



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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n; ll t, x;
	cin>>n>>t;
	ll ans = 0, cur = 0;
	for(int i = 0; i < n; i++){
		cin>>x;
		if(x <= cur){
			ans += x + t - cur;
		}else{
			ans += t;
		}
		cur = x + t;
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
ary = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
i = gets.to_i
puts ary[i - 1]


Measured memory_bytes: 1788
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            Console.WriteLine(n < 1000 ? "ABC" : "ABD");
        }
    }
}


Measured memory_bytes: 13140
import java.io.*;
import java.util.*;

public class Main {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	void go(ArrayDeque<Integer> q, long x) {
		if (x == 1) {
			return;
		}
		if (x % 2 == 0) {
			go(q, x / 2);
			q.addLast(q.size() + 1);
		} else {
			go(q, x - 1);
			q.addFirst(q.size() + 1);
		}
	}
	
	void solve() throws IOException {
		long x = nextLong() + 1;
		ArrayDeque<Integer> q = new ArrayDeque<>();
		go(q, x);
		
		List<Integer> ans = new ArrayList<>();
		for (int i = 1; i <= q.size(); i++) {
			ans.add(i);
		}
		
		ans.addAll(q);
		out.println(ans.size());
		for (int xx : ans) {
			out.print(xx + " ");
		}
		out.println();
	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <list>
#include <iomanip>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}
#

int main() {
	int n; cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	sort(p.begin(), p.end());
	Int sum = 0;
	for (int i = 0; i < n; i++) {
		sum += p[i];
	}
	cout << sum - p[n - 1] / 2;

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define _GLIBCXX_DEBUG
static const int MAX = 100;

struct Card{ char suit, value; };

void bubble(Card A[], int N){
    bool flag = 1;

    for(int i = 0; flag; i++){
        flag = 0;

        for(int j = N-1; j >= i+1; j--){
            if(A[j].value < A[j-1].value){
                swap(A[j], A[j-1]);
                flag = 1;
            }
        }
    }
}

void selection(Card A[], int N){
    int minj;

    rep(i, N-1){
        minj = i;

        rep2(j, i, N){
            if(A[j].value < A[minj].value) minj = j;
        }

        swap(A[i], A[minj]);
    }
}

void trace(Card A[], int N){
    int i;
    rep(i, N){
        if(i > 0) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(Card A1[], Card A2[], int N){
    rep(i, N){
        if(A1[i].suit != A2[i].suit) return false;
    }
    return true;
}

int main(){
    int N;
    Card A1[100], A2[100];

    cin >> N;
    rep(i, N) cin >> A1[i].suit >> A1[i].value;
    rep(i, N) A2[i] = A1[i];

    bubble(A1, N);
    trace(A1, N);
    cout << "Stable" << endl;

    selection(A2, N);
    trace(A2,N);
    if(isStable(A1, A2 , N)){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }

}


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

int main() {
    int n,k;
    cin>>n>>k;
    int h[n];
    for (int i=0;i<n;i++)
        cin>>h[i];
    sort(h,h+n);
    int mn=1e9;
    for (int i=0;i+k-1<n;i++)
        mn=min(mn,h[i+k-1]-h[i]);
    cout<<mn<<endl;
    return 0;
}

Measured memory_bytes: 640
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

S = str(input())
week = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
print(7 - week.index(S))

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

#define PrintLn(X) cout << X << endl
int main(void)
{
	int A, B, C;
	cin >> A >> B >> C;
	cout << ((A <= C && C <= B) ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int i,j;            //  ループ文に使用
    int x,y,z;
    int n;
    int box[100001] = {};
    int mode = 0;
    int min = 1000000;
    int max = 0;
    int count,count2;   //  カウント用に使用
    char s[256];        //  文字列
    
    count = 0;
    count2 = 0;
    
    //  入力処理
    
    scanf("%d",&n);
    for (i = 0; i < n; i++){
        scanf("%d",&box[i]);

        if (i != (n - 1)){
            if (min > box[i]){
                min = box[i];
            }
            if (box[i] > min + 1 && box[i] > max){
                mode = 2;
                max = box[i];
            }
        }
        if (mode == 2){
            if (max - 1> box[i]){
                mode = 1;
                break;
            }
        }
        if (i > 0 && i != (n - 1)){
            if (box[i - 1] + 1 < box[i]){
                mode = 2;
            }
        }
        
        if (mode == 2){
            if (max - 1 >box[i]){
                mode = 1;
                break;
            }
        }
    }
    
    if (n == 2){
        if (box[0] - 1> box[1]){
            mode = 1;
        }
    }
/*
    if (max - 1 > min){
        mode = 1;
    }
    */
    //  計算処理

    //  出力処理
    
    if (mode == 0 || mode == 2){
        printf("Yes");
    }else{
        printf("No");
    }
    
}


Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <cmath>
#pragma warning(disable:4996)
using namespace std;
int i, j, k, n, m, b, c, d, f, g, w, h, q, x, y;
long long ret[100005];
int a[100005], o[100005], e[100005], om, os, em, es;


int main(){
	scanf("%d",&n );
	for(i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		if (i & 1) {
			o[a[i]]++;
			if (o[a[i]] >= o[om] && a[i] != om) {
				os = om;
				om = a[i];
				//printf("om:%d* ", om);
			}
		}
		else {
			e[a[i]]++;
			if (e[a[i]] >= e[em] && a[i] != em) {
				es = em;
				em = a[i];
				//printf("em:%d* ", em);
			}
		}
	}
	if (om == em) o[om] - o[os] > e[em] - e[es] ? em = es : om = os;
	//printf("os:%d, om:%d ,es:%d, em:%d ",os, om, es, em);
	printf("%d", n - o[om] - e[em]);
}

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

using namespace std;

bool check(int i) {
    if (i % 10 == 3) {
        return true;
    }
    if (i / 10 == 0) {
        return false;
    }
    return check(i / 10);
}

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0 || i % 10 == 3 || check(i)) {
            cout << " " << i;
        }
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

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

struct item
{
    ll w, v;
};
ll n, W;
vector<item> items;
map<pair<int, int>, int> dic;

ll rec_dp(ll i, ll w)
{
    if (dic.count(make_pair(i, w)) > 0)
    {
        return dic[make_pair(i, w)];
    }
    ll result;
    if (i == n)
    {
        result = 0;
    }
    else if (w - items[i].w < 0)
    {
        result = rec_dp(i + 1, w);
    }
    else
    {
        result = max(
            rec_dp(i + 1, w),
            rec_dp(i + 1, w - items[i].w) + items[i].v);
    }
    dic[make_pair(i, w)] = result;
    return result;
}

int main()
{
    cin >> n >> W;
    items.resize(n);
    rep(i, n)
    {
        cin >> items[i].w >> items[i].v;
    }
    cout << rec_dp(0, W) << endl;
}


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

int c[10][10];
int cnt[10];
int d[10][10];

int main(void){
  int H, W; cin >> H >> W;
  for(int i=0;i<10;i++)for(int j=0;j<10;j++){
    cin >> c[i][j];
    d[i][j] = c[i][j];
  }
  for(int i=0;i<H;i++)for(int j=0;j<W;j++){
    int tmp; cin >> tmp;
    if (tmp >= 0) cnt[tmp]++;
  }
  
  for(int i=0;i<10;i++)for(int j=0;j<10;j++)for(int k=0;k<10;k++){
    d[j][k] = min(d[j][k], d[j][i] + d[i][k]);    
  }
  int ans = 0;
  for(int i=0;i<10;i++) ans += cnt[i] * d[i][1];
  cout << ans << endl;
  return 0;
}
  
  
  
  
  
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1e9)
using namespace std;

string s;
int p;
bool flg;
int bnf();
bool check(int i){return i<s.size()&&s[i]!='+'&&s[i]!='-'&&s[i]!='*'&&s[i]!=')';}

bool check2(){
  if(s[p]!='(')return 1;
  int i=p+1;
  while(isdigit(s[i]))i++;
  if(s[i]==')')return 0;
  
  i=p+2;
  int c=s[p+1]=='(';
  while(i<s.size()&&c) c+=(s[i]=='(')-(s[i++]==')');
  return c==0&&s[i]!=')';
}


int Num(){
  int res=0;
  if(s[p]=='('){
    flg&=check2();
    p++;
    res=bnf(),flg&=s[p++]==')';
    return res;
  }

  while(isdigit(s[p]))res=res*2+s[p++]-'0';
  if(res>1024)flg=0;
  return res;
}

int calc(){
  int res=0;
  p++;
  flg&=check2()&check(p);
  if(s[p]=='('){
    res=bnf();
    if(res<0||res>=1024)flg=0;
    return res;
  }
  res=Num();
  if(s[p]=='*') res*=calc();
  if(res<0||res>=1024) flg=0;
  return res;
}

int bnf(){
  flg&=check(p);
  int res=Num();
  while(p<s.size()&&flg){
    if(s[p]=='(') flg=0;
    if(s[p]==')')break;
    flg&=check(p+1);
    if(s[p]=='+')res+=calc();
    else if(s[p]=='-')res-=calc();
    else if(s[p]=='*')res*=calc();
    else break;
    if(res<0||res>=1024) flg=0;
  }
  if(!flg||res>=1024||res<0)return -INF;
  return res;
}

int dfs(int idx){
  char ch[]={'0','1','+','-','*','(',')'};
  while(idx<s.size()&&s[idx]!='.')idx++;
  if(idx==s.size()){p=0,flg=1;return max(-1.0,bnf()-(p!=s.size())*INF);}

  int res=-1;
  for(int i=0;i<7;i++)s[idx]=ch[i],res=max(res,dfs(idx+1));
  s[idx]='.';
  return res;
}

int main(){
  cin>>s;
  cout<<dfs(0)<<endl;
  return 0;
}

Measured memory_bytes: 3168
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    int n;
    std::cin>>n;
    std::vector<std::string> s(n);
    for(int i = 0;i < n;i++){
        std::cin>>s[i];
    }
    int m;
    std::cin>>m;
    std::vector<std::string> t(m);
    for(int i = 0;i < m;i++){
        std::cin>>t[i];
    }

    std::vector<std::string> u;
    std::copy(s.begin(), s.end(), back_inserter(u));
    std::copy(t.begin(), t.end(), back_inserter(u));
    std::sort(u.begin(), u.end());
    u.erase(std::unique(u.begin(), u.end()), u.end());

    int total = 0;
    for(auto i = u.begin();i != u.end();i++){
        int k = 0;
        for(auto j = s.begin();j != s.end();j++){
            if(*i == *j){
                ++k;
            }
        }
        for(auto j = t.begin();j != t.end();j++){
            if(*i == *j){
                --k;
            }
        }
        if(total < k){
            total = k;
        }
    }
    std::cout<<total<<std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int Inf = 1e9 + 7;
const int maxn = 1e5 + 7;
queue <int> qua;
map <int, int> mp;
int n;

int main() {
    cin >> n;
    int minT = Inf;
    if(n % 10 == 0) minT = 10;
    else {
        for(int i = 1; i <= n; i++) {
            int t = i, p = n - i;
            int s1 = 0, s2 = 0;
            while(t) {
                s1 += t % 10;
                t /= 10;
            }
            while(p) {
                s2 += p % 10;
                p /= 10;
            }
            minT = min(minT, s1 + s2);
        }
    }
    cout << minT << endl;
}

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


int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    ll n, k; cin >> n >> k;
    cout << min(n % k, k - n % k) << '\n';

    return 0;
}


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

int main()
{
ll s , w ;
cin >> s >> w ;
if(w>=s)ans="unsafe";
cout << ans << endl;
return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(void) {
	int N,M;
	scanf("%d%d",&N,&M);
	long long int dp[N+1];
	int s[N+1];
	for(int i=0;i<N+1;i++) s[i] = 1;
	for(int i=0;i<M;i++){
		int a;
		scanf("%d",&a);
		s[a] = 0;
	}
	dp[0] = 1; dp[1] = 1*s[1];
	for(int i=2;i<N+1;i++){
		dp[i] = ((dp[i-1]+dp[i-2])*s[i])%1000000007;
	}
		printf("%d",dp[N]%1000000007);
		
	/*for(int i=0;i<=N;i++){
		printf("%d %d\n",dp[i],s[i]);
	}*/
	
	return 0;
}

Measured memory_bytes: 1280