akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


unsigned int A[100000+1];
unsigned int B[100000+1];
int N,K;


LL getMaxX(unsigned int X) {
	LL value = 0;
	for(int i=0; i<N; i++) {
		if( (A[i] | X) == X ) {
			value += B[i];
		}
	}
	return value;
}



int main(void) {

	cin >> N >> K;
	for(int i=0; i<N; i++) {
		cin >> A[i] >> B[i];
	}


	int r = 0;
	unsigned int R = 0;
	for(int i=0; i<=30; i++) {
		if( (K & (1<<i)) != 0 ) {
			r = i;
		}
	}
	/*
	for(int i=0; i<=r; i++) {
		R += (1<<i);
	}
	
	LL res = 0;
	for(int i=0; i<=r; i++) {
		unsigned int X = R - (1<<i);
		if ( X > K ) continue;
		res = max(res,getMaxX(X));
	}
	*/
	LL res = getMaxX(K);
	for(int i=0; i<=r; i++) {
		if ( (K & (1<<i))==0 ) continue;
		unsigned int X = K - (1<<i);
		for(int j=0; j<i; j++) {
			X |= 1<<j;
		}
		res = max(res,getMaxX(X));
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

int main(){
  int n; cin >> n;
  vi a(n); rep(i, n) cin >> a[i];
  //a[0], a[1], a[2]
  vi lm(n);// lm[i]; iより左にある者たちの中でのmax　lm[0]=0 としとく
  for(int i = 1; i < n; i++) lm[i] = max(lm[i-1],a[i-1]);
  vi rm(n);// rm[i]; iより右にある者たちの中でのmax rm[n-1] = 0
  for(int i = n-2; i >= 0; i--) rm[i] = max(rm[i+1],a[i+1]);

  rep(i, n) std::cout << max(lm[i], rm[i]) << '\n';
}


Measured memory_bytes: 3968
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;
const long long MINF = LLONG_MIN;

// -------------------------------------------------------
const int MAX = 1010101;

long long binom[55][55];

void binom_init() {
  binom[0][0] = 1;
  binom[1][0] = 1;
  binom[1][1] = 1;

  for (int i = 2; i <= 50; ++i) {
    binom[i][0] = 1;
    for (int j = 1; j <= i; ++j) {
      binom[i][j] = binom[i - 1][j - 1] + binom[i - 1][j];
    }
  }
}

ll N, A, B;
ll v[100];

int main() {
  binom_init();
  cin >> N >> A >> B;
  rep(i, 0, N) { cin >> v[i]; }
  sort(v, v + N, greater<ll>());
  ll sum = 0;
  rep(i, 0, A) { sum += v[i]; }
  long double sumd = sum;
  cout << setprecision(20) << fixed << sumd / A << endl;

  ll lastv = v[A - 1];
  ll lastvcnt = 0;
  ll ulastv = 0;
  rep(i, 0, N) {
    if (v[i] > lastv) ++ulastv;
    if (v[i] == lastv) ++lastvcnt;
  }

  ll ans = 0;
  if (ulastv == 0) {
    repe(i, A, B) {
      ll num = i - ulastv;
      ans += binom[lastvcnt][num];
    }
  } else {
    ll num = A - ulastv;
    ans += binom[lastvcnt][num];
  }
  cout << ans << endl;
}



Measured memory_bytes: 3780
import sys
array = [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]
print(array[int(sys.stdin.readline()) - 1])

Measured memory_bytes: 3060
import java.util.*;

public class Main{
    public static void main(String[] args){
	int count = 0;
	boolean p = true;
	Scanner a = new Scanner(System.in);
	int n = a.nextInt();
	int m[] = new int[n];
	for(int i = 0; i < n; i++){
	    m[i] = a.nextInt();
	}
	for(int i=0; i<n; i++){
	    p = true;
	    if(m[i]==2){
	        count++;
	    }
	    else if(m[i]>2 && m[i]%2==0){
	        continue;
	    }
	    else{
		for(int j=3; j <= Math.sqrt(m[i]); j+=2){
		    if(m[i]%j == 0){
			p = false;
			break;
		    }
		}
		if(p){
		count++;
		}
	    }
	}
	System.out.println(count);
    }
}



Measured memory_bytes: 40972
#include<iostream>
using namespace std;
int main(){
  int n, h, dp[20], cnt=1;
  cin >> n;
  cin >> dp[0];
  for(int i=1; i<n; i++){
    cin >> h;
    if(h >= dp[i-1]){
      cnt ++;
      dp[i] = h;
    }else{
      dp[i] = dp[i-1];
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
import static java.lang.System.out;
import java.util.Scanner;
import java.util.Arrays;
public class Main{
   public static void main(String[]aa){
      Scanner sc = new Scanner(System.in); 
      String[] S =sc.nextLine().split("");
      int count=0;
      for(int i=0;i<S.length;i++){
            if(S[i].equals("1")){
                  count++;
            }
      }
      out.println(count);
      sc.close();
   }
}


Measured memory_bytes: 21716
h, w, a, b = map(int, input().split())
ans = []
x = ['0'*a + '1'*(w-a)]
y = ['1'*a + '0'*(w-a)]
for i in range(b):
  ans.append(x)
for j in range(h-b):
  ans.append(y)
  
for line in ans:
    print(''.join(line))

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
int main()
{
    
   int n,c=0;
   string s;
   cin>>s;
   if(s[0]=='7' ||s[1]=='7' || s[2]=='7')
   {
       c++;
   }
   
   if(c>0)
   {
       cout<<"Yes";
   }
   else
   cout<<"No";
    return 0;
}


Measured memory_bytes: 3624
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
	int a, b, c;
	cin >> a >> b >>c;

    cout << min (b/a, c) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;

ll a[N];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n, x;
    cin >> n >> x;
    for(int i = 0; i < n; i++) cin >> a[i];
    x *= 2;
    ll lcm = a[0];
    for(int i = 1; i < n; i++){
        lcm = lcm / __gcd(lcm, a[i]) * a[i];
        if(lcm > x) return cout << 0, 0;
    }
    if(lcm > x) return cout << 0, 0;
    for(int i = 0; i < n; i++){
        if((lcm / a[i]) % 2 == 0) return cout << 0, 0;
    }
    cout << x / lcm - x / (2 * lcm);

    return 0;
}


Measured memory_bytes: 4432
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            long[] A = new long[N];
            long[] max = {0, 0};
            for (int i = 0; i < N; i++) {
                A[i] = in.nextLong();
                if (max[0] <= A[i]) {
                    max[1] = max[0];
                    max[0] = A[i];
                } else if (max[1] < A[i]) {
                    max[1] = A[i];
                }
            }

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < N; i++) {
                if (A[i] == max[0]) {
                    sb.append(max[1]).append('\n');
                } else {
                    sb.append(max[0]).append('\n');
                }
            }
            out.print(sb.toString());
        }

    }
}



