akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <sstream>
#include <map>
using namespace std;

const string kan[38] = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "ld", "mb", "mp", "nc", "nd", "ng", "nt", "nw", "ps", "qu", "cw", "ts"};

int main() {
  int n;
  while(cin >> n) {
    cin.ignore();
    map<pair<int,int>, int> m;
    for(int i = 0; i < n; ++i) {
      string s;
      getline(cin, s);
      stringstream ss(s);
      while(ss >> s) {
        for(int j = 0, pre = -1; j < s.size(); ) {
          for(int k = 0; k < 38; ++k) {
            int nk = (k + 26) % 38;
            const string &t = kan[nk];
            if(s.substr(j, t.size()) == t) {
              j += t.size();
              if(pre != -1) {
                m[make_pair(pre, nk)] += 1;
              }
              pre = nk;
              break;
            }
          }
        }
      }
    }

    pair<int,int> maxi[38] = make_pair(0,0);
    for(map<pair<int,int>,int>::iterator it = m.begin();
        it != m.end(); ++it) {
      int a = it->first.first;
      int b = it->first.second;
      int c = it->second;
      maxi[a] = max(maxi[a], make_pair(c, -b));
    }
    for(int i = 0; i < 38; ++i) {
      cout << kan[i] << " " << kan[-maxi[i].second] << " " << maxi[i].first << endl;
    }
  }
  return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef int64_t ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
  string S, T;
  cin >> S >> T;

  int cnt = 0;
  REP(i, 3) if (S[i] == T[i]) cnt++;
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        String c = stdIn.next();
        String strSet = "abcdefghijklmnopqrstuvwxyz";

        int n = strSet.indexOf(c);
        System.out.println(strSet.charAt(n + 1));
    }
}

Measured memory_bytes: 20948
import sys
sys.setrecursionlimit(10**6)

#a = int(input())
#b = list(map(int, input().split()))
n, x = map(int, input().split())
#s = input()
#s,t = input().split()
#
readline = sys.stdin.readline
l = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

ans = 1
height = 0
for i in range(n):
    height += l[i]
    if height <= x:
        ans += 1
    else:
        break
print(ans)

Measured memory_bytes: 9120
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
 
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;
}
ll max(ll a, ll b){
    if(a > b) return a;
    else return b;
}
 
ll min(ll a, ll b){
    if(a < b) return a;
    else return b;
}
 
