akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main()
{
    int A,B,C,X;
    int res=0;
    cin>>A>>B>>C>>X;
    for(int i=0;i<=A;i++){
        for(int j=0;j<=B;j++){
            for(int k=0;k<=C;k++){
                int total=i*500+j*100+k*50;
                if(total==X)res++;
            }
        }
    }
    cout<<res<<'\n';
    return 0;
}

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

// 0 ~ A の xor を計算
long xorSum( long A )
{
    long ans = 0;
    // i bit目の 1 の個数を調べる
    for( int i = 0; i <= 40; ++i ){
        long period = (1L << (i+1));
        long num1 = (A+1)/period * period/2;  // 0 ~ A なので A+1 になることに注意
        num1 += max( 0L, (A+1)%period - period/2 );
        ans += ( num1%2 == 1 )? (1L << i): 0;
    }
    return ans;
}

// ( 2n ^ 2n+1 ) = 1 になることを用いた解法
long xorSum2( long A )
{
    long num1 = (A+1)/2;
    long ans = (num1%2 == 1)? 1: 0;
    if( A%2 == 0 ) ans ^= A;

    return ans;
}


int main()
{
    long A, B;
    cin >> A >> B;

    cout << ( xorSum2(A-1) ^ xorSum2(B) )  << endl;

    return 0;
}

Measured memory_bytes: 256
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

char query(vector<int> arr) {
    cout << "?";
    for (int v : arr) {
        cout << " " << v;
    }
    cout << endl;
    string ret;
    cin >> ret;
    return ret == "Red" ? 'R' : 'B';
}

int N;
char init_color, color;

