akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
typedef long long ll;
using namespace std;

const ll MAXN = 200000;
const ll INF = 1001001001;

ll N, ans=0, tmp=0;

//abc097_D.cpp

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

signed main() {
    int N, M;
    cin >> N >> M;

    vector<ll> A(N);
    UnionFind tree(N);

    for(int i = 0; i < N; i++) {
        int  p;
        cin >> p;
        A[p-1] = i;
    }

    for(int i = 0; i < M; i++) {
        int  x, y;
        cin >> x >> y;
        tree.unite(x-1, y-1); // xの木とyの木を併合する
    }

    int cnt=0;
    for(int i=0;i<N;i++){
        if(tree.same(A[i],i)){
            cnt++;
        }
    }

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

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

int N;
int A;
int B;

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

    int diff=B-A;

    if (diff%2==1)
    {
        cout<<"Borys"<<endl;
    }

    else
    {
        cout<<"Alice"<<endl;
    }
}

Measured memory_bytes: 3624
use strict;
use warnings;
 
chomp(my $a = <>);
chomp(my $b = <>);
chomp(my $c = <>);
chomp(my $x = <>);
 
my $solve = 0;
 
for (my $i = 0; $i <= $a; $i++) {
	for (my $j = 0; $j <= $b; $j++) {
    	for (my $k = 0; $k <= $c; $k++) {
        	if (500*$i + 100*$j + 50*$k == $x){
            	$solve++;
                last;
            }
        }
    }
}
 
print $solve . "\n";

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

