akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
            #pragma comment(linker, "/stack:200000000")
            #pragma GCC optimize("unroll-loops")
             
            #include <algorithm>
            #include <bitset>
            #include <cassert>
            #include <chrono>
            #include <cmath>
            #include <complex>
            #include <cstdio>
            #include <cstdlib>
            #include <cstring>
            #include <ctime>
            #include <deque>
            #include <functional>
            #include <iomanip>
            #include <iostream>
            #include <iterator>
            #include <limits>
            #include <climits>
            #include <list>
            #include <map>
            #include <numeric>
            #include <queue>
            #include <random>
            #include <ratio>
            #include <set>
            #include <sstream>
            #include <stack>
            #include <string>
            #include <unordered_map>
            #include <unordered_set>
            #include <utility>
            #include <vector>
            using namespace std;
             
            typedef long long ll;
            typedef long double LD;
            #define int ll
            #define double LD
            #define pb push_back
            #define mp make_pair
            #define REP(i,n) for (int i = 0; i < n; i++)
            #define loop(i,n) for (int i = 0; i < n; i++)
            #define FOR(i,a,b) for (int i = a; i < b; i++)
            #define REPD(i,n) for (int i = n-1; i >= 0; i--)
            #define FORD(i,a,b) for (int i = a; i >= b; i--)
            #define remax(a,b) a = max(a,b)
            #define remin(a,b) a = min(a,b)
            #define mem(a, b) memset(a, b, sizeof a)
            #define append push_back
            #define all(v) v.begin(),v.end()
            #define F first
            #define S second
            #define print(x) cout << (x) << endl
            #define PRECISION(x) cout << fixed << setprecision(x)
            #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
            #define N 505
            #define pb push_back
            const double PI=acos(-1);
            const int MOD = 1000000007;
            const int FMOD = 998244353;
            const double eps = 1e-9;
             
            mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
            
         
           signed main()
           {
           		int n;
           		cin>>n;
           		int a[n+1];
           		
           		for(int i=2;i<=n;i++)
           		cin>>a[i];
           		map<int,int> mp1;
           		FOR(i,2,n+1)
           		{
           			mp1[a[i]]++;
				}
				FOR(i,1,n+1)
				cout<<mp1[i]<<endl;
		   }

Measured memory_bytes: 17668
#include<set>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define gt getchar()
#define ll long long
#define File(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
inline int in()
{
	int k=0;char ch=gt;bool p=1;
	while(ch<'-')ch=gt;if(ch=='-')ch=gt,p=0;
	while(ch>'-')k=k*10+ch-'0',ch=gt;
	return p?k:-k;
}
const int N=3e5+5;
int lz[N<<2];
#define lc k<<1
#define rc k<<1|1
struct node
{
	int l,r,cov;
	node(int l=0,int r=0,int cov=0):l(l),r(r),cov(cov){}
	inline bool operator<(const node &t)const{return l<t.l;}
};
typedef std::set<node>::iterator P;
std::set<node>cx;
P split(int l)
{
	P it=cx.lower_bound(l);
	if(it!=cx.end()&&it->l==l)return it;
	--it;node now=*it;cx.erase(it);
	cx.insert(node(now.l,l-1,now.cov));
	return cx.insert(node(l,now.r,now.cov)).first;
}
inline void cov(int l,int r,int x)
{
	
	if(l>r)return;P itr=split(r+1),itl=split(l);
	cx.erase(itl,itr);cx.insert(node(l,r,x));
}
ll a[N],b[N],s[N],f[N],K;
int tot,L[N],R[N],ls[N];
inline int MO(const int &x){return x>=K?x-K:x;}
inline ll query(int p)
{
	P itl=split(p);int x=itl->cov;
	return (x?f[x]+MO(ls[L[x]]-ls[p]+K):0);
}
int main()
{
	int n=in();K=in();
	for(int i=1;i<=n;++i)
	{
		s[i]=s[i-1]+(a[i]=in()),b[i]=in();
		if(b[i]==2)L[i]=0,R[i]=K-1;
		else L[i]=MO(K-s[i-1]*2%K),R[i]=MO(K-s[i]*2%K);
		if(b[i]==1&&a[i]*2>K)return puts("-1"),0;
		ls[++tot]=L[i],ls[++tot]=R[i];
	}
	std::sort(ls+1,ls+tot+1);tot=std::unique(ls+1,ls+tot+1)-ls-1;
	for(int i=1;i<=n;++i)L[i]=std::lower_bound(ls+1,ls+tot+1,L[i])-ls;
	for(int i=1;i<=n;++i)R[i]=std::lower_bound(ls+1,ls+tot+1,R[i])-ls;
	cx.insert(node(1,tot,0));
	for(int i=n;i>=1;--i)
	{
		f[i]=query(L[i]);
		if(L[i]>R[i])cov(R[i]+1,L[i]-1,i);
		else cov(1,L[i]-1,i),cov(R[i]+1,tot,i);
	}
	ll ans=f[1];
	for(int i=1;i<=tot;++i)ans=std::min(ans,query(i));
	printf("%lld\n",ans+s[n]*2);
	return 0;
}


Measured memory_bytes: 19968
#include<stdio.h>
 
