akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int M = sc.nextInt();
		int C = sc.nextInt();
		int[] B = new int[M];
		
		for (int i = 0; i < M; i++) {
			B[i] = sc.nextInt();
		}
		
		int ans = 0;
		for (int i = 0; i < N; i++) {
			int sum = C;
			for (int j = 0; j < M; j++) {
				sum += B[j]*sc.nextInt();
			}
			if (sum > 0)
				ans++;
		}
		System.out.println(ans);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 22996
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (200001)
#define MOD (1000000007)

ll w[MAXN];

int main(void)
{
    ll n;
    scanf("%ld",&n);
    for(int i=0;i<n;i++) scanf("%ld",&w[i]);

    ll ans = INT64_MAX;
    for(int t=0;t<n-1;t++)
    {
        ll s1 =0;
        for(int i=0;i<=t;i++) s1 += w[i];
        ll s2 = 0;
        for(int i=t+1;i<n;i++) s2 += w[i];
        ans = min(ans,abs(s2-s1));

    }

    printf("%ld\n", ans);
    return 0;
}


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

int main () {
  string s, t; cin >> s >> t;
  map<char,int> ms, mt;
  int idx = 1;
  vector<int> ss(s.size()), ts(s.size());
  for (int i = 0; i < s.size(); ++i) {
    if (ms.count(s[i]) == 0) {
      ms[s[i]] = idx++;
    }
    ss[i] = ms[s[i]];
  }
  idx = 1;
  for (int i = 0; i < s.size(); ++i) {
    if (mt.count(t[i]) == 0) {
      mt[t[i]] = idx++;
    }
    ts[i] = mt[t[i]];
  }
  
  bool ok = 1;
  for (int i = 0; i < s.size(); ++i) {
    if (ss[i] != ts[i]) ok = 0;
  }
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 2312
#include <iostream>
    #include <string>
    #include <set>  
    #include <algorithm>
    #include <vector>
    #include <cmath>
    #include <queue>
    #include <deque>
    #include <cstring>
    #include <cstdio>
    #include <map>
    #include <numeric>
    #include <cassert>
    #include <iomanip>
    #include <sstream>
using namespace std;
typedef long long LL;
const int MAXN=2002;
const int MAXM=MAXN*MAXN;
const LL M=1e9+7;
LL fac[MAXM],inv[MAXM],f[MAXN][MAXN];
int N,K;
LL C(int x,int y)
{
	if(x<y)return 0;
	return fac[x]*inv[y]%M*inv[x-y]%M;
}
int main()
{
	scanf("%d %d",&N,&K);
	if(K==1)
	{
		puts("1");
		return 0;
	}
	fac[0]=inv[0]=inv[1]=1LL;
	for(int i=1;i<MAXM;i++)
		fac[i]=1LL*fac[i-1]*i%M;
	for(int i=2;i<MAXM;i++)
		inv[i]=1LL*(M-M/i)*inv[M%i]%M;
	for(int i=1;i<MAXM;i++)
		inv[i]=inv[i-1]*inv[i]%M;
	f[0][0]=1;
	for(int i=1;i<=N;i++)
		for(int j=i;~j;j--)
		{
			f[i][j]=f[i][j+1];
			if(j)f[i][j]+=f[i-1][j-1]*C(i*K-j-1,K-2)%M;
			f[i][j]%=M;
		}
	printf("%lld\n",f[N][0]*fac[N]%M);
	return 0;
}

Measured memory_bytes: 92672
n = int(input())

s = list(input())

res = 0
for i in range(1, n):
    temp = 0
    a = set(s[:i])
    b = set(s[i:])
    for j in a:
        if j in b:
            temp += 1
    if temp > res:
        res = temp

print(res)

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

int main(){
	
	long long s,n, i;
	long long last,sum;
	
	while(cin>>n){
		
		last=0;sum=0;
		for(i=0;i<n;i++){
			cin>>s;
			
			if(s){
				sum+=(s+last)/2;
				last=(s+last)%2;	
			}else if(s==0){
				last=0;
			}
		}
		cout<<sum<<endl;		
	}
	
	
	return 0;
}

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

x = 0 
y = 0

if a < 0 and b < 0:
  if c < 0 and d < 0:
    x = a
    y = c
  elif c < 0 and d >= 0:
    x = a
    y = c
  elif c >= 0 and d >= 0:
    x = b
    y = c

if a < 0 and b >= 0:
  if c < 0 and d < 0:
    x = a
    y = c
  elif c < 0 and d >= 0:
    if a * c >= b * d:
      x = a
      y = c
    else:
      x = b
      y = d
  elif c >= 0 and d >= 0:
    x = b
    y = d
    
if a >= 0 and b >= 0:
  if c < 0 and d < 0:
    x = a
    y = d
  elif c < 0 and d >= 0:
    x = b
    y = d
  elif c >= 0 and d >= 0:
    x = b
    y = d  
  
  
print(x * y)

Measured memory_bytes: 9252
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#define FOR(i,a,n) for (int i = a; i < n; i++)
#define IFOR(i,n,a) for (int i = n; i >= a; i--)
#define mp make_pair
#define full(a) a.begin(), a.end()
#define SZ(x) ((int)(x).size())
#define TC(tc) while (tc--)
#define VI vector<int>
#define PII pair<int, int>
#define trav(a,x) for (auto& a : x)
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
using namespace std;
const int mod = 1e9 + 7;


int main()
{
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int r, c, k; cin >> r >> c >> k;
	vector<vector<char>> v(r, vector<char>(c));
	trav(i, v) trav(j, i) cin >> j;
	int cnt = 0;
	FOR(i, 0, (1 << r))
	{
		FOR(j, 0, (1 << c))
		{
			vector<vector<char>> tmp = v;
			int cur = 0;
			FOR(t, 0, r) if (i & (1 << t)) FOR(y, 0, c) tmp[t][y] = '$';
			FOR(t, 0, c) if (j & (1 << t)) FOR(y, 0, r) tmp[y][t] = '$';
			FOR(i, 0, r) FOR(j, 0, c) if (tmp[i][j] == '#') cur++;
			if (cur == k) cnt++;
		}
	}
	cout << cnt;
	return 0;
}

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

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

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

    int h, w;
    cin >> h >> w;
    
    queue<P> q;
    
    char C[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> C[i][j];
            if(C[i][j] == '#'){
                q.push({{i, j}, 1});
            }
        }
    }

    int ans = 0;
    while(!q.empty()){
        P p = q.front();
        q.pop();
        int x = p.first.first;
        int y = p.first.second;
        int c = p.second;

        for(int i = 0; i < 4; i++){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(nx < 0 or ny < 0 or nx >= h or ny >= w){
                continue;
            }
            if(C[nx][ny] == '#'){
                continue;
            }
            C[nx][ny] = '#';
            q.push({{nx, ny}, c + 1});
            ans = max(ans, c);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 13328
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  string s,t,u;
  cin>>s>>t;
  cin>>a>>b;
  cin>>u;
  if(u==s){
    a--;
  cout<<a<<" "<<b<<endl;
  }
  else
  {
    b--;
  cout<<a<<" "<<b<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
using ll = long long;

ll d3[31];

ll mh(ll a, ll b, ll c, ll d) {
	return abs(a - c) + abs(b - d);
}

int main() {
	d3[0] = 1;
	for (int i = 1;i < 31;i++) {
		d3[i] = d3[i - 1] * 3;
	}
	ll Q, a, b, c, d, A, B, C, D, ans;
	cin >> Q;

	for (int i = 0;i < Q;i++) {
		cin >> a >> b >> c >> d;
		a--;b--;c--;d--;
		ans = -1;
		if (abs(a - c) < abs(b - d)) {
			swap(a, b);
			swap(c, d);
		}
		if (a > c) {
			swap(a, c);
			swap(b, d);
		}
		if (b > d) {
			b = d3[30] - 1LL - b;
			d = d3[30] - 1LL - d;
		}
			
		//cout << a << " " << b << " " << c << " " << d << endl;
		for (int j = 29;j >= 0;j--) {
			A = a / d3[j] * d3[j] + d3[j];
			B = b / d3[j] * d3[j];
			//cout << A << " " << B << endl;

			if ((B / d3[j]) % 3 == 1) {
				if ((A / d3[j]) % 3 == 0) {
					A += d3[j];
				}
				else if ((A / d3[j]) % 3 == 2) {
					A += d3[j] * 2;
				}

				if (d < B + d3[j] && A + d3[j] <= c) {
					ans = min(
						mh(a, b, A - 1, B - 1) + mh(A - 1, B - 1, A + d3[j], B - 1) + mh(A + d3[j], B - 1, c, d),
						mh(a, b, A - 1, B + d3[j]) + mh(A - 1, B + d3[j], A + d3[j], B + d3[j]) + mh(A + d3[j], B + d3[j], c, d));
					cout << ans << endl;
					break;
				}
			}
		}
		if (ans < 0) {
			cout << mh(a, b, c, d) << endl;
		}
	}
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN=100005;
int n,p=1;
int main()
{
  cin>>n;
  long long ans=0;
  for(int i=1;i<=n;++i){
    int x;   
    scanf("%d",&x);
    if(x<p)continue;
    if(x==p)++p;
    else{
      if(x%p==0)ans+=x/p-1;
      else ans+=x/p;
    }
    if(p==1)++p;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
fn solve() {
    let s: Vec<char> = read::<String>().chars().collect();
    let mut gnum = 0;
    let mut pnum = 0;
    for i in 0..s.len() {
        if s[i] == 'g' {
            gnum += 1;
        } else {
            pnum += 1;
        }
    }
    println!("{}", (gnum - pnum) / 2);
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

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

// =========


Measured memory_bytes: 2396
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>=0;++i)

using namespace std;

int main() {
	string a; cin >> a;
	if ((a[0]==a[1]&&a[0]==a[2])||(a[1]==a[2]&&a[3]==a[2])) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b  && b == c) cout << "No" << endl;
	else if (a == b || a == c || b == c) cout << "Yes" << endl;
	else cout << "No" << endl;  
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;

struct food{
  ll time;
  ll value;
};

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

  ll N, T;
  cin >> N >> T;

  vector<food> F(N);
  REP(i,N){
    ll ai, bi;
    cin >> ai >> bi;
    food fi = {ai, bi};
    F[i] = fi;
  }

  sort(F.begin(), F.end(), [](auto const& l, auto const& r){
    if (l.time == r.time){
      return l.value > r.value;
    } else {
      return l.time < r.time;
    }
  });

  ll ans = 0;
  // eat maximum foot until T-1
  vector<vector<ll>> dp(N+1, vector<ll>(T+F[N-1].time,0));
  REP3(i,0,N){
    food f = F[i];
    REP(t,T+F[N-1].time){
      dp[i+1][t] = max(dp[i+1][t], dp[i][t]);
      if (t<T){
        dp[i+1][t+f.time] = max(dp[i+1][t+f.time], dp[i][t]+f.value);
      }
    }
  }
  ans = *max_element(dp[N].begin(), dp[N].end());
  cout << ans << "\n";
  return 0;
}


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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int cnt = 0;
  for (char c : S) {
    if (c == '(') cnt++;
    else if (cnt > 0) cnt--;
    else cout << '(';
  } 
  cout << S;
  while (cnt--) cout << ')';
  cout << "\n";
}

Measured memory_bytes: 256
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;

    int main(){
      ll n,m;
      cin>>n>>m;
      ll ans;
      if(n == 1 && m == 1)ans = 1;
      else if(n == 1 || m == 1)ans = m*n-2;
      else ans = (m-2)*(n-2);
      cout<<ans<<endl;
    }


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

ll Par[100000],Size[100000];

void init(int n)
{
	for(int i = 0;i<n;++i)
	{
		Par[i] = i;
		Size[i] = 1;
	}
}

ll find(ll x)
{
	if(Par[x]==x)return x;
	return Par[x] = find(Par[x]);
}

void unite(ll x,ll y)
{
	x = find(x);
	y = find(y);
	if(x==y)return;
	Par[y] = x;
	Size[x] += Size[y];
}

ll size(ll x)
{
	return Size[find(x)];
}


int main()
{
	ll n,m;
	cin >> n >> m;
	vector<pair<ll,ll>> vp(m);
	for(ll i = 0;i<m;i++)
	{
		int a,b;
		cin >> a >> b; 
		a--;b--;
		vp[i]=make_pair(a,b);
	}
	reverse(vp.begin(),vp.end());
	ll ans = n*(n-1)/2;
	init(n);
	vector<ll> anss;
	for(ll i = 0 ;i<m;i++)
	{
		anss.push_back(ans);
		if(find(vp[i].first)!=find(vp[i].second))
		ans -= size(vp[i].first)*size(vp[i].second);
		unite(vp[i].first,vp[i].second);
	}
	reverse(anss.begin(),anss.end());
	for(int i = 0;i<m;i++)cout<<anss[i]<<endl;
	return 0;
}

Measured memory_bytes: 5364
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
    vector <string> weather = {"Sunny", "Cloudy", "Rainy"};
    string today;
    cin >> today;
    ll ni;
    REP(i, weather.size()) {
        if (weather.at(i) == today) {
            ni = (i+1 < weather.size()? i+1 : 0);
            break;
        }
    }
    cout << weather.at(ni) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h_1,m_1,h_2,m_2,k;
  cin>>h_1>>m_1>>h_2>>m_2>>k;
  //分数計算
  int time;
  time = (h_2-h_1)*60+(m_2-m_1);
  cout<<time-k<<endl;
  
  

}

Measured memory_bytes: 3616
#include <iostream>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	int m;
	cin >> m;
	cout << 24-m+24 << endl;
}

Measured memory_bytes: 256
l,r=map(int,input().split())
x=l//2019
y=l%2019
z=r//2019
w=r%2019
if x<z:
    print(0)
else:
    if y==0:
        print(0)
    else:
        ans=2020
        for i in range(y,w):
            for j in range(i+1,w+1):
                ans=min(ans,(i*j)%2019)
        print(ans)


Measured memory_bytes: 64560
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

int main() {
    ll n;
    cin >> n;
    ll a[5];
    for (auto &e: a) cin >> e;

    int mi = min_element(a, a + 5) - a;
    ll ans = n / a[mi];
    if (n % a[mi] > 0) ans += 1;
    ans += 4;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final int m = scanner.nextInt();
        final int q = scanner.nextInt();

        final int[][] table = new int[n][n];

        for (int i = 0; i < m; i++) {
            final int begin = scanner.nextInt() - 1;
            final int end = scanner.nextInt() - 1;
            table[begin][end]++;
        }

        for (int i = 0; i < n; i++) {
            for (int j = 1; j < n; j++) {
                table[i][j] += table[i][j - 1];
            }
        }

        for (int i = 1; i < n; i++) {
            for (int j = 0; j < n; j++) {
                table[i][j] += table[i - 1][j];
            }
        }

        for (int i = 0; i < q; i++) {
            final int begin = scanner.nextInt() - 1;
            final int end = scanner.nextInt() - 1;

            int tmp = 0;
            if (begin != 0) {
                tmp = -table[begin - 1][begin - 1];
                tmp += table[begin - 1][end];
                tmp += table[end][begin-1];
            }

            System.out.println(table[end][end] - tmp);
        }
    }

    static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

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

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


Measured memory_bytes: 69016
#素数判定
import math
from itertools import accumulate
def sosuu(n):
  if n==1:
    return False
  else:
    for i in range(2,int(math.sqrt(n)+1)):
      if n%i==0:
        return False
    return True

#入力
q=int(input())
l=[0]*q
r=[0]*q
for i in range(q):
    l[i],r[i]=list(map(int,input().split()))
L=min(l)
R=max(r)

#累積和を作る
A=[]
for i in range(L,R+1):
  if i%2==0:
    A.append(0)
  else:
    if sosuu(i) and sosuu(int((i+1)/2)):
      A.append(1)
    else:
      A.append(0)
s=[0]+A
S=list(accumulate(s))
for i in range(q):
    #print(S[r[i]-L+1])
    #print(S[l[i]-L])
    print(S[r[i]-L+1]-S[l[i]-L])
    



Measured memory_bytes: 16384
#include <bits/stdc++.h>
// #include "bits:stdc++.h"
using namespace std;
#define pb push_back
#define LLINF 1234567890987654321
#define INF 1234567890
#define f first
#define s second
#define flase false
#define db 0
typedef long long ll;
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair<pi, pi>dpi;
int main()
{
	int ans = 0;
	for(ll i = 1; i <= 4; i++)
	{
		char ch;
		cin >> ch;
		if(ch == '+')
		{
			ans ++;
		}
		else
		{
			ans --;
		}
	}
	cout << ans << "\n";
}


Measured memory_bytes: 256
import re
# 盤面の状態
s = input()

# Aマッチする数を数える
w = re.findall(r'[W]+', s)
# Bにマッチする数を数える
b= re.findall(r'[B]+', s)

# 全部Wなら入れ替える必要なし
if s.count("W") == len(s):
    print(0)
else:
    print(len(w)+len(b)-1)

Measured memory_bytes: 5108
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int N = sc.nextInt();
		long[] t = new long[N];
		long max = 0, time = 0, ans = 0;

		for (int i = 0; i < N; i++) {
			t[i] = Long.valueOf(sc.next());
			if (max < t[i]) {
				max = t[i];
			}
		}

		for (int i = 0; i < N; i++) {
			time = max;
			while (time % t[i] != 0) {
				time += max;
			}
			if (ans < time) {
				ans = time;
				max = ans;
			}
		}

		System.out.println(ans);

		sc.close();
	}
}


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

