akhauriyash/Code-Regression huggingface dataset:
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    char a,b;
    cin >> a>>b;
    if(a==b)cout<<'='<<"\n";
    else if(a>b)cout<<'>'<<"\n";
    else cout<<'<'<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF=1e5;
int dp[41][402][402];
int main(){
	int a[401],b[401],c[401];
	for(int i=0;i<41;i++)
	for(int j=0;j<401;j++)
	for(int k=0;k<401;k++)
		dp[i][j][k]=INF;
	dp[0][0][0]=0;
	int n,ma,mb;
	scanf("%d%d%d",&n,&ma,&mb);
	for(int i=0;i<n;i++)
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
	for(int i=0;i<n;i++){
		for(int j=400;j>=0;j--){
			for(int k=400;k>=0;k--){
				if(dp[i][j][k]==INF) continue;
				dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
				dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
			}
		}
	}
	int mins=INF;
	for(int j=1;j*ma<=400&&j*mb<=400;j++){
		mins=min(mins,dp[n][j*ma][j*mb]);
	}
	if(mins==INF){puts("-1");return 0;}
	printf("%d\n",mins);
	return 0;
}

Measured memory_bytes: 26112
#include<stdio.h>

int main(){
  int N,A,B;
  char c;
  scanf("%d%d%d",&N,&A,&B);
  int pass_a=0,pass_b=0;
  while (1)
  {
    if (N < 0)break;
    
    scanf("%c",&c);
    switch (c)
    {
    case 'a':
      if ((pass_a + pass_b) < A + B)
      {
        printf("Yes\n");
        pass_a++;
      }else
      {
        printf("No\n");
      }
      break;
    case 'b':
      if (((pass_a + pass_b) < A + B) && (pass_b < B))
      {
        printf("Yes\n");
        pass_b++;
        
      }else
      {
        printf("No\n");
      }
      break;
    case 'c':
      printf("No\n");
      break;  
    default:
      break;
    }
    N--;
  }


  return 0;
}

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

N = int(input())

i = 0
while i * 4 <= 100:
    j = 0
    while j * 7 <= 100:
        if i * 4 + j * 7 == N:
            print("Yes")
            exit()
        j += 1
    i += 1
print("No")

Measured memory_bytes: 3060
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;

int main()
{
    int N;
    std::cin >> N;

    std::vector<uint64_t> F;
    for (int i = 0; i < N; ++i) {
        uint64_t t = 0;
        for (size_t j = 0; j < 10; ++j) {
            t <<= 1;
            int b;
            std::cin >> b;
            if (b) {
                t |= 1;
            }
        }
        F.push_back(t);
    }

    boost::multi_array<int64_t, 2> P(boost::extents[N][11]);
    for (auto p = P.origin(); p < (P.origin() + P.num_elements()); ++p) {
        cin >> *p;
    }

    int64_t ma = INT64_MIN;
    for (uint64_t d = 1; d < (1 << 10); ++d) { // 営業日マスク
        int64_t r = 0;
        for (int n = 0; n < N; ++n) { // 他店
            // 重複日数
            auto dup_day_n = std::bitset<10>(F[n] & d).count();
            r += P[n][dup_day_n];
        }
        ma = std::max(ma, r);
    }

    std::cout << ma << std::endl;

    return 0;
}


Measured memory_bytes: 256
n = int( input() )
a = list( map( int, input().split() ) )

LIMIT = 18

for a_i in a:
    if a_i == 0:
        print( 0 )
        exit()

ans = 1
for a_i in a:
    if len( str( ans ) ) + len( str( a_i ) ) > LIMIT + 2:
        print( -1 )
        break
    elif len( str( ans ) ) + len( str( a_i ) ) > LIMIT:
        if ans * a_i > 10 ** 18:
            print( -1 )
            break
    ans *= a_i
else:
    print( ans )

Measured memory_bytes: 21796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=100005,INF=1<<28;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        string S;
        int A,B,C;cin>>S>>A>>B>>C;
        
        if(S=="#") break;
        
        if(A==31){
            if(B<=4){
                cout<<"HEISEI "<<A<<" "<<B<<" "<<C<<endl;
            }else{
                cout<<"? "<<1<<" "<<B<<" "<<C<<endl;
            }
        }else if(A<31){
            cout<<"HEISEI "<<A<<" "<<B<<" "<<C<<endl;
        }else{
            cout<<"? "<<A-30<<" "<<B<<" "<<C<<endl;
        }
    }
}



