akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

#include<iomanip>
using namespace std;

int main()
{

    int n;
    double s=0,x;
    cin>>n;

    int a[n];

    for(int i=0;i<n;i++){

        cin>>a[i];
        s+=(1.0/a[i]);
    }

    x=(1.0/s);

    cout<<showpoint;
    cout<<setprecision(16);
    cout<<x<<endl;


    return 0;
}



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

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

  string N;
  cin >> N;
  for(int i = 0; i < 3; i++){
    if(N[i] == '7'){
      cout << "Yes" <<endl;
      return 0;
    }
  }
  cout << "No" <<endl;
}



Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
 
int main() {
	int a, b; scanf("%d%d", &a, &b);
	puts(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0 ? "Possible" : "Impossible");
}

Measured memory_bytes: 256
n = int(input())
s = [list(input()) for i in range(n)]
s += s

def ok(array):
    for i in range(1,n):
        for j in range(i):
            if array[i][j] != array[j][i]:
                return False
    return True
ans = 0
for i in range(n):
    if ok(s[i:i+n]):
        ans += n
print(ans)


Measured memory_bytes: 43120
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
ll n,m,k,ans;
string s,t;
const ll powll = 1LL<<1;

bool cmp(P a, P b){
  return a.first+a.second < b.first+ b.second;
}

int main(void){
  int a,b; cin >> a >> b;
  if(a == b) cout << "Yes\n";
  else cout << "No\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
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; }

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

const ll INF = 1ll<<60;

 
int main(){
    int n, w;
    cin >> n >> w;
    vec<vec<ll>> dp(n+1, vec<ll>(1e5));
    rep(i, n) rep(j, 100005) dp[i][j] = INF;
    dp[0][0] = 0;
    rep(i, n) {
        int wi, vi;
        cin >> wi >> vi;
        rep(j, 100005) {
            if (j-vi<0) dp[i+1][j] = dp[i][j];
            else dp[i+1][j] = min(dp[i][j], dp[i][j-vi] + wi);
        }
    }
    ll ans = 0;
    rep(j, 100005) if (dp[n][j]<=w) ans = j;
    cout << ans << endl;
}

Measured memory_bytes: 80256
module vector_int32_mod
    use,intrinsic :: iso_fortran_env
    type vector
        integer(int64),allocatable:: array(:)
        integer(int64):: l
    contains
        procedure :: push_back => vector_regist
    end type

    interface vector
        module procedure vector_init
    end interface
    private
    public:: vector
contains
    function vector_init() result(vec)
        type(vector):: vec
        allocate(vec%array(1))
        vec%l = 0
    end function

    subroutine vector_regist(vec, v)
        class(vector):: vec
        integer(int64):: v

        if (vec%l+1 > size(vec%array)) call add_(vec)
        vec%l=vec%l+1
        vec%array(vec%l) = v
    end subroutine


    subroutine add_(vec)
        type(vector):: vec
        integer(int64),allocatable:: tmp(:)
        integer(int64):: l

        l = size(vec%array)
        allocate(tmp(l))
        tmp(:) = vec%array(:)
        deallocate(vec%array)
        allocate(vec%array(l*2))
        vec%array(1:l) = tmp(:)
        deallocate(tmp)
    end subroutine
end module

program main
    use,intrinsic :: iso_fortran_env
    use vector_int32_mod
    implicit none
    integer(int64):: n,q,k,i
    integer(int64), allocatable:: a(:), b(:), c(:), x(:), y(:)
    integer(int64), allocatable:: k_dist(:)
    type(vector), allocatable:: to(:), d(:)
    
    read*, n
    allocate(a(n-1), b(n-1), c(n-1))
    allocate(to(n), d(n))
    allocate(k_dist(0:n))

    do i=1,n
        to(i) = vector()
        d(i) = vector()
    end do
    
    do i=1,n-1
        read*, a(i), b(i), c(i)
        call to(a(i))%push_back(b(i))
        call to(b(i))%push_back(a(i))
        call d(a(i))%push_back(c(i))
        call d(b(i))%push_back(c(i))
    end do

    read*, q,k
    allocate(x(q), y(q))
    k_dist(0)=0_8
    call dfs(k,0_8,0_8)

    do i=1,q
        read*, x(i), y(i)
    end do

    do i=1,q
        print'(i0)', k_dist(x(i)) + k_dist(y(i))
    end do
contains
    recursive subroutine dfs(self, from, distance)
        integer(int64), intent(in):: self, from, distance
        integer(int64):: i, next, next_d

        k_dist(self) = k_dist(from)+distance

        do i=1,to(self)%l
            next = to(self)%array(i)
            next_d = d(self)%array(i)
            if (next == from) cycle
            call dfs(next, self,next_d)
        end do
    end subroutine
end program main

Measured memory_bytes: 37216
import sys
input = sys.stdin.readline


n = int(input())
a = list(map(int, input().split()))
MOD = 998244353
max_a = max(a)

c = [0] * (max_a + 1)
for i in range(1, max_a + 1):
    c[i] = pow(i, MOD - 2, MOD)

for i in range(1, max_a):
    j = i
    while True:
        j += i
        if j <= max_a:
            c[j] -= c[i]
            c[j] %= MOD
        else:
            break

