akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int h, w, n;
	cin >> w >> h >> n;
	vector<tuple<int, int, int>> v(n);
	rep(i,n) {
		int x, y, a;
		cin >> x >> y >> a;
		v[i] = tuple<int, int, int> (x, y, a);
	}
	int lx = 0;
	int rx = w;
	int dy = 0;
	int uy = h;
	rep(i,n) {
		int x = get<0>(v[i]);
		int y = get<1>(v[i]);
		int a = get<2>(v[i]);
		if (a == 1) {
			lx = max(lx, x);
		} else if (a == 2) {
			rx = min(rx, x);
		} else if (a == 3) {
			dy = max(dy, y);
		} else {
			uy = min(uy, y);
		}
	}
	int x = rx - lx;
	int y = uy - dy;
	if (x <= 0 || y <= 0) {
		cout << 0 << endl;
	} else {
		cout << x * y << endl;
	}
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3636
// The moment you think of giving up you have already lost the battle
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
typedef long double dl;
#define PI  3.14159265358979323846
#define Mod 1000000007
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }

    }
}
int main()
{
    ll K;
    cin>>K;
    ll X=7;
    ll ans=-1;
    for(ll i=1;i<=1e6+100;i++)
    {
        if(X%K==0)
        {
            ans=i;
            break;
        }
        X=(X*10)%K;
        X=(X+7)%K;
    }
    cout<<ans;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  int i, j;
  cin >> H >> W;
  vector<int> h(H, 0);
  vector<int> w(W, 0);
  vector<vector<char>> a(H, vector<char>(W));
  for (i = 0; i < H; i++) {
    for (j = 0; j < W; j++) {
      cin >> a.at(i).at(j);
    }
  }

  for (i = 0; i < H; i++) {
    for (j = 0; j < W-1; j++) {
      if(a.at(i).at(j)!=a.at(i).at(j+1)) break;
      if(j == W-2 && a.at(i).at(j) == '.') h.at(i) = 1;
    }
  }
  for (j = 0; j < W; j++) {
    for (i = 0; i < H-1; i++) {
      if(a.at(i).at(j)!=a.at(i+1).at(j)) break;
      if(i == H-2 && a.at(i).at(j) == '.') w.at(j) = 1;
    }
  }

  for (i = 0; i < H; i++) {
    for (j = 0; j < W; j++) {
      if(h.at(i)==0 && w.at(j) == 0) cout << a.at(i).at(j);
    }
    if(h.at(i)==0) cout << endl;
  }
}

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