int main(){
    int i, j;
    int count;
    int N;
    scanf("%d\n", &N);
 
    int A[N];
    for(i = 0; i < N; ++i)
        scanf("%d", &A[i]);
     
    count = 0;
    //selectionSort(A, N)
    for(i = 0; i < N; ++i) {
        int minj = i;
        for(j = i; j < N; ++j) {
            if(A[j] < A[minj])
                minj = j;
        }
        if(i != minj) {
            int tmp = A[i];
            A[i] = A[minj];
            A[minj] = tmp;
            count++;
        }
    }
     
    for(i = 0; i < N; ++i) {
        if(i == N-1)
            printf("%d\n", A[i]);
        else
            printf("%d ", A[i]);
    }
    printf("%d\n", count);
    return 0;
}

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll div_num(ll n){
  vl div(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      div[i]++;
    }
  }
  if(n!=1)div[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=div[i];
  }
  return num;
}
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}
long long lopow(ll a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a ;
        a = a * a ;
        n >>= 1;
    }
    return res;
}


//vc alp ={'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'};
//vc Alp ={'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'};
//cout<<""<<endl;

int main(){
  ll N;cin>>N;
  vl a(N);rep(i,N)cin>>a[i];
  ll tot=0;
  rep(i,N){
   tot ^= a[i];
  }
  
  rep(i,N){
    ll ans =tot ^a[i];
    cout<<ans<<' ';
  }
  cout<<endl;
}


Measured memory_bytes: 4688
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main()
{
	string s;
	cin >> s;

	string t;
	cin >> t;

	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	
	reverse(t.begin(), t.end());

	if (s < t) {
		cout << "Yes";
	} else {
		cout << "No";
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <unordered_map>
#include <vector>
#define task ""
using namespace std;
using ll = long long;
using ld = long double;

const int N = 1e5 + 2;
int n, a[N];

void Read(){
	n = 5;
	for(int i = 1; i <= n; ++i)
		cin >> a[i];
}

void Solve(){
	for(int i = 1; i <= n; ++i)
		if(!a[i]){
			cout << i;
			return;
		}
}

main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	Read();
	Solve();
}


Measured memory_bytes: 3532
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int n = sc.nextInt();
		int k = sc.nextInt();
    
		// 文字列の入力
		String[] sList = sc.next().split("");
        sList[k - 1] = sList[k - 1].toLowerCase();
        String ans = "";
        for (String s : sList) {
          ans += s;
        }
    
		// 出力
		System.out.println(ans);
	}
}

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

char solve(string ABC, int a, int b, int c, string next){
    if (ABC == "AB" && a == 0 && b == 0) return 'N';
    if (ABC == "BC" && b == 0 && c == 0) return 'N';
    if (ABC == "AC" && a == 0 && c == 0) return 'N';
    if (ABC == "AB" && a == 1 && b == 1 && c == 0){
        if (next == "AB") return 'A';
        if (next == "BC") return 'B';
        if (next == "AC") return 'A';
        return 'A';
    }
    if (ABC == "BC" && b == 1 && c == 1 && a == 0){
        if (next == "AB") return 'B';
        if (next == "BC") return 'B';
        if (next == "AC") return 'C';
        return 'B';
    }
    if (ABC == "AC" && a == 1 && c == 1 && b == 0){
        if (next == "AB") return 'A';
        if (next == "BC") return 'C';
        if (next == "AC") return 'C';
        return 'C';
    }
    if (ABC == "AB" && a < b) return 'A';
    if (ABC == "AB" && a >= b) return 'B';
    if (ABC == "BC" && b < c) return 'B';
    if (ABC == "BC" && b >= c) return 'C'; 
    if (ABC == "AC" && c < a) return 'C';
    if (ABC == "AC" && c >= a) return 'A';
}

void sousa(string ABC, char p, int &a, int &b, int &c){
    if (ABC == "AB"){
        if (p == 'A'){a++; b--;}
        else {a--; b++;}
    }
    if (ABC == "BC"){
        if (p == 'B'){b++; c--;}
        else {b--; c++;}
    }
    if (ABC == "AC"){
        if (p == 'A'){a++; c--;}
        else {a--; c++;}
    }
}

int main() {
    int n, a, b, c; cin >> n >> a >> b >> c;
    vector<string> ar(n);
    vector<char> an(n);
    rep(i,n) cin >> ar[i];
    ar.emplace_back("ABC");
    if (a == 0 && b == 0 && c == 0){
        cout << "No" << endl;
        return 0;
    }
    else {
        rep(i,n){
            char ans = solve(ar[i],a,b,c,ar[i+1]);
            if (ans == 'N'){
                cout << "No" << endl;
                return 0;
            }
            else {
                an[i] = ans;
                sousa(ar[i],ans,a,b,c);
            }
        }
    }
    cout << "Yes" << endl;
    rep(i,n) cout << an[i] << endl;
}