Measured memory_bytes: 3036
#include <iostream>
using namespace std;
int main()
{
    int n,a[100005][5],dp[100005][5];
    cin >> n;
    for (int i=1;i<=n;i++)
    {
        for (int j=1;j<=3;j++)
        {
            cin >> a[i][j];
        }
    }
    for (int j=1;j<=3;j++)
    {
        dp[1][j]=a[1][j];
    }
    for (int i=2;i<=n;i++)
    {
        for (int j=1;j<=3;j++)
        {
            if (j==1) dp[i][j]=max(dp[i-1][2],dp[i-1][3])+a[i][j];
            else if (j==2) dp[i][j]=max(dp[i-1][1],dp[i-1][3])+a[i][j];
            else if (j==3) dp[i][j]=max(dp[i-1][1],dp[i-1][2])+a[i][j];
        }
    }
    cout << max(max(dp[n][1],dp[n][2]),dp[n][3]);
}

Measured memory_bytes: 4096
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <map>
#include <iterator>
#include <queue>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for (int i=(a-1);i>=(b);--i)
#define rrep(i,n) rrepd(i,n,0)
typedef long long ll;
typedef pair<int, int> P;


int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  rep(i,9){
    if (n % (i+1) == 0){
      if (n / (i+1) <= 9){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};

int main(){
	int H, W;
	char area[400][400];

	cin >> H >> W;
	for(int i = 0; i < H; i++)
		for(int j = 0; j < W; j++)
			cin >> area[i][j];

	llong ans = 0;
	bool use[400][400] = {false};
	for(int h = 0; h < H; h++)
		for(int w = 0; w < W; w++){
			if(area[h][w] == '.') continue;
			if(use[h][w]) continue;
			llong bl = 0, wh = 0;
			queue<P> que;
			que.push(P(h,w));
			use[h][w] = true;
			while(que.size()){
				P now = que.front();
				que.pop();
				if(area[now.first][now.second] == '.')
					wh++;
				else
					bl++;
				for(int i = 0; i < 4; i++){
					P next(now.first + nh[i], now.second + nw[i]);
					if(next.first < 0 || next.second < 0 || next.first >= H || next.second >= W)
						continue;
					if(use[next.first][next.second])
						continue;
					if(area[now.first][now.second] == area[next.first][next.second])
						continue;
					use[next.first][next.second] = true;
					que.push(next);
				}
			}
			ans += bl*wh;
		}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        Integer n = Integer.parseInt(scan.next());
        scan.close();

        int[] fib = new int[n + 1];
        fib[0] = 1;
        fib[1] = 1;
        for (int i = 2; i <= n; i++) {
            fib[i] = fib[i - 1] + fib[i - 2];
        }

        System.out.println(fib[n]);
    }

}



Measured memory_bytes: 26076
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;

template <typename Tp> inline void getint(Tp &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

int cnt[10];

int main(){
	for(register int i = 1, v; i <= 4; i++) getint(v), cnt[v]++;
	return puts(cnt[1] && cnt[9] && cnt[7] && cnt[4] ? "YES" : "NO"), 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;

int main() {
  int M;
  int D;
  cin>>M>>D;
  int count=0;
  for(int i=1;i<=M;i++){
      for(int k=1;k<=D;k++){
        int d1=k%10;
        int d10=k/10;
        if(d1>=2&&d10>=2&&d1*d10==i){count++;}
      }
    }
  cout<<count<<endl;
  return 0;}

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


int main() {

    int n,m; cin >> n >> m;
    int x[100001];
    ll ans = 0;
    vector<int> d;

    rep(i,m){
        cin >> x[i];
    }

    sort(x,x+m);

    rep(i,m-1){
        d.push_back(x[i+1]-x[i]);
    }

    sort(d.begin(),d.end());
    rep(i,m-1-(n-1)){
        ans += d[i];
    }

    cout << ans;


    return 0;
}











Measured memory_bytes: 4272
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  string a;
  cin>>a;
  int b=0;
  for(int i=0;i<a.size();i++){
    if(a.at(i)=='x')
      b++;
  }
  if(b<8)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxN = 2005;
int n, k, q;
int a[maxN];
int ans = 2 * (int)1e9 + 10;
vector < int > g[maxN];
int id[maxN];
int sz[maxN];
void go(int val) {
    int l = 1;
    int r = 1;
    int cnt = 0;
    while (l <= n) {
        if (a[l] < val) {
            l++;
            r++;
            continue;
        }
        while (a[r] >= val && r <= n) r++; r--;
        r = min(r, n);
        if ((r - l + 1) >= k) {
            cnt++;
            g[cnt].clear();
            for (int j = l; j <= r; j++) {
                g[cnt].push_back(j);
                id[j] = cnt;
            }
            sz[cnt] = g[cnt].size();
        }
        l = r + 1;
        r = r + 1;
    }
    int mx = val;
    int nq = q;
    set < pair < int, int > > s;
    for (int v = 1; v <= cnt; v++) {
        for (int j = 0; j < g[v].size(); j++) {
            s.insert(make_pair(a[g[v][j]], g[v][j]));
        }
    }
    while (nq > 0) {
        if (s.empty()) return;
        auto t = (*s.begin());
        s.erase(s.begin());
        int val = t.first;
        int num = t.second;
        mx = val;
        nq--;
        sz[id[num]]--;
        if (sz[id[num]] < k) {
            int v = id[num];
            for (int j = 0; j < g[v].size(); j++) {
                s.erase(make_pair(a[g[v][j]], g[v][j]));
            }
        }
    }
    ans = min(ans, mx - val);
}
int main() {
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin >> n >> k >> q;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) {
        go(a[i]);
    }
    cout << ans;
	return 0;
}


Measured memory_bytes: 640
#include <cassert>
#include <stack>
#include <iostream>


int main()
{
    std::stack<int> Stack;
    while(true){
        int n;
        std::cin >> n;
        if(std::cin.eof()) break;
        if(n == 0){
            assert(Stack.empty() == false);
            std::cout << Stack.top() << std::endl;
            Stack.pop();
        }else{
            Stack.push(n);
        }
    }
    return 0;
}

Measured memory_bytes: 3024
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<unsigned long long int> A(N + 2, 0);
    vector<pair <unsigned long long int, unsigned long long int>> P(N + 1);
    unsigned long long int ans = 0;
    for (int i = 0; i <= N; ++i) {
        cin >> A[i];
    }
    bool T = true;
    for (int i = N; i >= 0; --i) {
        unsigned long long int min_t, max_t;
        if (i == N) {
            min_t = A[i];
            max_t = A[i];
            P[i] = make_pair(min_t, max_t);
        }
        else {
            if (P[i + 1].first % 2 == 0) min_t = P[i + 1].first / 2 + A[i];
            else min_t = P[i + 1].first / 2 + 1 + A[i];
            max_t = P[i + 1].second + A[i];
            P[i] = make_pair(min_t, max_t);
        }
        if (i == 0) {
            if (P[i].first != 1) T = false;
        }
    }
    unsigned long long int tmp = 0;
    for (int i = 0; i <= N; ++i) {
        unsigned long long int s = 0;
        if (i == 0) {
            tmp = 1;
        }
        tmp = min(P[i].second, tmp);
        s = tmp;
        tmp  -= A[i];
        tmp *= 2;
        ans += s;
    }
    if (T) cout << ans << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 5628
#include <stdio.h>
#define N 10000
#define N2 500

int main()
{
  int i,j,k,l;
  int n,q;
  int S[N],T[N2],U[N2];
  int count=0,flag;;
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {   
      scanf(" %d",&S[i]);
    }
  
  scanf("%d",&q);
  for(i=0;i<q;i++)
    {   
      scanf(" %d",&T[i]);
    }
  //  printf("//////////////////////////\n");
  for(i=0;i<n;i++)
    {
      for(j=0;j<q;j++)
	{
	  if(S[i]==T[j])
	    {
	      flag=1;
	      if(k>0)
		{
		  for(l=0;l<k;l++)
		    {
		      if(S[i]==U[l])
			{
			  flag=0;
			}
		    }
		}
	      U[k]=S[i];
	      k++;
	      if(flag==1)
		{
		  count++;
		}
	    }
	  else continue;
	}
    }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;

int main()
{
  int H, W; cin >> H >> W;
  vector<string> S(H);
  for(int i = 0; i < H; i++) cin >> S[i];

  vector<vector<int>> left(H, vector<int>(W, 0));
  vector<vector<int>> right(H, vector<int>(W, 0));
  vector<vector<int>> up(H, vector<int>(W, 0));
  vector<vector<int>> down(H, vector<int>(W, 0));

  for(int i = 0; i < H; i++){
    int cur = 0;
    for(int j = 0; j < W; j++){
      if(S[i][j] == '.') cur++;
      else cur = 0;
      left[i][j] = cur;
    }
  }
  
  for(int i = 0; i < H; i++){
    int cur = 0;
    for(int j = W - 1; j >= 0; j--){
      if(S[i][j] == '.') cur++;
      else cur = 0;
      right[i][j] = cur;
    }
  }
  
  for(int j = 0; j < W; j++){
    int cur = 0;
    for(int i = 0; i < H; i++){
      if(S[i][j] == '.') cur++;
      else cur = 0;
      up[i][j] = cur;
    }
  }
  
  for(int j = 0; j < W; j++){
    int cur = 0;
    for(int i = H - 1; i >= 0; i--){
      if(S[i][j] == '.') cur++;
      else cur = 0;
      down[i][j] = cur;
    }
  }
  
  int ans = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      int tmp = left[i][j] + right[i][j] + up[i][j] + down[i][j] - 3;
      if(tmp > ans) ans = tmp;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 67200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int a,b,c;
    cin >> a >> b >> c;
    cout << c <<" "<< a <<" "<< b << endl;
}

Measured memory_bytes: 256
ls_a = []
for i in range(3):
    ls_a.extend(list(map(int,input().split())))
n = int(input())
ls_b = [int(input()) for i in range(n)]

for i in range(9):
    if ls_a[i] in ls_b:
        ls_a[i] = 0

for i in range(3):
    if ls_a[i] == 0 and ls_a[i+3] == 0 and ls_a[i+6] == 0:
        print("Yes")
        exit()
    if ls_a[i*3] == 0 and ls_a[i*3+1] == 0 and ls_a[i*3+2] == 0:
        print("Yes")
        exit()
if ls_a[0] == 0 and ls_a[4] == 0 and ls_a[8] == 0:
    print("Yes")
    exit()
if ls_a[2] == 0 and ls_a[4] == 0 and ls_a[6] == 0:
    print("Yes")
    exit()
print("No")
            

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
#define spn setprecision
#define fr(x,a,b,c) for(int x = a; x <= b; x+=c)
using namespace std;
ll multiply(ll num1, ll num2, ll mod) { // with mod > 1e9
	ll ans = 0;
	num1 %= mod;
	num2 %= mod;
	while (num2) {
		if (num2&1) {
			ans += num1;
			ans %= mod;
		}
		num1 *= 2;
		num1 %= mod;
		num2 /= 2;
	}
	return ans;
}
ll powmod2(ll base,ll exponent,ll mod){ // with mod > 1e9
	ll ans = 1;
	while (exponent) {
		if (exponent&1) {
			ans = multiply(ans, base, mod);
		}
		base = multiply(base, base, mod);
		exponent /= 2;
	}
	return ans;
}
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
int main() {
	int n,mini=INF,maxi=-INF;
	sd(n);
	int inp;
	for(int i = 1; i <= n; i++){
		sd(inp);
		mini=min(mini,inp);
		maxi=max(inp,maxi);
	}
	pd(maxi-mini);
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
namespace AGC010A
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            int[,] ab = new int[n, 2];
            for (int i = 0; i < n; i++)
            {
                string[] s = Console.ReadLine().Split(' ');
                ab[i, 0] = int.Parse(s[0]);
                ab[i, 1] = int.Parse(s[1]);
            }
            long ans = 0;
            for (int i = n - 1; i >= 0; i--)
            {
                if ((ab[i, 0] + ans) % ab[i, 1] == 0)
                    continue;
                ans += (ab[i, 1] - (ab[i, 0] + ans) % ab[i, 1]);
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 15808
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1LL,0,1LL,0 }, dy[] = { 0,1LL,0,-1LL };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1LL; while (b > 0) { if (b & 1LL) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1LL] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) { a[i] = 1LL; }for (int i = 2; i < n + 1LL; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

typedef pair<int, pair<int, int>> edge;

class UnionFind {
private:
	vector<int> par;
public:
	UnionFind(int N) { par = vector<int>(N, -1LL); }
	int find(int x);
	ll size(int x);
	void unite(int x, int y);
	bool same(int x, int y);
};



class Kruskal {
private:
	UnionFind *uf;
	vector<edge> e;
public:
	vector<edge> mst;
	Kruskal(int N) { uf = new UnionFind(N); }
	void add(int x, int y, ll z);
	void run();
};



//----UnionFind-------------------------------
int UnionFind::find(int x) {
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}

ll UnionFind::size(int x) {
	return -par[find(x)];
}

void UnionFind::unite(int x, int y) {
	x = find(x);
	y = find(y);

	//大きい方に小さい方をくっ付ける
	if (size(x) < size(y)) swap(x, y);
	par[x] += par[y];
	par[y] = x;
}

bool UnionFind::same(int x, int y) {
	x = find(x);
	y = find(y);
	return x == y;
}



//----Kruskal-------------------------------
void Kruskal::add(int x, int y, ll z) {
	//x < y
	if (x > y) swap(x, y);
	e.push_back({ z,{x,y} });
}

void Kruskal::run() {
	sort(e.begin(), e.end());
	e.erase(unique(e.begin(), e.end()), e.end());
	for (auto x : e) {
		if (uf->same(x.second.first, x.second.second)) {
			continue;
		}
		else {
			mst.push_back(x);
			uf->unite(x.second.first, x.second.second);
		}
	}
}



signed main() {
	string a;
	cin >> a;
	int n = a.size();
	map<char,int> ma;
	REP (i,n) {
		char x;
		x = a[i];
		ma[x]++;
	}
	int ans = n * (n-1) / 2 + 1;
	for (auto itr = ma.begin();itr != ma.end();itr++) {
		int xx = itr->second;
		ans -= xx * (xx-1)/ 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;

ll a, b, c, n, k, x;
string s;

int main()
{
  int n;
  cin >> n;
  int r = 0;

  int c = 0;
  int t = n;
  for (int j = 0; j < 8; j++)
  {
    c += t % 10;
    t /= 10;
  }
  if (n % c == 0)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=1000000007;
	static long[] r,g;
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia;
		int[][] a=new int[s[2]][];
		long[] h=new long[s[2]];
		int m=s[0]+s[1]-1;
		r=new long[m];
		g=new long[m];
		r[0]=1;g[0]=1;
		for(int i = 1;i<m;i++) {
			r[i]=(r[i-1]*i)%mod;
			g[i]=Mi(r[i]);
		}
		for(int i = 0;i<s[2];i++) {a[i]=sc.Ia;}
		Array.Sort(a,(u,v)=>(u[0]+u[1])-(v[0]+v[1]));
		long ans=Fu(s[0],s[1]);
		for(int i = 0;i<s[2];i++) {
			h[i]=Fu(a[i][0],a[i][1]);
			for(int j = 0;j<i;j++) {
				if(a[j][0]<=a[i][0]&&a[j][1]<=a[i][1]){
					h[i]=(h[i]+mod-((Fu(a[i][0]+1-a[j][0],a[i][1]+1-a[j][1])*h[j])%mod))%mod;
				}
			}
			ans=(ans+mod-((h[i]*Fu(s[0]+1-a[i][0],s[1]+1-a[i][1]))%mod))%mod;
		}
		Console.WriteLine(ans);
	}
	static long Fu(int h,int w){
		int n=h+w-2,k=h-1;
		return (r[n]*((g[k]*g[n-k])%mod))%mod;
	}
	static long Mi(long a){
		long b=mod,u=1,v=0;
		while(b>0){
			long t=a/b;
			a-=t*b;a^=b;b^=a;a^=b;
			u-=t*v;u^=v;v^=u;u^=v;
		}
		u%=mod;
		if(u<0){u+=mod;}
		return u%mod;
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

Measured memory_bytes: 14420
#include<iostream>
#include<cstdlib>
#include<vector>
#include<algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(x,a) for(auto& (x):(a))
#define ALL(obj) (obj).begin(),(obj).end()
#define Yes(n) cout<<((n)?"Yes":"No")<<endl;
using namespace std;
using ll=long long;
const int INF=1e9;
const ll LINF=1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

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

  int N;
  vector<ll> A;
  cin>>N;
  ll a;
  REP(i,N){
    cin>>a;
    A.push_back(a);
  }
  sort(ALL(A));

  ll absmin=LINF;
  int negCnt=0;
  bool noZero=true;
  ll ans=0;
  REP(i,N){
    if(A[i]==0) noZero=false;
    if(A[i]<0) ++negCnt;
    absmin = min(abs(absmin), abs(A[i]));
    ans += abs(A[i]);
  }
  if(noZero and negCnt%2==1) ans -= 2*absmin;

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
ll gcd(ll a, ll b){
    if(a < 0) a = -a;
    if(b < 0) b = -b;
    if(b == 0) return a;
    else return gcd(b, a%b);
}

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

void solve(){
    ll n; cin >> n;
    vector<ll> t(n);
    REP(i, n) cin >> t[i];
    ll res = t[0];
    for(int i=1; i<n; i++){
        res = lcm(t[i], res);
    }

    cout << res << endl;
}

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

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

#define times(n, i) uptil(0, n, i)
#define upto(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f) poi i <= _##i poi i++)
#define uptil(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f) poi i < _##i poi i++)
#define downto(f, t, i) for(auto i = (f), _##i = decltype(i)(t) poi i >= _##i poi i--)
#define downtil(f, t, i) for(auto i = (f), _##i = decltype(i)(t) poi i > _##i poi i--)

#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define poi ;
#define poipoi << "\n"

using namespace std;

bool pyon(int a, int b, int c){
    return c && a * a + b * b == c * c poi
}

int main(){
    int n poi
    cin >> n poi
    times(n, i){
        int a, b, c poi
        cin >> a >> b >> c poi
        if(pyon(a, b, c) || pyon(b, c, a) || pyon(c, a, b)) cout << "YES" poipoi poi
        else cout << "NO" poipoi poi
    }
    return 0 poi
}

Measured memory_bytes: 1112
public class Main {
  private static void solve() {
    int n = ni();
    int m = ni();
    System.out.println(n * (n - 1) / 2 + m * (m - 1) / 2);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define mod 1000000007
#define PI 3.1415926535
using namespace std;
ll power(ll x, ll y)
{
	if (y == 0)
		return 1;
	else if (y % 2 == 0)
		return power(x, y / 2) * power(x, y / 2);
	else
		return x * power(x, y / 2) * power(x, y / 2);
}
ll modExpo(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return modExpo((x*x)%mod,n/2);
    else                            
        return (x*modExpo((x*x)%mod,(n-1)/2))%mod;
 
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	auto start_time = clock();
	cerr << setprecision(3) << fixed;
#endif
	ll d,t,s;
	cin>>d>>t>>s;
	double ti=d*1.0/s;
	if(ti<= (double)t)
		cout<<"Yes";
	else 
		cout<<"No";
#ifdef LOCAL
	auto end_time = clock();
	cerr << "Execution time: " << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << " ms\n";
#endif
}

Measured memory_bytes: 3604
#include<iostream>
using namespace std;
#define  ll    long long int
#define  mod   1000000007   //10^9
#define  N     100005       //10^5
int main()
{
    int n,k,i=0,j;
    ll a[N];
    cin>>n;
    while(n>0)
    {
        k=n%10;
        n/=10;
        if(k==1)
        {
            a[i]=9;
            i++;
        }
        else if(k==9)
        {
            a[i]=1;
            i++;
        }
    }
    for(j=i-1;j>=0;j--)
        cout<<a[j];
    cout<<endl;
    return 0;
}



Measured memory_bytes: 256
/**
 *      ABC 44 B
 *      author  : kyomukyomupurin
 *      created : 2018-09-20 04:14:04
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string w; cin >> w;
    int sizew = w.size();

    int count[30] = {};
    for (auto i = 0; i < sizew; ++i) {
        char c = w[i];
        ++count[c - 'a'];
    }
    for (auto i = 0; i < 30; ++i) {
        if (count[i] % 2 != 0){
            cout << "No" << endl; return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m,x,y,z,a,b,c,cc[300000],dd[300000];
char s[500000],ss[500000];
int main(){
	gets(s);
	gets(ss);
	n=strlen(s);
	for (int i=0;i<n;i++){
		if (cc[s[i]-'a'+1]==0) cc[s[i]-'a'+1]=ss[i]-'a'+1;
		else if (cc[s[i]-'a'+1]!=ss[i]-'a'+1) a=1;
		if (dd[ss[i]-'a'+1]!=s[i]-'a'+1 && dd[ss[i]-'a'+1]!=0) a=1;
		dd[ss[i]-'a'+1]=s[i]-'a'+1;
	}
	if (a==0) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long

using namespace std;
const int inf=0x3f3f3f3f;
int a[100024];
int mp[120][120];
int main()
{

    int h,w,n;
    scanf("%d%d",&h,&w);
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    int x=1;
    for(int i=0;i<h;i++)
    {
        if(i%2)
        {
            for(int j=w-1;j>=0;j--)
            {
                if(a[x]==0){
                    x++;
                    a[x]--;
                    mp[i][j]=x;
                 //   cout<<x<<endl;
                }else{
                  mp[i][j]=x;
                 //   cout<<x<<endl;
                    a[x]--;
                }
            }
        }else{
            for(int j=0;j<w;j++)
                if(a[x]==0){
                    x++;
                    a[x]--;
                  mp[i][j]=x;
               //   cout<<x<<endl;
                }else{
                mp[i][j]=x;
                    a[x]--;
                }
        }
    }
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
            if(j==w-1) printf("%d\n",mp[i][j]);
            else  printf("%d ",mp[i][j]);
    }
    return 0;
}


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

int main(){
    string w,op,fill;
    int n;
    cin >> w;
    cin >> n;
    int n1,n2;
    for(int i=0; i<n; i++){
        cin >> op;
        if(op=="print"){
            cin >> n1 >> n2;
            for(int j=n1; j<=n2; j++)
                cout << w[j];
            cout << endl;
        }
        else if (op=="replace"){
            cin >> n1 >> n2;
            cin >> fill;
            for(int j=0; j<fill.size(); j++){
                w[n1+j]=fill[j];
            }
        }
        else if (op=="reverse"){
            cin >> n1 >> n2;
            for(int j=0; j<(n2-n1+1)/2; j++){
                int tmp = w[n1+j];
                w[n1+j] = w[n2-j];
                w[n2-j] = tmp;
            }
        }
    }
    
    return 0;
}


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

int main() {
  int N, Y;
  cin >> N >> Y;
  
  int x = -1, y = -1, z = -1;
  
  for (int i = 0; i <= N; i++){
    for (int j = 0; j <= N - i; j++){
      if (1000 * (N - i - j) == Y - 10000 * i - 5000 * j){
        x = i;
        y = j;
        z = N - i - j;
        break;
      }
    }
    if (x > -1){
      break;
    }
  }
  
  cout << x << " " << y << " " << z << endl;
}



Measured memory_bytes: 3644
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

n = I()
V = LI()
odd = [V[i] for i in range(n) if i % 2 != 0]
even = [V[i] for i in range(n) if i % 2 == 0]
A = Counter(odd).most_common(2) + [(0, 0)]
B = Counter(even).most_common(2) + [(0, 0)]
ans = INF
for a in A:
    for b in B:
        if a[0] == b[0]:
            continue
        else:
            ans = min(ans, n-a[1]-b[1])
print(ans)


Measured memory_bytes: 89720
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define all(a) a.begin(), a.end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;
using P  = pair<int,int>;
const int INF = 1001001001;
const int MOD = 1000000007;



int main(){
    int n, m;
    cin >> n >> m;
    rep(i,m){
        int a;
        cin >> a;
        n -= a;
    }
    if(n<0)
        cout << -1 << endl;
    else
        cout << n << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>

using namespace std;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int cur = 0;
  int sum = 0;
  int ans = 0;
  while (cur < n) {
    cur++;
    if (cur%10000 == 0) sum -= 35;
    else if (cur%1000 == 0) sum -= 26;
    else if (cur%100 == 0) sum -= 17;
    else if (cur%10 == 0) sum -= 8;
    else sum++;
    if (sum >= a && sum <= b) ans += cur;
  }
  cout << ans << endl;
}


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

#include<bits/stdc++.h>

using namespace std;

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

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

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

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

class FXorShift {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      vector<int> a(n);
      vector<int> b(n);
      rep(i, n) {
        cin >> a[i];
      }
      rep(i, n) {
        cin >> b[i];
      }

      rep(i, n) {
        int p = n-i;
        int x = a[0] ^ b[p%n];
        bool flag = true;
        rep(j, 400) {
          int r = rng() % n;
          int y = a[r] ^b[(r+p)%n];
          if (x != y) {
            flag = false;
            break;
          }
        }
        if (flag) {
          cout << i << ' ' << x << '\n';
        }
      }




    }
};

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

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define LL long long
#define M 1000000007
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

int main()
{
	fastio
	int n, i;
	cin>>n;
	vector<pair<int, int> > a(n);
	for(i=1; i<=n; i++){
		int v;
		cin>>v;
		a[i-1] = make_pair(v, i);
	}
	sort(a.begin(), a.end());
	for(i=0; i<n; i++)
		cout<<a[i].second<<" ";
	cout<<endl;
	return 0;
}

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

using namespace std;

#pragma GCC optimize("O3")
static const auto __ = [] {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  return nullptr;
}();

int solve(int N) {
  int A[N];
  for (int& a : A) {
    cin >> a;
  }
  int P[N];
  P[0] = A[0];
  for (int i {1}; i < N; ++i) {
    P[i] = __gcd(P[i - 1], A[i]);
  }
  int S[N];
  S[N - 1] = A[N - 1];
  for (int i {N - 2}; i; --i) {
    S[i] = __gcd(S[i + 1], A[i]);
  }
  int ans {1};
  for (int i {0}; i < N; ++i) {
    int prefix_gcd {i > 0     ? P[i - 1] : S[i + 1]};
    int suffix_gcd {i < N - 1 ? S[i + 1] : P[i - 1]};
    ans = max(ans, __gcd(prefix_gcd, suffix_gcd));
  }
  return ans;
}

int main(int argc, char* argv[]) {
  int N;
  cin >> N;
  cout << solve(N) << '\n';
  return 0;
}

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

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

	int n = s.size();
	int ret = 0;
	int temp = 0;
	for (int i = 0; i < n; ++i) {
		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
			++temp;
		}
		else if (temp) {
			if(ret < temp){
				ret = temp;
			}
			temp = 0;
		}
	}

	if (temp) {
		if (ret < temp) {
			ret = temp;
		}
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

///////////////////////////





int main() {

	ll n;
	ll p[30];
	cin >> n;
	repn(i, n) cin >> p[i];

	int ans = 0;

	for (int i = 2; i < n; i++) {
		if (p[i - 1] < p[i] && p[i] < p[i + 1]) { ans++; }
		if (p[i - 1] > p[i] && p[i] > p[i + 1]) { ans++; }

	}

	cout << ans;

	system("PAUSE");


}


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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

vector<int> memo[1000010];
int a[1000010];
signed main(){
	int n;
	cin >> n;

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

	for(int i = 2;i < 1000010;i++){
		if(memo[i].size() > 0) continue;
		for(int j = i;j < 1000010;j += i){
			memo[j].push_back(i);
		}
	}

	bool ok = true;
	set<int> st;
	for(int i = 0;i < n;i++){
		for(auto e : memo[a[i]]){
			if(st.find(e) != st.end()){
				ok = false;
				break;
			}
			st.insert(e);
		}
	}

	if(ok){
		cout << "pairwise coprime" << endl;
		return 0;
	}

	int gg = a[0];
	for(int i = 1;i < n;i++) gg = __gcd(gg, a[i]);
	if(gg == 1){
		cout << "setwise coprime" << endl;
	}else{
		cout << "not coprime" << endl;
	}

	return 0;
}


Measured memory_bytes: 85064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,b[105],ans[101];
vector<int> a;
bool d[105];
int main(){
    ios::sync_with_stdio(false);
	cin >> n;
	for (int i=2;i<=n;i++){
		if(d[i])continue;
		a.push_back(i);
		for(int j=i*2;j<=n;j+=i)d[j]=1;
		for(int j=i;j<=n;j*=i)b[i]+=n/j;
	}
	ans[1]=1;
	for (int i=2;i<=n;i++){
		if(d[i])continue;
		for (int j=75;j>=0;j--)
			for (int k=1;k<=b[i];k++)
				if (j*(k+1)<=75)ans[j*(k+1)]+=ans[j];
	}
	cout << ans[75];
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define mm(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define pf(a) printf("%d\n",a)
#define pf2(a,b) printf("%d %d\n",a,b)
#define p_f(a) printf("%d ",a)
#define pyn(a) if(a)puts("Yes");else puts("No");
#define fi first
#define se second
#define db double
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const db eps=1e-9;
int n,m,a[200],tot;
bool flag;
int main()
{
    sc2(n,m);
    rep(i,1,n)sc(a[i]),tot+=a[i];
    sort(a+1,a+n+1);
    if(a[n-m+1]*4*m>=tot)flag=true;
    pyn(flag);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[]ar = new int[n];
    int sum = 0;
    for(int i=0;i<n;i++){
      ar[i] = sc.nextInt();
    }
    for(int j=0;j<n-1;j++){
      for(int k=j+1;k<n;k++){
        sum += ar[j]*ar[k];
      }
    }
    System.out.println(sum);
  }
}

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

int main() {
    int n, m; cin >> n >> m;
    int X, Y; cin >> X >> Y;
    vector<int> x(n);
    for (auto &xi: x) cin >> xi;
    x.emplace_back(X);
    vector<int> y(m);
    for (auto &yi: y) cin >> yi;
    y.emplace_back(Y);
    int ma_x = *max_element(begin(x), end(x));
    int mi_y = *min_element(begin(y), end(y));
    cout << (ma_x < mi_y ? "No War" : "War") << endl;
    return 0;
}


Measured memory_bytes: 256