akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <sstream>
#include <utility>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cmath>
#include <functional>
#include <chrono>
#include <cstring>
#include <limits.h>

using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<lint> vl;
typedef pair<lint,lint> pll;

int main()
{
    ios_base::sync_with_stdio(0);    cin.tie(NULL);    cout.tie(NULL);

    int n; cin>>n;
    vi p(n);
    vi cnt(1e6+1, 0);
//    set<int>
    for (int &i : p){
        cin>>i;
        cnt[i]++;
    }

    sort(p.begin(), p.end());
    auto it = unique(p.begin(), p.end());
    p.resize(it - p.begin());

    vi vst(1e6+1, 0);

    int tot = 1e6;
    int l = p.size();
    for (int id = 0; id < p.size(); ++id){
        int i = p[id];
        if(cnt[i] > 1) vst[i] = 1;
        if (tot/i < l-id) {
            for (int j = 2*i; j<= 1e6; j += i){
                vst[j] = 1;
            }
        } else {
            for (int j = id +1; j<p.size(); ++j){
                if (p[j]%i == 0) vst[p[j]] = 1;
            }
        }
    }

    int ans = 0;
    for (int v : p){
        if (!vst[v]) ans += cnt[v];
    }
    cout<<ans;



}


Measured memory_bytes: 11916
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif
#define FILE_IO freopen("input.txt","r",stdin)
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
void solve(){
     int n,a,b;
     cin>>n>>a>>b;
     cout<<min(n*a,b)<<endl;
 }
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
    IOS;
    solve();
    #ifdef LOCAL_DEFINE
    cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
    #endif
}

Measured memory_bytes: 256
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N;
    cin >> N;

    vector<ll> T(N);
    REP(i, N)
    cin >> T[i];
    sort(ALL(T));
    ll current = T[0];

    FOR(i, 1, N - 1)
    {
        current = lcm(current, T[i]);
    }

    cout << current << endl;

    return 0;
}


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

int main() {
  int N, a = 0, b = 0;
  cin >> N;
  vector<int> vec(N);

  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }

  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());

  for (int j = 0; j < N; j++) {
    if (j % 2 == 0) {
      a += vec.at(j);
    } else {
      b += vec.at(j);
    }
  }
  cout << a - b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    int q;
    cin >> q;
    int b[q];
    vector<int> c;
    for(int i=0;i<q;i++) cin >> b[i];
    for(int i=0;i<(1<<n);i++){
        bitset<20> s(i);
        int cnt = 0;
        for(int j=0;j<n;j++){
            if(s.test(j)) cnt += a[j]; 
        }
        c.push_back(cnt);
    }
    for(int i=0;i<q;i++){
        bool flag = 0;
        for(auto j:c){
            if(j==b[i]) flag=1;
        }
        if(flag) cout << "yes" << endl;
        else cout << "no" << endl;
    }
        
}


Measured memory_bytes: 6956
S=input()
dp = {0:1}

p=0
q=1

for i in range(len(S)-1,-1,-1):
  p += (int(S[i])*q)
  p = p%2019
  q *= 10
  q = q%2019
  if p not in dp:
    dp[p]=0
  dp[p]+=1

#print(dp)
c = 0
for v in dp:
  c += dp[v]*(dp[v]-1)//2
print(c)

Measured memory_bytes: 9376
def abc053_d():
    _ = int(input())
    A = list(map(int, input().split()))
    ans = 0
    from collections import Counter
    multi_even = 0
    for _, v in Counter(A).items():
        ans += 1
        if 2 <= v and v % 2 == 0:
            multi_even += 1
    if 0 < multi_even and multi_even % 2 == 1:
        ans -= 1
    print(ans)

abc053_d()

Measured memory_bytes: 17652
from fractions import gcd

MOD = 10**9 + 7
N = int(input())
A = list(map(int, input().split()))

l = A[0]
for a in A:
  l = l * a // gcd(l, a)

ans = 0
for a in A:
  ans += (l//a)

print(ans%MOD)

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

const ll MOD = 1E+9 + 7;

int main() {
    ll M, N;
    cin >> M >> N;

    ll ans = 1, a = M;
    for (ll bit=0; (1LL<<bit) <=N; bit++) {
        if (N & (1LL<<bit)) ans = (ans * a) % MOD;
        a = (a * a) % MOD;
    }

    cout << ans << endl;

    return 0;
}




Measured memory_bytes: 3100
H, W = map(int, input().split())
 
x = ["."*(W+2)]
for k in range(H):
    x.append("."+input()+".")
x.append("."*(W+2))
 
for k in range(1,W+1):
    for l in range(1,H+1):
        if x[l][k]=="#":
            if x[l+1][k]=="#" or x[l-1][k]=="#" or x[l][k+1]=="#" or x[l][k-1]=="#":
                pass
            else:
                print("No")
                exit()
print("Yes")

Measured memory_bytes: 3064
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int[] a = new int[n];
        
        int sum = 0;
        for(int i=0; i<n; i++){
            a[i] = Integer.parseInt(sc.next());
            sum += a[i];
        }
        
        int len = 4000001;
        BitSet bs = new BitSet(len);
        bs.set(len);
        for(int i=0; i<n; i++){
            BitSet shift = bs.get(a[i], len+1);
            //System.out.println(shift);
            bs.or(shift);
        }
        
        for(int i=len-(sum+1)/2; i>0; i--){
            //System.out.println(len-i);
            if(bs.get(i)){
                System.out.println(len-i);
                break;
            }
        }
        
    }
}


