akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class M {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      vector<string> ans;
      if (n==1) {
        cout << 1 << endl;
        cout << 1 << endl;
      } else if (n==2) {
        cout << 2 << endl;
        cout << 1 << endl;
        cout << "00" << endl;
      } else {
        cout << n-1 << endl;
        rep(i, n-1) {
          cout << 1;
          rep(j, i) {
            cout << 0;
          }
          cout << 1 << endl;
        }
      }

    }
};

signed main() {
  M solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int n, W;
int weight[110], value[110];

int dp[110][10010];

int main() {
   cin >> n >> W;
   rep (i, n) cin >> value[i] >> weight[i];

   rep (i, W+1) dp[0][i] = 0;
   for (int i = 0; i < n; i++) {
      for (int j = 0; j <= W; j++) {
         if (j >= weight[i]) {
            dp[i+1][j] = max(dp[i][j], dp[i][j-weight[i]]+value[i]);
         } else {
            dp[i+1][j] = dp[i][j];
         }
      }
   }

   cout << dp[n][W] << endl;

   return 0;
}


Measured memory_bytes: 7032
import java.util.*;


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

        Scanner sc = new Scanner(System.in);
        int[] n = new int[5];
        
        
        for(int i = 0;i < 5;i++){
            n[i] = sc.nextInt();
        }
        
        int betwen = sc.nextInt();
        
        int max = n[0];
        int min = n[0];
        
        for(int i : n){
            if(max < i){
                max = i;
                
            }
            if(min > i){
                min = i;
            }
        }
        
        if(max - min <= betwen){
            System.out.println("Yay!");
        }else{
            System.out.println(":(");
        }
    }
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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 MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
int dh[4] = {-1, 0, 0, 1};
int dw[4] = {0, -1, 1, 0}; 
using P = pair<int, int>;
const double pi = acos(-1.0);

using Graph = vector<vector<ll>>;

int main(){
  //一番素直に考えると、2^2Nを全部ためすやり方が考えられるが、2^(2*18)=6*1e10のため余裕でオーバー
  //右n文字と左ｎ文字に分割して右側を反転して逆の色で塗り分けることでこの作業自体は2^18=262144ぐらいのオーダー
  //後はハッシュマップを作ればそれほど大きくなくても行ける
  //input
  int n;
  string s;
  cin>>n>>s;
  map<pair<string,string>,ll>mp;
  ll ans=0;
  //前半分を左から
  rep(i,1<<n){
    string red="",blue="";
    rep(j,n){
      if((i>>j)&1)red+=s[j];
      else blue+=s[j];
    }
    mp[{red,blue}]++;
  }

  //後ろ半分を反転させたものが前のやつを色が逆で同じ形になっているか
  rep(i,1<<n){
    string red="",blue="";
    rep(j,n){
      if((i>>j)&1)red+=s[n+j];
      else blue+=s[n+j];
    }
    reverse(all(red));
    reverse(all(blue));
    ans+=mp[{blue,red}];
  }
  //output
  cout<<ans<<endl;
  
    
  return 0;
}


Measured memory_bytes: 61000
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int R = sc.nextInt();
		
		if(R < 1200) {
			out.println("ABC");
		}else if(R < 2800) {
			out.println("ARC");
		}else {
			out.println("AGC");
		}
		
		sc.close();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

}


Measured memory_bytes: 21716
#include<iostream>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>
#define pb push_back
#define ff first
#define ss second
#define N 100001
using namespace std;

int n,m;
vector<int> v[N];
bool vis[N];

void dfs(int s){
    vis[s] = true;
    for(int j=0;j<v[s].size();j++){
        if(!vis[v[s][j]]){
            dfs(v[s][j]);
        }
    }
}

int main(){
    cin>>n>>m;
    int x,y,z;
    for(int i=0;i<m;i++){
        cin>>x>>y>>z;
        v[x].pb(y);
        v[y].pb(x);
    }
    memset(vis,0,sizeof(vis));
    int cc =0;
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            cc++;
            dfs(i);
        }
    }
    cout<<cc<<endl;
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  ll t;
  cin >> t;
  while (t--) {
    ll n;
    cin >> n;
    vector<ll> k(n), l(n), r(n);
    rep(i, n) {
      cin >> k[i] >> l[i] >> r[i];
      k[i]--;
    }

    ll ans = 0;
    rep(i, n) ans += min(l[i], r[i]);
    priority_queue<pair<ll, ll>> pq1, pq2;
    rep(i, n) {
      if (l[i] >= r[i]) pq1.push({l[i] - r[i], k[i]});
      else pq2.push({r[i] - l[i], k[i]});
    }
    set<ll> s1, s2;
    rep(i, n) {
      s1.insert(i);
      s2.insert(i);
    }
    while (pq1.size()) {
      pair<ll, ll> res = pq1.top();
      pq1.pop();
      s2.erase(s2.begin());
      auto it = s1.upper_bound(res.second);
      if (it == s1.begin()) continue;
      it--;
      ans += res.first;
      s1.erase(it);
    }
    while (pq2.size()) {
      pair<ll, ll> res = pq2.top();
      pq2.pop();
      auto it = s2.upper_bound(res.second);
      if (it == s2.end()) {
        s2.erase(s2.begin());
      }
      else {
        ans += res.first;
        s2.erase(it);
      }
    }
    cout << ans << '\n';
  }

  




  
  return 0;
}