int main(){
  int N;
  cin >> N;
  vector<pair<string,int>> v;
  for(int i=0; i<N; i++){
    string s;
    int t;
    cin >> s >> t;
    v.emplace_back(s,t);
  }
  string x;
  cin >> x;
  
  int i=0;
  while(i<N){
    if(v[i].first == x){
      i++;
      break;
    }
    i++;
  }
  int ret = 0;
  while(i<N){
    ret += v[i].second;
    i++;
  }
  
  cout << ret << endl;
  
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  int64_t ans = 0;
  for (int i = 1; i <= n; ++i){
    if (i%3 == 0) continue;
    if (i%5 == 0) continue;
    ans += i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3648
local n = io.read("*n")
local a, b = {}, {}
a[1], b[1] = 0, 0
for i = 2, n+1 do a[i] = a[i-1] + io.read("*n") end
for i = 2, n+1 do b[i] = b[i-1] + io.read("*n") end
local max = 0
local bm = b[n+1]
for i = 2, n+1 do
  max = math.max(max, a[i]+bm-b[i-1])
end
print(max)


Measured memory_bytes: 256
#include <cstdio>
#include <string> 
#include <algorithm>
#include <iostream>
using namespace std;
typedef string::iterator State;
bool isdigit(State& pos);
int number(State& pos);
int factor(State& pos);
int expression(State& pos);
int term(State& pos);

bool isdigit(State& pos)
{
	if('0'<=*pos&&*pos<='9')return true;
	else return false;
}
int number(State& pos)
{
	int res = 0;
	while(isdigit(pos))
	{
		res*=10;
		res += (*pos)-'0';
		pos++;
	}
	return res;
}
int term(State& pos)
{
	int ret = factor(pos);
	while(*pos == '*'||*pos == '/')
	{
		bool mul = (*pos == '*');
		pos++;
		int k = factor(pos);
		if(mul)ret *= k;
		else ret/=k;
	}
	return ret;
}
int factor(State& pos)
{
	int ret;
	if(*pos=='(')
	{
		pos++;
		ret = expression(pos);
		pos++;
	}
	else ret = number(pos);
	return ret;
}
int expression(State& pos)
{
	int ret = term(pos);
	while(*pos == '+'||*pos == '-')
	{
		bool plus = (*pos == '+');
		pos++;
		int k = term(pos);
		if(plus)ret += k;
		else ret -= k;
	}
	return ret;
}
int main()
{
	int n;
	cin >> n;
	for(int i=0;i<n;i++)
	{
		string s;
		cin >> s;
		State pos = s.begin();
		cout << expression(pos) << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

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

int lcm(int a, int b){
	return a / gcd(a, b) * b;
}


long long power(long long x, long long n, long long mod){
	long long ans = 1;
	for(;n;n>>=1,x*=x,ans%=mod,x%=mod)
		if(n&1)ans*=x;
	return ans%mod;
}

void exgcd(long long a, long long b, long long &x, long long &y){
	if(b == 0){
		x = 1;
		y = 0;
		return ;
	}
	exgcd(b, a % b, y, x);
	y -= a / b * x;
}
	
long long modlog(long long a, long long b, long long mod){
	
	a %= mod, b %= mod;
	
	long long low = -1, high = mod, mid;
	
	
	while(low + 1 < high){
		mid = (low + high) >> 1;
		
		if(mid * mid >= mod) high = mid;
		else low = mid;
	}
	
	long long sqrtM = high;
	map<long long,long long> mp;
	
	for(long long i = 0, x = 1; i < sqrtM; i++){
		if(!mp.count(x)) mp[x] = i;
		x = x * a % mod;
	}
	
	long long x, y, temp;
	long long A;
	
	temp = power(a, sqrtM ,mod);
	
	if(gcd(temp, mod) != 1) return -1;
	
	exgcd(temp , mod, x, y);
	
	A = x;
	
	// A = power(power(a, sqrtM ,mod), mod-2, mod);
	
	for(long long i = 0, bA = b; i < sqrtM; i++){
		if(mp.count(bA)){
			long long res = i * sqrtM + mp[bA];
			
			if(res > 0) return res;
			// return res;
		}
		bA = bA * A % mod;
	}
	
	return -1;
}

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N, n;
	int Lcm = 1;
	vector<int> p;
	
	cin>>N;
	
	n = N;
	
	for(int i = 2; i * i <= N; i++){
		if(N % (i * i) == 0) {
			cout<<-1<<endl;
			return 0;
		}
		
		while(n % i == 0){
			p.push_back(i);
			n /= i;
		}
	}
	
	if(n != 1) {
		p.push_back(n);
	}
	
	if(p.size() == 1) {
		cout<<1<<endl;
		return 0;
	}
	
	for(int i = 0; i < p.size(); i++){
		Lcm = lcm(Lcm, p[i] - 1);
	}
	
	cout<<modlog(N, 1, Lcm)<<endl;
	
	return 0;
}


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

int main()
{
	int a, b;
	cin >> a >> b;

	string ans = "Positive";
	if( a < 0 ) {
		if( b < 0 ) {
			if( (-a - -b + 1) % 2 ) {
				ans = "Negative";
			}
		}
		else {
			ans = "Zero";
		}
	}
	else if( a == 0 ) ans = "Zero";

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int N;
    scanf("%lld",&N);
    string s;
    set <string, greater <string> > alphabet;
    for(int i=0;i<N;i++)
    {
    	cin >> s;
    	alphabet.insert(s);
	}
    
	printf("%lld\n",alphabet.size());

}

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

using namespace std;

int main(void){
    int x;
    cin >> x;
    
    for (int i = 1; i <= pow(10,9); i++){
        if (i * (i + 1) >= 2 * x){
            cout << i << endl;
            return 0;
        }
    }
    
}


Measured memory_bytes: 256
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

n = int(input())
x_list = list(map(int, input().split()))
a = int(Decimal(str(sum(x_list)/n)).quantize(Decimal('0'), rounding=ROUND_HALF_EVEN))

ans = 0
for x in x_list:
    ans += (x-a)**2
print(ans)


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

using namespace std;

#define Mod 1000000007

int main(){
	
	int H,W;
	
	cin>>H>>W;
	
	string grid[H];
	
	int dp[H][W];
	
	for(int i=0; i<H; i+=1){
		
		cin>>grid[i];
		
		for(int j=0; j<W; j+=1){
			
			dp[i][j] = 0;
		}
	}
	
	dp[0][0] = 1;
	
	for(int i=0; i<H; i+=1){
		
		for(int j=0; j<W; j+=1){
			
			if(grid[i][j] == '#'){
				
				continue;
			}
			
			int u = i-1;
			
			int b = j-1;
			
			if(u >= 0 && grid[u][j] != '#'){
				
				dp[i][j] = ((dp[i][j]%Mod)+(dp[u][j]%Mod))%Mod;
			}
			
			if(b >= 0 && grid[i][b] != '#'){
				
				dp[i][j] = ((dp[i][j]%Mod)+(dp[i][b]%Mod))%Mod;
			}
		}
	}
	
	cout<<dp[H-1][W-1];
}

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


int main() {
	int N;
	cin >> N;
	double a = 0.0;
	for (int i = 0; i < N; i++) {
		if ((i + 1) % 2 == 1) {
			a += 1.0;
		}
	}
	double ans = a / N;

	printf("%.8lf\n", ans);

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
#include <queue>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll intpow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = intpow(N, P/2);
        return t*t;
    }
    return N * intpow(N, P-1);
}
ll modpow(ll N, ll P,ll k){
    if(P==0) return 1;
    if(P%2==0){
        ll t = modpow(N, P/2,k)%k;
        return t*t%k;
    }
    return N * modpow(N, P-1,k)%k;
}
ll modkai(ll n,ll m,ll k){//n*(n-1)*(n-2)*...(m+1)%k
    if(n == m)return 1;
    return modkai(n-1,m,k)*n%k;
}
ll mod_cnb(ll n,ll m,ll k){//nCm%k,kは十分大きい素数
  int m_=modkai(m,0,k);
  return modkai(n,n-m,k)*modpow(m_,k-2,k)%k;
}
ll gcd(ll n,ll m){
    ll n_ = max(n,m);
    ll m_ = min(n,m);
    if(n_%m_ == 0)return m_;
    return gcd(m_,n_%m_);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}
int main(){
priority_queue<int>q;
int n,m;cin>>n>>m;
map<int,vector<int>>memo;
rep(i,n){
    int a,b;cin>>a>>b;
    memo[a].push_back(b);
}
int sum=0;
rep(i,m){
    for(auto tmp : memo[i+1])q.push(tmp);
    if(q.empty() == 0){
        sum+=q.top();
        q.pop();
    }
}
cout <<sum<<endl;


}

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

int main(){
  int m,n;
  int x,y,d;
  string command;
  int step;

  while(1){
    cin >> m >> n;
    if(!m && !n)break;

    x = 1;
    y = 1;
    d = 0;

    while(1){
      cin >> command;
      if(command == "STOP")break;
      
      if(command == "LEFT"){
	d--;
	if(d < 0)d += 4;
      }
      else if(command == "RIGHT"){
	d++;
	if(d >= 4)d -= 4;
      }
      else{
	cin >> step;
	if(command == "BACKWARD")step *= -1;
	if(d == 0){
	  y += step;
	  if(y > n)y = n;
	  if(y < 1)y = 1;
	}
	else if(d == 1){
	  x += step;
	  if(x > m)x = m;
	  if(x < 1)x = 1;
	}
	else if(d == 2){
	  y -= step;
	  if(y > n)y = n;
	  if(y < 1)y = 1;
	}
	else if(d == 3){
	  x -= step;
	  if(x > m)x = m;
	  if(x < 1)x = 1;
	}
      }
    }
    cout << x << " " << y << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 1000000007;

ll dp[200][10][2][4];
int n, K;
string number;

ll fun( int pos, int digit, int isStart, int k ){
    ///cout << pos << " " << digit << k << endl;
    if( k == K ){
        return 1;
    }
    if( pos == n ){
        return 0;
    }
    if( dp[pos][digit][isStart][k] != -1 ){
        return dp[pos][digit][isStart][k];
    }
    int l = 0, r = (isStart)?number[pos]-'0':9;
    ll ans = 0;
    for( int i = 0; i <= r; i++ ){
        int newK = k;
        int newStart = isStart;
        if( i == number[pos]-'0' ){
            newStart = isStart;
        }else{
            newStart = 0;
        }
        if( i != 0 ){
            newK++;
        }
        ans += fun( pos+1, i,newStart, newK );
    }
    return dp[pos][digit][isStart][k] = ans;
}

int main(){
    while( cin >> number >> K ){
        n = number.size();
        memset( dp, -1, sizeof dp );
        cout << fun( 0, 0,1, 0 ) << endl;
    }
}


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

const int Max1 = 50005;
const int Max2 = 30;
const int INF = (1<<29);
int C[Max2], T[Max2][Max1];
int T2[Max1];

int main()
{
    int n, m;
    cin >> n >> m;
    for(int i=1; i<=m; i++)
    {
        cin >> C[i];
    }
    //sort(C+1, C+m+1);
    for(int j=0; j<=n; j++)
    {
        T2[j] = INF;
    }
    T2[0] = 0;
    for(int i=1; i<=m; i++)//动态规划存数组
    {
        for(int j=C[i]; j<=n; j++)
        {
            T2[j] = min(T2[j], T2[j-C[i]]+1);
        }
    }
    cout << T2[n] << endl;
    return 0;
}



Measured memory_bytes: 3292
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    ans=1
    n=int(input())
    for i in range(2,n+1):
        ans=ans*i%MOD
    print(ans)
resolve()

Measured memory_bytes: 38384
N, X = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)
dists = (x + [X]).sort.each_cons(2).map do |a, b|
  b - a
end

ans = dists[0]
1.upto(dists.size - 1) do |i|
  ans = ans.gcd(dists[i])
end

puts ans


Measured memory_bytes: 13552
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			int k = cin.nextInt();
			if(k==0){
				break;
			}
			else if(k==2){
				int tmp = cin.nextInt();
				System.out.println(tmp);
				continue;
			}
			int[] a = new int[(k*(k-1))/2];
			int sum = 0;
			for(int i = 0; i < a.length; i++){
				int tmp = cin.nextInt();
				sum+= tmp; 
				//a[i] = cin.nextInt();
			}
			System.out.println(sum/(k-1));
			
		}
	}

}

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