cnt = [0] * (max_a + 1)
for i in range(n):
   cnt[a[i]] += 1

ans = 0
for i in range(1, max_a + 1):
    tmp0 = 0
    tmp1 = 0
    j = i
    while True:
        if j <= max_a:
            tmp0 += cnt[j] * j
            tmp1 += cnt[j] * (j ** 2)
        else:
            break
        j += i
    tmp0 *= tmp0
    ans += (tmp0 - tmp1) * c[i]
    ans %= MOD

print((ans * pow(2, MOD - 2, MOD)) % MOD)

Measured memory_bytes: 88524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define INF 1007654321
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<typename U, typename V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}
 
const int MAXN = 700 + 10;
int N, M;
bool connected[MAXN][MAXN];
vector<int> adj[MAXN];
int T[MAXN], C[MAXN];
int component = 0;
bool DP[MAXN][2*MAXN+1];
 
bool dfs(int curr, int color) {
    C[curr] = component;
    T[curr] = color;
    bool ans = true;
    for(auto &next : adj[curr]) {
        if(C[next] == 0) {
            ans &= dfs(next, 3 - color);
        } else {
            ans &= (T[curr] != T[next]);
        }
    }
    return ans;
}
 
int main() {
    FAST_IO();
    cin >> N >> M;
    rep(i, M) {
        int a, b; cin >> a >> b;
        connected[a-1][b-1] = true;
        connected[b-1][a-1] = true;
    }
    rep(i, N) rep(j, N) {
        if(i != j && !connected[i][j]) {
            adj[i].push_back(j);
            adj[j].push_back(i);
        }
    }
    rep(i, N) {
        if(C[i] == 0) {
            component++;
            if(!dfs(i, 1)) {
                cout << "-1\n";
                return 0;
            }
        }
    }
    vector<int> X;
    repp(i, 1, component) {
        int t1 = 0, t2 = 0;
        rep(j, N) {
            if(C[j] == i) {
                t1 += T[j] == 1;
                t2 += T[j] == 2;
            }
        }
        X.push_back(abs(t1-t2));
    }
    rep(i, component) {
        repp(j, -N, N) {
            if(i == 0) {
                DP[i][j + N] = (j == X[i] || j == -X[i]);
            } else {
                if(j + N - X[i] < 0 ) DP[i][j + N] = DP[i-1][j + N + X[i]];
              	else if(j + N + X[i] > 2*N+1) DP[i][j + N] = DP[i-1][j + N - X[i]];
                else DP[i][j + N] = DP[i-1][j + N - X[i]] || DP[i-1][j + N + X[i]];
            }
        }
    }
    int d = 0;
    repp(diff, 0, N) {
        if(DP[component - 1][N + diff] || DP[component - 1][N - diff]) {
            d = diff;
            break;
        }
    }
    int x = (N - d) / 2, y = N - x;
    cout << x * (x - 1) / 2 + y * (y - 1) / 2 << endl;
}

Measured memory_bytes: 6016
# Problem https://atcoder.jp/contests/abc081/tasks/abc081_b
# Python 3rd Try
import math


def solve(N, Ai):
    answer = int(math.log2(10**9)) + 1
    eachCounter = [0] * N
    for j in range(0, N):
        counter = 0
        while True:
            if Ai[j] % 2 == 0:
                counter = counter + 1
                Ai[j] = Ai[j] / 2
            else:
                break
        eachCounter[j] = counter
    for j in range(0, N):
        if eachCounter[j] < answer:
            answer = eachCounter[j]

    return answer


if __name__ == "__main__":
    N = int(input())
    Ai = list(map(int, input().split(' ')))
    print(solve(N, Ai))


Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
int n;
V<int> z(V<int> v){
	int i=1,j=0,t;
	V<int> s;
	s.resize(v.size());
	s[0]=v.size();
	while(i<v.size()){
		while(i+j<v.size()&&v[i+j]==v[j])j++;
		s[i]=j;
		if(!j){
			i++;continue;
		}
		t=1;
		while(i+t<v.size()&&t+s[t]<j){
			s[i+t]=s[t];
			t++;
		}
		i+=t;
		j-=t;
	} 
	RE s;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	V<int> v,a,b;
	cin>>n;
	a.resize(n);v.resize(3*n+1);b.resize(n);
	rep(i,0,n)cin>>a[i];
	rep(i,0,n)cin>>b[i];
	rep(i,0,n){
		v[i]=b[i]^b[(i+1)%n];
	}
	v[n]=-1;
	rep(i,0,n){
		v[i+n+1]=a[i]^a[(i+1)%n];
		v[i+n*2+1]=v[i+n+1];
	}
	V<int> ans=z(v);
	FOR(i,n+1,2*n){
		if(ans[i]>=n-1){
			cout<<i-n-1<<' '<<(a[i-n-1]^b[0])<<'\n';
		}
	}
	RE 0;
}



