akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line
vector<int> color(210,-1);
vector<int> graph[205];
bool dfs(int v, int c) {
	color[v] = c;
	for (int i = 0; i < graph[v].size(); i++){
		// 隣接している頂点が同じ色ならfalse
		if(color[graph[v][i]] == c) return false;
		// 隣接している頂点がまだ塗られていないなら、1-cで塗る
		if(color[graph[v][i]] == -1){
			if(dfs(graph[v][i], 1-c) == false) return false;
		}
		// 塗られてて、チガウ色のときは何もしなくていい。（これは、根の方に戻らないという意味にもなる)
	}
	return true;
}
vector<int> dist(210,-1);
int dig(int v, int d){
	dist[v] = d;
	for(int i = 0; i < graph[v].size(); i++){
		if(dist[graph[v][i]] == -1){
			dig(graph[v][i], d + 1);
		}
	}
	int ret = 0;
	rep(i,203) {
		ret = max(dist[i],ret);
	}
	return ret;
}
int main()
{
	int n;
	cin >> n;
	rep(i,n){
		string s;
		cin >> s;
		rep(j,n){
			if(s[j] == '1'){
				graph[i].push_back(j);
			}
		}
	}
	// 二部グラフ判定
	if(dfs(0, 0)){
		// dfsをした結果二部グラフ
		// 根とするのにどれが最適かをN頂点全部調べる
		int ans = 0;
		rep(i,n){
			// 根を i としたときの、深さのMAXを知る
			// BFSで
			int ret = 0;
			queue<P> que;
			vector<bool> seen(n,false);
			seen[i] = true;
			que.push(P(i,0));
			while(que.size()){
				int v = que.front().first;
				int w = que.front().second;
				que.pop();
				for(auto x: graph[v]){
					if(seen[x])continue;
					que.push({x,w+1});
					ret = max(ret,w+1);
					seen[x] = true;
				}
			}
			ans = max(ret,ans);
		}
		cout << ans + 1 << endl;
	} else {
		cout << -1 << endl;
	}
}


Measured memory_bytes: 512
#include<stdio.h>
int main()
{
    int x,i,count=0;
    for(i=1; i<=10000; i++)
    {
        while(scanf("%d",&x)!=EOF)
            if(x!=0)
            {
                {
                    count=count+i;
                    printf("Case %d: %d\n",count,x);
                }
            }

    }
    return 0;
}



Measured memory_bytes: 2044
// Combinatorial - Longest Increasing Subsequence
// ?§£??¬???????????????????£??????????
// ?§£??¬?????????????????£?????????O(n^2)?????¢?????´????????????????????§???????????\????????????
// ????????????O(NlogN)?????¢?????´?????????????????????????????????????????????????????¨????????????
// ??°?±?????????£??????
// ????????¢?´¢??§?????????????????????????????????????????????accept??????????????£??????
// ?´???????????????????????????§?§£????????¨???????????????????§?????????????????????£??????
#include <iostream>
#include <vector>
#define MAX 100100
#define rep(i,p) for(int i=0;i<p;i++)
#define pb push_back
using namespace std;
int n,temp,length,j;
int LAST[MAX]={0};
std::vector<int> A;

int binary_search (int x, int end) {
  int m,s=1,l=end;
  if (l-s <= 1) {
    if (LAST[1] > x) return 1;
    else return 2;
  }
  while ( l-s > 1) {
    m = (s+l)/2;
    if ( LAST[m] > x ) l = m;
    else s = m;
  }
  if (LAST[s] >= x) return s;
  else return l;
}
int main(){
  cin >> n;
  rep(i,n) {
    cin >> temp;
    A.pb(temp);
  }

  LAST[1] = A.at(0);
  length = 1;

  for (int i=1; i<n; i++) {    
    if (LAST[length] < A.at(i)) {
      length++;
      LAST[length] = A.at(i);
    } else {
      j = binary_search(A.at(i),length);
      LAST[j] = A.at(i);
    }
//    rep(k,length) cout << LAST[k+1] << " ";
 //   cout << endl;
  }
  cout << length << endl;
  return 0;
}

Measured memory_bytes: 2068
C[1<<18]={0,1},j,N;main(i){for(;i++<5e4;)for(j=i;j<1e5;)C[j+=i]=1;for(;~scanf("%d",&N);printf("%d\n",j))for(j=i=0;i++<N;)j+=!C[i]&!C[N+1-i];}

Measured memory_bytes: 0
n = int(input())
R = []
for i in range(n):
    R.append(int(input()))

# R???i???????????§???????°???????i?????????????´???¨???????????????list
mins = [R[0]]
for i in range(1, n):
    mins.append(min(R[i], mins[i-1]))

# ???????????????j????????????????????\??????????°??????¨??????????±?????????????????????§???????±????????????????
mx = - 10 ** 12
for j in range(1, n):
    mx = max(mx, R[j] - mins[j-1])

print(mx)

Measured memory_bytes: 17012
//49
#include<iostream>
#include<string>

using namespace std;

int main(){
  for(char t;cin>>t,t!='#';){
    int s[2]={};
    int l=0;
    string c[4][13];
    for(int i=0;i<4;i++){
      for(int j=0;j<13;j++){
	cin>>c[i][j];
      }
    }
    for(int i=0;i<13;i++){
      int x=l;
      for(int j=0;j<4;j++){
	if(c[j][i][1]!=c[x][i][1]){
	  if(c[j][i][1]==t){
	    x=j;
	  }
	}else{
	  string r="23456789TJQKA";
	  if(r.find(c[j][i][0])>r.find(c[x][i][0])){
	    x=j;
	  }
	}
      }
      s[x%2]++;
      l=x;
    }
    if(s[0]>s[1]){
      cout<<"NS "<<s[0]-6<<endl;
    }else{
      cout<<"EW "<<s[1]-6<<endl;
    }
  }
}

