akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int m, n;
int dat[7400000];

int main(void){
	while(1){
		scanf("%d %d", &m, &n);
		if(m == 0 && n == 0) return 0;
		rep(i, 7400000) dat[i] = 0;

		int cnt = 0;
		int d = m;
		while(cnt < n){
			if(dat[d] != 0){
				d++;
				continue;
			}
			for (int j = d; j <= 7400000; j += d){
				dat[j] = 1;
			}
			cnt++;
			d++;
		}

		reps(i, m, 7400000){
			if(dat[i] == 0){
				printf("%d\n", i);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 32076
#include <stdio.h>          // printf(), scanf()

int
main(int argc, char** argv)
{
	char maze[9][5];
	int x, y;
	int px, py;
	int mx, my;
	char dir;
	int i;

	for (i = 0; i < 9; ++i)
		scanf("%s", &maze[i][0]);

	x = 0, y = 0;
	dir = 'R';
	printf("%c", dir);

	do
	{
		px = x + 1, py = y + 1;
		mx = x - 1, my = y - 1;
		if (dir == 'R')
		{
			if (px < 5 && my >= 0 && maze[my][px] == '1')
			{
				dir = 'U';
				printf("%c", dir);
				x = px;
				y = my;
			}

			else if (px < 4 && maze[y][px] == '1')
			{
				printf("%c", dir);
				x = px;
			}

			else if (px < 5 && py < 9 && maze[py][px] == '1')
			{
				dir = 'D';
				printf("%c", dir);
				x = px;
				y = py;
			}

			else
			{
				dir = 'L';
				printf("%c", dir);
			}
		}

		else if (dir == 'L')
		{
			if (py < 9 && maze[py][x] == '1')
			{
				dir = 'D';
				printf("%c", dir);
				y = py;
			}

			else if (mx >= 0 && maze[y][mx] == '1')
			{
				printf("%c", dir);
				x = mx;
			}

			else if (my >= 0 && maze[my][x] == '1')
			{
				dir = 'U';
				printf("%c", dir);
				y = my;
			}

			else
			{
				dir = 'R';
				printf("%c", dir);
			}
		}

		else if (dir == 'D')
		{
			if (py < 9 && maze[py][x] == '1')
			{
				dir = 'R';
				printf("%c", dir);
				y = py;
			}

			else if (y + 2 < 9 && maze[y + 2][x] == '1')
			{
				printf("%c", dir);
				y += 2;
			}

			else if (mx >= 0 && py < 9 && maze[py][mx] == '1')
			{
				dir = 'L';
				printf("%c", dir);
				x = mx;
				y = py;
			}

			else
			{
				dir = 'U';
				printf("%c", dir);
			}
		}

		else if (dir == 'U')
		{
			if (my >= 0 && mx >= 0 && maze[my][mx] == '1')
			{
				dir = 'L';
				printf("%c", dir);
				x = mx;
				y = my;
			}

			else if (y - 2 >= 0 && maze[y - 2][x] == '1')
			{
				printf("%c", dir);
				y -= 2;
			}

			else if (my >= 0 && maze[my][x] == '1')
			{
				dir = 'R';
				printf("%c", dir);
				y = my;
			}

			else
			{
				dir = 'D';
				printf("%c", dir);
			}
		}

	} while (!(x == 0 && y == 0));

	printf("\n");
	return 0;
}

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

public class Main {
  Scanner sc;

  void run() {
    int[][] ofs = new int[256][];
    ofs['N'] = new int[] { 0, 1 };
    ofs['E'] = new int[] { 1, 0 };
    ofs['S'] = new int[] { 0, -1 };
    ofs['W'] = new int[] { -1, 0 };
    while (true) {
      boolean[][] field = new boolean[21][21];
      boolean[][] done = new boolean[21][21];
      int rx = 10, ry = 10;
      int N = ni();
      if (N == 0)
        break;

      for (int i = 0; i < N; ++i) {
        int x = ni();
        int y = ni();
        field[y][x] = true;
      }

      int M = ni();
      int cnt = field[ry][rx] ? 1 : 0;
      for (int i = 0; i < M; ++i) {
        char d = sc.next().charAt(0);
        int l = ni();
        for (int j = 0; j < l; ++j) {
          rx += ofs[d][0];
          ry += ofs[d][1];
          if (!done[ry][rx] && field[ry][rx]) {
            ++cnt;
            done[ry][rx] = true;
          }
        }
      }

      System.out.println(cnt == N ? "Yes" : "No");
    }
  }

  int ni() {
    return sc.nextInt();
  }

  Main() {
    sc = new Scanner(System.in);
  }

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

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }
}

Measured memory_bytes: 39248
#include <stdio.h>
#include <string>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main(void){
    int n;
    cin >> n;
    int ans=0;
    if(n%2==0)ans=n/2*n/2;
    else ans=n/2*(n+1)/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>

using namespace std;

void solve(long long N, vector<long long> A){
    vector<long long> s(N);
    s[0] = (abs(A[0] - 0) + abs(A[1] - A[0])) - abs(A[1] - 0);
    s[N-1] = (abs(A[N-1] - A[N-2]) + abs(0 - A[N-1])) - abs(A[N-2] - 0);
    for (int i = 1; i < N-1; i++) {
        s[i] = (abs(A[i] - A[i-1]) + abs(A[i+1] - A[i])) - abs(A[i+1] - A[i-1]);
    }
    long long tot = 0;
    tot += abs(A[0] - 0) + abs(0 - A[N-1]);
    for (int i = 0; i < N-1; i++) {
        tot += abs(A[i+1] - A[i]);
    }
    for (int i = 0; i < N; i++) {
        std::cout << tot - s[i] << std::endl;
    }
}

int main(){	
    struct timeval start,end;
    long long span;
    gettimeofday(&start,NULL);

    long long N;
    scanf("%lld",&N);
    vector<long long> A(N-1+1);
    for(int i = 0 ; i <= N-1 ; i++){
    	scanf("%lld",&A[i]);
    }
    solve(N, A);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 4216
program atcoder
    implicit none
    integer(8) :: N,A(0:2),K=1,i,j,s(0:5),cut(0:5),ans,p;
    integer(8),allocatable,dimension(:) :: L;
    read*,N,A(0),A(1),A(2)
    allocate(L(N))
    read(*,*)(L(i),i=1,N)
    do i=1,N
        K = K * 4
    enddo
    ans = 100000000000000000_8
    do j = 1,K
        s = 0
        cut = 0
        p = j
        do i = 1,N
            s(mod(p,4)) = s(mod(p,4)) + L(i)
            cut(mod(p,4)) = cut(mod(p,4)) + 1
            p = int(p/4)
        enddo
        do i=0,2
            p=p + abs(s(i)-A(i))
            p=p + (cut(i)-1)*10
            if(cut(i)==0)then
                p= 100000000000000000_8
            endif
        enddo
        ans = min(ans,p)
    enddo
    write(*,'(I0)')ans
    stop 
contains

function minlen(s,t,x)
    integer(8) minlen,s,t,x
    if(s>=x .and. t>=x)then
        minlen = max(abs(s-x),abs(t-x))
    else if(s<=x .and. t<=x)then
        minlen = max(abs(s-x),abs(t-x))
    else
        minlen = max(abs(s-x),abs(t-x)) + min(abs(s-x),abs(t-x))*2_8
    endif
end function minlen

end program atcoder

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX_N 100000
ll dp[MAX_N+1][2];

int main() {	
	long long N;
	scanf("%lld",&N);
	vector<long long> A(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&A[i]);
	}
	
	dp[2][0] = A[0]+A[1];
	dp[2][1] = -(A[0]+A[1]);

	for (int i=3; i<=N; i++) {
		dp[i][0] = max(dp[i-1][0]+A[i-1], dp[i-1][1]+A[i-1]);
		dp[i][1] = max(dp[i-1][0]-A[i-1]-2*A[i-2], dp[i-1][1]-A[i-1]+2*A[i-2]);

		// cout << i << " 0: " << dp[i][0] << endl;
		// cout << i << " 1: " << dp[i][1] << endl;
	}

	cout << max(dp[N][0], dp[N][1]) << endl;

	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include <vector> 
#include <algorithm>
#include<iomanip>
#include<math.h>
#include<string>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
using namespace std;
struct Room {
	int *a;
	int shortest;
	int way;
	int ways;
};
//for (int x = 0; x < N; x++)room[x].a=(int*)malloc(room[x].way * sizeof(int));
int main() {
	static long long X, N, a[200], b[101] = { 0 },tal=0;
	cin >> X >> N;
	for (int x = 0; x < N; x ++) {
		cin >> a[x];
	}
	for (int x = 0; x < N; x++) {
		b[a[x]]++;
	}
	for (int x = 1; x <= 101; x++) {
		if (b[x] == 0) {
			if (abs(tal - X) > abs(x - X))tal = x;
		}
	}cout << tal << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int C[MAX_N], A[MAX_N];
int E[2010], F[2010]; //W and B at
int W[2010][4010], B[2010][4010];
int dp[2010][2010];


void pre(int at[2010], int S[2010][4010]) {
	rep(i, 0, N) {
		rep(j, 0, 2 * N + 1) {
			S[i + 1][j] = S[i][j];
		}
		S[i + 1][at[i] + 1]++;
	}
	rep(i, 0, N + 1) {
		rep(j, 0, 2 * N) {
			S[i][j + 1] += S[i][j];
		}
		// debug(vi(S[i], S[i] + 2 * N + 1));
	}
}
void solve() {
	cin >> N;
	rep(i, 0, 2 * N) {
		char c; int a;
		cin >> c >> a; a--;
		if(c == 'B') {
			C[i] = 1;
			F[a] = i;
		}
		else {
			C[i] = 0;
			E[a] = i;
		}
		A[i] = a;
	}
	pre(E, W);
	pre(F, B);
	rep(i, 0, N + 1) {
		rep(j, 0, N + 1) {
			dp[i][j] = inf;
		}
	}
	dp[0][0] = 0;
	rep(i, 0, N + 1) {
		rep(j, 0, N + 1) {
			if(dp[i][j] != inf) {
				if(i != N) {
					// debug(i, j, dp[i][j], W[i][E[i]], B[j][E[i]]);
					MIN(dp[i + 1][j], dp[i][j] + E[i] - (W[i][E[i]] + B[j][E[i]]));
				}
				if(j != N) {
					// debug(i, j, dp[i][j], W[i][F[j]], B[j][F[j]]);
					MIN(dp[i][j + 1], dp[i][j] + F[j] - (W[i][F[j]] + B[j][F[j]]));
				}
			}
		}
	}
	cout << dp[N][N] << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 80128
#include <iostream>
#include<set>
#include <vector>
#include <map>

using namespace std;

int main()
{
    map<int,bool>m;
    map<int,int>b;
    int n, mm;
    cin >> n >> mm;
    for(int i = 1; i <= n;i++)
        b[i] = 1;
    m[1] = true;
    for(int i = 0; i < mm; i++)
    {
        int x, y;
        cin >> x >> y;
        if(m[x])
            m[y] = true;
        b[x]--;
        b[y]++;
        if(!b[x] && m[x])
        {
            m[x] = false;
        }
        if(!m[x])
            m.erase(x);
    }
    cout << m.size() << endl;
}


Measured memory_bytes: 9600
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
  
  int N, K;
  cin >> N >> K;
  
  double ans = 0;
  
  for(int i=1; i<=N; i++)
  {
    int value = i;
    double prob = 1;
    while(value<K)
    {
      value *= 2;
      prob *= 0.5;
    }
    ans += prob / N;
    
//    cout << ans << endl;
  }
  
//  cout << ans << endl;
  
  printf("%1.12lf", ans);
  
  return 0;
}



Measured memory_bytes: 256
while True:
    a,b=map(int,input().split())
    if a==0 and b==0:break
    
    f=[[0 for i in range(b)]for j in range(a)]
    
    for i in range(a):
        for j in range(b):
            if i==0 or i==a-1 or j==0 or j==b-1:
                f[i][j]=1
    
    for i in range(a):
        for j in range(b):
            if f[i][j]==1:
                print('#',end='')
            else :
                print('.',end='')
        print()
    print()


Measured memory_bytes: 7256
W,H,N = map(int,input().split())
X = [i for i in range(W+1)]
Y = [i for i in range(H+1)]

for i in range(N):
    x,y,a = map(int,input().split())
    if a == 1:
        for j in range(W+1):
            if X[j] < x:
                X[j] = x
    elif a == 2:
        for j in range(W+1):
            if X[j] > x:
                X[j] = x
    elif a == 3:
        for j in range(H+1):
            if Y[j] < y:
                Y[j] = y
    else:
        for j in range(H+1):
            if Y[j] > y:
                Y[j] = y
print((max(X)-min(X))*(max(Y)-min(Y)))

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

int main()
{
  int n;
  int A[500000];
  cin >> n;

  int N = 1;
  for(int i=0; i<n; i++) {
    N *= 2;
  }
  //cout << N << endl;
  for(int i=0; i<N; i++) cin >> A[i];

  for(int i=0; i<=n; i++) {
    for(int j=0; j<N; j+=(int)pow(2, i+1)) {

      if( A[j] < A[j+(int)pow(2, i)] ) {
	A[j] = A[j+(int)pow(2, i)] - A[j];
	A[j+(int)pow(2, i)] = 0;
      }
      else if( A[j] > A[j+(int)pow(2, i)] ) {
	A[j] = A[j] - A[j+(int)pow(2, i)];
	A[j+(int)pow(2, i)] = 0;
      }
      else {
	A[j+(int)pow(2, i)] = 0;
       
      }
      //cout << A[j] << endl;
    }
  }

  
  for(int i=0; i<N; i++) {
    if( A[i] != 0 ) {
      cout << A[i] << endl;
    }
  }
  
}


Measured memory_bytes: 1280
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <math.h> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

int main(){
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int x,a,b;
    cin >> x >> a >> b;
    string res = "A";

    if(abs(x-a) > abs(x-b))
    {
        res = "B";
    }

    cout << res << endl;
    return 0;    
}



Measured memory_bytes: 256
N = int(input())
S = str(input())

R = 0
G = 0
B = 0

for i in range(len(S)):
  if S[i] == "R":
    R+=1
  elif S[i] == "G":
    G+=1
  else:
    B+=1

ans = R*G*B

# i<j<k
# k = (j-i) + j
for i in range(N-1):
  for j in range(i+1,N):
    k = (j - i) + j
    if k < N:
      if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
        ans -= 1

print(ans)


Measured memory_bytes: 9212
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

pii INIT = pii(-1, -1);
int board[33][33];
int acc[33][33];
pii memo[33][33][33][33];

int H, W, E, S;

int getsum(int p, int q, int x, int y) {
    return board[x][y] - board[p][y] - board[x][q] + board[p][q];
}

// ?°???°??? (??????) ??????????????????
pii solve(int lx, int ly, int rx, int ry) {
    pii& ans = memo[lx][ly][rx][ry];
    if(ans != INIT) return ans;

    // ?°???°???????????¶???????????????????????§??????????????±???????????????????????????????????????
    int sum = getsum(lx, ly, rx, ry);
    if(sum < E - S) return ans = pii(0, INF);

    // ??????
    ans = pii(1, S - (E - sum));

    // ?¨??????????
    rep(i,lx+1,rx) {
        pii ra = solve(lx, ly, i, ry);
        pii rb = solve(i, ly, rx, ry);
        pii temp = pii(ra.first + rb.first, min(ra.second, rb.second));
        chmax(ans, temp);
    }

    // ????????????
    rep(i,ly+1,ry) {
        pii ra = solve(lx, ly, rx, i);
        pii rb = solve(lx, i, rx, ry);
        pii temp = pii(ra.first + rb.first, min(ra.second, rb.second));
        chmax(ans, temp);
    }

    //printf("lx = %lld, ly = %lld, rx = %lld, ry = %lld, val = (%lld, %lld)\n",
    //    lx, ly, rx, ry, ans.first, ans.second);
    //printf("sum: %lld\n\n", sum);
    return ans;
}

signed main() {
    while(cin >> H >> W >> S, H || W || S) {
        memset(board, 0, sizeof(board));
        rep(i,0,33) rep(j,0,33) rep(k,0,33) rep(l,0,33)
            memo[i][j][k][l] = INIT;
        rep(i,0,H) rep(j,0,W) cin >> board[i+1][j+1];
        rep(i,0,H) rep(j,0,W) board[i+1][j+1] += board[i+1][j];
        rep(j,0,W) rep(i,0,H) board[i+1][j+1] += board[i][j+1];

        /*
        rep(i,0,H) {
            rep(j,0,W) {
                printf("%lld ", board[i+1][j+1]);
            }
            cout << endl;
        }
        */

        E = getsum(0, 0, H, W);
        // printf("debug: E = %lld\n", E);
        pii ans = solve(0, 0, H, W);
        printf("%lld %lld\n", ans.first, ans.second);
    }
    return 0;
}

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

int main()
{
    int X,N;cin >> X >> N;
    vector<int> p(151,0);
    int n;
    for (int i=0;i<N;i++)
    {
        cin >> n;
        p[n]=1;
    } 
    int ans=150;
    for (int i=150;i>=0;i--)
    {
        if (p[i]==0)
        {
            if (abs(ans-X)>=abs(i-X))
            {
                ans=i;
            }
        }
    }
    if (N==0) cout << X << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
// In the name of God //
 
#include <bits/stdc++.h>
#define ll long long
#define all(x) (x).begin(), (x).end()
#define pii pair <int, int>
using namespace std;
const int N = 2e5 + 5;

void solve() {
    int n;
    cin >> n;
    map<string, int> mp;
    mp["AC"] = 0;
    mp["WA"] = 0;
    mp["TLE"] = 0;
    mp["RE"] = 0;
    while (n--) {
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << "AC" << " x " << mp["AC"] << "\n";
    cout << "WA" << " x " << mp["WA"] << "\n";
    cout << "TLE" << " x " << mp["TLE"] << "\n";
    cout << "RE" << " x " << mp["RE"] << "\n";
}

int main()  {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int tt = 1;
    // cin >> tt;
    for (int tc = 1; tc <= tt; ++tc) {
        solve();
    } 
}                                   

Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;

int pow(int a, int n )
{
	int ret = 1 ;
	for( int i = 0; i < n; i++ ){
		ret *= a;
	}
	return ret;
}
int min( int a, int b )
{
	return (a < b) ? a : b;
}

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

	vector<int> dp(N+1);
	for( int i = 0; i < N+1; i++ ){
		dp.at(i) = i;
	}
	for( int m = 1 ; m <= N; m++ ){
		for( int n6 = 1 ; n6 <= 7 ; n6++ ) {
			int p6 = pow(6,n6);
			if( p6 <= m ){
				dp.at(m) = min(dp.at(m),dp.at(m- p6)+1);
			}else{
				break;
			}
		}
		for( int n9 = 1 ; n9 <= 6 ; n9++ ) {
			int p9 = pow(9,n9);
			if( p9 <= m ){
				dp.at(m) = min(dp.at(m),dp.at(m- p9)+1);
			}else{
				break;
			}
		}
	}
	//for( int i = 0; i < N+1; i++ )	cout << dp.at(i) << " ";
	cout << dp.at(N) << endl;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void){
        int x;
        int h,m,s;

        scanf("%d",&x);

        s = x%60;
        h = (x/60)/60;
        m = x/60 - h*60;

        printf("%d:%d:%d\n",h,m,s);
        return 0;
}

Measured memory_bytes: 592
from io import StringIO
from collections import *
from functools import *
import sys


def main(inputs):
    # n = int(next(inputs))
    # n, k = map(int, next(inputs).split())
    # xs = list(map(int, next(inputs).split()))
    n, m = map(int, next(inputs).split())
    xs = [ list(map(int, next(inputs).split())) for _ in range(m) ]
    ls, rs = zip(*xs)
    l = max(ls)
    r = min(rs)
    if l > r:
        return 0
    return r - l + 1


def gen_inputs(str_=None):
    inputs = StringIO(str_) if str_ else sys.stdin
    while True:
        a = inputs.readline().rstrip()
        yield a
        pass
    pass


if __name__ == "__main__":
    print(main(gen_inputs()))
    pass


Measured memory_bytes: 36580
#include <iostream>
#include <set>

#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
    int n;
    set<int> d;
    cin >> n;
    REP(i, n) {
        int tmp;
        cin >> tmp;
        d.insert(tmp);
    }
    cout << d.size() << endl;
}


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

int main()
{
    int n,m,x;
    cin >> n >> m >> x;
    int a,c0 = 0,cm = 0;
    for(int i = 0; i < m; i++){
        cin >> a;
        a < x ? c0++ : cm++;
    }

    cout << min(c0,cm) << endl;

    return 0;
}

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

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define REVREP(i, n)      for(ll i = n - 1; i >= 0 ; i--)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               (ll)2e9
#define INF_LL            1LL<<60
#define MOD               998244353

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
ll _accumulate(const VL &v) { return accumulate(ALL(v), (ll)0); }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// 処理
void Solve()
{
	ll N;
	cin >> N;
	VL X(N, 0);
	REP(i, N) cin >> X[i];

	if (X[0] != 0) {
		cout << -1 << endl;
		return;
	}

	ll ans = 0;
	for (ll i = 0; i < N - 1; i++) {
		if (X[i] + 1 == X[i + 1]) {
			ans++;		
		} else if (X[i] + 2 <= X[i + 1]) {
			cout << -1 << endl;
			return;
		} else {
			ans += X[i + 1];
		}
	}

	cout << ans << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
//i64 mod = 998244353;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;

int main(int argc, char **argv) {
    i64 n;
    cin >>n;

    cout << (n>=30 ? "Yes": "No") << endl;
    return 0;
}

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

using namespace std;

int main(){

  	vector<char> res;
  
  	string s; cin >> s;
  	for(int i = 0; i < s.size(); ++i){
    	if(s[i] == 'B' && !res.empty()) res.pop_back();
      	else if(s[i] != 'B') res.push_back(s[i]);
    }
	for(int i = 0; i < res.size(); ++i) cout << res[i];
  	cout << "\n";
}


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

int main(void){
    int h,w;
    cin >> h >> w;
    string s[h];
    for (size_t i = 0; i < h; i++)
    {
        cin >> s[i];
    }
    for (size_t y = 0; y < h; y++)
    {
        for (size_t x = 0;x < w;x++)
        {
            if (s[y][x]=='#')
            {
                cout << '#';
            }else
            {
                char cnt = '0';
                for (size_t i = (y==0?0:y-1); i <= (y==h-1?h-1:y+1); i++)
                {
                    for (size_t j = (x==0?0:x-1); j <= (x==w-1?w-1:x+1); j++)
                    {
                        if(s[i][j]=='#')cnt++;
                    }
                }
                cout << cnt;
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
int main()
{
	int a[5], ans = 0;
	scanf("%d%d%d", &a[1], &a[2], &a[3]);
	sort(a + 1, a + 4);
	for (int i = 2; i <= 3; i++)
		ans += a[i] - a[i - 1];
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9+1;

int main(){
    int n;
    cin>>n;
    int cnt[n]={};
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        cnt[a-1]++;
    }
    int ans[n]={};
    priority_queue<int> q;
    for(int i=0;i<n;i++){
        if(cnt[i]>0){
            q.push(-cnt[i]);
        }
    }
    for(int i=q.size();i>=1;i--){
        int p=ans[i-1]=-q.top();
        q.pop();
        if(i==1)break;
        while(p>0){
            p--;
            int r=q.top();
            q.pop();
            q.push(r-1);
        }
    }
    for(int i=0;i<n;i++){
        cout<<ans[i]<<endl;
    }
}


Measured memory_bytes: 4724
package main

import (
	"fmt"
)

type Node struct {
	p, l, r int
	d       int
	h       int
}

const NIL = -1

var n, id, l, r int

func main() {
	fmt.Scan(&n)

	nodes := make([]Node, n)
	for i := 0; i < n; i++ {
		nodes[i].p = NIL
	}

	for i := 0; i < n; i++ {
		fmt.Scan(&id)
		fmt.Scan(&l)
		fmt.Scan(&r)

		nodes[id].l = l
		nodes[id].r = r

		if l != NIL {
			nodes[l].p = id
		}
		if r != NIL {
			nodes[r].p = id
		}
	}

	//nodesができたのでrootを探す
	root := -1
	for i := 0; i < n; i++ {
		if nodes[i].p == NIL {
			root = i
			break
		}
	}

	//depthを下に向かって設定
	setDepth(nodes, root, 0)

	//高さを設定
	for i := 0; i < n; i++ {
		setHeight(nodes, i)
	}

	//出力
	for i := 0; i < n; i++ {
		print(nodes, i)
	}
}

func setDepth(nodes []Node, current int, depth int) {
	if current == NIL {
		return
	}

	nodes[current].d = depth

	setDepth(nodes, nodes[current].l, depth+1)
	setDepth(nodes, nodes[current].r, depth+1)
}

func setHeight(nodes []Node, u int) int {
	h1 := 0
	h2 := 0

	if nodes[u].l != NIL {
		h1 = setHeight(nodes, nodes[u].l) + 1
	}
	if nodes[u].r != NIL {
		h2 = setHeight(nodes, nodes[u].r) + 1
	}

	h := h1
	if h1 < h2 {
		h = h2
	}
	nodes[u].h = h
	return h
}

func getSibling(nodes []Node, u int) int {
	if nodes[u].p == NIL {
		return NIL
	}

	if nodes[nodes[u].p].l != u && nodes[nodes[u].p].l != NIL {
		return nodes[nodes[u].p].l
	}
	if nodes[nodes[u].p].r != u && nodes[nodes[u].p].r != NIL {
		return nodes[nodes[u].p].r
	}
	return NIL
}

func print(nodes []Node, u int) {
	format := "node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n"

	nodeType := ""
	if nodes[u].p == NIL {
		nodeType = "root"
	} else if nodes[u].l == NIL && nodes[u].r == NIL {
		nodeType = "leaf"
	} else {
		nodeType = "internal node"
	}

	sibling := getSibling(nodes, u)
	degree := 0
	if nodes[u].l != NIL {
		degree++
	}
	if nodes[u].r != NIL {
		degree++
	}

	fmt.Printf(format, u, nodes[u].p, sibling, degree, nodes[u].d, nodes[u].h, nodeType)

}



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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

ll gcd(ll n, ll m) {
    if (n < m) {
        swap(n, m);
    }
    if (n % m == 0) return m;
    return gcd(m, n % m);
}

int main() {
    ll N, X; cin >> N >> X;
    vector<ll> x(N);
    for (int i = 0; i < N; i++) {
        cin >> x.at(i);
    }
    ll ans, dist;
    for (int i = 0; i < N; i++) {
        if (i == 0) {
            ans = abs(X - x.at(i));
        }
        else {
            dist = abs(X - x.at(i));
            ans = gcd(ans, dist);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
A,B,N = gets.split.map &:to_i
n = [N-1-N%B,1].max
m = N%B*A - A*N%B
x = n%B*A - A*n%B
m = x  if m < x
t = Time.now
c = 0
y = N%B
N.downto(1){|n|
  l = y*A
  r = A*n %B
  x = l - r
  m = x  if m < x
  c += 1
  y -= 1
  y += B  if y < 0
  break if 0 == c&0xffff && Time.now - t > 1.92
}
p m / B

Measured memory_bytes: 14368
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
  vector<vector<int> > data;
  for (int i = 0; i < 3; ++i)
  {
    int v0, v1, v2;
    cin >> v0 >> v1 >> v2;
    vector<int> row;
    row.push_back(v0);
    row.push_back(v1);
    row.push_back(v2);
    data.push_back(row);
  }

  if (data[1][0] - data[0][0] != data[1][1] - data[0][1] || data[1][0] - data[0][0] != data[1][2] - data[0][2])
  {
    cout << "No" << endl;
  }
  else if (data[2][0] - data[0][0] != data[2][1] - data[0][1] || data[2][0] - data[0][0] != data[2][2] - data[0][2])
  {
    cout << "No" << endl;
  }
  else if (data[0][1] - data[0][0] != data[1][1] - data[1][0] || data[0][1] - data[0][0] != data[2][1] - data[2][0])
  {
    cout << "No" << endl;
  }
  else if (data[0][2] - data[0][0] != data[1][2] - data[1][0] || data[0][2] - data[0][0] != data[2][2] - data[2][0])
  {
    cout << "No" << endl;
  }
  else
  {
      cout << "Yes" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<utility>
#include<cassert>
using namespace std;
#define MS(m,z) memset(m,z,sizeof(m))
typedef unsigned U;typedef long long ll;typedef pair<int,int > P;
void inp();
int main(){
#ifdef XS
	//freopen(".in","r",stdin);
#endif
	//int ttt;scanf("%d",&ttt);for(int i=1;i<=ttt;i++)
	inp();
	return 0;
}
const ll N = 3e5 + 1e3;
ll ans[N],unq[N];
void inp(){
    ll n,a,b;scanf("%lld%lld%lld", &n, &a,&b);
    if( a + b - 1 <= n && n <= a * b){
        ll cnt = n;
        for(ll i = b - 1;i>=0;i--){
            const ll begin = a * i + 1,
                  end = a * i + a;
            //printf("%d %d\n", begin , end );
            for(ll j = begin;j<=end && cnt >= i + 1 ;j++, cnt --){
                ans[ n - cnt ] = j;
            }
        }
        //assert( cnt == 0);
        memcpy( unq, ans, sizeof(ll) * n);
        sort(unq, unq + n);
        ll * ed = unique(unq, unq + n );
        sort( unq, ed);
        for(ll i =0 ;i<n;i++){
            if( i ){
                putchar(' ');
            }
            printf("%ld", lower_bound(unq, ed,  (ans[i])) - unq + 1);
        }
    }
    else printf("-1\n");
}
//e.cc by xsthunder at Mon Aug  6 10:28:04 2018


Measured memory_bytes: 6784
//Copyright(c)2018 Mstdream
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N=200010;
int t[N],a[N],b[N],n;
void add(int x){
	for(;x<=2*n+1;x+=x&-x)t[x]++;
}
int qry(int x){
	int ret=0;
	for(;x;x-=x&-x)ret+=t[x];
	return ret;
}
bool check(int x){
	x++;
	LL ret=0;
	for(int i=1;i<=2*n;i++)t[i]=0;
	for(int i=1;i<=n;i++){
		b[i]=(a[i]>=x?1:-1);
		b[i]+=b[i-1];
		add(b[i-1]+n+1);
		ret+=qry(b[i]+n+1);
	}
	ret=(LL)n*(n+1)/2-ret;
	return ret>=((LL)n*(n+1)/2+2)/2;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	int l=1,r=1e9+1;
	while(l!=r){
		int mid=l+r>>1;
		if(check(mid))r=mid;
		else l=mid+1;
	}
	cout<<l<<endl;
}


Measured memory_bytes: 1792
#include <stdio.h> using namespace std;
 void outPut(int Array[],char mark)
{ for(int i = 1; i <= 13; i++){ if(Array[i] == 0)
 printf("%c %d\n",mark,i); } } int main(){ char mark[2];
 int n,S[14],H[14],C[14],D[14],tmp; for(int i = 0; i < 14; i++) S[i] = H[i] = C[i] = D[i] = 0; scanf("%d",&n); for(int i = 0; i < n; i++){ scanf("%s %d",mark,&tmp); switch(mark[0]){ case 'S': S[tmp] = 1; break; case 'H': H[tmp] = 1; break; case 'C': C[tmp] = 1; break; case 'D': D[tmp] = 1; break; } } outPut(S,'S'); outPut(H,'H'); outPut(C,'C'); outPut(D,'D'); } 



 



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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 100005

int n , m , x , y;
vector<bool> used(MAXX , false);
vector<int> v[MAXX];
void DFS(int n){
    used[n] = true;
    for(int i = 0; i < v[n].size(); i++){
        int to = v[n][i];
        if(!used[to])
            DFS(to);
    }
}

int main()
{
    _FastIO;

    cin >> n >> m;


    while(m--){
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(!used[i]){
            DFS(i);
            ans++;
        }
    }
    ans--;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9624
# coding: utf-8
import sys
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
answer = 0
digit = len(str(N))
# 3, 5, 7だけでできた数を列挙
for d in range(3, digit+1):
    for x in itertools.product(['3', '5', '7'], repeat=d):
        if len(set(x)) != 3:
            continue
        y = int(''.join(x))
        if y <= N:
            answer += 1

print(answer)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
struct SegTree {
    int N;
    vector<Int> A;
    SegTree(int n) {
        N = 1; while (N < n) N *= 2;
        A.resize(2 * N);
    }
    void rangeadd(int L, int R, Int val) {
        L += N, R += N;
        while (L < R) {
            if (L & 1) A[L++] += val;
            if (R & 1) A[--R] += val;
            L /= 2, R /= 2;
        }
    }
    Int get(int idx) {
        Int ans = 0;
        idx += N;
        while (idx > 0) {
            ans += A[idx];
            idx /= 2;
        }
        return ans;
    }
};
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    Int N, D, A; cin >> N >> D >> A;
    vector<pair<Int, Int>> X(N);
    for (int i = 0; i < N; i++) cin >> X[i].first >> X[i].second;
    sort(begin(X), end(X));
    SegTree st(N);
    for (int i = 0; i < N; i++) {
        st.rangeadd(i, i + 1, X[i].second);
    }
    Int ans = 0;
    for (int i = 0; i < N; i++) {
        Int hp = st.get(i);
        if (hp > 0) {
            Int k = (hp + A - 1) / A;
            int ok = i, ng = N; // ok : damaged by bomb
            while (abs(ok - ng) > 1) {
                int mid = (ok + ng) / 2;
                if (X[mid].first > X[i].first + 2 * D) {
                    ng = mid;
                } else {
                    ok = mid;
                }
            }
            st.rangeadd(i, ng, k * (-A));
            ans += k;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7552
N,M = [int(x) for x in input().split()]
ans = 0
fd = [0] * (M + 10)
for i in range(N):
  x, *xs=[int(x) for x in input().split()]
  for j in xs:
    fd[j] += 1
print(len(list(filter(lambda x: x == N, fd))))

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

int main() {
  int A , B , C;
  cin >> A >> B >> C ;
  
  if ( (A < C) && (B > C) ){
    cout << "Yes" << endl;
  }
  
  else if ( (A > C) && (B < C) ){
    cout << "Yes" << endl;
  }
  
  else{
    cout << "No" << endl;
  }

}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) < (b) ? (a) : (b))

int main(void) {
	int A, B, H, M;
	
	scanf("%d %d %d %d", &A, &B, &H, &M);
	
	double rad_A = M_PI * 2.0 * H / 12 + M_PI * 2.0 * M / 12 / 60;
	double rad_B = M_PI * 2.0 * M / 60;
	
	double distance = sqrt(A * A + B * B - 2 * A * B * cos(max(rad_A, rad_B) - min(rad_A, rad_B)));
	
	printf("%.16f\n", distance);
	
	return 0;
}

Measured memory_bytes: 2592
/*  ex5_3
    L40S38  */
#include<stdio.h>
#define LIMIT 100
int main(void){
    int high,wide,i,j,black_exist_high[LIMIT],black_exist_wide[LIMIT];
    //high,wide:マス目の縦,横の長さ
    //black_exist_high:黒いマスがあった行番号を格納
    //black_exist_wide:黒いマスがあった列番号を格納
    char cells[LIMIT][LIMIT];
    scanf("%d %d",&high,&wide);
    
    for(i=0;i<LIMIT;i++){
        black_exist_high[i]=0;
    }//black_exist_highの初期化
    for(j=0;j<LIMIT;j++){
        black_exist_wide[j]=0;
    }//black_exist_wideの初期化
    
    for(i=0;i<high;i++){
        for(j=0;j<wide;j++){
            scanf(" %c",&cells[i][j]);
            if(cells[i][j]=='#'){
                black_exist_high[i]=1;
                black_exist_wide[j]=1;
                //黒いマスがあったらその行、列に印（1）をつける
            }
        }
    }
    
    for(i=0;i<high;i++){
        if(black_exist_high[i]==1){
            for(j=0;j<wide;j++){
                if(black_exist_wide[j]==1){
                    printf("%c",cells[i][j]);
                    //行・列のどちらかに印があった要素だけ出力
                }
            }
            printf("\n");
        }
    }
    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int64_t> A_vec(N);
    for (int i = 0; i < N; ++i)
        cin >> A_vec.at(i);
    vector<int64_t> stand_vec(N, 0);
    int64_t prev = A_vec.at(0);
    for (int i = 1; i < N; ++i) {
        if (prev <= A_vec.at(i)) {
            prev = A_vec.at(i);
            continue;
        }
        stand_vec.at(i) = prev - A_vec.at(i);
    }
    int64_t sum = 0;
    for (int i = 0; i < N; ++i) {
        sum += stand_vec.at(i);
    }
    cout << sum << endl;
}


Measured memory_bytes: 6376
n = int(input())
s = input()
n = n % (ord('Z') - ord('A') + 1)
ans = ''
for i in s:
    if ord(i) + n > ord('Z'):
        ans += chr(ord(i) + n - (ord('Z') - ord('A') + 1))
    else:
        ans += chr(ord(i) + n)
print(ans)


Measured memory_bytes: 41324
n = int(input())
s = input()

count = 0
r = []
g = []
b = []

for i in range(n):
    if s[i] == 'R':
        r.append(i)
    if s[i] == 'G':
        g.append(i)
    if s[i] == 'B':
        b.append(i)

count += len(r)*len(g)*len(b)

for i in range(n-2):
    for j in range(i+1,n):
        if j+(j-i) >= n:
            continue
        k = j + (j-i)
        if (s[i] != s[j]) and (s[j] != s[k]) and (s[k] != s[i]):
            count -= 1
            
print(count)


Measured memory_bytes: 68196
N=int(input())
A=input().split()
A=[int(i) for i in A]
S=0
A_sum=0
for i in range(N):
    A_sum+=A[i]
    

B=A_sum
for i in range(N):
    B-=A[i]
    S+=A[i]*B

print(S%(pow(10,9)+7))

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) ((v).begin(),(v).end())
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int a,b;
    cin >> a >> b;
    COUT(a*b);
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
int main()
{
  int n;cin >> n;
  vector<ll> a(n);rep(i,n) cin >> a[i];
  vector<ll> sum(n+1);
  sum[0] = 0;
  rep(i,n) sum[i+1] = sum[i] + a[i];
  map<ll,ll> mp;
  rep(i,n+1) mp[sum[i]]++;
  ll res2 = 0;
  for(auto m:mp){
    res2 += m.second*(m.second-1)/2;
  }
  cout << res2 << "\n";
  // ll res = 0;
  // rep(i,n+1){
  //   mp[sum[i]]--;
  //   res += mp[sum[i]];
  // }
  // cout << res << "\n";
  return 0;
}


Measured memory_bytes: 15872
M,N,K = [int(hoge) for hoge in input().split()]
A = [int(hoge) for hoge in input().split()]
B = [int(hoge) for hoge in input().split()]
S = 0
Abook = 0
Bbook = 0
curbook = 0
for a in A:
    if S + a <= K:
        Abook += 1
        curbook += 1
        S += a
    else:
        break
nextB = 0
for n,b in enumerate(B):
    if S + b <= K:
        Bbook += 1
        curbook += 1
        S += b
    else:
        nextB = n
        break
if Abook == len(A) and Bbook == len(B):
    print(len(A) + len(B))
    exit()

ans = curbook
for i in range(Abook):
    Abook -= 1
    curbook -= 1
    S -= A[Abook]
    for b_index in range(nextB,len(B)):
        if S + B[b_index] <= K:
            Bbook += 1
            curbook += 1
            S += B[b_index]
            nextB += 1
        else:
            nextB = b_index
            break
    ans = max(ans,curbook)
print(ans)

Measured memory_bytes: 111672
import java.awt.Polygon;
import java.awt.geom.Line2D;
import java.io.IOException;
import java.util.Scanner;

public class Main {

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

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			for (int i = 0; i < n; i++) {
				int m = scanner.nextInt();
				Polygon[] tetragon = new Polygon[m];
				Line2D[][] lines = new Line2D[m][4];
				for (int j = 0; j < m; j++) {
					int[] xs = new int[4];
					int[] ys = new int[4];
					for (int j1 = 0; j1 < 4; j1++) {
						xs[j1] = scanner.nextInt();
						ys[j1] = scanner.nextInt();
					}
					tetragon[j] = new Polygon(xs, ys, 4);
					for (int k = 0; k < 4; k++) {
						lines[j][k] = new Line2D.Double(xs[k], ys[k],
								xs[(k + 1) % 4], ys[(k + 1) % 4]);
					}
				}
				UnionFin unionFin = new UnionFin(m);
				for (int j = 0; j < m; j++) {
					for (int k = j + 1; k < m; k++) {
						boolean flag = false;
						if (tetragon[j].contains(tetragon[k].xpoints[0],
								tetragon[k].ypoints[0])
								|| tetragon[k].contains(tetragon[j].xpoints[0],
										tetragon[j].ypoints[0])) {
							flag = true;
						}
						if (!flag)
							for (int l = 0; l < 4; l++) {
								for (int p = 0; p < 4; p++) {
									if (lines[j][l].intersectsLine(lines[k][p])) {
										flag = true;
										break;
									}
								}
							}
						if (flag)
							unionFin.unite(j, k);
					}
				}
				System.out.println(unionFin.num);
			}
		}
	}

	class UnionFin {
		int[] par, rank;
		int num;

		public UnionFin(int size) {
			num = size;
			par = new int[size];
			rank = new int[size];
			for (int i = 0; i < size; i++)
				par[i] = i;
		}

		int root(int x) {
			if (par[x] == x)
				return x;
			else
				return par[x] = root(par[x]);
		}

		void unite(int x, int y) {
			x = root(x);
			y = root(y);
			if (x == y)
				return;
			if (rank[x] < rank[y])
				par[x] = y;
			else {
				par[y] = x;
				if (rank[x] == rank[y])
					rank[x]++;
			}
			num--;
		}

		boolean isSame(int x, int y) {
			return root(x) == root(y);
		}
	}
}

Measured memory_bytes: 33120
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;

int main() {
  int n;
  cin >> n;
  ll total = 0;
  rep(i, n) {
    int k;
    cin >> k;
    total += k - 1;
  }
  cout << total << endl;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 61)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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; }

i64 ceil(i64 a, i64 b) { return (a+b-1)/b; }
mt19937 rnd(time(NULL));

int d, c[30], s[404][30];
int ans[400];
clock_t start;

int score(int a[400], int l, int r){
	int cnt = 0;
	int last[26] = {};
	fill(last,last+26,l-1);
	
	for(int i = l; i < r; i++){
		cnt += s[i][a[i]];
		last[a[i]] = i;
		for(int j = 0; j < 26; j++){
			cnt -= c[j]*(i-last[j]);
		}
	}
	return cnt;
}

void solve(){
	start = clock();
	
	cin >> d;
	for(int i = 0; i < 26; i++) cin >> c[i];
	for(int i = 0; i < d; i++){
		for(int j = 0; j < 26; j++) cin >> s[i][j];
	}
	
	int ma = 0;
	for(int i = 0; i < d; i++){
		// int v = i%26;
		// ans[i] = v;
		ans[i] = rnd()%26;
	}
	ma = score(ans,0,d);
	
	int cc[30] = {};
	for(int i = 0; i < 26; i++){
		cc[i+1] = c[i] + cc[i];
	}
	
	int value[30] = {};
	int lp = 0;
	while(clock()-start < 1.9*CLOCKS_PER_SEC){
		int res[400] = {};
		int last[26] = {};
		fill(last,last+26,-1);
		for(int i = 0; i < d; i++){
			res[i] = ans[i];
			int r = rnd()%200;
			if(r == 0){
				for(int j = 0; j < 26; j++){
					value[j+1] = value[j];
					value[j+1] += c[i] * (i-last[j])*(i-last[j]-1)/2;
					value[j+1] += s[i][j];
				}
				r = rnd()%value[26];
				r = lower_bound(value,value+26, r)-value-1;
				res[i] = r;
			}
			last[res[i]] = i;
		}
		
		if(chmax(ma,score(res,0,d))){
			for(int i = 0; i < d; i++){
				ans[i] = res[i];
			}
		}
		//cout << score(res,0,d) << endl;
		lp++;
	}
	//cout << lp << endl;
	//cout << ma << endl;
	
	for(int i = 0; i < d; i++){
		cout << ans[i]+1 << endl;
	}
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <map>
#include <cmath>
#include <bitset>
#include <deque>
#define MAX_N 100
#define MAX_T 200
#define INF 4000000000000000000
#define fst first
#define snd second
typedef long long ll;
typedef std::pair<int,int> ii;
using namespace std;

int main(){
  ll n,ans,t;
  ll a[100000];
  cin>>n;

  for(ll i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a, a+n);
  t=1;ans=1;
  for(ll i=1;i<n;i++){
    if(a[i]==a[i-1]){
      t*=-1;
    }else{
      t=1;
    }
    ans+=t;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
N, A, B = (int(i) for i in input().split())
# 求めたい総和
sum = 0
for i in range(N + 1):
    # 各桁の総和
    digitsum = 0
    i_copy = i
    while i > 0:
        digitsum += i % 10
        i = i // 10

    if A <= digitsum <= B:
        sum += i_copy
print("{}".format(sum))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define mt              make_tuple
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define range(a,b)		substr(a,b-a+1)
#define w(x)            int x; cin>>x; while(x--)
#define trace(x) 		cerr<<#x<<": "<<x<<" "<<endl;
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int dp[1000001][2][2] = {};
int32_t main()
{
	FIO;
	int n; cin >> n;

	dp[0][0][0] = 8;
	dp[0][1][0] = dp[0][0][1] = 1;

	for (int i = 1; i < n; ++i)
	{
		dp[i][0][0] = (dp[i - 1][0][0] * 8ll) % mod;
		dp[i][1][0] = (dp[i - 1][0][0] + dp[i - 1][1][0] * 9ll) % mod;
		dp[i][0][1] = (dp[i - 1][0][0] + dp[i - 1][0][1] * 9ll) % mod;
		dp[i][1][1] = (dp[i - 1][1][1] * 10ll + dp[i - 1][1][0] + dp[i - 1][0][1]) % mod;
	}

	cout << dp[n - 1][1][1] << '\n';
	return 0;
}

Measured memory_bytes: 34764