Measured memory_bytes: 9688
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)
    cin >> a[i];
    int max = 1000000000000;
    
    for(int i = -100; i < 101; i++){
        int sum = 0;
        for(int j = 0; j < n; j++){
            sum += (a[j] - i) * (a[j] - i);
            
      }
        max= min(max,sum);
    }
    cout << max << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String a = sc.nextLine();
		String[] array = a.split("");
		int l = array.length;
		int count = 0;

		for(int i = 0; i < l/2;i++){
			if(!array[i].equals(array[l-i-1])){
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21844
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

class program
{
    static public int mod = 1000000007;
    static void Main()
    {
        var l = rint();
        double a = (double)l / 3;
        Write(a * a * a);
    }

    static int pow(int a, int b) { string binary = Convert.ToString(b, 2); int bileng = binary.Length; long a_power = a; long value = 1; for (int i = bileng - 1; i >= 0; i--) { if (binary[i] == '1') { value = value * a_power % mod; } a_power = a_power * a_power % mod; } return (int)value; }
    static string rstr() { return ReadLine(); }
    static int rint() { return int.Parse(ReadLine()); }
    static long rlong() { return long.Parse(ReadLine()); }
    static string[] stra() { return ReadLine().Split(' '); }
    static char[] chara() { string[] a = stra(); string b = ""; for (int i = 0; i < a.Length; i++) { b += a[i]; } return b.ToCharArray(); }
    static int[] inta() { string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; }
    static long[] longa() { string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; }
    static double[] doublea() { string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_double_array[countup_i] = double.Parse(read_str_array[countup_i]); } return return_double_array; }
    static long GCD(long a, long b) { if (a < b) { long temp = a; a = b; b = temp; } if (a % b == 0) { return b; } else { long temp = b; b = a % b; a = temp; return GCD(a, b); } }
    static long LCM(long a, long b) { return a * b / GCD(a, b); }
    static void WriteArray2(int[,] a, int b, int c) { for (int i = 0; i < b; i++) { for (int j = 0; j < c; j++) { if (j != 0) Write(" "); Write(a[i, j]); } WriteLine(); } }
    static void WriteArray(int[] a, int b) { for (int i = 0; i < b; i++) { Write(" "); Write(a[i]); } WriteLine(); }
}


Measured memory_bytes: 27564
n, k = map(int, input().split(" "))
r, s, p = map(int, input().split(" "))
t = input()
t = list(t)
ans = 0
key = []

for i in range(k):
    key.append(t[i::k])
m = len(key)
#print(key)
for i in range(m):
    flag = 0
    for j,tem in enumerate(key[i]):
        if j == 0:
            if tem == 'r':
                ans += p
            elif tem == 's':
                ans += r
            else:
                ans += s
        elif j < len(key[i])-1:
            if (flag == 0)and(tem == key[i][j-1]):
                ans = ans
                flag = 1
            elif (flag == 1) and (tem == key[i][j-1]):
                if tem == 'r':
                    ans += p
                elif tem == 's':
                    ans += r
                else:
                    ans += s 
                flag = 0
            else:    
                if tem == 'r':
                    ans += p
                elif tem == 's':
                    ans += r
                else:
                    ans += s
                if tem == key[i][j+1]:
                    flag = 0
        else:
            if (flag == 0)and(tem == key[i][j-1]):
                ans = ans
                flag = 1
            elif (flag == 1) and (tem == key[i][j-1]):
                if tem == 'r':
                    ans += p
                elif tem == 's':
                    ans += r
                else:
                    ans += s 
                flag = 0
            else:    
                if tem == 'r':
                    ans += p
                elif tem == 's':
                    ans += r
                else:
                    ans += s
                              
print(ans)         

Measured memory_bytes: 12712
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
const int dx[] = { -1, 0, 0, 1 }, dy[] = { 0, -1, 1, 0 };
//[const int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 }, dy[] = { 0, -1, 1, -1, 1, 0, -1, 1 };
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
int place(int x, int y, int w) { return w*x + y; }

typedef vector<vi> mat;
mat fld;
int h, w;

int check(int x, int y)
{
	int a = fld[x][y];
	int b = fld[x + 1][y];
	int c = fld[x][y + 1];
	int d = fld[x + 1][y + 1];
	if (a == -1 || b == -1 || c == -1 || d == -1) return 1;
	if (a != b&&a != c&&a != d&&b != c&&b != d&&c != d) return 0;
	return 1;
}

int cnt = 0;
void solve(int p)
{
	int x = p / w, y = p % w;
	if (p == h*w) cnt++;
	else if (fld[x][y] != -1) solve(p + 1);
	else
	{
		fld[x][y] = p;
		if (x != h - 1 && fld[x + 1][y] == -1)
		{
			fld[x + 1][y] = p;
			if ((x > 0 && y > 0 && check(x - 1, y - 1) && check(x, y - 1)) || (x == 0 || y == 0)) solve(p + 1);
			fld[x + 1][y] = -1;
		}
		if (y != w - 1 && fld[x][y + 1] == -1)
		{
			fld[x][y + 1] = p;
			if ((x > 0 && y > 0 && check(x - 1, y - 1) && check(x - 1, y)) || (x == 0 || y == 0)) solve(p + 1);
			fld[x][y + 1] = -1;
		}
		fld[x][y] = -1;
	}
}

int main()
{
	while (cin >> h >> w, h)
	{
		fld.clear();
		fld.resize(h, vi(w, -1));
		queue<pair<mat, int>> que;
		que.push(make_pair(fld, 0));
		cnt = 0;
		solve(0);
		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 3156
package main

import "fmt"

func main() {
	var n, k, q int
	fmt.Scan(&n, &k, &q)

	// ans := make([]int , n)
	scores := make([]int, n)
	for i := 0; i < n; i++ {
		scores[i] = k - q
	}
	corCnt:= map[int]int{}
	for i := 0; i < q ; i++ {
		var a int
		fmt.Scan(&a)
		corCnt[a-1]++
	}


	for k, v := range corCnt {
		scores[k] += v
	}
	for _, v := range scores {
		if v > 0 {
			fmt.Println("Yes")
			continue
		}
		fmt.Println("No")
	}
}



Measured memory_bytes: 8320
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    

N=int(input())
a=[int(input()) for _ in range(N)]

lt=0
cnt=0

while lt!=1 and cnt<N:
	lt=a[lt]-1
	cnt+=1
	
if lt==1:
	print(cnt)
else:
	print(-1)

Measured memory_bytes: 7084
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  int count=0;
    vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
    count+=A[i];
  }
  int c=count;
  int a=0;
  for(int i=0;i<N;i++){
  cin>>A[i];
    a+=A[i];
    c=min(c,abs(a-(count-a)));
    
  
  }
cout<<c<<endl;
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

int cnt[MAXN];

void solve(){
	int n, a, ans = 0;
	scanf("%d", &n);
	REP(i, 0, n){
		scanf("%d", &a);
		cnt[a]++;
	}
	REP(i, 1, MAXN){
		if (cnt[i]){
			ans++;
		}
	}
	if (ans % 2 == 0){
		ans--;
	}
	printf("%d\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = 1 << 29;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const int MAX_V = 500;
// const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
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; }











void solve() {
    ll n;
    ll a[200010];
    cin>>n;
    rep(i,n) cin>>a[i];
    ll cnt[200010];
    cnt[n]=0;
    for(ll i=n-1;i>=0;i--){
        cnt[i] = cnt[i+1]+a[i];
        cnt[i]%=MOD;
    }
    ll ans=0;
    rep(i,n){
        ans+=(a[i]*cnt[i+1]%MOD);
        ans%=MOD;
    }
    cout<<ans<<endl;
    // rep(i,n+1) cout<<cnt[i]<<endl;




}







signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);


    ll t=1;
    rep(i,t){
        solve(); 
    }


    return 0;
}

Measured memory_bytes: 6764
#include <bits/stdc++.h>
//#include<fstream>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define all(con) con.begin(),con.end()
#define w(x) int x; cin>>x; while(x--)
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

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

/*ofstream fout("bcount.out");
ifstream fin("bcount.in");*/

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
    int x;
    cin>>x;
    if(x >= 30)
         cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3580
#include<stdio.h>

int main(){

    int N,K;
    scanf("%d %d", &N, &K);

    double p[N];
    for (int i = 0; i < N; i+=1){
        scanf("%lf", &p[i]);
    }

    double exp[N];
    for (int i = 0; i < N; i += 1){
        exp[i] = (p[i] + 1) / 2;
    }

    double sum_exp[N - K + 1];
    double sum = 0;

    for (int i = 0; i < K; i++){
        sum += exp[i];
    }

    sum_exp[0] = sum;

    for (int i = 1; i < N - K + 1; i += 1){

        sum_exp[i] = sum_exp[i-1] - exp[i-1] + exp[i+K-1];
    }

    double max = 0;

    for (int i = 0; i < N - K + 1; i++){
        if(max < sum_exp[i]){
            max = sum_exp[i];
        }
    }

    printf("%lf\n", max);

    return 0;
}

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

using namespace std;
const int N=2e5+10;
int a[N];
const int MAX=1e9+10;
vector <int> g[N];
int f[N];
int n;
int ans[N];
void dfs(int fa,int now){
    int pos=lower_bound(f,f+n+1,a[now])-f;
    int tmp=f[pos];
    f[pos]=min(a[now],f[pos]);
    for(int i=0;i<g[now].size();i++){
        if(g[now][i]==fa) continue;
        dfs(now,g[now][i]);
    }
    ans[now]=lower_bound(f,f+n+1,MAX)-f-1;
    f[pos]=tmp;
}
int main()
{
    //cout<<0x3f;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n-1;i++){
        int x,y;
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    memset(f,0x3f,sizeof(f));
    f[0]=0;
    dfs(1,1);
    for(int i=1;i<=n;i++) cout<<ans[i]<<endl;
}


Measured memory_bytes: 31104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int H;
  int N;
  cin >> H >> N;
  int saidai;
  saidai = 0;
  for (int i=0; i<N; i++){
  int A;
    cin >> A;
    saidai += A;
  }
  if (saidai >= H){
    cout << "Yes";
  } else {
    cout << "No";
  }
  
  
  
}

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