int main(void){
    string a, b; cin >> a >> b;
    int n = stoi(a + b);
    for(int i = 1; i <= sqrt(100100) + 10; i++){
        if(pow(i, 2) == n){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//                       _oo0oo_                         //
//                      o8888888o                        //
//                      88" . "88      ------ hzt1       //
//                      (| -_- |)                        //
//                      0\  =  /0                        //
//                    ___/`---'\___                      //
//                  .' \|     |// '.                     //
//                 / \|||  :  |||// \                    //
//                / _||||| -:- |||||- \                  //
//               |   | \  -  /// |     |                 //
//               | \_|  ''\---/''  |_/ |                 //
//               \  .-\__  '-'  ___/-. /                 //
//             ___'. .'  /--.--\  `. .'___               //
//          ."" '<  `.___\_<|>_/___.' >' "".             //
//         | | :  `- \`.;`\ _ /`;.`/ - ` : | |           //
//         \  \ `_.   \_ __\ /__ _/   .-` /  /           //
//     =====`-.____`.___ \_____/___.-`___.-'=====        //
//                       `=---='                         //
//                                                       //
//                                                       //
//     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~       //
//                                                       //
//                 God-He Bless All.                     //
//           This Code Will Never Explode.               //
//                                                       //
//                                                       //
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#include<vector>
#define pb push_back
#define mp make_pair
#define xx first
#define yy second
#define rep(i,a,b) for(int i=(a),i##_end_=(b);i<=i##_end_;i++)
#define dwn(i,a,b) for(int i=(a),i##_end_=(b);i>=i##_end_;i--)
using namespace std;
const int Size=1<<16;
char buffer[Size],*head,*tail;
inline char Getchar() {
    if(head==tail) {
        int l=fread(buffer,1,Size,stdin);
        tail=(head=buffer)+l;
    }
    if(head==tail) return -1;
    return *head++;
}
inline int read() {
    int x=0,f=1;char c=Getchar();
    for(;!isdigit(c);c=Getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=Getchar()) x=x*10+c-'0';
    return x*f;
}
typedef long long ll;
const int maxn=310;
int n,m,A[maxn][maxn],use[maxn],p[maxn],cnt[maxn];
int main() {
	n=read();m=read();
	rep(i,1,n) rep(j,1,m) A[i][j]=read();
	rep(i,1,n) p[i]=1;
	int ans=n;
	rep(T,1,m) {
		memset(cnt,0,sizeof(cnt));
		rep(i,1,n) {
			while(use[A[i][p[i]]]) p[i]++;
			cnt[A[i][p[i]]]++;
		}
		int res=0;
		rep(i,1,m) if(!use[i]) res=max(res,cnt[i]);
		ans=min(ans,res);
		rep(i,1,m) if(cnt[i]==res) {use[i]=1;break;}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int CC[310][310];
char p[310];
int M[310][310], w[310], vis[310][310], D[310][310][310], Mod = 998244353;
int n;
long long res;
void UDT(int i, int a, int b){
    if(M[i][a]<b)M[i][a]=b;
}
void Do(int L){
    int i, j, k;
    for(i=0;i<=n;i++){
        for(j=0;j<=n;j++){
            M[i][j]=-1;
        }
    }
    M[0][0]=0;
    for(i=0;i<L;i++){
        for(j=0;j<=L;j++){
            int a = j, b = M[i][j];
            if(b==-1)continue;
            UDT(i+1,a,b);
            if(i+2<=L){
                if(w[i+1]==0||w[i+2]==0)UDT(i+2, a+1,b);
                if(w[i+1]==1||w[i+2]==1)UDT(i+2, a,b+1);
            }
            if(w[i+1]==0 && b){
                UDT(i+1,a+1,b-1);
            }
            if(w[i+1]==1 && a){
                UDT(i+1,a-1,b+1);
            }
        }
    }
    int cc[2]={0};
    for(i=L+1;i<=n;i++){
        cc[w[i]]++;
    }
    for(i=0;i<=L;i++){
        for(j=0;j<=M[L][i];j++){
            if(!i&&!j)continue;
            int x = cc[0]+i,y = cc[1]+j;
            if(!vis[x][y]){
                vis[x][y]=1;
                for(k=n-L;k<=n;k++){
                    res+=D[x][y][k];
                }
            }
        }
    }
}
int main(){
    int i, j, k, l;
    scanf("%s",p);
    for(i=0;p[i];i++);
    n=i;
    for(i=1;i<=n;i++)w[i]=p[i-1]-'0';
    D[0][0][0]=1;
    for(i=0;i<=n;i++){
        for(j=0;i+j<=n;j++){
            for(k=0;k<=n;k++){
                if(!D[i][j][k])continue;
                int t = D[i][j][k];
                if(k+1<=n && w[n-(k+1)+1]==0){
                    D[i+1][j][k+1]=(D[i+1][j][k+1]+t)%Mod;
                }
                else{
                    D[i+1][j][k]=(D[i+1][j][k]+t)%Mod;
                }
                if(k+1<=n && w[n-(k+1)+1]==1){
                    D[i][j+1][k+1]=(D[i][j+1][k+1]+t)%Mod;
                }
                else{
                    D[i][j+1][k]=(D[i][j+1][k]+t)%Mod;
                }
            }
        }
    }
    for(i=n;i>=2;i--){
        Do(i);
    }
    res++;
    printf("%lld\n",res%Mod);
}


Measured memory_bytes: 58700
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(long long i=0;i<n;i++)
#define REPP(i,m,n) for(long long i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl;
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() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    int M,D;
    cin >> M >> D;
    int ans = 0;
    REPP(i,1,M+1){
        REPP(j,22,D+1){
            if((j/10) * (j%10) == i && (j/10) >= 2 && (j%10) >= 2){
                ans++;
                //cout << i << ' ' << j/10 << ' ' << j%10 << endl;
            }
        }
    }
    cout << ans << endl;
}

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

int main()
{
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    s = "z" + s;

    vector<int> cumcnt(n+1);
    cumcnt[0] = 0;
    rep(i, 1, n + 1)
    {
        cumcnt[i] = cumcnt[i - 1];
        if (s[i - 1] == 'A' and s[i] == 'C')
            cumcnt[i]++;
        // cout << cumcnt[i] << endl;
    }

    rep(i, 0, q)
    {
        int l, r;
        cin >> l >> r;
        cout << cumcnt[r] - cumcnt[l] << endl;
    }
    return 0;
}

Measured memory_bytes: 1404
# https://atcoder.jp/contests/agc024/tasks/agc024_b

N = int(input())
A = [int(input()) - 1 for _ in range(N)]
Q = [0] * N
for i in range(N):
    Q[A[i]] = i

ans = 0
res = 1
for i in range(1, N):
    if Q[i] > Q[i - 1]:
        # keepできる
        res += 1
    else:
        # 回数をカウント
        ans = max(ans, res)
        res = 1
ans = max(ans, res)
# 全体 - 動かさない
print(N - ans)

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

string hoge[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

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

    string s;
    cin >> s;

    int i;
    for (i = 0; i < 7; i++) {
        if (hoge[i] == s) {
            break;
        }
    }
    if (i == 0) {
        cout << 7 << endl;
    } else {
        cout << 7 - i << endl;
    }
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		String NN = keyboard.next();
			int N = Integer.parseInt(NN);
			
		int[] yama = new int[N];
			for(int i=0; i < N; i++) {
				yama[i] = keyboard.nextInt();
			}
			
		int count = 1;
		
		int max = yama[0];
		int min = 0;
		
		if (N > 1) {
			min = yama[1];
		}
		
		for (int j = 1; j < N; j++) {
		    int height = yama[j];
		    if ( height >= max) {
		        max = height;
		        count ++;
		        continue;
		    }else {
		    	if (height < min) {
		    		min = height;
		    		continue;
		    	}
		    }
		}
			System.out.print(count);

		keyboard.close();	
	}
}

Measured memory_bytes: 21588
#include<cstdio>
#include<algorithm>
using namespace std;
inline int read()
{
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x; 
}
#define MN 1000
#define MX 5000
int p[MN+5],x[MN+5],f[MN+5][MX+5];
int main()
{
	int n=read(),i,j;
	for(i=2;i<=n;++i)p[i]=read();
	for(i=1;i<=n;++i)x[i]=read();
	for(i=n;i;--i)for(j=x[p[i]];j>=0;--j)
		f[p[i]][j]=min(x[i]<=j?f[p[i]][j-x[i]]+f[i][x[i]]:1e9,
					   f[i][x[i]]<=j?f[p[i]][j-f[i][x[i]]]+x[i]:1e9);
	puts(f[1][x[1]]<1e9?"POSSIBLE":"IMPOSSIBLE");
}

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

void sort(int a[], int b[], int n)  {
	for (int i = 0; i < n; i++)
		for (int j = i; j > 0; j--)
			if (b[j-1] < b[j]) {
				int t = b[j-1];
				b[j-1] = b[j];
				b[j] = t;
				int s = a[j-1];
				a[j-1] = a[j];
				a[j] = s;
			}
}

int main() {
	while (true) {
		int n, m;
		cin >> n >> m;
		if (n == 0 && m == 0) break;
		int d[n], p[n];
		for (int i = 0; i < n; i++)
			cin >> d[i] >> p[i];
		
		sort(d, p, n);
		
		int sum = 0;
		for (int i = 0; i < n; i++)
			sum += d[i] * p[i];
		
		for (int i = 0; i < n; i++) {
			if (m >= d[i]) {
				sum -= d[i] * p[i];
				m -= d[i];
			} else {
				sum -= p[i] * m;
				m = 0;
			}
			if (m == 0) break;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3092
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>

#define fo(i,j,l) for(int i=j;i<=l;++i)
#define fd(i,j,l) for(int i=j;i>=l;--i)

using namespace std;
typedef long long ll;
const ll N=320,M=N<<1;

int n,m,S,T,inf,limit,point;

int lb[M][N],g[M],d[M];
int flow[M][M];
int vh[M],h[M];

inline char readchar()
{
	char ch=' ';
	for(;ch!='S'&&ch!='T'&&ch!='.'&&ch!='o';ch=getchar());
	return ch;
}

inline int min(int a,int b)
{return a<b?a:b;}

int net(int o,int u)
{
	if(o==T)return u;
	int minh=point+1;
	fo(i,1,g[o]<<1){
		d[o]=d[o]==g[o]?1:d[o]+1;
		int k=lb[o][d[o]];
		if(flow[k][o]){		
			if(h[o]==h[k]+1){
				int uu=net(k,min(u,flow[k][o]));
				if(uu>0){
					flow[k][o]-=uu;
					flow[o][k]+=uu;
					return uu;
				}
				if(h[S]>point)return 0;
			}
			minh=min(minh,h[k]+1);
		}
	}
	--vh[h[o]];
	if(vh[h[o]]==0){
		h[S]=point+1;
		return 0;
	}
	h[o]=minh;
	++vh[h[o]];
	return 0;
}
int main()
{
	cin>>n>>m;
	S=n+m+1,T=S+1,limit=n+m,inf=limit<<1,point=n+m+2;
	fo(i,1,n)fo(l,n+1,m+n){
		char ch=readchar();
		if(ch=='o'){
			flow[i][l]=flow[l][i]=1;
			lb[i][++g[i]]=l; lb[l][++g[l]]=i;
		}
		if(ch=='S'){
			flow[i][S]=inf;	flow[l][S]=inf;
			lb[S][++g[S]]=i; lb[S][++g[S]]=l;
		}
		if(ch=='T'){
			flow[T][i]=inf; flow[T][l]=inf;
			lb[i][++g[i]]=T; lb[l][++g[l]]=T;
		}
	}
	vh[0]=point; ll ans=0;
	while(h[S]<=point)ans+=net(S,inf<<3);
	if(ans>limit)puts("-1");else printf("%lld",ans);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>-
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define clr(a,x) memset(a,x,sizeof(a))
#define input(x) freopen(x".in","r",stdin)
#define output(x) freopen(x".in"",w",stdout)
#define file(x) input(x),output(x)
using namespace std;

const int N=100005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x+=y;if(x>=mod) x-=mod;}
inline void read(int &x){
	x=0;char ch=getchar();
	while(ch>'9'||ch<'0') ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
}

int n,W,w[105],v[105];
int dp[105][105][505];

int main(){
	scanf("%d%d",&n,&W);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&w[i],&v[i]);
		for(int j=0;j<=n;j++)
			for(int k=0;k<=n*3;k++){
				dp[i][j][k]=dp[i-1][j][k];
				if(k>=w[i]-w[1]&&j>0) gmax(dp[i][j][k],dp[i-1][j-1][k-w[i]+w[1]]+v[i]);
			}
	}
	int ans=0;
	for(int i=0;i<=n;i++)
		for(int j=0;j<=n*3;j++)
			if(W>=(ll)w[1]*i+j){
			//	printf("%d %d\n",i,j);
				gmax(ans,dp[n][i][j]);
			}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 20864
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

constexpr int MOD = 998244353;

// + - * / ^
int mod(int a)
{
    int res = a % MOD;
    if(res < 0) {
        return res + MOD;
    }
    return res;
}
int mul_mod(int a, int b)
{
    ll res = ((ll)a * (ll)b) % MOD;
    return mod((int)res);
}
int pow_mod(int a, int b)
{
    ll res = 1;
    while (b > 0) {
        if(b & 1) {
            res = res * (ll)a % (ll)MOD;
        }
        a = mul_mod(a, a);
        b >>= 1;
    }
    return (int)res;
}
int inv_mod(int a)
{
    return pow_mod(a, MOD - 2);
}
int div_mod(int a, int b)
{
    return mul_mod(a, inv_mod(b));
}

// ! C
constexpr int FAC_MAX = 3000001;
ll fac[FAC_MAX], finv[FAC_MAX], inv[FAC_MAX];
void com_init()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < FAC_MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll com_mod(int a, int b){
    if (a < b) return 0;
    if (a < 0 || b < 0) return 0;
    return fac[a] * (finv[b] * finv[a - b] % MOD) % MOD;
}


int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, s;  cin >> n >> s;
    vector<int> a(n); rep (i, n) cin >> a[i];
    sort(all(a));
    vector<vector<ll>> dp(n + 1, vector<ll>(s + 3001));
    dp[0][0] = pow_mod(2, n);
    ll X = inv_mod(2);
    rep (i, n) {
        rep (j, s + 1) {
            dp[i + 1][j + a[i]] = mod(dp[i + 1][j + a[i]] + mul_mod(dp[i][j], X));
            dp[i + 1][j] = mod(dp[i + 1][j] + dp[i][j]);
            // dp[i + 1][j] = mod(dp[i + 1][j] + div_mod(dp[i][j], 2));
        }
    }
    ll ans = 0;
    // rep (i, 1, n + 1) ans = mod(ans + dp[i][s]);
    // cout << ans << "\n";
    rep (i, n + 1) {
        rep (j, s + 1) eprintf("%d ", dp[i][j]); eprintf("\n");
    }
    cout << dp[n][s] << "\n";
    return 0;
}

Measured memory_bytes: 144140
//
//  main.cpp
//  A
//
//  Created by Kazi Nayeem on 9/13/20.
//  Copyright © 2020 Brain Craft Ltd. All rights reserved.
//

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

int main(int argc, const char * argv[]) {
    // insert code here...
    int x;
    scanf("%d", &x);
    printf("%d\n", x^1);
    return 0;
}


Measured memory_bytes: 3812
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>
#include <complex>
#include <cassert>
#include <climits>

using namespace std;
using i64 = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const int INF = (1<<30);
const i64 INFL = (1LL<<62);
const i64 MOD = 1000000007;
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> i64 mod_pow(i64 a, i64 n, T mod) { mod=(i64)mod; i64 res=1, p=a%mod; while(n){ if(n&1) res=res*p%mod; p=p*p%mod; n>>=1; } return res; }
void print() { std::cout << std::endl; }
template <typename T, typename... A> void print(const T& first, const A&... rest) { cout << sizeof...(rest) << endl; std::cout << first; if (sizeof...(rest)) std::cout << " "; print(rest...); }
template <typename... A> void print(const A&... rest) { print(rest...); }
template <typename A> void print(const std::vector<A>& v) { std::for_each(v.begin(), v.end(), [](A x) { std::cout << x << " "; }); std::cout << std::endl; }

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  cout << (n-1)*(m-1) << endl;

  return 0;
}


Measured memory_bytes: 256
while True:
    try:
        s = input().strip()
    except:
        break
    i = 0
    cnt_joi, cnt_ioi = 0, 0
    while i < len(s) - 2:
        t = s[i:i + 3]
        if t == 'JOI':
            cnt_joi += 1
            i += 2
        elif t == 'IOI':
            cnt_ioi += 1
            i += 2
        elif t[2] == 'O':
            i += 1
        elif t[2] == 'I' or t[2] == 'J':
            i += 2
        else:
            i += 3
    print(cnt_joi)
    print(cnt_ioi)

Measured memory_bytes: 7380
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 3005;
int dp[N][N];
string s1,s2;
char s[3001],t[3001];


int main(int argc, char* argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);


    scanf("%s",s);
    scanf("%s",t);
    s1=s;
    s2=t;
    int n=s1.size();
    int m=s2.size();
    
    for(int i=0;i<=n;i++){
    	for(int j=0;j<=m;j++){
    		if(i==0||j==0)
    			dp[i][j]=0;
    		else{
    			if(s1[i-1]==s2[j-1]){
    				dp[i][j]=dp[i-1][j-1]+1;
    			}
    			else{
    				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    			}
    		}
    	}
    }


    string ans="";
    while(n!=0 && m!=0){
    	if(s1[n-1]==s2[m-1]){
    		ans = s1[n-1] + ans;
    		--n;--m;
    	}
    	else{
    		if(dp[n-1][m]>dp[n][m-1]){
    			n--;
    		}
    		else
    			m--;
    	}
    }
    cout<<ans;
    

    return 0;
}

Measured memory_bytes: 35456
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)2e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

void output(int d){
	static bool used = false;
	if(used)cout << " ";
	cout << d;
	used = true;
}

int main(){
	int n;
	cin >> n;
	vector<pii> line(n);
	rep(i, n){
		cin >> line[i].first;
		line[i].second = i+1;
	}
	sort(all(line));

	foreach(i, line){
		output(i.second);
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 1664
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))


def h_temp(h):
    return T - h * 0.006

p = [1, abs(A - h_temp(H[0]))]

for i, temp in enumerate(H, 1):
    if p[1] > abs(A - h_temp(temp)):
        p[1] = abs(A - h_temp(temp))
        p[0] = i

print(p[0])


Measured memory_bytes: 3064
N,C=map(int,input().split())

L=[]
for i in range(N):
    x,y=map(int,input().split())
    L.append([x,y])
    
l=L[::-1]
L=[[0,0]]+L
R=[]

for i in range(N):
    R.append([C-l[i][0],l[i][1]])
R=[[0,0]]+R


#print(L)
#print(R)
TS=[0]
TW=[0]
RS=[0]
RW=[0]

for i in range(N):
    TS.append(TS[i]-L[i+1][0]+L[i][0]+L[i+1][1])
    TW.append(TW[i]-2*(L[i+1][0]-L[i][0])+L[i+1][1])
    RS.append(RS[i]-R[i+1][0]+R[i][0]+R[i+1][1])
    RW.append(RW[i]-2*(R[i+1][0]-R[i][0])+R[i+1][1])
    
MTS=[0]
MRS=[0]
for i in range(1,N+1):
    MTS.append(max(MTS[i-1],TS[i]))
    MRS.append(max(MRS[i-1],RS[i]))

ans=0
for i in range(N+1):
    if i>0 and L[i-1][0]*2>C:
        break
    else:
        if ans<TW[i] + MRS[N-i]:
            ans=TW[i] + MRS[N-i]
            
for i in range(N+1):
    if i>0 and R[i-1][0]*2>C:
        break
    else:
        if ans<RW[i]+MTS[N-i]:
            ans=RW[i]+MTS[N-i]
print(ans)


Measured memory_bytes: 57568
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			final int A = s.nextInt();
			s.nextInt();
			s.nextInt();
			s.nextInt();
			final int E = s.nextInt();
			final int K = s.nextInt();

			if(E - A > K) {
				System.out.println(":(");
			} else {
				System.out.println("Yay!");
			}
		}
	}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;