Measured memory_bytes: 97312
/*  ex4_1
    kosaq       */

#include <stdio.h>
#include <math.h>

int main(void){
    double n_tree;//N本の林檎の木をn_treeで定義
    double d_range;//一人は、D本先までを監視できるのでDをd_rangeで定義
    double one_observe;//一人が監視できる林檎の木の数
    int people_number;//N本の林檎の木を監視するために必要な人数の最小値

    scanf("%lf %lf", &n_tree, &d_range);//NとDを入力

    one_observe = d_range * 2 + 1;//一人が監視できる林檎の木の数
    people_number = ceil(n_tree / one_observe);//N本の林檎の木を監視するために必要な人数の最小値は(n_tree / one_observ)eの小数値を切り上げた整数
    printf("%d\n", people_number);//N本の林檎の木を監視するために必要な人数の最小値を出力

    return 0;
}

Measured memory_bytes: 128
num = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
b, f, r, v, v1, n, x, y, z  = 0, 0, 0, 0, 0, 0, 0, 0, 0
n = int(input())
for i in range(n):
	b, f, r, v = list(map(int, input().split()))
	num[b - 1][f - 1][r - 1] += v
for i in range(4):
	if y >= 1:
		z = 0
		y = 0
		x += 1
		print()
		print('####################')
	for i in range(3):
		if z >= 1:
			z = 0
			y += 1
			print('')
		for i in range(10):
			print('', num[x][y][z], end = '')
			z += 1
print()

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

using namespace std;
int n;
int a[55];
int main()
{
    scanf("%d",&n);
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]!=i) ans++;
    }
    if(ans==0||ans==2)
        printf("YES");
    else
        printf("NO");
    return 0;
}


Measured memory_bytes: 256
n=int(input())

count=0
i=1

#if n<10:
#    print(n)
#else:

now=[1]
for i in range(n-1):
    j=0
    tmp_len=len(now)
    while True:
        if j == tmp_len-1:
            if now[j]==9:
                for k in range(tmp_len):
                    now[k]=0
                now.append(1)
            else:
                now[j]+=1
                for k in reversed(range(tmp_len-1)):
                    now[k] = now[k+1]-1 if now[k+1] > 0 else 0
            break
        else:
            if now[j] <= now[j+1] and now[j]<9:
                now[j]+=1
                for k in reversed(range(j)):
                    now[k] = now[k+1]-1 if now[k+1] > 0 else 0
                break
            else:
                j+=1
print("".join(list(map(str,reversed(now)))))

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>

char map[505][505];
char ans[2][505][505];