int main(){
    map<string, int> p;
    int n; cin >> n;
    rep(i,n){
        string s;
        cin >> s;
        p[s] ++;
    }
    int m; cin >> m;
    rep(i,m){
        string t;
        cin >> t;
        p[t] --;
    }
    int a=0;
    for(auto x:p){
        a=max(a,x.second);
    }
    cout << a << endl;
}

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

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

int main() {
    //cout.precision(10);
    int h, w;
    cin >> h >> w;
    int a[600][600];
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            cin >> a[i][j];
        }
    }
    vector<int> ans;
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            if((i == h) && (j == w)){
                break;
            }
            if(a[i][j] % 2 == 0){
                continue;
            }
            if(j < w){
                a[i][j + 1]++;
                ans.push_back(i);
                ans.push_back(j);
                ans.push_back(i);
                ans.push_back(j + 1);
                continue;
            }
            a[i + 1][j]++;
            ans.push_back(i);
            ans.push_back(j);
            ans.push_back(i + 1);
            ans.push_back(j);
        }
    }
    cout << ans.size() / 4 << endl;
    for(int i = 0; i < ans.size(); i++){
        cout << ans[i];
        if(i % 4 == 3){
            cout << endl;
        } else {
          cout << " ";
        }
    }
    return 0;
}