int main() {
    cin >> N;

    // phase 1
    vector<int> arr0;
    for (int i = 1; i <= N; ++i) {
        arr0.push_back(i);
    }
    init_color = query(arr0);

    int l = 0, r = N; 
    while (l < r) {
        int m = (l+r) / 2;
        vector<int> arr;
        for (int j = 1; j <= N; ++j) {
            arr.push_back(j <= m ? j+N : j);
        }
        sort(begin(arr), end(arr));
        color = query(arr);
        if (color == init_color) {
            l = m+1;
        } else {
            r = m;
        }
    }
    
    char ans[300];
    ans[2*N] = '\0';
    for (int i = 1; i <= 2*N; ++i) {
        vector<int> arr;
        arr.push_back(i);
        if (i <= r || r+N+1 <= i) {
            for (int j = r+1; j < r+N; ++j) arr.push_back(j);
        } else {
            for (int j = 1; j < r; ++j) arr.push_back(j);
            for (int j = r+N+1; j <= 2*N; ++j) arr.push_back(j);
        }
        sort(begin(arr), end(arr));
        color = query(arr);
        ans[i] = color;
    }
    cout << "! ";
    for (int i = 1; i <= 2*N; ++i) {
        cout << ans[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 724
#d
n=int(input())
a=list(map(int,input().split()))
m=1000
kabu=0
t=0
a.insert(0,300)
for i in range(1,n):
    if a[i-1]>=a[i] and a[i]<a[i+1] and t==0:
        kabu=m//a[i]
        m=m%a[i]
        t=1
    elif a[i-1]<=a[i] and a[i]>a[i+1] and t==1:
        m+=kabu*a[i]
        t=0

if t==1:
    m+=kabu*a[n]
print(m)

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

int main(){
	int n, m;
	int point_t[100] = { 0 };
	int point_h[100] = { 0 };

	while (cin >> n >> m, n != 0 || m != 0){
		int a = 999, b = 999;
		for (int i = 0; i < n; i++){
			cin >> point_t[i];
		}
		for (int i = 0; i < m; i++){
			cin >> point_h[i];
		}
		int sum_t = accumulate(point_t, point_t + n, 0);
		int sum_h = accumulate(point_h, point_h + m, 0);

		for (int i = 0; i < n; i++){
			for (int j = 0; j < m; j++){
				if (sum_t - point_t[i] + point_h[j] == sum_h + point_t[i] - point_h[j]){
					if (a + b > point_t[i] + point_h[j]){
						a = point_t[i];
						b = point_h[j];
					}
				}
			}
		}
		if (a == 999 && b == 999){
			cout << -1 << endl;
		}
		else cout << a << ' ' << b << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){

    int3(w, a, b);
    if(a + w < b)pri(b - a - w);
    else if(b + w < a)pri(a - b - w);
    else pri(0);

/*/

//*/ break;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


V<string> split(const string& s, char c) {
  V<string> res;
  stringstream ss(s);
  string t;
  while (getline(ss, t, c)) res.push_back(t);
  return res;
}

int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  string str;
  while (getline(cin, str)) {
    auto ss = split(str, ' ');
    int a = stoi(ss[0]), b = stoi(ss[1]);
    string s = to_string(a + b);
    cout << s.size() << '\n';
  }
}


Measured memory_bytes: 3140
N, K, S = list(map(int, input().split()))
ans = []


def p(lst):
    t = ""
    for i in range(len(lst)-1):
        t += str(lst[i])
        t += " "
    t += str(lst[-1])
    print(t)


if S == 10**9:
    p([S if x < K else 1 for x in range(N)])
else:
    p([S if x < K else S+1 for x in range(N)])


Measured memory_bytes: 9880
from collections import namedtuple, defaultdict

City = namedtuple('City', ('num', 'pref', 'year'))
cities = defaultdict(list)

n, m = map(int, input().split())
for i in range(m):
    p, y = map(int, input().split())
    cities[p].append(City(i, p, y))

for _, cs in cities.items():
    cs.sort(key=lambda c: c.year)

ids = ['' for _ in range(m)]
for pref, cs in cities.items():
    for ith, c in enumerate(cs):
        ids[c.num] = str(c.pref).zfill(6) + str(ith + 1).zfill(6)

for id in ids:
    print(id)

Measured memory_bytes: 46500
#include <stdio.h>

int main(void) {

	int a , d;

	scanf("%d", &a);
	
	d = a % 7;

	if (d == 1) {
		printf("fri\n");
	}
	else if (d == 2) {
		printf("sat\n");
	}
	else if (d == 3) {
		printf("sun\n");
	}
	else if (d == 4) {
		printf("mon\n");
	}
	else if (d == 5) {
		printf("tue\n");
	}
	else if (d == 6) {
		printf("wed\n");
	}
	else {
		printf("thu\n");
	}

	return 0;
}


Measured memory_bytes: 2692
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;

ll N, ans;

void dfs(ll num, int three, int five, int seven) {
  if (num > N) {
    return;
  }
  if (three * five * seven > 0) {
    ans++;
  }

  dfs(10 * num + 3, 1, five, seven);
  dfs(10 * num + 5, three, 1, seven);
  dfs(10 * num + 7, three, five, 1);

  return;
}

int main() {
  cin >> N;
  dfs(0, 0, 0, 0);
  cout << ans << endl;
}

Measured memory_bytes: 3520
use std::io;
use std::collections::HashSet;

fn read_line() -> String {
    let mut line = String::new();

    io::stdin().read_line(&mut line)
        .expect("Failed to read line");
    return line;
}
fn to_i(s: &str) -> i64 {
    return s.trim().parse()
        .expect("Please type a number!");
}
fn check(nums: &Vec<i64>, i: i32, count: i32, data: &HashSet<i64>) -> i32 {
    if i+2==nums.len() as i32 {
        if data.len()==2 {
            return count;
        } else {
            return 9999999;
        }
    }
    if data.len() >=3 {
        return 9999999;
    }
    let x = nums[i as usize];
    let x2 = nums[(i+2) as usize];
    //println!("{} {} {} {} {}", i, x, x2, count, data.len());
    if x==x2 {
        let mut data1 = data.clone();
        data1.insert(x);
        if data.len()==2 {
            if data.contains(&x) {
                //println!("# {} {} ", i+1+2, nums.len());
                
                return check(nums, i+1, count, &data1);
            }else{
                return check(nums, i+1, count+2, &data1);
            }
        }else{
            /*if data.include?(x) {

            }else{

            }*/
            if i+1+2==nums.len() as i32 {
                    
                    
                        return count+2;
                    
            }
            return check(nums, i+1, count, &data1);
        }
        
    }

    if data.len()==2 {
        if data.contains(&x) || data.contains(&x2) { 
            if data.contains(&x) {
                let mut data3 = data.clone();
                data3.insert(x2);
                return check(nums, i+1, count+1, &data3);
            }else{
                let mut data2 = data.clone();
                data2.insert(x);
                return check(nums, i+1, count+1, &data2);
            }
        }else{
            return check(nums, i+1, count+2, &data);
        }
    }else{
        //nums[(i+2) as usize] = x;
        let mut data2 = data.clone();
        data2.insert(x);
        let a = check(nums, i+1, count+1, &data2);
        //println!("a {} {} ",a, data2.len());
        //nums[(i+0) as usize] = x2;
        let mut data3 = data.clone();
        data3.insert(x2);
        let b = check(nums, i+1, count+1, &data3);

        //println!("b {} {}", b, data3.len());
        if a>b {
            return b;
        }else {
            return a;
        }
    }
    
}
fn main() {
    let l = read_line();
    let n = to_i(&l);
    if n == 1 {
        print!("Hello World");
        return;
    } 
    
    let l1 = read_line();
    let a = to_i(&l1);
    let l2 = read_line();
    let b = to_i(&l2);

    let result = a+b;
    print!("{}", result);


}   

Measured memory_bytes: 4352
#include <bits/stdc++.h>
     
    using namespace std;
    typedef long long ll;
     
    char a[1001][1001];
    int dx[] = {0, 0, 1, -1};
    int dy[] = {1, -1, 0, 0};
    int dx2[] = {-2, -2, -2, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 2, 2, 2,-1,1,-1,1};
    int dy2[] = {-2, -1, 0, 1, 2, -2, 2, -2, 2, -2, 2, -2, -1, 0, 1, 2,-1,1,1,-1};
    bool c[1001][1001];
     
    int main()
    {
        ios_base::sync_with_stdio(false);
     
        int n, m;
        cin >> n >> m;
        int x, y, nx, ny;
        cin >> x >> y >> nx >> ny;
        x -= 1; y -= 1; nx -= 1; ny -=1;
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < m; j++)
            {
                cin >> a[i][j];
            }
        }
        queue<pair<int, int>> q;
        q.push({x, y});
        c[x][y] = true;
        int ans = 0;
     
        while (1)
        {
            queue<pair<int, int>> q2;
            while (!q.empty())
            {
                int x = q.front().first;
                int y = q.front().second;
                q.pop();
                q2.push({x, y});
                for (int i = 0; i < 4; i++)
                {
                    int nx = x + dx[i];
                    int ny = y + dy[i];
                    if (nx >= 0 && ny >= 0 && nx < n && ny < m && a[nx][ny] != '#' && !c[nx][ny])
                    {
                        c[nx][ny] = true;
                        q.push({nx, ny});
                    }
                }
            }
     
            if (c[nx][ny])
            {
                break;
            }
            
            while (!q2.empty())
            {
                int x = q2.front().first;
                int y = q2.front().second;
                
                q2.pop();
                for (int i = 0; i < 20; i++)
                {
                    int nx = x + dx2[i];
                    int ny = y + dy2[i];
                    if (nx >= 0 && ny >= 0 && nx < n && ny < m && a[nx][ny] != '#' && !c[nx][ny])
                    {
                        c[nx][ny] = true;
                        q.push({nx, ny});
                    }
                }
            }
            ans += 1;
            
            if (c[nx][ny])
            {
                break;
            }
            if(q.size() == 0){
                cout << -1<<'\n'; return 0;
            }
        }
     
        cout << ans << '\n';
    }

Measured memory_bytes: 5564
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod = 1e9 + 7;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> plus, minus, total;
    int mx = -mod;
    for(int i = 0, num; i < n; i++){
        cin >> num;
        if(num > 0){
            plus.push_back(num);
        }else{
            minus.push_back(-num);
        }
        mx = max(mx, num);
        total.push_back(num);
    }
    if(mx <= 0 || n == k){
        sort(total.begin(), total.end());
        if(k % 2){
            reverse(total.begin(), total.end());
        }
        int res = 1;
        for(int i = 0; i < k; i++){
            if(total[i] < 0){
                res = (res * (total[i] + mod) % mod) % mod; 
            } else{
                res = (res * total[i]) % mod;
            }
        }
        cout << res << endl;
    }else{
        sort(plus.begin(), plus.end());
        sort(minus.begin(), minus.end());
        int res = 1;
        if(k % 2){
            res *= plus.back();
            plus.pop_back();
            k--;
        }
        k /= 2;
        vector<int> ans;
        reverse(plus.begin(), plus.end());
        reverse(minus.begin(), minus.end());
        for(int i = 0; i + 1 < plus.size(); i += 2){
            ans.push_back(plus[i] * plus[i + 1]);
        }
        for(int i = 0; i + 1 < minus.size(); i += 2){
            ans.push_back(minus[i] * minus[i + 1]);
        }
        while((int)ans.size() < k){
            ans.push_back(0);
        }
        sort(ans.begin(), ans.end());
        reverse(ans.begin(), ans.end());
        for(int i = 0; i < k; i++){
            res = (res * (ans[i] % mod)) % mod;
        }
        cout << res << endl;
    }
    
}

Measured memory_bytes: 8260
#include <iostream>
using namespace std;
int main(){
      int n,count=0,min;
      cin>> n;
      int num[n];
      for(int i = 0;i <n;i++)
            cin>>num[i];
      for(int i= 0;i<n;i++){
            min = i;
            for(int j = i;j<n;j++){
                  if(num[j]<num[min])
                        min = j;
            }
            if(i != min)
                  count++;
            swap(num[i],num[min]);
      }
      for(int i=0;i<n-1;i++)
            cout<<num[i]<<" ";
      cout<<num[n-1]<<endl<<count<<endl;
}

Measured memory_bytes: 1160
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		// your code goes here
		
		var a = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
		int n = a[0];
		int k = a[1];
		int counter = 0;
		double[] score = new double[n];
		
		for(int b=0; b!=n; b++){
			
			counter = 0;
			
			int c=b+1; 
			for (int hoge=0; c<k;){
				counter++;
				c=c*2;
			}
			score[b] = n*Math.Pow(2,counter);
			
		}
		
		double last = 0;
		
		for(int d=0; d!=n; d++){
			
			last = last + 1/score[d];
			
		}
		
		Console.WriteLine(last);
		
		
		
		
		
	}
}