int main() {
	int h, w;
	scanf("%d%d", &h, &w);
	for(int i = 0;i < h;i++) scanf("%s", map[i]);
	for(int k = 0;k < 2;k++) {
		for(int i = 0;i < h;i++) 
			for(int j = 0;j < w;j++) 
				ans[k][i][j] = ((i % 2 == k)? '.': '#');
		for(int i = 0;i < h;i++)
			ans[k][i][k % 2? 0: w - 1] = '#', ans[k][i][k % 2? w - 1: 0] = '.';	
	}
	for(int i = 0;i < h;i++)
		for(int j = 0;j < w;j++)
			if(map[i][j] == '#')
				ans[0][i][j] = ans[1][i][j] = '#';
	for(int k = 0;k < 2;k++, putchar(10))
		for(int i = 0;i < h;i++, putchar(10))
			for(int j = 0;j < w;j++) putchar(ans[k][i][j]);
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;
#define MAX 1000000000
int dis[1050][1050];

/*黒マスの位置*/
typedef struct position {
 int y;
 int x;
}position_ ;

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

int main(void){
 string A[1050];
 queue<position_> Q;
 int cnt=0;
 cin>>H>>W;
 
 for(int i=0; i<H; i++)cin>>A[i];
 
 position_ B;
 for(int i=0; i<H; i++)
  for(int j=0; j<W; j++){
   if(A[i][j]=='#'){
    B.x=j;
    B.y=i;
    Q.push(B);
    dis[i][j]=0;
   }
   else{
    dis[i][j]=MAX;
   }
  }
 
 position_ C;
 while(Q.empty()!=true){
  B=Q.front();
  Q.pop();
  for(int i=0; i<4; i++){
   if(0<=dx[i]+B.x && dx[i]+B.x<W && 0<=dy[i]+B.y && dy[i]+B.y<H){
    if(dis[dy[i]+B.y][dx[i]+B.x]==MAX){
     dis[dy[i]+B.y][dx[i]+B.x]=dis[B.y][B.x]+1;
     C.x=B.x+dx[i];
     C.y=B.y+dy[i];
     Q.push(C);
     ans=max(ans,dis[dy[i]+B.y][dx[i]+B.x]);
    }
   }
  }
 }
 cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 13584
#include <algorithm>
#include <iostream>

using namespace std;

long long ceil(long long x, int n) {
  return x % n == 0 ? x / n : x / n + 1;
}

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

  int N;
  cin >> N;

  int x, y;
  long long a, b;
  cin >> a >> b;
  for (int i = 1; i < N; ++i) {
    cin >> x >> y;
    long long n = max(ceil(a, x), ceil(b, y));
    a = n * x;
    b = n * y;
  }

  cout << a + b << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int G[105][105];

signed main()
{
    int W,H,N; cin>>W>>H>>N;
    while(N--){
        int x,y,a; cin>>x>>y>>a;

        if(a==1){
            REP(i,x) REP(j,H) G[i][j]=1;
        }
        if(a==2){
            for(int i=x;i<W;i++) REP(j,H) G[i][j]=1;
        }
        if(a==3){
            REP(i,W) REP(j,y) G[i][j]=1;
        }
        if(a==4){
            REP(i,W) for(int j=y;j<H;j++) G[i][j]=1;
        }
    }
    
    int ans=0;
    REP(i,W) REP(j,H) if(G[i][j]==0) ans++;
    cout<<ans<<endl;

}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	int a, b;
	string s;
	cin >> a >> b;
	if (a == 1) a = 14;
	if (b == 1) b = 14;
	if (a > b) s = "Alice";
	else if (a < b) s = "Bob";
	else s = "Draw";
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a, b, q;
    cin >> a >> b >> q;
    vector<ll> s(a), t(b);
    rep(i, a) cin >> s[i];
    rep(i, b) cin >> t[i];
    
    rep(i, q) {
        ll x, dx = __LONG_LONG_MAX__;
        cin >> x;
        
        int sp = lower_bound(all(s), x) - s.begin();
        int tp = lower_bound(all(t), x) - t.begin();
        
        if ((sp < sz(s)) && (tp < sz(t))) {
            dx = min(dx, max(s[sp] - x, t[tp] - x));
        }
        
        if ((sp < sz(s)) && (tp > 0)) {
            dx = min(dx, (s[sp] - x) + (x - t[tp - 1]) + min(s[sp] - x, x - t[tp - 1]));
        }
        
        if ((sp > 0) && (tp < sz(t))) {
            dx = min(dx, (x - s[sp - 1]) + (t[tp] - x) + min(x - s[sp - 1], t[tp] - x));
        }
        
        if ((tp > 0) && (sp > 0)) {
            dx = min(dx, max(x - s[sp - 1], x - t[tp - 1]));
        }
        
        cout << dx << endl;
    }
    
    return 0;
}

Measured memory_bytes: 2944
/*input
6
30 10 60 10 60 50
*/

#include <functional>
#include <algorithm>
#include <iostream>
#include <string.h>
#include <utility> 
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>

using namespace std;

using ll = long long;
using ld = long double;

const int SINF = 1000000009;
const ll INF =  1000000000000000018;

#define sp          cout << " "
#define nl          cout << "\n"
#define all(c)      (c).begin(),(c).end()
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define ifalse      ios_base::sync_with_stdio(false), cin.tie(NULL)

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T, typename U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.first >> p.second;
  return is;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for(auto x: v) {
    os << x << " ";
  }
  return os;
}

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto &x : v) is >> x;
  return is;
}

/******************************** START *********************************/
const int N = 100005;

int main()
{
  ifalse;
  int n;
  cin >> n;
  vector < int > v(n);
  cin >> v;

  int dp[n + 1] = {0};
  for(int i = 1; i < n; i ++) {
    dp[i] = dp[i - 1] + abs(v[i] - v[i - 1]);
    if(i - 2 >= 0) {
      dp[i] = min(dp[i], dp[i - 2] + abs(v[i] - v[i - 2]));
    }
  }
  cout << dp[n - 1], nl;
  return 0;
}

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

int main(){
    int n, a, b, c, d;
    int l[4][3][10];
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 10; k++){
                l[i][j][k] = 0;
            }
        }
    }
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a >> b >> c >> d;
        l[a - 1][b - 1][c - 1] += d;
    }
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 10; k++){
                cout << " " << l[i][j][k];
            }
            cout << endl;
        }
        if(i != 3)cout << "####################" << endl;
    }
    
    return 0;
}


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

