akhauriyash/Code-Regression huggingface dataset:
///----------------------///
///---Code Written by----///
///-----Al-Shahreyaj-----///
///----------------------///

///PRAGMA
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>

///PBDS
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;

//PBDS_SET
//Index of Value - .order_of_key()
//Value at Index - .find_by_order()
//typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds_set; 
//typedef tree<int, null_type, lessorequal<int>, rb_tree_tag,tree_order_statistics_node_update> pbds_multiset; 

#define mem(a, x) memset(a, x, sizeof(a))
#define MP make_air
#define inf 1e8
#define INF 1e18
#define CP(x) printf("Case %d: ", x);
#define unq(v) v.erase(unique(all(v)),v.end())
#define one(x) __builtin_popcount(x)
#define onel(x) __builtin_popcountll(x)
#define ll long long
#define ld long double
#define LMX LLONG_MAX
#define fixpre(x) cout << fixed << setprecision(x)
#define endl "\n"
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define matrix vector<vector<ll> >
#define F first
#define S second
#define pb push_back
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define INT ini()
#define LONG inl()
#define M 998244353
#define N 3005

int ini(){int x;scanf("%d",&x);return x;}
ll inl(){ll x;scanf("%lld",&x);return x;}

ll dp[N][N], arr[N];

int main()
{
	int n, s;
	cin >> n >> s;
	for(int i = 1; i <= n; i++) cin >> arr[i];
	dp[0][0] = 1;
	ll cc = 1;
	for(int i = 1; i <= n; i++)
	{
		cc = (cc * 2LL) % M;
		dp[i][0] = cc;
		for(int j = 1; j <= s; j++)
		{
			dp[i][j] = (dp[i - 1][j] * 2LL) % M;
			if(j - arr[i] >= 0) dp[i][j] = (dp[i][j] + dp[i - 1][j - arr[i]]) % M;
		}
		//cout << dp[i][s] << endl;
		//ans = (ans + dp[i][s]) % M;
	}
	cout << dp[n][s] % M  << endl;
	return 0;
}