Measured memory_bytes: 1196
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

typedef complex<double> P;

// OÏ
double cross(P a, P b)
{	return a.real() * b.imag() - b.real() * a.imag();	}

// àÏ
double dot(P a, P b)
{	return a.real() * b.real() + a.imag() * b.imag();	}

// _ÆüªÌ£
double dist(P a, P b, P c)
{
	if(dot(b - a, c - a) < EPS) return abs(c - a);
	if(dot(a - b, c - b) < EPS) return abs(c - b);
	
	return abs(cross(b - a, c - a)) / abs(b - a);
}

// _ªOp`ÌÉ é©
bool isInTriangle(P p[3], P x)
{
	double S = abs(cross(p[1] - p[0], p[2] - p[0]));
	
	rep(i, 3) S -= abs(cross(p[(i + 1) % 3] - p[i], x - p[i]));
	
	return abs(S) < EPS;
}

int main()
{
    int n;
	cin >> n;
	
	
	while(n--)
	{
		P p[3];
		P k, s;
		
		rep(i, 3) cin >> p[i].real() >> p[i].imag();
		cin >> k.real() >> k.imag() >> s.real() >> s.imag();
	
		if(isInTriangle(p, k) ^ isInTriangle(p, s))
		{
			cout << "OK" << endl;
		}
		else
		{
			cout << "NG" << endl;
		}
	}
}

Measured memory_bytes: 952
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int main() {
  int N; cin>>N;
  cout << (N<1000 ? "ABC" : "ABD") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	int a, b, c;

	scanf("%d %d %d", &a, &b, &c);


	if (a <= b&&b <= c)
		printf("%d %d %d\n", a, b, c);
	else if (a <= c&&c <= b)
		printf("%d %d %d\n", a, c, b);
	else if (b <= a&&a <= c)
		printf("%d %d %d\n", b, a, c);
	else if (b <= c&&c <= a)
		printf("%d %d %d\n", b, c, a);
	else if (c <= a&&a <= b)
		printf("%d %d %d\n", c, a, b);
	else if (c <= b&&b <= a)
		printf("%d %d %d\n", c, b, a);

	return 0;
}

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

bool ok(int i, string s1, string s2)
{
  for (int j = 0; j < s2.size(); j++)
    if (s1[i+j] != s2[j])
      return false;
  return true;
}

int main()
{
  string s1, s2; cin >> s1 >> s2;
  for (int i = 0; i < s1.size(); i++) {
    if (ok(i, s1, s2))
      cout << i << endl;
  }
  return EXIT_SUCCESS;
}




Measured memory_bytes: 3208
main = do 
    [n, x] <- map (read :: String -> Int). words <$> getLine
    l <- map (read :: String -> Int). words <$> getLine
    print $ 1 + solve x 0 l
    where
        solve k d [] = 0
        solve k d (x:xs) = 
            if (nextd <= k)
            then 
                1 + solve k nextd xs
            else
                solve k nextd xs
            where
                nextd = d + x



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

int main(){
  int n; cin >> n;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  int ans = 0;
  sort(l.begin(), l.end());
  rep(b,n)rep(a,b){
    int ab = l[a] + l[b];
    int r = lower_bound(l.begin(), l.end(), ab) - l.begin();
   // cout << r << b << endl;
    ans += r - b - 1;
  }

  cout << ans << endl;
}



Measured memory_bytes: 256
#if 0
date +%Y.%m.%d

题解先咕着。
        ▁▃▄▄▄▃▃▃▃▄▶
      ▗▇▀▔    ▔▔▔▔
     ▄▛   ▃▅━━■▄▂
    ▟▊   ▐▘     ▀▙
   ▟▜▌   ▐▖   ▋  ▐▍
  ▟▘ ▜   ▝▀▇▆●▘  ▐▌
▗▟▘   ▜▃       ▁▅▛
▔▀▼▅▄▃▃██▅▄▄▄▅■▀▔   CopyRight :)
      ▔▔▔▔▔▔
#endif
#include <cstdio>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator () (a...); }
} read;

const int maxn = 100005;
const ll inf = 1000000000000000000;
ll a[maxn];
ll b[maxn];

int main () {
	int n = read;
	for (int i = 0; i <= n; i ++) read(a[i]);
	b[0] = 1;
	for (int i = 0; i <= n; i ++) {
		b[i] -= a[i];
		if (b[i] < 0) return puts("-1"), 0;
		b[i + 1] = std::min(inf, b[i] << 1);
	}
	ll ans = 0;
	for (int i = n; i; i --) {
		ans += a[i];
		ll x = std::min(b[i - 1], a[i]);
		a[i - 1] += x;
		debug("%d : %lld\n", i, a[i]);
	}
	ans += a[0];
	printf("%lld\n", ans);
}


Measured memory_bytes: 3948
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		int n = scan.nextInt();
		int tarop = 0;
		int hanap = 0;

		loop:
		for (int i = 0; i < n; i++) {
			String taroCard = scan.next();
			String hanaCard = scan.next();

			char[] taroAr = taroCard.toCharArray();
			char[] hanaAr = hanaCard.toCharArray();

			int taroL = taroAr.length;
			int hanaL = hanaAr.length;

			for ( int j = 0; j < Math.min(taroL, hanaL); j++) {
				if (taroAr[j] > hanaAr[j]) {
					tarop += 3;
					continue loop;
				} else if (taroAr[j] < hanaAr[j]) {
					hanap += 3;
					continue loop;
				}
			}

			if (taroL > hanaL) {
				tarop += 3;
				continue loop;
			} else if ( taroL < hanaL) {
				hanap += 3;
				continue loop;
			} else {
				tarop += 1;
				hanap += 1;
			}
		}
		System.out.println(tarop + " " + hanap);
	}

}