int main(void){
  int m,d;
  cin >> m >> d;
  int ans = 0;
  for(int i = 1;i <= m;i++){
        for(int j = 1;j <= d;j++){
              int a = j % 100 / 10;
              int b = j % 10;
              if(a >= 2 && b >= 2){
                    if(a * b == i){
                          ans++;
                    }
              }
        }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3596
# include <bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
	int N;
  	cin >> N;
	map<string, int> strings;
    int max = 0;
  	for (int i = 0; i < N; ++i) { 
      string s;
      cin >> s;
      strings[s] += 1;
      
      if (max < strings[s]) max = strings[s];
    }
  
    for(auto x : strings) {
    	if (max == x.second) cout << x.first << endl;
    }

    return 0;
}

Measured memory_bytes: 25216
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

INF = 1 << 60

dp = [INF] * (h + 1)
dp[0] = 0

for i in range(0, h + 1):
    #　hを超えるために必要な最小コストは？
    for a, b in ab:
        if i + a <= h:
            dp[i + a] = min(dp[i] + b, dp[i + a])
        else:
            dp[h] = min(dp[i] + b, dp[h])

print(dp[h])

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

int main() {
  int N,count=0;
  string S;
  cin>>N>>S;
  for(int i=0;i<N-2;i++){
    if(S.at(i)=='A' && S.at(i+1)=='B' && S.at(i+2)=='C'){
      count++;
    }
  }
  cout<<count<<endl;
}



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

int main(){

    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<int> l(Q), r(Q);
    for(int i = 0; i < Q; i++) cin >> l[i] >> r[i];

    vector<int> ac_sum(S.length(), 0);
    for(int i = 1; i < S.length(); i++){
        if(S[i - 1] == 'A' && S[i] == 'C') ac_sum[i] = ac_sum[i - 1] + 1;
        else ac_sum[i] = ac_sum[i - 1];
    }

    for(int i = 0; i < Q; i++){
        int ans = ac_sum[r[i] - 1] - ac_sum[l[i] - 1];
        cout << ans << endl;
    }

    return 0;
}

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

using namespace std;

vector<int> v;

int check(int x)
{
    int pos = lower_bound(v.begin(), v.end(), x) - v.begin();
    if(v.size()-pos == pos)
        return 1;
    else
        return 0;
}


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

    int x;
    cin>>x;

    v.resize(x);
    
    for(int i = 0; i< x; i++)
    {
        cin>>v[i];
    }

    sort(v.begin(), v.end());
    int count = 0;
    int maxi = *max_element(v.begin(), v.end());

     for(int i = 0; i <= maxi; i++)
    {
        if(check(i))
            count++;
    }
    
    cout<<count;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vvl v = VV(n, 2, 0, ll);
  re(i, n) scanf("%lld %lld", &v[i][0], &v[i][1]);

  sort(all(v));
  if(n%2==1){
    ll L = v[n/2][0];
    sort(all(v), [](vll a, vll b){return a[1]<b[1];});
    ll R = v[n/2][1];
    std::cout << R - L + 1 << '\n';
    return 0;
  }else{
    ll l = v[n/2-1][0] + v[n/2][0];
    sort(all(v), [](vll a, vll b){return a[1]<b[1];});
    ll r = v[n/2-1][1] + v[n/2][1];
    std::cout << r - l + 1 << '\n';
  }
  return 0;
}


Measured memory_bytes: 13684
#include <iostream>
#include <algorithm>
#define llint long long
#define inf 1e18

using namespace std;

llint N;
llint A[200005];
llint sum[200005];

int main(void)
{
	cin >> N;
	for(int i = 1; i <= N; i++) cin >> A[i];
	for(int i = 1; i <= N; i++){
		sum[i] = sum[i-1] + A[i];
	}
	sort(sum, sum+N+1);
	
	llint ans = 0;
	llint prev = -inf, cnt = 0;
	for(int i = 0; i <= N; i++){
		if(prev == sum[i]) cnt++;
		else{
			ans += cnt * (cnt-1) / 2;
			cnt = 1;
		}
		prev = sum[i];
	}
	ans += cnt * (cnt-1) / 2;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3328
#include<cstdio>
int gcd(int a,int b){return b?gcd(b,a%b):a;}
long long inv(int a,int p){return p==1?0:(1+p*(a-inv(p%a,a)))/a%p;}
bool find(long long a1,long long b1,long long c1,long long a2,long long b2,long long c2,long long&x,long long&y){
	long long t1=a1/c1,t2=a2/c2,y1=b1/c1,y2=(b2-1)/c2;
	a1-c1*t1<0?t1--:1;
	a2-c2*t2<0?t2--:1;
	b1-c1*y1<0?y1--:1;
	b2-1-c2*y2<0?y2--:1;
	if(y1<y2){
		x=0;y=y2;
		return 1;
	}
	if(y1>y2||t1>t2||!a2)return 0;
	if(t1){
		bool res=find(a1-c1*t1,b1,c1,a2-c2*t2,b2,c2,x,y);y+=x*t1;
		return res;
	}
	bool res=find(c2,c2*(y2+1)-b2,a2,c1,c1*(y1+1)-b1,a1,x,y);
	t1=x;x=y;y=t1+y1+1;
	return res;
}
int calc(int A,int X,int B,int Y,int C){
	int G=gcd(B,C),z=C/G,x=G/gcd(A,G),y=1ll*A*x/G*inv(B/G,z)%z;
	if(!y)return X/x+Y/z;
	long long x0,y0,l=0,r=1ll*Y*x+1ll*X*y+1,m;
	while(r-l>1){
		m=(l+r)/2;
		if(find(-y,-y,z,-1ll*Y*x-1ll*X*y,m-1ll*Y*x-1ll*X*y,1ll*X*z,x0,y0))r=m;
		else l=m;
	}
	find(-y,-y,z,-1ll*Y*x-1ll*X*y,r-1ll*Y*x-1ll*X*y,1ll*X*z,x0,y0);
	y0=(x0+1)*y%z;x0=(x0+1)*x;
	int t=(x0*Y+y0*X)/z/x,x1=inv(x0/x*y/z,x0/x)*x*t%x0;
	x1=X-(X+x1)%x0;
	if(y0*x1+x0*Y<1ll*t*z*x)t--;
	return t;
}
int main(){
	int T;scanf("%d",&T);
	while(T--){
		int A,X,B,Y,C;
		scanf("%d%d%d%d%d",&A,&X,&B,&Y,&C);
		printf("%d\n",calc(A,X,B,Y,C));
	}
}

Measured memory_bytes: 3224
#include <iostream>
#include <cmath>
#include <cstring>

using std::cin;
using std::cout;
using std::endl;

void solve() {
  int d, n, c = 0;
  cin >> d >> n;

  for (int i = 1; ; ++i) {
    int k = int(pow(10, d)) * i;
    int cnt = 0;
    while (k % 100 == 0) {
      cnt++;
      k /= 100;
    }
    if (cnt == d) {
      c++;
      if (c == n) {
        cout << int(pow(10, d)) * i << endl;
        return;
      }
    }
  }
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 384
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        double a = scanner.nextDouble();
        BigDecimal b = new BigDecimal(a);
        BigDecimal c = new BigDecimal(2);
        BigDecimal d = new BigDecimal(3.14159265359);

//        Integer b = scanner.nextInt();

        BigDecimal x = b.multiply(c).multiply(d);
        BigDecimal y = b.multiply(b).multiply(d);
        System.out.println(y + " " + x);
    }
}