Measured memory_bytes: 74096
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip.split())
def main():
    n,m = LI()

    if 2*n>=m:
        print(str(m//2))
    else:
        print(str(n+(m-2*n)//4))
main()

Measured memory_bytes: 68312
#include <bits/stdc++.h>
#define rank tipa_rank
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define INF 1000000000
#define EPS 1e-6
#define EPS2 1e-8
using namespace std;
const ll MOD = INF + 7;
using namespace std;
int n , c , k;
int t[100000];
int begT = -1;
int cnt = 0;
int main()
{
	scanf("%d %d %d" , &n , &c , &k);
	for(int i = 0; i < n; i++)
		scanf("%d" , &t[i]);
	sort(t , t + n);
	int ans = 0;
	for(int i = 0; i < n; i++)
	{
		if(begT == -1 || t[i] - begT <= k && cnt < c)
		{
			if(begT == -1)
				begT = t[i];
			cnt++;
		}
		else
		{
			ans++;
			begT = t[i];
			cnt = 1;
		}
	}
	ans++;
	cout << ans;
}


Measured memory_bytes: 640
#include<stdio.h>
main(){
	int N,K,X,Y,H;
	int sum=0,sum2=0,sum3=0;
	scanf("%d %d %d %d",&N,&K,&X,&Y);
	sum = K * X;
	H=K+1;
	if ( N > K ){
	for(;H<=N;H++){
		sum2=sum2+Y;
	   }
	sum3=sum+sum2;
	printf("%d",sum3);
    }
	else{
		sum3=N * X;
		printf("%d",sum3);
	}
	return 0;
} 

Measured memory_bytes: 128
N, K = map(int, input().split())
PO, NE = [0], []
for a in input().split():
    a = int(a)
    if a >= 0: PO.append(a)
    else: NE.append(-a)

NE = [0] + NE[::-1]
ans = 1<<99

for i in range(K+1):
    j = K - i
    if i < len(PO) and j < len(NE):
        ans = min(ans, PO[i] * 2 + NE[j], PO[i] + NE[j] * 2)
print(ans)

Measured memory_bytes: 64112
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char mp[55][55];
int a,b;
int dir[8][2]={-1,-1,-1,0,0,-1,1,0,0,1,1,1,-1,1,1,-1};
void sss(int aa,int bb)
{
   int sum=0;
   for(int k=0;k<8;k++)
   {
      int aaa=aa+dir[k][0];
      int bbb=bb+dir[k][1];
      if(aaa>=a||bbb>=b) continue;
      if(aaa<0||bbb<0) continue;
      if(mp[aaa][bbb]=='#')
      sum++;
   }
   printf("%d",sum);
   return ;
}

int main()
{
   scanf("%d%d",&a,&b);
   for(int i=0;i<a;i++)
   {
      scanf("%s",mp[i]);
   }
   for(int i=0;i<a;i++)
   {
      for(int j=0;j<b;j++)
      {
         if(mp[i][j]=='#')
         printf("#");
         else
         sss(i,j);
      }
      printf("\n");
   }
   return 0;
}








    

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

// Union-Find {{{
// O(a(n))
// verified AOJ DSL_1_A
struct UF {
    vector<int> p;  // parent
    vector<int> r;  // rank

    UF(int n) {
        p.resize(n);
        r.resize(n);
        for(int i=0;i<n;i++){
            p[i] = i;
            r[i] = 1;
        }
    }

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

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

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n;cin >> n;
    int m;cin >> m;
    vector<int> p(n);
    inc(i, 0, n){
        cin >> p[i];
        p[i]--;
    }
    UF uf(n);
    inc(i, 0, m){
        int x, y;cin >> x >> y;x--;y--;
        uf.unite(x, y);
    }
    int cnt = 0;
    inc(i, 0, n){
        if(uf.find(p[i]) == uf.find(i)){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


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

int main() {
    int N;
    string S;
    cin >> N >> S;

    int east[N + 1];
    east[0] = 0;
    // east[i] = i文字目までのWの数

    for (int i = 1; i <= N; ++i) {
        east[i] = east[i - 1] + (S[i - 1] == 'E');
    }

    int ans = N;

    // i人目をリーダーにする
    for (int i = 1; i <= N; ++i) {
        int cnt = (i - 1 - east[i - 1]) + (east[N] - east[i]);
        ans = min(ans, cnt);
    }

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


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

int main(){

  int n;
  int ans=1,c=1;
  cin>>n;
  for(int i=0,a;i<n;i++){
    cin>>a;
    if(a%2==0)c*=2;
    ans*=3;
  }
  cout<<ans-c<<endl;
  return 0;
}


Measured memory_bytes: 256
<?php
$n = trim(fgets(STDIN));
$arare = explode(' ', trim(fgets(STDIN)));

$arr = [];

foreach ($arare as $a) {
    switch ($a) {
        case 'P':
            $arr[0] = true;
            break;
        case 'W':
            $arr[1] = true;
            break;
        case 'G':
            $arr[2] = true;
            break;
        case 'Y':
            $arr[3] = true;
            break;
    }

    if (count($arr) === 4) {
        echo 'Four' . "\n";
        exit;
    }
}

echo 'Three' . "\n";

Measured memory_bytes: 4856
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * 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;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int ans = 0;
            while (n > 0) {
                n /= k;
                ans++;
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 23508
import sys
import copy
from collections import deque
import collections
stdin = sys.stdin

mod = 10**9+7

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

s = ns()
t = ns()

cnt = 0
for i in range(len(s)):
    if s[i] is not t[i]:
        cnt+=1

print(cnt)

Measured memory_bytes: 69060
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=1000010;
int p[N],a[N],n,k,d[N],tot,ans[N];
vector<int>G[N];
priority_queue<int,vector<int>,greater<int> >q;
void Add(int u,int v){G[u].push_back(v);d[v]++;}
int t[N<<1];
void modify(int o,int l,int r,int pos,int v){
	if(l==r){t[o]=v;return;}
	int mid=(l+r)>>1;
	if(pos<=mid)modify(o<<1,l,mid,pos,v);
	else modify(o<<1|1,mid+1,r,pos,v);
	t[o]=min(t[o<<1],t[o<<1|1]);
}
int query(int o,int l,int r,int posl,int posr){
	if(posl>posr)return t[0];
	if(posl<=l && r<=posr)return t[o];
	int mid=(l+r)>>1,ret=t[0];
	if(posl<=mid)ret=min(ret,query(o<<1,l,mid,posl,posr));
	if(mid<posr)ret=min(ret,query(o<<1|1,mid+1,r,posl,posr));
	return ret;
}
int main(){
	n=gi();k=gi();
	for(int i=1;i<=n;i++)p[i]=gi(),a[p[i]]=i;
	memset(t,63,sizeof(t));
	for(int i=n;i;i--){
		int x=query(1,1,n,a[i]+1,min(n,a[i]+k-1));
		if(x<t[0])Add(a[i],a[x]);
		x=query(1,1,n,max(1,a[i]-k+1),a[i]-1);
		if(x<t[0])Add(a[i],a[x]);
		modify(1,1,n,a[i],i);
	}
	for(int i=1;i<=n;i++)if(!d[i])q.push(i);
	while(!q.empty()){
		int u=q.top();q.pop();ans[u]=++tot;
		for(int v:G[u]){d[v]--;if(!d[v])q.push(v);}
	}
	for(int i=1;i<=n;i++)printf("%d\n",ans[i]);
	return 0;
}



Measured memory_bytes: 64256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int i, j;
		while(true){
			int H = sc.nextInt();
			int W = sc.nextInt();
			
			if(H == 0 && W == 0) break;
			
			for(i = 0; i < H; i++){
				for(j = 0; j < W; j++){
					if(i == 0 || i == H - 1 || j == 0 || j == W -1) System.out.print("#");
					else System.out.print(".");
				}
			System.out.println();
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 33972
// #includes {{{
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <cmath>
using namespace std;
// }}}
// pre-written code {{{
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
#ifdef __MINGW32__
typedef double rn;
#else
typedef long double rn;
#endif

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

typedef int Num;
const int mod = 1000000007;

//{{{ operation
inline Num prod(const Num &a, const Num &b, const Num m = mod){
	Num c = (a*(long long)b)%m;
//	assert(0<=c and c<m);
	return c;
}
inline void mult(Num &a, const Num &b, const Num m = mod){
	a = prod(a,b,m);
}
inline Num sum(const Num &a, const Num &b, const Num m = mod){
	Num c=a+b;
	if(c>=m)c-=m;
//	assert(0<=c and c<m);
	return c;
}
inline Num add(Num &a, const Num &b, const Num m = mod){
	a = sum(a,b,m);
}
inline Num neg(const Num &a, const Num m = mod){
	if(a==0)return 0;
	else return m-a;
}
inline Num diff(const Num &a, const Num &b, const Num m = mod){
	Num c=a-b;
	if(c<0)c+=m;
	return c;
}
inline Num subt(Num &a, const Num &b, const Num m = mod){
	a -= b;
	if(a<0)a+=m;
}
/*
inline Num inv(const Num &a, const Num m = mod){
	return invMod(a,m);
}
inline Num quot(const Num &a, const Num &b, const Num m = mod){
	return prod(a,inv(b,m),m);
}
inline void divide(Num &a, const Num &b, const Num m = mod){
	a = prod(a,inv(b,m),m);
}
*/
//}}}
int N;
int A[100010];
pii p[100010];

int main(){
	cin>>N;
	REP(i,N)cin>>A[i];
	REP(i,N){
		int s = A[i]+N-1;
		if(s%2!=0){
			cout<<0<<endl;
			return 0;
		}
		p[i] = MP(s/2,N-1-s/2);
		if(p[i].first>=p[i].second)swap(p[i].first,p[i].second);
//		cout<<p[i].first<<" "<<p[i].second<<endl;
	}
	map<int,int> mp;
	REP(i,N){
		mp[p[i].first]++;
	}
	int ans = 1;
	for(auto it:mp){
		if(it.first*2==N-1){
			if(it.second!=1){
				cout<<0<<endl;
				return 0;
			}
		}else{
			if(it.second!=2){
				cout<<0<<endl;
				return 0;
			}else{
				mult(ans,2);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3712
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String taro, hanako, str;
        int st=0, sh=0;
        int n = scan.nextInt();
        while (n > 0) {
            taro = scan.next();
            hanako = scan.next();
            if(taro.compareTo(hanako) < 0) sh += 3;
            if(taro.compareTo(hanako) > 0) st += 3;
            if (taro.compareTo(hanako) == 0) {
                st++;
                sh++;
            }
            n--;
        }
        System.out.println(st + " " + sh);
    }
}

Measured memory_bytes: 30184
#include <stdio.h>
int main()
{
  int n,p=0;
  scanf("%d",&n);
  for(int i=1;i<=9;i++)
  {
    for(int j=i;j<=9;j++)
    {
    	if(n==(i*j))
      {
          printf("Yes\n");
          p=1;
          break;
      }
    }
    if(p==1){break;}
  }
  if(p==0)
  {
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
n = int(input())
s = list(map(int,input().split(" ")))

counter = 0
ans = 0
for i in range(n-1):
    if s[i] >= s[i+1]:
        counter += 1
        ans = max(ans,counter)
    else:
        ans = max (ans,counter)
        counter = 0
print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
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;}


int main(){
  int n,x,t;
  cin >> n >> x >> t;
  cout << ((n + x - 1) / x) * t << endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b)cout << c << endl;
    else if(b == c)cout << a << endl;
    else if(a == c)cout << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

const int mod = 1e9 + 7;
long long int mypow(long long int a, long long int b) {
    if (b == 0) return 1;
    if (b == 1) return a;
    long long int res = mypow(a, b / 2);
    res = res * res % mod;
    if (b % 2 == 1) res = res * a % mod;
    return res;
}

int main() { 
    long long int n;
    cin >> n;
    vector<long long int> v(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end(), greater<long long int>());
    long long int res = 0;
    for (int i = 0; i < n; i++) {
        res += v[i] * mypow(2, i + 1) % mod * ((mypow(2, i) + i * mypow(2, i - 1)) % mod) % mod * mypow(4, n - i - 1) % mod;
        res %= mod;
    }
    cout << res << endl;
}




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

int main()
{
	ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
 	
	long long n; cin >> n;
	string ans = "";
	string abc = "abcdefghijklmnopqrstuvwxyz";	
	int rem ; 
	while(n > 0){
		n -= 1;
		rem = n%26;
		ans += abc[rem];
		n /= 26;
	}

  reverse(ans.begin(), ans.end());
	cout << ans;

  return 0;
}


Measured memory_bytes: 3656
import bisect
a,b,q=map(int,input().split())
s=[]
t=[]
for i in range(a):
    s.append(int(input()))
for i in range(b):
    t.append(int(input()))
for i in range(q):
    x=int(input())
    si=bisect.bisect_left(s,x)
    ti=bisect.bisect_left(t,x)
    if si==a:
        sk=[s[a-1]]
    elif si==0:
        sk=[s[0]]
    else:
        sk=[s[si-1],s[si]]
    if ti==0:
        tk=[t[0]]
    elif ti==b:
        tk=[t[b-1]]
    else:
        tk=[t[ti-1],t[ti]]
    ans=1000000000000
    for f in sk:
        for g in tk:
            ans=min(ans,abs(x-f)+abs(f-g),abs(x-g)+abs(g-f))
    print(ans)


Measured memory_bytes: 12092
X, K, D = map(int, input().split())
count = abs(X) // D
distance = abs(X) % D
if K <= count:
  print(abs(X) - (K * D))
else:
  remain = K - count
  if remain % 2 == 1:
    # if odd, move from current position
    print(abs(distance - D))
  else:
    # even, thus stays at current position
    print(distance)


Measured memory_bytes: 61812
import math


def main():
    a,b,n = map(int,input().split())
    # m = math.floor(a * 0 /b) - a * math.floor(0/b)
    # for i in range(1,min(b-1,n)+1):
    #     if m < math.floor(a * i / b) - a * math.floor(i/b):
    #         m = math.floor(a * i / b) - a * math.floor(i/b)
    i = min(b-1,n)
    m = a*i//b - a*(i//b)
    
    print(m)
if __name__ == "__main__":
    main()


Measured memory_bytes: 9024
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
   int N, A, B;
   cin >> N >> A >> B;
   cout << min(N * A, B) << endl;
   return 0;
}


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


struct pos {
	int x, y;
	pos() = default;
	pos(int x_, int y_) 
		:x{ x_ }, y{ y_ }
	{}

	friend decltype(auto)
		operator>>(std::istream& is, pos&p) {
		return is >> p.x >> p.y;
	}
};

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

	//constexpr const auto size = 200;
	
	std::vector<pos>R{}, B{};

	R.resize(n);
	B.resize(n);

	for (auto&e : R)
		std::cin >> e;

	for (auto&e : B)
		std::cin >> e;

	std::sort(std::begin(R), std::end(R)
		, [](auto a,auto b) {
			return a.y > b.y;
		}
	);

	std::sort(std::begin(B), std::end(B)
		, [](auto a,auto b) {
		return
			a.x < b.x;
		}
	);

	std::vector<bool> check(n,false);


	int ans{};
	for (int i{}; i < n; ++i) {

		for (int j{}; j < n; ++j) {
			/*std::cout
				<< R[i].x << " " << R[i].y << " "
				<< B[j].x << " " << B[j].y << " "
				<< (check[j] ? "T" : "F")
				<< "\n";

			*/
			if (check[j])
				continue;

			if ( R[i].x < B[j].x && R[i].y < B[j].y ) {
				check[j] = true;
				++ans;
				break;
			}
		}
	}

	std::cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct node_t {
	int val;
	struct node_t *prev, *next;
} node;

node* new_node(int val) {
	static int it = 0;
	static node pool[500100];
	pool[it] = (node) { val, NULL, NULL };
	return &pool[it++];
}

int main(void)
{
	int q, com, x, cnt = 0;
	node *st = new_node(0), *it = st, *tmp;
	scanf("%d", &q);
	while (q--) {
		scanf("%d", &com);
		if (com == 0) {
			scanf("%d", &x);
			tmp = new_node(x);
			if (it == st) st = tmp;
			tmp->next = it;
			tmp->prev = it->prev;
			if (it->prev) it->prev->next = tmp;
			it->prev = tmp;
			it = tmp;
			++cnt;
		}
		else if (com == 1) {
			scanf("%d", &x);
			if (x >= 0) {
				while (x--) it = it->next;
			}
			else {
				x = -x;
				while (x--) it = it->prev;
			}
		}
		else {
			tmp = it;
			it = it->next;
			if (tmp == st) st = it;
			if (tmp->prev) tmp->prev->next = it;
			it->prev = tmp->prev;
			--cnt;
		}
	}
	while (st->next) {
		printf("%d\n", st->val);
		st = st->next;
	}
	return 0;
}



Measured memory_bytes: 14248
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - Pyramid
            int N = int.Parse(Console.ReadLine());

            //座標の情報をすべて取得
            var coords = GetCoodinates(N);

            for(int cx = 0; cx <= 100; cx++)
            {
                for(int cy = 0; cy <= 100; cy++)
                {
                    int H = GetCenterHeight(cx, cy, coords);

                    if (IsMatch(cx, cy, H, coords))
                    {
                        Console.WriteLine("{0} {1} {2}", cx, cy, H);
                        break;
                    }
                }
            }
        }

        static bool IsMatch(int cx, int cy, int H, int[][] coords)
        {
            foreach(var coord in coords)
            {
                int h = CalcHeight(cx, cy, H, coord);

                if (h != coord[2])
                {
                    return false;
                }
            }

            return true;
        }

        static int CalcHeight(int cx, int cy,int H, int[] coord)
        {
            int x = coord[0];
            int y = coord[1];
            int h = coord[2];

            return Math.Max(H - Math.Abs(x - cx) - Math.Abs(y - cy), 0);
        }

        static int GetCenterHeight(int cx, int cy, int[][] coords) 
        {
            foreach(var coord in coords)
            {
                if (coord[2] > 0)
                {
                    int x = coord[0];
                    int y = coord[1];
                    int h = coord[2];

                    return h + Math.Abs(x - cx) + Math.Abs(y - cy);
                }
            }

            return 1;
        }

        static int[][] GetCoodinates(int N)
        {
            var coods = new int[N][];

            for(int i = 0; i < N; i++)
            {
                var coord = ReadLine();
                coods[i] = coord;
            }

            return coods;
        }

        static int[] ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToArray();
        }
    }
}

Measured memory_bytes: 13396
W,H,N = map(int, input().split())
xya = [list(map(int, input().split())) for _ in range(N)]

x1 = 0
y1 = 0
x2 = W
y2 = H

for i in range(N):
    a = xya[i][2]

    if a == 1:
        x1 = max(x1, xya[i][0])
    elif a == 2:
        x2 = min(x2, xya[i][0])
    elif a == 3:
        y1 = max(y1, xya[i][1])
    else:
        y2 = min(y2, xya[i][1])
x = x2-x1
y = y2-y1

if x > 0 and y > 0:
    print((x2-x1) * (y2-y1))
else:
    print(0)




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

int main() {
    int N;
    cin >> N;
    vector<int> a(N), b(N);
    for(int i=0; i<N; ++i) cin >> a[i];
    for(int j=0; j<N; ++j) cin >> b[j];

    int res = 0;
    vector<int> A(N), B(N);
    
    for(int k=0; k<29; ++k) {
        int mask = (1 << (k + 1)) - 1;
        for(int i=0; i<N; ++i) {
            A[i] = a[i] & mask;
            B[i] = b[i] & mask;
        }
        sort(begin(B), end(B));

        int cnt = 0;
        for(int i=0; i<N; ++i) {
            if(A[i] <= (1 << k)) {
                cnt += lower_bound(begin(B), end(B), (1 << (k + 1)) - A[i])
                        - lower_bound(begin(B), end(B), (1 << k) - A[i]);
            } else {
                cnt += lower_bound(begin(B), end(B), (1 << (k + 1)) - A[i]) - begin(B);
                cnt += end(B) - lower_bound(begin(B), end(B), (1 << k) + (1 << (k + 1)) - A[i]);
            }
            cnt %= 2;
        }

        if(cnt) res += (1 << k);
    }
    
    cout << res << endl;
}

Measured memory_bytes: 3328
import copy
n,a,b,c,d=map(int, input().split())
S='.'+input()
dpa=[0]*(n+1)
dpb=[0]*(n+1)
seta=[c]
setb=[d]
if d<c:
    if S[b-1:d+2].find('...')>=0:
        while seta:
            i = seta.pop()
            if i>0 and S[i-1]=='.' and dpa[i-1]==0:
                dpa[i-1]=1
                seta.append(i-1)
            if i>1 and S[i-2]=='.' and dpa[i-2]==0:
                dpa[i-2]=1
                seta.append(i-2)
        while setb:
            i = setb.pop()
            if i>0 and S[i-1]=='.' and dpb[i-1]==0:
                dpb[i-1]=1
                setb.append(i-1)
            if i>1 and S[i-2]=='.' and dpb[i-2]==0:
                dpb[i-2]=1
                setb.append(i-2)
else:
    while setb:
        i = setb.pop()
        if i>0 and S[i-1]=='.' and dpb[i-1]==0:
            dpb[i-1]=1
            setb.append(i-1)
        if i>1 and S[i-2]=='.' and dpb[i-2]==0:
            dpb[i-2]=1
            setb.append(i-2)
    while seta:
        i = seta.pop()
        if i>0 and S[i-1]=='.' and dpa[i-1]==0:
            dpa[i-1]=1
            seta.append(i-1)
        if i>1 and S[i-2]=='.' and dpa[i-2]==0:
            dpa[i-2]=1
            seta.append(i-2)
if dpa[a]==1 and dpb[b]==1:
    print('Yes')
else:
    print('No')
    

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

int main() {
  int n;
  cin >> n;
  // 4ドルケーキ
  for (int i = 0; i < 30; i++) {
    // 7ドルケーキ
    for (int j = 0; j < 15; j++) {
      int sum = 4 * i + 7 * j;
      if (sum == n) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    vector<int> x(a);
    for (int i = 0; i < a; i++) {
        cin >> x[i];
    }
    double kaunto = 0;
    int count = 0;
    for (int i = 0; i < a; i++) {
        kaunto += x[i];
    }
    for (int i = 0; i < a; i++) {
        if (x[i] >= kaunto / (4 * b)) {
            count++;
        }
    }
    if (count >= b) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;     
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main() {
    vector<string> v={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string s;
    cin>>s;
    int ans=0;
    rep(i,7) if(s==v[i]) ans=7-i;
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n;bool flag=false;
  cin >> n;
  char *s = new char[n];
  cin >> s;
  if(n%2==1)cout << "No" << endl;
  else{
    for(int i=0;i<(n/2);i++){
      if(s[i] != s[i+(n/2)]){
        flag = true;
        break;
      }
    }
    if(flag)cout << "No" << endl;
    else cout << "Yes" << endl;
  }
  return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


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


void solve(VLL & w){
  int n = w.size();
  bool dp[n][n];
  memset(dp,false,sizeof(dp));
  FOR(len,2,n+1){
    for(int l = 0; (l + len - 1) < n; l++){
      int r = l + len - 1;
      if(len == 2){
        dp[l][r] = dp[l][r] || (abs(w[l] - w[r]) <= 1);
      }
      FOR(k,l+1,r){

        dp[l][r] = (dp[l][k] && dp[k+1][r]) || dp[l][r];
        dp[l][r] = dp[l][r] || ( (abs(w[l] - w[r]) <= 1) && ( (dp[l+1][k] && dp[k+1][r-1]) || dp[l+1][r-1]));
      }
    }
  }
  // rep(i,n){
  //   rep(j,n){
  //     cout << dp[i][j] << ' ';
  //   }
  //   cout << endl;
  // }
  ll ep[n+1];
  memset(ep,0,sizeof(ep));
  rep(i,n){
    ep[i+1] = max(ep[i],ep[i+1]);
    FOR(j,i+1,n){
      if(dp[i][j]){
        if(i == 0) ep[j] = max((ll)(j-i+1),ep[j]);
        else ep[j] = max((ll)(j-i+1)+ep[i-1],ep[j]);
      }
    }
  }
  cout << ep[n] << endl;
  return;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  while(true){
    cin >> n;
    if(n == 0) break;
    VLL w(n);
    rep(i,n) cin >> w[i];
    solve(w);
  }
  cin >> n;

  return 0;
}



Measured memory_bytes: 3208
/*

------------------------------------------------------------

i番目の足場に到達するための最小のコストをc[i]とする

c[0] = 0
c[i] = min(j; 0 .. i) (c[j] + (h[i] - h[j])^2 + C)

上記を計算すればよいが、これはもちろんTLE

jのほうを絞り込む

------------------------------------------------------------

c[i] = h[i]^2 + C + min(j; 0 .. i)(-2 h[i] h[j] + c[j] + h[j]^2)

hの一次関数 f[j]: h => -2 h[j] h + c[j] + h[j]^2 を考える
（定義域は h >= h[j]）

これは単調減少、しかも傾きはjが増加するとき減少(負で絶対値が大きくなる)

c[i] = h[i]^2 + C + q(h[i])
hの関数 q(h) = min(j; 0 .. i) f[j](h) は、傾きが単調に増加する折れ線関数 ※jに応じて変わる

「h >= l[k] の範囲では、q(h) = -a[k]h + b[k]」

 (l, a, b)[k] として、lでソートして配列に持っておく

新しいfができたら、それを考慮する
a、bはわかっているがlを求めなければならない

二分探索でf(l) >= q(l) をみたす最大のlをみつける
元々あったl以降は消す

------------------------------------------------------------


*/


import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }


class F{
	long left;
	long a, b;
	this(long a, long b){
		this.a = a;
		this.b = b;
	}
	long opCall(long h){
		return a * h + b;
	}
	override string toString(){
		return a.to!string ~ "x+" ~ b.to!string ~ "(x>=" ~ left.to!string ~ ")";
	}
}

void main(){
	
	// a <= x <=  c の中でfをみたす最大(二分探索; binary search) ※テンプレート版
	T uplimit(T)(T a, T c, bool delegate(T) f){
		if(f(c)) return c; if(! f(a)) return a - 1;
		while(a + 1 < c){ T b = (a + c) / 2; if(f(b)) a = b; else c = b; }
		return a;
	}
	
	long n = read.to!long;
	long c = read.to!long;
	
	long[] hs;
	foreach(i; 0 .. n) hs ~= read.to!long;
	
	long[] cs = new long[](n);
	cs[0] = 0;
	F[] fs = [new F(-2 * hs[0], cs[0] + hs[0] * hs[0])];
	fs[0].left = hs[0];
	foreach(i; 1 .. n){
		// 計算
		long k = uplimit(0, fs.length - 1, (long _) => fs[_].left <= hs[i]);
		cs[i] = hs[i] * hs[i] + c + fs[k](hs[i]);
		debug writeln("k:", k, " cs:", cs);
		
		// 1次関数
		F f = new F(-2 * hs[i], cs[i] + hs[i] * hs[i]);
		f.left = hs[i];
		
		// 挿入するところを見つける
		debug writeln("i:", i, " fs:", fs, " f:", f);
		k = uplimit(0, fs.length - 1, (long _) => fs[_](fs[_].left) <= f(fs[_].left));
		debug writeln("k:", k);
		long l = 1 + uplimit(fs[k].left, hs[n - 1] + 1, (long _) => f(_) > fs[k](_));
		debug writeln("l:", l);
		
		// 挿入
		fs.length = k + 2;
		fs[$ - 1] = f;
		f.left = l;
		debug writeln("fs:", fs);
		
	}
	
	cs[n - 1].writeln;
	
}


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

using namespace std;

#define MAX 15
typedef pair<int,int> pii;
typedef pair<int,pii> piii;

int H,W,T;
vector<piii> vec;

bool check(int s){
  int now = s;
 
  for(int i = 0 ; i < (int)vec.size() ; i++){
    if(vec[i].second.first == now){
      now = vec[i].second.second;
    }else if(vec[i].second.second == now){
      now = vec[i].second.first;
    }
  }
  return now == T;
}

int main(){
  int S;
  bool G[MAX][MAX][MAX];
  char in;
  
  while(cin >> W,W){
    memset(G,false,sizeof(G));
    vec.clear();
    cin >> S >> T >> H; S--; T--;
    for(int i = 0 ; i < H ; i++){
      for(int j = 0 ; j < W-1 ; j++){
        cin >> in;
        if(in == '1'){
          if(j > 0){
            G[i][j-1][j] = true;
          }
          G[i][j][j+1] = true;
          G[i][j+1][j+2] = true;
          vec.push_back(piii(i,pii(j,j+1)));
        }
      }
    }
    sort(vec.begin(),vec.end());
    if(check(S)){
      cout << 0 << endl;
    }else{
      bool found = false;
      for(int i = 0 ; i < H ; i++){
        for(int j = 0 ; j < W-1 ; j++){
          if(G[i][j][j+1]) continue;
          vector<piii> tmp = vec;
          vec.push_back(piii(i,pii(j,j+1)));
          sort(vec.begin(),vec.end());
          if(check(S)){
            cout << i+1 << " " << j+1 << endl;
            found = true;
            goto end;
          }
          vec = tmp;
        }
      }
    end:;
      if(!found){
        cout << 1 << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1204
n=int(input())
h=list(map(int,input().split()))
x=h[0]
y=0
z=0
for i in range(1,n):
  if x>=h[i]:
    y=y+1
  else:
    if y>z:
      z=y
    y=0
  x=h[i]
if y>z:
  z=y
print(z)

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	long long n, k, s = 0, c = 1;
	cin >> n >> k;
	for (int i = 0; i < 3; i++) c *= n / k;
	s += c; 
	if (k % 2 == 0) {
		c = 1; n += k / 2;
		for (int i = 0; i < 3; i++) c *= n / k;
		s += c;
	}
	cout << s << '\n';
	return 0;
}

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

const int nmax = 40, abmax = 10, inf = 1000000;

int a[nmax], b[nmax], c[nmax];
int dp[nmax + 1][nmax * abmax + 1][nmax * abmax + 1];

int main () {

    int n, ma, mb;

    cin >> n >> ma >> mb;

    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }

    for (int i = 0; i <= n; i++) {
        for (int ca = 0; ca <= nmax * abmax; ca++) {
            for (int cb = 0; cb <= nmax * abmax; cb++) {
                dp[i][ca][cb] = inf;
            }
        }
    }

    dp[0][0][0] = 0;

    for (int i = 0; i < n; i++) {
        for (int ca = 0; ca <= nmax * abmax; ca++) {
            for (int cb = 0; cb <= nmax * abmax; cb++) {
                if (dp[i][ca][cb] == inf) continue;

                dp[i+1][ca][cb] = min(dp[i+1][ca][cb], dp[i][ca][cb]);
                dp[i+1][ca+a[i]][cb+b[i]] = min(dp[i+1][ca+a[i]][cb+b[i]], dp[i][ca][cb] + c[i]);
            }
        }
    }

    int ans = inf;

    for (int ca = 1; ca <= nmax * abmax; ca++) {
        for (int cb = 1; cb <= nmax * abmax; cb++) {
            if (ca * mb == cb * ma) ans = min(ans, dp[n][ca][cb]);
        }
    }

    if (ans == inf) ans = -1;
    cout << ans << endl;

    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(ll i=x;i<y;i++)
#define frr(i,x,y) for(ll i=x-1;i>=y;i--)
#define inf 10000000000000000
const ll mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

void solve()
{
    ll n,k,ct=0;
    cin>>n>>k;
    ll last=n-k;
    ll max=n*(n+1)/2;
    max-=last*(last+1)/2;
    fr(i,k,n+2)
    {
        ll min=i*(i-1)/2;
        //cout<<max<<" "<<min<<endl;
        ct+=(max-min+1);
        ct%=mod;
        max+=last;
        last--;
        if(last<0)
            last=0;
    }
    cout<<ct<<endl;
    return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
const int N=105;
int a,b,f[N][N],d[N][N],s[N][N];
int main()
{
    scanf("%d%d",&a,&b);
    for(int x=1;x<=a;x++)
        for(int y=1;y<=b;y++)
        scanf("%d",&d[x][y]);
    for(int i=1;i<=101;i++)
        for(int j=1;j<=101;j++)
        for(int x=1;x<=a;x++)
        for(int y=1;y<=b;y++)
        f[i][j]=max(f[i][j],d[x][y]-(i-1)*x-(101-j)*y);
    memset(s,inf,sizeof(s));
    for(int i=1;i<=101;i++)
        for(int j=1;j<=101;j++)
            for(int x=1;x<=a;x++)
            for(int y=1;y<=b;y++)
            s[x][y]=min(s[x][y],f[i][j]+(i-1)*x+(101-j)*y);
    for(int x=1;x<=a;x++)
        for(int y=1;y<=b;y++)
        if(d[x][y]!=s[x][y])
    {
        printf("Impossible\n");
        return 0;
    }
    printf("Possible\n");
    printf("202 %d\n",100+100+101*101);
    for(int i=1;i<101;i++)
        printf("%d %d X\n",i,i+1);
    for(int i=1;i<101;i++)
        printf("%d %d Y\n",101+i,101+i+1);
    for(int i=1;i<=101;i++)
        for(int j=1;j<=101;j++)
        printf("%d %d %d\n",i,j+101,f[i][j]);
    printf("%d %d\n",1,202);
}


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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

using Int = long long;
Int N, C;
Int imos[100005][32];
set<int> s_set[32], t_set[32];
int main() {
    cin >> N >> C;
    rep(i, N) {
        int s, t, c;
        cin >> s >> t >> c;
        c--;
        imos[s][c]++;
        imos[t + 1][c]--;
        s_set[c].insert(s);
        t_set[c].insert(t);
    }
    rep(i, 100005) rep(j, 32) if (i) imos[i][j] += imos[i - 1][j];
    rep(c, 32) {
        for (auto e : s_set[c]) {
            if (t_set[c].count(e)) imos[e][c]--;
        }
    }
    Int ans = 0;
    rep(i, 100005) {
        Int s = 0;
        rep(j, 32) s += imos[i][j];
        ans = max(ans, s);
    }
    // rep(i, 11) cout << imos[i][0] << " ";
    cout << endl;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 34688
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define INF 10000000000000009
#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl

signed main(){
    int N;
    int a[114514];
    bool odd=false;
    cin >> N;
    REP(i,N){
        cin >> a[i];
        if(a[i]%2==1){
            odd=true;
        }
    }
    out(odd,"first","second");
    return 0;
}   


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<vector>
struct P{int x,y;P(int x,int y):x(x),y(y){}};

int num[10][10];
bool visited[10][10];
std::vector<P>v;

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

bool BackTrack(int x,int y,int index,int rest)
{
	if(rest<0) return false;
	if(rest==0)
	{
		if(index==v.size()-1)
			return true;
		++index;
		x=v[index].x;
		y=v[index].y;
		rest = -num[y][x];
		return BackTrack(x,y,index,rest);
	}
	for(int i=0; i<4; ++i)
	{
		int nx = x+dx[i];
		int ny = y+dy[i];
		if(visited[ny][nx])continue;
		visited[ny][nx] = true;

		if(BackTrack(nx,ny,index,rest-num[ny][nx]))
			return true;

		visited[ny][nx] = false;
	}
	return false;
}

int main()
{
	int n,i,j,t;
	while(scanf("%d",&n),n)
	{
		v.clear();
		memset(visited,1,sizeof(visited));

		int check = 0;
		for(i=1; i<=n; ++i)
		{
			for(j=1; j<=n; ++j)
			{
				scanf("%d",&t);
				num[i][j]=t;
				if(t<0)
				{
					v.push_back(P(j,i));
					visited[i][j]=true;
				}
				else
				{
					visited[i][j]=false;
				}
				check += t;
			}
		}

		int x=v[0].x;
		int y=v[0].y;
		puts(check==0&&BackTrack(x,y,0,-num[y][x]) ? "YES" : "NO");
	}
	return 0;
}

Measured memory_bytes: 1016
S = gets.chomp.split('')
T = gets.chomp.split('')
translatable = false

s_char_types = []
S.uniq.each do |s|
  s_char_types << S.count(s)
end
t_char_types = []
T.uniq.each do |t|
  t_char_types << T.count(t)
end

if S.uniq.size == T.uniq.size && s_char_types.sort == t_char_types.sort
  translatable = true
end

if translatable
  puts "Yes"
else
  puts "No"
end


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

int n;
int m = 0;
long long cnt;
vector<int> G;

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

void ShellSort(int A[], int n) {
    G.clear();
    for (int i = 1; i <= n; i = i * 3 + 1) {
        G.push_back(i);
        m++;
    }
    for (int i = G.size() - 1; i >= 0; i--) {
        InsertionSort(A, n, G[i]);
    }
}

int main() {
	cin >> n;
	int A[n];
	cnt = 0;
	for (int i = 0; i < n; i++) cin >> A[i];
	ShellSort(A, n);
	cout << m << endl;
	for(int i = m - 1; i >= 0 ;i--) {
	    cout << G[i];
	    if (i < m) cout << " ";
	}
	cout << endl << cnt << endl;
	for (int i = 0; i < n; i++) cout << A[i] << endl;
}



Measured memory_bytes: 6964
#include <bits/stdc++.h>
using namespace std;
const int MAX_N=101;

int n,ans;
vector<int> s(MAX_N);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n,n){
        for (int i=0;i<n;++i) cin >> s[i];
        sort(s.begin(),s.begin()+n);
        ans=0;
        for (int i=1;i<n-1;++i) ans+=s[i];
        cout << ans/(n-2) << '\n';
    }
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

auto dist(pair<int, int> a, pair<int, int> b) {
  if (b.first < a.first) swap(a, b);
  if (b.first < a.second) {
    return 0;
  }
  return b.first - a.second;
}

int main() {
  int W, a, b;
  cin >> W >> a >> b;
  vector<pair<int, int>> vs = {
    make_pair(a, a + W),
    make_pair(b, b + W)
  };
  cout << dist(vs[0], vs[1]) << "\n";
}


Measured memory_bytes: 256
#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: 128
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        decimal n = decimal.Parse(Console.ReadLine());
        //int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();

        var tmp1 = Math.Round(n / (decimal)1.08);
        var tmp2 = Math.Floor(tmp1 * (decimal)1.08);
        var tmp3 = Math.Floor((tmp1 - 1) * (decimal)1.08);
        var tmp4 = Math.Floor((tmp1 + 1) * (decimal)1.08);

        var ans = ":(";
        if (tmp2 == n) ans = tmp1.ToString();
        else if (tmp3 == n) ans = (tmp1-1).ToString();
        else if (tmp4 == n) ans = (tmp1+1).ToString();
        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11220
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
int main(){
  string s;
  int ok = 0;
  cin >> s;
  if(s[2] == s[3] && s[4] == s[5])ok = 1;
  if(ok == 1)cout << "Yes" << endl;
  else cout << "No" << endl; 
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<vector<int>> paths(N);
  for(int i=0;i<M;i++){ // O(M)
    int a,b;
    cin >> a >> b;
    paths.at(a-1).push_back(b-1);
    paths.at(b-1).push_back(a-1);
  }
  vector<int> label(N);
  vector<int> depth(N);
  vector<bool> checked(N,false);
  checked.at(0) = true;
  queue<int> que;
  que.push(0);
  while(1){
    int i = que.front(); que.pop();
    for(auto j:paths.at(i)){
      if(!checked.at(j)){
        que.push(j);
        checked.at(j) = true;
        depth.at(j) = depth.at(i) + 1;
        label.at(j) = i;
      }
    }
    if(que.empty()){
      break;
    }
  }
  bool ok=true;
  for(int i=0;i<N;i++)
    if(!checked.at(i)) ok=false;
  if(ok){
    cout << "Yes" << endl;
    for(int i=1;i<N;i++)
      cout << label.at(i) + 1 << endl;
  }else{
    cout << "No" << endl;
  }
}
  

Measured memory_bytes: 10648