Measured memory_bytes: 29864
import numpy as np

N,K = [int(i) for i in input().split()]
n = np.array([int(i) for i in input().split()])
n=np.sort(n)

mn = n[np.where(n<0)]
mz = n[np.where(n==0)]
mp = n[np.where(n>0)]

cn = len(mn)
cp = len(mp)
cz = len(mz)

if cn*cp < K <= cn*cp + (N-cz)*cz + cz*(cz-1)//2:
    print(0)
    exit(0)

M = 10**18
m = -1*M-1
pos = 0

while M-m > 1:
    a = 0
    pos=(M+m)//2
    a+=np.searchsorted(n,pos//mp,side="right").sum()
    if pos >= 0: a+=cz*N
    a+=N*len(mn) - np.searchsorted(n,-(-pos//mn),side="left").sum()
    a-=np.count_nonzero(n*n <= pos)
    a=a//2
    if a >= K:
        M=pos
    else:
        m=pos
#print(M,m)
print(M)


Measured memory_bytes: 32304
N = int(input())
H = list(map(int, input().split()))

c = 0
tmp = 0
for n in range(N-1):
    if H[n] >= H[n+1]:
        tmp += 1

    if c < tmp:
        c = tmp

    if H[n] < H[n+1]:
        tmp = 0

print(c)


Measured memory_bytes: 14224
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        int x = scan.nextInt();
        int[] a = new int[m];
        int g1 = 0;
        int g2 = 0;
        for(int i = 0; i < m; i++){
            a[i] = scan.nextInt();
            if(a[i] < x) g1++;
            else g2++;
        }
        System.out.println((int)(Math.min(g1, g2)));
        scan.close();
    }
}

Measured memory_bytes: 27176
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const int INF = 1000000001;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n;
  cin >> n;
  vector<P> a(n);
  rep(i, n){
    cin >> a[i].first;
    a[i].second = i;
  }

  sort(a.rbegin(), a.rend());

  ll dp[n+1][n+1] = {};
  for(int i = 0; i < n; ++i){   // total
    ll atv = a[i].first;
    ll pos = a[i].second;
    for(int j = 0; j <= i; ++j){ // left
      int k = i - j;  // right
      dp[j+1][k] = max(dp[j+1][k], dp[j][k] + abs(pos - j) * atv);
      dp[j][k+1] = max(dp[j][k+1], dp[j][k] + abs(n - pos - 1 - k) * atv);
    }
  }
  
  ll ans = 0;
  for(int i = 0; i <= n; ++i){
    ans = max(ans, dp[i][n-i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 34912
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	M := nextInt()
	D := nextInt()

	cnt := 0
	for d := 1; d <= D; d++ {
		d1 := d % 10
		d10 := d / 10
		if d1 < 2 || d10 < 2 {
			continue
		}
		for m := 4; m <= M; m++ {
			if d1*d10 == m {
				cnt++
			}
		}
	}

	fmt.Println(cnt)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795


int vx[]={ 0, 1, 0,-1};
int vy[]={ 1, 0,-1, 0};

bool min_u(int&m, int v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


int get_armin(vvi&f, int x, int y)
{
	int ret=999999;

	for(int d=0;d<4;d++)
	{
		int nx=x+vx[d];
		int ny=y+vy[d];
		min_u(ret, f[ny][nx]);
	}
	return ret;
}


void remove(int n, vvi&f, vvi&used, int x, int y)
{
	used[y][x]=0;
	f[y][x]=get_armin(f, x, y);

	queue<pair<int,int> > q;
	q.push(make_pair(x, y));
	while(!q.empty())
	{
//printf("x=%d y=%d\n", x, y);
		tie(x, y)=q.front();
		q.pop();
		for(int d=0;d<4;d++)
		{
			int nx=x+vx[d];
			int ny=y+vy[d];
			if(f[ny][nx]<0) continue;

			int v=get_armin(f, nx, ny);
			if(min_u(f[ny][nx], v+used[ny][nx]))
			{
				q.push(make_pair(nx, ny));
			}
		}
	}
}


int solve(int n, vvi&f, vi&p)
{
	int ret=0;
	vvi used(n+2);
	for(auto&m:used) m.assign(n+2, 1);

	for(int m:p)
	{
		int x=(m-1)%n+1;
		int y=(m-1)/n+1;

		ret+=f[y][x];
		remove(n, f, used, x, y);
	}

	return ret;
}


int main(void)
{
	int n;
	while(scanf("%d", &n)==1)
	{
		vi p(n*n);
		for(auto&mp:p) scanf("%d", &mp);

		vvi f(n+2);
		for(auto&mf:f) mf.assign(n+2, -1);

		for(int y=1;y<=n;y++)
		{
			for(int x=1;x<=n;x++)
			{
				int v=x-1;
				min_u(v, n-x);
				min_u(v, y-1);
				min_u(v, n-y);
				f[y][x]=v;
			}
		}

		printf("%d\n", solve(n, f, p));
	}
	return 0;
}


Measured memory_bytes: 5636
#include <iostream>
#include <string>
#include <map>
using namespace std;
 
int main(){
  int n,m,tmp2,sum;
  string tmp,make,fa;
  while(cin >> n,n){
    sum = 0;
    map <string,int> item;
    while(n--){
      cin >> tmp >> tmp2;
      item.insert(map<string,int>::value_type(tmp,tmp2));
    }
    cin >> m;
    while(m--){
      cin >> tmp >> tmp2;
      sum = 0;
      while(tmp2--){
    cin >> fa;
    if(item.find(fa)!=item.end()) sum += item[fa];
      }
      if(sum < item[tmp]) item[tmp] = sum;
    }
    cin >> make;
    cout << item[make] << endl;
  }
}
 

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

using namespace std;

int main()
{
    char a[55][55];
    int n,m;
    cin >> n>>m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin >> a[i][j];
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(a[i][j]=='#') continue;
            else
            {
                int sum=0;
                if(a[i+1][j+1]=='#') sum++;
                if(a[i][j+1]=='#') sum++;
                if(a[i+1][j]=='#') sum++;
                if(a[i][j-1]=='#') sum++;
                if(a[i-1][j]=='#') sum++;
                if(a[i-1][j-1]=='#') sum++;
                if(a[i-1][j+1]=='#') sum++;
                if(a[i+1][j-1]=='#') sum++;
                a[i][j]=sum+'0';
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cout <<a[i][j];
        }
        cout <<endl;
    }

}


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;

int main(void) {

	//string s1,s2,s3;
	int a=0, b = 0;
	cin >> a >> b;
	int res = 0;
	int r[5] = {};
	int temp = 0;
	for (int i = a; i <= b; i++) {
		
		temp = i;

		r[0] = temp / 10000;
		temp = temp % 10000;
		r[1] = temp / 1000;
		temp = temp % 1000;
		r[2] = temp / 100;
		temp = temp % 100;
		r[3] = temp / 10;
		temp = temp % 10;
		r[4] = temp ;
		
		//cout << r[0] << r[1] << r[2] << r[3] << r[4] << endl;



		if (r[0] == r[4] && r[1] == r[3]) {
			res++;
		}

	}


	cout << res << endl;


	


	return 0;




}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int monsterHealth, attackPower, attacksAmount, isKilled;
    scanf("%d %d",&monsterHealth, &attackPower);
    
    attacksAmount = monsterHealth / attackPower;
    isKilled = attacksAmount * attackPower >= monsterHealth;

    if (!isKilled)
    {
        attacksAmount++;
    }

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

    return 0;
}

Measured memory_bytes: 128
#![allow(unused_imports)]
#![allow(dead_code)]
use std::io::prelude::*;
use std::cmp::{max, min};
use std::collections::BinaryHeap;

const MOD: i64 = 1e9 as i64 + 7; 

fn main(){
    let s: Vec<char> = read::<String>().chars().collect();
    let mut f = true;
    let n = s.len();
    let mut ans = 1;
    let mut i = 1;
    while i < n{
        if f && s[i - 1] == s[i] {
            i += 1;
            f = false;
        }else{
            f = true;
        }
        i += 1;
        if i > n{
            break;
        }
        ans += 1;
    }
    println!("{}", ans);
}

fn read<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4476
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
#define ls k<<1,l,mid
#define rs k<<1|1,mid+1,r
#define mp(x,y) make_pair(x,y)
#define r(x) read(x)
#define rr(x,y) read(x);read(y)
#define rrr(x,y,z) read(x);read(y);read(z)
#define FOR(i,l,r) for(int i=l;i<=r;i++)
#define pb(x) push_back(x)
#define sss(str) scanf("%s",str+1)
#define ssf(x) scanf("%lf",&x)
#define aLL(x) x.begin(),x.end()
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef double dd;
typedef pair<LL,LL> pt;
const int N=2e5+5;
const int M=2e2+5;
const int INF=0x7fffffff;
const int mod=1e9+7;
const int sz=18;
const double eps=1e-10;
const double pi=acos(-1);
//***********************
int n,m;
char str[N];
int f[N];
int a[N],b[N];
map<int,pt> mm;
//***********************
template<class T>
inline void read(T &x)
{
    char c; x=1;
    while((c=getchar())<'0'||c>'9') if(c=='-') x=-1;
    T res=c-'0';
    while((c=getchar())>='0'&&c<='9') res=res*10+c-'0';
    x*=res;
}
int main()
{
    rr(n,m);
    bool flag=1;
    memset(f,-1,sizeof f);
    FOR(i,1,m){
        rr(a[i],b[i]);
        f[a[i]]=b[i];
    }
    FOR(i,1,m){
        if(f[a[i]]!=b[i]){
            flag=0;
            break;
        }
    }
    if(n!=1&&f[1]==0) flag=0;
    if(flag==0){
        cout<<-1<<endl;
    }
    else{
        bool ff=1;
        if(n==1&&f[1]==-1){
            cout<<0<<endl;
            return 0;
        }
        FOR(i,1,n){
            if(f[i]==-1){
                if(ff){
                    f[i]=1;
                }
                else f[i]=0;
            }
            cout<<f[i];
            if(f[i]) ff=0;
        }
        cout<<endl;
    }
    return 0;
}


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


def main():
    from itertools import accumulate
    import sys
    input = sys.stdin.readline

    n, k = map(int, input().split())
    mod = 10 ** 9 + 7
    a = list(accumulate([0] + [i for i in range(n + 1)]))
    ans = 0

    for j in range(k, n + 2):
        max_value = a[-1] - a[n + 1 - j]
        min_value = a[j]
        ans += (max_value - min_value) + 1
        ans %= mod

    print(ans % mod)


if __name__ == '__main__':
    main()


Measured memory_bytes: 28608
fun main(args: Array<String>) = run {
    val (h,w) = readLine()!!.split(" ").map { it.toInt() }
    val a = (1..h).map { readLine()!! }

    val x = (0..w-1).filter { j -> a.all { it[j] == '.' } }.toSet()
    val y = (0..h-1).filter { i -> a[i].all { it == '.' } }.toSet()

    for (i in 0..h-1) {
        if(i in y) continue
        for (j in 0..w-1) {
            if (j in x) continue
            print(a[i][j])
        }
        println()
    }

}


Measured memory_bytes: 40312
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

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

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    return mp;
}

void solve(){
    ll N, H, W;
    cin >> N >> H >> W;

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

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] >= H && B[i] >= W) {
            ans++;
        }
    }

    cout << ans << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


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