Measured memory_bytes: 9580
#include<stdio.h>
#include<algorithm>
using namespace std;
int n,l,a[111111];
int nex[111111][22];
int calc(int x,int y){
	if(nex[x][0] >= y)return 1;
	int p = 0;
	while(nex[x][p] < y)p++;
	--p;
	return (1<<p) + calc(nex[x][p],y);
}
int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; i++)
		scanf("%d",&a[i]);
	scanf("%d", &l);
	for(int i=n; i>=1; i--){
		if(i==n){
			for(int j=0; j<=17; j++)
				nex[i][j] = n;
		}else{
			nex[i][0] = upper_bound(a+1,a+n+1,a[i]+l)-a-1;
			for(int j=1; j<=17; j++){
				nex[i][j] = nex[nex[i][j-1]][j-1];
			}
		}
	}
	int q;
	for(scanf("%d",&q); q--;){
		int x,y;
		scanf("%d%d", &x, &y);
		if(x>y)swap(x,y);
		printf("%d\n",calc(x,y));
	}
	return 0;
}

Measured memory_bytes: 9728
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main()
{
    int n, m;
    cin >> n >> m;
    int nmmax = 50; //制約の最大値
    char a[nmmax][nmmax], b[nmmax][nmmax];
    rep(i, n)
    {
        rep(j, n)
        {
            cin >> a[i][j];
        }
    }
    rep(i, m)
    {
        rep(j, m)
        {
            cin >> b[i][j];
        }
    }
    bool exist = false;
    rep(i, n) //配列aを基準に全探索
    {
        rep (j, n)
        {
            if (i + m - 1 >= n or j + m - 1 >= n) //画像Aの中におけるM × Mの正方形領域は何通りあるか考えます。これは(N − M + 1) × (N − M + 1)通り。
                continue;
            bool match = true;
            for (int y = 0; y < m; ++y)
            {
                for (int x = 0; x < m; ++x)
                {
                    if (a[i + y][j + x] != b[y][x])
                        match = false;
                }
            }
            if (match)
                exist = true;
        }
    }
    if (exist)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
# author:  Taichicchi
# created: 15.09.2020 21:14:18

import sys

N, M, K = map(int, input().split())

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

a = [0]
b = [0]

for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans = 0
j = M

for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)


Measured memory_bytes: 47344
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
using namespace std;

const int INF = (int)1e7 + 10;
const int N = 4040;
int n;
vector<int> g[N];
int k;
int ans = N;
int q[N];
int topQ;
int dist[N];

void BFS()
{
	for (int k = 0; k < topQ; k++)
	{
		int v = q[k];
		for (int u : g[v])
		{
			int w = dist[v] + 2;
			if (dist[u] <= w) continue;
			dist[u] = w;
			q[topQ++] = u;
		}
	}
	return;
}

int solveVertex(int v)
{
	for (int i = 0; i < n; i++)
		dist[i] = INF;
	dist[v] = 0;
	topQ = 0;
	q[topQ++] = v;
	BFS();
	int res = 0;
	for (int i = 0; i < n; i++)
		if (dist[i] > k)
			res++;
	return res;
}
int solveEdge(int v, int u)
{
	for (int i = 0; i < n; i++)
		dist[i] = INF;
	dist[v] = dist[u] = 1;
	topQ = 0;
	q[topQ++] = v;
	q[topQ++] = u;
	BFS();
	int res = 0;
	for (int i = 0; i < n; i++)
		if (dist[i] > k)
			res++;
	return res;
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d%d", &n, &k);
	for (int i = 1; i < n; i++)
	{
		int v, u;
		scanf("%d%d", &v, &u);
		v--;u--;
		g[v].push_back(u);
		g[u].push_back(v);
	}
	for (int v = 0; v < n; v++)
		ans = min(ans, solveVertex(v));
	for (int v = 0; v < n; v++)
		for (int u : g[v])
			if (u > v)
				ans = min(ans, solveEdge(v, u));
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
const int N=1e5+5;
int cnt[N];
int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);

	int n;
	cin>>n;
	int q;
	cin>>q;
	string s;
	cin>>s;
	for(int i=0; i<s.length()-1; i++) {
		if(s[i]=='A'&&s[i+1]=='C') {
			cnt[i+1]++;
		}
	}
	for(int i=1; i<s.length(); i++) {
		cnt[i]+=cnt[i-1];
	}



	while(q--) {
		int l,r;
		cin>>l>>r;
		l--;
		r--;
		cout<<cnt[r]-cnt[l]<<endl;
	}

	return 0;
}


Measured memory_bytes: 1488
from collections import deque
N=int(input())
A=list(map(int, input().split()))

A=sorted(A, reverse=True)
if N==2:
    print(A[0])
    exit()

ans=A[0]+A[1]
que=deque([A[1], A[2],A[2]])
nowbin=1
for i in range(3,N):
    ans+=que.popleft()
    que.append(A[i])
    que.append(A[i])
    
print(ans)