Measured memory_bytes: 13392
#include<iostream>
#include<string>
#include <bits/stdc++.h>
#include<vector>
using namespace std;

int main(){
  int n,k;
  int d[110],a[110][110];
  cin >> n >> k;
  int i,j;
  for(i=1;i<=k;i++){
    cin >> d[i];
    for(j=1;j<=d[i];j++){
      cin >> a[i][j];
    }
  }
  int count=0;
  int flag[110]={0};
  int n1;
  for(i=1;i<=k;i++){
    for(j=1;j<=d[i];j++){
      for(n1=1;n1<=n;n1++){
        if(a[i][j] == n1){
          flag[n1]=1;
        }
      }
    }
  }
  for(i=1;i<=n;i++){
    if(flag[i] == 1){
      count++;
    }
  }
  cout << n-count << endl;

}


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

if m == 0:
    if n == 1:
        print(0)
    elif n == 2:
        print(10)
    else:
        print(100)
else:
    impo = False
    if n == 1:
        keta = [0]
        changed = [False]
    elif n == 2:
        keta = [1, 0]
        changed = [False, False]
    else:
        keta = [1, 0, 0]
        changed = [False, False, False]
    for i in range(m):
        s, c = map(int, input().split())
        if changed[s-1] is False and c >= keta[s-1]:
            keta[s-1] = c
            changed[s-1] = True
        elif changed[s-1] is True and keta[s-1] == c:
            continue
        else:
            impo = True
            break
    
    if impo:
        print(-1)
    else:
        for k in keta:
            print(k, end='')


Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,k,cnt=0;
  cin >> a >> b >> c >> k;
  while(a>=b){b*=2;cnt++;}
  while(b>=c){c*=2;cnt++;}
  if(cnt<=k)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3596