Measured memory_bytes: 5488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
double dp[305][305][305];
ll cnt[4];
double dfs(int a, int b, int c) {
  if (a == 0 && b == 0 && c == 0)
    return 0;
  if (dp[a][b][c] != -1)
    return dp[a][b][c];
  double ans = 1.0 * n / (a + b + c);
  if (a)
    ans += 1.0 * dfs(a - 1, b, c) * a / (a + b + c);
  if (b)
    ans += 1.0 * dfs(a + 1, b - 1, c) * b / (a + b + c);
  if (c)
    ans += 1.0 * dfs(a, b + 1, c - 1) * c / (a + b + c);
  return dp[a][b][c] = ans;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    cnt[x]++;
  }
  for (int i = 0; i <= 300; i++) {
    for (int j = 0; j <= 300; j++) {
      for (int k = 0; k <= 300; k++)
        dp[i][j][k] = -1;
    }
  }
  printf("%.12lf\n", dfs(cnt[1], cnt[2], cnt[3]));
}


Measured memory_bytes: 219520
#include<iostream>
#include<stack>
#include<cstdlib>
using namespace std;

int main(){
    stack<int> S;
    int a,b,x;
    string s;

    while(cin >> s){ 
        if(cin.eof())break;
        if (s[0] == '+'){
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a+b);
        }else if(s[0] == '-'){
            b = S.top(); S.pop();
            a = S.top(); S.pop();
            S.push(a-b);
        }else if(s[0] == '*'){
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a*b);
        }else{
            S.push(atoi(s.c_str()));
        }
    }   
    cout << S.top() << endl;
    return 0;
}



Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;

int main(){
    lint w, h;
    scanf("%lld%lld", &w, &h);
    lint sum = 0;
    lint a[w], b[h];
    rep(i, w){
        scanf("%lld", &a[i]);
        sum += a[i] * (h+1);
    }
    rep(i, h){
        scanf("%lld", &b[i]);
        sum += b[i] * (w+1);
    }
    sort(a, a+w);
    sort(b, b+h);
    rep(i, w) sum -= a[i] * (upper_bound(b, b+h, a[i]) - b);
    rep(i, h) sum -= b[i] * (lower_bound(a, a+w, b[i]) - a);
    printf("%lld", sum);
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int temp,n,k,count;
  	cin >> n>> k;
  	count = 0;
  	for(int i=0;i<n;i++)
    {
    	cin >> temp;
      	if(temp>=k)
          	count++;
    }
  	printf("%d\n",count);
  	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int N = Integer.parseInt(sc.next());

    long[] H = new long[N];
    for (int i = 0; i < N; i++) {
      H[i] = Long.parseLong(sc.next());
    }

    for (int i = H.length-1; i > 0; i--) {
      if (H[i] < H[i-1]) {
        if (H[i] == H[i-1]-1) {
          H[i-1]--;
        } else {
          System.out.println("No");
          return;
        }
      }
    }

    System.out.println("Yes");
  }
}

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

int N;
int C[555], S[555], F[555];

int main() {
   cin >> N;
   for (int i = 0; i < N-1; i++) {
      cin >> C[i] >> S[i] >> F[i];
   }

   for (int i = 0; i < N; i++) { // 駅iを始点とする
      int t = 0; // 現在時刻
      for (int j = i; j < N-1; j++) {
         // 駅jから駅j+1までにかかる時間を計算
         int k = max(0, (t - S[j] + F[j] - 1) / F[j]);
         t = S[j] + F[j]*k + C[j];
      }
      cout << t << endl;
   }

   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>

using namespace std;


int main(){
    //bool ans=false;
   vector<char> a,b;
   int n;
   cin>>n;
   for(int i=0;i<n;i++){
       char c;
       cin>>c;
       a.push_back(c);
   }
   for(int i=0;i<n;i++){
       char c;
       cin>>c;
       b.push_back(c);
   }

   for(int i=0;i<n;i++){
       cout<<a[i]<<b[i];
   }
   cout<<endl;

    return 0;
}

Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
const int N = 2e5 + 2;

int n;
ll k, a[N], b[N];

int ok(ll x) {
    ll res = 0;
    for (int i = 0; i < n; ++i)
        if (x < a[i] * b[i]) 
            res += (a[i] * b[i] - x - 1) / b[i] + 1;
    return res <= k;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> k;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int i = 0; i < n; ++i)
        cin >> b[i];
    sort(a, a + n);
    sort(b, b + n);
    reverse(b, b + n);
    ll l = 0, r = 1e12;
    while (l < r) {
        ll m = l + (r - l >> 1);
        if (!ok(m)) l = m + 1;
        else r = m;
    }
    cout << l << '\n';
}