Measured memory_bytes: 28280
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define vpii vct<pii>
#define vpll vct<pll>
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define print(v) for(auto it:v)cout<<it<<' ';cout<<endl;
#define PI 2*acos(0.0)
#define yes cout<<"Yes"<<endl
#define no cout<<"-1"<<endl
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
///................function.....................///
#define siz(s) (int)(s.size())
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
int main()
{
    FIO;
    ///freopen("in.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    int n;
    cin>>n;
    n%=1000;
    (n==0)?cout<<0<<endl:cout<<1000-n<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>

int main(void)
{
	int n;
	int ct = 0;
	scanf("%d", &n);
	
	if (n % 10) {
		for (n; n>0; n/=10) {
			ct += (n % 10);
		}
		printf("%d\n", ct);
	} else {
		for ( n; n>10; n /= 10 ) {
		}
		printf("%d\n", n);
	}
	
	return 0;
}

Measured memory_bytes: 128
/*挿入ソート*/
#include <stdio.h>
#include <stdlib.h>
#define N 1000001

void insertionSort(int *, int, int);

int cnt=0;

int main()
{
  int i, j, n, m, x;
  int g[N], A[N];
  
  scanf("%d", &n);
  for (i=0; i<n; i++){
    scanf("%d", &A[i]);
  }

  
  g[0] = 1;
  i=1;
  while(1){
    x = 3*g[i-1]+1;
    if (n>x){
      g[i] = x;
      i++;
    }
    else break;
  }
  m = i;

  for (i=m-1; i>=0; i--){
    insertionSort(A, n, g[i]);
  }
  
  /*結果の出力*/
  printf("%d\n", m);

  for (i=m-1;i>=0;i--){
    if(i==0)
      printf("%d\n", g[i]);
    else
      printf("%d ", g[i]);
  }

  printf("%d\n", cnt);

  for (i=0; i<n; i++)
    printf("%d\n", A[i]);
  
  return 0;
}

void insertionSort(int *A, int n, int g){
  int i, j, v;

  for (i=g; i<n; i++){
    v = A[i];
    j = i - g;
    while (j>=0 && A[j] > v){
      A[j+g] = A[j];
      j -= g;
      cnt++;
    }
    A[j+g] = v;
  }
}



Measured memory_bytes: 5644
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
#define fori(s,n) for(ll i=s;i<=n;i++)
#define ford(s,n) for(int i=n;i>=s;i--)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define TEST(t) for(int T=1;T<=t;T++)
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,f=0;
    cin>>n;
  	while(n){
      if(n%10==7) f=1; 
      n/=10;
    }
  if(f==1) cout<<"Yes";
  else cout<<"No";
    return 0;
}


Measured memory_bytes: 3640
import sys

number = int(input())
box = list(map(int,input().split()))

for var in box:
    if var == 0:
        print("0")
        sys.exit()

overflow = 1e18
ans = 1
for var in box:
    if overflow/var < ans:
        print("-1")
        sys.exit()
    ans *= var

if ans <= overflow:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 21552
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;

const int N=370;
const int M=30;

int D,ans,d,q;
int s[N][M],lst[M],c[M],t[N],cnt[N][M];

int calc(){
	int sum=0;
	for (int i=1;i<=26;i++) lst[i]=0;
	for (int i=1;i<=D;i++){
		sum+=s[i][t[i]];
		lst[t[i]]=i;
		for (int j=1;j<=26;j++) sum-=c[j]*(i-lst[j]);
	}
	return sum;
}

