akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        // cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int a, b;
    cin >> a >> b;
    if (a <= b) {
        cout << a << endl;
    } else {
        cout << a - 1 << endl;
    }
    return 0;
}



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

using namespace std;

typedef long long LL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<LL> vl;
typedef vector<vector<LL>> vvl;
typedef vector<vector<vector<LL>>> vvvl;


const int inf = 1e9+7;
const LL INF = 1e18+5;
const int mod = 1e9+7;
const int mxN = 1e6+1;
const int mxM = 1e5+5;


int spf[mxN];
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<mxN; i++)
        spf[i] = i; 
    for (int i=4; i<mxN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<mxN; i++) 
    { 
        if (spf[i] == i) 
        { 
            for (int j=i*i; j<mxN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 

set<int> getFactorization(int x) 
{ 
    set<int> ret; 
    while (x != 1) 
    { 
        ret.insert(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
}


int getGCD(int a, int b) {
    return b ? getGCD(b, a % b) : a;
}

int main(){
    #ifndef ONLINE_JUDGE
    freopen("E:\\Coding\\Programming\\input.txt", "r", stdin);
    freopen("E:\\Coding\\Programming\\output.txt", "w", stdout);
    #endif
    sieve();
    map<int,int> mp;
    int n;
    cin>>n;
    vi a(n);
    for(int i=0;i<n;i++) cin>>a[i];

    bool pairWisePrime = true;
    bool setWisePrime = true;
    bool notPrime = true;

    for(int i=0;i<n;i++){
        set<int> f = getFactorization(a[i]);
        for(auto i:f){
            if(mp.find(i)!=mp.end()){
                pairWisePrime = false;
            }
            mp[i] = 1;
        }
    }

    if(!pairWisePrime){
        int gcd = a[0];
        for(int i=1;i<n;i++){
            gcd = getGCD(gcd,a[i]);
        }
        if(gcd!=1){
            setWisePrime = false;
        }
    }

    if(pairWisePrime){
        cout<<"pairwise coprime"<<endl;
    }else if(setWisePrime){
        cout<<"setwise coprime"<<endl;
    }else{
        cout<<"not coprime"<<endl;
    }
}


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

const int N = 100005;

int n, t, a[N];

int main() {
    ios::sync_with_stdio(false);

    cin >> n >> t;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int mx = 0;
    int diff = 0;
    int result = 0;
    for (int i = n - 1; i >= 0; --i) {
        if (a[i] > mx) {
            mx = a[i];
        } else {
            if (mx - a[i] > diff) {
                result = 1;
                diff = mx - a[i];
            } else
            if (mx - a[i] == diff) {
                ++result;
            }
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using uint1024_t = mp::uint1024_t;
using namespace std;


int main() {
	int n, k;
	cin >> n >> k;
	deque<int>a;
	vector<int>mod(k);
	if (k == 1) {
		cout << (ll)n*n*n << endl;
	}
	else {
		FOR(i, 1, n + 1) {
			if (i * 2 % k == 0) {
				mod[i%k]++;
			}
		}

		ll count = 0;
		count += (ll)mod[0] * mod[0] * mod[0];

		if (k % 2 == 0) {
			count += (ll)mod[k/2] * mod[k/2] * mod[k/2];
		}
		cout << count << endl;
	}
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}
#define int ll
int x, y, a, b, c;
vector<int> p, q, r;
void read() {
	cin >> x >> y >> a >> b >> c;
	p.resize(a);
	for (auto &i : p)
		cin >> i;
	sort(all(p));
	reverse(all(p));
	q.resize(b);
	for (auto &i : q)
		cin >> i;
	sort(all(q));
	reverse(all(q));
	r.resize(c);
	for (auto &i : r)
		cin >> i;
	sort(all(r));
	reverse(all(r));
}

priority_queue<int> B, C;

void wr(priority_queue<int> a) {
	while (!a.empty()) {
		cout << a.top() << " ";
		a.pop();
	}
	cout << endl;
}

int ans = 0;

void run() {
	int min_A = max(0LL, x - c);
	int fans = 0;
	for (int i = 0; i < min_A; i++)
		fans += p[i];
	for (int i = 0; i < x - min_A; i++) {
		C.push(-r[i]);
		fans += r[i];
	}
	//cout << "puhh" << endl;
	//cout << "min_A = " << min_A << endl;
	//wr(C);
	//cout << endl;
	for (int i = 0; i < y; i++) {
		if (B.size() < y && C.size() < r.size()) {
			int valQ = q[B.size()];
			int valR = r[C.size()];
			if (valQ < valR) {
				C.push(-valR);
				fans += valR;
			} else {
				B.push(-valQ);
				fans += valQ;
			}
		} else if (B.size() < y) {
			fans += q[B.size()];
			B.push(-q[B.size()]);
		} else {
			assert(C.size() < r.size());
			fans += r[C.size()];
			C.push(-r[C.size()]);
		}
	}
	//cout << "puhh" << endl;
	//wr(B);
	//wr(C);
	//cout << endl;
	chkmax(ans, fans);
	for (int i = min_A; i < x; i++) {
		fans += p[i];
		if (!B.empty() && (int)C.size() + i >= x) {
			int valB = -B.top();
			int valC = -C.top();
			if (valB < valC) {
				fans -= valB;
				B.pop();
			} else {
				fans -= valC;
				C.pop();
			}
		} else if (!B.empty()) {
			fans -= -B.top();
			B.pop();
		} else {
			assert((int)C.size() + i >= x);
			fans -= -C.top();
			C.pop();
		}
		/*(if (fans == 14) {
			cout << "out = " << endl; 
			cout << i << endl;
			wr(B);
			wr(C);
			exit(0);
		}*/
		chkmax(ans, fans);
	}
}

void write() {
	cout << ans << endl;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	read();
	run();
	write();
	return 0;
}

Measured memory_bytes: 4980
#include <iostream>

using namespace std;

int main(){
	
	int count[] = {0, 0, 0, 0};
	string s;
	cin >> s;
	
	for(int i = 0; i < s.size(); i++){
		for(int j = 0; j < s.size(); j++){
			if(s[i] == s[j]){
				count[i]++;
			}
		}
		if(count[i] != 0 && count[i] != 2){
			cout << "No" << endl;
			return 0;
		}
	}
	
	cout << "Yes" << endl;
	
	return 0;

}

Measured memory_bytes: 256
//Author- VMAX


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_multiset tree<long long , null_type,less_equal<long long >, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set tree<long long , null_type,less<long long >, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define ld     long double 
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define fo(i,a) for(i=1;i<=a;i++)
#define fa(i,a) for(auto i:a)
#define r(i,a) for(auto i=a.rbegin();i!=a.rend();i++)
#define en cout<<"\n";
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define F first
#define in insert
#define mp make_pair
#define S second
#define pre(n) cout<<fixed<<setprecision(n);
#define      gcd(a,b)    __gcd(a,b)
#define bs            binary_search
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define pi 3.14159265358979323846
#define all(x) x.begin(),x.end()
#define re return 0;
// *#######################################################################################*

/*
bool isp(ll n)
{
    ll i;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            return false;
        }
        
    }
}
  */      
       int main()
       
       {
        fast
        
        
        string s;
        cin>>s;
        ll i,f=0;
        f(i,s.size()-1)
        {
            if(s[i]==s[i+1])
            {
                f=1;
            }
        }
        if(f==0)
        {
            o("Good")
            re
        }
     
     o("Bad")
     
     
     
        
        
 
          re
}


Measured memory_bytes: 3656
import java.io.BufferedReader
import java.io.InputStreamReader

fun main() {
    val br = BufferedReader(InputStreamReader(System.`in`))
    var s = br.readLine()!!
    var mod = IntArray(2019, { 0 })
    var ans = 0
    for (i in 0 until s.length) {
        var tmp = IntArray(2019, { 0 })
        for (j in 0 until 2019) {
            if (mod[j] == 0) continue
            var nxt = (j * 10 + (s[i] - '0')) % 2019
            if (nxt == 0) ans += mod[j]
            tmp[nxt] = mod[j]
        }
        tmp[s[i] - '0']++
        mod = tmp
    }
    print(ans)
}

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

int main() {
  int n;
  int64_t  b;
  cin >> n;
  vector<int64_t> luca = {2,1};
  for (int i = 2; i <= n; i++) {
    b = luca.at(i-2) + luca.at(i-1);
    luca.push_back(b);
  }
  cout << luca.at(n) << endl;
}

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

using namespace std;

using ll = long long;

#define MOD_NUMBER 1000000007

template <class T> void vector_print(vector<T> vec) {
  for (unsigned int i = 0; i < vec.size(); i++) {
    cout << vec.at(i);
    if (i < vec.size()-1) {
      cout << " ";
    } else if (i == vec.size()-1) {
      cout << endl;
    }
  }
}

int main() {
  ll x1, x2, x3, x4, y1, y2, y3, y4;
  cin >> x1 >> y1 >> x2 >> y2;

  x3 = x2-(y2-y1);
  y3 = y2-(x1-x2);
  x4 = x3-(y3-y2);
  y4 = y3-(x2-x3);

  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

	N := nextInt()
	X := nextInt()

	min := 100000
	for i := 0; i < N; i++ {
		a := nextInt()
		X -= a

		if min > a {
			min = a
		}
	}

	fmt.Println(N + X / min)
}

Measured memory_bytes: 640
//Link : https://atcoder.jp/contests/cf16-final/tasks/codefestival_2016_final_f

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 302
#define mod 1000000007

int add(int x,int y) {
  int ret = x + y;
  if(ret >= mod) {
    ret -= mod;
  } else if(ret<0) {
    ret += mod;
  }
  return ret;
}

int mul(int x,int y) {
  return (ll)x*y%mod;
}

int dp[N][N][N];

int solveDp(int remEdge,int scc,int unused,int n) {
  if(remEdge==0) {
    if(scc==n) {
      return 1;
    } else {
      return 0;
    }
  }
  int &ret = dp[remEdge][scc][unused];
  if(ret!=-1) {
    return ret;
  }
  ret = 0;
  int remNode = n - scc- unused;
  if(remNode) {
    ret = add(ret, mul(remNode, solveDp(remEdge-1,scc,unused+1,n)));
  }
  ret = add(ret, mul(unused, solveDp(remEdge-1,scc,unused,n)));
  ret = add(ret, mul(scc, solveDp(remEdge-1,scc+unused,0,n)));

  return ret;
}
void solve() {
  int n,m;scanf("%d %d", &n,&m);
  memset(dp,-1,sizeof(dp));
  printf("%d\n", solveDp(m,1,0,n));
}

int main() {
    //freopen("input.txt","r",stdin);
    solve();
    return 0;
}


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

int main(){
    int A, B, C, N, M ,K;
    int a[6];
    int c[4]={};

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

    for(int i = 0; i < 6; i++){
        if(1==a[i]) c[0]++;
        else if(2==a[i]) c[1]++;
        else if(3==a[i]) c[2]++;
        else if(4==a[i]) c[3]++;
    }

    if(c[0]<3 && c[1]<3 && c[2]<3 && c[3]<3)cout << "YES" << endl;
    else cout << "NO" << endl;

}

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

const ll MOD = 1000000007;

int main(){
  ll n;cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a.at(i);

  ll ans = 0;
  rep(i,60){
    ll x = 0;
    // 与数字のi桁目が1である個数を求める
    rep(j,n) if( a.at(j) >> i & 1 ) ++x;
    // i桁目が1の個数(=x)と0の個数(=n-x)の積
    // xor では 0 ^ 1 = 1 なので
    // i桁目の0と1の組み合わせの総数が、
    // 答えのi桁目になる。
    ll now = x*(n-x)%MOD;
    // 桁を合わせる
    rep(j,i) now = now*2%MOD;
    ans += now;
    ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5604
#include <iostream>
#include <vector>
#include <algorithm>
#define int long long
using namespace std;

signed main() {
  int N, cnt = 0; cin >> N;
  vector<int> A(N), B(N), D(N);
  int as = 0, bs = 0, S = 0;
  for(int i = 0; i < N; ++i) {
    cin >> A[i];
    as += A[i];
  }
  for(int i = 0; i < N; ++i) {
    cin >> B[i];
    bs += B[i];
    if(A[i] < B[i]) cnt++, S += B[i] - A[i];
    D[i] = A[i] - B[i];
  }
  if(as < bs) {
    std::cout << -1 << std::endl;
    return 0;
  }
  if(cnt == 0) {
    std::cout << 0 << std::endl;
    return 0;
  }
  sort(D.begin(), D.end());
  reverse(D.begin(), D.end());
  int tmp = 0;
  for(int i = 0; i < N; ++i) {
    tmp += D[i];
    if(S <= tmp) {
      std::cout << cnt + i + 1 << std::endl;
      return 0;
    }
  }
  return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << fixed << setprecision(15);
    //freopen("input.txt", "r", stdin);
    int n, x, y;
    cin >> n >> x >> y;
    cout << min(x, y) << ' ' << max(0, x + y - n);
}


Measured memory_bytes: 256
h, n = map(int, input().split())
magic = [0]*(h+1)
for i in range(n):
    a, b = map(int, input().split())
    for j in range(h+1):
        if (magic[j] or j == 0):
            if j == h:
                continue
            key = min([j+a, h])
            if magic[key] == 0:
                magic[key] = magic[j] + b
            else:
                magic[key] = min([magic[key], magic[j]+b])
print(magic[h])


Measured memory_bytes: 46756
void main(){
	string[] val = inln!string();
	writeln( (val[0]=="H")^(val[1]=="H")?'D':'H');
}
     
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;      
// 1要素のみの入力
T inelm(T= int)(){
	return to!(T)( readln().chomp() );
}
     
// 1行に同一型の複数入力
T[] inln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split())ln ~= elm.to!T();
	return ln;
}


Measured memory_bytes: 2560
"use strict"
function main(input) {

	let tmp = null
	let boo = false
	//let i = 0

	input = input.split('\n')
	input[0] = input[0].split('')
	input[1] = input[1].split('')

	for(let i=0;i<input[0].length;i++)
	//while(boo == false || i < input[0].length )
	{
		tmp = input[0].shift()
		input[0].push(tmp)
		if(input[0].join('')==input[1].join(''))
		{
			boo = true
			console.log('Yes')
			break
		}else{

		}
		//i++

	}
	if(!boo) console.log('No')

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



Measured memory_bytes: 11340
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

int main() {
    string s;
    cin >> s;
    ll l = s.length();
    ll *dp = new ll[l+1];
    dp[l] = 0;
    ll p = 1;
    for (int i = l-1; i >= 0; i--) {
        dp[i] = dp[i+1] + (s[i]-'0')*p;
        dp[i] %= 2019;
        p*=10;
        p%=2019;
    }

    map<ll, ll> m;
    for (int i = 0; i <= l; i++)
        m[dp[i]]++;

    ll ans = 0;
    for (auto ite = m.begin(); ite != m.end(); ite++)
        ans += (*ite).second * ((*ite).second-1) / 2;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5292
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1000000007;
const ll INF=2e18;

ll H,W,C;
queue<P> edgeQ;
queue<P> nowColorQ;
const ll dh[4]={0,1,0,-1};
const ll dw[4]={1,0,-1,0};
bool checked[10][10];
ll p[10][10];
void UpdateEdgeQ(ll color,ll& ans){
    vector<P> returnToEdgeQ;
    while(!edgeQ.empty()){
        P now=edgeQ.front();edgeQ.pop();
        ll nh=now.first;
        ll nw=now.second;
        if(p[nh][nw]==color && !checked[nh][nw]){
            nowColorQ.push(now);
            checked[nh][nw]=true;
            ans++;
        }else{
            returnToEdgeQ.push_back(now);
        }
    }
    for(auto p:returnToEdgeQ){
        edgeQ.push(p);
    }
    while(!nowColorQ.empty()){
        P now=nowColorQ.front();nowColorQ.pop();
        ll nh=now.first;
        ll nw=now.second;
        for(ll i=0;i<4;i++){
            ll h=nh+dh[i];
            ll w=nw+dw[i];
            if(0<=h&&h<H && 0<=w&&w<W && !checked[h][w]){
                if(p[h][w]==color){
                    nowColorQ.push(P(h,w));
                    checked[h][w]=true;
                    ans++;
                }else{
                    edgeQ.push(P(h,w));
                }
            }
        }
    }
}
ll Solve(vector<ll>& changedColor){
    if(changedColor.size()==4){
        changedColor.push_back(C);
        for(ll i=0;i<H;i++){
            for(ll j=0;j<W;j++){
                checked[i][j]=false;
            }
        }
        edgeQ.push(P(0,0));
        ll ret=0;
        UpdateEdgeQ(p[0][0],ret);
        for(auto c:changedColor){
            UpdateEdgeQ(c,ret);
        }
        while(!edgeQ.empty()){
            edgeQ.pop();
        }
        changedColor.pop_back();
        return ret;
    }
    
    ll ret=0;
    for(ll i=1;i<=6;i++){
        if(changedColor.size()!=0 && i==changedColor[changedColor.size()-1])continue;
        changedColor.push_back(i);
        ret=max(ret,Solve(changedColor));
        changedColor.pop_back();
    }
    return ret;
}
int main(){
    while(cin>>H>>W>>C,H!=0){
        vector<ll> changedColor;
        changedColor.reserve(5);
        for(ll i=0;i<H;i++){
            for(ll j=0;j<W;j++){
                cin>>p[i][j];
            }
        }
        cout<<Solve(changedColor)<<endl;
    }
    return 0;
}



Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vi A, B;
string S, T;

void input() {
  cin >> N;
  A.resize(N);
  rep(i, 0, N - 1) { cin >> A[i]; }
  int x, y, z;
  ;
}
void solve() {
  // == 2の倍数*２の倍数  OR 4の倍数*任意
  int yon = 0, ni = 0;
  for (auto x : A) {
    if (x % 4 == 0)
      yon++;
    else if (x % 2 == 0)
      ni++;
  }

  int ki = N - yon - ni;

  bool ans;

  ans = yon + 1 >= ki + (ni ? 1 : 0);
  cout << (ans ? "Yes" : "No") << endl;

  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 1024
n=int(input())
a=[]
b=[]
c=[]
d=[]
for i in range(n):
    k,l=map(int,input().split())
    a.append((k-l,i))
    b.append((k+l,i))
    c.append((-k-l,i))
    d.append((-k+l,i))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
d.sort(reverse=True)
print(max(a[0][0]+d[0][0],b[0][0]+c[0][0]))

Measured memory_bytes: 98268
#include <stdio.h>
#define N 1000
#define MIN 1000000
   int main(){
  int i,j,n,min,a,b,c;
  int x[N][N],y[N],z[N];
    
  scanf("%d",&n);
    
  for(i=0;i<n;i++){
    y[i]=0;
    z[i]=MIN;
    for(j=0;j<n;j++) x[i][j]=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&a,&b);
    for(j=0;j<b;j++){
      scanf("%d",&c);
      scanf("%d",&x[a][c]);
    }
  }
  z[0]=0;
  while(1){
    min=MIN;
    for(i=0;i<n;i++){
      if(y[i]!=1&&z[i]<min){
        min=z[i];
        a=i;
      }
    }
    
    if(min==MIN) break;
    for(i=0;i<n;i++){
      if(x[a][i]!=(-1) && y[i]!=1 && z[a]+x[a][i]<z[i]) z[i]=z[a]+x[a][i];
    }
    y[a]=1;
  }
  for(i=0;i<n;i++) printf("%d %d\n",i,z[i]);
  return 0;
}

Measured memory_bytes: 996
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define fr(i,l,r) for(int i=l;i<=r;i++)
signed main()
{  // freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int a[n+1];
    int b[n];
    for(int i=0;i<n+1;i++)
    {
    	cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {
    	cin>>b[i];
    }
    
    int ans=0;

    for(int i=0;i<n;i++)
    {
    	int mini=min(a[i],b[i]);
    	ans+=mini;
    	a[i]-=mini;
    	b[i]-=mini;
    	int mini2=min(b[i],a[i+1]);
    	ans+=mini2;
    	a[i+1]-=mini2;
    	b[i]-=mini2;
    }
  cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<algorithm>
#define ll long long
using namespace std;

ll n,m;
ll tot=0;
ll head[500005],dis[500005],vis[500005],f[500005];
struct pp
{
	ll v,w,nxt;
}e[1000005];
queue <ll> q;

ll read()
{
	ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}

void add(ll u,ll v,ll w)
{
	e[tot].v=v;
	e[tot].w=w;
	e[tot].nxt=head[u];
	head[u]=tot++;
}

void in()
{
	n=read();m=read();
	for(int i=1;i<=m;++i)
	{
		ll u=read(),v=read(),w=read();
		add(u,v,w);
		add(v,u,-w);
	}
}

bool spfa(ll s)
{
	q.push(s);
	f[s]=1;
	dis[s]=0;
	ll maxx=0,minn=0;
	while(!q.empty())
	{
		ll u=q.front();
		q.pop();
		
		for(int i=head[u];i!=-1;i=e[i].nxt)
		{
			ll v=e[i].v;
			if(dis[v]==12345678987654321)
			{
				dis[v]=dis[u]+e[i].w;
				maxx=max(maxx,dis[v]);
				minn=min(minn,dis[v]);
				if(maxx-minn>1000000000)
				return false;
				vis[v]=1;
				if(!f[v])
				{
					q.push(v);
					//f[v]=1;
				}
			}
			else if(dis[v]!=dis[u]+e[i].w)
			{
				return false;
			}
		}
		f[u]=0;
	}
	return true;
}

void work()
{
	for(int i=1;i<=n;++i)
	{
		if(!vis[i])
		{
			vis[i]=1;bool flag=spfa(i);
			if(flag==false)
			{
				printf("No\n");
				return ;
			}
		}
	}
	printf("Yes\n");
}

int main()
{
	memset(head,-1,sizeof(head));
	for(int i=0;i<500005;++i)
	dis[i]=12345678987654321;
	in();
	work();
	return 0;
}

Measured memory_bytes: 23680
S = input()
idx = 1
count = 0
S_b = S[0]

while True:
    if idx >= len(S):
        break
    S_a = S[idx]
    if S_a == S_b:
        count += 1
        S_b = S[idx:idx+2]
        idx += 2
    else:
        S_b = S_a
        idx += 1
print(len(S)-count)

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

bool is_prime(int x){
    if (x == 2) return true;
    if (x < 2 || x % 2 == 0) return false;
    //合成数を調べる
    int i = 3;
    while(i <= pow(x, (float)1/2)){
        if (x % i == 0) return false;
        i += 2;
    }
    return true;
}

int main(){
    int n, j, ans = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> j;
        if(is_prime(j) == true) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
	int x, y;
	cin >> x >> y;
	if (y >= 2 * x && y <= 4 * x && y % 2 == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

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

int month[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};

int main(){
    int m,d;

    while(cin>>m>>d,m){
        for(int i=1;i<m;i++)d+=month[i];
        d=(d-1)%7+1;
        string ans;
        switch((d+2)%7){
        case 0:ans="Monday";break;
        case 1:ans="Tuesday";break;
        case 2:ans="Wednesday";break;
        case 3:ans="Thursday";break;
        case 4:ans="Friday";break;
        case 5:ans="Saturday";break;
        case 6:ans="Sunday";break;
        }

        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1184
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

ll dp[55][35];
bool ok[55][35];

int main() {
	int n, m, t;
	while (cin >> n,n)
	{
		int s=-1;
		rep(i, 31) {
			rep(j, n) {
				dp[j][i] = 0;
				ok[j][i] = false;
			}
		}
		
		for (int i = 0; i < n; i++) {
			cin >> m;
			for (int j = 0; j < m; j++) {
				cin >> t;
				ok[i][t] = true;
			}
		}

		rep(i, n) {
			dp[i][0] |= 1ll << i;
		}
		for (int j = 1; j < 31;j++) {
			rep(i, n) {
				if (ok[i][j] == true) rep(k, n) {
					if (ok[k][j] == true) {
						dp[i][j] |= dp[k][j-1];
					}
				}
				else dp[i][j] |= dp[i][j-1];
			}
		}
		rep(j, 31) {
			rep(i, n) {
				if (dp[i][j] == (1ll << n) - 1) {
					s = j; goto end;
				}
			}
		}

	end:
		cout << s << endl;
	}

}

Measured memory_bytes: 1172
#import <iostream>
#import <algorithm>
using namespace std;

int main(){
	int d[3],sum,tyokkaku=0,eikaku=0,donnkaku=0;
	while(true){
		for(int i=0;i<3;i++)cin>>d[i];
		sort(d,d+3);
		if(d[2]>=d[0]+d[1])break;
		else if(d[2]*d[2]==d[0]*d[0]+d[1]*d[1])tyokkaku++;
		else if(d[2]*d[2]<d[0]*d[0]+d[1]*d[1])eikaku++;
		else donnkaku++;
	}
	sum=tyokkaku+eikaku+donnkaku;
	cout<<sum<<" "<<tyokkaku<<" "<<eikaku<<" "<<donnkaku<<endl;
	return 0;
}


Measured memory_bytes: 3160
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var Ts = ReadIntArray();
            var M = ReadInt();
            var sum = Ts.Sum();
            List<int> rets = new List<int>();
            for (int i = 0; i < M; i++)
            {
                var PX = ReadIntArray();
                var ret = sum - Ts[PX[0] - 1] + PX[1];
                rets.Add(ret);
            }

            foreach (var ret in rets)
            {
                Console.WriteLine(ret);
            }
        }

        private static readonly Func<string> Read = () => Console.ReadLine();
        private static readonly Func<string[]> ReadStringArray = () => Console.ReadLine().Split();
        private static readonly Func<int> ReadInt = () => int.Parse(Console.ReadLine());
        private static readonly Func<long> ReadLong = () => long.Parse(Console.ReadLine());
        private static readonly Func<int[]> ReadIntArray = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
        private static readonly Func<long[]> ReadLongArray = () => Console.ReadLine().Split().Select(long.Parse).ToArray();
        private static readonly Action<string> Cw = str => Console.WriteLine(str);
    }
}

Measured memory_bytes: 13396
// practice with Dukkha
#include <algorithm>
#include <iostream>
#include <cstdlib>

using namespace std;

const int N = 50, M = 100, A = 50, MD = N * A + 1;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;

int oo[N], *oh[N];
int ij[M + N], aa[M + N], bb[M + N];
int pq[N * MD], iq[1 + N * MD], cnt;
long long dd[N * MD];

void init(int n) {
	for (int i = 0; i < n; i++)
		oh[i] = (int *) malloc(2 * sizeof *oh[i]);
}

void link(int i, int h) {
	int o = oo[i];
	if (o >= 2 && (o & o - 1) == 0)
		oh[i] = (int *) realloc(oh[i], (o << 1) * sizeof *oh[i]);
	oh[i][oo[i]++] = h;
}

bool lt(int i, int j) {
	return dd[i] < dd[j];
}

int p2(int p) {
	return (p *= 2) > cnt ? 0 : p < cnt && lt(iq[p + 1], iq[p]) ? p + 1 : p;
}

void pq_up(int i) {
	int j, p, q;
	for (p = pq[i]; (q = p / 2) > 0 && lt(i, j = iq[q]); p = q)
		iq[pq[j] = p] = j;
	iq[pq[i] = p] = i;
}

void pq_dn(int i) {
	int j, p, q;
	for (p = pq[i]; (q = p2(p)) > 0 && lt(j = iq[q], i); p = q)
		iq[pq[j] = p] = j;
	iq[pq[i] = p] = i;
}

void pq_add_last(int i) {
	iq[pq[i] = ++cnt] = i;
}

int pq_remove_first() {
	int i = iq[1], j = iq[cnt--];
	if (j != i)
		pq[j] = 1, pq_dn(j);
	pq[i] = 0;
	return i;
}

int main() {
	int n, m, s; cin >> n >> m >> s;
	init(n);
	for (int h = 0; h < m; h++) {
		int i, j, a, b; cin >> i >> j >> a >> b, i--, j--;
		ij[h] = i ^ j;
		aa[h] = -a;
		bb[h] = b;
		link(i, h);
		link(j, h);
	}
	for (int h = m, i = 0; i < n; h++, i++) {
		cin >> aa[h] >> bb[h];
		link(i, h);
	}
	int md = n * A + 1;
	s = min(s, md - 1);
	fill(dd, dd + n * md, INF);
	dd[s] = 0, pq_add_last(s);
	while (cnt) {
		int u = pq_remove_first();
		int i = u / md; s = u % md;
		for (int o = 0; o < oo[i]; o++) {
			int h = oh[i][o];
			int j = i ^ ij[h];
			int t = s + aa[h];
			if (t < 0)
				continue;
			t = min(t, md - 1);
			int v = j * md + t;
			long long d = dd[u] + bb[h];
			if (dd[v] > d) {
				if (dd[v] == INF)
					pq_add_last(v);
				dd[v] = d, pq_up(v);
			}
		}
	}
	for (int i = 1; i < n; i++) {
		long long d = INF;
		for (s = 0; s < md; s++) {
			int u = i * md + s;
			d = min(d, dd[u]);
		}
		cout << d << '\n';
	}
	return 0;
}


Measured memory_bytes: 5232
# 曜日と時間帯の組み合わせを1111111111の10ビットで全探索

import sys
readline = sys.stdin.readline

N = int(readline())
F = [None] * N
for i in range(N):
  F[i] = int(readline().rstrip().replace(" ",""),2)
    
P = [None] * N
for i in range(N):
  P[i] = list(map(int,readline().split()))
  
ans = -(10 ** 10)
for i in range(1, 2 ** 10):
  # joisinoが営業する時間帯の文字列11011101
  # 各店について、店jとANDを取って、1ビットの数を数えるとCが分かる
  point = 0
  for j in range(N):
    # 店j
    debug = False
    c = bin(i & F[j])[2:].count("1")
    point += P[j][c]
  if ans < point:
    ans = point
  
print(ans)


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

int main() {
  int n; cin >> n;
  vector<int> arr(n);
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
    sum += arr[i];
  }
  int m; cin >> m;
  for (int i = 0; i < m; ++i) {
    int p, x;
    cin >> p >> x;
    cout << sum - arr[p - 1] + x << endl;
  }
}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
n = int(input())
a = list(map(int, input().split()))
a.sort()
a.reverse()
tate = 0
yoko = 0
now = 0
#print(a)
for i in a:
    if tate == 0:
        if now == i:
            tate = now
            now = 0
            continue
    else:
        if now == i:
            yoko = now
            break
    now = i

print(tate * yoko)


Measured memory_bytes: 14224
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(' ');
            var a = double.Parse(inputs[0]);
            var b = double.Parse(inputs[1]);
            var x = double.Parse(inputs[2]);

            // 三角柱の高さ
            var height = a;
            // 三角柱の底面の 2 辺
            var line1 = b;
            var line2 = ((x / height) * 2) / line1;
            
            if (line2 > a)
            {
                // このときは底面が台形
                var bottom = line1;
                var top = (((x / height) * 2) / a) - bottom;
                var virtualLine = top * a / (bottom - top);
                line2 = a + virtualLine;
            }

            var rad = Math.Atan(line1 / line2);
            Console.WriteLine(rad * 360 / (2 * Math.PI));
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#include <assert.h>
#include <bitset>
#define Endl endl
#define mp make_pair
#define ll long long 
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define quickcin ios_base::sync_with_stdio(false);
const int mod=1e9+7;
const int inf=1039074182;
const ll llinf=1LL*inf*inf;
using namespace std;
template <typename T1,typename T2> inline void chmin(T1 &x,T2 b) {if(b<x) x=b;}
template <typename T1,typename T2> inline void chmax(T1 &x,T2 b) {if(b>x) x=b;}
template <typename T1,typename T2> inline void chadd(T1 &x,T2 b) {x+=b;if(x>=mod) x-=mod;}
template <typename T1,typename T2> inline void chmul(T1 &x,T2 b) {x=1LL*x*b%mod;}
template <typename T1,typename T2> inline void chmod(T1 &x,T2 b) {x%=b,x+=b;if(x>=b) x-=b;}
const int basis=1;
int dp[305][305][305];
int n,m;
vector <pair<int,int> > ed[305];

int dfs(int x,int y,int z)
{
	if(y>z) swap(y,z);
	if(x>y) swap(x,y);
	if(y>z) swap(y,z);
//	assert(x<y);
//	assert(y<z);
	if(dp[x+basis][y+basis][z+basis]!=-1) return dp[x+basis][y+basis][z+basis];
	int &res=dp[x+basis][y+basis][z+basis];
	res=0;
	for(auto &o:ed[z+1])
	{
		int l=o.first,c=0;
		if(z>=l) c++;
		if(y>=l) c++;
		if(x>=l) c++;
		if(c!=o.second) return res=0;
	}
	if(y<z-1) return res=dfs(x,y,z-1);
	chadd(res,dfs(-1,x,y));
	for(int i=0;i<y;i++)
	{
		if(i==x) continue;
		chadd(res,dfs(x,y,i));
	}
	return res;
}

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>n>>m;
	memset(dp,-1,sizeof(dp));
	for(int q=0;q<m;q++)
	{
		int l,r,c;
		cin>>l>>r>>c;
		l--;
		ed[r].push_back(mp(l,c));
	}
	dp[0][0][0]=1;
	int res=0;
	for(int i=-1;i<n;i++)
	{
		for(int j=-1;j<n;j++)
		{
			for(int k=-1;k<n;k++)
			{
				if(max({i,j,k})!=n-1) continue;
				if(i==j && i!=-1) continue;
				if(i==k && i!=-1) continue;
				if(j==k && j!=-1) continue;
				chadd(res,dfs(i,j,k));
			}
		}
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 114476
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define FT() int t; scanf("%d",&t); while(t--)
#define pb push_back
#define nl printf("\n")
#define fi(i,start,end) for(int i=start; i < (int)end ; ++i)
#define ip(n)   scanf("%d",&n)
#define mz(a)   memset(a,0,sizeof(a))
#define inpArr(A,n) fi(i,0,n)   ip(A[i]);
#define print(a)  for(auto i : a)   cout<<i<<" "; nl;
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
ll max(ll a,ll b)   {return a>b?a:b;}
ll min(ll a,ll b)   {return a<b?a:b;}

int main() {
    #ifndef ONLINE_JUDGE
    freopen("D:/Sublime/Rough/input.txt","r",stdin);
    #endif
    //std::cout << std::fixed;
    //std::cout << std::setprecision(6);
    Fastio;
    
    string s;
    cin>>s;
    int n = s.length();
    if(s[n-1] == 's')
    {
        s+='e';
        s+='s';
    }
    else
        s+='s';
    cout<<s;

    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
    #endif
    
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <climits>
#include <algorithm>
using namespace std;

// 入力
int n, W;
int weight[110], value[110];

// DPテーブル
int dp[110][10010];

int main() {
  cin >> n >> W;
  for (int i = 0; i < n; ++i) cin >> value[i] >> weight[i];

  // DP初期条件: dp[0][w] = 0
  for (int w = 0; w <= W; ++w) dp[0][w] = 0;

  // DPループ
  for (int i = 0; i < n; ++i) {
    for (int w = 0; w <= W; ++w) {
      if (w >= weight[i]) dp[i+1][w] = max(dp[i][w-weight[i]] + value[i], dp[i][w]);
      else dp[i+1][w] = dp[i][w];
    }
  }

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


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>S;
	int ret=0;
	for(i=1;i<=N-1;i++) {
		int cnt[256][2]={};
		string A=S.substr(0,i);
		string B=S.substr(i);
		
		FORR(c,A) cnt[c][0]=1;
		FORR(c,B) cnt[c][1]=1;
		x=0;
		FOR(y,256) x+=cnt[y][0]*cnt[y][1];
		ret=max(ret,x);
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
n = int(input())
a = tuple(map(str, input()))
b = tuple(map(str, input()))
c = tuple(map(str, input()))
ans = 2*n
for i in range(n):
    if a[i] == b[i] == c[i]:
        ans -= 2
        continue
    elif a[i] == b[i] or b[i] == c[i] or c[i] == a[i]:
        ans -= 1
print(ans)

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

int main()
{
    int n,m,q;
    std::cin >> n >> m >> q;
    std::vector<std::vector<int>> sum(n + 1,std::vector<int>(n + 1)), a(n,std::vector<int>(n)); // left / right
    for(int i = 0; i < m; i++){
        int t,k; std::cin >> t >> k;
        t--; k--;
        a[t][k]++;
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            sum[i + 1][j + 1] = sum[i][j + 1] + sum[i + 1][j] - sum[i][j] + a[i][j];
        }
    }

    std::vector<int> l(q), r(q);
    for(int i = 0; i < q; i++)std::cin >> l[i] >> r[i];




    for(int i = 0; i < q; i++){
        std::cout << sum[r[i]][r[i]] - sum[l[i] - 1][r[i]] - sum[r[i]][l[i] - 1] + sum[l[i] - 1][l[i] - 1] << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define s second
#define f first
long long const mod = 1000000007;
#define inf 1000000000000000000
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod)+mod)%mod;}
inline ll mul(ll a, ll b){ return (((a%mod)*(b%mod))%mod+mod)%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

ll power(ll x,ll y,ll m)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m;
    return (y%2 == 0)? p : (x * p) % m;
}

ll modInv(ll x)
{
    return power(x,mod-2,mod)%mod;
}



int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    ll k;
    cin>>k;
    cout<<a[k-1]<<endl;
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict,Counter
N = input()
Ndic = defaultdict(int)
Mdic = defaultdict(int)
for i in range(int(N)):
    s = input()
    Ndic[s] += 1
M = input()
for j in range(int(M)):
    t = input()
    Mdic[t] += 1

ans = []
c = Counter(Ndic)
for k,v in c.most_common(1):
    mans = v
for k,v in c.most_common():
    if k in Mdic:
        ans.append(Ndic[k]-Mdic[k])
    else:
        ans.append(Ndic[k])

if ans:
    print(max(max(ans),0))
else:
    print(mans)

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

using namespace std;

// Union-Find木
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) {
            par[i] = i;
        }
    }

    int root(int x) { // データxが属する木の根を再帰で得る
        if (par[x] == x) {
            return x;
        }

        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) {
            return; //xとyの根が同じ(=同じ木にある)時はそのまま
        }

        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    vector<vector<int>> graph(N, vector<int>(N, 0));
    int count = 0;

    vector<int> a(M), b(M);

    for(int i = 0; i < M; i++) {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
    }

    // それぞれの辺について取り除く
    for(int i = 0; i < M; i++) {
        UnionFind U(N);

        // それ以外の辺で繋がれる頂点を併合する
        for(int j = 0; j < M; j++) {
            if(j == i) {
                continue;
            }

            U.unite(a[j], b[j]);
        }

        // 取り除いた辺で繋がれる頂点が連結されているか判断する
        if(U.same(a[i], b[i]) == false) {
            count++;
        }
    }

    cout << count << endl;
	return 0;
}

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

typedef long long ll;

int main()
{
  ll n;
  cin>>n;
  ll a[n];
  for(int i=0;i<n;i++)
   	cin>>a[i];
  ll sum=0;
  for(int i=1;i<n;i++)
  {
    sum+=max(0*1LL,a[i-1]-a[i]);
    //cout<<a[i-1]-a[i]<<" ";
    // cout<<sum<<endl;
    a[i]=max(a[i-1],a[i]);
  }
  cout<<sum<<endl;
  return 0;
}
  

Measured memory_bytes: 5100
#include <iostream>
using namespace std;
 
int main() {
  int n, A[100];
  cin >> n;
  for (int i = 0; i < n ; i++) {
    cin >> A[i];
  }
  for (int i = n-1; 0 <= i ; i-- ) {
    cout << A[i];
    if (i != 0) {cout << " ";}
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3080
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

    public static void main(String[] args) throws IOException {

        ArrayList<Integer> x = new ArrayList<>();
        ArrayList<String> st = new ArrayList<>();
        ArrayList<Integer> y = new ArrayList<>();

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        while (true) {
            
            String[] line = br.readLine().split(" ");
            if ("?".equals(line[1])) {
                break;
            }
            x.add(Integer.parseInt(line[0]));
            st.add(line[1]);
            y.add(Integer.parseInt(line[2]));

        }

        for (int i = 0; i < x.size(); i++) {
            if ("+".equals(st.get(i))) {
                System.out.println(x.get(i) + y.get(i));
            }

            if ("-".equals(st.get(i))) {
                System.out.println(x.get(i) - y.get(i));
            }

            if ("*".equals(st.get(i))) {
                System.out.println(x.get(i) * y.get(i));
            }

            if ("/".equals(st.get(i))) {
                System.out.println(x.get(i) / y.get(i));
            }
        }

    }

}

Measured memory_bytes: 24496
#include <iostream>
#include <algorithm>
#include <climits>

using namespace std;

int dp[2][1 << 22];

int main(void){
	while(1){
		int n, m; cin >> n >> m;
		if(!n && !m) break;

		int b[505][505]={0};
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				char c; cin >> c;
				b[i][j] = c - '0';
			}
		}

		int ans = 0;
		if(n <= 22){
			int S = 1 << n;
			for(int i=0; i<S; i++){
				int cnt = 0;
				int ingredient[501]={0};//材料
				for(int j=0; j<n; j++){
					if((i & (1<<(j))) == 0) continue;
					cnt++;
					for(int k=0; k<m; k++) ingredient[k] ^= b[j][k];
				}
				bool flag = true;
				for(int j=0; j<m; j++){
					if(ingredient[j] == 1){
						flag = false;
						break;
					}
				}
				if(flag) ans = max(ans, cnt);
			}
		}else{
			int B[501]={0};
			for(int i=0; i<n; i++){
				for(int j=0; j<m; j++){
					B[i] |= (b[i][j] << j);
				}
			}

			int S = 1 << m;
			fill(dp[0], dp[2], INT_MIN);
			dp[0][0] = 0;
			for(int i=0; i<n; i++){
				for(int j=0; j<S; j++){
					dp[(i+1)%2][j^B[i]] = max(dp[(i+1)%2][j^B[i]], dp[i%2][j] + 1);
					dp[(i+1)%2][j] = max(dp[(i+1)%2][j], dp[i%2][j]);
				}
			}
			ans = dp[n%2][0];
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 36844
s1 = input()
s2 = input()
dic = {}
for i in range(len(s1)):
    if not s1[i] in dic:
        dic[s1[i]] = s2[i]
    else:
        if dic[s1[i]] != s2[i]:
            print('No')
            quit()
#print('Yes')
if len(dic) != len(set(dic.values())):
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

int w, h;
void dfs(VVI &c,int y, int x){
    c[y][x] = 0;

    for (int dy : {-1, 0, 1})
        for (int dx : {-1, 0, 1}){
            int ny = y + dy, nx = x + dx;
            if (nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
            if (c[ny][nx] == 0) continue;

            dfs(c, ny, nx);
        }
}


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

while (1){
    cin >> w >> h;
    if (w == 0 && h == 0) return 0;
    VVI c(h, VI(w));
    rep(i, 0, h) rep(j, 0, w) cin >> c[i][j];
    int cnt = 0;

    rep(y, 0, h) rep(x, 0, w){
        if (c[y][x] == 0) continue;
        dfs(c, y, x);
        ++cnt;
    }
    cout << cnt << "\n";
}
}

// 境界，出力文字列 チェック
// まずは全探索，次にDP
// 制限を見る
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり




Measured memory_bytes: 3324