Measured memory_bytes: 277860
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val ab = (1..n).map { Pair(sc.nextLong(), sc.nextLong()) }

  var count = 0L
  for (i in n-1 downTo 0) {
    val abi = ab[i]
    val a = abi.first
    val b = abi.second

    val aa = a + count
    val tmp = aa % b
    if (tmp == 0L) {
      continue
    }
    count += b - tmp
  }


  println(count)
}


Measured memory_bytes: 68348
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	for (int i = 0; i < s.size(); i += 2) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 512
import java.util.*;
        import java.io.*;

class Main
{
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args)
    {
        FastReader s = new FastReader();
        int no = s.nextInt();
        long[] arr =new long[no+1];
        arr[0] = 2;
        arr[1] = 1;
//        int sum = 2;
        for (int i =2;i<no+1;i++)
        {
            arr[i] = arr[i-1]+arr[i-2];
        }
        System.out.println(arr[no]);



    }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  int n, x, t;
  cin >> n >> x >> t;
  if (n <= x) {
    cout << t << endl;
  } else {
    int ans =  t*(n/x);
    if (0 < (n%x)) {
      ans += t;
    } 
    cout << ans << endl;
  }
}

Measured memory_bytes: 3616
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define vd vector<double>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define reverse_v(a) reverse(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    (c) ? (cout << "Yes" << endl) : (cout << "No" << endl);
}

void Print(bool c)
{
    (c) ? (cout << "YES" << endl) : (cout << "NO" << endl);
}

//最小公倍数
template <typename T>
T gcd(T a, T b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

//最大公約数
template <typename T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}
//セカンドキー->ファーストキーの順ソート
bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

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

int eve(int x)
{
    if (x % 400 == 0)
        return 1;
    if (x % 100 == 0)
        return 0;
    if (x % 4 == 0)
        return 1;
    return 0;
}

int main(void)
{
    int a, b;
    cin >> a >> b;
    if (b == 1)
        return cout << 0 << endl, 0;
    for (ll i = 1;; i++)
    {
        if ((a - 1) * i + 1 >= b)
            return cout << i << endl, 0;
    }
}

Measured memory_bytes: 256
#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
a,b,k= map(int, sys.stdin.readline().split(' '))

for i in range(k):
    if(i%2==0):
        if(a%2):
            a-=1
            c=a//2
            a-=c
            b+=c
        else:
            c=a//2
            a-=c
            b+=c
    else:
        if(b%2):
            b-=1
            c=b//2
            a+=c
            b-=c
        else:
            c=b//2
            a+=c
            b-=c

print(a,b)

    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

Measured memory_bytes: 3064
def main():

    X, Y = map(int, input().split())
    d = {1: 300000, 2: 200000, 3: 100000}
    ans = 0
    if X in d:
        ans += d[X]
    if Y in d:
        ans += d[Y]
    if X == 1 and Y == 1:
        ans += 400000 
    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7;

int N;
unordered_set<int> visited;
map<int, vector<int>> edges;
map<int, vector<int>> subtree_sizes;

ll mod_exp(ll x, ll exp) {
    ll ans = 1;
    ll base = x % MOD;
    while (exp > 0) {
        if (exp % 2 == 1) {
            ans = (ans * base) % MOD;
        }
        base = (base * base) % MOD;
        exp /= 2;
    }
    return ans;
}

ll mod_inv_prime(ll x) {
    return mod_exp(x, MOD-2);
}

int dfs(int v) {
    // cout << v << endl;
    visited.insert(v);
    int total_size = 0;
    for (int ne : edges[v]) {
        // cout << "attempt visit " << ne << endl;
        if (!visited.count(ne)) { 
            int subtree_size = dfs(ne) + 1;
            // cout << "subtree size " << subtree_size << endl;
            if (subtree_size > 0) {
                subtree_sizes[v].push_back(subtree_size);
            }
            total_size += subtree_size;
        }
    }
    if (N - 1 - total_size > 0) {
        subtree_sizes[v].push_back(N-1-total_size);
    }
    return total_size;
}