int main(){
  int A,B,C,X;
  cin >> A >> B >> C >> X;
  int res = 0;
  for (int a = 0; a <= A; a++ ){
    for (int b=0; b<=B;b++){
      for (int c=0; c<=C; c++){
      int total = 500*a + 100*b + 50*c;
      if (total== X)res++;
      }
    }
  }
cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,flag;
char s[1000000];
int main(){
	cin>>s;n=strlen(s);
	for(int i=0;i<n;i++)if(s[i]!='0')flag=1;
	if(!flag){cout<<n<<endl; return 0;}
	for(int i=(n+1)/2;i<n;i++){
		if(s[i]!=s[n-i-1]||s[i]!=s[i-1]){
			cout<<i<<endl; return 0;
		}
	}cout<<n<<endl;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define MAX_N 101
#define MAX_W 10001
vvi dp(MAX_N, vi(MAX_W, 0));
int main()
{
    int n, W;
    cin >> n >> W;
    vi v(n);
    vi w(n);
    rep(i, n)
    {
        cin >> v[i] >> w[i];
    }
    rep(i, n)
    {
        rep(j, W + 1)
        {
            if (j < w[i])
            {
                dp[i + 1][j] = dp[i][j];
            }
            else
            {
                dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
            }
        }
    }
    cout << dp[n][W] << endl;
    return 0;
}


Measured memory_bytes: 6672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans;
ll cal(ll x)
{
	return (1+x)*x/2;
}
int main()
{
	int n;
	cin>>n;	
	for(int i=1;i<=n;i++) ans+=i*cal(n/i);
	cout<<ans;
}

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

using namespace std;

#define vit vector<int>::iterator
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fr first
#define sc second
#define skip continue
#define PI 3.14159265

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int ui;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;

const int INF = 1e9 + 5;
const int MAXN = 3e6 + 123;

void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
bool cmp(const string& a, const string& b) {
	return (a + b) < (b + a);
}

vector<int> Reversed(const vector<int>& s){
   vector<int> d = s;
   reverse(all(d));
   return d;
}


void solve(){
    int a, b, c;
    cin >> a >> b >> c;
    if((a == 5 && b == 5 && c == 7) || (a == 5 && b == 7 && c == 5) || (a == 7 && b == 5 && c == 5))
        cout << "YES";
    else cout << "NO";
}

// ."ww"w"".ww"""...ww"".

int main(){
    //freopen("lepus.in","r",stdin);
    //freopen("lepus.out","w",stdout);
    //faster();
    int n=1;
    //cin>>n;
    while(n--){
    solve();
    //cout << endl;
    }
    //fclose(stdout);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int cnt[20][20];
int main() {
	int n; read(n);
	int m = 18;
	for (int i = 1; i <= n; i++) {
		ll x = 0; char c = getchar();
		for (; !isdigit(c); c = getchar());
		for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
		int bit = 1000000000; x *= bit;
		if (c == '.') {
			c = getchar();
			for (; isdigit(c); c = getchar()) {
				bit /= 10;
				x += bit * (c - '0');
			}
		}
		int a = 0, b = 0;
		while (x % 2 == 0) x /= 2, a++;
		while (x % 5 == 0) x /= 5, b++;
		cnt[min(m, a)][min(m, b)]++;
	}
	ll ans = 0;
	for (int i = 0; i <= m; i++)
	for (int j = 0; j <= m; j++) {
		for (int a = m - i; a <= m; a++)
		for (int b = m - j; b <= m; b++) {
			int x = cnt[i][j];
			int y = cnt[a][b];
			if (i == a && j == b) ans += 1ll * x * (y - 1);
			else ans += 1ll * x * y;
		}
	}
	cout << ans / 2 << endl;
	return 0;
}


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

int main()
{
    string s;
    cin >> s;
    int counter = 0;

    if(s[0] == '1')
    {
        ++counter;
    }
    if(s[1] == '1')
    {
        ++counter;
    }
    if(s[2] == '1')
    {
        ++counter;
    }
    cout << counter << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountll
#define m_p make_pair
#define infi 1e18+1
#define eps 0.000000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
//////////////
auto clk=clock();
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define sz(x) ((long long)x.size())
#define int long long  
#define f80 __float128
#define pii pair<int,int>
/////////////
int va[300001][10]={};
int v[300001];
int w[300001];
int ans[300001];
int n;
vector<pair<int,int>> qu[300001];
void dfs2(int i,vector<int> &vv){
	if(i>n)
		return;
	vv.push_back(i);	
	dfs2(2*i+1,vv);
	dfs2(2*i,vv);
	if(qu[i].size())
	for(int j=0;j<(1<<vv.size());++j){
		int tw=0,tva=0;
		for(int k=0;k<vv.size();++k){
			if(j&(1<<k)){
				tw+=w[vv[k]];
				tva+=v[vv[k]];
			}
		}
		for(auto r:qu[i]){
			if(r.F>=tw)
				ans[r.S]=max(ans[r.S],va[r.F-tw][9]+tva);
		}
	}
	vv.pop_back();
}
void dfs(int i,int lv){
	if(i>n)
		return;
	if(lv>9){
		vector<int> vv;
		dfs2(i,vv);
	}else{
		for(int j=0;j<=100000;++j){
			va[j][lv]=va[j][lv-1];
			if(j>0)
				va[j][lv]=max(va[j][lv],va[j][lv-1]);
			if(j-w[i]>=0)
				va[j][lv]=max(va[j][lv-1],va[j-w[i]][lv-1]+v[i]);
		}
		for(auto r:qu[i]){
			ans[r.S]=va[r.F][lv];
		}
		dfs(2*i,lv+1);
		dfs(2*i+1,lv+1);
	}
}
signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>v[i]>>w[i];
	}
	int q;
	cin>>q;
	for(int i=1;i<=q;++i){
		int no,l;
		cin>>no>>l;
		qu[no].push_back({l,i});
	}
	dfs(1,1);
	for(int i=1;i<=q;++i){
		cout<<ans[i]<<"\n";
	}
	#ifdef ANIKET_GOYAL
		// cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
	#endif
}

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

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n-1;i++){
    cin>>a.at(i);
  }
  vector<int> b(n);
  for(int i=0;i<n-1;i++){
    b.at(a.at(i)-1)++;
  }
  for(int i=0;i<n;i++){
    cout<<b.at(i)<<endl;
  }
}