template<class Monoid> struct SegmentTree{
    int N;
    vector<Monoid> tree;

    //depending on the problem
    Monoid unit;
    using FX = function<Monoid(Monoid,Monoid)>; FX func;
    //

    SegmentTree(int _N,Monoid _unit,FX _func) :N(_N),unit(_unit),func(_func) {
        tree.assign(2*N,unit);
    }

    void build(vector<Monoid> &array){
        for (int i = N; i < 2*N; i++) tree[i] = array[i - N];
        for (int i = N - 1;i > 0; i--) tree[i] = func(tree[i << 1],tree[i << 1|1]);
    }

    void update(int k,Monoid x){
        k += N;
        tree[k] = func(tree[k],x);
        while (k > 1){
            k >>= 1;
            tree[k] = func(tree[k << 1],tree[k << 1|1]);
        }
    }

    Monoid query(int L,int R){
        L += N; R += N;
        Monoid vL = unit,vR = unit;
        while (L < R){
            if (L&1){ vL = func(vL,tree[L]); L ++; }
            if (R&1){ R --; vR = func(tree[R],vR); }
            L >>= 1; R >>= 1;
        }
        return func(vL,vR);
    }

    void debug() {
        for (int i = 0;i < 2*N;++i) cout << "  st[" << i << "] : " << tree[i];
    }
};


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

    int N; cin >> N;
    vector<PL> point(N);
    rep(i,N) cin >> point[i].first >> point[i].second;
    sort(point.begin(),point.end());

    vector<ll> add(N),minus(N);
    rep(i,N) {
        add[i] = point[i].first + point[i].second;
        minus[i] = point[i].first - point[i].second;
    } 

    vector<int> compress(N);
    rep(i,N) compress[i] = point[i].second;
    sort(compress.begin(),compress.end());
    compress.erase(unique(compress.begin(),compress.end()),compress.end());
    map<ll,int> mp;
    for (ll y:compress) {
        mp[y] = lower_bound(compress.begin(),compress.end(),y) - compress.begin();
    }

    int M = compress.size();
    auto f = [&](ll a,ll b){return min(a,b);};
    SegmentTree<ll> s(M,HINF,f);
    SegmentTree<ll> t(M,HINF,f);

    ll ans = 0;
    rep(i,N) {
        ll y1 = s.query(0,mp[point[i].second]);
        ans = max(ans,add[i] - y1);
        ll y2 = t.query(mp[point[i].second],M);
        ans = max(ans,minus[i] - y2);
        s.update(mp[point[i].second],add[i]);
        t.update(mp[point[i].second],minus[i]);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 29048
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<cmath>


#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

int v[4];
string spp;

void dfs(int op, int sum, string sp)
{
    if(op == 3){
        if(sum == 7){
            spp = sp;
            return;
        }else{
            return;
        }
    }
    dfs(op+1, sum+v[op+1], sp+'+');
    dfs(op+1, sum-v[op+1], sp+'-');
}

int main()
{
    string s;
    cin >> s;
    rep(i, s.size()){
        v[i] = s[i] - '0';
    }

    int sum = 0;
    rep(i, 4){
        sum += v[i];
    }
    dfs(0, v[0], "");
    cout << s[0] << spp[0] << s[1] << spp[1] << s[2] << spp[2] << s[3] << '=' << '7';
}

Measured memory_bytes: 256
n = int(input())
arr = list(input())
head = 0
tail = n-1
count = 0
while True:
    while arr[head]=='R' and head<tail:
        head+=1
    while arr[tail]=='W' and head<tail:
        tail-=1
    if arr[head]=='W' and arr[tail]=='R':
        count+=1
    head+=1
    tail-=1
    if head>=tail:
        break
print(count)

Measured memory_bytes: 10792
m,n=map(int,input().split())
count=0
for a in range(m):
  for day in range(n):
    b=(day+1)//10
    c=(day+1)%10
    #print(b,c)
    if a+1==b*c and b>=2 and c>=2:
      count+=1
print(count)

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


int main() {
    char c[5];
    int n[4];
    char op[3];
    cin >> c;
    for (int i = 0; i < 4; i++) {
        n[i] = c[i] - '0';
    }

    for (int bit = 0; bit < (1 << 3); bit++) {
        int ANS = n[0];
        for (int i = 0; i < 3; i++) {
            if (bit & (1 << i)) {
                op[i] = '+';
                ANS += n[i + 1];
            }
            else {
                op[i] = '-';
                ANS -= n[i + 1];
            }
        }
        if (ANS == 7) {
            cout << n[0];
            for (int i = 0; i < 3; i++) {
                cout << op[i] << n[i + 1];
            }
            cout << "=7" << endl;
            return 0;
        }
    }
}


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

int main()
{
ll i,n;
cin>>n;
n=n%10;
if(n==2||n==4||n==5||n==7||n==9)
    cout<<"hon";
else if(n==3)
    cout<<"bon";
else
    cout<<"pon";
}


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

using namespace std;

int a[510][510],c[250250][4];
int h,w;


int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    cin>>h>>w;
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            cin>>a[i][j];
        }
    }
    int ans=0;
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w-1;j++)
        {
            if(a[i][j]%2==1)
            {
                c[ans][0]=i;
                c[ans][1]=j;
                c[ans][2]=i;
                c[ans][3]=j+1;
                ans++;
                a[i][j+1]++;
            }
        }
    }
    for(int i=0;i<h-1;i++)
    {
        if(a[i][w-1]%2==1)
        {
            c[ans][0]=i;
            c[ans][1]=w-1;
            c[ans][2]=i+1;
            c[ans][3]=w-1;
            ans++;
            a[i+1][w-1]++;
        }
    }
    cout<<ans<<endl;
    for(int i=0;i<ans;i++)
    {
        cout << c[i][0] + 1 << " " << c[i][1] + 1 << " " << c[i][2] + 1 << " " << c[i][3] + 1 << endl;
    }
    return 0;
}