using namespace std;

int min(int a,int b){
    int x;
    if(a>b){
        return b;
    }
    return a;
}
void findpath(vector<vector<int>> &c){
    vector<int> U(10);  //group in path
    U[1] = 1;
    for(int i=1;i<=9;i++){
        int mindis = 10000;
        int minindex =-1;
        for(int j=0;j<=9;j++){
            if(c[j][1] <= mindis && U[j] == 0){
                mindis = c[j][1];
                minindex = j;
            }
        }
        U[minindex] = 1;
        for(int j=0;j<=9;j++){
            if(U[j]==0){
                c[j][1] = min(c[j][1],c[j][minindex]+c[minindex][1]);
            }
        }
    }
    return;
}

int main(){
    int H,W;
    cin >> H;
    cin >> W;
    vector<vector<int>> c(10,vector<int>(10));
    for(int i=0;i<=9;i++){
        for(int j=0;j<=9;j++){
            cin >> c[i][j];
        }
    }
    findpath(c); 
    int sum = 0;
    for(int i=0;i<H*W;i++){
        int Aij;
        cin >> Aij;
        if (Aij == -1) continue;
        sum += c[Aij][1];
    }
    cout <<sum <<endl;
    return 0;
}

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

int acnt[200010];
int bcnt[200010];
int main() {
	int n; cin >> n;
	int a[n]; for(int i = 0; i < n; ++i) cin >> a[i];
	int b[n]; for(int i = 0; i < n; ++i) cin >> b[i];
	for(int i = 0; i < n; ++i) {
		++acnt[a[i]];
		++bcnt[b[i]];
	}
	for(int i = 1; i <= n; ++i) {
		if(acnt[i] + bcnt[i] > n) {
			cout << "No" << '\n';
			return 0;
		}
		acnt[i] += acnt[i - 1];
		bcnt[i] += bcnt[i - 1];
	}
	int maxi = 0;
	for(int i = 1; i <= n; ++i) {
		maxi = max(maxi, acnt[i] - bcnt[i - 1]);
	}
	int ans[n];
	for(int i = 0; i < n; ++i) {
		ans[(i + maxi) % n] = b[i];
	}
	cout << "Yes" << '\n';
	for(int i = 0; i < n; ++i) {
		cout << ans[i] << (i == n - 1 ? "\n" : " ");
	}
	return 0;
}