Measured memory_bytes: 4804
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Watch
{
    class Program
    {
        static void Main(string[] args)
        {
            //入力
            var n = int.Parse(Console.ReadLine());  // ユーザーの入力した整数を読み込む

            int h = n/60/60;
            int m = n/60%60;
            int s = n%60%60;

            //計算結果を表示
            Console.WriteLine(h+":"+m+":"+s);
           
        }
    }
}



Measured memory_bytes: 17920
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include "bits/stdc++.h"

typedef long long ll;
using namespace std;

//#define

#define FOR(i,n) for(ll i=0;i<n;i++) 
#define RFOR(i,n) for(ll i=n-1;i>=0;--i)
#define COUT(str) cout << str << endl

#define INF 1000000001ll
#define MOD 1000000007ll

//入力
int N; 

int main() {

	scanf("%d", &N);  
	printf("%d\n",(1+N)*N/2 ); 
					  
	return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def f_bit_count(A, bit):
    if A <= 0:
        return 0
    C = A + 1
    if C < 2 ** bit:
        return 0
    b = 2L**(bit + 1)
    count = (C/b) * (2L ** bit)
    if C % b != 0 and C % b > (2L ** bit):
        count += (2L ** bit) - (b - C % b)

    return count

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [A, B] = [long(input_raw[0]), long(input_raw[1])]

    ans  = 0L
    for bit in range(42):
        B_count = f_bit_count(B, bit)
        A_count = f_bit_count(A - 1, bit)
        if (B_count - A_count) % 2 == 1:
            ans += 1 << bit;
    print ans



if __name__ == '__main__':
    main()


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

typedef pair<int, int> sig;

int main () {
  map<sig, char> dir;
  dir[sig(+1, +1)] = 'R';
  dir[sig(+1, -1)] = 'U';
  dir[sig(-1, +1)] = 'D';
  dir[sig(-1, -1)] = 'L';

  int N;
  cin >> N;
  vector<int> U(N), V(N);

  rep(i,N) {
    int X, Y;
    cin >> X >> Y;
    U[i] = X + Y;
    V[i] = X - Y;
  }

  int p = U[0] & 1;
  rep(i,N) {
    if((U[i] & 1) != p) {
      cout << "-1" << endl;
      return 0;
    }
  }


  int m = 31;
  cout << m + (!p) << endl;
  if(!p) cout << "1 ";
  for(int i = m - 1; i >= 0; i--) {
    cout << (1<<i);
    if(i != 0) cout << " ";
  }
  cout << endl;

  rep(i,N) {
    int u = 0, v = 0;
    if(!p) {
      cout << 'R';
      u++; v++;
    }

    for(int j = m - 1; j >= 0; j--) {
      int d = (1<<j);

      sig s = sig((U[i]-u)/abs(U[i] - u), (V[i] - v)/abs(V[i] - v));
      u += d*s.first;
      v += d*s.second;
      cout << dir[s];
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define RFOR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define EPS 1e-15

using namespace std;

typedef complex<double> point;
typedef vector<point> polygon;
typedef pair<int, int> paii;
typedef long long ll;

double dot(point va, point vb){
	return real(va) * real(vb) + imag(va) * imag(vb);
}

double cross(point va, point vb){
	return real(va) * imag(vb) - imag(va) * real(vb);
}

double distance_l_p(point a, point b, point c){
	return abs(cross(b - a, c - a)) / abs(b - a);
}

double distance_ls_p(point a, point b, point c){
	if( dot(b - a, c - a) <= 0.0 ) return abs(c - a);
	if( dot(a - b, c - b) <= 0.0 ) return abs(c - b);
	return distance_l_p(a, b, c);
}

bool contains(polygon plg, point pt){
	int cnt = 0;
	double y = imag(pt);

	for(int i = 0; i < plg.size(); ++i){
		int j = (i + 1 == plg.size() ? 0: i + 1);

		if( distance_ls_p(plg[i], plg[j], pt) <= EPS ){
			return true;
		}

		double dyi = imag(plg[i]) - y;
		double dyj = y - imag(plg[j]);
		double tx = (dyi * real(plg[j]) + dyj * real(plg[i])) / (dyi + dyj);

		if(imag(plg[i]) >= y && imag(plg[j]) < y){
			if( tx < real(pt) ) ++cnt;
		}
		else if(imag(plg[i]) < y && imag(plg[j]) >= y){
			if( tx < real(pt) ) ++cnt;
		}
	}
	
	return (cnt % 2 != 0);
}

bool intersected(point pa1, point pa2, point pb1, point pb2){
	double a = cross(pa2 - pa1, pb1 - pa1);
	double b = cross(pa2 - pa1, pb2 - pa1);
	double c = cross(pb2 - pb1, pa1 - pb1);
	double d = cross(pb2 - pb1, pa2 - pb1);

	if( (a < -EPS && b > EPS) || (b < -EPS && a > EPS) ){
		if( (c < -EPS && d > EPS) || (d < -EPS && c > EPS) ){
			return true;
		}
	}
	
	if( 	distance_ls_p(pa1, pa2, pb1) < EPS
		 || distance_ls_p(pa1, pa2, pb2) < EPS
		 || distance_ls_p(pb1, pb2, pa1) < EPS
		 || distance_ls_p(pb1, pb2, pa2) < EPS
	){
		return true;
	}	
	
	return false;
}

int contact(polygon plg1, polygon plg2){
	int n = plg1.size();
	int m = plg2.size();

	for(int i = 0; i < n; ++i){
		for(int j = 0; j < m; ++j){
			if( intersected(plg1[i], plg1[(i+1)%n], plg2[j], plg2[(j+1)%m]) ){
				return 1;
			}
		}
	}
	
	if( contains(plg1, plg2[0]) ){
		return -1;
	}
	if( contains(plg2, plg1[0]) ){
		return -2;
	}
	
	return 0;
}

int main()
{
	double arg[8];
	
	while( cin >> arg[0], !cin.eof())
	{
		FOR(i, 1, 8)
		{
			cin >> arg[i];
		}
		
		polygon plg1, plg2;
		
		plg1.push_back(point(arg[0], arg[1]));
		plg1.push_back(point(arg[2], arg[1]));
		plg1.push_back(point(arg[2], arg[3]));
		plg1.push_back(point(arg[0], arg[3]));

		plg2.push_back(point(arg[4], arg[5]));
		plg2.push_back(point(arg[6], arg[5]));
		plg2.push_back(point(arg[6], arg[7]));
		plg2.push_back(point(arg[4], arg[7]));
		
		int con = contact(plg1, plg2);
		
		cout << (con != 0 ? "YES" : "NO") << endl;
	}
		
	return 0;
}

Measured memory_bytes: 1236
n, m = map(int, input().split())

h = list(map(int, input().split()))

a = [0] * m
b = [0] * m

good = [1] * n

for i in range(m):
  a[i], b[i] = map(int, input().split())

for i in range(m):
  if h[a[i] - 1] > h[b[i] - 1]:
    good[b[i] - 1] -= 1
  elif h[b[i] - 1] > h[a[i] - 1]:
    good[a[i] - 1] -= 1
  elif h[a[i] - 1] == h[b[i] - 1]:
  # elif h[a[i] - 1] == h[b[i] - 1] and good[a[i] - 1] != 1:
    good[b[i] - 1] -= 1
  # elif h[a[i] - 1] == h[b[i] - 1] and good[b[i] - 1] != 1:
    good[a[i] - 1] -= 1


print(good.count(1))



Measured memory_bytes: 85224
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define min(a,b) a<b ? a:b
#define max(a, b) a < b ? b : a
#define IOS                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0)
#define endl "\n"
#define pb push_back
#define pi 3.14159265358979323846

// int explore(vector<vector<int>> &adj,int x,int y,vector<int> &visited)
// {
//     if(x==y)
//     return 1;
//     visited[x]=1;
//     for(int i=0;i<adj[x].size();i++)
//     {
//         if(!visited[adj[x][i]])
//         {
//             if(explore(adj,adj[x][i],y,visited))
//             return 1;
//         }
//     }
//     return 0;
// }
bool valley(int p[], int k)
{
    if (p[k] < p[k - 1] && p[k] < p[k + 1])
        return true;
    return false;
}
bool peak(int p[], int k)
{
    if (p[k] > p[k - 1] && p[k] > p[k + 1])
        return true;
    return false;
}

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b); 
}
int const N=10000007;
int prime[N];
// for(int i=1;i<=n;i++)
//         {
//             if(a[i]==maxi)
//             {
//                 ctr++;
//                 ans=max(ans,ctr);
//             }
//             else
//             ctr=0;
//         }
int32_t main() 
{
    // IOS;
    // int t;
    // cin>>t;
    // while(t--)
    // {
          int n,x,t;
          cin>>n>>x>>t;
          int ctr=0;
          while(n>0)
          {
              n-=x;
              ctr++;
          }  
          cout<<ctr*t;


    // }

}

Measured memory_bytes: 3584
read*,i,j,k
if(j<i)then
n=i;i=j;j=n
endif
if(k<j)then
n=j;j=k;k=n
endif
if(j<i)then
n=i;i=j;j=n
endif
n=(k-i)/2+(k-j)/2;k=i+j+2*n-k-k
if(k==-1)then
n=n+2
else if(k==-2)then
n=n+1
endif
print"(i0)",n
end

Measured memory_bytes: 768
import static java.lang.Double.parseDouble;

public class Main {
    public static void main (String[] args ) {
        int i ;
        String number = new java.util.Scanner ( System.in ).nextLine();
        i = (int) xclubic (parseDouble(number));
        System.out.println(i);
    }
    public static double xclubic (double x) {
        double y;
        y = 3;
        return Math.pow(x , y);
    }
}

Measured memory_bytes: 26000
import java.io.PrintStream;
import java.util.Scanner;
public class Main {
    private static final PrintStream so = System.out;
    private static final Scanner     sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N = ni();
        int K = ni();
        println(2*K - 1 <= N ? "YES" : "NO");
    }

    static int    ni() { return sc.nextInt(); }
    static long   nl() { return sc.nextLong(); }
    static String n()  { return sc.next(); }
    
    static char[] nChars() { return n().toCharArray(); }
    static int[] nInts(int n) { 
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = ni();
        return a;
    }
    static void println(Object o)  { so.println(o);}
    static void println(long l)    { so.println(l);}
    static void println(char c)    { so.println(c);}
    static void println(double d)  { so.println(d);}
    static void println(boolean b) { so.println(b);}
    
    static void print(Object o)  { so.print(o);}
    static void print(long l)    { so.print(l);}
    static void print(char c)    { so.print(c);}
    static void print(double d)  { so.print(d);}
    static void print(boolean b) { so.print(b);}
}


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

bool check[105];

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			check[i * j] = 1;
		}
	}
	int n;
	cin >> n;
	if (check[n]) cout << "Yes";
	else cout << "No";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