int argmx(int d){
	int id=1;
	for (int i=2;i<=26;i++)
		if (s[d][i]>s[d][id]) id=i;
	return id;
}

int main(){
	scanf("%d",&D);
	for (int i=1;i<=26;i++) scanf("%d",&c[i]);
	for (int i=1;i<=D;i++)
		for (int j=1;j<=26;j++) scanf("%d",&s[i][j]);
	for (int i=1;i<=D;i++) t[i]=argmx(i);
	ans=calc();
	int lim=100000/D/26;
	for (int T=1;T<=lim;T++){ 
		int sum,tmp;
		for (int d=1;d<=D;d++){
			for (int q=1;q<=26;q++){
				tmp=t[d];
				t[d]=q; sum=calc();
				if (sum>ans) ans=sum;
				else t[d]=tmp;
			}
		}
	}
	for (int i=1;i<=D;i++) printf("%d\n",t[i]);
	return 0;
}

Measured memory_bytes: 3864
L=[]
c=0
while 1:
  L+=[map(int, raw_input().split())]
  if L[c][0]+L[c][1]+L[c][2]==-3:
    break
  c+=1
  
c=0
while 1:
  if L[c][0]+L[c][1]+L[c][2]==-3:
    break
  if L[c][0]==-1 or L[c][1]==-1 or L[c][0] + L[c][1] < 30:
    print 'F'
  elif L[c][0] + L[c][1] >=80:
    print 'A'
  elif 65 <= L[c][0] + L[c][1] < 80:
    print 'B'
  elif 50 <= L[c][0] + L[c][1] < 65 or 30 <= L[c][0] + L[c][1] < 50 and L[c][2] >= 50:
    print 'C'
  else:
    print 'D'
  c+=1

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

int main(){

  int s,X, Y, W, H,N,x,y,a;
  cin >> s;
  while(s){
    a = 0;
    cin >> X >> Y >> W >> H >> N;
    while(N){
      cin >> x >> y;
      if( X <= x && X + W >= x &&  Y <= y && Y + H >= y)
	a++;
      N--;
    }
    cout << a<<endl;
    s--;
  }
  return 0;
} 

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define forr(i,p,n) for(ll i=p;i<n;i++)
#define tam 200010
#define tamlog 12
#define offset 50000
#define mp make_pair
using namespace std;
typedef long long  ll;
typedef pair<ll,ll> ii;
typedef pair<string,ll> si;
typedef pair<ll,ii> iii;
const ll INF=1e11;
ll H,W,N;
set<ii> resp[12];
set<ii> s;
ll hay(ll xx,ll yy)
{
    if (s.find(mp(xx,yy))==s.end())
        return 0;
    return 1;
}
bool valid(ll xx,ll yy)
{
    if (xx<=0|| yy<=0|| xx>H|| yy>W)
        return 0;
    return 1;
}
ll calc(ll xx,ll yy)
{
    ll tot=0;
    for(ll i=0;i>=-2;i--)
    {
        for(ll j=0;j>=-2;j--)
        {
            if (valid(xx+i,yy+j)==false)
                return 10;
            tot+=hay(xx+i,yy+j);
        }
    }
    return tot;
}
ll vx[tam],vy[tam];
int main()
{
    
    cin>>H>>W>>N;
    forr(i,0,N)
    {
        cin>>vx[i]>>vy[i];
        s.insert(ii(vx[i],vy[i]));
    }
    ll xx,yy;
    forr(i,0,N)
    {
        forr(j,0,3)
        {
            forr(k,0,3)
            {
                xx=vx[i]+j;
                yy=vy[i]+k;
                resp[calc(xx,yy)].insert(ii(xx,yy));

            }
        }
    }
    ll atot=0;
    forr(i,1,10)
    atot+=resp[i].size();
    cout<<(H-2)*(W-2)-atot<<endl;
    forr(i,1,10){
        cout<<resp[i].size()<<endl;
        /*for(set<ii>::iterator ite=resp[i].begin();ite!=resp[i].end();ite++)
        {
            //cout<<(*ite).fi<<" "<<(*ite).se<<endl;  
        }*/
    }

}


Measured memory_bytes: 64256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int m,n;
    cin>>n>>m;
    int c = 0;
  	long a[n];
  	for(int i=0;i<n;i++) cin>> a[i];
  	double votes = accumulate(a,a+n,0);
  	for(int i =0;i<n;i++) if(a[i] >=(double)(votes/(m*4)) ) c++;
	if(c<m) cout<< "No";
  	else cout << "Yes";
}

Measured memory_bytes: 256
/*
 * Author:  heyuhhh
 * Created Time:  2020/5/31 20:46:05
 */
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <assert.h>
#include <functional>
#include <numeric>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A> 
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 2e5 + 5;

struct seg {
    int l, r;   
}a[N];

int n;

int findL(int k) {
    return a[k + 1].r;
}

int findR(int k) {
    return a[k + 1].l;
}

seg find(int k) {
    sort(a + 1, a + n + 1, [&](seg A, seg B) {
        return A.r < B.r;
    });
    int r = findL(k - 1);
    sort(a + 1, a + n + 1, [&](seg A, seg B) {
        return A.l > B.l;
    });   
    int l = findR(n - k);
    return seg{l, r};
}