int main(){
    int n, t;
    cin >> n >> t;
    vector<pair<int, int>> dish(n);
    for (int i = 0; i < n; i++) cin >> dish[i].first >> dish[i].second;
    vector<vector<int>> dp(n + 1, vector<int>(t, 0));
    for (int i = 0; i < n; i++){
        if (dish[i].first < t) dp[i + 1][dish[i].first] = max(dp[i + 1][dish[i].first], dish[i].second);
        for (int j = 0; j < t; j++){
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            if (j + dish[i].first < t) dp[i + 1][j + dish[i].first] = max(dp[i + 1][j + dish[i].first], dp[i][j] + dish[i].second);
            if (j != t - 1) dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i + 1][j + 1]);
        }
    }
    reverse(dish.begin(), dish.end());
    vector<vector<int>> rev_dp(n + 1, vector<int>(t, 0));
    for (int i = 0; i < n; i++){
        if (dish[i].first < t) rev_dp[i + 1][dish[i].first] = max(rev_dp[i + 1][dish[i].first], dish[i].second);
        for (int j = 0; j < t; j++){
            rev_dp[i + 1][j] = max(rev_dp[i + 1][j], rev_dp[i][j]);
            if (j + dish[i].first < t) rev_dp[i + 1][j + dish[i].first] = max(rev_dp[i + 1][j + dish[i].first], rev_dp[i][j] + dish[i].second);
            if (j != t - 1) rev_dp[i + 1][j + 1] = max(rev_dp[i + 1][j], rev_dp[i + 1][j + 1]);
        }
    }
    reverse(dish.begin(), dish.end());
    int ans = dp[n][t - 1];
    for (int i = 0; i < n; i++){
        if (i == 0) ans = max(ans, dish[i].second + rev_dp[n - 1][t - 1]);
        else if (i == n - 1) ans = max(ans, dish[i].second + dp[n - 1][t - 1]);
        else {
            for (int j = 0; j < t; j++) ans = max(ans, dish[i].second + dp[i][j] + rev_dp[n - i - 1][t - j - 1]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 70912
n,m = input().split()

n = int(n)
m = int(m)

A = [[0]*m for a in range(n)]
count = 0
while n != 0:
    A[count] = list(map(int,input().split()))
    count += 1
    n -= 1

B = []
while m != 0:
    B.append(int(input()))
    m -= 1

output = []
for a in A:
    temp = [x * y for (x,y) in zip(a,B)]
    output.append(sum(temp))

for a in output:
    print(a)



Measured memory_bytes: 5956
#include <cstdio>
#include <cmath>
#include <algorithm>

int n;

void update(int* v_array, int init_i, int ban, int* result, int* count, int* number)
{
	for (int i = 0; i < 500000; ++i)
	{
		result[i] = v_array[i];
	}
	int counts[500001] = {};
	for (int i = init_i; i < n; i += 2)
	{
		int value = v_array[i];
		counts[value]++;
	}

	int max = 0;
	int max_v = ban;
	for (int i = init_i; i < n; i += 2)
	{
		int value = v_array[i];
		if (value != ban && counts[value] > max)
		{
			max = counts[value];
			max_v = value;
		}
	}

	*count = 0;
	for (int i = init_i; i < n; i += 2)
	{
		int value = v_array[i];
		if (value != max_v || value == ban)
		{
			*count += 1;
			result[i] = max_v;
		}
	}
	*number = max_v;
}

int main()
{
	int v[500000] = {};

	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &v[i]);
	}

	int even_odd = 0, odd_even = 0;

	{
		int result[500000], count, number;
		update(v, 0, 0, result, &count, &number);
		even_odd += count;
		update(result, 1, number, result, &count, &number);
		even_odd += count;
	}

	{
		int result[500000], count, number;
		update(v, 1, 0, result, &count, &number);
		odd_even += count;
		update(result, 0, number, result, &count, &number);
		odd_even += count;
	}

	printf("%d\n", std::min(even_odd, odd_even));
}

Measured memory_bytes: 6016
//************************
//*  Date: 2018.9.8      *
//*  Problem:            *
//*  Author: xuziyuan    * 
//************************

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

string s;
char lst;
map <string,int> mp;
int n;

int main()
{
	int n;
	cin>>n;
	rep(i,n)
	{
		cin>>s;
		mp[s]++;
		if(mp[s]>=2)
		{
			puts("No");
			rt0;
		}
		if(i==0) lst=s[0];
		if(lst!=s[0])
		{
			puts("No");
			rt0;
		}
		lst=s[s.size()-1];
	}
	puts("Yes");
	rt0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    private static Scanner sc;
    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
            int N = sc.nextInt();
            int[] A = new int[N];
            for (int i = 0; i < N; i++) {
                A[i] = sc.nextInt();
            }
            System.out.println(gcd(A));


        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private int gcd(int a, int b) {
        if (a < b) return gcd(b, a);
        if (b == 0) return a;
        return gcd(b, a%b);
    }

    private int gcd(int[] param) {
        final int len = param.length;
        int g = gcd(param[0], param[1]);
        for (int i = 1; i < len - 1; i++) {
            g = gcd(g, param[i+1]);
        }
        return g;
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

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

int main() {
	int N,M,A,a[1000],cnt=0;
	cin>>N>>M;
	
	for(int i=1;i<=M;i++){
	cin>>A;
	if(M>=A) cnt++;
	}

	cout<<M-cnt<<endl;
	
	return 0;
}


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

#define ALL(v) v.begin(), v.end()
typedef long long ll;



using namespace std;
int main() {
	ll n;
	cin >> n;
	
	n = n - 1;

	ll ans = (n + 1) * n / 2;

	cout << ans << endl;
	

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, q; cin >> n >> q;
    deque<pair<int, int>> start, end;
    for (int i = 0; i < n; i++) {
        int s, t, x; cin >> s >> t >> x;
        start.emplace_back(s-x, x);
        end.emplace_back(t-x, x);
    }
    sort(start.begin(), start.end());
    sort(end.begin(), end.end());
    multiset<int> xset;
    for (int i = 0; i < q; i++) {
        int d; cin >> d;
        while (!start.empty() && start.front().first <= d) {
            xset.insert(start.front().second);
            start.pop_front();
        }
        while (!end.empty() && end.front().first <= d) {
            xset.erase(xset.find(end.front().second));
            end.pop_front();
        }
        if (xset.empty()) cout << -1 << endl;
        else cout << *xset.begin() << endl;
    }
    return 0;
}

Measured memory_bytes: 12288
#include <iostream>
#include <cstdio>
#include <map>
using namespace std;

long long mod = 1e9+7;

int main(){
    long long n;
    cin >> n;

    map <long long, long long> T;

    for(long long now = n; now >= 1; now--){
        long long num = now;

        for(long long i = 2; i*i <= now; i++){
            if(num % i != 0){
                continue;
            }
            
            while(num % i == 0){
                if(T.find(i) == T.end()){
                    T[i] = 1;
                    num /= i;
                }
                else{
                    T[i]++;
                    num /= i;
                }
            }
        }
        if(num != 1){
            if(T.find(num) == T.end()){
                T[num] = 1;
            }
            else{
                T[num]++;
            }
        }
        
    }

    map<long long, long long>::iterator it;
    long long ans = 1;
    for(it = T.begin(); it != T.end(); it++){
        ans *= (it->second+1)%mod;
        ans %= mod;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

ll N;

int main(){
  cin>>N;

  /*if(N==2){
      cout<<0<<endl;
      return 0;
  }else if(N==6){
      cout<<5<<endl;
      return 0;
  }*/
  
  ll ans=0;
  for(ll i=1;i*i<N;i++){
      if(N%i==0&&(N/i-1)!=i) ans+=(N/i-1);
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
while 1:
        H,W = map(int, raw_input().split())
        if H + W == 0:
                break
        for i in range(H):
                if i % 2 == 0:
                        if W % 2 == 0:
                                print "#." * (W / 2)
                        else:
                                print "#." * (W / 2) + "#"                       
                else:
                        if W % 2 == 0:
                                print ".#" * (W / 2)
                        else:
                                print ".#" * (W / 2) +"."
        print ""

Measured memory_bytes: 6404
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)

#include <cstdio>
#include <vector>
#include <cstring>
#include <climits>

using namespace std;

int wait(int x) {
    int remain = x % 10;
    if (remain > 0) {
        return 10 - remain;
    }

    return 0;
}

int main(){
    int A[5];

    REP(i, 5) {
        scanf("%d", &A[i]);
    }

    int res = INT_MAX;

    REP(i1, 5) {
        REP(i2, 5) {
            if (i2 == i1) continue;
            REP(i3, 5) {
                if (i3 == i1 || i3 == i2) continue;
                REP (i4, 5) {
                    if (i4 == i1 || i4 == i2 || i4 == i3) continue;
                    REP (i5, 5) {
                        if (i5 == i1 || i5 == i2 || i5 == i3 || i5 == i4) continue;

                        int tmp = 0;
                        int a = A[i1];
                        int b = A[i2];
                        int c = A[i3];
                        int d = A[i4];
                        int e = A[i5];

                        tmp = a + wait(a) + b + wait(b) + c + wait(c) + d + wait(d) + e;

                        res = tmp < res ? tmp : res;
                    }
                }
            }
        }
    }

    printf("%d\n", res);

}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  int x; cin>>x;
  string s = to_string(x);
  if (s[0] == s[2]) out("Yes");
  out("No");

  return 0;
}


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

using namespace std;

int v[10010][1270];

int main() {
  int N, M, r;
  while (cin >> N >> M, N) {
    for (int i = 0; i <= M; i++) {
      for (int j = 0; j < 1270; j++) {
        v[i][j] = 0;
      }
    }

    cin >> r;
    while (r--) {
      int t, n, m, s;
      cin >> t >> n >> m >> s;
      if (s) {
        v[m][t]++;
      } else {
        v[m][t]--;
      }
    }
    for (int i = 0; i <= M; i++) {
      for (int j = 0; j <= 1260; j++) {
        v[i][j + 1] += v[i][j];
      }
    }

    int q;
    cin >> q;
    while (q--) {
      int s, e, m;
      cin >> s >> e >> m;
      int ans = 0;
      for (int i = s; i < e; i++) {
        ans += (v[m][i] > 0);
      }
      cout << ans << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 51132
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

/* define */
#define Yes(X) puts ( (X) ? "Yes" : "No")
#define YES(X) puts ( (X) ? "YES" : "NO")
#define FOR(i, a, b) for ( int i = (a); i < (b) ; i++)
#define REP(i, n) for ( int i = 0; i < (n) ; i++)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = 1000000007;

/* alias */
typedef long long ll;
typedef unsigned  u;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0) return Lgcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / Lgcd(a, b) * b;
}

/* main */

int n, a[200001], b[400001] = {}, c = 0, d[200001] = {};

int main() {
	
	scanf("%d", &n);
	REP(i, n) scanf("%d", &a[i + 1]);
	for(int i = n; i; i--) {
		int k = 0;
		for (int j = 2; j * i <= n; j++)k += b[j * i];
		if (k % 2 != a[i]) {
			b[i]++;
			d[c] = i;
			c++;
		}
	}
	printf("%d\n", c);
	REP(i, c)printf("%d ", d[i]);
	return 0;
}

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

using namespace std;
mt19937_64 rng(58);

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    long long d, x, y;
    int n, ans = 0;
    cin >> n >> d;
    for (int i = 0; i < n; i++) {
        cin >> x >> y;
        if (x * x + y * y <= d * d) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
use std::io::prelude::*;
use std::str::FromStr;
pub struct Scanner<R: Read>(R);
impl<R: Read> Scanner<R> {
    pub fn new(reader: R) -> Self {
        Self(reader)
    }
    pub fn read<T: FromStr>(&mut self) -> T {
        let token = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| (b as char).is_whitespace())
            .take_while(|&b| !(b as char).is_whitespace())
            .collect::<Vec<u8>>();
        unsafe { std::str::from_utf8_unchecked(token.as_slice()) }
            .parse()
            .ok()
            .expect("Can't parse it.")
    }
    pub fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
fn main() {
    let (stdin, stdout) = (std::io::stdin(), std::io::stdout());
    let mut sc = Scanner::new(stdin.lock());
    let mut out = std::io::BufWriter::new(stdout.lock());
    solve(&mut sc, &mut out);
    out.flush().ok().unwrap();
}
fn solve(sc: &mut Scanner<std::io::StdinLock>, out: &mut std::io::BufWriter<std::io::StdoutLock>) {
    let n: usize = sc.read();
    let mut d: Vec<u32> = (0..n).map(|_| sc.read()).collect();
    d.sort();
    d.dedup();
    println!("{}", d.len());
}


Measured memory_bytes: 2164
#include <iostream>
using namespace std;
int n;
int ball[10];
bool b1;

bool hako(int top1,int top2,int i) {
  if(i<=9) {
    if((ball[i] > top1) && (ball[i] > top2)) {
      return hako(ball[i],top2,i+1) || hako(top1,ball[i],i+1);
    }
    else if(ball[i] > top1) {
      return hako(ball[i],top2,i+1);
    }
    else if(ball[i] > top2) {
      return hako(top1,ball[i],i+1);
    }
    else
      return false;
  }
  return true;
}

int main() {
  cin >> n;
  for(int i=0;i<n;i++) {
    for(int i=0;i<10;i++) {
      cin >> ball[i];
    }
    if(b1 = hako(0,0,0),b1) printf("YES\n");
    else printf("NO\n");
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

long long MOD = 1e9+7;
int MAX_INT = 1e9;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int M, D;
  cin >> M >> D;

  int cnt = 0;

  for(int i = 1; i <= M; i++) {
    for (int j = 1; j <= D; j++) {
      int d1 = j / 10;
      int d10 = j % 10;
      if(d1 > 1 && d10 > 1 && i == d1 * d10) {
        // cout << i << ": " << d1 << " " << d10 << endl;
        cnt++;
      }
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>


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


if (A==5&&B==5&&C==7)
    printf("YES\n");
else if (A==5&&B==7&&C==5)
    printf("YES\n");
else if(A==7&&B==5&&C==5)
    printf("YES\n");
else
printf("NO\n");

return 0;
}


Measured memory_bytes: 2084
#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<int>adj[200005];
bool vis[200005];
map<int,int>prevcnt;

int ans=-1,tcnt,node;
ll n,k;

void dfs(int u,int cnt,int chk)
{
    vis[u]=true;
    if(chk==1)
    prevcnt[u]=cnt;

    if(cnt==k)
        ans=u;
    for(int v:adj[u])
    {
        if(vis[v]==true&&chk==1)
        {
            node=v;
            return;
        }
        if(vis[v]==true&&chk==2)
        {
            tcnt=cnt+1;
            return;
        }
        dfs(v,cnt+1,chk);
    }
}
void dfs2(int u,int cnt)
{
    if(cnt==k){
       cout<<u<<endl;
       exit(0);
    }
    for(int v:adj[u])
    {
        dfs2(v,cnt+1);
    }
}
int main()
{

    cin>>n>>k;
    for(int i=1; i<=n; i++)
    {
        int x;
        cin>>x;
        adj[i].push_back(x);
    }
    dfs(1,0,1);

    if(ans!=-1) cout<<ans<<endl;
    else
    {
        memset(vis,0,sizeof vis);

        dfs(node,0,2);
        k-=prevcnt[node];

        k%=tcnt;
        dfs2(node,0);
    }
}


Measured memory_bytes: 45440
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

int main() {
  int n; cin>>n;
  long long m, v, p; cin>>m>>v>>p;
  vector<long long> a(n);
  rep(i, n) cin>>a[i];
  sort(a.begin(), a.end());

  int ng = -1, ok = n;
  while (ng + 1 < ok) {
    int mid = (ng + ok) / 2;
    bool good = true;
    int x = a[mid] + m;

    int large_idx = lower_bound(a.begin(), a.end(), x+1) - a.begin();
    int large = n - large_idx;
    if (large >= p) good = false;

    int same_idx = lower_bound(a.begin(), a.end(), x) - a.begin();
    int rem_prob = p - (n - same_idx + 1);
    long long rem_vote = m * (v - 1 - large);
    int same = large_idx - same_idx;
    rep(i, same) {
      if (large + i + 1 >= p) break;
      if (rem_prob > 0) {
        rem_vote -= m;
        --rem_prob;
      }
    }
    RREP(i, same_idx, 0) {
      if (i == mid) continue;
      if (rem_prob > 0) {
        rem_vote -= m;
        --rem_prob;
      } else {
        rem_vote -= min(m, x - a[i]);
      }
    }
    if (rem_vote > 0) good = false;

    if (good) ok = mid;
    else ng = mid;
  }

  print(n - ok);

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define optimize ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define INF 2000000020LL
#define ALL(x) x.begin(), x.end()
#define UNIQUE(c) (c).resize(unique(ALL(c)) - (c).begin())
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define POS(n, x) (lower_bound(ALL(n), x) - (n).begin())
#define ll long long
#define ld long double
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define PB push_back
#define EB emplace_back
#define MOD 1000000007
#define PRIME 101 
#define MAXN 110
#define MAXP 100010
#define MAXL 23
#define endl '\n'

using namespace std;

// (1 + sqrt(5)) / 2
const ld GOLDEN_RATIO = 1.6180339887498949025257388711906969547271728515625;
const ld PI = 2.0 * acos(0.0);
const int BLOCK = 333;

ll dp[MAXN][MAXP], peso[MAXN], ganho[MAXN];
int N, W;

ll solve(int i, int v)
{
	if(dp[i][v] != -1) return dp[i][v];
	if(i == N) return dp[i][v] = (v == 0 ? 0 : INF);

	dp[i][v] = solve(i + 1, v);

	if(ganho[i] <= v) dp[i][v] = min(dp[i][v], peso[i] + solve(i + 1, v - ganho[i]));

	return dp[i][v];
}

int main(int argc, char const *argv[])
{
	optimize;

	memset(dp, -1, sizeof dp);

	cin >> N >> W;

	int x = 0;

	for(int i = 0; i < N; i++)
	{
		cin >> peso[i] >> ganho[i];

		x += ganho[i];
	}

	ll ans = 0;

	for(int i = 1; i <= x; i++)
		if(solve(0, i) <= W)
			ans = i;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 89536
import java.util.*;

class Main{
	public static void main(String[] args){
      	int k, p;
      	double answer = 0, n;
    	Scanner sc = new Scanner(System.in);
      	n = sc.nextDouble();
      	k = sc.nextInt();
      	
      	for(int i = 1; i <= n; i++) {
      		int count = 0;
      		p = i;
      		while(true) {
      			if(p >= k) {
      				answer = answer + ((1.0/n) * Math.pow(0.5, count));
      				break;
      			}
      			count++;
      			p = p*2;
      		}
      	}
      	System.out.println(answer);
    }
}

Measured memory_bytes: 24660
# -coding: utf-8 -

n,a,b = map(int, input().split())

lis = range(a,b+1)

ans = 0
for i in range(1, n+1):
    summation = 0
    for k in list(str(i)):
        summation += int(k)
    if summation in lis:
        #print(summation)
        ans += i
        
print(ans)    




Measured memory_bytes: 2940
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

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

int main() {
	int n=read();
	printf("%d\n",n+n*n+n*n*n);
	return 0;
}

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

#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template <typename Arg1>
void __f( const char* name , Arg1&& arg1 ) {
        cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f( const char* na , Arg1&& arg1 , Args&&... args ) {
        const char* c = strchr( na + 1 , ',' );
        cerr.write( na , c - na ) << " : " << arg1 << " , ";
        __f( c + 1 , args... );
}
#define endl "\n"
#define all(V) V.begin(),V.end()
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 1e5 + 5;

int main( ) {
        IO;
        #ifdef LOCAL
            //freopen( "input.txt" , "r" , stdin );
        #endif // LOCAL
        int n , k;
        cin >> n >> k;
        double ans = 0.0;
        for( int i = 1; i <= n; i++ ) {
                if( !(i >= 1 && i <= k - 1) ) {
                        ans += 1.0/n;
                        continue;
                }
                double prob = 1.0/n;
                int cur = i , cnt = 0;
                while( cur < k ) cur *= 2 , cnt++;
                prob = prob * 1.0/pow(2,cnt);
                //cout << setprecision(10) << fixed << prob << endl;
                ans += prob;
        }
        cout << setprecision(10) << fixed << ans << endl;
        return 0;
}










Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
#define chmax(a,b) a=max(a,b)

/*Coding Space*/
int main(){
  ll a,b,c,d; cin >> a >> b >> c >> d;
  ll ans = b - a + 1;
  ll cc = b/c - (a-1)/c;
  ll dd = b/d - (a-1)/d;
  ll gg = lcm(c,d);
  ll gc = b/gg - (a-1)/gg;
  ans -= cc + dd - gc;
  cout << ans << endl;
}


Measured memory_bytes: 256
n, m, x = map(int, input().split())

c, *aa = zip(*[tuple(map(int, input().split())) for _ in range(n)])
ans = float("inf")

for i in range(2 ** n):
    cnt = 0
    a = [0] * m
    items = [j for j in range(n) if (i >> j) & 1]

    for item in items:
        cnt += c[item]
        for k in range(m):
            a[k] += aa[k][item]
    
    if min(a) >= x: ans = min(cnt, ans)

print(-1 if ans == float("inf") else ans)


Measured memory_bytes: 68584
#include <iostream>
#include <iomanip>
#define ll long long int

using namespace std;

double ar[3005];
double dp[3005][3005]; // i = coins, j = Head

int main(){
    std::ios_base::sync_with_stdio(false); std::cin.tie(0);
    int N;
    cin >> N;
    double tmp;
    for(int i=1 ; i <= N; i++ ){
        cin >> tmp;
        ar[i] = tmp;
    }
    dp[1][1] = ar[1];
    for(int i=1; i <= N; i++){
        if( i == 1 ) dp[1][0] = 1-ar[i];
        else{
            dp[i][0] = dp[i-1][0] * (1-ar[i]);
        }
    }
    for(int i=1; i <= N; i++){
        for(int j=1; j <= N; j++){
            if( i >= j ){
                if( i == 1 && j == 1 ) continue;
                double tmp = ar[i];
                dp[i][j] = dp[i-1][j]*(1-tmp) + dp[i-1][j-1]*tmp;
            }
        }
    }

    double ans = 0;
    /*for(int i=p; i <= N; i++) ans += dp[i];
    cout << ans;*/
    for(int j= N/2 + 1; j <= N; j++ ){
        ans += dp[N][j];
    }
    cout << std::setprecision(13);
    cout << ans << endl;

    /*for(int i=0; i <= N; i++){
        for(int j=0; j <= N;j++){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }*/


}



Measured memory_bytes: 69120
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
f=int(input())
g=int(input())
h=int(input())
i=int(input())
j=int(input())
print(a+b+c+d+e+f+g+h+i+j)



Measured memory_bytes: 5588
#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;

int main()
{
    int n;
    cin >> n;
    ll a[100005];
    P p[100005];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        p[i] = P(a[i], i);
    }
    sort(p, p + n, greater<P>());
    a[n] = 0;
    p[n] = P(0, n);
    ll ans[100005];
    ll c = 0, l = n, h = 0, s = 0;
    for(int i = 0; i < n + 1; i++){
        int j = p[i].second;
        s += (h - a[j]) * c;
        h = a[j];
        c++;
        if(j < l || j == n){
            ans[l] = s;
            s = 0;
            l = j;
        }
    }
    for(int i = 0; i < n; i++) cout << ans[i] << endl;
}


Measured memory_bytes: 6700
import copy
s = input()
n=len(s)
ints=int(s)

# くっつけるか、数値としてたすパターンを再帰関数で回せばいい

all_sum=[0]
num = []
# 各桁のそれぞれの数字を出力するアルゴリズム
while ints != 0:
  # print(num)
  num.append(str(ints % 10))
  ints //= 10
num.reverse()



def DFS(num,count,sum):
    if count==n:
        # print(num)
        # print(sum)
        all_sum[0]+=sum
        return
    
    num_coppy = copy.deepcopy(num)
    # そのまま足しちゃう
    
    sum+=int(num_coppy[count])
    # print(int(num_coppy[count]))
    count+=1
    DFS(num_coppy,count,sum)

    count-=1

    #　一個後とくっつける
    if count<=n-2:
        
        num_coppy[count+1]=num_coppy[count]+num_coppy[count+1]
        sum -= int(num_coppy[count])
        count+=1
        DFS(num_coppy,count,sum)


    
    return

    
    
    
DFS(num,0,0)
    

print(all_sum[0])


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n,w;
  cin>>n>>w;
  ll wt[n+1],val[n+1];
  for(ll i=1;i<=n;i++)
  {
      ll a,b;
      cin>>a>>b;
      wt[i]=a;
      val[i]=b;
  }
  ll dp[n+1][w+1];
  dp[0][0]=0;
  for(ll i=0;i<=w;i++)
  {
      dp[0][i]=0;
  }
  for(ll i=1;i<=n;i++)
  {
    for(ll j=0;j<=w;j++)
    {
        if(j<wt[i])
        dp[i][j]=dp[i-1][j];
        else
        {
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-wt[i]]+val[i]);
        }
    }
  }
  cout<<dp[n][w];
  return 0;
}

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


#define ll long long int

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast_io std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)


#define trace(x) cout << '>' << #x << ':' << x << endl;
#define trace2(x,y) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y << endl;
#define trace3(x,y,z) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y <<" | " << #z << ':' << z << endl;
#define trace4(x,y,z,w) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y <<" | " << #z << ':' << z << " | " << #w << ':' << w << endl;

#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(),(v).end()
#define print(x) cout<<(x)<<endl;

int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};
int toInt(string s){int r=0;istringstream sin(s);sin>>r; return r;}
///////////////////////////////////////////////////////

int a[5][110];
int dp[5][110];
int n;

int main()
{
	fast_io;
	cout<<fixed;

	cin>>n;

	FOR(i,1,2){
		FOR(j,1,n){
			cin>>a[i][j];
		}
	}

	dp[1][1] = a[1][1];

	FOR(j,2,n){
		dp[1][j] = dp[1][j-1] + a[1][j];
	}

	dp[2][1] = dp[1][1] + a[2][1];

	FOR(j,2,n){
		dp[2][j] = max(dp[1][j],dp[2][j-1]) + a[2][j];
	}

	cout<<dp[2][n]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll A, B;
  cin >> A >> B;
  if (A == B) {
    COUT("Draw");
    return 0;
  }

  if (B == 1) {
    COUT("Bob");
    return 0;
  }

  if (A == 1) {
    COUT("Alice");
    return 0;
  }

  if (A < B) {
    COUT("Bob");
    return 0;
  } else {
    COUT("Alice");
    return 0;
  }

  return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define il inline
#define LL long long
#define _(d) while(d(isdigit(ch=getchar())))
using namespace std;
const int N=2e5+5,p=1e9+7;
int n,head[N],ne[N],to[N],rt[N],inv2=p-p/2,cnt;
struct node{
	int f[3];
	node(int a,int b,int c){f[0]=a;f[1]=b;f[2]=c;}
};vector<node> q[N];
il int read(){int x,f=1;char ch;_(!)ch=='-'?f=-1:f;x=ch^48;_()x=(x<<1)+(x<<3)+(ch^48);return f*x;}
il void insert(int x,int y){ne[++cnt]=head[x];head[x]=cnt;to[cnt]=y;}
il int mu(int x,int y){if(x+y>=p)return x+y-p;return x+y;}
il LL ksm(LL a,int y){LL b=1;while(y){if(y&1)b=b*a%p;a=a*a%p;y>>=1;}return b;}
il int merge(int x,int y){
	if(q[x].size()<q[y].size())swap(x,y);
	int xsz=q[x].size(),ysz=q[y].size();
	for(int i=0;i<ysz;i++){
		int px=xsz-i-1,py=ysz-i-1;
		int t0,t1,t2;
		t0=1ll*q[x][px].f[0]*q[y][py].f[0]%p;
		t1=mu(1ll*q[x][px].f[0]*q[y][py].f[1]%p,1ll*q[x][px].f[1]*q[y][py].f[0]%p);
		t2=mu(1ll*q[x][px].f[2]*q[y][py].f[2]%p,mu(1ll*q[x][px].f[2]*q[y][py].f[1]%p,1ll*q[x][px].f[2]*q[y][py].f[0]%p));
		t2=mu(mu(t2,1ll*q[x][px].f[0]*q[y][py].f[2]%p),mu(1ll*q[x][px].f[1]*q[y][py].f[2]%p,1ll*q[x][px].f[1]*q[y][py].f[1]%p));
		q[x][px]=node(t0,t1,t2);
	}
	q[y].clear();return x;
}
il void dfs(int x){
	rt[x]=x;int dep=0;
	if(!head[x]){
		q[x].push_back(node(inv2,inv2,0));return;
	}
	for(int i=head[x];i;i=ne[i]){
		dfs(to[i]);
		dep=max(dep,(int)min(q[rt[x]].size(),q[rt[to[i]]].size()));
		rt[x]=merge(rt[x],rt[to[i]]);
	}
	int now=rt[x];int s=q[now].size()-1;
	for(int i=0;i<dep;i++){
		q[now][s-i].f[0]=mu(q[now][s-i].f[2],q[now][s-i].f[0]);q[now][s-i].f[2]=0;
	}
	q[now].push_back(node(inv2,inv2,0));
}
int main()
{
	n=read();for(int i=1;i<=n;i++){int x=read();insert(x,i);}
	dfs(0);LL ans=0;
	for(int i=0;i<q[rt[0]].size();i++)
		ans=mu(ans,q[rt[0]][i].f[1])%p;
	printf("%lld\n",ans*ksm(2,n+1)%p);
	return 0;
}

Measured memory_bytes: 27764