/*
2 2
0 3
5 4
*/


Measured memory_bytes: 6592
import math
a,b,x = map(int,input().split())	
if ((a*a*b)/2) >= x:
    th=math.atan( (a*(b**2)) / (2*x))
    print(math.degrees(th))
else:
    x=(a*a*b)-x
    th=math.atan((2*x)/(a**3))
    print(math.degrees(th))




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

#define int long long
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

int fac[100010], finv[100010];

int mypow(int a, int b)
{
  if(b == 0) return 1;
  return mypow(a*a%mod, b/2)*(b%2?a:1)%mod;
}

int comb(int n, int r)
{
  if(n < r) return 0;
  return fac[n]*finv[n-r]%mod*finv[r]%mod;
}

signed main()
{
  fac[0] = 1;
  repi(i, 1, 100010) fac[i] = fac[i-1]*i%mod;
  finv[100009] = mypow(fac[100009], mod-2);
  for(int i = 100009; i > 0; i--) finv[i-1] = finv[i]*i%mod;

  int n;
  cin >> n;

  vi a(n+1), b(n+1);
  int x;
  rep(i, n+1){
    cin >> a[i];
    if(b[a[i]]) x = a[i];
    b[a[i]]++;
  }

  int left = -1, right;
  rep(i, n+1){
    if(a[i] == x){
      if(left == -1) left = i;
      else right = i;
    }
  }
  
  cout << n << endl;
  repi(i, 2, n+2){
    int tmp = comb(n+1, i)-comb(n-(right-left), i-1);
    tmp = (tmp+mod)%mod;
    cout << tmp << endl;
  }

  return 0;
}