Measured memory_bytes: 7544
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<int MOD>
struct ModInt {
	static const int Mod = MOD;
	unsigned x;
	ModInt() : x(0) {}
	ModInt(signed sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	ModInt(signed long long sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	int get() const { return (int)x; }

	ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
	ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }

	ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
	ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
	ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
	ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }

	ModInt inverse() const {
		signed a = x, b = MOD, u = 1, v = 0;
		while (b) {
			signed t = a / b;
			a -= t * b; std::swap(a, b);
			u -= t * v; std::swap(u, v);
		}
		if (u < 0) u += MOD;
		ModInt res; res.x = (unsigned)u;
		return res;
	}
};
template<int MOD>
ostream &operator << (ostream &os, const ModInt<MOD> &m) { return os << m.x; }
template<int MOD>
istream &operator >> (istream &is, ModInt<MOD> &m) { signed long long s; is >> s; m = ModInt<MOD>(s); return is; };
template<int MOD>
ModInt<MOD> pow(ModInt<MOD> a, unsigned long long k) {
	ModInt<MOD> r = 1;
	while (k) {
		if (k & 1) r *= a;
		a *= a;
		k >>= 1;
	}
	return r;
}

using mint = ModInt<1000000007>;

vector<mint> fact, factinv;
void nCr_compute_factinv(int N) {
	N = min(N, mint::Mod - 1);
	fact.resize(N + 1); factinv.resize(N + 1);
	fact[0] = 1;
	rep(i, 1, N + 1) fact[i] = fact[i - 1] * i;
	factinv[N] = fact[N].inverse();
	for (int i = N; i >= 1; i--) factinv[i - 1] = factinv[i] * i;
}
mint nCr(int n, int r) {
	if (n >= mint::Mod)
		return nCr(n % mint::Mod, r % mint::Mod) * nCr(n / mint::Mod, r / mint::Mod);
	return r > n ? 0 : fact[n] * factinv[n - r] * factinv[r];
}

