akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var abk = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
        var a = abk[0];
        var b = abk[1];
        var k = abk[2];

        Console.WriteLine($"{Math.Max(0, a - k)} {Math.Max(0, b - (k - Math.Min(k, a)))}");
    }
}


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

int main(){
  int n;
  cin >> n;
  vector<string> w(n);
  for(int i=0;i<n;i++){
    cin >> w.at(i);
  }
  bool frag=true;
  int x=0;
  for(int i=0;i<n-1;i++){
    if(w.at(i).at(w.at(i).size()-1)!=w.at(i+1).at(0)){
      frag=false;
    }
  }
  sort(w.begin(),w.end());
  for(int i=0;i<n-1;i++){
    if(w.at(i)==w.at(i+1)){
      x++;
    }
  }
  if(frag==false||x!=0){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

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

    x = ceil((a+b) / (double)2.0);

    cout << x << endl;
}

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

int main () {
    int N, Y; cin >> N >> Y;
    int x = -1, y = -1, z = -1, tmp, total;
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= N; j++) {
            tmp = N - i - j;
            if (tmp < 0) continue;
            total = i*10000 + j*5000 + tmp*1000;
            if (total == Y) {
                x = i;
                y = j;
                z = tmp;
            }
        }
    }
    printf("%d %d %d\n", x, y, z);
    return 0;
}

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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

bool is_sq(const int x) {
    int low = sqrt(x);
    while(low * low <= x) {
        if((low + 1) * (low + 1) <= x) low++;
        else break;
    }

    return (low * low) == x;
}

int sq_d(const vi &x, const vi &y) {
    int res = 0;
    REP(i, x.size()) {
        res += (x[i] - y[i]) * (x[i] - y[i]);
    }
    return res;
}

int main() {
    int n, d;
    cin >> n >> d;

    cout << (n + 2 * d) / (2 * d + 1) << "\n";

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try(Scanner sc = new Scanner(System.in)) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(a != 1 && b != 1) {
				System.out.println(1);
			} else if(a != 2 && b != 2) {
				System.out.println(2);
			} else if(a != 3 && b != 3) {
				System.out.println(3);
			}
		}

	}

}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define FOR(i, n) for(ll i = 0; i < n; i++)
#define FORR(i, n) for(ll i = n; i >= 0; i--)
#define FORS(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) accumulate(v.begin(),v.end(),0)
#define SORT(v) sort(v.begin(),v.end())
#define OUT(n) (cout << n << endl)
#define IN1(a) (cin >> a)
#define IN2(a,b) (cin >> a >> b)
#define IN3(a,b,c) (cin >> a >> b >> c)
#define IN4(a,b,c,d) (cin >> a >> b >> c >> d)
#define REVS(v) reverse(v.begin(),v.end())
#define PI 3.14159265359
using namespace std;
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  double a,b,h,m,ans,angle;
  IN4(a,b,h,m);
  angle = min(360-abs(((h * 30)+(30/(60/m))) - (m * 6)),abs(((h * 30)+(30/(60/m))) - ((m * 6))));
  ans = sqrt(pow(a,2)+pow(b,2)-(2*a*b*cos(angle/180*PI)));
  cout << fixed << setprecision(15);
  OUT(ans);

}


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

using namespace std;

int main()
{
    vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k; cin >> k;
    cout << v[k - 1];
    return 0;
}


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

int main() {				
  char c;					// *constarint*
  cin >> c;					// 1 <= |S| <= 100
  							
  string vowel = "aiueo";
  // ここにプログラムを追記
  int i = 0;
  bool isVowel = false; 
  while(i < vowel.size()){
    if(vowel.at(i) == c){
      isVowel = true; 
    }
    i ++;
  }
  
  if(isVowel){
    cout << "vowel" << endl;
  }else{
  	cout << "consonant" << endl;
  }
  
}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long int;

const int mod = 1E+09 + 7;

template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

using modint = ModInt< mod >;
const int N_MAX = 300005;
const int E_MAX = 60;
int n;
ll A[N_MAX];
int C[E_MAX];

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }
    modint ans(0);
    for(int i = 0; i < E_MAX; i++){
        ll k = (ll)1 << i;
        C[i] = 0;
        for(int j = 0; j < n; j++){
            if (A[j] & k)C[i]++;
        }

        ll count = (ll)C[i] * (n - C[i]);
        ans += modint(k) * modint(count);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define lld long long
#define pb push_back
#define mk make_pair
#define MAX (lld)1e18+7
#define lim (lld)1e9+7
#define MAX2 (lld)2e5+9
#define ff first
#define ss second
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

const lld mod=lim;

lld power(lld x, lld y, lld p)  
{   lld res = 1;     x = x % p; if (x == 0) return 0;  
  
    while (y > 0)  
    { if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;   }  
    return res;  } 


lld extend_gcd(lld a, lld b, lld& x, lld& y) {
    if (b == 0) { x = 1;y = 0;return a;}
    lld x1, y1;
    lld d = extend_gcd(b, a % b, x1, y1);
    x = y1; y = x1 - y1 * (a / b);return d;	}

lld rowNum[]={-1,0,0,1};
lld colNum[]={0,-1,1,0};

vector<int>v[MAX2];
std::vector<int> vis(MAX2);
int ans=0;
void dfs(int i)
{
	vis[i]=1;

	for(auto x:v[i])
	{
		if(!vis[x])
		{
			ans++;
			dfs(x);
		}
	}
}
int main()
{
	fastio
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;

		v[x].pb(y);
		v[y].pb(x);
	}

	int res=0;
	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
		{
			ans=1;
			dfs(i);
			res=max(res,ans);
		}
	}

	cout<<res<<endl;
}