<?php
  
  fscanf(STDIN,"%d %d",$n,$k);

$m = array();
for($i=0;$i<$n;$i++){
	$m[] = trim(fgets(STDIN));
}
$sum_kind = 0;
foreach($m as $gram){
  $sum_kind+=$gram;
}


$nokori =  $k-$sum_kind;

$kosu = (int)($nokori/min($m))+count($m);

echo $kosu."\n";



Measured memory_bytes: 4604
#include <cstdio>
#include <algorithm>

using namespace std;

int gcd(int a,int b)
{
	if(a<b) swap(a,b);
	while(b){
		int tmp=b;
		b=a%b;
		a=tmp;
		if(b==0) break;
	}
	return a;
}

int main()
{
	int n,x;
	scanf("%d %d",&n,&x);

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

	int ans;
	ans=def[0];
	for(int i=1;i<n;i++){
		ans=gcd(ans,def[i]);
	}

	printf("%d\n",ans);
}


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

int main() {
    int n,i,j,temp;
    bool ans=false;
    char tempc;
    string s,t,s1;
    cin >> s>>t;
    s1=s;
    char u[200];
    int counter=0;
    if(s==t)ans=true;
    for(i=0;i<s.length();i++){
       tempc=s[s.length()-1];
       for(j=s.length()-1;j>0;j--){
           s[j]=s[j-1];
       }
       s[0]=tempc;
       if(s==t)ans=true;
    }

    if(ans){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    //std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
char c[100][101];
int h, w;
void del(int a, int b, char t) {
  // 探索済みマークをつける
  c[a][b] = '.';
  // 右
  if(b < w-1 && c[a][b+1] == t) del(a, b+1, t);
  // 左
  if(b > 0 && c[a][b-1] == t) del(a, b-1, t);
  // 上
  if(a > 0 && c[a-1][b] == t) del(a-1, b, t);
  // 下
  if(a < h-1 && c[a+1][b] == t) del(a+1, b, t);
  return;
}

int main() {
  int a, b;
  while(scanf("%d%d", &a, &b), a != 0) {
    h = a;
    w = b;
    for(int i = 0; i < a; i++) {
      scanf("%s", c[i]);
    }
    // 区間をカウントする。
    int ret = 0;
    for(int i = 0; i < a; i++) {
      for(int j = 0; j < b; j++) {
        if(c[i][j] != '.') {
          ret++;
          del(i, j, c[i][j]);
        }
      }
    }
    printf("%d\n", ret);
  }
}



Measured memory_bytes: 3044
function Main(input) {
	const s = input.split("\n")[0];

    const next = {
   		"SUN": 7,
		"MON": 6,
      	"TUE": 5,
        "WED": 4,
        "THU": 3,
       	"FRI": 2,
    	"SAT": 1,
    }
	console.log(next[s]);
    
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include "bits/stdc++.h"
#include<assert.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int inf = 1e17;
const int mod = 1000000007;
typedef pair<int, int> P;
typedef pair<int, P> PP;
int x[100006];

struct RMQ {
	int n; vector<int>node;
	void init(int N) {
		n = 1;
		while (n < N)n *= 2;
		node.resize(2 * n, inf);
	}

	void update(int x, int a) {
		x += n - 1;
		node[x] = a;
		while (x > 0) {
			x = (x - 1) / 2;
			node[x] = min(node[x * 2 + 1], node[x * 2 + 2]);
		}
	}
	int query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l)return inf;
		if (a <= l&&r <= b)return node[k];
		int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
	int get(int a, int b) {
		return query(a, b, 0, 0, n);
	}
};
RMQ dp1, dp2;
signed main() {
	int n, e, t; cin >> n >> e >> t;
	rep(i, n)cin >> x[i];
	dp1.init(n + 2);
	dp2.init(n + 2);

	x[n] = x[n - 1];
	dp1.update(0, 0);
	dp2.update(0, -2*x[0]);
	rep(i,n){//dp[i+1]
		int lb = -1, ub = i+1;
		while (ub - lb > 1) {
			int mi = (ub + lb) / 2;
			if (2 * (x[i] - x[mi]) > t)lb = mi;
			else ub = mi;
		}

		//[0,i]を分ける
		//[0,lb]は2(x[i]-x[j]), [ub,i]はt
		int X1, X2;
		X1 = dp1.get(ub, i+1) + t;
		X2 = dp2.get(0, ub) + 2 * x[i];
//		cout << ub << ' ' << X1 << ' ' << X2 << endl;
		dp1.update(i+1, min(X1, X2));
		dp2.update(i+1, min(X1,X2)-2 * x[i+1]);
	}
	cout << dp1.get(n, n+1)+e << endl;

	/*
	dp[0] = 0;
	rep(i, n) {
		for (int j = i; j<n; j++) {
			dp[j + 1] = min(dp[j + 1], dp[i] + max(2 * (x[j] - x[i]), t));
		}
	}
	cout << dp[n] + e<< endl;
	*/

}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int a,n,aa[110000],cnt=0;
double d,dd=1000.0;
pair<string,int> p[220000];
string s,ss[220000],x;
char c;
signed main(){
    cin>>n;
    rep(i,n){
        cin>>aa[i];
        cnt+=aa[i];
    }
    d=cnt*1.0/n;
    rep(i,n){
        if(abs(aa[i]-d)<dd){
            dd=abs(aa[i]-d);
            a=i;
        }
    }
    cout<<a;
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	map<int,int> deg;
	int mx=0;
	for (int i=0; i<3; i++) {
		int a,b; cin>>a>>b; deg[a]++; deg[b]++;
		mx=max({mx,deg[a],deg[b]});
	}
	cout<<(mx<=2?"YES":"NO")<<"\n";
	return 0;
}

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

int main()
{
	int X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;
	vector<long long> p( A );
	for( int i = 0; i < A; i++ ) {
		cin >> p[i];
	}
	vector<long long> q( B );
	for( int i = 0; i < B; i++ ) {
		cin >> q[i];
	}
	vector<long long> r( C );
	for( int i = 0; i < C; i++ ) {
		cin >> r[i];
	}

	sort( p.begin(), p.end(), greater<long long>() );
	sort( q.begin(), q.end(), greater<long long>() );
	sort( r.begin(), r.end(), greater<long long>() );
	long long ans = 0;
	int pi = 0;
	int qi = 0;
	int ri = 0;
	for( int i = 0; i < X + Y; i++ ) {
		long long ma = 0;
		int s = -1;
		if( pi < min( X, A ) ) {
			ma = p[pi];
			s = 0;
		}
		if( qi < min( Y, B ) && q[qi] > ma ) {
			ma = q[qi];
			s = 1;
		}
		if( ri < C && r[ri] > ma ) {
			ma = r[ri];
			s = 2;
		}
		if( s == 0 ) pi++;
		else if( s == 1 ) qi++;
		else if( s == 2 ) ri++;
		ans += ma;
	}

	cout << ans << endl;
}


Measured memory_bytes: 2560
import numpy as np

H,W = map(int,input().split())
# 周りに壁を、0,1化、壁を0で持つ
grid = np.zeros((H+2,W+2),dtype=np.bool)
grid[1:-1,1:-1] = (np.array([list(input()) for _ in range(H)]) == '.')

# x軸方向の集計
def F(transpose):
  x = grid
  if transpose:
    x = x.T
  x = np.ravel(x) # to 1D array
  L = len(x)
  
  left_zero = -np.arange(L) # 左の壁のindexの-1倍
  left_zero[x] = 0
  np.minimum.accumulate(left_zero, out=left_zero)
  
  right_zero = np.arange(L) # 逆順ソートした上で左の壁のindex
  right_zero[x[::-1]] = 0
  np.maximum.accumulate(right_zero, out=right_zero)
  
  y = left_zero
  y += L-right_zero[::-1]
  
  return y.reshape(grid.T.shape).T if transpose else y.reshape(grid.shape)
  
answer = (F(False) + F(True)).max()-5
print(answer)


Measured memory_bytes: 161324
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int a,b,c,i,j;
	cin>>a>>b>>c;
	if(a<=c&&c<=b)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(void) {
	int X,i,j;
	scanf("%d", &X);
	for (i = 1; i < 1000;i++) {
		for (j = -1000; j < 1000; j++) {
			if (pow(i, 5) - pow(j, 5) == X) {
				printf("%d %d", i, j);
				return 0;
			}
		}

	}
	
}

Measured memory_bytes: 2596
N = int(input())
weight = list(map(int, input().strip().split()))
 
S1 = 0
S2 = 0
 
for i in range(N):
    S1 += weight[i]
 
res = S1
for i in range(N):
    S1 -= weight[i]
    S2 += weight[i]
    if S1 < S2:
        if S2 - S1 < res:
            res = S2 - S1
        break
    if S1 - S2 < res:
        res = S1 - S2
 
print(res)

Measured memory_bytes: 9092
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int k = in.nextInt();
            int[] a = new int[k];
            for (int i = 0; i < k; ++i) a[i] = in.nextInt();
            long min = 2;
            long max = 2;
            for (int i = k - 1; i >= 0; --i) {
                long b = a[i];
                min = (min + b - 1) / b * b;
                max = max / b * b;
                if (min > max) {
                    out.println(-1);
                    return;
                }
                max += b - 1;
            }
            out.println(min + " " + max);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 40032
//#include<bits/stdc++.h>
#include<iostream>
#include <stdio.h>
#include<vector>
#include<math.h>

using namespace std;

//#define io freopen("test.txt", "r", stdin);
#define fast ios_base::sync_with_stdio(0);cin.tie(0);


#define ull unsigned long long int
#define lli long long int
#define li long int
#define ld long double

#define cout(x) cout<<x<<" "
#define coutn(x) cout<<x<<endl
#define newline cout<<endl

#define sz(x) (int)x.size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()

const int MOD=1000000007;
const lli INF=1e18;
const int MX=100001;
const int N=1000000;


vector<int> g[N];
bool v[N];
int id[N],s[N];
lli n,m,k,x,y;

int root(int i){
    while(id[i]!=i){
        id[i]=id[id[i]];
        i=id[i];
    }
    return i;
}

void uni(int x, int y){
    int rx=root(x), ry=root(y);
    if(rx==ry) return;
    if(s[rx]<s[ry]){
        id[rx]=ry;
        s[ry]+=s[rx];
        s[rx]=0;
    }else{
        id[ry]=rx;
        s[rx]+=s[ry];
        s[ry]=0;
    }
}

int main(){
    fast 
    //io

    cin>>n>>m;
    k=0;
    while(n--){
        cin>>x>>y;
        x=x*x, y=y*y;
        ld ans = sqrt(x+y);
        
        if(ans<=double(m))
            k++;
            //cout<<ans<<" "<<m<<endl;
        
    }

    cout<<k<<endl;

    return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1e9 + 7

using namespace std;

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

int main(void)
{
    int n;
    cin >> n;
    cout << lcm(2, n) << endl;
    return 0;
}

Measured memory_bytes: 256
import random
#a,bの最大公約数
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)


#nの約数列挙
def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    return ass

#n以下の素数列挙(O(n log(n))
def primes(n):
    is_prime = [True] * (n + 100)
    is_prime[0] = False
    is_prime[1] = True
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False

    return is_prime

def is_prime(n):
    if n == 1:
        return True
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


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

g = gcd(a,b)
d = divisor(g)
d.sort()

res = 0

#isp = primes(g)
#print(isp)

for e in d:
    if is_prime(e):
        res += 1

print(res)



Measured memory_bytes: 41836
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    ll x,y;
    cin>>x>>y;
    ll ans=longinf;
    if(x<=y)ans=min(y-x,ans);
    if(-x<=y)ans=min(x+y+1,ans);
    if(x<=-y)ans=min(-y-x+1,ans);
    if(-x<=-y)ans=min(-y+x+2,ans);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <functional>
#include <set>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<ll,ll>;
const ll M = 1e9+7;
void add(ll& x, ll y) {x+=y; x%=M;}
void chmax(ll& x, ll y) {if (x<y) x=y;}

int main() {
  int n; cin>>n;
  ll a[n],b[n];
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n;i++) cin>>b[i];

  bool p[n]={};
  ll nw = -1;
  for(int i=0;i<n;i++) {
    if (nw != a[i]) {
      if (a[i] > b[i]) {
        cout<<"0"<<endl;
        return 0;
      }
      p[i]=true;
      nw = a[i];
    }
  }

  nw = -1;
  for(int i=n-1;i>=0;i--) {
    if (nw != b[i]) {
      if (a[i] < b[i]) {
        cout<<"0"<<endl;
        return 0;
      }
      p[i]=true;
      nw = b[i];
    }
  }

  ll an=1;
  for(int i=0;i<n;i++) {
    if (p[i]) continue;
    an*=min(a[i],b[i]); an%=M;
  }
  cout<<an<<endl;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
const int N=100009;
typedef long long ll;
ll n,ans;
ll a[N];
ll pos[N];
ll lmaxp[N],rmaxp[N];
int main() {
    cin>>n;
    for(ll i=1;i<=n;i++) {
        cin>>a[i];
        pos[a[i]]=i;
        lmaxp[i]=i-1;
        rmaxp[i]=i+1;  
    }
    for(ll i=1;i<=n;i++) {
        ll lpos1=lmaxp[pos[i]];
        ll lpos2=lmaxp[lpos1];
        ll rpos1=rmaxp[pos[i]];
        ll rpos2=rmaxp[rpos1];
//        cout<<lpos2<<" "<<lpos1<<" "<<i<<" "<<rpos1<<" "<<rpos2<<endl;
        if(lpos1!=0) ans+=i*(lpos1-lpos2)*(rpos1-pos[i]);
        if(rpos1!=n+1) ans+=i*(pos[i]-lpos1)*(rpos2-rpos1);
        lmaxp[rpos1]=lpos1;
        rmaxp[lpos1]=rpos1;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  
  sort(A.begin(), A.end());

  ll res1, res2;
  res2 = -1;
  bool flag = false;
  for(int i = N-1; i >= 0; i--){
    if(A[i] == A[i-1]){
      if(!flag){
	res1 = A[i];
      }else{
	res2 = A[i];
	break;
      }
      i--;
      flag = true;
    }
  }

  if(res2 == -1){
    cout << 0 << endl;
  }else{
    cout << res1 * res2 << endl;
  }
}


Measured memory_bytes: 1024
#include<iostream>

using namespace std;
typedef struct pointT
{
        int *h;
        int *v;
        int sho;
}point;

int main(){
        int h,w;
        cin >> h >> w;

        point * map = new point[h*w];
        int* tmp = new int[2 * h*w];
        tmp[0] = 0;
        int tmp_cnt = 1;

        char c;
        for(int i=0;i<h*w;i++){
                cin >> c;
                map[i].h = 0;
                map[i].v = 0;
                map[i].sho =  c== '#' ? 1 : 0;
        }

        for(int i=0, k = 0, cnt = 0;i<h;i++, k+=w){
                for(int j=0;j<w;j++){
                        if(!map[k + j].sho){
                                cnt++;
                                map[k+j].h = &tmp[tmp_cnt];
                        }
                        else
                        {
                                if(cnt > 0){
                                        tmp[tmp_cnt] = cnt;
                                        tmp_cnt++;
                                }
                                map[k+j].h = &tmp[0];
                                cnt = 0;
                        }
                }
                if(cnt > 0){
                        tmp[tmp_cnt] = cnt;
                        tmp_cnt++;
                        cnt = 0;
                }
        }
        for(int i=0, cnt = 0;i<w;i++){
                for(int j=0;j<h;j++){
                        if(!map[i + j * w].sho){
                                cnt++;
                                map[i+j * w].v = &tmp[tmp_cnt];
                        }
                        else
                        {
                                if(cnt > 0){
                                        tmp[tmp_cnt] = cnt;
                                        tmp_cnt++;
                                }
                                map[i+j * w].v = &tmp[0];
                                cnt = 0;
                        }
                }
                if(cnt > 0){
                        tmp[tmp_cnt] = cnt;
                        tmp_cnt++;
                }
                cnt = 0;
        }

        int max = 0;
        for(int i=0;i<w;i++){
        for(int j=0;j<h;j++)
        {
                point* m = &map[i + j * w];
                //cout << "(" << *m->h << "," << *m->v << ")  ";
                if(max < *m->h + *m->v){
                        max = *m->h + *m->v;
                        //cout << "(" << i << "," << j << ") : " << max << endl;
                }
        }
        //cout << endl;
        }

        cout << max - 1<< endl;
}

Measured memory_bytes: 102656
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, a;
    cin >> x >> a;
    if (x < a)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << 10 << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
 
int main(void){
	int n, k;
	string s;
	cin >> n >> k >> s;
	int j = 0; bool r = false;	
	int l = 0;
	
	while(j!=n){
		if(r^(s[j]=='A')) s[j] = r?'A':'B';
		else{
			j++;
			s += (r?'A':'B');
			r = !r;
		}
		l++;
		if(l==k){
			s = s.substr(j, n);
			if(r){
				rep(i, n){
					s[i] = s[i]=='A'?'B':'A';
				}
			}
			cout << s << endl;
			return 0;
		}
	}
	
	rep(i, (k-l)%2){
		if(r^(s[j]=='A')) s[j] = r?'A':'B';
		else{
			j++;
			s += (r?'A':'B');
			r = !r;
		}
	}
	
	s = s.substr(j, n);
	if(r){
		rep(i, n){
			s[i] = s[i]=='A'?'B':'A';
		}
	}
	
	cout << s << endl;
	
	return 0;
}

Measured memory_bytes: 900
/*
 * DATE : 2017-07-29
 * Algo :
*/
#include<bits/stdc++.h>
using namespace std;
/*------- Constants---- */

#define LL                      long long
#define Ulong                   unsigned long long
#define FOR(I,A,B)              for(long long i=0; i < n ; i++ )
#define REP(i,n)                for(long long i=0; i < n ; i++ )
#define mp                      make_pair
#define pb                      push_back
#define all(x)                  (x).begin(),(x).end()
#define PI                      acos(-1.0)
#define EPS                     1e-14
#define F                       first
#define S                       second
#define di(x)                   int x; input(x)
#define in(x)                   input(x)
#define in2(x,y)                in(x),in(y)
#define in3(x,y,z)              in(x),in2(y,z)
#define lc                      ((n)<<1)
#define rc                      ((n)<<1|1)
#define db(x)                   cout << #x << " -> " << x << endl
#define nl                      cout<<endl
#define ms(ara_name,value)      memset(ara_name,value,sizeof(ara_name))
#define IO                      ios_base::sync_with_stdio(0);cin.tie(0)
#define READ                    freopen("in.txt","r",stdin)
#define WRITE                   freopen("out.txt","w",stdout)
template<class T> inline void input(T &x) {
    register char c = getchar();x = 0;
    int neg = 0;
    for(; ((c<48 || c>57) && c != '-'); c = getchar());
    if(c=='-'){neg = 1;c = getchar();}
    for(; c>47 && c<58 ; c = getchar()){x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x = -x;
}
inline long long bigmod(long long p,long long e,long long M){
    long long ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

/***************************** END OF TEMPLATE *******************************/

const int N = 2e5+5;

int n,m;
int a,b;
unordered_set<int> g[N];
int main()
{   cin >> n >> m;
    for(int i = 1;i <= m; i ++ ) {
        cin >> a >> b;
        g[a].insert(b);
        g[b].insert(a);
    }
    for(int i = 2;i < n; i ++ ) {
        if(g[1].count(i) && g[i].count(n)) {
            printf("POSSIBLE\n");
            return 0;
        }
    }
    printf("IMPOSSIBLE\n");
    return 0;
}


Measured memory_bytes: 31944
#include <bits/stdc++.h>
#define owo(i,a, b) for(int i=(a);i<(b); ++i)
#define uwu(i,a, b) for(int i=(a)-1; i>=(b); --i)
#define senpai push_back
#define ttgl pair<int, int>
#define ayaya cout<<"ayaya~"<<endl
 
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
gpu_hash_map<int, int> mp;*/
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
const ll root = 62;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
const double PI = acos(-1);
const double eps = -1e6;
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
const int mxN = 100001;
int arr[mxN];
ll sumx[mxN];
int rsum[mxN];
ll sumxmod[mxN];
int lsummod[mxN];
int n;
vector<int> divs[mxN];
int main() {
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0)->sync_with_stdio(0);
    cin>>n;
    cout<<(n>=30 ? "Yes\n" : "No\n");
    return 0;
}

Measured memory_bytes: 5988
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

int n;
int a[5][N];
int cache[5][N];

int dp(int idx, int prev)
{
	if(idx==n+1)
		return 0;
	int &ans=cache[prev][idx];
	if(ans!=-1)
		return ans;
	ans=0;
	for(int i=1;i<=3;i++)
	{
		if(i==prev)
			continue;
		ans=max(ans, a[i][idx] + dp(idx+1, i));
	}
	return ans;
}

int32_t main()
{
	IOS;
	memset(cache, -1, sizeof(cache));
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=3;j++)
			cin>>a[j][i];
	}
	int ans=dp(1, 0);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 15104
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 200005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

void solve() {
	LL n;
	cin>>n;
	LL a[n];
	LL f[MAX] = {0};
	for(int i=0;i<n;i++) {
		cin>>a[i];
		f[a[i]]++;
	}
	
	LL ans = 0;
	for(int i=1;i<MAX;i++) {
		if(f[i] > 0) ans = ans + (f[i] * (f[i]-1))/2;
	}
	
	for(int i=0;i<n;i++) {
		cout<<ans - (f[a[i]]-1)<<en;
	}
}

int main() {
	int t = 1;
	
	//~cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define MOD			1000000007
#define FOR(i,l,r)	for(int i=l;i<=r;i++)
#define REP(i,n)	for(int i=1;i<=n;i++)
#define REP0(i,n)	for(int i=0;i<n;i++)
#define PB			push_back
#define MP			make_pair
#define PII			pair<int,int>
#define VI			vector<int>
#define ALL(x)		(x).begin(),(x).end()
int n,m;
vector<int> g[200005];
int a[200005],ans[200005];
void dfs(int cur,int sum,int fa){
	ans[cur]=sum+a[cur];
	for(int i=0;i<g[cur].size();i++){
		int to=g[cur][i];
		if(to==fa)	continue;
		dfs(to,ans[cur],cur);
	}
}
int main(){
	cin>>n>>m;
	for(int i=1;i<n;i++){
		int u,v;cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	while(m--){
		int x,p;cin>>x>>p;
		a[x]+=p;
	}
	dfs(1,0,0);
	for(int i=1;i<=n;i++)	cout<<ans[i]<<" ";
	return 0;
}

Measured memory_bytes: 27136
#include<cstdio>
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;

int main(void) {
	int N;
	scanf("%d", &N);
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	vector<int> copy(A);
	sort(copy.begin(), copy.end());
	for (int i = 0; i < N; i++) {
		if (A[i] == copy[N - 1]) {
			printf("%d\n", copy[N - 2]);
		} else {
			printf("%d\n", copy[N - 1]);
		}
	}
	return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int f[110][110]={},h,w,ans;
int dy[4]={1,-1,0,0};
int dx[4]={0,0,1,-1};
string s[110];


void dfs(int y,int x,char c){
	if(y<0||h<=y||x<0||w<=x||s[y][x]!=c||f[y][x]) return;
	f[y][x]=1;
	rep(i,0,4){
		int ny=y+dy[i],nx=x+dx[i];
		dfs(ny,nx,c);
	}
	return;
}

int main(){
	while(cin>>h>>w){
		if(h==0 && w==0) break;
		rep(i,0,h){
			cin>>s[i];
			rep(j,0,w){
				f[i][j]=0;
			}
		}
		ans=0;
		rep(i,0,h){
			rep(j,0,w){
				if(f[i][j]==0){
					dfs(i,j,s[i][j]);
					ans++;
				}
			}
		}
		o(ans);
	}
}

Measured memory_bytes: 1732