mint sum(vector<int> x) {
	int n = x.size();
	mint tot = 0;
	rep(i, 0, n - 1) {
		mint t = x[i + 1] - x[i];
		int l = i + 1;
		int r = n - l;
		t *= l;
		t *= r;
		tot += t;
	}
	return tot;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m; cin >> n >> m;
	vector<int> x(n); rep(i, 0, n) {
		cin >> x[i];
	}
	vector<int> y(m); rep(i, 0, m) {
		cin >> y[i];
	}
	dump(sum(x), sum(y));
	cout << sum(x)*sum(y) << endl;
	return 0;
}

Measured memory_bytes: 1920
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

long long gcd(long long a, long long b) {
	long long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}
}

long long lcm(long long a, long long b) {
	return a * b / gcd(a, b);
}

int main() {
	string s;
	char t;
	cin >> s >> t;
	cout << "A" << t << "C" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  vector<ll> p(n);
  vector<ll> q(n);
  vector<ll> r(n);
  rep(i,n){
    cin>>p[i]>>q[i];
    r[i]=100*(i+1)*p[i]+q[i];
  }

//——————————————bit全探索——————————————
  ll ans=INF;
  rep(i, (1<<n)){
    ll sum=0;
    ll mon=0;
    vector<bool> toita(n,false);
    rep(j,n){
      if(i & (1<<j)){
      sum+=r[j];
      mon+=p[j];
      toita[j]=true;
      }
    }
    if(sum>=g) chmin(ans,mon);
    else {
      for(int j=n-1;j>=0;j--){
        if(toita[j]) continue;
        if((g-sum+((j+1)*100)-1)/((j+1)*100)>p[j]) continue;
        mon+=(g-sum+((j+1)*100)-1)/((j+1)*100);
        chmin(ans,mon);
        break;
      }
    }
  }

  cout << ans << endl;

//——————————————————————————————————————

}


Measured memory_bytes: 256
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():
    S = input()
    d = dict()
    for s in S:
        if s in d:
            d[s] += 1
        else:
            d[s] = 1

    ans = 'Yes'
    if len(d) == 2:
        for k, v in d.items():
            if v != 2:
                ans = 'No'
    else:
        ans = 'No'

    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3060
import math

#x = int(input())
#a = int(input())
#ls = list(input().split(" "))
ls = list(map(int,input().split(" ")))
#a,b = list(map(int,input().split(" ")))
#a,b,c = list(input().split())
#string = input()

k = int(input())

maxnum = max(ls)
ls.remove(maxnum)
for i in range(k):
  maxnum = maxnum * 2
print(sum(ls) + maxnum)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(x) cerr << #x << " is " << x << endl;
#define all(x) x.begin(),x.end()
const lli inf=1e18;
const int mod=1e9+7;
int prefix[300005][65];
int main(){
IOS;
lli n,i,j;
cin>>n;
lli a[n];
for(i=0;i<n;i++){
    cin>>a[i];
}
for(i=n-1;i>=0;i--){
    for(j=0;j<60;j++){
            prefix[i][j]=prefix[i+1][j];
        if(a[i]&((lli)1<<j)){
            prefix[i][j]+=1;
        }
    }
}
lli ans=0;
for(i=0;i<n-1;i++){
    for(j=0;j<60;j++){
            lli y=((lli)1<<j)%mod;
        if(a[i]&((lli)1<<j)){
            ans=(ans+(n-i-1-prefix[i+1][j])*y)%mod;
        }
        else ans=(ans+(prefix[i+1][j])*y)%mod;
    }
}
cout<<ans<<endl;
}


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