Measured memory_bytes: 21060
using System.IO;
using System;

class Program
{
    static void Main()
    {
        long src_sec = long.Parse(Console.ReadLine());
        int hour = (int)(src_sec/60/60);
        int min = (int)(src_sec/60%60);
        int sec = (int)(src_sec%60);

        Console.WriteLine("{0}:{1}:{2}", hour, min, sec);
    }
}

Measured memory_bytes: 9104
#include <atcoder/all>
#include <bits/stdc++.h>

using namespace atcoder;
using namespace std;

int mx(int a, int b) {
	return max(a, b);
}
int e() {
	return 0;
}

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

	const int N = 300005;

	auto st = segtree<int, mx, e>(N);

	while(n--) {
		int x;
		scanf("%d", &x);
		int me = st.prod(max(0, x - k), min(N, x + k + 1));
		st.set(x, me + 1);
	}

	printf("%d\n", st.prod(0, N));
}



Measured memory_bytes: 8600
// unihernandez22
// https://atcoder.jp/contests/abc157/tasks/abc157_b
// implementation

import std.stdio: writeln, writefln, readln;
import std.array: array, split;
import std.algorithm: map;
import std.string: chomp;
import std.conv: to;

void main() {
	int[3][3] bingo;
	foreach(byte i; 0..3) {
		int[3] input = readln.split.map!(to!int).array;
		bingo[i] = input;
	}
	int n = readln.chomp.to!int;
	bool[int] won;
	foreach(_; 0..n) {
		int x = readln.chomp.to!int;
		won[x] = true;
	}

	// Check rows
	foreach(int[3] i; bingo) {
		if (won.get(i[0], false) && won.get(i[1], false) && won.get(i[2], false)) {
			writeln("Yes");
			return;
		}
	}

	// Check columns
	foreach(byte i; 0..3) {
		if (won.get(bingo[0][i], false) && won.get(bingo[1][i], false) && won.get(bingo[2][i], false)) {
			writeln("Yes");
			return;
		}
	}

	// Check a diagonal
	bool diagonal_a = true;
	foreach(byte i; 0..3)
		diagonal_a = diagonal_a && won.get(bingo[i][i], false);

	// The other diagonal
	bool diagonal_b = true;
	foreach(byte i; 0..3)
		diagonal_b = diagonal_b && won.get(bingo[i][2-i], false);

	if (diagonal_a || diagonal_b)
		writeln("Yes");
	else
		writeln("No");
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	char s[1000006];
	scanf("%s", s);
	int i, n = strlen(s);
	long long int ans = 0;
	long long int a[1000006];
	for (i = 0; i < n; i++)
		a[i] = (long long int)(s[i] - '0');
	for (i = n - 1; i > 0; i--)
	{
		if (a[i] > 9)
		{
			a[i - 1]++;
			a[i] %= 10;
		}
		if (a[i] > 5)
		{
			a[i - 1]++;
			ans += 10 - a[i];
		}
		else if (a[i] == 5 && a[i - 1] >= 5)
		{
			a[i - 1]++;
			ans += 5;
		}
		else
			ans += a[i];
	}
	while (a[0] > 0)
	{
		if (a[0] % 10 > 5)
		{
			ans += 10 - a[0] % 10;
			a[0] = a[0] / 10 + 1;
		}
		else if (a[0] == 5 && a[0] / 10 % 10 >= 5)
		{
			ans += 5;
			a[0] = a[0] / 10 + 1;
		}
		else
		{
			ans += a[0] % 10;
			a[0] /= 10;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 8960
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define BUF 8

int main(void) {
  char str[BUF];
  scanf("%s", str);

  if (str[2] == str[3] && str[4] == str[5]) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

template<typename T>
vector<T> Divisor(T x) {
    vector<T> res;
    for(T i = 1; i*i<=x; ++i) {
        if(x%i == 0) {
            res.emplace_back(i);
            if(i*i != x) res.emplace_back(x/i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    ll ans = LLONG_MAX;
    vector<ll> d = Divisor(n);
    int l = d.size();
    REP(i,l) {
        ll a = d[i], b = n/d[i]; --a, --b;
        chmin(ans, a+b);
    }
    cout << ans << endl;
    return 0;
}

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

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    
    if (S.equals("Sunny")) {
      System.out.println("Cloudy");
    } else if (S.equals("Cloudy")) {
      System.out.println("Rainy");
    } else {
      System.out.println("Sunny");
    }
  }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define MAX 3100
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> new_data_set; 

ll a[MAX];
pii dp[MAX][MAX];
pii f(ll start,ll end,ll n,ll chance){
	if(start>end) return mp(0,0);
	if(dp[start][end].fi!=-1) return dp[start][end];

	pii first = f(start+1,end,n,!chance);
	pii second = f(start,end-1,n,!chance);
	if(chance){
		first.fi+=a[start];
		second.fi+=a[end];
		if(first.fi-first.se>second.fi-second.se) dp[start][end]=first;
		else dp[start][end]=second;
	}else{
		first.se+=a[start];
		second.se+=a[end];
		if(first.fi-first.se>second.fi-second.se) dp[start][end]= second;
		else dp[start][end]= first;
	}
	return dp[start][end];
}

int main(){
	ios_base::sync_with_stdio(false);
	For(i,0,MAX) For(j,0,MAX){
		pii temp(-1,-1);
		dp[i][j]=temp;
	}
	ll n;cin>>n;
	For(i,0,n) cin>>a[i];
	pii ans = f(0,n-1,n,1);
	cout<<ans.fi-ans.se<<endl;
}


Measured memory_bytes: 150784
MOD = 1000000007
n, k = map(int, input().split())

n_li = list(range(n+1))

ans = 0

while(k <= n+1):
    p = (k - 1) * k / 2
    q = ((n + n - k + 1) * k) / 2

    ans += q - p + 1
    ans %= MOD
    k += 1

print(int(ans))


Measured memory_bytes: 16792
def insertionSort(A, n, g):
    cnti = 0
    for i in range(g, n):
        v = A[i]
        j = i-g
        while (j >= 0 and A[j] > v):
            A[j + g] = A[j]
            j -= g
            cnti += 1
        A[j+g] = v
    return cnti
def shellSort(A,n):
    cnt = 0
    G = [1]
    h = 1
    for k in range(int(n**0.33333333)+1):
        h = 3*h + 1  ## h=1,4,13,40,121,364 ... 왜 이게 효율이 좋은지는 모르겠음(다른 사이트 봄)
        if (h <= n and len(G) < 100):
            G.append(h)
        elif(len(G) == 100):
            break    
    G.reverse()
    m = len(G)
    for i in range(m):
        cnt += insertionSort(A, n, G[i])
    print(m)
    for i in range(m):
        if (i == m-1):
            print('{}'.format(G[i]), end = '')
        else:
            print('{}'.format(G[i]), end = ' ')
    return cnt
        
        
        
n = int(input())
nlist = []
for i in range(n):
    x = int(input())
    nlist.append(x)
    
c = shellSort(nlist,n)
print()
print(c)
for i in nlist:
    print(i)


Measured memory_bytes: 45532
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <queue>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<long long> C(n);
    for (auto& c: C) cin >> c;
    sort(begin(C), end(C));
    reverse(begin(C), end(C));

    long long ans = C[0];
    
    queue<long long> Q;
    Q.push(C[1]);
    Q.push(C[1]);
    for (int i = 2; i < n; ++i) {
        ans += Q.front();
        Q.pop();
        Q.push(C[i]);
        Q.push(C[i]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 6392
#include <cstdio>
#include <iostream>
#include <sstream>
#include <string>
using namespace std;

int main(){
	int n;
	scanf(" %d", &n);
	
	bool ans=true;
	int a=n, b=n;
	while(ans){
		if(a>=0){	
			stringstream ss1;
			ss1<<a;
			string s=ss1.str();
			
			bool flag=true;
			for(int i=0; i<s.size(); ++i){
				if(s[i] != s[s.size()-1-i]) flag=false;	
			}
			
			if(flag){
				ans=false;
				printf("%d\n", a);
				break;	
			}
			a--;
		}
		
		stringstream ss2;
		ss2<<b;
		string t=ss2.str();
		
		bool flag=true;
		for(int i=0; i<t.size(); ++i){
			if(t[i] != t[t.size()-1-i]) flag=false;	
		}
			
		if(flag){
			ans=false;
			printf("%d\n", b);
				break;	
		}
		b++;
	}
}

Measured memory_bytes: 1260
X, Y, A, B, C = map(int, input().split())
ps = list(map(int, input().split()))
qs = list(map(int, input().split()))
rs = list(map(int, input().split()))
ps = sorted(ps, reverse=True)[:X]
qs = sorted(qs, reverse=True)[:Y]
rs = sorted(ps+qs+rs, reverse=True)[:X+Y]
r = sum(rs)
print(r)


Measured memory_bytes: 23328
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N;
	cin >> N;
	vector<int>S(N);
	rep(i, N) {
		cin >> S[i];
	}
	sort(S);
	int sum = 0;
	rep(i, N) {
		sum += S[i];
	}
	if (sum % 10 != 0) {
		cout << sum << endl;
		return 0;
	}
	else {
		rep(i, N) {
			if (S[i] % 10 != 0) {
				cout << sum - S[i] << endl;
				return 0;
			}
		}
	}
	cout << 0 << endl;
}




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

const int MAX=2020202;
const int MOD=1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  rep(i, MAX) {
    if (i==0||i==1) continue;
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

ll COM(int n, int k) {
  if (n<k) return 0;
  if (n<0||k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main() {
  int r1,r2,c1,c2;
  cin>>r1>>c1>>r2>>c2;
  COMinit();
  ll res=0;
  rep(i, r2-r1+1) {
    res+=COM(r1+c2+1+i, r1+1+i);
    res-=COM(r1+c1+i, r1+1+i);
    if (res<0) res+=MOD;
    res%=MOD;
  }
  cout<<res<<endl;
}

Measured memory_bytes: 47616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> L(M), R(M);
    int min_v = 0, max_v = 100001;
    for (int i = 0; i < M; i++) {
        cin >> L.at(i) >> R.at(i);
        L.at(i)--;
        R.at(i)--;
        min_v = max(min_v, L.at(i));
        max_v = min(max_v, R.at(i));
    }

    int ans;
    if (max_v - min_v >= 0) ans = max_v - min_v + 1;
    else ans = 0;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mkp make_pair
#define pin pair<int,int>
pin solve(V<pin>& ab, int ex) {
	if (!ex) { return mkp(0, 0); }
	V<V<pin>> qab(2);
	int sz = ab.size();
	qab[0].reserve(sz);
	qab[1].reserve(sz);
	for (pin& x : ab) {
		qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));
		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2)); }
	}
	int c = 0;
	for (pin& x : qab[0]) {
		int qc = 2 * x.first + x.second+1;
    qc = (qc & (0xffffffff)) + ((qc & (0x7fffffff00000000)) >> 32);
	qc = (qc & (0xffffffff)) + ((qc & (0x100000000)) >> 32);
	qc = (qc & (0xffff)) + ((qc & (0xffff0000)) >> 16);
	qc = (qc & (0xffff)) + ((qc & (0x10000)) >> 16);
	qc = (qc & (0xff)) + ((qc & (0xff00)) >> 8);
	qc = (qc & (0xff)) + ((qc & (0x100)) >> 8);
	qc = (qc & (0xf)) + ((qc & (0xf0)) >> 4);
	qc = (qc & (0xf)) + ((qc & (0x10)) >> 4);
	qc = (qc & 3) + ((qc & 12) >> 2);
	qc = (qc & 3) + ((qc & 4) >> 2);
		c ^= qc;
	}
	if (!c) {
		pin ans = solve(qab[1], ex - 1);
		ans.first *= 2; ans.second *= 2; ans.second++;
		return ans;
	}
	pin ans = solve(qab[0], ex - 1);
	c = 0;
	int d = 0;
	for (pin& x : qab[1]) {
		int w = ans.second - x.second - 1;
		if ((w & x.first) == w) { c ^= 1; }
      	w++;
      	if ((w & x.first) == w) { d ^= 1; }
	}
  	ans.first *= 2; ans.second *= 2;
	ans.first+=(c|d); ans.second -= c;
	return ans;
}
signed main() {
	cin.tie(0); ios::sync_with_stdio(false);
	long long inf = 1e17;
	int n; cin >> n;
	V<pin> ab(n);
	rep(i, n) {
		long long a, b; cin >> a >> b;
		ab[i] = { a + inf,b + inf };
	}
	pin ret = solve(ab, 59);
	cout << ret.first - inf << " " << ret.second - inf << "\n";
}

Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];

    ll ans = 0;
    rep(i,n){
        if(i>0 && a[i-1]>0 && a[i]>0){
            a[i-1]--;
            a[i]--;
            ans++;
        }
        ll t = a[i] / 2;
        ans += t;
        a[i] -= t*2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
using namespace std;

vector <int> edges[1000];
bool used[100];
bool active[100];

bool dfs(int cur){
    active[cur] = true;
    used[cur] = true;
    for(int i = 0; i < edges[cur].size(); i++){
        if(active[edges[cur][i]]){
            return true;
        }
        if(used[edges[cur][i]]){
            continue;
        }
        if(dfs(edges[cur][i])){
            return true;
        }
    }
    active[cur] = false;
    return false;
}

int main(){
    int N;
    int M;
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int s;
        int t;
        cin >> s >> t;
        edges[s].push_back(t);
    }

    for(int i = 0; i < N; i++){
        if(used[i]){
            continue;
        }
        if(dfs(i)){
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}



Measured memory_bytes: 3192
def main():
    k,a,b=map(int, raw_input().split(" "))   
    if b-a<=2:    
        print(k+1)
        return
    x=a-1
    y=(k-x)/2
    z=k-x-2*y
    print(1+x+z+(b-a)*y)
    
main()




Measured memory_bytes: 2568
<?php

$x = 0;
$inp = explode( ' ', trim( fgets( STDIN ) )  );

for ( $i = 0; $i < $inp[$x]; $i++ ) {
  $inps[$i] = trim( fgets( STDIN ) );
}

$count = count( $inps );

for ( $i = 0; $i < $count; $i++ ) {
  for ( $j = $i + 1; $j < $count; $j++ ) {
    if ( $inps[$i] > $inps[$j] ) {
      $tmp = $inps[$i];
      $inps[$i] = $inps[$j];
      $inps[$j] = $tmp;
    }
  }
}

echo implode( '', $inps );

?>

Measured memory_bytes: 4604
#include "bits/stdc++.h"

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
#define mp make_pair


int main() {
  int n, i;
  cin >> n >> i;
  cout <<n - i + 1 << endl;
}


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


int main() {
    string s;
    cin >> s;

    int res = 0;

    if (s.at(0) == 'R' && s.at(1) == 'R' && s.at(2) == 'R') {
        res = 3;
    } else if (s.at(0) == 'R' && s.at(1) == 'R') {
        res = 2;
    } else if (s.at(0) == 'R' && s.at(2) == 'R') {
        res = 1;
    } else if (s.at(1) == 'R' && s.at(2) == 'R') {
        res = 2;
    } else if (s.at(0) == 'R') {
        res = 1;
    } else if (s.at(1) == 'R') {
        res = 1;
    } else if (s.at(2) == 'R') {
        res = 1;
    } else {
        res = 0;
    }
    cout << res << endl;

}


Measured memory_bytes: 3628
fun main(args:Array<String>?): Unit {
    val mod = 1_000_000_007L
    val (n, l) = readLine()!!.trim().split(' ').map(String::toInt)
    val initialPosition = readLine()!!.trim().split(' ').map(String::toInt) + l
    val jump = readLine()!!.trim().split(' ').map(String::toInt) + 0
    val memo = Array(n + 1){LongArray(0)}//memo[i][x] i番目のウサギがx回右に飛んだ時にありうる右側のパターン. memo[n]は番兵
    memo[n] = LongArray(1){1L}
    for (i in n - 1 downTo 0) {
        var next = memo[i + 1].lastIndex
        val mostRight = next * jump[i + 1] + initialPosition[i + 1]
        memo[i] = if (jump[i] != 0) LongArray((mostRight - initialPosition[i] - 1) / jump[i] + 1){0L} else LongArray(1){0L}
        for (j in memo[i].lastIndex downTo 0) {
            if (j != memo[i].lastIndex) memo[i][j] = memo[i][j + 1]
            while(next >= 0 && j * jump[i] + initialPosition[i] < next * jump[i + 1] + initialPosition[i + 1]){
                memo[i][j] += memo[i + 1][next--]
            }
            memo[i][j] %= mod
        }
    }
    println(memo[0].sum() % mod)
}


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

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

	ll ans = 1;
	vector<int> prime(n + 2, 1);
	for (int i = 2; i <= n; i++)
	{
		for (int j = i; j <= n; j += i)
		{
			prime[j]++;
		}
		ans += (ll)i * prime[i];
	}

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

Measured memory_bytes: 42296
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <climits>
#include <sstream>
#include <functional>
#include <complex>

using namespace std;

#define len(array)  (sizeof (array) / sizeof *(array))
#define rep(i, s, e) for(int i = s;i < e;i++)
#define Rep(i, e) for(int i = 0;i < e;i++)
#define rrep(i, e, s) for(int i = e;s <= i;i--)
#define Rrep(i, e) for(int i = e;0 <= i;i--)
#define mrep(i, e, t1, t2) for(map<t1, t2>::iterator i = e.begin(); i != e.end(); i++)
#define vrange(v) v.begin(), v.end()
#define vrrange(v) v.rbegin(), v.rend()
#define vsort(v) sort(vrange(v))
#define vrsort(v) sort(vrrange(v))
#define arange(a) a, a + len(a)
#define asort(a) sort(arange(a))
#define arsort(a, t) sort(arange(a), greater<t>())
#define afill(a, v) fill(arange(a), v)
#define afill2(a, v, t) fill((t *)a, (t *)(a + len(a)), v)
#define fmax(a, b) (a < b? b : a)
#define fmin(a, b) (a > b? b : a)
#define fabs(a) (a < 0? -a : a)
#define pb push_back
#define rg(e, s, t) s <= e && e < t
#define PQDecl(name, tp) priority_queue< tp, vector<tp>, greater<tp> > name;
//#define X real()
//#define Y imag()
//typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
//typedef complex<double> p;
const int INF = (int)2e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-10;
//const int dx[] = {1, -1, 0, 0, 1, -1, -1, 1};
//const int dy[] = {0, 0, 1, -1, -1, -1, 1, 1};
//const ll weight[] = {1e0,1e1,1e2,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13};
#define MAX_N 1000

void doIt(){
  string a, b;
  int c = 0;
  string ans = "No";
  cin >> a >> b;
  Rep(i, a.length()){
    c = 0;
    Rep(j, b.length()){
      if(i + j >= a.length() || (b[j] != '_' && a[i + j] != b[j])){
        break;
      }
      c++;
    }
    if(c == b.length()){
      ans = "Yes";
      break;
    }
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 1192
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

#define ll long long
#define loop(x, start, end) for(int x = start; x < end; x++)

#define MAX_H 10001
#define INFTY 100000001
ll H, N, A, B;
vector<ll> dp(MAX_H, INFTY);

void solve() {
  cin >> H >> N;
  dp.at(0) = 0;
  loop(n,0,N) {
    cin >> A >> B;
    loop(h,0,H+1) {
      if (h < A) dp.at(h) = min(dp[h], B);
      else dp.at(h) = min(dp[h], dp.at(h-A) + B);
    }
  }
  cout << dp[H] << endl;
}

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


Measured memory_bytes: 384
//#pragma GCC optimize "trapv"
//-D_GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define pm(m) for(auto itr=(m).begin();itr!=(m).end();itr++){itr->first<<" "<<itr->second<<"\n";}
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define ii pair<int,int>
#define Max 100000+5
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f first
#define s second
#define pb push_back
#define bug(x) cout<<(x)<<" ";exit(0);
int mod = 1000000007;
int mod1 = 998244353;
vector<int> g[Max];
bool vis[Max];
int d, x, y;
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
void ex(int A, int B) {
    if(B == 0) {
        d = A;
        x = 1;
        y = 0;
    }
    else {
        ex(B, A%B);
        int temp = x;
        x = y;
        y = temp - (A/B)*y;
    }
}





int power(int a,int b){
    if(b==1)return a;
    if(a>mod)a%=mod;
    int r=1;
    while(b){
        if(b&1)r=r%mod*a%mod;
        a=a%mod*a%mod;
        b/=2;
    }
    return r;
}
class uf{
    vector<int> v;
    vector<int> sz;
    
    
    public :
    uf(int n){
        v.resize(n+1);
        iota(v.begin()+1,v.end(),1);
        sz.resize(n+1,1);
        //1 to sz
    }
    int root(int b){
        while(v[b]!=b){
            b = v[b];
        }   
        return b;
    }
    void u(int a, int b){
        //combine a and b
        
        int ra=root(a);
        int rb=root(b);
        if(ra==rb)return ;
        if(sz[ra]<sz[rb]){
            v[ra] = v[rb];
            sz[rb]+=sz[ra];
        }else{
            v[rb]=v[ra];
            sz[ra]+=sz[rb];
        }
    }
    bool f(int a,int b){
        //same set
        return (root(a)==root(b));
    }
   
    
};
vector<int> matmul(vector<int> a,vector<int> b){
    vector<int> c(4,0);
    c[0] = (a[0]%mod*b[0]%mod + a[1]%mod*b[2]%mod)%mod;
    c[1] = (a[0]%mod*b[1]%mod + a[1]%mod*b[3]%mod)%mod;
    c[2] = (a[2]%mod*b[0]%mod + a[3]%mod*b[2]%mod)%mod;
    c[3] = (a[2]%mod*b[1]%mod + a[3]%mod*b[3]%mod)%mod;
    return c;
}
vector<int> id={1,0,0,1};

int n,m;

vector<int> dp(Max,-1);
int dfs(int u){
    if(dp[u]!=-1)return dp[u];
    if(g[u].size()==0){dp[u]=0;return 0;}
    int ans=0;
    for(auto v:g[u]){
        ans=max(ans,dfs(v));
    }
    dp[u]=ans+1;
    return dp[u];
    
}
int32_t main(){
	IO
	//freopen("input.txt","r",stdin);
    	//freopen("output.txt","w",stdout);
    	

	cin>>n;
	cin>>m;
	for(int i=0;i<m;i++){
	    int u,v;
	    cin>>u>>v;
	    g[u].pb(v);
	}
	
	for(int i=1;i<=n;i++){
	    if(dp[i]==-1)dfs(i);
	    
	}
	
	cout<<*max_element(dp.begin()+1,dp.begin()+n+1);
	
	
}

Measured memory_bytes: 11432
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<double>vec(n);
  double sum;
  for(int i=0;i<n;i++){
   cin >> vec.at(i);
  sum+=1/vec.at(i);}
  cout << 1/sum <<endl;
}

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

int H, W;
vector<vector<char>> maze(51, vector<char>(51));
vector<vector<bool>> check(51, vector<bool>(51));
bool goal;

queue<pair<int, int>> BFS(queue<pair<int, int>> q, pair<int, int> p) {
  int y = p.first, x = p.second;
  //cout << y << " " << x <<endl;
  if (y == H - 1 && x == W - 1) {
    goal = true;
  }
  pair<int, int> tmp;
  //上
  if (y > 0 && maze[y - 1][x] == '.' && !check[y - 1][x]) {
    check[y-1][x] = true;
    tmp = make_pair(y - 1, x);
    q.push(tmp);
  }
  //下
  if (y < H - 1 && maze[y + 1][x] == '.' && !check[y + 1][x]) {
    check[y+1][x] = true;
    tmp = make_pair(y + 1, x);
    q.push(tmp);
  }
  //左
  if (x > 0 && maze[y][x - 1] == '.' && !check[y][x - 1]) {
    check[y][x-1] = true;
    tmp = make_pair(y, x - 1);
    q.push(tmp);
  }
  //右
  if (x < W - 1 && maze[y][x + 1] == '.' && !check[y][x + 1]) {
    check[y][x+1] = true;
    tmp = make_pair(y, x + 1);
    q.push(tmp);
  }
  return q;
}

int clearMaze() {
  queue<pair<int, int>> q, q2;
  pair<int, int> start = make_pair(0, 0);
  q2.push(start);
  check[0][0] = true;
  int i = 0;
  while (true) {
    if(goal){
      return i;
    }
    if(q2.empty()){
      return -1;
    }
    i++;
    q.swap(q2);
    while (!q.empty()) {
      q2 = BFS(q2, q.front());
      q.pop();
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  cin >> H >> W;
  int white = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> maze[i][j];
      if(maze[i][j] == '.'){
        white++;
      }
    }
  }
  int root = clearMaze();
  if(root > 0){
    cout << white - root <<endl;;
  } else{
    cout << -1 <<endl;
  }
}

Measured memory_bytes: 3604
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

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

  LL N;
  string s;
  cin >> N>>s;

  LL cnt = 0;
  LL sum = 0;

  vector<LL> w(N + 1, 0);
  vector<LL> b(N + 1, 0);
  REP(i, s.size())
  {
    w[i + 1] = w[i];
    b[i + 1] = b[i];
    if (s[i] == '.')
    {
      w[i + 1]++;
    }
    else{
      b[i + 1]++;
    }
  }

  LL min = N + 1;

  REP(i, N+1)
  {
    LL a = b[i] + (w[N] - w[i]);
    if(a<min)
      {
        min = a;
      }
  }
  cout << min << endl;
}


Measured memory_bytes: 3732
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <climits>

int main(int argc, char const *argv[])
{
    int N , A , B;
    std::cin >> N ;
    if( N == 1)
    {
        std::cout<<"Hello World"<<std::endl;
        return 0;
    }
    else
    {
        std::cin >> A;
        std::cin >> B;
        std::cout<<A + B <<std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    unsigned long H,attack=0,tmp=1;
  	cin >> H;
    while(H>1){
        H /= 2;
      	if(attack==0) attack+=1;
        else attack+=tmp;
      	tmp*=2;
    }
  	attack+=tmp;
    cout << attack << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	double w,h;
	int x,y;
	double s=0;

	scanf("%lf" "%lf" "%d" "%d",&w,&h,&x,&y);
	s=(w*h)/2;
	printf("%f",s);
	if((w==x*2)&&(h==y*2)){
	printf(" 1\n");
    }
	else
    {
	printf(" 0\n");
    }
	return 0;
}

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

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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<pair<string, int>> v(n);
  for (auto&& [s, t] : v) {
    cin >> s >> t;
  }
  string x;
  cin >> x;
  bool iscnt = false;
  int ans = 0;
  for (auto&& [s, t] : v) {
    if (iscnt) ans += t;
    if (s == x) iscnt = true;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3672
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

K = get_int

sum = 0

1.step(K) do |a|
  1.step(K) do |b|
    1.step(K) do |c|
      sum += a.gcd(b).gcd(c)
    end
  end
end

puts sum


Measured memory_bytes: 14460
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    double pi = 3.141592;
    double num;
    cin >> num;
    cout << setprecision(20) << pi*2*num << endl;
    return 0;
}

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

bool check(int x){
    if(x%2==0) return false;
    map<int,int> mp;
    int d = 3;
    while(x>1){
        if(x%d == 0){
            x /= d;
            mp[d]++;
        }else{
            d += 2;
        }
    }
    int cnt = 1;
    for(auto itr : mp){
        cnt *= itr.second+1;
    }
    return cnt == 8;
}

int main(void){
    int n;
    cin>>n;
    int cnt = 0;
    rep1(i,n){
        if(check(i)) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
N, Q = gets.split.map(&:to_i)
STXs = N.times.map{gets.split.map(&:to_i)}
Ds = Q.times.map{gets.to_i}

class Heap
  def initialize
    @a = [nil]
    @h = {}
  end

  def swap(i, j)
    @a[i], @a[j] = @a[j], @a[i]
    @h[@a[i]], @h[@a[j]] = i, j
  end

  def up(i)
    p = i / 2
    return if i <= 1 || @a[p] <= @a[i]
    swap(i, p)
    up(p)
  end

  def down(i)
    c = i * 2
    a = @a.size
    return if c >= a
    c += 1 if c != a - 1 && @a[c] > @a[c + 1]
    return if @a[i] <= @a[c]
    swap(i, c)
    down(c)
  end

  def add(v)
    return if @h[v]
    @a << v
    i = @a.size - 1
    @h[v] = i
    up(i)
  end

  def delete(v)
    return unless i = @h[v]
    u = @a[-1]
    swap(i, -1)
    ret = @a.pop
    @h[ret] = nil
    v > u ? up(i) : down(i)
    ret
  end

  def first
    @a[1] || -1
  end
end

ss = Heap.new
es = []
es = STXs.each_with_object([]){|(s, t, x), a| a << [s - x, 0, x] << [t - x, 1, x] if t - x > 0}
es += Ds.map{|d| [d, 2, 0]}
ans = []
es.sort_by(&:first).each do |t, e, x|
  case e
  when 0; ss.add(x)
  when 1; ss.delete(x)
  else;   ans << ss.first
  end
end
puts ans

Measured memory_bytes: 100100
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long ans = 0;
		for(int i = 1; i < N; i++) {
			ans += (N-1) / i;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 35728
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

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

ll x[510000];
ll y[510000];
int main(){
    string s;
    cin >> s;

    fill(x, x+510000, 0);
    fill(y, y+510000, 0);
    x[0] = 0;
    ll res = 0, mi = INT32_MAX;
    ll count1 = 0, count2 = 0;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == '<') {
            x[i+1] = x[i] + 1;
        }
        else{
            x[i+1] = 0;
        }
    }
    y[s.length()] = 0;
    for(int i = s.length()-1 ; i >= 0; i--){
        if(s[i] == '>') {
            y[i] = y[i+1] + 1;
        }
        else{
            y[i] = 0;
        }
    }

    for(int i = 0; i <= s.length(); i++){
        res += max(x[i], y[i]);
    }

    cout << res << endl;



    return 0;
}




Measured memory_bytes: 8836
#include<iostream>
using namespace std;
int n,ans,c;
char s;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		if(s=='I')
		{
			c++;
			ans=max(c,ans);
		}
		if(s=='D')
		{
			c--;
			ans=max(c,ans);
		}
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
const int N = 1e6 + 5 ;
const int MOD = 1e9+7;
typedef long long int ll;
vector< pair< ll , ll > > vp;
map<ll , ll > mp , mpp;
vector < ll > v , v1 , v2 ;
ll dp[N] , visit[N] ;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<"  ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
int a[N] , k  ;
ll go(int n) {
	int x = 1e9 + 5 , y = 1e9 + 5 ;
	if(n <= 1) return 0 ;
	if(dp[n] != - 1) return dp[n] ;
	ll res = 1e9 + 5  ;
	for(int i = 1 ;  i <= k ; i++ ) {
	if(n > i) res = min(res , abs(a[n] - a[n - i]) + go(n - i)) ;
	}
	return dp[n] = res ;
}
int main()
{ fast;
   ll n, m, val, d, mi=1e9, mx(0) ;
   ll sum(0), ct(0), p(0), q(0);
   string s ;
   cin >> n >> k ;
   memset(dp , -1 , sizeof(dp)) ;
   for(int i = 1;  i <= n; i++ ) cin >> a[i] ;
   cout << go(n) ;
}


Measured memory_bytes: 14592
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        // 整数の入力
        // final int a = sc.nextInt();
        // 文字列の入力
        // final String s1 = sc.next();
        long resN = Long.parseLong(sc.next());
        long modN = 0;

        sc.close();
        StringBuilder sb = new StringBuilder();

        while (resN > 0) {
            modN = resN % 26;
            if (modN == 0) {
                modN = 26;
            }
            resN = (resN - modN) / 26;

            sb.insert(0, (char) (96 + modN));
        }
        System.out.println(sb.toString());
    }
}

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

public class Main {

	public static void main(String args[]) throws IOException{
		Scanner sc = new Scanner(System.in);
		
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//StringTokenizer st = new StringTokenizer(br.readLine());
		
		//StringBuilder sb = new StringBuilder();
		
		int n = sc.nextInt();
		
		boolean f = false;
		for(int i=0;i<n;i++){
			if(sc.next().equals("Y"))
				f = true;
		}
		
		System.out.println(f ? "Four":"Three");
	}
}

Measured memory_bytes: 21972