Measured memory_bytes: 29336
#include<bits/stdc++.h>
using namespace std;
char s[20];


int main()
{
    scanf("%s",s);
    int ans1=0, ans2=0, len=strlen(s);
    for(int i=0;i<len;i++)
        ans1+=s[i]-'0';
    ans2=s[0]-'1';
    ans2+=(len-1)*9;
    int ans=max(ans1,ans2);
    printf("%d\n",ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL) ; cout.tie(NULL);
#define MOD 998244353

int dp[3005][3005];

int main() 
{
   int i,j,l1,l2;
   string s,r;
   cin>>s;
   cin>>r;

   l1=s.length();
   l2=r.length();

   for(i=1;i<=l1;i++)
   {
       for(j=1;j<=l2;j++)
       {
       	 if(s[i-1]==r[j-1])
          {
          	dp[i][j]=max(dp[i-1][j],dp[i-1][j-1]+1);
          }
          else
          	dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
       }
   }
   
   i=l1;
   j=l2;
   
   deque<char> v;

   while(i>0&&j>0)
   {
     if(s[i-1]==r[j-1])
     {
       v.push_front(s[i-1]);
       i--;
       j--;
     }
     else if (dp[i-1][j]>dp[i][j-1]/* conddition */)
     {
     	i--;/* code */
     }else
     {
        j--;
     }
   }
   
  /* for(i=0;i<=l1;i++)
   {
     for(j=0;j<=l2;j++)
     {
     	cout<<dp[i][j]<<" ";
     }
     cout<<"\n";
   }
   */
   for(auto it=v.begin();it!=v.end();it++)
   	 cout<<*it;
   	 cout<<"\n";

 	return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N,M;
  cin >> N >> M;
  vector<vector<int>> graph(N);
  vector<int> come(N,0);
  for(int i=0;i<M;i++){
    int x,y;
    cin >> x >> y;
    x--;
    y--;
    graph.at(x).pb(y);
    come.at(y)++;
  }

  queue<int> que;
  for(int i=0;i<N;i++)  if(come.at(i)==0) que.push(i);
  vector<int> dp(N,0);
  while(!que.empty()){
    int v=que.front();
    que.pop();
    for(int i=0;i<sz(graph.at(v));i++){
      int nv=graph.at(v).at(i);
      dp.at(nv)=max(dp.at(nv),dp.at(v)+1);
      come.at(nv)--;
      if(come.at(nv)==0)  que.push(nv);
    }
  }
  int ans=0;
  for(int i=0;i<N;i++)  ans=max(ans,dp.at(i));
  cout << ans << endl;

  return 0;
}

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

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

    string a, b;
    cin >> a >> b;
    int num = stoi(a + b);
    int x = sqrt(num);
    cout << ((x * x == num) ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
 
#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
using namespace std;
using ll=long long;
constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}

int main() {
ll N,H;
ll ans=0;
cin >> N>>H;
ll a[N],b[N];
FOR(i,0,N-1){
  cin >> a[i]>>b[i];
}
// amax
ll amax=0;
FOR(i,0,N-1){
  if(a[i]>amax){amax=a[i];}
}
sort(b, b+N,greater<int>());
FOR(i,0,N-1){
  if(b[i]>amax){
    H=H-b[i];
    ans++;
    if(H<=0){cout<<ans<<endl;return 0;}
  }
}
ll tmp;
tmp=H/amax;
ans=tmp+ans;
if(H%amax!=0){
  ans++;
}
cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

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

    cout << (n == m ? "Yes" : "No") << endl;

    return 0;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    int ans=n*(n-1)/2+m*(m-1)/2;
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;

int main(){
	long long x,a,b;
	scanf("%lld %lld %lld", &x, &a, &b);
	
	if(b<=a){
		printf("delicious\n");
	}else if(b<=a+x){
		printf("safe\n");
	}else{
		printf("dangerous\n");
	}

	return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    h,w = LI()
    a = [[c for c in S()] for _ in range(h)]
    ff = True
    for i in range(h):
        for j in range(w):
            if a[i][j] == '.':
                continue
            f = False
            if (i>0 and a[i-1][j] == '#') or (i<h-1 and a[i+1][j] == '#') or (j>0 and a[i][j-1] == '#') or (j<w-1 and a[i][j+1] == '#'):
                f = True
            if not f:
                ff = False
                break
        if not ff:
            break

    if ff:
        return 'Yes'
    return 'No'



print(main())



Measured memory_bytes: 5424
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
	char *map;
	bool *mapb;
	int x,y;
 
	while(1){
		scanf("%d %d",&y,&x);
		if(y==0 || x==0)
			return 0;

		map =(char*)malloc(x*y*sizeof(char));
		mapb = (bool*)malloc(x*y*sizeof(bool));

		for(int i=0;i<y;i++){
			char *buf;
			buf = (char*)malloc(x+1);
			scanf("%s",buf);
			memcpy(&map[x*i],buf,x);
			free(buf);
		}

		int posx=0,posy=0;
		memset(mapb,0,x*y);

		while(map[posy*x+posx]!='.'){
			mapb[posy*x+posx] = 1;   
			switch(map[posy*x+posx]){
  		case '>':
        posx++;
        break;
  		case '<':
        posx--;
        break;
  		case 'v':
        posy++;
        break;
  		case '^':
        posy--;
        break;
			}
			if(mapb[posy*x+posx]==1){
				// passed twice
				printf("LOOP\n");
        posx=-1;
        break;
			}
		}
		if(posx!=-1)
			printf("%d %d\n",posx,posy);
    free(map);
    free(mapb);
	}

	return 0;
}

Measured memory_bytes: 0
def main():
    N, M = (int(i) for i in input().split())
    p_ac = (1/(2**M))
    p_wa = 1 - p_ac
    ans = 0
    exe_time = 1900*M + 100*(N-M)
    for k in range(1, 10**5)[::-1]:
        ans += k * (exe_time) * p_ac * (p_wa**(k-1))
    print(round(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38896
from sys import stdin
input = stdin.readline

while True:
    m,f,r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
        
    if m == -1 or f == -1:
        print('F')
    elif m + f >= 80:
        print('A')
    elif m + f >= 65:
        print('B')
    elif m + f >= 50:
        print('C')
    elif m + f >= 30:
        if r >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')


Measured memory_bytes: 5592
from heapq import heappush, heappop
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
AB.sort(reverse=True)
hp = []
ret = 0
for i in range(1, M+1):
    # push
    while len(AB) > 0 and AB[len(AB)-1][0] <= i:
        heappush(hp, AB.pop()[1]*-1)
    # pop
    if len(hp) > 0:
        ret += heappop(hp)*-1

print(ret)


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

int main() {
    int a, b;
    cin >> a >> b;
    
    if (a <= 5)
        cout << 0 << endl;
    else if (a <= 12)
        cout << b/2 << endl;
    else
        cout << b << endl;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
mat = []
ans = [[0 for i in range(W)] for j in range(H)]
for i in range(H):
    s = list(input())
    mat.append(s)

def search(h,w):
    count = 0
    if mat[h][w] == '#':
        return '#'
    else:
        if h+1 <= H-1:
            if mat[h+1][w] == '#':
                count += 1
            if w+1 <= W-1:
                if mat[h+1][w+1] == '#':
                    count += 1
            if w-1 >= 0:
                if mat[h+1][w-1] == '#':
                    count += 1
        if h-1 >= 0:
            if mat[h-1][w] == '#':
                count += 1
            if w+1 <= W-1:
                if mat[h-1][w+1] == '#':
                    count += 1
            if w-1 >= 0:
                if mat[h-1][w-1] == '#':
                    count += 1
        if w+1 <= W-1:
            if mat[h][w+1] == '#':
                count += 1
        if w-1 >= 0:
            if mat[h][w-1] == '#':
                count += 1   
        return count
    
for i in range(H):
    for j in range(W):
        ans[i][j] = search(i,j)
        
for i in range(H):
    ans[i] = map(str,ans[i])
    print(''.join(ans[i]))


        

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

typedef long long lint;
typedef pair<int, int> pii;

const int INF = 2e9;
const int MOD = 1e9+7;
const int MAX = 5e5+10;
const lint LNF = 2e18;

int n, L[MAX], R[MAX], A[MAX];
char S[MAX];

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

	cin>>(S+1); n = strlen(S+1) + 1;
	for(int i=1; i<n; i++) L[i] = (S[i]=='<' ? L[i-1]+1 : 0);
	for(int i=n-2; i>=0; i--) R[i] = (S[i+1]=='>' ? R[i+1]+1 : 0);
	for(int i=0; i<n; i++) A[i] = max(L[i], R[i]);

	lint sum = 0;
	for(int i=0; i<n; i++) sum+=A[i];
	cout<<sum<<'\n';

	return 0;
}


Measured memory_bytes: 6656
A, B, C, D = gets.chomp.split("")

["+", "-"].repeated_permutation(3) do |op1, op2, op3|
  if 7 == eval(A+op1+B+op2+C+op3+D)
    puts A+op1+B+op2+C+op3+D+"=7"
    exit
  end
end


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

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();}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#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())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

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

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 main(void){
    ll N,C; cin >> N >> C;
    vector<ll> x(N+1), rx(N+1), v(N+1); REP(i,N){cin >> x[i+1] >> v[i+1]; rx[N-i] = C-x[i+1];}
    x[0] = 0; rx[0] = 0; v[0] = 0; 
    
    vector<ll> sum(N+1), rsum(N+1), f(N+1), rf(N+1), g(N+1), rg(N+1);
    sum[0] = 0; rsum[0] = 0;
    REP(i,N){
        sum[i+1] = sum[i] + v[i+1];
        rsum[i+1] = rsum[i] + v[N-i];
    }
    f[0] = 0; rf[0] = 0;
    REP(i,N){
        f[i+1] = sum[i+1] - x[i+1];
        rf[i+1] = rsum[i+1] - rx[i+1];
    }
    g[0] = f[0]; rg[0] = rf[0];
    REP(i,N){
        g[i+1] = max(g[i], f[i+1]);
        rg[i+1] = max(rg[i], rf[i+1]);
    }

    ll ans = 0;
    REP(i,N+1){
        ll ans_i;
        ans_i = f[i] - x[i];
        ans_i += rg[N-i];
        chmax(ans, ans_i);
    }
    REP(i,N+1){
        ll ans_i;
        ans_i = rf[i] - rx[i];
        ans_i += g[N-i];
        chmax(ans, ans_i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7296
def solve():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline

    N, Q = map(int, input().split())
    adjL = [[] for _ in range(N)]
    for _ in range(N-1):
        A, B = map(int, input().split())
        A, B = A-1, B-1
        adjL[A].append(B)
        adjL[B].append(A)

    anss = [0] * N
    for _ in range(Q):
        p, x = map(int, input().split())
        p = p-1
        anss[p] += x

    useds = [False] * N
    def dfs(vNow, x):
        useds[vNow] = True
        anss[vNow] += x
        ans = anss[vNow]
        for v2 in adjL[vNow]:
            if not useds[v2]:
                dfs(v2, ans)

    dfs(0, 0)

    print(' '.join(map(str, anss)))

solve()


Measured memory_bytes: 271380
#include<stdio.h>
 
int main()
{
  int a,b;
  scanf("%d %d",&a,&b);
  int c=a+b;
  int d=a*b;
  int e=a-b;
  int ans=0;
  if(c<d)
    {
      if(d<e)
	{
	  ans=e;
	}
      else
	{
	  ans=d;
	}
    }
  if(c>d)
    {
      if(c<e)
	{
	  ans=e;
	}
      else
	{
	  ans=c;
	}
    }
  printf("%d\n",ans);
  return 0;
}

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

#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

inline void Main() {
  int n; cin >> n;
  string s;
  map<string, int> mp;
  mp["AC"] = 0;
  mp["WA"] = 0;
  mp["TLE"] = 0;
  mp["RE"] = 0;
  rep(i, n) {
    cin >> s;
    mp[s] += 1;
  }
  cout << "AC x " << mp["AC"] << endl;
  cout << "WA x " << mp["WA"] << endl;
  cout << "TLE x " << mp["TLE"] << endl;
  cout << "RE x " << mp["RE"] << endl;
}

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


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

ll find_opponent(ll now) {
    ll base = 1;
    while (base <= now)base *= 2;
    base -= now;
    return base;
}

int main()
{
    multiset<ll> ms;
    int N;
    cin >> N;
    rep(i, N) {
        ll a;
        cin >> a;
        ms.insert(a);
    }

    ll res = 0;
    while (!ms.empty()) {
        auto itr = ms.end();
        itr--;
        ll now = *itr;
        ms.erase(itr);

        itr = ms.find(find_opponent(now));
        if (itr == ms.end())continue;
        res++;
        ms.erase(itr);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 9600
#include <stdio.h>

const int MAX_N=10000;
int a[MAX_N];
int b[MAX_N];
int n;
int A=0;int B=0;
void solve(){
	for(int i=0;i<n;i++){
		if(a[i]>b[i]){
			A+=a[i]+b[i];
		}
		else if(a[i]<b[i]){
			B+=a[i]+b[i];
		}
		else{
			A+=a[i];
			B+=a[i];
		}
	}
}
int main(){
 while(1){
	scanf("%d",&n);
	if(n==0){
		break;
	}
	for(int i=0;i<n;i++){
	scanf("%d%d",&a[i],&b[i]);
	}
	solve();
	printf("%d %d\n",A,B);
	A=0;
	B=0;
 }
   return 0;
}

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

int main() {
    int R, G, B, N;
    cin >> R >> G >> B >> N;

    int res = 0;
    for (int i = 0; i <= N / R; i++) {
        for (int j = 0; j <= N / G; j++) {
            int rest = N - i * R - j * G;
            if (rest % B == 0 && rest / B >= 0) {
                res++;
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack> 
#include <set>
#include <map>
using namespace std;

#define N 120
const int INF = 1 << 30;

char s[N], tmp[N], tmp2[N];

bool Check(char *str, int n)
{
	for (int i = 1; i < n; ++i) if (str[i] != str[n]) return false;
	return true;
}

int main()
{
	//freopen("in.in", "r", stdin);
	//freopen("out.out", "w", stdout);
     
    int n, res = 10000;
    scanf("%s", s + 1);
    n = strlen(s + 1);


    for (char ch = 'a'; ch <= 'z'; ++ch)
    {
    	memcpy(tmp, s, sizeof(s));
    	if (Check(tmp, n)) 
    	{
    		res = 0;
    		break;
    	}
    	int m = n;
    	for (int i = 1; ; ++i)
    	{
    		m--;
    		for (int j = 1; j <= m; ++j) 
    		{
    			if (tmp[j] == ch || tmp[j + 1] == ch) tmp2[j] = ch;
    			else tmp2[j] = tmp[j];
    		}
    		memcpy(tmp, tmp2, sizeof(tmp2));
    		if (Check(tmp, m))
    		{
    			res = min(res, i);
    			break;
    		}
    	}
    }
	printf("%d\n", res);
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

#define MAX_N 10000+5

int par[MAX_N];
int rnk[MAX_N];

void init(int n){
	for(int i=0;i<n;i++){
		par[i]=i;
		rnk[i]=0;
	}
}

int find(int x){
	if(par[x]==x){
		return x;
	}else{
		return par[x]=find(par[x]);
	}
}

void unite(int x,int y){
	x=find(x);
	y=find(y);
	if(x==y) return;
	if(rnk[x]<rnk[y]){
		par[x]=y;
	}else{
		par[y]=x;
		if(rnk[x]==rnk[y]) rnk[x]++;
	}
}

bool same(int x,int y){
	return find(x)==find(y);
}

int main(){

	int n,q;
	int c,x,y;

	cin>>n>>q;

	init(n+1);
	for(int i=0;i<q;i++){

		cin>>c>>x>>y;

		if(c==0) unite(x,y);
		else cout<<same(x,y)<<endl;

	}
	
}

Measured memory_bytes: 1240
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')

N=int(input())


l=[]

for i in range(N):
	a,b=map(int,input().split())
	st,fin=(a-b,a+b)
	l.append([fin,st])


list=sorted(l)

pt=list[0][0]
cnt=1


for j in range(1,N):
	if pt<= list[j][1]:
		cnt+=1
		pt=list[j][0]

print(cnt)
	
	

Measured memory_bytes: 20880
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod=1e9+7;

int main(){
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x, y;
    x=x2-x1;
    y=y2-y1;
    cout << x2 - y << ' ' << y2 + x << ' ';
    cout << x1 - y << ' ' << y1 + x;
}

Measured memory_bytes: 256
// #pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

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

const ll INF = numeric_limits<ll>::max(),
         MOD = 1e9 + 7;

const int INF_i = numeric_limits<int>::max(),
          MAX = 1e6;

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    // freopen("in.in", "r", stdin);

    int n, k;
    cin >> n >> k;
    vii v(n);
    for (int &e : v) cin >> e;
    bool dp[k + 1] = {};
    for (int i = 0, j; i <= k; i++) {
        if (dp[i]) continue;
        for (int e : v) {
            j = i + e;
            if (j <= k) 
                dp[j] = true;
        }
    }
    cout << (dp[k] ? "First" : "Second") << '\n';
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define zzz ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){return (a*b)/gcd(a, b);}

int main()
{
    zzz;
    int n; cin>>n; cout<<n*n*3;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <queue>

using namespace std;

typedef pair<int, int> PII;
typedef long long LL;
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main() {
  int N;
  LL K;
  cin >> N >> K;

  priority_queue<PII, vector<PII>, greater<PII> > pq;
  REP(i, N) {
    int a, b;
    cin >> a >> b;
    pq.push(MP(a, b));
  }
  while (true) {
    PII top = pq.top();
    pq.pop();
    K -= top.second;
    if (K <= 0) {
      cout << top.first << endl;
      break;
    }
  }
  return 0;
}


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

using namespace std;
using ll = long long int;
constexpr ll M = 1e9 + 7;
inline ll sum_1(const ll n) { return ((n * (n + 1)) / 2) % M; }
inline ll sum_2(const ll n) { return ((n * (n + 1) * (2 * n + 1)) / 6) % M; }
inline ll sum_3(const ll n) { return (((n * (n + 1)) / 2) % M * ((n * (n + 1)) / 2) % M) % M; }
inline ll sum_1(const ll i, const ll j) { return (sum_1(j) - sum_1(i - 1) + M) % M; }
inline ll sum_2(const ll i, const ll j) { return (sum_2(j) - sum_2(i - 1) + M) % M; }
inline ll sum_3(const ll i, const ll j) { return (sum_3(j) - sum_3(i - 1) + M) % M; }

void solve() {
    int n;
    cin >> n;
    while (n) {
        int t = n%10;
        if (t == 7) {
            cout << "Yes" << endl;
            return;
        }
        n /= 10;
    }
    cout << "No" << endl;
}

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

    solve();

    return 0;
}

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

int main() {
    int H, W;
    cin >> H >> W;

    vector<string> a(H, string(W, '.')),
                   R(H, string(W, '.')),
                   B(H, string(W, '.'));
    for (int r = 0; r < H; r++) {
        cin >> a[r];
        for (int c = 0; c < W; c++) {
            if (r % 2 == 0) {
                if (c < W - 1) R[r][c] = '#';
                else B[r][c] = '#';
                if (a[r][c] == '#') B[r][c] = '#';
            } else {
                if (c > 0) B[r][c] = '#';
                else R[r][c] = '#';
                if (a[r][c] == '#') R[r][c] = '#';
            }
        }
    }
    for (int r = 0; r < H; r++) {
        cout << R[r] << endl;
    }
    cout << endl;
    for (int r = 0; r < H; r++) {
        cout << B[r] << endl;
    }
                   
    return 0;
}

Measured memory_bytes: 1536
#include<stdio.h>
int main(void){
 
     int N[100],n;
     int i,j,m;
     int k;
 
     scanf("%d",&n);
     for(i=0;i<n;i++){
         scanf("%d",&N[i]);
     }
 
     for(i=1;i<n;i++){
 
         for(j=0;j<n;j++){
             if(j!=0){
                 printf(" ");
             }
             printf("%d",N[j]);
         }
         printf("\n");
 
         m=i;
 
         for(j=i-1;j>=0;j--){
             if(N[j]<N[m]){
                 break;
             }
             else{
                 k=N[j];
                 N[j]=N[m];
                 N[m]=k;
                 m--;
             }
         }
 
     }
 
     for(j=0;j<n;j++){
             if(j!=0){
                 printf(" ");
             }
             printf("%d",N[j]);
         }
     printf("\n");
 
     return 0;
 }


Measured memory_bytes: 2088
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
char s[12];
int n;
void dfs(int indx,char c){
    //cout << indx << endl;
    if(indx==n){
    //    cout << indx <<endl;
        printf("%s\n",s);
        //cout <<s <<endl;
        return ;
    }
    for(char i='a';i<=c;i++){
        s[indx]=i;
        dfs(indx+1,max((char)(i+1),c));
    }
}
int main()
{
    //ios::sync_with_stdio(false);
    cin >> n;
    s[0]='a';
    dfs(0,'a');
    return 0;
}


Measured memory_bytes: 3588
n = int(input())
ary = [1]
x = 1
for i in range(6):
	x *= 6
	ary.append(x)
x = 1
for i in range(5):
	x *= 9
	ary.append(x)
ary.sort()

dp = [i for i in range(n+1)]

for i in range(1,n+1):
	for j in ary:
		if j > i:
			break
		dp[i] = min(dp[i],dp[i-j]+1)
print (dp[n])

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

#define fi first
#define se second
#define FO(x, n) for (int x = 0; x < n; ++x)
#define FOR(x, a, b) for (int x = a; x < b; ++x)
#define RFO(x, n) for (int x = n - 1; x >= 0; --x)
#define RFOR(x, a, b) for (int x = b - 1; x >= a; --x)
#define FOR_ITER(x, a) for(auto x = a.begin(); x != a.end(); ++x)



using namespace std;
typedef unsigned char byte;
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;
typedef pair<llong, llong> pll;
inline bool feq(const double& a, const double& b) { return fabs(a - b) < 1e-10; }

using namespace std;


int main(){
//    int n, l;
//    cin >> n >> k;
//    vector<bool> dislike(10, false);
//
//    FOR(i, 0, k) {
//        int t;
//        cin >> t;
//        dislike[t] = true;
//    }
set<int> s;
    FO(i, 3) {
        int a;
        cin >> a;
        s.insert(a);
    }




    cout << s.size() << endl;
    return 0;
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    // 数値の配列を作る
    const numList = input.map(x => x.split(" ").map(x => parseInt(x, 10))[0]);
 
    // １番端数が小さい数を求める
    var minHasuu = 10;
    var totalTime = 0;
    for (var i = 0; i < 5; i++) {
        var num = numList[i];
        var hasuu = num % 10;
        if (hasuu !== 0) {
            minHasuu = Math.min(minHasuu, hasuu);
            num += 10;
        }
        totalTime += num - hasuu;
    }
 
    // 端数分を調整する
    totalTime += minHasuu;
    totalTime -= 10;
    console.log(totalTime);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    vector<int> v[n+1];
    int x,y,z;
    for(int i=0;i<m;i++)
    {
        scanf("%d%d%d",&x,&y,&z);
        v[x].push_back(y);
        v[y].push_back(x);
    }
    int res=0;
    vector<bool> vis(n+1,0);
    queue<int> q;
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            res++;
            q.push(i);
            vis[i]=1;
            while(!q.empty())
            {
                int e=q.front();
                q.pop();
                for(int to:v[e])
                {
                    if(!vis[to])
                    {
                        vis[to]=1;
                        q.push(to);
                    }
                }
            }
        }
    }
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 6520
module RegExp : sig
  type t
  val empty_set : t
  val empty_str : t
  val char : char -> t
  val app : t -> t -> t
  val union : t -> t -> t
  val star : t -> t

  val matches : char list -> t -> bool
end = struct
  type t = { sort : sort; match_eps : bool; derive : char -> t }
  and sort = EmptySet | EmptyStr | Other

  let rec empty_set =
    { sort = EmptySet;
      match_eps = false;
      derive = fun _ -> empty_set }

  let empty_str =
    { sort = EmptyStr;
      match_eps = true;
      derive = fun _ -> empty_set }

  let char c =
    { sort = Other;
      match_eps = false;
      derive = fun c' -> if c = c' then empty_str else empty_set }

  let rec union re1 re2 =
    match re1, re2 with
    | { sort = EmptySet }, _ -> re2
    | _, { sort = EmptySet } -> re1
    | _, _ ->
        { sort = Other;
          match_eps = re1.match_eps || re2.match_eps;
          derive = fun c -> union (re1.derive c) (re2.derive c) }

  let rec app re1 re2 =
    match re1 with
    | { sort = EmptyStr } -> re2
    | { sort = EmptySet } -> empty_set
    | _ ->
        { sort = Other;
          match_eps = re1.match_eps && re2.match_eps;
          derive = fun c ->
            union
              (app (re1.derive c) re2)
              (if re1.match_eps then re2.derive c else empty_set) }
  let app re1 = function
    | { sort = EmptyStr } -> re1
    | { sort = EmptySet } -> empty_set
    | re2 -> app re1 re2

  let star = function
    | { sort = EmptySet }
    | { sort = EmptyStr } -> empty_str
    | re0 ->
        let rec re =
          { sort = Other;
            match_eps = true;
            derive = fun c -> app (re0.derive c) re } in re

  let matches s re =
    (List.fold_left (fun re -> re.derive) re s).match_eps
end

let () =
  let s = read_line () in
  print_endline @@
  if
    let open RegExp in
    matches
      (* ((dream(er)?)|(erase(r)?))* *)
      (Array.to_list @@ Array.init (String.length s) @@ String.get s) @@
      star @@
        union
          (app (char 'd') @@ app (char 'r') @@ app (char 'e') @@ app (char 'a') @@ app (char 'm') @@
            union empty_str @@ app (char 'e') @@ char 'r')
          (app (char 'e') @@ app (char 'r') @@ app (char 'a') @@ app (char 's') @@ app (char 'e') @@
            (union empty_str @@ char 'r'))
  then "YES"
  else "NO"

Measured memory_bytes: 6400
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
typedef long long LL;
const LL INF = 0x3f3f3f3f3f3f3f3f;

LL n,a;
LL mx = 0,cnt[100005];

int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	for(LL i = 1;i <= n;i ++){
		cin >> a; mx = max(mx,a);
		cnt[a] ++;
	}
	for(LL i = 0;i <= mx;i ++) cnt[max(i,mx - i)] --;
	for(LL i = 1;i <= n;i ++) if(cnt[i] < 0){ cout << "Impossible" << endl; return 0; }
	
	for(LL i = 1;i <= ((mx + 1) >> 1);i ++) if(cnt[i] > 0){ cout << "Impossible" << endl; return 0; }
	for(LL i = mx + 1;i <= mx;i ++) if(cnt[i] > 0){ cout << "Impossible" << endl; return 0; }
	
	cout << "Possible" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>

using namespace std;

int main(void)
{
    vector<int> arr = { 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 };
    int k;
    cin >> k;
    cout << arr[k - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int card[400];
int n;

void shuffle(int k)
{
	int i, j;
	int tmp[100];
	
	if (k){
		for (i = 0; i < n * 2; i++){
			card[n * 2 + i] = card[i];
			card[i] = card[k + i];
		}
	}
	else {
		for (i = 1; i < n; i++){
			tmp[i] = card[i];
		}
		
		for (i = 1, j = n;i < 2 * n; i += 2, j++){
			card[i] = card[j];
			card[i + 1] = tmp[j - n + 1];
		}
	}
}

int main(void)
{
	int i, j;
	int m;
	int k;
	
	scanf("%d", &n);
	for (i = 0; i < n * 2; i++){
		card[i] = i + 1;
	}
	
	scanf("%d", &m);
	for (i = 0; i < m; i++){
		scanf("%d", &k);
		shuffle(k);
	}
	
	for (i = 0; i < n * 2; i++){
		printf("%d\n", card[i]);
	}
	
	return (0);
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
using ll   = long long;
const ll mod = 1e9+7;

void solve(){
    int n,w, max_val=0;cin>>n>>w;
    vector<vector<ll>> a(n, vector<ll>(2));
    for(int i=0;i<n;i++){
        cin>>a[i][0]>>a[i][1];
        max_val += a[i][1];
    }
    vector<ll> dp(max_val+1, mod);
    dp[0]=0;
    for(int i=0;i<n;i++){
        vector<ll> newDp(max_val+1, mod);
        newDp[0]=0;
        for(int val=1;val<=max_val;val++){
            if(a[i][1]>val){
                newDp[val] = dp[val];
            }else newDp[val] = min(dp[val], dp[val-a[i][1]] + a[i][0]);
        }
        dp = newDp;
    }
    ll ans=0;
    for(int i=1;i<=max_val;i++){
        if(dp[i]<=w)ans = max(ans, (ll)i);
    }
    cout<<ans;
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input1.txt","r",stdin);
        freopen("output1.txt", "w", stdout);
    #endif
    int t;
    t=1;
    // cin>>t;

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


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

int main(){
  int n;
  map<int, int> mp;
  queue<int> que;
  cin >> n;

  int tmp;
  for(int i = 0;i < n;i++){
    cin >> tmp;
    if(mp[tmp] == 0){
      que.push(tmp);
    }
    mp[tmp]++;
  }

  int ans = 0;
  while(!que.empty()){
    tmp = que.front(); que.pop();
    if(tmp > mp[tmp]){
      ans += mp[tmp];
    }else{
      ans += mp[tmp] - tmp;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5120
#include<iostream>
#include<vector>
#include<string>
#include<climits>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<queue>


int main(){
	int n, d;
	std::cin>>n>>d;

	int ans= n/(2*d+1);
	ans+= (n%(2*d+1)==0)? 0 : 1;

	std::cout<<  ans <<std::endl;

	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  int N, M;
  cin >> N >> M;
  if (N == M) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
 
#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)
 
#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
using namespace std;
 
const int MX = 3007;
 
int f[MX][MX];
 
int main() {
#ifdef FASTIO
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            f[i][j] = max(f[i - 1][j], f[i][j - 1]);
            if (s[i - 1] == t[j - 1]) {
                f[i][j] = max(f[i][j], f[i - 1][j - 1] + 1);
            }
        }
    }
 
    int x = n, y = m;
    string res;
    while (x > 0 && y > 0) {
        if (f[x][y] == f[x - 1][y]) {
            x--;
        } else if (f[x][y] == f[x][y - 1]) {
            y--;
        } else {
            res += s[x - 1];
            x--;
            y--;
        }
    }
 
    reverse(res.begin(), res.end());
 
    cout << res << "\n";
    return 0;
}
 

Measured memory_bytes: 35584
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;
 
signed main()
{
    tezz
    
    int n;
    cin>>n;

    vi v(n);
    for(int &x:v) cin>>x;
    vi rem = v;
    
    sort(all(rem));

    int count = 0;

    for(int i=0;i<n;i++){
        if(rem[i] != v[i]) {count++;}
    }

    if(count == 2 || !count) cout<<"YES";
    else cout<<"NO";
} 

Measured memory_bytes: 256
targ, length = map(int, input().split(' '))

banned = [False] * 100

bans = input()
if bans != '':
    for ban in bans.split(' '):
        banned[int(ban) - 1] = True

for dist in range(100):
    if targ - dist > 0:
        if not banned[targ - dist - 1]:
            print(targ - dist)
            exit()
    else:
        print(targ - dist)
        exit()
    if targ + dist <= 100:
        if not banned[targ + dist - 1]:
            print(targ + dist)
            exit()
    else:
        print(targ + dist)
        exit()

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

import fileinput
import math

def main():

    a = int(input())

    hour = a / 3600
    minute = (a%3600) / 60
    second = (a%3600) % 60

    print('{0}:{1}:{2}'.format(hour, minute, second))

if __name__ == '__main__':
    main()

Measured memory_bytes: 6516
import sys
import math

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n,k = na()
a = na()

if n == k:
    print(1)
elif k >= n//2:
    print(2)
elif k == 2:
    print(n-1)
else:
    print(math.ceil((n-k)/(k-1))+1)


Measured memory_bytes: 13876
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { -1, 0, 0, 1 };
const ll dy[4] = { 0, -1, 1, 0 };
const ll INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
struct Accelerate_Cin {
	Accelerate_Cin() {
		cin.tie(0);
		ios::sync_with_stdio(0);
		cout << fixed << setprecision(20);
	};
};
///////////////////////////////////////

int main() {
	int N; cin >> N;
	set<int>s;
	REP(i, N) {
		int a; cin >> a;
		s.insert(a);
	}
	int key = s.size();
	if ((N - key) % 2 == 0)cout << key << endl;
	else cout << key - 1 << endl;
	return 0;
}


Measured memory_bytes: 4992