Measured memory_bytes: 95352
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn=2e5+10;
char s[maxn];
int n;
int premod[maxn];
int cnt[2050];
inline int quickpow(int base,int ind)
{
	int ans=1;
	while(ind>0)
	{
		if(ind&1)ans=ans*base%2019;
		ind>>=1;
		base=base*base%2019;
		cout<<ans<<" "<<base<<" "<<ind<<endl;
	}
	cout<<ans<<endl;
	return ans;
}
int inv10[maxn];
int main()
{
	inv10[0]=1;
	inv10[1]=202;
//	cout<<inv10[1]<<endl;
	for(int i=2;i<maxn;i++)
	{
		inv10[i]=inv10[i-1]*inv10[1]%2019;
	}
	scanf("%s",s);
	n=strlen(s);
	for(int i=0;i<n;i++)
	{
		premod[i+1]=(premod[i]*10+(s[i]-'0'))%2019;
//		cout<<premod[i+1]<<endl;
	}
	ll ans=0;
	cnt[0]++;
//	cout<<(181700000%2019)<<endl;
	for(int i=1;i<=n;i++)
	{
		premod[i]=premod[i]*inv10[i]%2019;
	//	cout<<i<<" "<<premod[i]<<endl;
		ans+=cnt[premod[i]];
		cnt[premod[i]]++;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 5552
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#include <utility>
#include <numeric>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
const int MOD = 1000000007;
using namespace std;

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

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

int main() {
	int n;
	cin >> n;
	ll ans=1;
	REP(i, n) {
		ll t;
		cin >> t;
		ans = lcm(ans, t);
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

unordered_map<int,int>dp;
int dfsutil(int i,vector<int>adj[]){
	if(dp.find(i) != dp.end())
	return dp[i];
	//cout<<i<<" ";
	int ans = 0;
	for(int j=0;j<adj[i].size();j++){
		ans = max(ans,1+dfsutil(adj[i][j],adj));
	}
	dp[i] = ans;
	return ans;
}
int main(){
	int n,m;cin>>n>>m;
	vector<int>adj[n+1];
	for(int i=0;i<m;i++){
		int a,b;cin>>a>>b;
		adj[a].push_back(b);
	}
	bool visited[n+1];
	for(int i=0;i<=n;i++){
		visited[i] = false;
	}
	int ans = INT_MIN;
	for(int i=1;i<=n;i++){
		if(dp.find(i) == dp.end()){
			ans = max(ans,dfsutil(i,adj));
			//cout<<ans<<" ";
		}
		else{
			ans = max(ans,dp[i]);
		}
	}
	cout<<ans;
}


Measured memory_bytes: 11940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define F  first
#define S  second
#define int ll
#define f(i,x,n) for(ldb i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define edl "\n"
#define ceils(s,n) (s+n-1)/n
#define str string
#define add insert
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, N = 1e5 + 10;
const ll LINF = LLONG_MAX;
ll a,b,c,n,sum;
string s1,s2,s;

int32_t main() {
    fast();
    ll n;
    cin >> n;
    f(i,1,n+1){
        ldb re=1.08*i;
       
        if((int)re==(int)n){
            cout<<(int)i<<edl;
            return 0;
        }
    }
    cout<<":(";


    cerr << "\nTime taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

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

int main() {
  ll a,b,c,d;
  cin >> a >> b >> c >> d;

  ll p,q;
  p = c;
  q = d;
  ll x = p*q;
  if(p<q){
    swap(p,q);
  }

  //cout << c << d << endl;

  ll r = p % q;
  while(r != 0){
    p=q;
    q=r;
    r=p%q;
  }

  ll sai = x / q;

  ll sub = (b/c - (a-1)/c ) + (b/d - (a-1)/d ) - (b/sai - (a-1)/sai ) ;

  cout << b - a + 1 - sub << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
 
int main(){

    int n,m,k;cin>>n>>m>>k;
    vector<ll> dp1(n + 1), dp2(m + 1);
    for(int i=0;i<n;i++){
    	int a;cin>>a;
    	dp1[i + 1] = dp1[i] + a;
    }
    for(int i=0;i<m;i++){
    	int a;cin>>a;
    	dp2[i + 1] = dp2[i] + a;
    }
    int c = 0;
    for(int i=0;i<=m;i++){
    	if(dp2[i] > k){
    		break;
    	}
    	else {
    		c = i;
    	}
    }
    int ans = 0;
    for(int i=0;i<=n;i++){
    	ll sum = dp1[i];
    	while(c > -1 && sum + dp2[c] > k){
    		c--;
    	}
    	if(c != -1) {
    		ans = max(ans, c + i);
    	}
    }
    cout<<ans;

    return 0;
}

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

using namespace std;

using ll = long long;

int main(){
    ll n, m;
    cin >> n >> m;
    char matrix[n][m];
    ll ans[n][m], ans1[n][m];
    for(ll i = 0; i < n; ++i){
        for(ll j = 0; j < m; ++j){
            cin >> matrix[i][j];
        }
    }
    ll cnt;
    for(ll i = 0; i < n; ++i){
        cnt = 0;
        for(ll j = 0; j < m; ++j){
            if(matrix[i][j] == '.'){
                cnt++;
                ans[i][j] = cnt;
            }else{
                cnt = 0;
                ans[i][j] = 0;
            }
        }
        for(ll j = m - 2; j >= 0; --j){
            if(matrix[i][j] == '.' && matrix[i][j + 1] != '#'){
                ans[i][j] = ans [i][j + 1];
            }
        }
    }
     cnt = 0;
     for(ll i = 0; i < m; ++i){
        ll cnt = 0;
        for(ll j = 0; j < n; ++j){
            if(matrix[j][i] == '.'){
                cnt++;
                ans1[j][i] = cnt;
            }else{
                cnt = 0;
                ans1[j][i] = 0;
            }
        }
        for(ll j = n - 2; j >= 0; --j){
            if(matrix[j][i] == '.' && matrix[j + 1][i] != '#'){
                ans1[j][i] = ans1[j + 1][i];
            }
        }
    }
    ll maxans = 0;
    for(ll i = 0; i < n; ++i){
        for(ll j = 0; j < m; ++j){
            maxans = max(maxans, ans1[i][j] + ans[i][j]);
        }
    }
    cout << maxans - 1;
    return 0;
}


Measured memory_bytes: 66688
#include <iomanip>
#include <cmath>
#include <limits>
#include <iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 1; i < (int)(n+1); i++)


int main() {
	int N, M;
	cin >> N >> M;
	set<int> L;
	set<int> R;


	rep(i, M) {
		int Ri, Li;
		cin >> Li >> Ri;
		L.insert(Li);
		R.insert(Ri);

	}
	if (*begin(R) - *rbegin(L) + 1 < 0) {
		cout << 0 << endl;
	}
	else {
		cout << *begin(R) - *rbegin(L) + 1 << endl;
	}
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, W;
	cin >> N >> W;



	int w[100], v[100];
	rep(i, N) cin >> w[i] >> v[i];
	int w0 = w[0];

	int dp[101][101][301] = {};
	rep(i, 101) {
		rep(j, 101) {
			rep(k, 301) {
				dp[i][j][k] = -1;
			}
		}
	}

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

	rep(i, N) {
		rep(j, i + 1) {
			rep(k, 300) {
				if (dp[i][j][k] >= 0) {
					dp[i + 1][j + 1][k + w[i] - w0] = max(dp[i + 1][j + 1][k + w[i] - w0], dp[i][j][k] + v[i]);
					dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j][k]);
				}
			}
		}
	}

	int kotae = 0;
	rep(j, N + 1) {
		rep(k, 301) {
			if ((ll)j * w0 + k <= W) {
				kotae = max(kotae, dp[N][j][k]);
			}
		}
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 12288
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mkp make_pair
#define f(i,l,h) for(ll i=l;i<h;i++)
#define fr(i,h,l) for(ll i=h;i>=l;i--)

using namespace std;

typedef pair<ll,ll> pll;
const ll INF=(ll)(1e9+7);
typedef vector<ll> vll;

int main()
{
    //cout << "Hello world!" << endl;
    ll n;
    cin>>n;
    n%=10;
    if(n==2 || n==4 || n==5 || n==7 || n==9){
        cout<<"hon"<<endl;
    }else if(n==0 || n==1 || n==6 || n==8){
        cout<<"pon"<<endl;
    }else{
        cout<<"bon"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define lli long long int

using namespace std;

int main() {
    lli n;
    cin>>n;
    lli a[n];
    for(lli i=0;i<n;i++)
    {
        cin>>a[i];
    }
    lli mi=a[0],count=1;
    for(lli i=1;i<n;i++)
    {
        if(a[i]<=mi)
        {
            //cout<<mi<<endl;
            mi=a[i];
            count++;
        }
    }
    cout<<count<<endl;
    
}

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

int main()
{
    int n,k;
    cin >> n >> k;
    double p[n + 5];
    double tmp;
    double maxa = 0;
    rep(i,n){
        cin >> tmp;
        p[i] = (tmp + 1) / 2;
        if(i<k){
            maxa += p[i];
        }
    }

    double a[n + 5];
    a[0] = p[0];
    for (int i = 1; i < n; i++){
        a[i] = a[i - 1] + p[i];
        
    }



    for (int i = 0; i <n- k; i++){
        if(a[i+k]-a[i]>maxa){
            maxa = a[i + k] - a[i];
           
        }
    }

 

    cout << setprecision(12) << maxa << endl;

    return 0;
}

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

int main(void) {
    int n;
    long long ans = 0;
    vector<int> a;
    cin >> n;
    a.resize(n * 3);
    for (int i = 0; i < n * 3; i++)
        cin >> a[i];
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i++)
        ans += a[n + i * 2];
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
vector<long long> fct(0),invfct(0);

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

void invfct_input(long long maximum,long long mod){
    invfct.resize(maximum+1,-1);
    invfct.at(0) = 1;
    invfct.at(1) = 1;
    long long x = 1;
    for(long long i=2;i<=maximum;i++){
        x = x * i % mod;
        invfct.at(i) = modpow(x,mod - 2,mod);
    }
}

main(){
    ll n,a,b; cin >> n >> a >> b ;

    ll maximum = max(a,b);
    invfct_input(maximum,mod);

    ll nca = n ,ncb = n;
    for(int i=1;i<a;i++){
        nca = nca * (n-i) %mod;        
    }
    nca = nca * invfct.at(a) % mod;
    for(int i=1;i<b;i++){
        ncb = ncb * (n-i) %mod;        
    }
    ncb = ncb * invfct.at(b) % mod;

    ll x = (nca + ncb + 1)%mod;

    ll ans = (modpow(2,n,mod) - x)%mod;

    if(ans<0){
        ans += mod;
    }

    cout << ans << endl;    

}

Measured memory_bytes: 1792
from fractions import Fraction
from decimal import Decimal

def twice_num(i, limit):
    count = 0
    while i < limit:
        i *= 2
        count += 1
    return count

def main():
    n, k = map(int, input().split())

    ans = 0

    for i in range(1, n+1):
        p = Fraction(1, n)

        num = twice_num(i, k)
        if num > 0:
            p *= Fraction(1, 2**num)
        ans += p

    ans = Decimal(ans.numerator) / Decimal(ans.denominator)
    print("{:.12f}".format(ans))


main()


Measured memory_bytes: 10620
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;

typedef long long ll;
#define READ(a) int a; cin >> a;
#define READARR(a, n) int a[(n) + 1]; FOR(i, 1, (n)) {cin >> a[i];}
#define READMAT(a, n, m) int a[n + 1][m + 1]; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
#define pb(x) push_back(x)
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	READ(n);
	READARR(p, n);
	
	int status = 0;
	        FOR (k, 1, n)
	            if (p[k] != k) {status = 1; break;}
	        if (!status) {cout << "YES"; return 0;}
	
	FOR (i, 1, n)
	    FOR (j, 1, n)
	    {
	        if (i == j) continue;
	        swap(p[i], p[j]);
	        int status = 0;
	        FOR (k, 1, n)
	            if (p[k] != k) {status = 1; break;}
	        if (!status) {cout << "YES"; return 0;}
	        swap(p[i], p[j]);
	    }
	 cout << "NO";
}

Measured memory_bytes: 256
N=int(input())
AB=[list(map(int,input().split())) for _ in range(N)]
AB=sorted(AB,key=lambda x:x[1])
cnt=0
for i in range(N):
    cnt+=AB[i][0]
    if cnt>AB[i][1]:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 55260
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll n = s.length();
    ll cnt = 0,i = 0;
    while(s[i] == '>' && i < n) i++;
    cnt += i*(i+1)/2;
    s += 'a';
    ll stock = 1;
    vector<ll> a;
    rep(j,i,n){
        if (s[j] == s[j+1]) stock++;
        else{
            a.push_back(stock);
            stock = 1;
        }
    }
    n = a.size();
    if (n%2 == 1) cnt += a[n-1]*(a[n-1]+1)/2;
    rep(j,n/2){
        ll c = a[2*j],d = a[2*j+1];
        if (c > d) swap(c,d);
        c--;
        cnt += c*(c+1)/2+d*(d+1)/2;
    }
    PRINT(cnt);
}


Measured memory_bytes: 3352
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
typedef pair <string, int> P;
typedef pair <P, int> PP;

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

    int n;
    cin >> n;

    vector <PP> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec[i].first.first >> vec[i].first.second;
        vec[i].second = i + 1;
    }

    sort(vec.begin(), vec.end(), [](const PP &x, const PP &y) {
        if (x.first.first == y.first.first) {
            return x.first.second > y.first.second;
        } else {
            return x.first.first < y.first.first;
        }
    });

    for (auto p : vec) cout << p.second << '\n';
    return 0;
}

Measured memory_bytes: 256
a,b,k = map(int, input().split())

def ans(a,b,k):
    if a >= k:
        a -= k
        print(a,b)
        return
    else:
        k -= a
        a = 0
        if b >= k:
            b -= k
            print(a,b)
            return
        else:
            print(0,0)
            return

ans(a,b,k)

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

int main() {
    int A,B,C,D;
    cin >> A >> B >> C >> D;

    while(1) {
        C = C - B;
        if(C <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        A = A - D;
        if(A <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    return 0;
}

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

using namespace std;

int gcd(int x, int y){
  return x ? gcd(y%x,x) : y;
}

int main(){
  int i,n,x,y,g;
  cin >> n >> x;
  cin >> y;
  g = abs(y-x);
  for(i=1;i<n;i++){
    cin >> y;
    y = abs(y-x);
    g = gcd(g,y);
  }
  cout << g << endl;
  return 0;
}


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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)

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

    int a, b;
    cin >> a >> b;
    cout << a * b << " " << a * 2 + b * 2 << endl;    
    return 0;
}



Measured memory_bytes: 3060
using System;
class aoj
{
    static void Main()
    {
        for (;;)
        {
            string a = Console.ReadLine();
            char b = ' ';
            string[] c = a.Split(b);
            int d, e;
            d = int.Parse(c[0]);
            e = int.Parse(c[1]);
            if (d == 0 && e == 0) break;
            for (int i = 0; i < d; i++)
            {
                for (int j = 0; j < e; j++)
                {
                    Console.Write("#");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 8808
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,n,s) for(int i=s;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

int N;
int A[20];
int x[20][20];
int y[20][20];

int counter(int x) {
    if(x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

void solve() {
    cin >> N;
    for(int i = 1; i <= N; i++) {
        cin >> A[i];
        for(int j = 1; j <= A[i]; j++) {
            cin >> x[i][j] >> y[i][j];
        }
    }
    int ans = 0;
    for(int bits = 1; bits < (1 << N); bits++) {
        bool ok = true;
        for(int i = 1; i <= N; i++) {
            if(!(bits & (1 << (i-1)))) continue;
            for(int j = 1; j <= A[i]; j++) {
                if(((bits >> (x[i][j]-1)) & 1) ^ y[i][j]) ok = false;
            }
        }
        if(ok) ans = max(ans, counter(bits));
    }
    cout << ans << endl;
    return;
}

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


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

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

// Problem Specific Parameter:
const ll inf=1LL<<50;

// Description: ??°??????????????????
using edge=struct{int to;ll cost;};
using G=vector<vector<edge>>;

void add_edge(G &graph,int from,int to,ll cost){
	graph[from].push_back({to,cost});
}

// Description: ?´????????????????????????????????§???? 
// TimeComplexity: ?????????$\mathcal{O}(n)$ ??´??°$\mathcal{O}(\log n)$
// Verifyed: AOJ DSL_1_A

class Union_find{
	public:
	    Union_find(int n){par.resize(n),iota(_all(par),0);}
	    int find(int x){return (par[x]==x)?x:par[x]=find(par[x]);}
	    void unite(int a,int b){a=find(a),b=find(b);par[a]=b;}
		bool same(int a,int b){return find(a)==find(b);}
	private:
		vector<int> par;
};

// Description: ??£?????°??????????????????????°?????????¨?????¨ 
// TimeComplexity: $ \mathcal{O}(E \log V) $
// Verifyed: AOJ GRL_2_A Todo

template <typename W> W kruskal(const G &graph){
	const int n=graph.size();
	using state=tuple<W,int,int>; //(cost,from,to)
	priority_queue<state,vector<state>,greater<state>> q;
	rep(v,n)for(auto &e:graph[v]) q.push(state(e.cost,v,e.to));
	Union_find uf(n);

	W res=0;
	while(!q.empty()){
		int a,b;W c;
		tie(c,a,b)=q.top();q.pop();
		if(!uf.same(a,b)) uf.unite(a,b),res+=c;
	}
	return res;
}

int main(void){
	int n,m;
	cin >> n >> m;
	G graph(n);

	rep(i,m){
		int a,b; ll c;
		cin >> a >> b >> c;
		add_edge(graph,a,b,c);
	}

	cout << kruskal<ll>(graph) << endl;
	return 0;
}

Measured memory_bytes: 7776
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


N, T = map(int, input().split())
a = 10000
for i in range(N):
    c, t = map(int, input().split())
    if t <= T:
        a = min(a, c)
if a == 10000:
    print('TLE')
else:
    print(a)


Measured memory_bytes: 3832
#include <stdio.h>

int main(){
    int n,cnt;
    int a,b,c,d;
    while(scanf("%d",&n)!=EOF){
        cnt = 0;
        if(n<37){
            for(a=0;a<10&&a<=n;a++){
                for(b=0;b<10&&a+b<=n;b++){
                    for(c=0;c<10&&a+b+c<=n;c++){
                        d = n-a-b-c;
                        if(d<10)cnt++;
                    }
                }
            }
        }
        printf("%d\n",cnt);
    }
}

Measured memory_bytes: 1024
s = input()

if s[0] == 'A':
    index = s.find('C', 2, -1)
    s = s[:index] + s[index + 1:]
    if index > 0:
        if s[1:].islower():
            print('AC')
        else:
            print('WA')
    else:
        print('WA')
else:
    print("WA")

Measured memory_bytes: 3060
N = int(input())
L = list(map(int, input().split()))
ans = 0
for i in range(N):
  for j in range(i+1,N):
    if L[i]==L[j]:
      continue
    for k in range(j+1,N):
      if L[k]==L[i] or L[k]==L[j]:
        continue
      A = sorted([L[i],L[j],L[k]])
      if A[0]+A[1]>A[2]:
        ans += 1
print(ans)


Measured memory_bytes: 9184
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;

// to container
template <class C>
void input(C &c)
{
    for_each(c.begin(), c.end(), [](auto &i) { cin >> i; });
}

// to number, string
template <class T>
T input()
{
    T data;
    cin >> data;
    return data;
}

int main()
{
    int A, B;
    cin >> A >> B;

    if((1 <= A && A <= 9) && (1 <= B && B <= 9)){
        cout << A * B << endl;
    }
    else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int[] ary = new int[N];
		for(int i = 0; i< N; i++)
		{
			ary[i] = int.Parse(Console.ReadLine());
		}
		
		//HashSetに変換する
		System.Collections.Generic.HashSet<int> hs1 =
			new System.Collections.Generic.HashSet<int>(ary);

		Console.WriteLine(hs1.Count);
	}
}

Measured memory_bytes: 13396
function main(input) {
  const args = input.split('\n');
  const ary1 = args[0].split(' ').map(n => parseInt(n, 10));
  const ary2 = args[1].split(' ').map(n => parseInt(n, 10));
  const ary3 = args[2].split(' ').map(n => parseInt(n, 10));
  const W = ary1[0],
        H = ary1[1],
        X = ary1[2],
        Y = ary1[3];
  let ans = 'War';
  
  for (let z = (X+1); z <= Y; z++) {
    if (checkX(z) && checkY(z)) { ans = 'No War'; }
  }
  
  function checkX(z) {
    bool = true;
    for (let i = 0; i < ary2.length; i++) {
      if (ary2[i] >= z) { bool = false }
    }
    return bool;
  }
  
  function checkY(z) {
    bool = true;
    for (let i = 0; i < ary3.length; i++) {
      if (ary3[i] < z) { bool = false }
    }
    return bool;
  }
  
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 31512
#!/usr/bin/ruby
#encoding: utf-8

# 「前から調べる場合、できるだけ1下げるほうが、構成しやすい」
# (貪欲法)

n = gets.to_i
h = gets.split.map(&:to_i)

ans = false

if n == 1
  puts "Yes"
  exit
end

# できるだけ1下げる
(0..n-1).each do |i|
  if i == 0
    h[i] -= 1
  else
    if h[i-1] <= h[i]-1
      h[i] -= 1
    end
  end
end

h2 = h.sort
(0..n-1).each do |i|
  if h[i] != h2[i]
    puts "No"
    exit
  end
end

puts "Yes"


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

typedef vector<int> vec;
typedef vector<vec> mat;

int n, m, a, b, c, t;

mat mul(mat &A, mat &B){
    mat C(A.size(), vec(B[0].size()));
    for(int i = 0; i < A.size(); i++){
        for(int k = 0; k < B.size(); k++){
            for(int j = 0; j < B[0].size(); j++){
                C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % m;
            }
        }
    }
    return C;
}

mat pow(mat A, int n){
    mat B(A.size(), vec(A.size()));
    for(int i = 0; i < A.size(); i++){
        B[i][i] = 1ll;
    }
    while(n > 0){
        if(n & 1)   B = mul(B, A);
        A = mul(A, A);
        n >>= 1;
    }
    return B;
}

int main(){
    while(cin >> n >> m >> a >> b >> c >> t, n+m+a+b+c+t){
        mat A(n, vec(n, 0));
        for(int i = 0; i < n; i++){
            if(i)   A[i][i-1] = a;
            A[i][i] = b;
            if(i != n-1)    A[i][i+1] = c;
        }
        A = pow(A, t);

        mat B(n, vec(1));
        for(int i = 0; i < n; i++)  cin >> B[i][0];

        mat C = mul(A, B);

        for(int i = 0; i < n; i++)  cout << C[i][0] << " \n"[i == n-1];
    }

    return 0;
}


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

using namespace std;

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

using vll = vector<ll>;

bool calc(ll n, ll k) {
  while (n % k == 0) {
    n = n / k;
  }
  if (n % k == 1) {
    return true;
  }
  return false;
}

vector<ll> get_divisors(const ll n) {
  vector<ll> divs;

  for (ll i = 1; i < (ll)sqrt((ld)n) + 1; i++) {
    if (n % i == 0) {
      divs.push_back(i);
      if (i != n / i) {
        divs.push_back(n / i);
      }
    }
  }

  return divs;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n;
  cin >> n;

  ll ans = get_divisors(n - 1).size() - 1;

  for (auto it : get_divisors(n)) {
    if (it == 1) {
      continue;
    }
    if (calc(n, it)) {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define IOS cin.tie(NULL);iosbase::sync_with_stdio(false);
#define pb push_back
string s;

int32_t main(){
    
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout<<"Yes";
        return 0;
    }
    cout<<"No";
    

}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		List<Integer> h = new ArrayList<Integer>();
		List<Integer> good = new ArrayList<Integer>();

		for(int i = 0;i < n;i++) {
			h.add(sc.nextInt());
			good.add(1);
		}

		for(int i = 0;i < m;i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(h.get(a - 1) > h.get(b - 1)) {
				good.set(b - 1, 0);
			}else if(h.get(a - 1).intValue() == h.get(b - 1).intValue()){
				good.set(b - 1, 0);
				good.set(a - 1, 0);
			}else {
				good.set(a - 1, 0);
			}
		}

		int count = 0;
		for(int i = 0;i < n;i++) {
			if(good.get(i) == 1) {
				count++;
			}
		}

		System.out.println(count);
	}
}

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

int main() {
  int k, n;
  cin >> k >> n;
  int a[n];
  rep(i,n)
    cin >> a[i];
  int max = 0;
  rep(i,n-1){
    if (max < a[i+1]-a[i]){
      max = a[i+1]-a[i];
    }
  }
  if(max < k - (a[n-1]-a[0])){
    max = k - (a[n-1]-a[0]);
  }
  cout << k - max << endl;
  return 0;
    
}


Measured memory_bytes: 1024
#include<iostream>
#include<math.h>
#include<vector>
#include <algorithm> 

using namespace std;
typedef long long ll;

int n;
ll a[200005];

void solve(){
	int n; 
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i<n; i++){
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	ll total = 0;
	int id = 0;
	for(int i = 0; i<n-1; i++){
		total+=(ll)a[id];
		if(i%2 == 0){
		id++;
		}
	}
	
	cout << total;
}

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

Measured memory_bytes: 4032
<?php
fscanf(STDIN, "%d", $count);
$lines = [];
for ($i = 0; $i < $count; $i++) {
    $text = trim(fgets(STDIN));
    $chars = str_split((string) $text);
    sort($chars);
    $lines[] = implode('', $chars);
}

//print_r($lines);
$matches = array_count_values($lines);
//print_r($matches);
$match_count = 0;
foreach ($matches as $line => $count) {
    if ($count == 1) {
        continue;
    } elseif ($count == 2) {
        $match_count += 1;
    } else {
        $temp_count = 0;
        for ($i = ($count - 1); $i >= 0; $i--) {
            $temp_count += $i;
        }
        $match_count += $temp_count;
    }
}

echo $match_count . "\n";

Measured memory_bytes: 19188
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, K = map(int, input().split())
        h = list(map(int, input().split()))

        ans = 0
        for _h in h:
            if _h >= K:
                ans += 1
        print(ans)


# Run main
if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 49904