using namespace std;

vector<string> split(const string& s, char c) {
    vector<string> v; stringstream ss(s); string x;
    while (getline(ss, x, c)) v.emplace_back(x); return move(v);
}
template<typename T, typename... Args>
inline string arrStr(T arr, int n) {
    stringstream s; s << "[";
    for(int i = 0; i < n - 1; i++) s << arr[i] << ",";
    s << arr[n - 1] << "]";
    return s.str();
}

#define ANTHRO(args...) {__anthro_begin(__LINE__); __anthro(split(#args, ',').begin(), args);}

inline void __anthro_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __anthro_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __anthro_out_var(T* val) { cerr << arrStr(val,2); } //Change the values in case you want to debug something
template<typename T> inline void __anthro_out_var(T val) { cerr << val; }
inline void __anthro(vector<string>::iterator it) { cerr << endl; }

template<typename T, typename... Args>
inline void __anthro(vector<string>::iterator it, T a, Args... args) {
    cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
    __anthro_out_var(a);
    cerr << "; ";
    __anthro(++it, args...);
}
//Simple Debugger

#define ll long long
#define MOD 1000000007
#define EPS 1e-9
int const INF = (int)1e9 + 1e3;
ll const INFL = (ll)1e18 + 1e6;
/*
    This is A. Beginner
    ABC 156
*/

int main(){
    ll n,r; cin>>n>>r;
    if(n<10){
        cout<<r+(100*(10-n));
    }
    else{
        cout<<r;
    }
    return 0;
}


Measured memory_bytes: 256
import itertools

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

for _ in range(K):
    B = [0] * N
    for i in range(N):
        l = max(0, i-A[i])
        r = min(N-1, i+A[i])
        B[l] += 1
        if r+1 < N:
            B[r+1] -= 1
    B = list(itertools.accumulate(B))
    A = B.copy()
    if A == [N] * N:
        break
print(*A)

Measured memory_bytes: 183104
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
int dp[1 << 26];
int main()
{
	string s;
	cin >> s;
	int now = 0;
	fill(dp, dp + (1 << 26), 1000000000);
	dp[0] = 0;
	for (int i = 0; i < s.size(); i++)
	{
		now ^= (1 << (s[i] - 'a'));
		for (int j = 0; j < 26; j++)dp[now] = min(dp[now], dp[now ^ (1 << j)] + 1);
	}
	printf("%d\n", max(1, dp[now]));
}

Measured memory_bytes: 262788
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;

signed main() {
	int n; cin >> n;
	vector<int>v(100010, 1);
	rep(i, 0, n) {
		int a, b; cin >> a >> b;
		for (int i = a; i <= b; i++)v[i]++;
	}
	int ans(0);
	rep(i, 0, v.size()) {
		if (v[i] >= i)ans = max(ans, i);
	}
	cout << ans - 1 << endl;
	return 0;
}

Measured memory_bytes: 3088
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include<list>
#include<map>
#include<utility>
#include<tuple>
#include<numeric>
#include<set>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),a.end()
using namespace std;

int main()
{
	int a, b, x;
	cin >> a >> b >> x;
	if (a <= x && x <= a + b)cout << "YES" << endl;
	else cout << "NO" << endl;

}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

long long l, r;

int main()
{
	scanf("%lld%lld", &l, &r);
	
	long long dist = r - l + 1;
	if (dist >= 2019)
	{
		printf("0\n");
		return 0;
	}
	
	long long minMod = 2020;
	long long curDist;
	for (long long i = l ; i <= r ; i++)
		for (long long j = i + 1 ; j <= r ; j++)
		{
			curDist = i * j % 2019;
			if (minMod > curDist)
				minMod = curDist;
		}
		
	printf("%lld\n", minMod);
	
	return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;

const int N = 8005;
int dp[N][2 * N];
int a[N], b[N];
int n;

void foo(int k, int x, int wh) {
    if(k == n) {
        dp[k][x] = k;
        return;
    }
    if(dp[k][x]) return;
    dp[k][x] = true;

    if(wh == 0) {
        if(a[k]) {
            foo(k + 1, x - a[k], wh);
            foo(k + 1, x + a[k], wh);
        }
        else foo(k + 1, x, wh);
    }

    else {
        if(b[k] ) {
            foo(k + 1, x - b[k], wh);
            foo(k + 1, x + b[k], wh);
        }
        else foo(k + 1, x, wh);
    }
}

bool reachable(int cur, int target, int wh) {
    memset(dp, 0, sizeof dp);
    foo(0, cur + 8002, wh);
    return dp[n][target + 8002] == n;
}


int main() {
    string s;
    int tx, ty;
    cin >> s >> tx >> ty;
    n = s.size();

    int f = 1;
    int dir = 0, x = 0, y = 0;

    int p = 0, q = 0;
    for (int i = 0; i < n; ++i) {
        if(s[i] == 'F') {
            if(f) x++;
            else {
                if(dir == 0) a[p]++;
                else b[q]++;
            }
        }
        else {
            f = 0;
            dir = 1 - dir;
            p++, q++;
        }
    }


    if(reachable(x, tx, 0) and reachable(0, ty, 1)) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 501120
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		try (Scanner sc = new Scanner(System.in);) {
			
			String str = sc.next();
			int q = sc.nextInt();
			
			StringBuilder sb = new StringBuilder();
			String transform = str;
			
			for(int i = 0; i < q; i++) {
				String command = sc.next();
				int a = sc.nextInt();
				int b = sc.nextInt();
				
				switch(command) {
				case "print":
					sb.append(transform.substring(a, b + 1));
					sb.append("\n");
					break;
				case "reverse":
					transform = transform.substring(0, a)
						+ new StringBuilder(transform.substring(a, b + 1)).reverse().toString()
						+ transform.substring(b + 1);
					break;
				case "replace":
					String p = sc.next();
					transform = transform.substring(0, a) + p + transform.substring(b + 1);
				}
			}

			System.out.print(sb.toString());
		}
	}
}


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


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	
 	string a[3];
 	int turn = 0, id[3] = {};

 	cin >> a[0] >> a[1] >> a[2];
 	while (id[0] <= a[0].size() && id[1] <= a[1].size() && id[2] <= a[2].size()) {
 		if (id[turn] == a[turn].size()) {
 			cout << (char) ('A' + turn) << '\n';
 			return 0;
 		}

 		int tmp = turn;
 		turn = a[turn][id[turn]] - 'a';
 		id[tmp]++;
 	}

	return 0;
}

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