Measured memory_bytes: 3328
from distutils.util import strtobool
s = input()
ss = [int(s[0]) if x % 2 == 0 else int(s[0])^1 for x in range(len(s))]

cnt = 0
for i in range(len(s)):
    if int(s[i]) != ss[i]:
        cnt += 1

print(cnt)

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

public class Main {
	static public void main(String [] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PriorityQueue<Integer> que = new PriorityQueue<Integer>(10,new Comp());
		while (true){
			StringTokenizer st=new StringTokenizer(br.readLine());
			String str=st.nextToken();
			if (str.equals("insert")){
				que.add(Integer.parseInt(st.nextToken()));
			}else if (str.equals("extract")){
				System.out.println(que.poll());
			}else if (str.equals("end")) System.exit(0);
		}
	}
	private static class Comp implements Comparator<Integer>{
        public int compare(Integer x,Integer y){
            return (x < y) ? 1 : ((x == y) ? 0 : -1);
        }
    }
		
}

Measured memory_bytes: 192608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b;
int main(){
  cin>>a>>b;
  b/=__gcd(a,b);
  ll x=b;
  ll ans=1;
  map<ll,bool> mp;
  for(ll i=2;i*i<=b;i++){
    while(x%i==0){
      if(!mp[i])ans*=i;
      mp[i]=true;
      x/=i;
    }
  }
  if(x>1)ans*=x;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1196
#include <iostream>
using namespace std;
constexpr long INF = 1L << 60;

long n, a[100010];

bool C(long x, bool f) {
  for(int i = 0; i < n; ++i) {
    x = x - x % a[i];
  }
  return (f ? x >= 2 : x <= 2);
}

int main() {
  cin.tie(0); ios_base::sync_with_stdio(false);
  cin >> n;
  for(int i = 0; i < n; ++i) cin >> a[i];
  long l = 0, r = INF, L, R;
  while(r - l > 1) {
    long mid = (l + r)>>1;
    if(C(mid,1)) r = mid;
    else l = mid;
  }
  L = r;

  l = 0, r = INF;
  while(r - l > 1) {
    long mid = (l + r)>>1;
    if(C(mid,0)) l = mid;
    else r = mid;
  }
  R = l;

  if(L < R) cout << L << endl << R;
  else cout << -1;

  return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int c[] = new int[500],s[] = new int[500],f[] = new int[500];

		for(int i = 0; i < n-1; i++) {
			c[i] = sc.nextInt();//次の駅にc秒で向かう
			s[i] = sc.nextInt();//s秒が始発
			f[i] = sc.nextInt();//f秒置きに発車
		}
		for(int i = 0; i < n; i++) {//駅1から駅nまで全探索
			int t = 0;//最初の時間は0
			for(int j = i; j < n-1; j++) {//j駅目からn駅目まで移動する
				if(t<s[j]) t=s[j];
				else if(t%f[j]==0);
				else t=t+f[j]-t%f[j];
				t += c[j];
			}
			System.out.println(t);
		}
	}
}


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

using namespace std;

int n;
string s;

void solve(int first, int second) {
    vector<int> ans(n);
    ans[0] = first;
    ans[1] = second;
    for (int i = 1; i < n - 1; ++i) {
        if (ans[i] ^ (s[i] == 'x')) {
            ans[i + 1] = ans[i - 1];
        } else {
            ans[i + 1] = ans[i - 1] ^ 1;
        }
    }
    if (ans[n - 1] ^ (s[n - 1] == 'x')) {
        if (ans[0] != ans[n - 2]) return;
    } else {
        if (ans[0] == ans[n - 2]) return;
    }
    if (ans[0] ^ (s[0] == 'x')) {
        if (ans[n - 1] != ans[1]) return;
    } else {
        if (ans[n - 1] == ans[1]) return;
    }
    for (int i = 0; i < n; ++i) {
        if (ans[i]) cout << 'S';
        else cout << 'W';
    }
    exit(0);
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);

    cin >> n >> s;
    for (int i = 0; i < 2; ++i) {
        for (int j = 0; j < 2; ++j) {
            solve(i, j);
        }
    }
    cout << "-1\n";
}


Measured memory_bytes: 976
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
using P = pair<int, int>;

const int MAX = 101;

vector<int> G[MAX];
int d[MAX];

int main() {

    int n;
    cin >> n;

    fill(d, d + MAX, -1);

    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v;
            cin >> v;
            G[u].push_back(v);
        }
    }

    queue<P> que;

    d[1] = 0;
    que.emplace(make_pair(1, d[1]));

    while (!que.empty()) {

        P &u = que.front();
        que.pop();

        for (auto v : G[u.first]) {
            if (d[v] == -1) {
                d[v] = u.second + 1;
                que.emplace(make_pair(v, d[v]));
            }
        }
    }

    for (int i = 1; i <= n; i++) {
        cout << i << " " << d[i] << endl;
    }
}


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