void run() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int l, r; cin >> l >> r;
        a[i] = seg{l, r};
    }
    if (n & 1) {
        seg res = find(n / 2 + 1);
        int ans = max(0, res.r - res.l + 1); 
        cout << ans << '\n';
    } else {
        seg res1 = find(n / 2), res2 = find(n / 2 + 1);
        int Min = res1.l + res2.l, Max = res1.r + res2.r;
        int ans = max(0, Max - Min + 1);
        cout << ans << '\n';
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}

Measured memory_bytes: 5220
fun main(args: Array<String>){
    val n = readLine()!!.toInt()
    val h = readLine()!!.split(" ").map(String::toLong).reversed().toLongArray()
    for(i in 1 until n){
        if(h[i] - h[i-1] > 1L){
            println("No")
            return
        }
        if(h[i] - h[i-1] == 1L){
            h[i]--
        }
    }
    println("Yes")
}

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

int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    rep(i, N) cin >> A[i];
    
    long long ans = 0, digit = 0;
    int right = 0;
    rep(left, N) {
        while (right < N && digit + A[right] == (digit ^ A[right])) {
            digit += A[right];
            ++right;
        }
        ans += right - left;
        if (left == right) ++right;
        else digit -= A[left];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1920
N = int(input())
A = list(map(int , input().split()))
B = list(map(int , input().split()))
C = list(map(int , input().split()))
ans = 0
for i in range(len(A)):
    ans += B[A[i] - 1]
    if i == len(A) - 1:
        break
    else:
        if A[i + 1] == A[i] + 1:
            ans += C[A[i] - 1]
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <set>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    set<char> s;
    for (int i = 0; i < n; ++i)
    {
        char x;
        cin >> x;
        s.insert(x);
    }
    if (s.size() == 3)
        cout << "Three";
    else
        cout << "Four";
    return 0;
}


Measured memory_bytes: 256
;; #!/usr/bin/env sbcl --script

(declaim (optimize (speed 3) (safety 0) (debug 0)))

