akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  int N,K;
  cin>>N>>K;
  ll R,S,P;
  cin>>R>>S>>P;
  string T;
  cin>>T;

  vector<int> win(N,0);
  ll ans=0;
  for(int i=0;i<N;i++){
    bool w=false;
    if(i>=K){
      if(win[i-K]&&T[i]==T[i-K]){

      }else{
        win[i]=1;
        w=true;
      }
    }else{
      win[i]=1;
      w=true;
    }

    if(w){
      if(T[i]=='r') ans+=P;
      else if(T[i]=='s') ans+=R;
      else ans+=S;
    }
  }

  cout<<ans<<endl;

  return 0;
}


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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxn = 1100;
int A[maxn][maxn];

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0); cout.precision(10); cout << fixed;
    int h,w,a,b;
    while (cin >> h >> w >> a >> b) {
        if (h-b < b || w-a < a)
            cout << -1 << endl;
        else {
            FOR(i,0,h) {
                int aa = a;
                FOR(j,0,w) {
                    if (aa)
                        A[i][j] = 1, aa--;
                    else
                        A[i][j] = 0;
                }
            }
            FOR(i,b,h) FOR(j,0,w)
                A[i][j] ^= 1;
            FOR(i,0,h) {
                FOR(j,0,w)
                    cout << A[i][j];
                cout << endl;
            }
        }
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  string S;
  cin >> S;
  for (int i = 0; i < S.size(); i++) {
    cout << char((S[i] - int('A') + N) % 26 + int('A'));
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(){
    long long K;
    while(cin >> K){
        vector<long long> res(50, 49+(K+49)/50);
        long long n = (K+49)/50*50;
        while(n > K){
            int mIdx = 0;
            for(int i=1;i<50;i++) if(res[mIdx] < res[i]) mIdx = i;
            for(int i=0;i<50;i++){
                if(i == mIdx) res[i] -= 50;
                else res[i]++;
            }
            --n;
        }
        cout << 50 << endl;
        cout << res[0];
        for(int i=1;i<50;i++) cout << " " << res[i];
        cout << endl;
    }
}

Measured memory_bytes: 256
// Fails for 4 test cases, but why??

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main()
{
    string s, t;
    cin >> s >> t;
    ll n = s.length(), m = t.length();
    vector<vector<pair<ll, char>>> dp(n + 1, vector<pair<ll, char>>(m + 1, {0, 'o'}));
    for (int i = 0; i <= m; i++)
        dp[0][i] = {0, 'L'};
    for (int i = 0; i <= n; i++)
        dp[i][0] = {0, 'U'};
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            if (s[i - 1] == t[j - 1])
            {
                dp[i][j] = {dp[i - 1][j - 1].first + 1, 'D'};
            }
            else
            {
                if (dp[i - 1][j].first > dp[i][j - 1].first)
                {
                    dp[i][j] = {dp[i - 1][j].first, 'U'};
                }
                else
                {
                    dp[i][j] = {dp[i][j - 1].first, 'L'};
                }
            }
        }
    }
    // for (int i = 0; i <= n; i++)
    // {
    //     for (int j = 0; j <= m; j++)
    //     {
    //         cout << dp[i][j].first << "," << dp[i][j].second << "  ";
    //     }
    //     cout << "\n";
    // }
    string ans = "";
    ll x = n, y = m;
    while (x > 0 || y > 0)
    {
        if (dp[x][y].second == 'D')
        {
            ans = s[x - 1] + ans;
            x--;
            y--;
        }
        else if (dp[x][y].second == 'U')
        {
            x--;
        }
        else
        {
            y--;
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 142464
// Problem : A - Registration
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db long double
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define mi map<int,int>
#define ml map<ll,ll>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define MAX 4294967295
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MAXN 15000005
#define inf 1e10
#define PI acos(-1.0)
#define int long long

string s,t;

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    cin>>s>>t;
    int f=0;
    for(int i=0;i<sz(s);i++){
        if(s[i]!=t[i]){
            f=1;
            break;
        }
    }
    if(!f && sz(t)==sz(s)+1) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 3616
S = input()
T = input()

def normalized(S):
    m_set = list()
    for moji in S:
        if moji not in m_set:
            m_set.append(moji)
    m_dic = {m : i for i, m in enumerate(m_set)}
    ad_list = [m_dic[moji] for moji in S]

    return ad_list

print('Yes' if normalized(S)==normalized(T) else 'No')

Measured memory_bytes: 6832
H, W = map(int, input().split())
if H % 3 == 0 or W % 3 == 0:
    sq = 0
else:
    sq = min((H // 3 + 1 - H // 3) * W, (W // 3 + 1 - W // 3) * H)
for H, W in [[H, W], [W, H]]:
    for h in range(1, H + 1):
        sq21 = h * W
        sq22 = (H - h) * -(-W // 2)
        sq23 = (H - h) * (W // 2)
        sq = min(sq, max(sq21, sq22, sq23) - min(sq21, sq22, sq23))
print(sq)


Measured memory_bytes: 3064
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main(){
	FIO
	
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	if(s[0] == 'a' && s[1] == 'b' && s[2] == 'c')puts("Yes");
	else puts("No");
	return 0; 
}


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

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

using namespace std;


//v.push_back(123);
//sort(v.begin(), v.end(),greater<int>());
//for(int x : v) {cout << x << endl;}

//for(int x: v) cout << x << endl;
//vector<vector<char>> v(H, vector<char>(W));
// vector<int> v(1000);

long long pow_mod(long long x, long long y, long long MOD){
	long long ret = 1;
	while(y){
		if (y & 1) ret = ret * x % MOD;
		x = x * x % MOD;
		y>>=1;
	}
	return ret;
}

signed main(){
  int N;
  cin>>N;
  int A[N];
  rep(i, N) cin >> A[i];
  int max_tmp=0;
  int second_tmp = 0;
  rep(i, N){
    if(max_tmp<=A[i]){
      second_tmp = max_tmp;
      max_tmp = A[i];
    }
  }
  int max_true = 0;
  rep(i, N){
    max_true = 0;
    if(max_tmp==A[i]){
      if(second_tmp==max_tmp){
        cout << second_tmp << endl; 
      }else{
        rep(j, N){
          if(i==j) continue;
          if(max_true<A[j]){
            max_true = A[j];
          }
        }
        cout << max_true << endl;
      }
    }else{
      cout << max_tmp << endl;
    }

    
  }


  return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

lld gcd(lld x,lld y)
{
	if (y == 0)
	{
		return x;
	}
	return gcd(y,x%y);
}

int main()
{
	lld a,b;
	while(cin >> a >> b)
	{
		lld n = min(a,b);
		lld m = max(a,b);
		lld sol = gcd(m,n);
		cout << sol << " " << (n * m) / sol <<  endl;
	}


	return 0;
}

Measured memory_bytes: 2976
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <memory>        // unique_ptr, shared_ptr, weak_ptr

using namespace std;

int main() {
    int H, W;
    while (true) {
        cin >> H >> W;
        if (H == 0 && W == 0) break;
        for (int i=0; i<H; i++) {
            for (int j=0; j<W; j++) {
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;		 
}


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

int main(){
	string s;
	cin >> s;
	
	bool flag=(s[0]==s[s.size()-1]);
	if(s.size()%2==1)flag=!flag;
	
	if(flag)cout << "First" << endl;
	else cout << "Second" << endl;
	return 0;
}

Measured memory_bytes: 512
sx, sy, tx, ty = map(int, input().split())

ans = ""

y = (ty - sy) 
x = (tx - sx)

# 一周目
ans += "U" * y
ans += "R" * x
ans += "D" * y
ans += "L" * x

# 二周目
ans += "L"
ans += "U" * (y + 1)
ans += "R" * (x + 1)
ans += "D"
ans += "R"
ans += "D" * (y + 1)
ans += "L" * (x + 1)
ans += "U"

print(ans)

Measured memory_bytes: 38384
#include <algorithm>
#include <array>
#include <bitset>
#include <cstdint>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <memory>
#include <numeric>
#include <unordered_set>
#include <unordered_map>
#include <vector>

// constexpr std::int64_t INF = 1ull << 50;
constexpr int INF = 1 << 20;

std::uint64_t f(std::uint64_t n) {
  if (n % 2) {
    return n * 3 + 1;
  } else {
    return n / 2;
  }
}

auto main() -> int {
  std::uint64_t s;
  std::cin >> s;

  std::array<std::uint64_t, 2> as{};
  as.at(0) = s;

  std::unordered_set<std::uint64_t> m{};
  m.emplace(s);

  for (auto i = 1ul;; ++i) {
    auto& ai = as.at(i % 2);
    auto& aip = as.at((i + 1) % 2);

    ai = f(aip);
    // std::cout << i << ' ' << "f(" << aip << ") = " << ai << std::endl;

    if (m.count(ai)) {
      std::cout << (i + 1) << std::endl;
      break;
    } else {
      m.emplace(ai);
    }
  }
}


Measured memory_bytes: 384
N = int(input())
As = list(map(int, input().split()))
mod = 10**9+7

dp = [[0]*3 for _ in range(N+1)]
ans = 1
for i in range(N):
    a = As[i]
    dplis = dp[i]
    cnt = 0
    dp[i+1] = dplis[:]
    for j, d in enumerate(dplis):
        if a==d:
            cnt += 1
            if cnt==1:
                dp[i+1][j] = a+1
    if cnt==0:
        print(0)
        break
    ans = ans*cnt%mod
else:
    print(ans%mod)

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

int main(void){
    int n,sum=0;
    cin >> n;
    int d[n];
    for(int i=0; i < n; i++) cin >> d[i];

    for(int p=0; p < n; p++){
        for(int q=p+1; q < n; q++){
            sum = sum + d[p] * d[q];
        } 
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int x,y;
    while(true){
        cin >> x >> y;
        if(x == 0 && y == 0){
            break;
        }else if(x < y){
            cout << x <<" "<< y << endl;
        }else{
            cout << y <<" "<< x << endl;
        }
    }
}


Measured memory_bytes: 3072
while 1:
    m,f,r=map(int,input().split())
    if m == -1 and f == -1 and r == -1: break
    if m == -1 or f == -1: s = 'F'
    elif m + f >= 80: s = 'A'
    elif m + f >= 65: s = 'B'
    elif m + f >= 50: s = 'C'
    elif m + f >= 30: 
        if r >= 50: s = 'C'
        else : s = 'D'
    else : s = 'F'
    print(s)

Measured memory_bytes: 7668
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

int comp(const void *px, const void *py){
    char x = *(char*)px;
    char y = *(char*)py;
    return (x>y)?1:(x<y)? -1:0;
}

int main(void){
    char w[101];
    int count[100];
    bool yn=true;

    scanf("%s",w);
  
    qsort(w,strlen(w),sizeof(char),comp);
    int i=0;

    while(w[i]!='\0'){
        //printf("1  ");
        int c=i+1;
        while(w[i]==w[c]){
            //printf("2  ");
            c++;
        }
        if((c-i)%2==1){
            yn=false;
            break; //奇数検知
        }
        i=c;
           
    }
    if(yn==false){
        puts("No");
    } else{
        puts("Yes");
    }
    return 0;

}

Measured memory_bytes: 128
N, K = list(map(int, input().split()))
H = sorted([int(input()) for _ in range(N)])

min_h = 1e15
for i in range(N-K+1):
    tmp = H[i+K-1] - H[i]
    if tmp < min_h:
        min_h = tmp
print(min_h)


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

using namespace std;

const int N = 5010;
int f[N][N];
bool up[N][N], le[N][N];

void solve(int x, int y) {
	if (x & 1) return;
	if (y & 1) {
		up[x / 2 + 1][y / 2 + 1] = true;
	} else {
		le[x / 2 + 1][y / 2 + 1] = true;
	}
}

int n, m, k, d;

int main() {
	scanf("%d %d %d", &n, &m, &k);
	swap(n, m);
	n = (n + 1) / 2;
	m = (m + 1) / 2;
	scanf("%d", &d);
	for (int i = 1; i <= d; i++) {
		int x, y;
		scanf("%d %d", &x, &y);
		swap(x, y);
		solve(x, y);
	}
	for (int i = 1; i <= n; i++) {
		f[i][0] = f[i - 1][m];
		for (int j = 1; j <= m; j++) {
			f[i][j] = f[i][j - 1] + (up[i][j] ? 2 : 1);
			if (j >= 2) f[i][j] = min(f[i][j], f[i][j - 2] + 2 * (le[i][j] ? 2 : 1));
		}
	}
	if (k < m) {
		cout << -1 << endl;
		return 0;
	}
	k -= m;
	int t = f[n][m] - n * m;
	int ans = f[n][m];
	ans -= m;
	d = min(k, t);
	ans -= 2 * d;
	k -= d;
	d = min(ans, k);
	ans -= d;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 149276
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n:usize,
        h: [i64;n],
    }
    let mut high: i64 = 0;
    let mut flag = false;
    for i in 0..n {
        if high - h[i] > 1 {
            flag = true;
        }
        high = std::cmp::max(high, h[i]);
    }
    if flag {
        println!("No");
    }else{
        println!("Yes");
    }
}

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

int dp[3003][3003];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s, t;
	cin >> s >> t;
	s = '-' + s; t = '-' + t;
	for (int i = 1; i < s.size(); ++i) {
		for (int j = 1; j < t.size(); ++j) {
			dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
			if (s[i] == t[j]) {
				dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
			}
		}
	}
	
	string r = "";
	int i = s.size() - 1; int j = t.size() - 1;
	while (i > 0 && j > 0) {
		if (dp[i - 1][j] == dp[i][j]) {
			--i;
			continue;
		}
		if (dp[i][j - 1] == dp[i][j]) {
			--j;
			continue;
		}
		
		r += t[j];
		--i; --j;
	}
	
	reverse(r.begin(), r.end());
	cout << r << "\n";
	return 0;
}


Measured memory_bytes: 35456
def check_bingo(point_list):
  BINGO_LIST = (
    ((0, 0), (0, 1), (0, 2)),
    ((1, 0), (1, 1), (1, 2)),
    ((2, 0), (2, 1), (2, 2)),
    ((0, 0), (1, 0), (2, 0)),
    ((0, 1), (1, 1), (2, 1)),
    ((0, 2), (1, 2), (2, 2)),
    ((0, 0), (1, 1), (2, 2)),
    ((0, 2), (1, 1), (2, 0))
  )
  for bingo_line in BINGO_LIST:
    bingo_flg = True
    for point in bingo_line:
      if point in point_list:
        continue
      else:
        bingo_flg = False
        break
    if bingo_flg:
      return True
  return False

def get_point(ind):
  x = ind % 3
  y = ind // 3
  
  return x, y

number_list = []
point_list = []
for i in range(3):
  number_list.extend(list(map(int, input().split())))
n = int(input())
for i in range(n):
  b = int(input())
  
  if b in number_list:
    point_list.append(get_point(number_list.index(b)))

if check_bingo(point_list):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = "";
		String alp = "abcdefghijklmnopqrstuvwxyz";
		int ans[] = new int[26];
		while(sc.hasNext()) {
			s =sc.nextLine();
			for (int i = 0; i < s.length(); i++) {
				for (int j = 0; j < 26; j++) {
					if (Character.toLowerCase(s.charAt(i)) == alp.charAt(j)) {
						ans[j]++;
					}
				}
			}
		}
		for (int i = 0; i < 26; i++) {
			System.out.println(alp.charAt(i) + " : " + ans[i]);
		}
	}
}


Measured memory_bytes: 26328
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int dp[100005][3];
int fun[100005][3];
int solve(int day , int activity){
    if(day<0)
        return 0 ;
    if(dp[day][activity]!=-1)
        return dp[day][activity];
    int res = INT_MIN;
    for(int i=0;i<3;i++){
        if(activity!=i){
            res = max(solve(day-1,i)+fun[day][activity],res);
        }
    }
    dp[day][activity]=res;
    return res ;
}
int main()
{
    ll n ;
    cin >> n ;
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin >> fun[i][j];
            dp[i][j]=-1;
        }
    }
    int res = solve(n-1,0);
    res = max(res,solve(n-1,1));
    res = max(res,solve(n-1,2));
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 10368
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int sum = 0;
		
		for(int i = 0; i < 10; i++)
			sum += sc.nextInt();
		
		System.out.println(sum);
		
		sc.close();
	}
}

Measured memory_bytes: 17208
import java.util.*;
import java.io.*;
class Main {
    public static void main(String args[] ) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int que = Integer.parseInt(br.readLine());
        int odds = (que/2) + (que%2);
        double dd = ((double)odds/(double)que);
        System.out.println(dd);
   }
}


Measured memory_bytes: 22612
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

// #define FL fflush(stdout)

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
  return scanf("%lld", &x);
}

int GI(int& x) {
  return scanf("%d", &x);
}

LL A, B;
int main() {
  GLL(A);
  GLL(B);

  if (max(A, B) - min(A, B) >  1) {
    printf("Alice\n");
  } else {
    printf("Brown\n");
  }
    
  return 0;
}


Measured memory_bytes: 256
from operator import itemgetter

N = int(input())
AB = sorted([list(map(int,input().split())) for i in range(N)])
CD = sorted([list(map(int,input().split())) for i in range(N)])
inf = float('inf')
ans = 0

for bx, by in CD:
    S = list(filter(lambda n:n[0]<bx, AB))
    S = list(filter(lambda n:n[1]<by, S))
    if len(S) != 0:
        S.sort(key=itemgetter(1))
        AB[AB.index(S[-1])] = [inf, inf]
        ans += 1
print(ans)


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

set<long> s;

long read_long() {
	long ret=0;char c=getchar();
	while(c<'0' || c>'9') c=getchar();
	while(c>='0' && c<='9') {
		ret=ret*10+c-'0';
		c=getchar();
	}		return ret;
}

int main() {
	long n;
	cin>>n;
	long i;
	long a;
	for(i=1;i<=n;++i) {
		a=read_long();
		s.insert(a);
		long nnn=s.size();
		if(nnn!=i) {
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           v.size()
#define		ss              ' '
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
typedef		long long       ll;
typedef		vector<ll>      vll;


int main()
{
   ll a,p;
   S(a);
   for(ll i=a;;i++)
   {
       p=0;
       for(ll j=2;j<i;j++){
          if(i%j==0){
            p=1;
          break;
          }

       }

       if(p==0){
        cout<<i<<nn;
     break;
       }
   }


    return 0;
}


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

int dfs(int n,int point);

int main(){
  int d,g;
  cin >>d >>g;
  int p[d],c[d];
  for(int i=0;i<d;i++)cin >> p[i] >>c[i];
  int ans=INT_MAX;
  for(int bit=0;bit<(1<<d);bit++){
    int point=0,count=0,las=-1;
    for(int j=0;j<d;j++){
      if(bit&(1<<j)){
        point+=p[j]*(j+1)*100+c[j];
        count+=p[j];
      }
      else las=j;
    }
    if(las!=-1 && point<g && point+p[las]*(las+1)*100>=g){
      while(point<g){
        point+=(las+1)*100;
        count++;
      }
    }
    if(point>=g)ans=min(ans,count);
  }
  cout << ans <<endl;
}

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

ans = 0
# 各数列A内での転倒数
for i in range(n):
  for j in range(i+1,n):
    if a[i] > a[j]: ans += 1
ans *= k

# k回の繰り返しによって発生する転倒数
a.sort()
nums = [0]*n
for i in range(1,n):
  if a[i] > a[i-1]: nums[i] = i
  else: nums[i] = nums[i-1]

ans += sum(nums)*k*(k-1)//2
ans %= 10**9+7
print(ans)

Measured memory_bytes: 9080
N = int(input())
A = list(map(int, input().split()))
 
M = 10**6 + 1
 
cnt = [0] * M
 
for a in A:
    if cnt[a] != 0:
        cnt[a] += 1
        continue
    for b in range(a, M, a):
        cnt[b] += 1
 
ans = 0
for a in A:
    if cnt[a] == 1:ans += 1
 
print(ans)


Measured memory_bytes: 32232
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; ++i)  cin >> h[i];
    int ans = 0;
    bool update = true;
    while(update){
        update = false;
        bool flag = false;
        for(int i = 0; i < n; ++i){
            if(!flag){
                if(h[i] > 0){
                    --h[i];
                    ++ans;
                    flag = true;
                    update = true;
                }
            }
            else{
                if(h[i] > 0){
                    --h[i];
                }
                else    flag = false;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (n : _ : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  xs <- sequence . replicate n $ map unsafeSignedDecimal . T.words <$> T.getLine :: IO [[Int]]
  let
    l = length . filter ((==) <$> id <*> (^ 2) . sq) . fst . f $ xs
  print l

f :: [[Int]] -> ([Int], [[Int]])
f = foldr step ([], [])
  where
    step x (ds, xs) = ((dist2 x <$> xs) ++ ds, x : xs)

dist2 :: [Int] -> [Int] -> Int
dist2 x y = sum $ (^ 2) . uncurry subtract <$> zip x y

sq :: Int -> Int
sq x = sq' 0 x
  where
    sq' y z | z == y + 1 = z
            | m ^ 2 >= x = sq' y m
            | otherwise = sq' m z
      where
        m = (y + z) `div` 2

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


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

using namespace std;
#define ll long long

int main()
{
    int n;
    cin>>n;
    vector<int>a(n,0);
    for (int i=0;i<n-1;i++)
    {
        ll a1;
        cin>>a1;
        a[a1-1]++;
    }
    for (int i=0;i<n;i++)
        cout<<a[i]<<" ";
    return 0;
}


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

int main() {
	int N;
	cin >> N;
	int rev = 0, x = N;
	while (x) {
		rev = rev * 10 + x % 10;
		x /= 10;
	}
	if (rev == N) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

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

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

int N, K;
vector<int> g[MAX];

vector<int> h[MAX];

bool s[MAX] = {};

void tree(int v){
	s[v] = 1;
	rep(i, g[v].size()) {
		int w = g[v][i];
		if(s[w]==0){
			h[v].push_back(w);
			tree(w);
		}
	}
}



int main() {

	cin >> N >> K;
	
	
	rep(i, N-1) {
		int a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	tree(1);

	ll ans = K;

	repn(v, N) {
		ll st;
		if (v == 1) { st = K - 1; }
		else { st = K - 2; }

		repn(i, h[v].size()) {
			ans =(ans*st)%MOD;
			st--;
		}

	}

	cout << ans;

	system("PAUSE");


}

Measured memory_bytes: 30208
class UnionFind:
    def __init__(self, n):
        self.p = [-1]*n
        # union by rank
        self.r = [1]*n
 
    def find(self, x):
        if self.p[x] < 0:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]
 
    def union(self, x, y):
        rx, ry = self.find(x), self.find(y)
 
        if rx != ry:
            if self.r[rx] > self.r[ry]:
                rx, ry = ry, rx
            if self.r[rx] == self.r[ry]:
                self.r[ry] += 1
            self.p[ry] += self.p[rx]
            self.p[rx] = ry
 
    def same(self, x, y):
        return self.find(x) == self.find(y)
 
    def count_member(self, x):
        return -self.p[self.find(x)]

n,m=map(int,input().split())
e=[]
for i in range(m):
  a,b=map(int,input().split())
  e.append((a-1,b-1))
ans=0
for i in range(m):
  uf=UnionFind(n)
  ok=False
  for j in range(m):
    if i!=j:
      a,b=e[j]
      uf.union(a,b)
  for k in range(n):
    t=uf.count_member(k)
    if t!=n:
      ok=True
      break
  if ok:ans+=1
print(ans)



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int bonbon(int N){
    int t;
    t = N %10;
    return t;
}

int main(){
    int N, s;
    cin >> N;
    s = bonbon(N);
    switch (s)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout << "hon" << endl;
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon" << endl;
        break;
    default:
        cout << "bon" << endl;
        break;
    }
}

Measured memory_bytes: 3636
N,K = map(int,input().split())
lis = list(map(int,input().split()))
dic = {}
for i in range(1,N+1):
    dic[i-1] = 0
for i in lis:
    dic[i-1] += 1

lis2 = list(dic.values())
lis2.sort()
print(N - sum(lis2[N-K:]))

Measured memory_bytes: 38400
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int h[] = new int[n];
		boolean heigher[] = new boolean[n];
		for(int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
			heigher[i] = true;
		}
 
		for(int i = 0; i < m; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
 
			if(h[a-1] < h[b-1]) {
				heigher[a-1] = false;
			}else if(h[b-1] < h[a-1]) {
				heigher[b-1] = false;
			}else {
				heigher[a-1] = false;
				heigher[b-1] = false;
			}
		}
		int ans = 0;
		for(int i = 0; i < n; i++) {
			if(heigher[i]) {
				ans++;
			}
		}
		System.out.println(ans);
	}
 
}

Measured memory_bytes: 59164
#include<iostream>
#include<string>
using namespace std;
#define MAX 25
#define NIL -1

struct Node {
  int parent;
  int left;
  int right;
};

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int v, int d){
  if (v==NIL) {
    return;
  }
  D[v] = d;
  setDepth(T[v].left, d+1);
  setDepth(T[v].right, d+1);
}

int setHeight(int v) {
  if (v==NIL) {
    return -1;
  }
  int h1 = setHeight(T[v].left)+1;
  int h2 = setHeight(T[v].right)+1;
  return H[v] = max(h1, h2);
}

int getSibling(int v) {
  if (T[v].parent==NIL) {
    return NIL;
  } else {
    int l = T[T[v].parent].left;
    if (l!=v) {
      return l;
    } else {
      return T[T[v].parent].right;
    }
  }
}

int getDegree(int v) {
  if (T[v].left!=NIL && T[v].right!=NIL) {
    return 2;
  } else if (T[v].left!=NIL || T[v].right!=NIL) {
    return 1;
  } else {
    return 0;
  }
}

string attr(int v) {
  if (T[v].parent==NIL) {
    return "root";
  } else if (T[v].left==NIL && T[v].right==NIL) {
    return "leaf";
  } else {
    return "internal node";
  }
}

int main() {
  cin >> n;
  for (int i=0; i<n; i++) {
    T[i].parent = T[i].left = T[i].right = NIL;
  }

  int id, l, r;
  for (int i=0; i<n; i++) {
    cin >> id >> l >> r;
    T[id].left = l;
    T[id].right = r;
    if (l!=NIL) {
      T[l].parent = id;
    }
    if (r!=NIL) {
      T[r].parent = id;
    }
  }

  int root;
  for (int i=0; i<n; i++) {
    if (T[i].parent == NIL) {
      root = i;
    }
  }

  setDepth(root, 0);
  setHeight(root);

  for (int i=0; i<n; i++) {
    cout << "node " << i << ": ";
    cout  << "parent = " << T[i].parent << ", ";
    cout << "sibling = " << getSibling(i) << ", ";
    cout << "degree = " << getDegree(i) << ", ";
    cout << "depth = " << D[i] << ", ";
    cout << "height = " << H[i] << ", ";
    cout << attr(i) << endl;
  }

  return 0;
}



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

int main() {
	int i,j,k,c=0,n,m,d=0;
	cin>>n;
	int a[n],b[100]={0};
	for(i=0;i<n;i++)
	{
		cin>>a[i];	
	}
	for(i=0;i<n;i++)
	{
		b[a[i]-1]++;
	}
	for(i=0;i<100;i++)
	{
		if(b[i]>0)
			c++;
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

vector<int> dp(100010, 0);

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    dp[0] = n;
    REP(i,100010) {
        if(dp[i]%2 == 0) {
            dp[i+1] = dp[i]/2;
        } else {
            dp[i+1] = 3*dp[i]+1;
        }
    }
    vector<ll> ans(10000);
    REP(i,10000) {
        ans[dp[i]]++;
        if (ans[dp[i]] == 2) {
            cout << i+1 << std::endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 768
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr ll LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  constexpr int X = 18;
  int n, k; cin >> n >> k;
  vector<int> x(n); REP(i, n) cin >> x[i];
  vector dpl(X, vector(n, -1)), dpr(X, vector(n, -1));
  vector suml(X, vector(n, -1LL)), sumr(X, vector(n, -1LL));
  int right = 0;
  REP(i, n) {
    while (right < n && x[right] - x[i] < k) ++right;
    if (right < n) dpl[0][i] = suml[0][i] = right;
  }
  REP(i, X - 1) REP(j, n) {
    if (dpl[i][j] != -1) {
      dpl[i + 1][j] = dpl[i][dpl[i][j]];
      suml[i + 1][j] = suml[i][j] + suml[i][dpl[i][j]];
    }
  }
  int left = n - 1;
  for (int i = n - 1; i >= 0; --i) {
    while (left >= 0 && x[i] - x[left] < k) --left;
    if (left >= 0) dpr[0][i] = sumr[0][i] = left;
  }
  REP(i, X - 1) REP(j, n) {
    if (dpr[i][j] != -1) {
      dpr[i + 1][j] = dpr[i][dpr[i][j]];
      sumr[i + 1][j] = sumr[i][j] + sumr[i][dpr[i][j]];
    }
  }
  int q; cin >> q;
  while (q--) {
    int l, r; cin >> l >> r; --l; --r;
    int lb = 0, ub = r - l + 1;
    while (ub - lb > 1) {
      int mid = (lb + ub) / 2;
      int pos = l;
      REP(i, X) {
        if ((mid >> i & 1) && pos != -1) pos = dpl[i][pos];
      }
      (pos != -1 && pos <= r ? lb : ub) = mid;
    }
    ll ans = lb + 1 + r - l;
    int pos = l;
    REP(i, X) {
      if (lb >> i & 1) {
        ans -= suml[i][pos];
        pos = dpl[i][pos];
      }
    }
    pos = r;
    REP(i, X) {
      if (lb >> i & 1) {
        ans += sumr[i][pos];
        pos = dpr[i][pos];
      }
    }
    cout << ans << '\n';
  }
  return 0;
}


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

int main() {
	string S;
	cin >> S;
	string words[4] = { "dream", "dreamer", "erase", "eraser" };

	reverse(S.begin(), S.end());
	for (int i = 0; i < 4; i++) {
		reverse(words[i].begin(), words[i].end());
	}

	for (int i = 0; i < S.size();) {
		bool flag = false;
		for (int j = 0; j < 4; j++) {
			string w = words[j];
			if (S.substr(i, w.size()) == w) {
				flag = true;
				i += w.size();
				break;
			}
		}
		if (!flag) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vl>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

ll combination(int n, int r) {
  if (n < r) return 0;
  if (n-r < r) r = n-r;
  if (r == 0) return 1;
  if (r == 1) return n;
  vi numerator(r), denominator(r);
  rep(i,r) {
    numerator[i] = n-r+i+1;
    denominator[i] = i+1;
  }
  for (int p=2; p<=r; ++p) {
    int pivot = denominator[p-1];
    if (pivot > 1) {
      int offset = (n-r)%p;
      for (int j=p-1; j<r; j+=p) {
        numerator[j-offset] /= pivot;
        denominator[j] /= pivot;
      }
    }
  }
  ll ret = 1;
  rep(i,r) (ret *= numerator[i]) %= MOD;
  return ret;
}

void solve() {
  int H, W, K; cin >> H >> W >> K;

  Graph G(H+1, vl(W+2, 0));
  G[0][1] = 1;

  vector<vi> comb(W+1, vi(W+1));  // nCr = comb[n][r]
  rep(i,W+1) rep(j,W+1) comb[i][j] = combination(i,j);

  vi draw(W, 0);
  rep(i,W) rep(j,(i/2)+1) draw[i] += comb[i-j][j];

  for (int i=1; i<=H; ++i) {
    for (int j=1; j<=W; ++j) {
      // stay
      (G[i][j] += G[i-1][j] * draw[j-1] * draw[W-j]) %= MOD;
      // ->
      (G[i][j] += G[i-1][j-1] * draw[j-2] * draw[W-j]) %= MOD;
      // <-
      (G[i][j] += G[i-1][j+1] * draw[j-1] * draw[W-j-1]) %= MOD;
    }
  }

  cout << G[H][K] << endl;
  return;
}

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


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main(){
    gearup;
    ll n;cin>>n;
    vvl G(n);
    vpii E_in;
    rep(i,n-1){
        int a,b;cin>>a>>b;
        a--;b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
        E_in.push_back(make_pair(a,b));
    }

    queue<int> que;
    vb used(n, false); //そのノードについて調べたか
    vl parent(n);
    int max_color = 0;
    map<pair<int, int>, int> E_num; // 辺への割り振った番号を保持する
    que.emplace(0);
    used[0] = true;
    while(!que.empty()){
        int node = que.front();
        que.pop();
        int num_color = 0;
        for(auto nv:G[node]){
            if(used[nv])continue;
            num_color++;
            used[nv] = true;
            if(num_color == parent[node])num_color++;
            pair<int, int> p = make_pair(node, nv);
            E_num[p] = num_color; //辺彩色
            parent[nv] = num_color;
            que.push(nv); //次の状態をqueueへ格納
        }
        chmax(max_color,num_color);
    }
    out(max_color);
    for(auto i:E_in){
        out(E_num[i]);
    }
}

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

long long func(string sign, vector<long long> a) {
  long long sum = a.at(0);
  long long res = 0;
  if (sign == "plus" && a.at(0) <= 0) {
    res += 1 - a.at(0);
    sum = 1;
  }
  else if (sign == "minus" && a.at(0) >= 0) {
    res += a.at(0) + 1;
    sum = -1;
  }
  for (int i = 1; i < a.size(); i++) {
    long long next = a.at(i);
    long long step = 0;
    if (sum > 0 && sum + next >= 0) {
      step = next + sum + 1;
      sum = -1;
    }
    else if (sum < 0 && sum + next <= 0) {
      step = 1 - sum - next;
      sum = 1;
    }
    else sum += next;
    res += step;
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  cout << min(func("plus", a), func("minus", a)) << endl;
}

Measured memory_bytes: 2560
#include <cstdio>

int main(){
	while(1){
		int h, w;
		scanf(" %d %d", &h, &w);
		if(h==0 && w==0) break;
		
		for(int i=0; i<h; ++i){
			for(int j=0; j<w; ++j){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");

	}
	return 0;
}

Measured memory_bytes: 1000
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main(){
	var N int
	fmt.Scan(&N)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	arr := make([]int, N)
	for i := range arr {
		sc.Scan()
		s := sc.Text()
		n, _ := strconv.Atoi(s)
		arr[i] = n

	}

	if N == 0 {
		fmt.Println(0)
		return
	}

	before := arr[0]
	max := 0
	count := 0
	for i := 1; i < len(arr); i++ {
		if before >= arr[i] {
			count += 1
		}else{
			count = 0
		}
		if max < count {
			max = count
		}
		before = arr[i]
	}
	fmt.Println(max)
}


Measured memory_bytes: 3072
/*
 _____ _             _              _           _ 
|_   _| |__   ___   / \   _ __  ___| |__  _   _| |
  | | | '_ \ / _ \ / _ \ | '_ \/ __| '_ \| | | | |
  | | | | | |  __// ___ \| | | \__ \ | | | |_| | |
  |_| |_| |_|\___/_/   \_\_| |_|___/_| |_|\__,_|_|                                                

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define trav(a, x) 	for(auto& a : x)
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vii         vector<pair<ll int, ll int>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound

/*	For Debugging	*/
#define DEBUG 		cerr<<"/n>>>I'm Here<<</n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define DECIMAL(n)  cout << fixed ; cout << setprecision(n);
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace __gnu_pbds;
using namespace std;
#define PI 	3.141592653589793
#define N 	300005
#define LOG 	60
vi v(N);
ll a[LOG],pw[LOG],pw2[LOG];

void solve()
{
	ll n;
	cin>>n;
	rep(i,0,n)
	cin>>v[i];
	ll ans=0,vl;
	repr(i,0,n)
	{
		repr(j,0,60)
		{
			if(v[i]&pw[j])
			{
				vl=((n-1-i-a[j])*pw2[j])%hell;
				ans=(ans+vl)%hell;
				a[j]++;
			}
			else
			{
				vl=(a[j]*pw2[j])%hell;
				ans=(ans+vl)%hell;
			}
		}
	}
	cout<<ans<<endl;

	return;
}
int main()
{
	FAST
	pw[0]=1;
	pw2[0]=1;
	rep(i,1,LOG)
	{
		pw[i]=(2*pw[i-1]);
		pw2[i]=(2*pw2[i-1])%hell;
	}
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	TIME
	return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
int main(void)
{
	int N,k,p,i,a;
	scanf("%d",&N);
	for(i=1;i<=N;i++){
	scanf("%d %d",&k,&p);
	a=k%p;
	if(a==0){
	a=p;
	}
	printf("%d\n",a);
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#include <fstream>
#include <functional>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 200001
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;
struct Point{int x; int y;};
struct PPoint{Point x; Point y;};
ll gcd(ll a, ll b) { if(a < b) swap(a, b); if(b <= 0) return a; return gcd(b, a % b); }

int main(void)
{
 //   cin.tie(NULL); ios_base::sync_with_stdio(false);
    int W, H, x, y; cin >> W >> H >> x >> y;
    
    printf("%.9lf ", (double)W * H / 2);
    if(H % 2 == 0 && W % 2 == 0 && H / 2 == y && W / 2 == x)
        cout << 1;
    else
        cout << 0;
   
    return 0;
}


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

#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define fi first
#define se second
#define pb push_back
#define int long long

typedef pair<int, int> ii;
typedef pair<int, ii> iii;

const int N = 1e5 + 10;
const int oo = 1e18;

vector<string> ans;
int n;
int a[20];
bool visit[20];

void check()    {
    string cur = "";
    FOR(i, 1, n) cur += char(a[i] + 96);
    ans.pb(cur);
}
void btr(int pos, int cnt, int num)  {
    if(pos == n + 1) {
        if(cnt != num) return;
        check();
        return;
    }
    if(n - pos + 1 < cnt - num) return;
    FOR(i, 1, cnt)  {
        a[pos] = i;

        int tmp = 0;
        if(!visit[i]) {
            visit[i] = 1;
            btr(pos + 1, cnt, num + 1);
            visit[i] = 0;
            break;
        }
        else btr(pos + 1, cnt, num);
    }
}

signed main()  {
    //freopen("test.inp", "r", stdin);
    //freopen("test.out", "w", stdout);
    ios_base::sync_with_stdio(false); cout.tie(0);

    cin >> n;
    FOR(i, 1, n) btr(1, i, 0);
    sort(ans.begin(), ans.end());
    for(auto it: ans) cout << it << '\n';
}


Measured memory_bytes: 9716