Measured memory_bytes: 4352
from collections import Counter
MOD = 2019
S = input()
T = [0]
base = 1
for si in reversed(S):
    T += [(T[-1] + int(si) * base) % MOD]
    base = (base * 10) % MOD
ans = 0
for n, count in Counter(T).items():
    ans += count*(count-1)//2
print(ans)


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

int main()
{
    int a,b;
    cin >> a >> b;
    cout << a*b << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <bitset>
#include <stack>
#include <cstdlib>
#include <complex>
#include <unordered_map>
#define REP(i,n) for(int i = 0; n > i; i++)
#define MODU 33
#define Range(x,a,b) ((a) <= (x) && (x) <= (b))
#define POWT(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef vector<int> Ivec;
typedef pair<int, int> pii;
typedef long long int ll;

int main() {
	string str;
	cin >> str;
	int len = str.length();
	REP(i, len-1) {
		if (str[i] == 'S' && str[i + 1] == 'T') {
			len-= 2;
			str.erase(str.begin() + i);
			str.erase(str.begin() + i);
			i = (i-2) < -1 ? -1 : i-2;
		}
	}
	printf("%d\n", len);

	return 0;
}

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

#define ll long long
#define ld long double
#define pi 3.14159265359

int main(){
    int N; cin >> N;
    vector<string> s(N);
    map<string, ll> cnt;
    for (int i = 0; i < N; i++) {
        cin >> s.at(i);
        sort(s.at(i).begin(), s.at(i).end());
        if (cnt.count(s.at(i))) {
            cnt.at(s.at(i))++;
        }
        else {
            cnt[s.at(i)] = 1;
        }
    }
    ll ans = 0;
    for (auto p : cnt) {
        ans += (p.second * (p.second - 1)) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 13904
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int N; cin >> N;
  vector<int> A(N), B(N);
  rep(i, N) cin >> A[i] >> B[i];
  
  reverse(all(A));
  reverse(all(B));
  
  int ans = 0;
  rep(i, N) {
    A[i] += ans;
    if(A[i]%B[i] == 0) continue;
    ans += B[i] - A[i]%B[i];
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 4824
// B - Minesweeper
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define irp(i,s,e) for(int i=(int)(s);i>(int)(e);--i)

int main(){
	int dy[]{-1, 1, 0, 0, -1, 1, -1, 1};
	int dx[]{ 0, 0,-1, 1, -1, 1,  1,-1};
	int H,W; cin>>H>>W;
	string S[H];
	rp(i,0,H) cin>>S[i];
	vvi A(H, vi(W, -1));
	rp(h,0,H){
		rp(w,0,W){
			if(S[h][w] == '#') continue;
			A[h][w] = 0;
			rp(k,0,8){
				int y = h + dy[k], x = w + dx[k];
				if(y<0 || H<=y || x<0 || W<=x) continue;
				if(S[y][x] == '#') A[h][w]++;
			}
		}
	}

	// rp(h,0,H){
	// 	rp(w,0,W){
	// 		cout<<setw(3)<<A[h][w]<<" ";
	// 	}
	// 	puts("");
	// }
	// puts("");


	rp(h,0,H){
		rp(w,0,W){
			if(A[h][w] < 0) cout<<"#";
			else cout<<A[h][w];
		}
		puts("");
	}

}


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

struct edge{int to,cost;};
typedef pair<int,int> P;

int N,R;
vector<edge> G[MAX_N];
int t[MAX_N][MAX_N];
set<int> ans;
bool visited[MAX_N];

void dfs(int pos,int d[MAX_N]){
  if(visited[pos])return;
  visited[pos]=true;
  ans.insert(pos);
  for(int i=0;i<(int)G[pos].size();i++){
    edge e=G[pos][i];
    if(d[e.to]+e.cost==d[pos])
      dfs(e.to,d);
  }
}

void dijkstra(int S,int d[MAX_N]){
  fill(d,d+N,INF);
  d[S]=0;
  priority_queue< P ,vector<P> ,greater<P> > Q;
  Q.push(P(0,S));
  while(!Q.empty()){
    P p=Q.top();Q.pop();
    int cost=p.first;
    int pos=p.second;
    if(cost>d[pos])continue;
    for(int i=0;i<(int)G[pos].size();i++){
      edge e=G[pos][i];
      if(d[e.to]>cost+e.cost){
        d[e.to]=cost+e.cost;
        Q.push(P(d[e.to],e.to));
      }
    }
  }
}

int main(){
  cin>>N>>R;
  for(int i=0;i<R;i++){
    int a,b,c;
    cin>>a>>b>>c;
    a--,b--;
    G[a].push_back((edge){b,c});
    G[b].push_back((edge){a,c});
  }
  
  for(int i=0;i<N;i++)
    dijkstra(i,t[i]);
  
  int maxm=0;
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      maxm=max(maxm,t[i][j]);

  for(int i=0;i<N;i++){
    fill(visited,visited+N,false);
    for(int j=0;j<N;j++)
      if(t[i][j]==maxm)
        dfs(j,t[i]);
  }

  
  cout<<N-ans.size()<<endl;
  for(int i=0;i<N;i++)
    if(ans.count(i)==0)
      cout<<i+1<<endl;
  return 0;
}

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

namespace AtCoder
{
	class Program
	{
		public static void Main()
		{
			var prev = '-';
			foreach(var iChar in IO.Read())
			{
				if(iChar == prev)
				{
					IO.Write("Bad");
					return;
				}
				prev = iChar;
			}
			IO.Write("Good");
		}
	}

	public static class IO
	{
		public static string   Read()							   { return Console.ReadLine(); }
		public static string[] ReadArray(char iSplitter = ' ')	   { return Read().Split(iSplitter); }
		public static int	   ReadInt()						   { return int.Parse(Read()); }
		public static int[]	   ReadIntArray(char iSplitter = ' ')  { return ReadArray().Select(iText => int.Parse(iText)).ToArray(); }
		public static long	   ReadLong()						   { return int.Parse(Read()); }
		public static long[]   ReadLongArray(char iSplitter = ' ') { return ReadArray().Select(iText => long.Parse(iText)).ToArray(); }
		public static char[]   ReadCharArray()					   { return Read().ToCharArray(); }

		public static void Write(string iValue)			  { Console.WriteLine(iValue); }
		public static void Write(int iValue)			  { Console.WriteLine(iValue); }
		public static void Write(IEnumerable<int> iValue) { Console.WriteLine(string.Join(" " , iValue)); }
		public static void Write(long iValue)			  { Console.WriteLine(iValue); }
		public static void Write(decimal iValue)		  { Console.WriteLine(iValue); }
		public static void Write(bool iValue)			  { Console.WriteLine(iValue ? "Yes" : "No"); }
	}

	public static class Util
	{
		public static long Gcd(long i0 , long i1) { return (i0 > i1) ? _Gcd(i0 , i1) : _Gcd(i0 , i1); }
		public static long Lcm(long i0 , long i1) { return (i0 * i1) / Gcd(i0 , i1); }
		public static long ModPow(long iBaseNumber , long iPow , long iModNumber)
		{
			var num = 1L;
			while(iPow != 0)
			{
				if((iPow & 0x1) != 0)
				{
					num = (num * iBaseNumber) % iModNumber;
				}
				iBaseNumber = (iBaseNumber * iBaseNumber) % iModNumber;
				iPow >>= 1;
			}
			return num;
		}

		private static long _Gcd(long i0 , long i1)	{ return (i1 == 0) ? i0 : _Gcd(i1 , i0 % i1); }
	}
}


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

vector<long> a;

void bfs(int s){
  queue<long> q;
  for(int i=1;i<=9;i++) {
    q.push(i);
    //a.push_back(i);
  }
  long u;
  int idx=0;
  while(idx<100005){
    u = q.front();
    q.pop();
    a.push_back(u);
    long d=u%10;
    if(d==0){
      q.push(u*10);
      q.push(u*10+1);
    }
    else if(d==9){
      q.push(u*10+8);
      q.push(u*10+9);
    }
    else{
      q.push(u*10+d-1);
      q.push(u*10+d);
      q.push(u*10+d+1);
    }
    idx++;
  }

return;

}

int main() {

long K;
cin>>K;


//for(int i=0;i<N;i++) cin>>a[i];

bfs(0);

cout<<a[K-1]<<endl;
}


Measured memory_bytes: 2548
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

map<int,int> tr[2];
int N;

int main(void) {
    cin>>N;
    for(int i = 0;i < N;i++) {
        int v;
        cin>>v;
        tr[i&1][v]++;
    }
    
    int m[2][2] = {0};
    int t[2][2] = {0};
    int s = 0;
    for(int i = 0;i < 2;i++) {
        int mx = 0;
        for(auto &it:tr[i]) {
            if(m[i][0] < it.second) {
                t[i][1] = t[i][0];t[i][0] = it.first;
                m[i][1] = m[i][0];m[i][0] = it.second;
            } else if(m[i][1] < it.second) {
                t[i][1] = it.first;
                m[i][1] = it.second;
            }
        }
    }

    if(t[0][0] != t[1][0])
        cout<<N-(m[0][0]+m[1][0])<<endl;
    else
        cout<<N-max(m[0][0]+m[1][1],m[0][1]+m[1][0])<<endl;

    return 0;
}

    



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

int main(){
  int num,gate;
  int tmpSmall,tmpBig;
  int small = -1;
  int big = 9999999;
  int kekka = 0;
  
  cin >> num >> gate;
  
  for(int i = 0; i < gate; i++){
    cin >> tmpSmall >> tmpBig;
    if(small < tmpSmall) small = tmpSmall;
    if(big > tmpBig) big = tmpBig;
  }
  
  if(big - small + 1 > 0) kekka = big - small + 1;
  cout << kekka;
}


Measured memory_bytes: 256
local mmi, mma = math.min, math.max
local n, k = io.read("*n", "*n")
local t = {}
for i = 1, n do
  t[i] = io.read("*n")
end
local ret = 1000000007
for left = 1, n - k + 1 do
  local right = left + k - 1
  if 0 <= t[left] then
    ret = mmi(ret, t[right])
  elseif t[right] <= 0 then
    ret = mmi(ret, -t[left])
  else
    if -t[left] < t[right] then
      ret = mmi(ret, t[right] - 2 * t[left])
    else
      ret = mmi(ret, 2 * t[right] - t[left])
    end
  end
end
print(ret)


Measured memory_bytes: 2424
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
int MOD = 10000000;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

const int MX = 100005;

int cnt[MX];
vector<int> T[MX];

int dfs(int x, int p = -1){
	int ans = 0, a = 0;
	for(int c : T[x]){
		if( c == p ) continue;
		int t = dfs(c, x);
		if( t ) ans += t;
		else a++;
	}
	if( a >= 2 ) ans += a-1;
	return ans;
}

int main()
{
	int N, a, b;
	scanf("%d", &N);
	for(int i = 1; i < N; i++){
		scanf("%d%d", &a, &b);
		cnt[a]++; cnt[b]++;
		T[a].push_back(b);
		T[b].push_back(a);
	}
	int st = 0;
	for(int i = 1; i < N; i++) if( cnt[st] < cnt[i] ) st = i;
	printf("%d\n", max(1, dfs(st)));
}


Measured memory_bytes: 12288
#include<stdlib.h>
#define r(i,n)for(int i=0;i<n;i++)
up(int*a,int*b){return *a-*b;}
n,m,x[100002],a[100002],sum=0;
main(){scanf("%d%d",&n,&m);
r(i,m)scanf("%d",&x[i]);qsort(x,m,sizeof(int),up);
r(i,m-1)a[i]=x[i+1]-x[i];qsort(a,m-1,sizeof(int),up);
r(i,m-n)sum+=a[i];printf("%d",sum);}

Measured memory_bytes: 1396
from bisect import bisect_right


N, *A = map(int, open(0).read().split())
A = [-a for a in A]
q = []
for a in A:
    idx = bisect_right(q, a)
    if idx == len(q):
        q.append(a)
    else:
        q[idx] = a
print(len(q))


Measured memory_bytes: 19968
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    ll X = 0;
    for (int i = 2; i < N; i++) X ^= A[i];

    ll S = A[0]+A[1];
    ll T = S-X;
    if (T < 0 or (T&1)) {
        cout << -1 << ln;
        return 0;
    }
    T >>= 1;
    if ((T&X) or T > A[0]) {
        cout << -1 << ln;
        return 0;
    }
    ll ans = T;
    for (int bit = 60; bit >= 0; bit--) {
        if (X&(1LL<<bit)) {
            if (ans+(1LL<<bit) <= A[0]) ans += (1LL<<bit);
        }
    }

    cout << (ans ? A[0]-ans : -1) << ln;
}


Measured memory_bytes: 3644
import java.io.*;

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		String s="";
		int[] map;
		int i,p,n,c;
		try {
			while(s!=null){
				s=r.readLine();
				n = Integer.parseInt(s);
				map = new int[n+1];
				c=0;
				for(i=2;i<=n/2;i++){
					map[i*2]=1;
				}
				p=3;
				while(p*p<=n){
					for(i=p;i<=n/p;i+=2){
						map[i*p]=1;
					}
					p++;
					while(map[p]==1){
						p++;
					}
				}
				for(i=2;i<=n;i++){
					if(map[i]==0){
						c++;
						//System.out.println(i);
					}
				}
				System.out.println(c);
			}
		} catch (Exception err) {
			System.exit(0);
		}
	}
}

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

int main(void) {   
    int n, T;
    cin >> n >> T;
    vector<int> c(n), t(n);
    rep(i, n) cin >> c[i] >> t[i];

    int ans = 1e9;
    rep(i, n) {
        if(t[i] <= T) {
            ans = min(ans, c[i]);
        }
    }

    if(ans == 1e9) puts("TLE");
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384