int main() {
    cin >> N;
    for (int i = 0; i < N-1; i++) {
        int a, b;
        cin >> a >> b;
        edges[a-1].push_back(b-1);
        edges[b-1].push_back(a-1);
    }
    int root = 0;
    for (int i = 0; i < N; i++) {
        if (edges[i].size() == 1) {
            root = i;
            break;
        }
    }

    dfs(root);

    /*
    for (int i = 0; i < N; i++) {
        printf("%d: ", i);
        for (int x : subtree_sizes[i])
            printf("%d ", x);
        printf("\n");
    }
    */

    ll ev = 0;
    ll two_inv = mod_inv_prime(2);
    /*
    vector<ll> two_inv_pow = {1};
    ll curr = 1;
    for (int i = 0; i < N; i++) {
        curr = (curr * mod_inv_prime) % MOD;
    }
    */

    for (int i = 0; i < N; i++) {
        if (subtree_sizes[i].size() < 2) continue;
        ll p_all_white = 1;
        for (int subtree_size : subtree_sizes[i]) {
            p_all_white = (p_all_white * mod_exp(two_inv, subtree_size)) % MOD;
        }
        ll p_one_black = 0;
        for (int subtree_size : subtree_sizes[i]) {
            ll p_t_white = mod_exp(two_inv, subtree_size);
            ll p_t_black = (1 - p_t_white + MOD) % MOD;
            ll prob = (p_all_white * ((p_t_black * mod_inv_prime(p_t_white)) % MOD)) % MOD;
            p_one_black = (p_one_black + prob) % MOD;
        }
        ll cond_prob = (1 - ((p_all_white + p_one_black) % MOD) + MOD) % MOD;
        ll total_prob = (two_inv * cond_prob) % MOD;
        ev = (ev + total_prob) % MOD;
    }

    cout << ev << endl;

}


Measured memory_bytes: 68808
N=int(input())
H=list(map(int,input().split()))
c=0
if N==1:
    print('Yes')
else:
    for n in range(N-1):
        i=N-n-1
        if H[i-1]>H[i]:
            if H[i-1]-H[i]>1:
                c=1
            else:
                H[i-1]=H[i-1]-1
    if c==0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 14252
END { load __FILE__ unless $stdin.eof? }

n = gets.to_i
a, b = Array.new(n) { gets.split.map!(&:to_i) }.transpose.each(&:sort!)

if n.even?
  mmin2 = a[n/2-1] + a[n/2]
  mmax2 = b[n/2-1] + b[n/2]
  puts mmax2 - mmin2 + 1
else
  mmin = a[n/2]
  mmax = b[n/2]
  puts mmax - mmin + 1
end


Measured memory_bytes: 32148
# -*- coding: utf-8 -*-
"""
Created on Sat Mar  9 21:53:23 2019

@author: yuta
"""

HW = list(map(int,input().split()))
hw = list(map(int,input().split()))
H = HW[0]
W = HW[1]
h = hw[0]
w = hw[1]

def main(A,B,a,b):
    print((A-a)*(B-b))
main(H,W,h,w)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define sync ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define mod 1000000007
using namespace std;
vector<ll> prime,sfac;
void sieve(ll n)
{
	prime.assign(n+1,1);
	sfac.assign(n+1,1);    
    for (ll p=2; p*p<=n; p++) 
    {         
        if (prime[p] == 1) 
        { 	sfac[p]=p;  			  
            for (ll i=p*p; i<=n; i += p) 
              {  prime[i] = 0; sfac[i]=p;}
        } 
    } 

}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll power(ll x, ll y) 
{ 
    ll res = 1;    
    while (y > 0) 
    { 
        ll k=y&1LL;
        if (k) 
            res = res*x;      
        y = y>>1LL;
        x = x*x;  
    } 
    return res; 
}
 
int isPrime(ll n) 
{ 
    if (n <= 1)  return 0; 
    if (n <= 3)  return 1; 
    if (n%2 == 0 || n%3 == 0) 
        return 0;   
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return 0;  
    return 1; 
} 
int main()
{
    
    sieve(1e+7);
    vector<ll>v;
    v.assign((1e+7)+1,0);
    v[1]=1;
    v[2]=2;
    v[3]=2;
    for(ll i=4;i<=1e+7;i++)
    {
        if(prime[i])
        {
            v[i]=2;
            continue;
        }
        ll count=1,c=0;
        ll f=sfac[i],no=i;
        while(no>1)
        {   
            if(no%f==0)
            {
                c++;
                no/=f;
                continue;
            }
            count*=(c+1);
            c=0;
            if(prime[no])
                {count*=2;break;}
            f=sfac[no];
        }
        if(c!=0)
            count*=(c+1);
        v[i]=count;
    }
    vector<ll>ans;
    ans.assign((1e+7)+1,0);
    ans[1]=1;
    for(int i=2;i<=1e+7;i++)
    {
        ans[i]=(i*v[i])+ans[i-1];
    }
    ll n;
    cin>>n;
    cout<<ans[n]<<endl;
}

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