int main()
{
    int n, x, max;
    char c;
    cin >> n;
    x = max = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> c;
        if (c == 'I')
        {
            x++;
            if (x > max)
                max = x;
        }
        else
            x--;
    }
    cout << max << endl;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split(' ')))
b = [0 for _ in range(N)]

a.insert(0, 0)
b.insert(0, 0)

n = int(N/2)

for i in range(N, 0, -1):
    nums = 0
    for ii in range(2, int(N/i)+1):
        nums += b[i*ii]

    if nums % 2 != a[i]:
        b[i] += 1

sum_b = sum(b)
print(sum_b)

flag = False
for i, bb in enumerate(b):
    if i == 0:
        continue

    if bb != 0:
        flag = True
        print(i, end=' ')

if flag:
    print()


Measured memory_bytes: 7276
#include <iostream>
#include <set>
#include <vector>
#include <iomanip>

#include <cfenv>
#include <cmath>
typedef long long int ll;

using namespace std;

int main()
{


    int N,M;

    cin >> N >> M;


    vector<int> c(M);
    vector<int> s(M);

     vector<int> number(N,-1);


    for (int i=0;i<M;i++){


        cin >>s[i] >> c[i];


        if(N>1&& s[i]==1 && c[i] == 0){


            cout << -1 << endl;

            return 0;

        }


        if(number[s[i]-1] == -1){

            number[s[i]-1] = c[i];


        }
        else{

            if(number[s[i]-1] != c[i]){

                cout << -1 << endl;

            return 0;


            }

            
        }
    }


    for (int i=0;i<N;i++){


        if(number[i] == -1){

            if(N>1 && i==0){

                number[i] = 1;
            }
            else{

                number[i] = 0;
            }



        }


        


    }

    for (int i=0;i<N;i++){


        cout << number[i];
    
    }



    




    

    
    return 0;
}

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

#define MAXN 1000001

int spf[MAXN]; 

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

vector<int> getFactorization(int x) 
{ 
    vector<int> ret; 
    set<int>s;
    while (x != 1) 
    { 
    	if(s.find(spf[x])==s.end()) {
        	ret.push_back(spf[x]); 
        	s.insert(spf[x]);
    	}
        x = x / spf[x]; 
    } 
    return ret; 
} 

int main() {
	int n;
	cin>>n;
	int a[n];
	for(int i=0; i<n; i++)
		cin>>a[i];
		
	bool pairwise = true;
	bool setwise = false;
	
	sieve();
	
	set<int>s;
	
	for(int i=n-1; i>=0; i--) {
		vector<int>factors = getFactorization(a[i]);
		
		for(auto e: factors) {
			if(s.find(e)!=s.end()) {
				pairwise = false;
				break;
			}
			s.insert(e);
		}
		
		if(!pairwise)
			break;
	}
	
	int ans = a[0];
	
	for(int i=0; i<n; i++) {
		ans = __gcd(ans, a[i]);
	}
	
	if(ans==1)
		setwise = true;
	
	if(pairwise) {
		cout<<"pairwise coprime\n";
	}
	else if(setwise) {
		cout<<"setwise coprime\n";
	}
	else {
		cout<<"not coprime\n";
	}
	return 0;
}

Measured memory_bytes: 11504
#include <stdio.h>