(defun main ()
  (let* ((n (read))
         (k (read))
         (a (make-array n :element-type 'fixnum))
         (dp (make-array n :element-type 'fixnum :initial-element (floor most-positive-fixnum 2))))
    (let ((stream (make-string-input-stream (read-line))))
      (loop for i from 0
         for j = (read stream nil) until (null j)
         do (setf (aref a i) j)))
    (setf (aref dp 0) 0)
    (dotimes (i n)
      (loop with from-val fixnum = (aref dp i)
         for j fixnum from (1+ i) to (+ i k)
         while (< j n)
         do
           (let ((nval (+ from-val (abs (- (aref a i) (aref a j))))))
             (setf (aref dp j) (min (aref dp j) nval)))))
    (format t "~a~%" (aref dp (- n 1)))))

(main)


Measured memory_bytes: 57700
import sys
import heapq as h

input=sys.stdin.readline

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

formersum=[0 for i in range(0,N+1)]
former=A[0:N]
formersum[0]=sum(former)
h.heapify(former)
for i in range(1,N+1):
    end=i+N-1
    new=A[end]
    m=h.heappop(former)
    if m<new:
        formersum[i]=formersum[i-1]+new-m
        h.heappush(former,new)
    else:
        formersum[i]=formersum[i-1]
        h.heappush(former,m)

A=A[::-1]
A=[-A[i] for i in range(0,3*N)]

latersum=[0 for i in range(0,N+1)]
later=A[0:N]
latersum[0]=sum(later)
h.heapify(later)
for i in range(1,N+1):
    end=i+N-1
    new=A[end]
    m=h.heappop(later)
    if m<new:
        latersum[i]=latersum[i-1]+new-m
        h.heappush(later,new)
    else:
        latersum[i]=latersum[i-1]
        h.heappush(later,m)

latersum=latersum[::-1]
ans=[formersum[i]+latersum[i] for i in range(0,N+1)]
print(max(ans))


Measured memory_bytes: 119312
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
//#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;



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

	int A, B;
	cin >> A >> B;
	if (A >= 13) {
		print(B);
	}
	else if (6<=A&&A <= 12) {
		print(B / 2);
	}
	else {
		print(0);
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int H1, M1, H2, M2, K;
	scanf("%d %d %d %d %d", &H1, &M1, &H2, &M2, &K);
	int time = (H2 - H1) * 60 + (M2 - M1);
	printf("%d", time - K);
	return 0;
}

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;
const int ROW_MAX = 100;

int main() {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    vector<vector<char>> ans(ROW_MAX, vector<char>(ROW_MAX));
    rep(y, ROW_MAX / 2) rep(x, ROW_MAX) ans[y][x] = '#';
    rep(y, ROW_MAX / 2) rep(x, ROW_MAX) ans[ROW_MAX / 2 + y][x] = '.';

    rep(i, a) {
        int j = i * 2;
        int x = j % (ROW_MAX - 2) + 1;
        int y = j / (ROW_MAX - 2) * 2;

        ans[y][x] = '.';
    }

    rep(i, b) {
        int j = i * 2;
        int rx = j % (ROW_MAX - 2) + 1;
        int ry = j / (ROW_MAX - 2) * 2;

        int y = ROW_MAX - ry - 1;
        ans[y][rx] = '#';
    }

    printf("100 100\n");
    rep(y, ROW_MAX) {
        rep(x, ROW_MAX) {
            cout << ans[y][x];
        }
        cout << endl;
    }


}




Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <stack>
#include <string.h>
#define rep(i, n) for(int i=0;i<n;i++)
#define FOR(i, j, n) for(int i=j;i<n;i++)
#define NOT_FOUND 0
using namespace std;

vector<int> graph[100001];
int memo[100001];

int dfs(int start, int label) {
    stack<int> stack;
    stack.push(start);
    memo[start] = label;

    while(!stack.empty()) {
        int v = stack.top();
        stack.pop();
        vector<int> edges = graph[v];

        rep(i, edges.size()) {
            int next = edges[i];
            if (memo[next] == 0) {
                memo[next] = label;
                stack.push(next);
            }
        }
    }
    return 1;
}

int main() {
    int n, m;
    cin >> n >> m;

    for (int i = 0; i < m; i++) {
        int v, e;
        cin >> v >> e;
        graph[v].push_back(e);
        graph[e].push_back(v);
    }

    memset(memo, 0, sizeof(memo));
    int id = 1;
    rep(i, n) {
        if (memo[i] == 0) {
            dfs(i, id++);
        }
    }

    int q;
    cin >> q;
    rep(i, q) {
        int s, d;
        cin >> s >> d;
        if (memo[s] == memo[d]) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 9008
import collections
s=list(map(str,input()))
if s[0]=="A":
    c=collections.Counter(s[2:-1])
    if c["C"]==1:
        s.remove("A")
        s.remove("C")
        s=map(str,s)
        s="".join(s)
        if s.islower():
            print("AC")
        else:
            print("WA")
    else:
        print("WA")
else:
    print("WA")


Measured memory_bytes: 3316
import sys, math
from functools import lru_cache
from collections import deque

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    A = list(mi())
    cnt = 0
    
    p = [1]*N
    for j in range(N-1):
        p[j+1] = 3*p[j]

    for i in range(3**N):
        B = [0]*N
        flg = False
        for j in range(N):
            t = (i//p[j])%3
            if t == 0:
                B[j] = A[j]
            if t == 1:
                B[j] = A[j]+1
            if t == 2:
                B[j] = A[j]-1

            if B[j]%2 == 0:
                flg = True
        
        if flg:
            cnt += 1

    print(cnt)

        

if __name__ == '__main__':
    main()


Measured memory_bytes: 9476
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <memory>
#include <iostream>

using namespace std;

struct Node {
    int key;
    Node *prev, *next;
};

using node_ptr = Node*;

class Linkedlist{
    public:
    Node *nil;
    Linkedlist(){
        // nilは常に最初にいる
        nil = (Node *)malloc(sizeof(Node));
        nil->next = nil;
        nil->prev = nil;
    };

    void insert(int key){
        Node *x = (Node *)malloc(sizeof(Node));
        x->key = key;
        // Add an element immediately after the sentinel
        x->next = nil->next;
        nil->next->prev = x;
        nil->next = x;
        x->prev = nil;
    };

    Node* search(int key){
        Node* cur = nil->next;
        while( cur != nil && cur->key != key){
            cur = cur->next;
        }
        return cur;
    };

    void deletenode(node_ptr t){
        if (t == nil) return; //番兵は削除しない
        t->prev->next = t->next;
        t->next->prev = t->prev;
        free(t);
    };

    void deletefirst(){
        deletenode(nil->next);
    };

    void deletelast(){
        deletenode(nil->prev);
    };

    void deletekey(int key){
        deletenode(search(key));
    }
};

void printlist(Linkedlist list){
    node_ptr cur = list.nil->next;
    int isf = 0;
    while(1){
        if (cur == list.nil) break;
        if (isf++ > 0) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

int main(){
    int key{0}, n{0}, i{0};
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    cin >> n;
    Linkedlist list;
    for (i = 0; i < n; i++){
        scanf("%s%d", com, &key);
        if (com[0] == 'i'){ 
            list.insert(key); 
            np++; 
            size++;}
        else if (com[0] == 'd'){
            if (strlen(com) > 6){
                if (com[6] == 'F') {
                    list.deletefirst();
                }
                else if (com[6] == 'L') {
                    list.deletelast();
                }
            }else{
                list.deletekey(key); nd++;
            }
            size--;
        }
    }
    printlist(list);
}


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

int main(void) {

    string S;
    cin >> S;

    if (S=="Sunny") 
        cout << "Cloudy" << endl;
    else if (S=="Cloudy")
        cout << "Rainy" << endl;
    else if (S=="Rainy")
        cout << "Sunny" << endl;
    return 0;
}


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

#define ll long long

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	 cin >> n;
	 vector<int>v(n);
	 for(int i=0;i<n;i++)
	 	cin >> v[i];
	 sort(v.begin(),v.end());
	 for(int i=1;i<n;i++){
	 	if(v[i]==v[i-1]){
	 		cout << "NO";
	 		return 0;
	 	}
	 }
	 cout << "YES";
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;


int main() {
    ios_base::sync_with_stdio(false); 

    int n,m;
    cin >> n >> m;
    vector<vector<int>> r(n);
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        r[a-1].push_back(b-1);
        r[b-1].push_back(a-1);
    }
    queue<int> q;
    q.push(0);
    vector<int> cost(n,-1); 
    cost[0]=0;
    while (!q.empty()) {
        int now=q.front();
        q.pop();
        rep(i,r[now].size()) {
            int next=r[now][i];
            if (cost[next]==-1) {
                q.push(next);
                cost[next]=cost[now]+1;
            }
        }
    }
    if (cost[n-1]<=2 && cost[n-1]!=-1) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 13168