#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

/*****************************************************START******************************************************************/



int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	int T = 1;
	 //cin >> T;
	// cin.ignore(); must be there when using getline(cin, s)
	while (T--)
	{
		int x,y; cin >> x >> y; 
		if((2*x < y && 4*x > y && ((y-2) % 4 == 0 || y % 4 == 0)) || (2*x == y || 4*x == y)){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3592
w, h, n = map(int, input().split())
high = h
low = 0
left = 0
right = w


for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        left = max(left, x)
    elif a == 2:
        right = min(right, x)
    elif a == 3:
        low = max(low, y)
    else:
        high = min(high, y)

print(max(high - low, 0)*max(right - left, 0))

Measured memory_bytes: 3064
#include<cstdio>
#include<queue>
#include<climits>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<ctype.h>
#include<set>
#include<vector>
#include<map>
#include<time.h>
#include<list>
#include<stack>
#include<iostream>
using namespace std;
#define mod 1000000007
#define mem(x,k ) memset(x, (k) ,sizeof(x))
#define mp(A, B) make_pair(A, B)
#define pb push_back
#define sca scanf
#define pri printf
#define fi first
#define se second

typedef long long LL;
typedef long double LD;
typedef pair< int , int  > pii;

const LL INFLL=0x3f3f3f3f3f3f3f3fll;
const int INF=0x7fffffff;
const double PI=acos(-1.0);
const double  eps=1e-9;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
int n,m,k;
int f[200005];
int f2[200005];
map<pair<int ,int >,int> G;
int Father(int k)
{
    if (k==f[k]) return k;
	return f[k]=Father(f[k]);
}

void Union(int x,int y)
{
    if (Father(x)==Father(y)) return;
    else
    {
        f[ f[x] ]=f[y];
        return;
    }
}
int Father2(int k)
{
    if (k==f2[k]) return k;
	return f2[k]=Father2(f2[k]);
}

void Union2(int x,int y)
{
    if (Father2(x)==Father2(y)) return;
    else
    {
        f2[ f2[x] ]=f2[y];
        return;
    }
}
int main(){
    scanf("%d%d%d",&n,&k,&m);
    for (int i=1;i<=n;i++){
        f[i]=f2[i]=i;
    }
    for (int i=1;i<=k;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        Union2(u,v);
    }
    for (int i=1;i<=m;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        Union(u,v);
    }
    for (int i=1;i<=n;i++){
        G[make_pair(Father(i),Father2(i))]++;
    }
    for (int i=1;i<=n;i++){
        //printf("@%d@",Father(i));
        printf("%d",G[make_pair(Father(i),Father2(i))]);
        if (i!=n) printf(" ");
    }
    printf("\n");
    return 0;
}





Measured memory_bytes: 13568
#include<bits/stdc++.h>                                                   //---------------------------------------------------------------
                                                                    
# define ll long long   
# define ld long double                                               
# define mod 1000000007                                                   
# define MAX 100005
# define pi 3.141592653589793238                                                                                  //shortcut keys
                                                                                
# define pb push_back                                                                     
# define mp make_pair 
# define all(x) x.begin(),x.end()                                                      
                                                                  
# define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);        //---------------------------------------------------------------                                       
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int h[n+1];
	vector<int> g[n+2];
	for(int i=1;i<n+1;i++)cin>>h[i];
	
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		g[x].pb(y);
		g[y].pb(x);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		int flag=1;
		for(int j=0;j<g[i].size();j++){
			if(h[g[i][j]]>=h[i]){
				flag=0;break;
			}
		}
		if(flag==1)ans++;
	}
	cout<<ans;
	return 0;
	
	
}