int main(){
    int n;
    cin >> n;
    string s;
    map<string,long long>mp;
    for(int i=0; i<n; i++){
        cin >> s;
        sort(s.begin(),s.end());
        mp[s]++;
    }
    long long ans=0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        /*
        std::cout << "key = " << itr->first
                  << ", val = " << itr->second << "\n";   
        */
        if(itr->second==2) ans++;
        if(itr->second>2){
            long long a = itr->second;
            if(a%2==0){
                ans += a/2*(a-1);
            }else{
                ans += (a-1)/2*a;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11296
#include<iostream>
#include<vector>
#include<string>
#include <algorithm>
#include <queue>
#include <climits>
#include<cmath>
#include <sstream>
#include <iomanip>

bool sort_pair( std::pair< int64_t, std::pair< int64_t, int64_t > > origin, std::pair< int64_t, std::pair< int64_t, int64_t > > another )
{
    return origin.second.first < another.second.first;
}

int main()
{

    int64_t a,b;
    
    std::cin>> a;
    std::cin>> b;

    std::vector< std::string > list( a );

    for( int i = 0; i < a; i++ )
    {
        std::cin>> list[i];
    }

    std::queue< std::pair< int, int > > q_list;

    int count = 0;

    for( int i = 0; i < a; i++ )
    {
        for( int r = 0; r < b; r++ )
        {
            if( list[i][r] == '#' )
            {
                std::pair< int, int > ins;
                ins.first = i;
                ins.second = r;
                q_list.push( ins );
            }
        }
    }


    while( 1 )
    {
        std::queue< std::pair< int, int > > next_q_list;

        while( !q_list.empty() )
        {
            int i = q_list.front().first;
            int r = q_list.front().second;
            std::pair< int, int > ins;
            //std::cout<< q_list.size() << " " << q_list.front().first <<  " " << q_list.front().second <<"\n";
            
            if( i != 0
                && list[i-1][r] == '.' )
            {
                ins.first = i-1;
                ins.second = r;
                list[i-1][r] = '#';
                next_q_list.push( ins );
            }
            
            if( i != a - 1
                && list[i+1][r] == '.' )
            {
                ins.first = i+1;
                ins.second = r;
                list[i+1][r] = '#';
                next_q_list.push( ins );
            }
            
            if( r != 0
                && list[i][r-1] == '.' )
            {
                ins.first = i;
                ins.second = r-1;
                list[i][r-1] = '#';
                next_q_list.push( ins );
            }
            
            if( r != b - 1
                && list[i][r+1] == '.' )
            {
                ins.first = i;
                ins.second = r+1;
                list[i][r+1] = '#';
                next_q_list.push( ins );
            }

            q_list.pop();
        }
        
        if( next_q_list.empty() )
        {
            break;
        }
        
        count += 1;
        q_list = next_q_list;
    }
    
    std::cout<< count;

}


Measured memory_bytes: 9600
#include <iostream>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int count = 0;
  if(S[1] == 'R'){
    count++;
    if(S[0] == 'R') count++;
    if(S[2] == 'R') count++;
  }
  else{
    if(S[0] == 'R' || S[2] == 'R') count++;
  }  
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3604
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<ctype.h>
#include<cwchar>
#include<cwctype>
#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<math.h>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<stdio.h>
#include<stdlib.h>
#include<streambuf>
#include<string.h>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
using namespace std;
int a[200010],cnt[200010],len[200010];
int main(void){
	int n,m;
	scanf("%d%d",&n,&m);
	int emp=0;
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		int pos=a[i]-(len[a[i]]++);
		if (pos) cnt[pos]++;
	}
	for (int i=1;i<=n;i++){
		if (!cnt[i]) emp++;
	}
	for (int i=1;i<=m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		int pos;
		pos=a[x]-(--len[a[x]]);
		if (pos>0){
			cnt[pos]--;
			if (!cnt[pos]) emp++;
		}
		a[x]=y;
		pos=a[x]-(len[a[x]]++);
		if (pos>0){
			if (!cnt[pos]) emp--;
			cnt[pos]++;
		}
		printf("%d\n",emp);
	}
	return 0;
}

Measured memory_bytes: 3712
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, m = map(int, input().split())
C = list(map(int, input().split()))

MAX = 10 ** 5
dp = [MAX] * (n + 1)

dp[0] = 0
for i in range(m):
    c = C[i]
    for j in range(n + 1):
        if j >= c:
            dp[j] = min(dp[j], dp[j - c] + 1)
print(dp[n])



Measured memory_bytes: 8016
#include <iostream>

using namespace std;


int P[100001];
int main(){
  int N;
  cin >> N;
  for(int i=0;i<N;++i){
    cin >> P[i];
  }
  P[N] = -1;
  bool cont=false;
  int swp_num = 0 , len = 0;
  for(int i=0;i<N+1;++i){
    if(cont){
      if(P[i]!=i+1){
        swp_num+=len/2+1;
        len = 0;
        cont=false;
      }else{
        len++;
      }
    }else if(P[i]==i+1){
      cont = true;
      len = 0;
    }
  }
  cout << swp_num << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(int i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

int main(void){
  int N,K;cin >> N >> K;
  int a[N];
  REP(i,N) cin >> a[i];
  //残りi個の時に先手が勝利
  int dp[K+1];
  dp[0] = 0;
  REP(j,K+1){
    dp[j] = 0;
    REP(i,N){
      if(j-a[i]>=0) dp[j] = max(dp[j],dp[j-a[i]]^1);
    }
  }
  if(dp[K]) cout << "First" << endl;
  else cout << "Second" << endl;
  return 0;
}


Measured memory_bytes: 640