akhauriyash/Code-Regression huggingface dataset:
def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    n, a, b = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    re = 0
    for i in range(1, n+1):
        sumNum = (i // 10000) + ((i % 10000) // 1000) + ((i % 1000) // 100) + ((i % 100) // 10) + (i % 10)
        if sumNum >= a and sumNum <= b:
            re += i

    print(re)
resolve()

Measured memory_bytes: 39536
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	cat A, B, C;
	cin >> A >> B >> C;
	cout << min(C, A+B+1) + B << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int a[] = new int[5];
    for (int i = 0; i < 5; i++){
      a[i] = sc.nextInt();
    }
    int k = sc.nextInt();

    if (a[4] - a[0] > k) {
      System.out.println(":(");
    }
    else
      System.out.println("Yay!");
  }
}


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

int main(void) {
    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int cnt = 0;
    for (int i = 0; i <= A; i++) {
        for (int j = 0; j <= B; j++) {
            for (int k = 0; k <= C; k++) {
                int sum = ((500 * i) + (100 * j) + (50 * k));
                if (sum == X) cnt++;
            }
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const ll oo = 1e18;
const int MOD = 1000000007;
const int N = 500002;
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define cpx complex<double>

int n , k, dp[2010][2010][2];
ll pw(ll a, ll b){
	if(!b)return 1ll;
	ll res = pw(a,b/2);
	res = (res*res)%MOD;
	if(b&1)
		return (res*a)%MOD;
	return res;
}
int calc(int idx, int left, bool go) {
	int used = n - idx - left;
	if (idx < 1 || left < 0 || used > k)return 0;
	if (idx == 1 && used != k) {
		if (go && left > 0)
			return calc(idx, left - 1, go);
		return 0;
	}
	if (idx == 1 && used == k)return 1;
	int &ret = dp[idx][left][go];
	if (ret != -1)return ret;
	ret = (calc(idx - 1, left + 1, false) + calc(idx - 1, left, true)) % MOD;
	if (go && left > 0)
		ret = (ret + calc(idx, left - 1, true))%MOD;
	return ret;
}
int main() {
	cin >> n >> k;
	--k;
	memset(dp, -1, sizeof dp);
	ll res = calc(n,0,0);
	if(n-k-2>=0)
		res = (res*pw(2,n-k-2))%MOD;
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 32000
import java.util.*;

public class Main{
	public static void main(String[] args){
    Scanner scn = new Scanner(System.in);
      
    String S = scn.next();
	int y1 = 2019;
    int m1 = 4;
    int d1 =30;
    
    int y2 = Integer.parseInt(S.substring(0,4));
    int m2 = Integer.parseInt(S.substring(5,7));
    int d2 = Integer.parseInt(S.substring(8,10));
    
    if(y1>=y2 && m1>=m2 && d1>=d2){
      System.out.print("Heisei");      
    }else{
      System.out.print("TBD");      
    }
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=200000000000000;
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
}

ll getdigit(ll n){
	string s=to_string(n);
	return s.size();
}
	
int main(){
	init();
	ll N,A,B;
	cin>>N>>A>>B;
	vector<ll>v(N);
	for(int i=0;i<N;i++)cin>>v[i];
	
	vector<vector<ll>>dp(N+1,vector<ll>(N+1,0));
	vector<vector<ll>>number(N+1,vector<ll>(N+1,0));
	number[0][0]=1;
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			//use 
			dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+v[i]);
			if(dp[i+1][j+1]==dp[i][j]+v[i]){
				number[i+1][j+1]+=number[i][j];
			}
			if(dp[i+1][j+1]<dp[i][j]+v[i]){
				dp[i+1][j+1]=dp[i][j]+v[i];
				number[i+1][j+1]=number[i][j];
			}
			
			//dp[i+1][j]=dp[i][j]
			if(dp[i+1][j]==dp[i][j]){
				number[i+1][j]+=number[i][j];
			}
			if(dp[i+1][j]<dp[i][j]){
				dp[i+1][j]=dp[i][j];
				number[i+1][j]=number[i][j];
			}
			
		}
	}
	
	/*for(int i=0;i<=N;i++){
		for(int j=0;j<=N;j++){
			cout<<number[i][j]<<" ";
		}
		cout<<endl;
	}*/
	long double ans=0;
	ll n=0;
	for(long double i=A;i<=B;i++){
		long double num=dp[N][i];
		if(ans==num/i){
			n+=number[N][i];
		}else if(ans<num/i){
			ans=num/i;
			n=number[N][i];
		}
		
	}
	cout<<ans<<endl;
	cout<<n<<endl;
}


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

using namespace std;

int main(){

    int n;
    cin >> n;
    vector<int> arr(100001, 0);
    int a;
    for(int i = 0; i < n; i++){
        cin >> a;
        arr[a]++;
    }
    int cal = 0, tot = 0;
    for(int i = 1; i <= 100000; i++){
        if( cal == n/2 )
            tot++;
        else if( cal > n/2 )
            break;
        cal += arr[i];
    }
    cout << tot << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n - 1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;
double PI = acos(-1);

void solve()
{	
	double r; cin >> r;
	cout << r*r*PI<<" "<<2*r*PI << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}



Measured memory_bytes: 3248
n = int(input())
A, B = [], []
for i in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

A.sort()
B.sort()

res = 0

if n % 2 == 1:
    midA = A[n // 2]
    midB = B[n // 2]
    if midB >= midA:
        res = midB - midA + 1
    else:
        res = 0
else:
    midA = A[n // 2 - 1] + A[n // 2] 
    midB = B[n // 2 - 1] + B[n // 2]
    if midB >= midA:
        res = midB - midA + 1
    else:
        res = 0
print(res)

Measured memory_bytes: 98744
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

int main(){
    vector<int> v;
    int sum=0;
    rep(i,1,1000){
        sum+=i;
        v.pb(sum);
    }

    int a,b;
    cin>>a>>b;
    rep(i,1,v.size()){
        if(v[i]-v[i-1]==b-a){
            cout<<v[i]-b<<endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1e9+7;
int modinv(int t) {
	int cur = 1, mult = t, p = MOD-2;
	while(p) {
		if(p&1) cur *= mult;
		mult *= mult;
		cur %= MOD;
		mult %= MOD;
		p /= 2;
	}
	return cur;
}
int32_t main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n, m;
	cin >> n >> m;
	if((n+m)%3) {
		return !(cout << 0);
	}
	int t = (n+m)/3;
	n -= t, m -= t;
	if(n < 0 || m < 0)
		return !(cout << 0);
	vector<int> dp(1000001);
	dp[0] = 1;
	for(int i=1; i<1000001; i++) {
		dp[i] = (dp[i-1]*i)%MOD;
	}
	cout << (((dp[n+m]*modinv(dp[n]))%MOD)*modinv(dp[m]))%MOD;
}

Measured memory_bytes: 8064
import scala.io.Source

object Main {
  def main(args:Array[String]) {
    for((line, index) <- scala.io.Source.stdin.getLines().zipWithIndex){
        line.toInt match {
          case 0 => return
          case _ => println("Case " +  (index + 1) + ": " + line)
        }
    }
  }
}

Measured memory_bytes: 55040
#include<iostream>
#include<vector>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
#define ip(arr, n) for(int i=0; i<n; i++) cin>>arr[i];
#define op(arr, n) for(int i=0; i<n; i++) cout<<arr[i]<<" ";
#define fstIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MAX 100005
#define Inf 1000000000005

int main(){
    int n,k;
    cin>>n>>k;
    ll height[n];
    ip(height, n);
    
    ll dp[MAX];
    for(int i=0; i<n+5; i++) dp[i]=Inf;
    dp[0]=0;

    for(int i=0; i<n; i++){
        for(int j=1; j<=k && (i+j)<n; j++){
            dp[i+j] = min(dp[i+j], dp[i]+abs(height[i]-height[i+j]));
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(998244353)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = 1234567;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll gattai = 0;
	char saita = 'N';
	ll botti = 0;
	char sub = 'N';
	ll ans = 1;
	rep(i,s.size()){
		if(sub == s[i]){
			if(botti == 0){
				char tmp = saita;
				saita = sub;
				sub = tmp;
			}
		}
		if(saita == s[i] || saita == 'N'){
			saita = s[i];
			botti++;
		}else if(sub == 'N' || sub == s[i]){
			ans *= botti;
			ans %= MOD;
			gattai++;
			botti--;
			sub = s[i];
		}else{
			ans *= gattai;
			ans %= MOD;
			gattai--;
			if(gattai == 0){
				sub = 'N';
				if(botti == 0){
					saita = 'N';
				}
			}
		}
		//cout<<i<<" "<<saita<<" "<<botti<<" "<<sub<<" "<<gattai<<" "<<ans<<endl; 
	}
	ans *= kaijo(n);
	ans %= MOD;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
package main

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

func main() {
	N, P := ReadInt(), ReadInt()
	A := ReadInts(N)

	dp := make([][2]int, N+1)
	dp[0][0] = 1
	for i := 0; i < N; i++ {
		for p := 0; p < 2; p++ {
			dp[i+1][p] = dp[i][p]
			dp[i+1][p] += dp[i][(p+A[i])%2]
		}
	}
	fmt.Println(dp[N][P])
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1844
#include <iostream>
#include <math.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <stack>

using namespace std;
typedef long long ll;

ll min(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    else return b;
}

int main(){
    ll a[3],n;cin>>a[0]>>a[1]>>a[2]>>n;
    ll dp[3][n+1];
    for(int i=0;i<=n;i++){
        if(i%a[0]==0){
            dp[0][i]=1;
        }else{
            dp[0][i]=0;
        }
    }
    for(int i=1;i<=2;i++){
        for(int j=0;j<=n;j++){
            dp[i][j]=0;
        }
    }
    for(int i=0;i<=1;i++){
        for(int j=0;j<=n;j++){
            if(dp[i][j]>0){
                for(int k=0;j+k*a[i+1]<=n;k++){
                    dp[i+1][j+k*a[i+1]]=dp[i+1][j+k*a[i+1]]+dp[i][j];
                }
            }
        }
    }
    cout<<dp[2][n]<<endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;n>i;++i)
using namespace std;
using ll=int64_t;
using vi=vector<int>;
using VI=vector<ll>;
using vis=vector<string>;
using vvi=vector<vi>;
int main(){
    string s;
    cin>>s;
    if(s=="A"){
        cout<<"T"<<endl;
        return 0;
    }
    if(s=="T"){
        cout<<"A"<<endl;
        return 0;
    }
    if(s=="G"){
        cout<<"C"<<endl;
        return 0;
    }
    if(s=="C"){
        cout<<"G"<<endl;
        return 0;
    }
}

Measured memory_bytes: 3596
# coding: utf-8

n = int(input())
arm = []

for n in range(n):
    X,L = [ int(i) for i in input().split() ]
    arm.append((X+L,X-L))

arm.sort()
# print(arm)
lowest = float("-inf")
cnt = 0

for x,l in arm:
    if l>=lowest:
        lowest = x
        cnt += 1

print(cnt)

Measured memory_bytes: 17020
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<float.h>
using namespace std;


int main() {
    int a, b,c,d;
    cin >> a>>b;
    if (a <= b) {
        cout << a << endl;
    }
    else cout << a - 1 << endl;
    return 0;
}

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


using namespace std;



#define For(i,x,n)  for(long long i=x;i<n;i++)
#define rFor(i,x,n) for(long long i=x;i>=n;i--)
#define itFor(it,st)   for(auto it=st.begin() ; it!=st.end() ; it++)
#define MOD 1000000007
#define PI 3.141592653589793
#define INF 999999999999999999
#define N 1000005
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sp " "
#define cont continue
#define brk break

#define deb1(x)                cout<<#x<<": "<<x<<endl
#define deb2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define deb3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define deb4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define deb5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define deb6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

using namespace std;

int main()
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed;
    cout<<setprecision(3);
    srand(time(NULL));

	ll n,a,b;
	cin>>n>>a>>b;
	ll single = a+b;
	if(n<=single){
		cout<<min(n,a);
	}    
	else{
		ll ans = (n/single);
		ll rem = n - (n/single)*single;
		ans *= a;
		ans += min(rem,a);
		cout<<ans;
	}
    
    //cout<<"\nTime used = "<<static_cast<double>(clock())/(CLOCKS_PER_SEC)<<"s"<<endl;  // - for checking time used for a test case
    return 0;
}

//s1.substr(1,3) - return 3 characters starting from position 1 as substring of string sz1. eg sz1="shreynumh" sz1.substr(2,5)="reyan"
//num = atoi(s.c_str()); //convert string s to integer num
//n.erase(i,std::string::npos); //erase i th position in string n , decreasing string size
//s.find(b)!= std::string::npos - finds string b in string a - true if found
//cout<<"Time used = "<<static_cast<double>(clock())/(CLOCKS_PER_SEC)<<"s"<<endl;  // - for checking time used for a test case                


Measured memory_bytes: 256
s = input()
n = len(s)
s1 = []
s2 = []
for i in range(n):
    if i % 2 == 0:
        s1.append("0")
    else: s1.append("1")
for i in range(n):
    if i % 2 != 0:
        s2.append("0")
    else: s2.append("1")
s1_switch = 0
s2_switch = 0
for i in range(n):
    if s[i] != s1[i]:
        s1_switch += 1
    elif s[i] != s2[i]:
        s2_switch += 1
print(min(s1_switch, s2_switch))


Measured memory_bytes: 4980
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using static System.Math;

class MainClass
{

    public static void Main(string[] args)
    {
        var _ = LnInts();
        var tH = _[0];
        var tA = _[1];
        var aH = _[2];
        var aA = _[3];
        var result = "";
        for (int i=0; i < 10000; i++)
        {
            aH -= tA;
            if (aH <= 0) { result = "Yes"; break; }
            tH -= aA;
            if (tH <= 0) { result = "No"; break; }
        }
        Console.WriteLine(result);
    }
   

public static long Gcd(long a, long b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int Gcd(int a, int b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int[] LnInts() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new int[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]); return ins; }
    public static int LnInt() { var vs = Console.ReadLine().Trim(); return int.Parse(vs); }
    public static long[] LnLngs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new long[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = long.Parse(vs[i]); return ins; }
    public static long LnLng() { var vs = Console.ReadLine().Trim(); return long.Parse(vs); }
    public static string[] LnStrs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); return vs; }
    public static string LnStr() { var vs = Console.ReadLine().Trim(); return vs; }
}



Measured memory_bytes: 17908
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string s;

    cin >> s;

    int a, b, n;

    n = s.length();
    a = b = -1;

    for (int i = 0; i < n-1 && a == -1; i++)
    {
        if (s[i] == s[i+1])
        {
            a = i+1;
            b = i+2;
        }
    }

    for (int i = 0; i < n-2 && a == -1; i++)
    {
        if (s[i] == s[i+2])
        {
            a = i+1;
            b = i+3;
        }
    }

    cout << a << " " << b << endl;

    return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

ll f(ll x){
	ll i=2ll,ret=0ll,t;
	while(i<=(x*2)){
		t = (i/2)*(x/i)+max(0ll,x%i-i/2);
		ret += (i/2)*(t%2);
		i *= 2;
	}
	return ret;
}

int main(void){
	ll a,b;
	cin >> a >> b;
	cout << (f(a)^f(b+1)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  	int n, m, ans=0;
  	cin>>n>>m;
  	int a[n];
  	for(int i=0;i<n;i++){
     	cin>>a[i]; 
    }
  	sort(a,a+n);
  	for(int i=0;i<m;i++){
     	ans+=a[i]; 
    }
  	cout<<ans;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
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 (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    set<string> mem;
    char c;
    string ans = "Yes";
    bool flag = true;
    rep(i, 0, n) {
        string s;
        cin >> s;
        if (i != 0 && (c != s[0] || mem.find(s) != mem.end())) {
            ans = "No";
        }
        c = s[s.size()-1];
        mem.insert(s);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(), (v).end()

int main(){
    int x;
    cin >> x;
    int h = 0;
    while(x>=500){
        if(x>=500){
            h += 1000;
            x -= 500;
        }
    }
    while(x>=5){
        if(x>=5){
            h += 5;
            x -= 5;
        }
    }
    cout << h << endl;
    
}

Measured memory_bytes: 256
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<fstream>
#include<map>
#include<iostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
#define rep(i,n) for (int i=1;i<=n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define flush fflush(stdout)
map<int,int> m;
ll ans=0;
int main()
{
    ios::sync_with_stdio(false);
    int a,b,c,d;
    ll need;
    cin>>a>>b>>c>>d>>need;
    m[1]=min(min(a*4,b*2),c);
    m[2]=min(m[1]*2,d);
    ans+=m[2]*(need/2);
    ans+=m[1]*(need%2);
    cout<<ans;
}

Measured memory_bytes: 256
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input()) # n=1
def inpm(): return map(int,input().split()) # x=1,y=2
def inpl(): return list(map(int, input().split())) # a=[1,2,3,4,5,...,n]
def inpls(): return list(input().split())  # a=['1','2','3',...,'n']
def inplm(n): return list(int(input()) for _ in range(n)) # x=[] 複数行
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)] # [[2,2,2,2],[1,1,1,1],[3,3,3,3]] 
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)]) # [[1,1,1,1],[2,2,2,2],[3,3,3,3]] 
def graph():
    n=inp()
    g=[[] for _ in range(n)]
    for i in range(n):
        a = inp()
        a -= 1
        g[i].append(a)
        g[a].append(i)
    return n,g

def main():
    n,c = inpm()
    D = inpll(c)
    a = inpll(n)
    dic1 = defaultdict(int)
    dic2 = defaultdict(int)
    dic3 = defaultdict(int)
    for i in range(n):
        for j in range(n):
            if (i+j)%3 == 0:
                dic1[a[i][j]] += 1
            elif (i+j)%3 == 1:
                dic2[a[i][j]] += 1
            elif (i+j)%3 == 2:
                dic3[a[i][j]] += 1
    ANS = 10**10
    if n == 1:
        for e in range(c):
            x = e
            ans = 0
            for color1 in dic1:
                if color1 == x+1:
                    continue
                ans += dic1[color1] * D[color1-1][x]
            ANS = min(ANS,ans)
        print(ANS)
        return
    for e in permutations(range(c),3):
        [x, y, z] = e
        ans = 0
        for color1 in dic1:
            if color1 == x+1:
                continue
            ans += dic1[color1] * D[color1-1][x]
        for color2 in dic2:
            if color2 == y+1:
                continue
            ans += dic2[color2] * D[color2-1][y]
        for color3 in dic3:
            if color3 == z+1:
                continue
            ans += dic3[color3] * D[color3-1][z]
        ANS = min(ANS,ans)
    print(ANS)            

if __name__ == "__main__":
    main()

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

Measured memory_bytes: 128
/* SANDEEP YADAV*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld double
#define lld long double
#define umap unordered_map<>
#define sz(x) ((ll)((x).size()))
#define all(x) (x).begin(),(x).end()
#define vi vector<int>
#define pi pair<int, int>
#define setp cout<<fixed<<setprecision(6)
#define loop(i,a,b)  for(int i=a;i<b;i++)
#define rloop(i,b,a) for(int i=b-1;i>=a;i--)
#define vl vector<ll>
#define pl pair<ll, ll>
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
ll gcd(ll a,ll b){ if(a<b) { a=a+b; b=a-b; a=a-b;}while(b!=0){ll r=a%b; a=b; b=r;} return a;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long power(long long a, long long b, long long m) {a %= m;long long res = 1;while (b > 0) {if (b & 1)res = res * a % m;a = a * a % m;b >>= 1;}return res;}
const int N=1000005;
void judge()
{
      #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("error.txt","w",stderr);
    #endif
}
struct myhash
{
    static uint64_t fxn(uint64_t x)
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator ()(uint64_t x) const
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return fxn(x + FIXED_RANDOM);
    }
};
void solve(int tc)
{

    string s,t;
    cin>>s>>t;

    int n=sz(s);
    int m=sz(t);

    ll dp[n+1][m+1]={};
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(s[i-1]==t[j-1])
                dp[i][j]=max(dp[i-1][j-1]+1,max(dp[i-1][j],dp[i][j-1]));
            else
                dp[i][j]=max(dp[i-1][j-1],max(dp[i][j-1],dp[i-1][j]));
        }
    }
    int x=n,y=m;
    stack<char>st;
    while(1)
    {
        if(x==0||y==0)
            break;
        if(s[x-1]==t[y-1])
        {
            st.push(s[x-1]);
            x--;y--;
        }
        else
        {
            if(dp[x][y]==dp[x-1][y-1])
            {
                x--;y--;
            }
            else if(dp[x][y]==dp[x-1][y])
            {
                x--;
            }
            else
                y--;
        }

    }
    while(!st.empty())
    {
        cout<<(char)st.top();
        st.pop();
    }

    // cout<<dp[n][m];
    return;
}
int main()
{
    fastio;
   // judge();

    int T=1;
    // cin>>T;
    for(int tc=1;tc<=T;tc++)
    {
        solve(tc);
    }
    return 0;
}

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

string fn(string s)
{
    string ret;
    int id = 0;
    map<char, int> m;
    for (auto c : s) {
        if (m[c]) {
            ret += m[c];
        } else {
            m[c] = ++id;
        }
    }
    return ret;
}
int main()
{
    string s, t;
    cin >> s >> t;

    cout << (fn(s) == fn(t) ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 1552
#include<bits/stdc++.h>
#define lson l, mid, i<<1
#define rson mid+1, r, i<<1|1
#define PII pair<int, int>
#define Size(x) (int)(x.size())
using namespace std;
typedef long long LL;
//const int MOD = 1e9+7;
const auto INF = 0x3f3f3f3f;
const int N = 2e5+5;
struct node {
    int x, id;
}num[N][26];


char str[N];
vector<char> ans;

void dfs(int cnt, int id) {
    if(cnt == 0)
        return;
    int pos = 0, minn = INF;
    for(int i=0; i<26; i++) {
        if(minn > num[id+1][i].x) {
            minn = num[id+1][i].x;
            pos = i;
        }
    }
    ans.push_back(pos+'a');
    dfs(cnt-1, num[id+1][pos].id);
}

int main() {
    scanf("%s", str);
    int len = (int)strlen(str);
    for(int i=0; i<26; i++) {
        num[len][i].id = -1;
        num[len][i].x = 0;
    }
    for(int i=len-1; i>=0; i--) {
        int minn = INF, pos = 0;
        for(int j=0; j<26; j++) {
            if(minn > num[i+1][j].x) {
                minn = num[i+1][j].x;
                pos = j;
            }
            num[i][j] = num[i+1][j];
        }
        minn++;
        num[i][str[i]-'a'].x = minn;
        num[i][str[i]-'a'].id = i;
    }
    int minn = INF;
    for(int j=0; j<26; j++) {
        minn = min(minn, num[0][j].x);
    }
    minn++;
    dfs(minn, -1);
    for(int i=0; i<Size(ans); i++)
        printf("%c", ans[i]);
    printf("\n");
}


//abcdefghijklmnopqrstuvwxyzabcdef




Measured memory_bytes: 41088
from collections import deque
n,m=map(int,input().split())
path=[[] for _ in range(n+1)]
for i in range(m):
  a,b=map(int,input().split())
  path[b].append(a)
  path[a].append(b)
q=deque()
q.append(1)
l=[-1]*(n+1)
while q:
  v=q.popleft()
  for i in path[v]:
    if l[i]==-1:
      l[i]=v
      q.append(i)
print('Yes')
for i in l[2:]:
  print(i)
      

Measured memory_bytes: 34788
#include<bits/stdc++.h>
using namespace std;
char s[2000010];
int sum[2000010],N,mx[2000010];
int calc(int x){
	int p = 0;
	for (int i=1; i<=N; i++){
		if (s[i] == '1') sum[i] = sum[i-1] + 1;
		else if (s[i] == '0') sum[i] = sum[i-1] - 1;
		else {
			if (mx[i] + 2*(p+1) <= x){
				sum[i] = sum[i-1] + 1, p++;
			}
			else sum[i] = sum[i-1] - 1;
		} 
	}
	int mn = N;
	for (int i=0; i<=N; i++) mn = min(mn,sum[i]);
	return mn;
}
int main(){
	scanf("%s",s+1);
	N = strlen(s+1);
	for (int i=1; i<=N; i++){
		if (s[i] == '1'){
			sum[i] = sum[i-1]+1;
		} else sum[i] = sum[i-1]-1;
	}
	mx[N] = sum[N];
	for (int i=N-1; i>=0; i--) mx[i] = max(mx[i+1],sum[i]);
	int m = mx[0];
	printf("%d\n",min( m-calc(m), m+1-calc(m+1) ));
	return 0;
}

Measured memory_bytes: 12592
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define int long long
using namespace std;

const int P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  int answer = 0;
  answer = N*100/108;
  if(answer*108/100==N)
  {
    cout << answer << endl;
  }
  else if((answer+1)*108/100==N)
  {
    cout << answer+1 <<endl;
  }
  else
  {
    cout << ":(" <<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll w, a, b; cin >> w >> a >> b;
    if(a>b) swap(a, b);
    ll ans = b - (a+w);
    cout << max(ans, 0LL) << endl;  
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
int main (){
    long long n,b,sum = 0;
    long long mi = 1000000,ma = -1000000;
    cin>>n;
    for (int i = 0; i < n; i++) {
        cin >> b;
        mi = min(mi, b);
        ma = max(ma, b);
        sum+=b;
    }
    cout <<mi<<" "<<ma<<" "<<sum<<endl;
    return 0;
}




Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
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; }
int Inf = (1<<30);
ll inf = (1LL<<60);
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
	int n;
	cin >> n;
	int k;
	cin >> k;
	int ans = 0;
	while (n) {
		n /= k;
		ans++;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <complex>

#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,n) for(int i=0;i<(n); i++)


using namespace std;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(0); //この2行はより速度を向上させる
	// 追加２, 以降 cin の入力元が 'input.txt' になる
	//提出時に消す！！
	//std::ifstream in("sample.txt");
	//std::cin.rdbuf(in.rdbuf());

	int n;
	cin>>n;
	int F[50];
	F[0]=F[1]=1;
	for(int i=2;i<=n;i++) F[i]=F[i-1]+F[i-2];

	cout << F[n] << endl;

	return 0;
}



Measured memory_bytes: 3224
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;

int used_pc_num[10000][1261];
int use_status[10000][1261];
int main(){
  while(true){
    int N;
    int M;
    cin >> N >> M;
    if(N == 0 && M == 0){
      break;
    }

    for(int i = 0; i < M; i++){
      for(int j = 0; j < 1261; j++){
        used_pc_num[i][j] = 0;
        use_status[i][j] = 0;
      }
    }

    int r;
    cin >> r;
    for(int i = 0; i < r; i++){
      int t;
      int n;
      int m;
      int s;
      cin >> t >> n >> m >> s;
      if(s == 0){
        used_pc_num[m - 1][t] --;
      } else {
        used_pc_num[m - 1][t] ++;
      }
    }

    for(int i = 0; i < M; i++){
      for(int j = 1; j < 1261; j++){
        used_pc_num[i][j] += used_pc_num[i][j - 1];
      }
    }

    for(int i = 0; i < M; i++){
      for(int j = 0; j < 1261; j++){
        if(used_pc_num[i][j] > 0){
          use_status[i][j] = 1;
        }
      }
    }

    for(int i = 0; i < M; i++){
      for(int j = 1; j < 1261; j++){
        use_status[i][j] += use_status[i][j - 1];
      }
    }

    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
      int ts;
      int te;
      int m;
      cin >> ts >> te >> m;
      cout << use_status[m - 1][te - 1] - use_status[m - 1][ts - 1] << endl;
    }

    
  }
  return 0;
}


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

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

    int cnt = s.size();
    rep(i, 0, s.size() - 1)
    if (s[i] == s[i + 1])
    {
        char now = s[i];
        int num = 1;
        while (i + 1 < s.size() and s[i + 1] == now)
        {
            ++num;
            ++i;
        }


        cnt -= (num / 3);
        if (num % 3 == 2)
        {
            --cnt;
            ++i;
        }
        // cout << i << ' ' << cnt << ' ' << num << endl;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

const int MAX_N = 444444;

int prime[MAX_N];
bool is_prime[MAX_N + 1];
void sieve(int n){
    int p = 0;
    for(int i = 0; i <= n; i++) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i <= n; i++){
        if(is_prime[i]){
            prime[p++] = i;
            for(int j = 2*i; j <= n; j += i) is_prime[j] = false;
        }
    }
}

int sum[444444];

signed main(){
    sieve(444444);
    rep(i, 1, 444444){
        sum[i] = sum[i - 1];
        if(is_prime[i]) sum[i]++;
    }
    while(1){
        int n;
        cin >> n;
        if(n == 0) break;
        cout << sum[2 * n] - sum[n] << endl;
    }
}

Measured memory_bytes: 7276
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
#include<limits.h>

typedef long long ll;

int max(int a,int b){
    if(a>b) return a;
    else return b;
}

int min(int a,int b){
    if(a<b) return a;
    else return b;
}

/*qsort(array,num_of_index,sizeof(int),compare_int); */
 int compare_int(const void *a,const void *b){
     return *(int*) a - *(int *) b; 
 } 
 
int main(){
    char S[1002];
    scanf("%s",S);
    if(S[strlen(S)-1] == 's')
        printf("%ses",S);
    else
        printf("%ss",S);
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, ll> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


vpair edges[100005];
vll d;
void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P>> que;
    d[s] = 0;
    que.push(P(0, s));

    while (que.size()) {
        P p = que.top();
        que.pop();
        int v = p.se;
        if (d[v] < p.fi) continue;
        for (auto e : edges[v]) {
            if (d[e.fi] > d[v] + e.se) {
                d[e.fi] = d[v] + e.se;
                que.push(P(d[e.fi], e.fi));
            }
        }
    }
}

int main() {
    int n;
    cin >> n;
    d.resize(n, LINF);
    rep(i, n-1) {
        int a, b, c;
        cin >> a >> b >> c;
        --a;
        --b;
        edges[a].emplace_back(b, c);
        edges[b].emplace_back(a, c);
    }
    int q, k;
    cin >> q >> k;
    --k;
    dijkstra(k);
    rep(i, q) {
        int x, y;
        cin >> x >> y;
        --x;
        --y;
        cout << d[x]+d[y] << endl;
    }

    return 0;
}

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

#define rep(i,a,n) for (int i = a;i<=n;++i)
#define per(i,a,n) for (int i = n;i>=a;--i)
#define all(x) (x).begin(), (x).end()     
#define SZ(x) ((int)x.size())

typedef vector<int> VI;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef long double ld;

mt19937 mrand(random_device{}());
ll rnd(ll a, ll b) { return a + mrand() % (b - a + 1); }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll mod = 1e9 + 7;
ll add(ll a, ll b) { return (a + b + mod) % mod; }

int main() {
      ios::sync_with_stdio(false); cin.tie(0);
#ifdef arrias
      freopen("a.txt", "r", stdin);
#endif
      ll n, k;
      cin >> n >> k;
      // 0 ... n 
      
      ll ans = 0;
      rep(i, k, n + 1) {
            ll num = i;
            ll L = (num * (num - 1)) / 2;
            ll c = n - i + 1;
            ll R = ((c + n) * num) / 2;
            ans = add(ans, add(R, -L + 1));
      }
      cout << ans << "\n";

      return 0;
}

Measured memory_bytes: 3664
import java.util.Scanner;

class Main{
public static void main(String[] args){

 int a;
 int hou;
 int min;
 int sec;
Scanner s = new Scanner(System.in);
    a=s.nextInt();
    hou=a/3600;
    min=a%3600/60;
    sec=a%3600%60;


System.out.println(hou+":"+min+":"+sec);}

}


Measured memory_bytes: 26152
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n, k;
		wh: while (true) {
			n = Integer.parseInt(sc.nextLine());
			String[] clist = new String[n];
			if (n == 0) {
				break;
			}
			for (int i = 0; i < n; i++) {//すべての空港名をフルコード変換して配列に入れる。
				clist[i] = makeCode(sc.nextLine());
			} //end for i

			kfor: for (k = 1; k <= 51; k++) {
				ifor: for (int i = 0; i < n; i++) {
					jfor: for (int j = i + 1; j < n; j++) {
						if (clist[i].substring(0, Math.min(clist[i].length(), k))
								.equals(clist[j].substring(0, Math.min(clist[j].length(), k)))) {//部分が同じ場合
							continue kfor;
						}
					}
				}
				System.out.println(k);

				continue wh;
			}

			System.out.println("-1");

		}

		sc.close();
	}

	public static String makeCode(String name) {
		String code = "";
		code += name.charAt(0);
		for (int i = 0; i < name.length() - 1; i++) {
			if (name.charAt(i) == 'a' || name.charAt(i) == 'i' || name.charAt(i) == 'u' || name.charAt(i) == 'e'
					|| name.charAt(i) == 'o') {
				code += name.charAt(i + 1);
			}
		}
		return code;
	}

}



Measured memory_bytes: 44920
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define for0(n) for(i=0; i<(n); i++)
#define for1(n) for(i=1; i<=(n); i++)


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll _,i,j,n,a,b,e,k,u,t,x=1,m,y,q,f=1,c=0,d=0,l,p,z,o,r,g;
    string ss,s;
    n=5;
    for1(n)
    {
        cin>>x;
        if(!x)c=i;
    }
    cout<<c<<endl;
}



Measured memory_bytes: 3580
#include <iostream>
#include <utility>
#include <map>
using namespace std;

int main() {
  int n;
  cin >> n;
  map<pair<int, int>, int> m;
  int now = 1;
  for (int i = 0; i <= 180; i += 30) {
    for (int j = 100; j <= 500; j += 100) {
      m[make_pair(j, i)] = now++;
    }
  }
  for (int i = 0; i < n; ++i) {
    int r, t;
    cin >> r >> t;
    if (r % 100 == 0 && t % 30 == 0) {
      cout << m[make_pair(r, t)] << endl;
    } else if (t % 30 == 0) {
      cout << m[make_pair(r / 100 * 100, t)] << " " << m[make_pair((r + 100) / 100 * 100, t)] << endl;
    } else if (r % 100 == 0) {
      cout << m[make_pair(r, t / 30 * 30)] << " " << m[make_pair(r, (t + 30) / 30 * 30)] << endl;
    } else {
      cout << m[make_pair(r / 100 * 100, t / 30 * 30)] << " " << m[make_pair((r + 100) / 100 * 100, t / 30 * 30)] 
        << " " << m[make_pair(r / 100 * 100, (t + 30) / 30 * 30)] << " " << m[make_pair((r + 100) / 100 * 100, (t + 30) / 30 * 30)] << endl;
    }
  }
}

Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fr first
#define sc second
const int mod = 1e9+7;
const int N = 1e6+6;
int n;
void go(string s, char c){
    if(n==s.size()){
        cout<<s<<endl;
        return ;
    }
    for(char nxt = 'a';nxt<c;nxt++){
        go(s+nxt,c);
    }
    go(s+c,c+1);
}
int main(){
    cin>>n;
    go("",'a');
}


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

int main(){
    int n,c=0;
    cin>>n;
    vector<int>a(10000000);
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]!=i+1){
            c++;
        }
    }
    if(c<3){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }

   return 0;
}

Measured memory_bytes: 39296
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
#include<set>

#define ll long long int
#define MOD 1000000007
#define pb push_back
#define ub upper_bound
#define lb lower_bound

using namespace std;

int main(){
    int n,r;
    int c[50];
    int cp[50];
    int com1,com2;
    int cnt=0;
    while(1){
        cin >> n >> r;
        for(int i=0;i<50;i++){
            c[i]=n-i;
        }
        if(n==0||r==0){
            break;
        }
        
        for(int i=0;i<r;i++){
            for(int i=0;i<50;i++){
                cp[i]=0;
            }
            cin >> com1 >> com2;
            cnt=0;
            for(int i=com1-1;i<com1-1+com2;i++){
                cp[cnt]=c[i];
                cnt++;
            }
            for(int i=com1-2;i>-1;i--){
                c[i+com2]=c[i];
            }
            for(int i=0;i<com2;i++){
                c[i]=cp[i];
            }
        }
        cout << c[0] << endl;
    }
    return 0;
}



Measured memory_bytes: 3076
while True:
    h, w = map(int, input().split())
    if h ==0 and w==0:
        break
    else:
        for i in range(h):
            for ii in range(w):
                if i == 0 or i == h-1:
                    print("#", end="")
                elif ii == 0 or ii == w-1:
                    print("#", end="")
                else:
                    print(".", end="")
            print()
        print()


Measured memory_bytes: 7000