int main() {
    int n, l;
    cin >> n >> l;
    vector<string> s(n);

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

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

    string ans = {};
    for(i = 0; i < n; i++) {
        ans += s[i];
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
//#define TIMER_
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;

int main() {
  fastio;
  char a;
  cin >> a;
  cout << (char)(a + 1) << endl;
  
  #ifdef TIMER_
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
  #endif
}


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

const ll INF = 1e+18;

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

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

    // 高くする数
    ll ans = INF;
    for (ll S = 0; S < (1 << N); S++)
    {
        ll inc = 0;
        ll max_h = 0;
        int k = 0;
        for (int i = 0; i < N; i++)
        {
            // どの家を高くするか
            if (S & (1 << i))
            {
                // max_hよりも大きくする。
                if (max_h >= a[i])
                {
                    inc += (max_h - a[i]) + 1;
                    max_h++;
                }
                else
                {
                    max_h = a[i];
                }

                k++;
            }
            else
            {
                // 高くするビルに該当しない場合はそのままの高さを評価
                if (max_h < a[i])
                {
                    k++;
                    max_h = a[i];
                }
            }

            if (K == k)
            {
                break;
            }
        }
        if (K > k)
        {
            continue;
        }
        ans = min(ans, inc);
    }

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

Measured memory_bytes: 256
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,m = INTM()
    print((n-1)*(m-1))
if __name__ == '__main__':
    do()

Measured memory_bytes: 3060
<?php
fscanf(STDIN, "%d", $n);
$a = explode(' ', trim(fgets(STDIN)));
$g = gcd($a[0], $a[1]);
$q[$a[0]] = $q[$a[1]] = 1;
for ($i = 2; $i < $n; $i++) {
	$t = [];
	foreach ($q as $r => $v) {
		$b = gcd($a[$i], $r);
		$t[$b] = 1;
	}
	$q = $t;
	$q[$g] = 1;
	$g = gcd($g, $a[$i]);
}
echo max(array_keys($q));

function gcd($n, $m) {
	return $n % $m ? gcd($m, $n % $m) : $m;
}

Measured memory_bytes: 14840
n,k = map(int,input().split())
al = list(map(int,input().split()))

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

for i in range(k+1):
    for a in al:
        if a <= i:
            if dp[i-a] == 0:
                dp[i] = 1


if dp[-1] % 2 == 0:
    print("Second")
else:
    print("First")



Measured memory_bytes: 44784
#include<stdio.h>
int main()
{
long long int n,T,i,ans;
  scanf("%lld %lld",&n,&T);

  ans=n*T;

  long long int t[n];
  scanf("%lld",&t[0]);
  for(i=1;i<n;++i)
  {
  scanf("%lld",&t[i]);
  if(t[i]-t[i-1]<T) ans=ans-T+t[i]-t[i-1];
  }
  
  printf("%lld",ans);

return 0;
}

Measured memory_bytes: 3272
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    int c,x;
    cin>>a>>b;
    c=b*2;
    x=a-c;
    if(x>=0)
    {
        cout<<x;
    }
    else
        cout<<0;


  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
h = [int(x) for x in input().split()]

chk = [True]*n

for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] > h[b-1]:
        chk[b-1] = False
    elif h[a-1] < h[b-1]:
        chk[a-1] = False
    else:
        chk[a-1] = False
        chk[b-1] = False

print(chk.count(True))

Measured memory_bytes: 86356
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)
#define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it)
#define MP make_pair
typedef long long LL;
#define EPS (1e-6)
double zero(double d){
  return d < EPS ? 0.0 : d;
}