int main() {
    int t; cin >> t;
    while (t--) {
        int n, k; cin >> n >> k;
        vector<int> x(n);
        for (int i = 0; i < n; i++) cin >> x[i];
        vector<int> d(n - 1);
        for (int i = 0; i < n - 1; i++) d[i] = x[i + 1] - x[i];
        sort(d.begin(), d.end());
        int ans = 0;
        for (int i = 0; i < n - 1 - (k - 1); i++) ans += d[i];
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
#define INF 100000000
#define IINF 9999999999999;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

// 1

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

    int a, b, n, s, f;
    cin >> a >> b >> n;
    rep(i, n){
        cin >> s >> f;
        if(a < f && b > s){
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 3124
#include <stdio.h>
#include <algorithm>
using namespace std;

const int MAXN = 3005;

int a[MAXN];
long long dp[MAXN][MAXN];
bool used[MAXN][MAXN];
int n;

long long solve(int l, int r) {
    if (l > r) return 0;
    if (used[l][r]) return dp[l][r];

    long long& ans = dp[l][r];
    if ((r - l) % 2 ==  (n - 1) % 2) {
        ans = max(a[l] + solve(l + 1, r), a[r] + solve(l, r - 1));
    } else {
        ans = min(-a[l] + solve(l + 1, r), -a[r] + solve(l, r - 1));
    }
    used[l][r] = true;
    return ans;
}

int main(void) {
    scanf(" %d", &n);
    for (int i = 0; i < n; i++) {
        scanf(" %d", &a[i]);
    }
    long long ans = solve(0, n - 1);
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 78464
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> a(3),b(3);
  int c=0;
  cin>>a[0]>>a[1]>>a[2];
  if(a[0]%2==1||a[1]%2==1||a[2]%2==1){
    cout<<c;
    return 0;
  }
  sort(a.begin(),a.end());
  for(;;){
  b[0]=(a[0]+a[1])/2;
  b[1]=(a[0]+a[2])/2;
  b[2]=(a[1]+a[2])/2;
  if(a[0]==b[0]&&a[1]==b[1]&&a[2]==b[2]){
    cout<<-1;
    return 0;
  }
  c++;
  if(b[0]%2==1||b[1]%2==1||b[2]%2==1){
    cout<<c;
    return 0;
  }
  a[0]=b[0];
  a[1]=b[1];
  a[2]=b[2];
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	private static long[] input = new long[200010];
	
	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		int i , j , n = scan.nextInt();
		long sum = 0;
		for (i = 0;i < n;i ++) {
			input[i] = scan.nextLong();
			sum += input[i];
		}
		long sum1 = 0 , sum2 = 0 , ans = - 1;
		for (i = 0;i < n - 1;i ++) {
			sum1 += input[i];
			sum2 = sum - sum1;
			long temp = Math.abs(sum1 - sum2);
			if (temp < ans || ans < 0) {
				ans = temp;
			}
		}
		System.out.println(ans);
		
	}
	
}


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

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }

  ll money = 1000;
  ll stock = 0;
  for (int i = 0; i < N; i++) {
    // i日目の株価
    ll i_day_stock_price = A.at(i);

    // 最終日より前の日
    if (i < N - 1) {
      ll i_next_day_stock_price = A.at(i + 1);

      // 翌日、株価が上昇する場合は買う
      if (i_next_day_stock_price > i_day_stock_price) {
        ll add_stock = money / i_day_stock_price;
        ll reduce_money = add_stock * i_day_stock_price;
        stock = stock + add_stock;
        money = money - reduce_money;
      // 翌日、株価が下落する場合は売る
      // （下落してから買い直す）
      } else if (i_next_day_stock_price < i_day_stock_price) {
        money = money + (i_day_stock_price * stock);
        stock = 0;
      }
    }

    // 最終日は売る
    if (i == N - 1) {
      money = money + (i_day_stock_price * stock);
      stock = 0;
    }
  }

  cout << money << endl;
  return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
typedef long long ll;
 
int main() {
  ll s[3];
  rep(i,3) cin>>s[i];
  sort(s,s+3);
  cout<<s[2]*10+s[1]+s[0];
  return 0;
}

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

using namespace std;

void solve();

int main() {
#ifdef OFFLINE
	freopen("input.txt", "r", stdin);
#endif
	ios::sync_with_stdio(false);
	solve();
	return 0;
}

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

typedef long long llong;

const int N = 51;

int n, x;
int a[N];

llong d[N*N][N];

void solve() {
	cin >> n >> x;
	forn(i, n)
		cin >> a[i];
	
	d[0][0] = 1;
	forn(i, n) {
		for (int j=N*N-1-a[i]; j >= 0; j--)
			for (int k=0; k<n; k++)
				if (d[j][k])
					d[j+a[i]][k+1] += d[j][k];
	}

	llong res = 0;
	for (int k=1; k <= n; k++)
		res += d[k*x][k];

	cout << res << endl;
}

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

using namespace std;

#define MAX 100005
#define pb push_back

/*
    we need to find longest non decreasing sequence and at each step, we need to search for an element that is closest to the current element, 
    i.e. largest number statisfying a[i]<a[j] so that we have maximum options available for next number. 
*/

int main(){
  int n,a;
  cin>>n;
  multiset<int> ans;
  cin>>a;
  ans.insert(-a);
  for(int i=1;i<n;i++){
    cin>>a;
    a*=-1;
    auto itr=ans.lower_bound(a);
    if(itr!=ans.end()){
        if(*itr==a){
            int b=a+1;
            auto it=ans.lower_bound(b);
            if(it!=ans.end()){
                ans.erase(it);
            }
        }
        else{
            ans.erase(itr);
        }
    }
    ans.insert(a);
  }
  cout<<ans.size()<<endl;
	return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>

 
static const int MAX = 500;
static const int INFTY = (1<<21);
 
main(){
  int n, i, j, e, sum=0;
  int M[MAX][MAX];
  int d[MAX],p[MAX],v[MAX];
  int a,point=0;
  
   
   
 
  scanf("%d", &n);
   
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      scanf("%d", &e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }
 
  for(i = 0; i < n; i++){
    v[i] = 0;
    d[i] = INFTY;
    p[i] = -1;
  }
   
  d[0] = 0;
   
  while(1){
    a = -1;
    point = INFTY;
     
    for(i = 0; i < n; i++){
 
      if(d[i] < point && !v[i]){
      a = i;
      point = d[i];
      }
    }
     
    if(a == -1){
      break;
    }
     
    v[a] = 1;
   
    for(j = 0; j < n; j++){
      
      if(M[a][j] < d[j] && !v[j]){
    p[j] = a;
    d[j] = M[a][j];
      }
    }
  }
   
   
  //   sum = 0;
   
  for(i = 0; i < n; i++){
    if(p[i] != -1){
      sum += M[i][p[i]];
    }
  }
   
  printf("%d\n",sum);
   
  return 0;
}

Measured memory_bytes: 808
#include <stdio.h>

int main(){
  int n, a, cnt=0;
  scanf("%d", &n);

  for(int i=1; i<=n; i++){
    scanf("%d", &a);
    if(i%2 && a%2){ cnt++; }
  }
  printf("%d", cnt);
  return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <math.h>
#include <map>
#include <time.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

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


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

 
int main() {
  int A, B, C, K;
  int x, y, t;
  cin >> A >> B >> C >> K;
  t= 0;
  while(A >= B){
      B = B*2;
      t++;
    }
  while(B >= C){
    C = C*2;
    t++;
    }
    
    if( t <= K ){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
    
           
}


Measured memory_bytes: 3680
A = list(input())
n = len(A)

str_cnt = {}
for a in A:
    if a in str_cnt:
        str_cnt[a] += 1
    else:
        str_cnt[a] = 1
# print(str_cnt)
zen = n * (n - 1) // 2 + 1

for k in str_cnt:
    num = str_cnt[k]
    if num > 1:
        zen -= num * (num - 1) // 2
print(zen)


Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
int a[26];
int main()
{
    long long t,n,m,i,j,k,x=0,y=0,z;

    char s;
    cin>>s;
    n=s-'a';
    n=n+1;
    cout<<char(n+'a')<<endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
char a,b;
while((cin>>a>>b)&&a!=NULL)
{if(a=='D')
{if(b=='D')
printf("H\n");
else
printf("D\n");}
if(a=='H')
{if(b=='D')
printf("D\n");
else
printf("H\n");}}
return 0;
}


Measured memory_bytes: 888
S = input()
K = int(input())

num0 = 0
start = 0
end = len(S)
if S[0] == S[-1]:
    pre = S[0]
    for i, c in enumerate(S):
        if c != pre:
            start = i
            T = S[::-1]
            for j, d in enumerate(T):
                if d != pre:
                    end = len(S) - j
                    break
                num0 += 1
            break
        num0 += 1
    else:
        print(len(S) * K // 2)
        exit(0)

pre = ' '
num = 1
count = 0
for c in S[start: end]:
    if c == pre:
        num += 1
    else:
        count += num // 2
        pre = c
        num = 1
else:
    count += num // 2

ans = count * K + start // 2 + (num0 // 2) * (K - 1) + (len(S) - end) // 2
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return b;
    }
    return gcd(b, a % b);
}

struct Jewel {
    int value;
    int cost;
};
int main()
{
    ll N;
    cin >> N;

    vector<Jewel> jewels(N);
    for (ll i = 0; i < N; i++)
    {
        cin >> jewels[i].value;
    }
    for (ll i = 0; i < N; i++)
    {
        cin >> jewels[i].cost;
    }
    
    ll ans = 0;
    for (size_t i = 0; i < 1<<N; i++)
    {
        ll value = 0;
        ll cost = 0;
        for (ll j = 0; j < N; j++)
        {
            if (bitset<20>(i)[j]) {
                value += jewels[j].value;
                cost += jewels[j].cost;
            }
        }
        ans = max(ans, value - cost);
    }
    cout << ans << endl;
}

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

const int N = 1e5+200;
const int INF = 2e9;
const int mod = 1e9+7;

int ans, n, m, k;
int a[N], b[N];

struct fenwick {
  vector<int> F;
  int N;

  fenwick(int n) : N(n) {
    F.resize(N);
  }

  fenwick(vector<int> v) {
    N = v.size();
    F.resize(N);
    for (int i = 0; i < N; ++i) {
      this->add(i+1, v[i]);
    }
  }

  void add(int k, int v) {
    while (k <= N) {
      F[k] += v;
      k += k&-k;
    }
  }

  int operator[](int k) {
    int s = 0;
    while (k >= 1) {
      s += F[k];
      k -= k&-k;
    }
    return s;
  }
};

int main() {
  for (int i = 0; i < N; ++i) a[i] = true;
  a[0] = a[1] = false;
  for (int i = 2; i < N; ++i) {
    if (a[i] && i*1LL*i < N) for (int j = i*i; j < N; j+=i) {
      a[j] = false;
    }
  }
  for (int i = 0; i < N; ++i) {
    if (a[i] && a[(i+1)/2]) b[i] = true;
    else b[i] = false;
  }
  fenwick f(vector<int>(b, b+N));

  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int l, r;
    scanf("%d%d", &l, &r);
    printf("%d\n", f[r+1]-f[l]);
  }

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;
using ll = long long;

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

int dp[100005][3];

int main() {
  int n;
  cin >> n;
  int d[n][3];
  rep(i, n) rep(j, 3) cin >> d[i][j];

  for (int i = 0; i < n; ++i) {
    dp[i + 1][0] = max(dp[i][1], dp[i][2]) + d[i][0];
    dp[i + 1][1] = max(dp[i][2], dp[i][0]) + d[i][1];
    dp[i + 1][2] = max(dp[i][0], dp[i][1]) + d[i][2];
  }

  int ans = 0;
  rep(i, 3) ans = max(ans, dp[n][i]);
  cout << ans << endl;
  return 0;
}


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

int main() {
  // 入力
  int H, N;
  cin >> H >> N;
  vector<int> A;
  int A_tmp;
  for (int i=0; i<N; i++) {
    cin >> A_tmp;
    A.push_back(A_tmp);
  }

  int damage = 0;
  for (int i=0; i<N; i++) {
    damage = damage + A.at(i);
  }

  string result = "No";
  if (damage>=H) {
    result = "Yes";
  }

  // 出力
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <algorithm>
#include "math.h"
#include <set>
#include <time.h>
#include <deque>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <memory.h>


using namespace std;
typedef long long int ll;
#define debug(val) "[ " << #val " : " << (val) << " ]\n"
#define space " "
#define space " "
#define vi vector<int>
#define PI atan(1)*4
#define pb push_back
#define ff first
#define ss second
#define PI atan(1)*4
const int INF = (int)2e9 ;

void solve() {
	int n ;
	cin >> n ;
	int a=0, b=0, c=0 ;
	for(int i=0;i<n;i++){
		int aa, bb, cc; 
		cin >> aa >> bb >> cc ;
		vi t = {a,b,c};
		a = aa + max(t[1],t[2]) ;
		b = bb + max(t[2], t[0]) ; 
		c = cc + max(t[0] , t[1]) ;
	}
	cout << max(a, max(b,c)) << endl; 
	
}
int main() {
#ifdef _DEBUG // place in cmake-build-debug folder
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int q = 1;
    //cin >> q;
    for (int i = 1; i <= q; i++) {
        // cout << "Case #" << i << ": ";
        solve();
    }
}


Measured memory_bytes: 3616
#!/usr/bin/env python
# -*- coding:utf-8 -*-

N = int(input())
A = list(map(int, input().split()))

def digit(i):
    a=0
    while True:
        Flag = int(i%2)
        if Flag==1:
            break;
        i = i/2
        a=a+1
    return(a)

        
Total=0
for i in A:
        add = digit(i)
        Total=Total+add
print(Total)


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

char s[100], mod[10] = {'0', 'F', 'E', 'S', 'T', 'I', 'V', 'A', 'L'};

bool Cmp( int st )
{
	for(int i = 1; i <= 8; ++i)
		if(s[st + i - 1] != mod[i]) return 0;
	return 1;
}

int main()
{
	scanf( "%s", s + 1 );
	int n = strlen(s + 1);
	for(int i = n; i >= 1; --i)
	{
		if(Cmp(i))
		{
			for(int j = 1; j < i; ++j) 
				printf( "%c", s[j] );
			cout << endl;
			break;
		}
	}
	return 0;
}

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

#define INF 10000000000

using namespace std;

typedef long long ll;

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

    int mc = 0;
    ll res = 0;
    ll minabs = INF;
    for (int i=0; i<N; i++) {
        long long a;
        cin >> a;
        if (a <= 0) {
            mc += 1;
        }
        if (abs(a) < minabs) minabs = abs(a);
        res += abs(a);
    }


    if (mc % 2 == 0) {
        ;
    } else {
        res = res - 2*minabs; 
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

const int MAX = 5e4 + 5;
int main()
{
	boost;
	int a, b;
	cin >> a >> b;
	for(int i = 1; i < MAX; i++){
		double x = (double)(i * 8);
		double y = (double)(i * 10);
		x /= 100.0, y /= 100.0;
		int px = x, py = y;
		if(px == a && py == b){
			cout << i;
			return 0;
		}
	}
	cout << -1;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	const ll mod = 1e9 + 7;
	
	int n;
	cin >> n;
	
	vector<ll> v(n + 1);
	for(int i = 0; i < n; i++)
		cin >> v[i];
	
	ll ans = 0;
	
	vector<vector<ll>> ones(63, vector<ll>(n + 1)), zeros(63, vector<ll>(n + 1));
	
	for(ll j = 0; j < 63; j++){
		for(int i = 0; i < n; i++){
			if(v[i] & (1ll << j))
				ones[j][i]++;
			else
				zeros[j][i]++;
		}
		
		for(int i = n - 1; i >= 0; i--){
			ones[j][i] += ones[j][i + 1];
			zeros[j][i] += zeros[j][i + 1];
		}
		
		ll p = 1ll << j;
		p %= mod;
		
		for(int i = 0; i + 1 < n; i++){
			if(v[i] & (1ll << j)){
				ans += zeros[j][i + 1] * p % mod;
				ans %= mod;
			}
			else{
				ans += ones[j][i + 1] * p % mod;
				ans %= mod;
			}
		}
	}

	cout << ans << endl;
	return 0;
}


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

int main() {
	// your code goes here
	set<string> s;
	long long n,i,j,k;
	cin>>n;
	for(i=0;i<n;i++)
	{
	    string c;
	    cin>>c;
	    s.insert(c);
	}
	cout<<s.size()<<endl;
	return 0;
}


Measured memory_bytes: 19228
use std::io::*;
use std::str::FromStr;
use std::cmp::max;

fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

fn main() {
  let n = read::<usize>();
  let size = read::<usize>() + 1;
  let mut value = vec![];
  let mut weight = vec![];
  let mut dp: Vec<Vec<i64>> = vec![];

  for _ in 0..n {
    value.push(read::<i64>());
    weight.push(read::<usize>());
  }
  let mut row = vec![];
  for _ in 0..size {
    row.push(0);
  }
  dp.push(row);

  for i in 0..n {
    let mut row = vec![];
    for _ in 0..size {
      row.push(0);
    }
    dp.push(row);
    for j in 0..size {
      let w = weight[i];
      let v = value[i];
      dp[i + 1][j] = if j >= w {
        max(dp[i][j - w] + v, dp[i][j])
      } else {
        dp[i][j]
      };
    }
  }

  println!("{:?}", dp[n][size - 1]);
}



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

int N;
double dp[310][310][310];

double rec(int c1, int c2, int c3){
    if(dp[c1][c2][c3] >= 0) return dp[c1][c2][c3];
    if(c1 == 0 && c2 == 0 && c3 == 0) return 0.0;
    double res = 0.0;
    if(c1>0)res+=rec(c1-1,c2,c3)*c1;
	if(c2>0)res+=rec(c1+1,c2-1,c3)*c2;
	if(c3>0)res+=rec(c1,c2+1,c3-1)*c3;
    res += N;
    res *= 1.0/(c1+c2+c3);
    return dp[c1][c2][c3] = res;
}

int main(){
    cin >> N;
    int c[3] = {0};
    rep(i,N){
        int a;
        cin >> a;
        c[a-1]++;
    }
    memset(dp, -1, sizeof(dp));
    printf("%.12lf\n",rec(c[0],c[1],c[2]));
    return 0;
}

Measured memory_bytes: 233088
#include <iostream>

using namespace std;

int main(){
    int n;
    int a[101];
    
    cin >> n;
    for(int i=0;i<n;++i) cin >> a[i];
    
    for(int k=0;k<n-1;k++) cout << a[k] << " ";
    cout << a[n-1] << endl;
    
    for(int i=1;i<n;++i){
    int v = a[i];
    int j = i -1;
    
    while(j>=0&&a[j]>v){
        a[j+1]=a[j];
        j--;
    }
    a[j+1]=v;
    
    for(int k=0;k<n-1;k++) cout << a[k] << " ";
    cout << a[n-1] << endl;
    }
}


Measured memory_bytes: 3084
from typing import List


def count_loadable_baggage_num(baggage_num: int, truck_num: int, baggages: List[int], truck_capacity: int) -> int:
    loaded_baggage_num: int = 0

    for _ in range(truck_num):
        current_weight: int = 0
        while current_weight + baggages[loaded_baggage_num] <= truck_capacity:
            current_weight += baggages[loaded_baggage_num]
            loaded_baggage_num += 1
            if loaded_baggage_num == baggage_num:
                return baggage_num

    return loaded_baggage_num


def calc_turck_min_capacity(baggage_num: int, truck_num: int, baggages: List[int]) -> int:
    ng: int = max(baggages) - 1
    ok: int = sum(baggages) + 1

    while ok - ng > 1:
        mid = (ng + ok) // 2
        loadable_baggage_num = count_loadable_baggage_num(baggage_num, truck_num, baggages, mid)
        if loadable_baggage_num >= baggage_num:
            ok = mid
        else:
            ng = mid

    return ok


def main():
    n, k = map(int, input().split())
    w: List[int] = []

    for _ in range(n):
        w.append(int(input()))

    P = calc_turck_min_capacity(n, k, w)
    print(P)


if __name__ == "__main__":
    main()



Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int slideX,slideY;
    slideX = 0 - x1;
    slideY = 0 - y1;
    x1 = 0;
    y1 = 0;
    x2 += slideX;
    y2 += slideY;
    //cout << x2 << " " << y2 << endl;
    int x3,y3;
    x3 = x2 - y2;
    y3 = y2 + x2;
    //cout << x3 << " " << y3 << endl;
    int x4,y4;
    x4 = 0 - y2;
    y4 = 0 + x2;
    cout << x3-slideX << " ";
    cout << y3-slideY << " ";
    cout << x4-slideX << " ";
    cout << y4-slideY << endl;
    return 0;
}

Measured memory_bytes: 3588
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N >> K;
	M = pow(100, N);
	if (K == 100)K++;
	cout << K * M << endl;
	return 0;
}


Measured memory_bytes: 256
from collections import deque

n=int(input())
E=[[]for _ in range(n)]
L=[]
for i in range(n-1):
   a,b=map(int,input().split())
   E[a-1].append(b-1)
   L.append(b-1)

que=deque([0])
ans=[0]*n
while que:
   s=que.pop()
   color=1
   for ni in E[s]:
      if color==ans[s]:
         color+=1
      ans[ni]=color
      color+=1
      que.append(ni)
print(max(ans))
for i in L:
   print(ans[i])

Measured memory_bytes: 68256
#include <stdio.h>
int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a<b && a<c){
        if(b<c){
           printf("%d %d %d\n",a,b,c);
        } else {
           printf("%d %d %d\n",a,c,b);
        }
    } else if(b<a && b<c){
        if(a<c){
           printf("%d %d %d\n",b,a,c);
        } else {
           printf("%d %d %d\n",b,c,a);
        }
    } else {
        if(a<b){
           printf("%d %d %d\n",c,a,b);
        } else {
           printf("%d %d %d\n",c,b,a);
        }
    }
    return 0;
}



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

int main() {
  string S, T;
  cin >> S >> T;

  bool ans = false;
    
  for (int i = 0; i < S.size(); i++) {
    char ch = S[S.size() - 1];
    S.pop_back();
    S = ch + S;
    if (S == T) {
      ans = true;
      break;
    }
  }

  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try {
            int q = Integer.parseInt(sc.nextLine());
            int MIN_LENGTH = 1;
            int MAX_LENGTH = 1000;
            while (sc.hasNext()) {
                String x = sc.nextLine();
                String y = sc.nextLine();
                if (x.length() < MIN_LENGTH || x.length() > MAX_LENGTH
                    || y.length() < MIN_LENGTH || y.length() > MAX_LENGTH) {
                    System.out.println("Conditions is invalid.");
                    return;
                }
                System.out.println(getLCS(x, y));
            }
        } catch (NoSuchElementException
                | NumberFormatException e) {
            System.out.println(e);
        }
    }

    private static int getLCS(String x, String y) {
//        if (x.isEmpty() || y.isEmpty()) {
//            return 0;
//        }
//        if (x.equals(y)) {
//            return x.length();
//        }
//        if (x.contains(y)) {
//            return y.length();
//        }
        char[] xs = x.toCharArray();
        char[] ys = y.toCharArray();
        int m = x.length();
        int n = y.length();
        int[][] c = new int[m + 1][n + 1];
        for (int i = 1; i <= m; i++) {
            c[i][0] = 0;
        }
        for (int i = 1; i <= n; i++) {
            c[0][i] = 0;
        }

        int maxl = 0;
        for (int i = 1; i <= m; i++) {
            for (int j = 1; j <= n; j++) {
                if (xs[i - 1] == ys[j - 1]) {
                    c[i][j] = c[i - 1][j - 1] + 1;
                } else {
                    c[i][j] = Integer.max(c[i - 1][j], c[i][j - 1]);
                }
                maxl = Integer.max(maxl, c[i][j]);
            }
        }
        return maxl;
    }
}



Measured memory_bytes: 63988
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int, int> ii;
typedef pair<int, bool> ib;

#define FOR(a, b, c) for(int a = b; a < c; ++a)
#define RFOR(a, b, c) for(int a = b; a >= c; --a)
#define mp(a, b) make_pair(a, b)
#define all(v) v.begin(), v.end()

#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define vvi vector<vi>
#define vb vector<bool>
#define fst first
#define snd second
#define MAXN 310
#define MAXM 44100
#define LOGMAXN 20
#define INF 1e9+7
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define MOD 1000000007LL

int n, m, l;
ii dist[MAXN];

void Dijkstra(int src, vii* adj)
{
	FOR(i, 0, n)
	{
		dist[i] = {INF, INF};
	}
	priority_queue<pair<ii, int>> pq;
	vector<bool> seen(n, false);
	dist[src] = {0, l};
	pq.push(mp(mp(-0, l), src));
	while(pq.size())
	{
		int cur = pq.top().snd;
		pq.pop();
		if(seen[cur]) continue;
		seen[cur] = true;
		for(ii& p : adj[cur])
		{
			int u = p.fst;
			int w = p.snd;
			int newdist = dist[cur].fst + (dist[cur].snd < w);
			int newl = dist[cur].snd < w ? l - w : dist[cur].snd - w;
			if(dist[u].fst > newdist || (dist[u].fst == newdist && dist[u].snd < newl))
			{
				dist[u].fst = newdist;
				dist[u].snd = newl;
				pq.push(mp(mp(-dist[u].fst, dist[u].snd), u));
			}
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	while(cin >> n >> m >> l)
	{
		vii adj[n];
		FOR(i, 0, m)
		{
			int a, b, c;
			cin >> a >> b >> c;
			a--, b--;
			if(c > l) continue;
			adj[a].emplace_back(mp(b, c));
			adj[b].emplace_back(mp(a, c));
		}
		int qn;
		cin >> qn;
		vector<pair<ii, int>> q(qn);
		FOR(i, 0, qn)
		{
			q[i].snd = i;
			cin >> q[i].fst.fst >> q[i].fst.snd;
			q[i].fst.fst--, q[i].fst.snd--;
		}
		sort(q.begin(), q.end());
		vi ans(qn);
		int pos = 0;
		FOR(i, 0, n)
		{
			if(q[pos].fst.fst == i)
			{
				Dijkstra(i, adj);
				while(pos < qn && q[pos].fst.fst == i)
				{
					ans[q[pos].snd] = dist[q[pos].fst.snd].fst;
					pos++;
				}
			}
		}
		FOR(i, 0, qn)
		{
			printf("%d\n", ans[i] == INF ? -1 : ans[i]);
		}
	}
	return 0;
}


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

void Main()
{
    int64_t X;
    cin >> X;

/*    for(int64_t i = 0; i < 64; ++i)
    {
        float a = pow(X + pow(i , 5.0f), 1.0f / 5.0f);
        if(ceil(a) == floor(a))
        {
            cout << a << " " << i << endl;
            return;
        }
        a = pow(X + pow(-i , 5.0f), 1.0f / 5.0f);
        if(ceil(a) == floor(a))
        {
            cout << a << " " << -i << endl;
            return;
        }
    }*/

    for(int64_t i = 0; i < 129; ++i)
    {
        for(int64_t j = 0; j < 129; ++j)
        {
            int64_t temp = pow(i, 5) - pow(j, 5);
            if(temp == X)
            {
                cout << i << " " << j << endl;
                return;
            }
            temp = pow(-i, 5) - pow(j, 5);
            if(temp == X)
            {
                cout << -i << " " << j << endl;
                return;
            }
            temp = pow(i, 5) - pow(-j, 5);
            if(temp == X)
            {
                cout << i << " " << -j << endl;
                return;
            }
            temp = pow(-i, 5) - pow(-j, 5);
            if(temp == X)
            {
                cout << -i << " " << -j << endl;
                return;
            }
        }
    }
}

int main()
{
    Main();
}


Measured memory_bytes: 4068
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;

int SURP = 1000000007;

int main(){
	int N;
	cin >> N;
	int a[N];
	FOR(i,0,N) cin >> a[i];

	sort(a,a+N);
	int target = a[N-1];
	int dif = a[N-1]*2;
	int index = -1;
	FOR(i,0,N-1){
		if(abs(a[i]*2 - target) < dif){
			index = i;
			dif = abs(a[i]*2 - target);
		}
	}
	cout << a[N-1] << " " << a[index] << endl;

	return 0;


}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S;
    cin >> S;
    while(S != "#"){
        reverse(S.begin(),S.end());
        ll deg = 0;
        int num = 0;
        for(int i=0; i<S.size(); num++){
            if(S.substr(i,5) == "htron"){
                deg *= 2;
                if(i != 0) deg--;
                i += 5;
            }else{
                deg *= 2;
                deg++;
                i += 4;
            }
        }
        deg *= 90;
        ll all = 1LL<<(num-1);
        while(deg%2==0 and all%2==0){
            deg /= 2;
            all /= 2;
        }
        if(all != 1){
            cout << deg << "/" << all << enld;
        }else{
            cout << deg << enld;
        }
        cin >> S;
    }
    return 0;
}


Measured memory_bytes: 3192
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))

def main():
    a, b = readInts()
    print(int((b - a) * (b - a + 1)//2 - b))
if __name__ == '__main__':
  main()


Measured memory_bytes: 5148
Public Class Program
  Shared Sub Main()
    Dim n As Integer = Integer.Parse(Console.ReadLine())
    Dim a() As Integer = Array.ConvertAll(Of String, Integer)(Console.ReadLine().Split(" "), AddressOf Integer.Parse)
    Dim output As Integer = a(0)
    For i As Integer = 1 To n - 1
      output = Gcd(output, a(i))
    Next
    Console.WriteLine(output.ToString())
  End Sub
  
  Shared Function Gcd(x As Long, y As Long) As Long
    Return If(x < y, Gcd(y, x), If(y > 0, Gcd(y, x Mod y), x))
  End Function
End Class

Measured memory_bytes: 20576
#include <stdio.h>
#include <unistd.h>


const int mod = 1000000007;

char s[100001];

int dp[2][13];

int main(){
  int i, k, r, b, d, l, t, sum, nsum;
 
  for(t=0;(k=read(STDIN_FILENO, s+t, sizeof(s)-t)) > 0;t+=k);

  for(l = 0; s[l] >= '0'; l++) ;

  r = 5;
  dp[0][0] = 1;
  b = 0;
  d = 1;
  sum = 1;
  for(i = l - 1; i >= 0; i--, d = d * 10 % 13){
    if(s[i] != '?'){
      r -= (s[i] - '0') * d;
      continue;
    }
    nsum = 0;
    for(k = 0; k < 13; k++){
      int a = k + d;
      if(a >= 13) a -= 13;
      dp[b^1][k] = sum;
      dp[b^1][k] -= dp[b][a];
      if(dp[b^1][k] < 0) dp[b^1][k] += mod;
      a += d;
      if(a >= 13) a -= 13;
      dp[b^1][k] -= dp[b][a];
      if(dp[b^1][k] < 0) dp[b^1][k] += mod;
      a += d;
      if(a >= 13) a -= 13;
      dp[b^1][k] -= dp[b][a];
      if(dp[b^1][k] < 0) dp[b^1][k] += mod;
      nsum += dp[b^1][k];
      if(nsum >= mod) nsum -= mod;
    }
    sum = nsum;
    b ^= 1;
  }

  r %= 13;
  if(r < 0) r += 13;

  printf("%d\n", dp[b][r]);
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front

using ll = long long;
using namespace std;

ll M = 1000000007;

int main()
{
    ll a,b,k;
    cin>>a>>b>>k;
    ll t=a,ao=b;
    t=max((ll)0,a-k);
    ll rest=max(k-a,(ll)0);
    ao=max((ll)0,b-rest);
    cout<<t<<" "<<ao<<endl;


}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(void) {
	ll n,k;
	cin>>n>>k;
	ll ans = 0;
	if(k==1){
		ans = n*n*n;
		cout << ans << endl;
		return 0;
	}
	rep(i,1,n+1){
		ll a = i;
		ll b = a%k;
		if(b==0)b+=k;
		if((b+b)%k==0){
			ll c = (max(0LL,n-b))/k+1;
			ans += c*c;
		}
	}
	cout << ans << endl;
	return 0;
}

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

mod=10**9+7

J=pow(2,n)%mod
def find_power(n,mod):
    # 0!からn!までのびっくりを出してくれる関数(ただし、modで割った値に対してである）
    powlist=[0]*(n+1)
    powlist[0]=1
    powlist[1]=1
    for i in range(2,n+1):
        powlist[i]=powlist[i-1]*i%(mod)
    return powlist

def find_inv_power(n):
    #0!からn!までの逆元を素数10**9+7で割ったあまりリストを作る関数
    powlist=find_power(n,10**9+7)
    check=powlist[-1]
    first=1
    uselist=[0]*(n+1)
    secondlist=[0]*30
    secondlist[0]=check
    secondlist[1]=check**2
    for i in range(28):
        secondlist[i+2]=(secondlist[i+1]**2)%(10**9+7)
    a=format(10**9+5,"b")
    for j in range(30):
        if a[29-j]=="1":
            first=(first*secondlist[j])%(10**9+7)
    uselist[n]=first
    for i in range(n,0,-1):
        uselist[i-1]=(uselist[i]*i)%(10**9+7)
    return uselist

C=find_inv_power(2*10**5+100)
if  True:
    c=1
    for i in range(a):
        c*=(n-i)
        c=c%mod
    c=c*C[a]
    c=c%mod
    d=1
    for i in range(b):
        d*=(n-i)
        d=d%mod
    d=d%mod
    d=d*C[b]
    print((J-c-d-1)%mod)

Measured memory_bytes: 158620
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    g = [[-1]*N for _ in range(N)]

    for i in range(N):
        A = int(input())
        
        for a in range(A):
            x, y = map(int, input().split())
            g[i][x-1] = y
    
    ans = 0
    for i in range(2**N):
        d = [0]*N
        for j in range(N):
            if i>>j & 1:
                d[j] = 1
        ok = True
        for j in range(N):
            if d[j] == 1:
                for k in range(N):
                    if g[j][k] == -1:
                       continue 
                    if g[j][k] != d[k]:
                        ok = False
        if ok:
            ans = max(ans, bin(i).count('1'))
    
    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 43116
import math
a, b, x = map(int, input().split())

if a**2*b < 2*x:
    hight = (a ** 2 * b - x)/((a**2/2))
    bottom = a

else:
    hight = b

    area = a * hight

    bottom = 2 * x / area

print(math.degrees(math.atan2(hight, bottom)))


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  while(cin >> n && n){
    ll m = inf,M = 0;
    rep(i,n){
      ll s = 0,a;
      rep(j,5){
        cin >> a;
        s += a;
      }
      m = min(s,m);
      M = max(s,M);
    }
    cout << M << ' ' << m << endl;
  }
  return 0;
}

Measured memory_bytes: 3188
/*-----rk_98-----*/
#include<bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define mod 1000000007
#define eps 1e-9
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
using namespace std;
const ll nax =3005;
ll dp[nax][nax] , pref[nax];
int main()
{
    //fast();
    ll n;
    cin>>n;
    string s;
    cin>>s;
    dp[1][1] = 1;
    for(ll i = 2 ; i <= n ; i++ )
    {
    	for(ll j = 1 ; j < i ; j++)
    	{
    		pref[j] = (pref[j-1] + dp[i-1][j]) % mod;
    	}
    	for(ll j = 1 ; j <= i ; j++)
    	{
    		ll L, R;
    		if(s[i - 2] == '<' )
    		{
    			L = 1;
    			R = j - 1;
    		}
    		else
    		{
    			L = j;
    			R = i - 1; 
    		}
    		dp[i][j] = (pref[R] - pref[L-1] + mod) % mod;
    	}
    }
   	ll ans = 0;
   	for(ll i = 1 ; i <= n ; i++)
	{
		ans+=dp[n][i];
		ans %= mod;
	}
   	cout<<ans<<endl;
}


Measured memory_bytes: 69120
import java.util.Scanner;

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

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int H = scanner.nextInt();
        int A = scanner.nextInt();

        int num = 0;
        for(int i =0; i < 100001; i++) {
            num++;
            H -= A;
            if(H <= 0) break;
        }

        System.out.println(num);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
int A;
  int B;
  int C;
  cin >>A>>B>>C;
  if(A==B) {
cout <<C<< endl;
  }
  else if(A==C) {
cout <<B<< endl;
  }
  else if(C==B) {
cout <<A<< endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
constexpr long INF = 1LL << 60;
constexpr int MOD = 1e9 + 7;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n; cin >> n;
    vector<double> v(n);REP(i,n) cin >> v[i];
    sort(v.begin(),v.end());
    double ans = v[0];
    for(int i=1;i < n; ++i) 
        ans = (ans + v[i]) / 2.0;
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// Problem : D - Xor Sum
// Contest : AtCoder Beginner Contest 050
// URL : https://atcoder.jp/contests/abc050/tasks/arc066_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#define DEBUG(...) cerr << #__VA_ARGS__ << ": ", debug(__VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename T, size_t N> ostream& operator << (ostream &os, const array<T, N> &a) {os << "("; for (int i=0; i<(int)N; i++) {if (i) os << ", "; os << a[i];} return os << ")";}
template<typename T> ostream& operator << (ostream &os, const vector<T> &v) {os << "["; for (int i=0; i<(int)v.size(); i++) {if (i) os << ", "; os << v[i];} return os << "]";}
void debug() {cerr << "\n";} template<typename T, typename... Args> void debug(T x, Args... args) {cerr << x << "; "; debug(args...);}

#define MOD 1000000007

long long n;

// dp[i][j][k] - ith position, are we greater than n, are we carrying
int dp[60][2][2];

int solve(int i, int over, int carry) {
    if (i == 60)
        return over == 0 && carry == 0;
    if (dp[i][over][carry] != -1)
        return dp[i][over][carry];
    
    dp[i][over][carry] = 0;
    int j = (n & (1LL << i)) > 0;
    for (int a=0; a<2; a++)
        for (int b=0; b<=a; b++) {
            int bit = (a + b + carry) % 2, nover = over, ncarry = (a + b + carry > 1);
            if (bit < j)
                nover = 0;
            if (bit > j)
                nover = 1;
            dp[i][over][carry] = (dp[i][over][carry] + solve(i + 1, nover, ncarry)) % MOD;
        }
    
    return dp[i][over][carry];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    cin >> n;
    
    memset(dp, -1, sizeof(dp));
    cout << solve(0, 0, 0) << "\n";

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstring>
using namespace std;
char joi[4]="JOI",ioi[4]="IOI";
int main(){
    while(1){
        char a[10000];
        if(!(cin>>a))break;
        int jcnt,icnt;
        jcnt=icnt=0;
        for(int i=0;i<strlen(a)-2;i++){
            if(!strncmp(a+i,joi,3))jcnt++;
            else if(!strncmp(a+i,ioi,3))icnt++;
        }
        cout<<jcnt<<endl<<icnt<<endl;

    }
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> V(N), C(N);
  
  for(int i = 0; i < N; i++){
    cin >> V.at(i);
  }
  
  int ans = 0;
  for(int i = 0; i < N; i++){
    cin >> C.at(i);
    int tmp = V.at(i) - C.at(i);
    ans += (tmp > 0) ? tmp : 0;
  }
  
  cout << ans << endl;


}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int N;
	string S;
	cin >> N >> S;
	if (S.substr(0,N / 2) == S.substr((N / 2), (N/2))&&N%2==0){
		

		cout << "Yes" << endl;
	}else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256