int main(void)
{
	int N;
	scanf("%d", &N);
	char str[N];
	scanf("%s", str);
	int i = 0;
	int count = 0;
	while (str[i])
	{
		if (str[i] == 'C' && str[i - 1] == 'B' && str[i - 2] == 'A')
			count++;
		i++;
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int mx=30;
#define sz(a) int(a.size())
#define pb push_back

struct opt {
	int op,i,j,k;
};

vector<opt> ans;

void add(int i,int j,int k) {
	//a[k]=a[i]+a[j];
	ans.pb((opt){0,i,j,k});
}

void cmp(int i,int j,int k) {
	//a[k]=a[i]<a[j];
	ans.pb((opt){1,i,j,k});
}

int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	//cin>>a[0]>>a[1];
	add(0,1,3);
	add(3,3,3);
	cmp(0,3,3);
	for(int i=4;i<=mx+3;i++) add(i-1,i-1,i);
	add(0,3,0);
	add(1,3,1);
	for(int i=30;~i;i--) {
		add(301,3+i,300);
		cmp(300,0,300);
		add(100+i,300,100+i);
		for(int j=1;j<=i;j++) add(300,300,300);
		add(300,301,301);
	}
	for(int i=30;~i;i--) {
		add(302,3+i,300);
		cmp(300,1,300);
		add(200+i,300,200+i);
		for(int j=1;j<=i;j++) add(300,300,300);
		add(300,302,302);
	}
	for(int i=0;i<=30;i++)
		for(int j=0;j<=30;j++) {
			add(100+i,200+j,300);
			cmp(3,300,300);
			for(int k=1;k<=i+j;k++) add(300,300,300);
			add(2,300,2);
		}
	//cerr<<a[2]<<'\n';
	cout<<sz(ans)<<'\n';
	for(auto t:ans) cout<<(t.op?'<':'+')<<' '<<t.i<<' '<<t.j<<' '<<t.k<<'\n';
	return 0;
}


Measured memory_bytes: 4108
#include<stdio.h>

int main(void){
    int A, B, C, D;
    scanf("%d%d%d%d", &A, &B, &C, &D);

    for (int i = 0; i < 100; i++) {
        C = C - B;
        if (C <= 0) {
            printf("Yes\n");
            break;
        }
        A = A - D;
        if (A <= 0) {
            printf("No\n");
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 1660
d={}
try:
    while True:
        n=int(raw_input())
        if n in d:
            d[n]+=1
        else:
            d[n]=1
except EOFError:
    pass
a=[]
m=max(d.values())
for key, value in d.items():
    if value == m:
        a.append(key)
a.sort()
for i in a:
    print i

Measured memory_bytes: 6304
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
using namespace __gnu_pbds;

#define debug(s) cout << #s << " = " << s << endl
#define all(v) (v).begin(), (v).end()
#define mem(a,val) memset(a, val, sizeof a)
 
#define ff first
#define ss second
typedef long long ll;

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

void max_self(int &a, int b) {
  a = max(a, b);
}

char s[3010], t[3010];
int dp[3010][3010];
pair<int, int> par[3010][3010];

int main() {
  scanf("%s%s", s, t);  
  int n = strlen(s);
  int m = strlen(t);
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= m; ++j) par[i][j] = {-1, -1};
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (s[i - 1] == t[j - 1]) {
        // max_self(dp[i][j], dp[i - 1][j - 1] + 1);
        if (dp[i - 1][j - 1] + 1 > dp[i][j]) {
          par[i][j] = {i - 1, j - 1};
          dp[i][j] = dp[i - 1][j - 1] + 1;
        }
      }
      // max_self(dp[i][j], max(dp[i - 1][j], dp[i][j - 1]));
      if (dp[i - 1][j] > dp[i][j]) {
        par[i][j] = {i - 1, j};
        dp[i][j] = dp[i - 1][j];
      }
      if (dp[i][j - 1] > dp[i][j]) {
        par[i][j] = {i, j - 1};
        dp[i][j] = dp[i][j - 1];
      }
    }
  }
  string answer = "";
  int x = n, y = m;
  while (par[x][y].ff != -1) {
    if (par[x][y].ff == x - 1 && par[x][y].ss == y - 1) {
      answer += string(1, s[x - 1]);
    }
    auto tmp = par[x][y];
    x = tmp.ff;
    y = tmp.ss;
  }
  reverse(all(answer));
  cout << answer << '\n';
}


Measured memory_bytes: 106368
import java.util.*;
import java.util.Arrays;

public class Main {
    class Node {
        int id, p = -1, depth = -1;
        int[] childs;
        String nodeType = null;
        Node(int id, int[] childs) {
            this.id = id;
            this.childs = childs;
        }
        void childsStr(StringBuilder sb) {
            if (childs.length != 0) {
                //String s = "["+childs[0];
                sb.append("[");
                sb.append(childs[0]);

                for (int i = 1; i < childs.length; i++) {
                    sb.append(", ");
                    sb.append(childs[i]);
                    //s += (", " + childs[i]);
                }
                sb.append("]");
                return;
                //return s+"]";
            }
            //return "[]";
            sb.append("[]");
        }
void print() {
            StringBuilder sb = new StringBuilder();
            sb.append("node ");
            sb.append(id);
            sb.append(": parent = ");
            sb.append(p);
            sb.append(", depth = ");
            sb.append(depth);
            sb.append(", ");
            sb.append(nodeType);
            sb.append(", ");
            childsStr(sb);
            //System.out.println("node "+id+": parent = "+p+", depth = "+depth+", "+nodeType+", "+childsStr());
            System.out.println(new String(sb));
        }
    }


    int findRoot(boolean[] rs) {
        for (int i = 0; i < rs.length; i++) {
            if (!rs[i]) return i;
        }
        System.out.println("could not find root.");
        return -1;
    }
void search(Node[] nodes, int id, int depth, int parent) {
        if (nodes[id].depth != -1) {
            System.out.println("error");
            return;
        }
        if (nodes[id].childs.length != 0) {
            for (int i = 0; i < nodes[id].childs.length; i++) {
                search(nodes, nodes[id].childs[i], depth+1, id);
            }
            nodes[id].nodeType = "internal node";
        } else {
            nodes[id].nodeType = "leaf";
        }
        if (parent == -1) {
            nodes[id].nodeType = "root";
        }
        nodes[id].p = parent;
        nodes[id].depth = depth;
    }
 void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Node[] nodes = new Node[n];
        boolean[] couldNotRoot = new boolean[n];
        for (int i = 0; i < n; i++) {
            int id = sc.nextInt();
            int k = sc.nextInt();
            int[] childs = new int[k];
            for (int j = 0; j < k; j++) {
                childs[j] = sc.nextInt();
                couldNotRoot[childs[j]] = true;
            }
            //Arrays.sort(childs);
            nodes[id] = new Node(id, childs);
        }
        int root = findRoot(couldNotRoot);
        search(nodes, root, 0, -1);
        for (int i = 0; i < nodes.length; i++) {
            nodes[i].print();
        }
    }
    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 118696