typedef pair<int,int> P;


int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(7);
  int INF = 1000000;

  int N;
  while(cin>>N){

    int sq_num = (int)sqrt((double)N);
    bool prime[N+1];

    for(int i = 0; i < N+1; i++)
      prime[i] = true;
    prime[0] = false;
    prime[1] = false;

    for (int i = 1; i <= sq_num; i++) {
      if (prime[i] == true)
	for (int j = 2; i*j <= N; j++)
	  prime[i*j] = false;
    }


    int res=0;
    for(int i=1; i< N+1; i++){
      if( prime[i] && prime[N+1-i] )
	res++;
    }
    cout << res << endl;
  }

  return 0;
}

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

int main(){
	map<string,int> m;
	string s;
	while(cin >> s){
		m[s]++;
	}
	int max_word = 0;
	string ans1;
	/*出現頻度が最大*/
	for(map<string,int>::iterator it = m.begin(); it != m.end(); ++it){
		if(it->second > max_word){
			ans1 = it->first;
			max_word = it->second;
		}
	}

	int max_length = 0;
	string ans2;
	/*文字数が最大*/
	for(map<string,int>::iterator it = m.begin(); it != m.end(); ++it){
		if(it->first.size() > max_length){
			ans2 = it->first;
			max_length = it->first.size();
		}
	}

	cout << ans1 << " " << ans2 << endl;
}

Measured memory_bytes: 1196
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n = I()
    A = LI()
    cnt = 0
    for a in A:
        while a%2 == 0:
            cnt += 1
            a //= 2
    print(cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 10032
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,n,f[100000],h[100000];
    cin>>n;
    for(i=0;i<n;i++)
        cin>>h[i];
  	f[0] = 0;
    f[1] = abs(h[0]-h[1]);
    f[2] = min(abs(h[0]-h[2]),f[1]+abs(h[1]-h[2]));
    for(i=3;i<n;i++)
        f[i] = min(f[i-1]+abs(h[i]-h[i-1]),f[i-2]+abs(h[i]-h[i-2]));
    cout<<f[n-1];
    return 0;
}

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

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

	int k = 0;
	for (int i = 0; i < n; ++i) {
		int d1, d2;
		cin >> d1 >> d2;

		if (d1 == d2) {
			++k;
		} else {
			k = 0;
		}

		if (k == 3) {
			break;
		}
	}

	if (k == 3) {
		cout << "Yes";
	} else {
		cout << "No";
	}
	
	return 0;
}


Measured memory_bytes: 3632
use whiteread::parse_line;

fn main() {
    let (a, b, k): (u32, u32, u32) = parse_line().unwrap();
    let mid: f64 = (a + b) as f64 / 2.0;

    for i in 0..k {
        if (a + i) as f64 <= mid {
            println!("{}", a + i);
        }
    }
    for i in (0..k).rev() {
        if i <= b && (b - i) as f64 > mid {
            println!("{}", b - i);
        }
    }
}


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

#define PI acos(-1.0)
#define INF 1e18
#define inf 0x3f3f3f3f
#define FAST_IO ios::sync_with_stdio(false)

const int N=1e5+10;
typedef long long LL;

int n,m;
int dis[N];
bool vis[N];
vector < pair<int,int> > E[N];

bool dfs(int u){
    vis[u]=1;
    for(auto p : E[u]){
        int v=p.first;
        int d=p.second;
        if(!vis[v]){
            dis[v]=dis[u]+d;
            if(!dfs(v)) return false;
        }
        else if((dis[u]+d)!=dis[v]) return false;
    }
    return true;
}

int main(){
    FAST_IO;
    cin>>n>>m;
    int u,v,w;
    for(int i=1;i<=m;i++){
        cin>>u>>v>>w;
        E[u].push_back(make_pair(v,w));
        E[v].push_back(make_pair(u,-w));
    }
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            //dis[i]=0;
            if(!dfs(i)) {cout<<"No"<<endl;return 0;}
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 11136
#include<stdio.h>
int main()
{
  int n,i,count,j,ans,max=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++)
  {
    count=0;
    j=i;
    while(j%2==0)
    {
      j=j/2;
      count++;
    }
    if(count>=max)
    {
      max=count;
      ans=i;
    }
  }
  printf("%d",ans);
  
  return 0;
}

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

int main() {
 
  int k;
  cin >> k;
  
  string s;
  cin >> s;
  
  if (s.size() <= k) cout << s << endl;
  else {
    for (int i = 0; i < k; i++) {
      cout << s[i];
    }
    cout << "..." << endl;
  }
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010

ll X, Y;

int main()
{
    cin >> X >> Y;
    ll ans = 0;
    while(X <= Y) {
        ans++;
        X *= 2;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256