Measured memory_bytes: 9112
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    N,=pin()
    S=input()
    if N%2!=0:print("No");return
    for i in range(N//2):
        if S[i]!=S[i+(N//2)]:
            print("No");return
    
    print("Yes")
#%%submit!
resolve()

Measured memory_bytes: 38384
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;

const ll MOD = 1000000007;

int main()
{
	int N;
	cin >> N;
	mat S(N, vec(N, -1));

	for (int i = 0; i < N; ++i)
	{
		int A; cin >> A;
		
		for (int j = 0; j < A; ++j)
		{
			int x, y; cin >> x >> y; --x;
			S[i][x] = y;
		}
	}
	int ans = 0;
	for (int i = 0; i < (1 << N); ++i)
	{
		
		bool flag = true;
		int cnt = 0;
		for (int h = 0; h < N; ++h)
		{
			if(i&(1<<h)){}
			else { continue; }
			++cnt;
			for (int g = 0; g < N; ++g)
			{
				if (S[h][g] == -1) { continue; }
				if (S[h][g] != ((i&(1 << g))!=0)) {
					
					flag = false; }
			}
		}
		if (flag)
		{
			ans = max(ans,cnt);
		}

	}

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

Measured memory_bytes: 256
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n = int(input())


r = 0
if n != 1:
    f = factorization(n) 
    num = []
    for a, b in f:
        for i in range(b):
            num.append(a ** (i + 1))
    num.sort()
    for c in num:
        if n < c:
            break
        else:
            if n % c == 0:
                n /= c
                r += 1

print(r)

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

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
using namespace std;


int main(void)
{
	string S; cin >> S;
	S = "XX" + S;
	int tail = S.length() - 1;
	bool flag = true;
	while (tail > 0) {
		if (S.substr(tail - 4, 5) == "dream") {
			tail -= 5;
		}
		else if (S.substr(tail - 6, 7) == "dreamer") {
			tail -= 7;
		}
		else if (S.substr(tail - 4, 5) == "erase") {
			tail -= 5;
		}
		else if (S.substr(tail - 5, 6) == "eraser") {
			tail -= 6;
		}
		else {
			flag = false;
			break;
		}
		if (tail == 1)break;
	}
	cout << (flag ? "YES" : "NO") << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

ll gcd(ll x, ll y) {
  if(x > y)
    return gcd(y, x);
  else if(x == 0)
    return y;
  else
    return gcd(y % x, x);
}
ll lcm(ll x, ll y) {
  ll g = gcd(x, y);
  return g * (x / g) * (y / g);
}
ll num(ll a, ll b, ll c) {
  return b / c - (a % c == 0 ? a / c : a / c + 1) + 1;
}

int main() {
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  ll L = lcm(C, D);
  cout << (B - A + 1) - (num(A, B, C) + num(A, B, D) - num(A, B, L)) << endl;
  return 0;
}


Measured memory_bytes: 256
#conding utf-8
x,y,z,k=map(int,input().split())
a=list(map(int,input().split())) 
b=list(map(int,input().split())) 
c=list(map(int,input().split())) 

ab=[]
ans=[]
for i in range(len(a)):
  for j in range(len(b)):
    ab.append(a[i]+b[j])
    
ab.sort()
ab.reverse()
del ab[k:]

c.sort()
c.reverse()

for i in range(len(ab)):
  for j in range(len(c)):
    ans.append(ab[i]+c[j])
    
ans.sort()
ans.reverse()

for i in range(k):
  print(ans[i])

Measured memory_bytes: 138384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int H, W;
    char S;
    string bom;

    cin >> H >> W;
    // 全体を'.'で囲って、後述の'#'の探索の際にatによるerrorを回避

    for(int i=0; i<H; i++){
        // 入力の最初に'.'のみの行がつくように修正
        if(i == 0){
            for(int j=0; j<W+2; j++){
                bom += '.';
            }
        }
        // 入力の前後に'.'のみの列がつくように修正
        for(int j=0; j<W; j++){
            if(j == 0){
                bom += '.';
            }   
            cin >> S;
            bom += S;
            if(j == W-1){
                bom += '.';
            }
        }
        // 入力の最後に'.'のみの行がつくように修正
        if(i == H-1){
            for(int j=0; j<W+2; j++){
                bom += '.';
            }
        }
    }

    /*
        Debug用で、入力の周囲に'.'が付いているか確認
        cout << bom << endl;
    */

    // '#'の検索する際に、周囲8マスの位置情報をvecotrとして格納。"-2"は行の前後に'.'をつけたのでその調整。
    int f0 = -W-1-2;
    int f1 = -W-2;
    int f2 = -W+1-2;
    int f3 = -1;
    int f4 = 1;
    int f5 = W-1+2;
    int f6 = W+2;
    int f7 = W+1+2;
    vector<int> vec = { f0, f1, f2, f3, f4, f5, f6, f7};

    int number = 0;
    // 0行目は'.'を追加したので、本来の入力はH(1)からスタート
    for(int i=1; i<=H; i++){
        // 0列目は'.'を追加したので、本来の入力はW(1)からスタート。終点はW列まで。
        for(int j=1+(2+W)*i; j<1+(2+W)*i+W; j++){
            // '#'にHITすれば数字は計算しないでいいので、次のループへ。
            if(bom.at(j) == '#'){
                cout << '#';
                continue;
            }
            // vectorを利用して'#'の有無を数字として格納し、最後に出力
            for(int k=0; k<vec.size(); k++){
                if(bom.at(j+vec.at(k)) == '#'){
                    number++;
                }
                if(k == vec.size()-1){
                    cout << number;
                    number = 0;
                }
            }
        }
        // i行目の出力終わりに改行
        cout << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int [][] List = new int[H+1][W+1];
        int [][] DP = new int[H+1][W+1];
        Arrays.fill(DP[0],0);
        Arrays.fill(List[0],0);
        for(int i=1;i<H+1;i++){
            Arrays.fill(DP[i],0);
            Arrays.fill(List[i],0);
            String s = sc.next();
            for(int j=1;j<W+1;j++){
                if(s.charAt(j-1)=='#'){
                    List[i][j] = 1;
                    DP[i][j]=-1;
                }
            }
        }
        DP[1][1]=1;
        for(int i=1;i<H+1;i++){
            for(int j=1;j<W+1;j++){
                if(DP[i][j]!=-1) {
                    if (DP[i][j - 1] != -1) {
                        DP[i][j] += DP[i][j - 1];
                        DP[i][j] %= 1000000007;
                    }
                    if (DP[i - 1][j] != -1) {
                        DP[i][j] += DP[i - 1][j];
                        DP[i][j] %= 1000000007;
                    }
                }
            }
        }
        System.out.println(DP[H][W]);
    }
}


Measured memory_bytes: 36788
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author TM
 */


#include <bits/stdc++.h>

using namespace std;

class B105 {
public:
  void solve(std::istream &cin, std::ostream &cout) {
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i < n + 1; i += 2) {
      int count = 0;
      for (int j = 1; j < i + 1; ++j) {
        if (i % j == 0)count++;
      }
      if (count == 8)ans++;
    }
    cout << ans << endl;
  }
};


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


Measured memory_bytes: 256
N = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(N):
    S = input()
    if S == 'AC':
        AC += 1
    elif S == 'WA':
        WA += 1
    elif S == 'TLE':
        TLE += 1
    elif S == 'RE':
        RE += 1
print('AC x ' + str(AC))
print('WA x ' + str(WA))
print('TLE x ' + str(TLE))
print('RE x ' + str(RE))

Measured memory_bytes: 9212
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>

typedef long long ll;
using namespace std;

bool in(int i,int j){
	if(i >= 0 && i<8 && j>=0 && j<8) return true;
	return false;
}

bool is_A(int i,int j,int table[8][8])
{
	if(table[i][j]==1
		&& in(i,j+1) && table[i][j+1]==1 
		&& in(i+1,j) && table[i+1][j]==1
		&& in(i+1,j+1) && table[i+1][j+1]==1
		) return true;

	return false;
}

bool is_B(int i,int j,int table[8][8])
{
	if(table[i][j]==1
		&& in(i+1,j) && table[i+1][j]==1 
		&& in(i+2,j) && table[i+2][j]==1
		&& in(i+3,j) && table[i+3][j]==1
		) return true;

	return false;
}

bool is_C(int i,int j,int table[8][8])
{
	if(table[i][j]==1
		&& in(i,j+1) && table[i][j+1]==1 
		&& in(i,j+2) && table[i][j+2]==1
		&& in(i,j+3) && table[i][j+3]==1
		) return true;

	return false;
}

bool is_D(int i,int j,int table[8][8])
{
	if(table[i][j]==1
		&& in(i,j+1) && table[i][j+1]==1 
		&& in(i-1,j+1) && table[i-1][j+1]==1
		&& in(i+1,j) && table[i+1][j]==1
		) return true;

	return false;
}

bool is_E(int i,int j,int table[8][8])
{
	if(table[i][j]==1
		&& in(i,j+1) && table[i][j+1]==1 
		&& in(i+1,j+1) && table[i+1][j+1]==1
		&& in(i+1,j+2) && table[i+1][j+2]==1
		) return true;

	return false;
}

bool is_F(int i,int j,int table[8][8]){
	if(table[i][j]==1
		&& in(i+1,j) && table[i+1][j]==1 
		&& in(i+1,j+1) && table[i+1][j+1]==1
		&& in(i+2,j+1) && table[i+2][j+1]==1
		) return true;

	return false;
}

bool is_G(int i,int j,int table[8][8]){
	if(table[i][j]==1
		&& in(i,j+1) && table[i][j+1]==1
		&& in(i+1,j-1) && table[i+1][j-1]==1
		&& in(i+1,j) && table[i+1][j]==1 		
		) return true;

	return false;
}

int main()
{
	int table[8][8];
	

	while(1){
		bool is_eof = false;
		memset(table,0,sizeof(table));
		for(int i=0;i<8;i++){
			char buf[32];
			if(scanf("%s",buf)==EOF){
				is_eof = true;
				break;
			}
			for(int j=0;j<8;j++){
				table[i][j]=buf[j]-'0';
			}
		}
		
		if(is_eof) break;

		for(int i=0;i<8;i++){
			for(int j=0;j<8;j++){
				if(is_A(i,j,table)){
					cout << 'A' << endl;
					goto found;
				}
				else if(is_B(i,j,table)){
					cout << 'B' << endl;
					goto found;
				}
				else if(is_C(i,j,table)){
					cout << 'C' << endl;
					goto found;
				}
				else if(is_D(i,j,table)){
					cout << 'D' << endl;
					goto found;
				}
				else if(is_E(i,j,table)){
					cout << 'E' << endl;
					goto found;
				}
				else if(is_F(i,j,table)){
					cout << 'F' << endl;
					goto found;
				}
				else if(is_G(i,j,table)){
					cout << 'G' << endl;
					goto found;
				}
			}
		}
found:;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
//typedef long long LL;
using namespace std;

int main(){
    int n;
    int tmp;
    int pos;
    vector<int> d;

    cin >> n;
    for(int i=0; i<n; i++){
        cin >> tmp;
        d.push_back(tmp);
    }

    sort(d.begin(), d.end());
    pos = n/2 - 1;
    cout << (d[pos+1] - d[pos]) << endl;
}

Measured memory_bytes: 892
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
ll k (ll a){
    a--;
    ll ans =0;
    while(a != 0){
        ans += a;
        a--;
        
    }
    return ans;
}


int main(){
    ll h;
    cin >> h;

    ll x = 1;
    ll ans = 0;
    for(int i = 1; i<100000; i++){
        ans += x;
        x *= 2;
        if(x > h){
            cout << ans <<endl;
            break;
        }
    }
    
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
using namespace std; using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
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;}
const ll INF = 1LL << 60;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll a,b,x;
    IN(a,b,x);
    if(a>0) cout << b/x - (a-1)/x << endl;
    else cout << b/x + 1 << endl;
}

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

int main() {
    auto query = [&]() {
        long long cur = 10;
        for (int i = 1; i <= 10; i++) {
            printf("? %lld\n", cur), fflush(stdout);
            char s[2]; scanf("%s", s);
            if (s[0] == 'N') return i;
            cur = cur * 10;
        }
        cur = 9;
        for (int i = 1; i <= 10; i++) {
            printf("? %lld\n", cur), fflush(stdout);
            char s[2]; scanf("%s", s);
            if (s[0] == 'Y') return i;
            cur = cur * 10 + 9;
        }
    };
    int len = query(), sum = 0;
    if (len == 10) printf("! %d\n", 1000000000), exit(0);
    for (int i = 1; i <= len; i++) {
        int l = (i == 1 ? 1 : 0), r = 9, pw = 1, ans = 0;
        for (int j = 1; i + j <= len; j++) pw *= 10;
        int tmp = i < len ? 9 : 0;
        for (int j = 1; i + j < len; j++) tmp = tmp * 10 + 9;
        while (l <= r) {
            int mid = (l + r) >> 1;
            printf("? %lld\n", (sum + mid * pw + tmp) * 10LL), fflush(stdout);
            char s[2]; scanf("%s", s);
            if (s[0] == 'Y') r = (ans = mid) - 1;
            else l = mid + 1;
        }
        sum += pw * ans;
    }
    printf("! %d\n", sum);
    return 0;
}

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

p=[3,13,23,43,53,
    73,83,103,113,163,
    173,193,223,233,263,
    283,293,313,353,373,
    383,433,443,463,503,
    523,563,593,613,643,
    653,673,683,733,743,
    773,823,853,863,883,
    953,983,1013,1033,1063,
    1093,1123,1153,1163,1193,
    1213,1223,1283,1303,1373]
for i in range(n):
    print(p[i],end=" ")

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

int main() {
	int a,b;
	cin>>a;
	cin>>b;
	if(b%2==0)
	{if(a>=13)
	cout<<b;
	else if(a>5&&a<13)
	cout<<b/2;
	else
	cout<<0;}
	return 0;
}

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

using Lint=long long;

Lint lcm(int a,int b)
{
   Lint res=1LL*a/__gcd(a,b)*b;
   return res;
}

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s, n) for(int i = s; i < n; ++i)
#define rep(i, n)		 REP(i, 0, n)
#define SORT(c)			 sort((c).begin(), (c).end())
#define IINF	INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
 
typedef long long				ll;
typedef pair <int, int> ii;
 
/*
struct point{
	ll x;
	ll y;
	point(){x = 0;y = 0;}
	point(ll x, ll y):x(x), y(y){}
};
*/

int main() {

	int w, h;
	while(cin >> w >> h, w, h){
		vector<ll> tate(w), yoko(h);
		map<ll, ii> mp;
		rep(i, w) {
			cin >> tate[i];
			mp[tate[i]].first++;
		}
		rep(i, h) {
			cin >> yoko[i];
			mp[yoko[i]].second++;
		}
		rep(i, w){
			ll tmp = tate[i];
			REP(j, i+1, w){
				tmp += tate[j];
				mp[tmp].first++;
			}
		}
		rep(i, h){
			ll tmp = yoko[i];
			REP(j, i+1, h){
				tmp += yoko[j];
				mp[tmp].second++;
			}
		}
		
		/*
		for(auto it = mp.begin(); it != mp.end(); ++it){
			cout << it-> first << "\t" << it->second.first << "\t" << it->second.second << endl;
		}
		cout << endl;
		*/
		
		ll ans = 0;
		for(auto it = mp.begin(); it != mp.end(); ++it){
			ans += (it->second.first * it->second.second);
		}
		
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 26808
// This amazing code is by Eric Sunli Chen.
#include<bits/stdc++.h>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

const int maxn=90;
const int mod=1e9+7;

LL f[maxn],q,a,b;

vector<pair<LL,LL> >fv[maxn];

int main()
{
	f[1]=1;for(int i=2;i<maxn;i++)f[i]=f[i-1]+f[i-2];
	
	fv[1].pb(mp(2ll,1ll));
	fv[1].pb(mp(3ll,1ll));
	for(int i=2;i<maxn;i++)
	{
		for(int j=0;j<(int)fv[i-1].size();j++)fv[i].pb(mp(fv[i-1][j].ff+fv[i-1][j].ss,fv[i-1][j].ff));
		fv[i].pb(mp(fv[i-1][0].ff*2+fv[i-1][0].ss,fv[i-1][0].ff));
		sort(fv[i].begin(),fv[i].end());
	}
	
	get1(q);
	while(q--)
	{
		get2(a,b);
		if(a>b)swap(a,b);
		int t;
		for(int i=1;i<maxn;i++)if(f[i-1]<=a&&f[i]<=b)t=i-2;else break;
		if(t==0)puts("1 1");
		else if(t==1)printf("1 %d\n",a*b%mod);
		else
		{
			int ans=0;t--;
			for(int i=0;i<(int)fv[t].size();i++)
			{
				LL tv;
				if(a>=fv[t][i].ff&&b>=fv[t][i].ss)
					ans=(ans+(b-fv[t][i].ss)/fv[t][i].ff)%mod;
				if(b>=fv[t][i].ff&&a>=fv[t][i].ss)
					ans=(ans+(a-fv[t][i].ss)/fv[t][i].ff)%mod;
			}
			printf("%d %d\n",t+1,ans);
		}
	}
	return 0;
}

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

public class Main {
	Scanner sc = new Scanner(System.in);
	int N, M;
	int INF = Integer.MAX_VALUE / 2;
	int[][] graph, memo;

	void run() {
		N = sc.nextInt(); // edge number
		M = sc.nextInt(); // vertex number
		graph = new int[N][N];
		memo = new int[N][1 << N];
		for (int i = 0; i < N; i++) {
			Arrays.fill(graph[i], INF);
			Arrays.fill(memo[i], -1);
		}
		for (int i = 0; i < M; i++) {
			int s = sc.nextInt();
			int t = sc.nextInt();
			int cost = sc.nextInt();
			graph[s][t] = cost;
		}
		int res = tsp(0, 1);
		System.out.println(res == INF ? -1 : res);
	}

	int tsp(int v, int mask) {
		if (memo[v][mask] != -1)  return memo[v][mask];
		if (mask == (1 << N) - 1) return graph[v][0];

		int res = INF;
		for (int i = 0; i < N; i++) {
			if ((mask & (1 << i)) != 0) continue;
			res = Math.min(res, graph[v][i] + tsp(i, mask | (1 << i)));
		}
		return memo[v][mask] = res;
	}

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


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

int main(){
    int n, m, count=0;
    cin >> n >> m;
    vector<int> a(m), b(m);
    for(int i=0; i<m; i++){
        cin >> a.at(i) >> b.at(i);
    }
    vector<int> p(n);
    for(int i=0; i<n; i++) p.at(i) = i+1;
    do{
        bool B;
        for(int i=0; i<n-1; i++){
            B=false;
            for(int j=0; j<m; j++){
                if((a.at(j) == p.at(i) && b.at(j) == p.at(i+1)) || (a.at(j) == p.at(i+1) && b.at(j) == p.at(i))){
                    B=true;
                    break;
                } 
            }
            if(!B) break;
        }
        if(B) count++;
    }while(next_permutation(p.begin()+1, p.end()));
    cout << count << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main{
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int pre = 0, curr = 1, ans = 0;
		boolean flag = false;
		while (num > 0) {
			curr = num % 10;
			if (pre == curr) {
				ans++;
				pre = curr;
			} else {
				ans = 1;
				pre = curr;
			}
			if (ans >= 3) {
				flag = true;
				break;
			}
			num /= 10;
 
		}
		System.out.println(flag == true ? "Yes" : "No");
	}
}

Measured memory_bytes: 23764