akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

fn main() {
    let _: usize = util::get();
    let s: Vec<bool> = util::line().chars().map(|c| c == 'o').collect();

    let ans = [vec![true, true],
               vec![true, false],
               vec![false, true],
               vec![false, false]]
            .into_iter()
            .cloned()
            .map(|mut seq| {
                     for &x in &s {
                         let (a, b) = (seq[seq.len() - 2], seq[seq.len() - 1]);
                         let c = a ^ b ^ x;
                         seq.push(c);
                     }
                     seq
                 })
            .find(|seq| seq[0] == seq[seq.len() - 2] && seq[1] == seq[seq.len() - 1])
            .map(|mut seq| {
                     seq.remove(0);
                     seq.pop();
                     seq
                 });

    if let Some(seq) = ans {
        println!("{}",
                 seq.into_iter()
                     .map(|b| if b { 'S' } else { 'W' })
                     .collect::<String>());
    } else {
        println!("-1");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef double db;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> pll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(a) cout << a << endl
#define exout(a) printf("%.10f\n", a)
#define re0 return 0
#define pb push_back
const ll mod = 1000000007;
const ll INF = 1e16;

int main() {
    ll n; 
    db a, b, c = 0, ans;
    cin >> n;
    
    rep(i, n) {
        cin >> a;
        b = 1.0/a;
        c += b;
    }

    ans = 1.0/c;

    exout(ans);
    re0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		// input
		final int NUM = scan.nextInt();
		String[] words = new String[NUM];
		for(int i = 0; i < NUM; i++){
			String input = scan.next();
			char[] inputChar = input.toCharArray();
			Arrays.sort(inputChar);
			words[i] = new String(inputChar);
		}
		Arrays.sort(words);
		
		//check
		String memory = words[0];
		long count =1;
		long answer = 0;
		for(int i = 1; i < NUM; i++){
			if(memory.equals(words[i])){
				count++;
			} else {
				answer += count * (count - 1) / 2;
				memory = words[i];
				count =1;
			}
		}
		if(count >= 2){
			answer += count * (count - 1) / 2;
		}
		
		System.out.println(answer);
	}
}

Measured memory_bytes: 52760
#include <stdio.h>
#include <iostream>
using namespace std;

int main(void)
{		
	int n, a[100];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	for (int j = n - 1; j > 0; j--) {
		cout << a[j] << " ";
	}
	
	cout << a[0] << endl;
	
	return 0;
}

Measured memory_bytes: 3096
#include<stdio.h>
     
    int main() {
      int N;
      char S[100] = {'\0'};
      int right[26] = {0};
      int left[26] = {0};
      int i, j;
      int max = 0;
      int num_tmp;
      
      scanf("%d", &N);
      scanf("%s", S);
      
      for (i = 0; i < N; i++) {
        num_tmp = 0;
        for (j = 0; j < 26; j++) {
          right[j] = 0;
          left[j] = 0;
        }
        for (j = 0; j < i; j++) {
          right[ S[j] - 'a' ] = 1;
        }
        for (j = i; j < N; j++) {
          left[ S[j] - 'a' ] = 1;
        }
        for (j = 0; j < N; j++) {
          if (right[j] == 1 && left[j] == 1) {
            num_tmp += 1;
          }
        }
        
        if (max < num_tmp) {
          max = num_tmp;
        }
      }
      
      printf("%d\n", max);
      
      return 0;
    }

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		int[] A = new int[n];
		for(int i = 0; i < n; i++) {
			A[i] = scan.nextInt();
		}

		int count = 0;

		for(int i = 0; i < n; i++) {
			for(int j = n - 1; j >i;j--) {
				if(A[j]< A[j-1]) {
					int temp = A[j];
					A[j] = A[j-1];
					A[j-1]=temp;
					count++;
				}
			}
		}

		for(int i = 0; i < n; i++) {
			if(i==0) {
				System.out.print(A[i]);
			}
			else {
				System.out.print(" " + A[i]);
			}
		}
		System.out.println();
		System.out.println(count);

	}
}


Measured memory_bytes: 26348
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
#include<stack>
#include<tuple>
#include<numeric>
#include<cassert>

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
#define DEBUG false

using namespace std;

using ll = long long;
using P = pair<int,int>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60;
const int MAX_N = 100005;
const ll lmod = 1e9+7;

int a[MAX_N],b[MAX_N],c[MAX_N];
ll bp[MAX_N];

int main(){
  int N; cin >> N;
  rep(i,N) scanf("%d",a+i);
  rep(i,N) scanf("%d",b+i);
  rep(i,N) scanf("%d",c+i);
  sort(a,a+N);
  sort(b,b+N);
  sort(c,c+N);
  ll ans = 0LL;
  int flag = 0;
  rep(i,N){
    int temp = b[i];
    while(1){
      if(flag==N) break;
      if(c[flag]>temp) break;
      flag++;
    }
    bp[i] = ll(N - flag);
  }
  ll _sum = 0LL;
  for(int i = N-1;i>=0;i--){
    _sum += bp[i];
    bp[i] = _sum;
  }
  flag = 0;
  rep(i,N){
    int temp = a[i];
    while(1){
      if(flag==N) break;
      if(b[flag]>temp) break;
      flag++;
    }
    ans += ll(bp[flag]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
string a;
int main()
{
    int left,right;
    cin>>a;
    for(int i=0;i<a.length();i++)
        if(a[i]=='A')
		{
            left=i;
            break;
        }
    for(int i=a.length()-1;i>=0;i--)
        if(a[i]=='Z')
		{
            right=i;
            break;
        }
    cout<<right-left+1<<endl;
    return 0; 
} 

Measured memory_bytes: 768
/* 
 Author:N_o_o_B 
 Created:November 18 2019 19:13:27
*/
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;
    int n,t;
    cin >> n >> t;
    trace(n,t);
    vii a(n);
    fori(i,n) {cin >> a[i].fi >> a[i].se;if(a[i].fi!=1 and a[i].se!=1) trace(a[i]);}
    vvl dp(n+1,vl(t+1));
    sort(all(a));
    ford(i,n){
        fori(j,t+1){
            if(j){
                dp[i][j]=max(dp[i+1][j],dp[i+1][max(0,j-a[i].fi)]+a[i].se);
            }
        }
    }
    cout << dp[0][t] << endl;

    time_taken();
    return 0;
}

Measured memory_bytes: 70784
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <vector>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
typedef long long ll;
const int maxn=1e5+50;
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
const int HASH=131;

ll quick_pow(int a,int b)
{
	ll base=a%MOD;
	ll ans=1;
	while(b>0)
	{
		if(b&1) ans=ans*base%MOD;
		base=base*base%MOD;
		b>>=1;
	}
	return ans;
}


int main()
{
    int n;
    cin>>n;
    ll ans=(quick_pow(10,n)+quick_pow(8,n)-2*quick_pow(9,n)+2*MOD)%MOD;
    cout<<ans<<endl;
}


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

int main(){
    int n;
    int a[100];
    
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cout<<a[i];
        if(i==n-1) cout<<endl;
        else cout<<' ';
    }
    for(int i=1;i<n;i++){
        int j=i-1;
        int key=a[i];
        while(j>=0 && a[j]>key){
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=key;
        for(int i=0;i<n;i++){
        cout<<a[i];
        if(i==n-1)cout<<endl;
        else cout<<' ';
    }
}
}


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

const int N = 3e5 + 10, p = 1e9 + 7;
int f[N][3][3];
char s[N];

void add(int &x, int y) { x += y; if (x >= p) x -= p; }

int main() {
	scanf("%s", s + 1); int n = strlen(s + 1);
	f[0][0][0] = 1;
	for (int i = 0; i < n; ++ i) {
		for (int j = 0; j < 3; ++ j) {
			for (int k = 0; k < 3; ++ k) {
				if (s[i + 1] != '0') {
					if (k) add(f[i + 1][j][k - 1], f[i][j][k]);
					else add(f[i + 1][std::min(j + 1, 2)][k], f[i][j][k]);
				}
				if (s[i + 1] != '1') {
					if (k == 2) add(f[i + 1][j][1], f[i][j][k]);
					else add(f[i + 1][j][k + 1], f[i][j][k]);
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i <= 2; ++ i) {
		for (int j = 0; j <= i; ++ j) {
			add(ans, f[n][i][j]);
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

vector<pair<char, int>> encode(string str) {
    vector<pair<char, int>> ret;
    str += '#';
    int cnt = 1;
    rep(i, 1, str.size()) {
        if (str[i] != str[i - 1]) {
            ret.push_back(make_pair(str[i - 1], cnt));
            cnt = 1;
        } else {
            cnt++;
        }
    }
    return ret;
}

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

    vector<pair<char, int>> v = encode(s);
    bool same = true;
    rep(i, 0, s.size() - 1) {
        if (s[i] != s[i + 1]) same = false;
    }
    int x = 0;
    for (auto i : v) {
        x += i.second / 2;
    }

    int n = s.size();
    ll ans = 0;
    if (same) ans = (ll)k * n / 2;
    else {
        if (s[0] == s[n - 1]) {
            if (v[0].second % 2 == 1 && v.back().second % 2 == 1) ans = (ll)k * x + k - 1;
            else ans = (ll)k * x;
        } else ans = (ll)k * x;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from itertools import accumulate
def myAnswer(N:int,A:list) -> int:
   accum = [A[0]]
   accumRev = [sum(A)]
   ans = 10**10
   for i in range(1,N):
      accumRev.append(accumRev[-1] - A[i-1])
      accum.append(accum[-1]+A[i])
   for i in range(len(accum)-1):
      ans = min(ans,abs(accumRev[i+1] - accum[i]))
   return ans
      
def modelAnswer(N:int,A:list) -> int:
   T1 = [A[0]]
   T2 = [sum(A)]
   for i in range(1,N): # O(N)
      T1.append(T1[-1]+A[i])
      T2.append(T2[0] - T1[i-1])
   # print(T1,T2)
   ans = 10**10
   for i in range(len(T1)-1): # O(N/2)
      # print(abs(T1[i]-T2[i+1]))
      ans = min(ans,abs(T1[i]-T2[i+1]))
   return ans


def main():
   N = int(input())
   A = list(map(int,input().split()))
   # print(modelAnswer(N,A[:]))
   # print("-----------------------------")
   print(myAnswer(N,A[:]))
if __name__ == '__main__':
   main()


Measured memory_bytes: 33704
#include <ext/pb_ds/assoc_container.hpp> 	// Common file
#include <ext/pb_ds/tree_policy.hpp> 		// Including tree_order_statistics_node_update
#include<bits/stdc++.h>
#define int            		long long
#define x              		first
#define y              		second
#define all(aaa)       		(aaa).begin(),(aaa).end()
#define REP(i,sss,eee) 		for(int i=sss;i<=eee;++i)
#define pb             		push_back
#define pii            		pair<int,int>
#define vi             		vector<int>
#define speed          		ios_base::sync_with_stdio(0);cin.tie(0);
#define N              		1000000007
#define inf					1000000000000000000
using namespace __gnu_pbds;
using namespace std;
template <class T>
T MAX(T a, T b){return ((a>b)?a:b);}
template <class T>
T MIN(T a, T b){return ((a<b)?a:b);}
template <class T>
T MOD(T a){return ((a>=0)?a:(-1*a));}
template <class T>
void SWAP(T &a,T &b){T temp=a;a=b;b=temp;}

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

inline int ex(int a, int b){
	if(b==0||a==1){return 1;}
	if(a==0||b==1){return a;}
	int tmp=ex(a,(b/2));
	if(b%2){return ((((tmp*tmp)%N)*a)%N);}
	else{return ((tmp*tmp)%N);}
}
inline int inv(int k){
	if(k==1){return 1;}
	else{return ex(k,N-2);}
}
/*****************default********************/
int solve()
{
	int a,b;cin>>a>>b;
	int k;cin>>k;
	int min=MIN(a,b);
	for(int i=min;i>=1;--i)
	{
		if(a%i==0&&b%i==0){--k;if(k==0){cout<<i<<"\n";return 0;}}
	}
}
signed main(){
	speed
	int tt=1;
	//cin>>tt;
	while(tt--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
import math

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

if x == (a*a*b):
    print("0")
elif x > (a*a*b)/2:
    h = (2*x)/(a*a)-b
    kaku = 90 - math.degrees(math.atan(a/(b-h)))
    print(kaku)
else:
    h = (2*x)/(a*b)
    kaku = 90 - math.degrees(math.atan(h/b))
    print(kaku)

Measured memory_bytes: 3188
import numpy as np
N, L = map(int, input().split())

aji = np.array([L + i for i in range(N)])

min_diff = 10e20
for i in range(N):
    diff = abs(aji[i])
    if diff < min_diff:
        min_diff = diff
        true_aji = sum(aji) - aji[i]

print(true_aji)

Measured memory_bytes: 12448
#include<cstdio>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;

int main(){
	int N, M;
	scanf("%d %d", &N, &M);
	pair<int, int> id[M];
	vector<pair<int, int> > comprise[N];
	for (int i = 0; i < M; ++i){
		int prefecture, birth;
		scanf("%d %d", &prefecture, &birth);
		id[i].first = prefecture;
		prefecture--;
		comprise[prefecture].push_back(make_pair(birth, i));
	}
	for (int i = 0; i < N; ++i){
		sort(comprise[i].begin(), comprise[i].end());
		for (int j = 0; j < comprise[i].size(); ++j){
			id[comprise[i][j].second].second = j + 1;
		}
	}
	for (int i = 0; i < M; ++i){
		printf("%06d%06d\n", id[i].first, id[i].second);
	}
	return 0;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long 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;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

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

    vector<ll> H(N);
    REP(i, N) cin >> H[i];

    H[0] -= 1;
    ll ma = H[0];
    REP(i, N - 1){
        if(ma < H[i + 1]) {
            H[i + 1] -= 1;
        }
        chmax(ma,H[i + 1]);
    }

    bool ans = true;
    REP(i, N-1){
        if(H[i] > H[i+1]) {
            ans = false;
            break;
        }
    }

    Yes(ans)

    return 0;
}


Measured memory_bytes: 1024
s,t =input().split()
a,b =map(int,input().split())
u = input()

if s == u and t == u:
  print(a-1,b-1)
elif s == u:
  print(a-1,b)
elif t == u:
  print(a,b-1)
else:
  print(a,b)

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

int main(int argc, char *argv[])
{
    int n;
    char mcxi[] = {'m', 'c' ,'x', 'i'};
    string num;
    cin >> n;
    while (n--) {
        vector<pair<char, int> > vp;
        for (int i = 0; i < 4; ++i)
            vp.push_back(make_pair(mcxi[i], 0));
        for (int i = 0; i < 2; ++i) {
            cin >> num;
            for (int j = 0; j < num.size(); ++j) {
                if (num[j] > 'a' && num[j] < 'z') {
                    for (int k = 0; k < 4; ++k) {
                        if (num[j] == vp[k].first) {
                            if (j-1 >= 0 && num[j-1] > '0' && num[j-1] <= '9')
                                vp[k].second += num[j-1] - '0';
                            else
                                vp[k].second++;
                        }
                    }
                }
            }
        }
        for (int i = 3; i >= 0; --i) {
            if (vp[i].second > 9) {
                vp[i-1].second++;
                vp[i].second %= 10;
            }
        }
        for (int i = 0; i < 4; ++i) {
            if (vp[i].second == 0)
                continue;
            else if (vp[i].second == 1)
                cout << vp[i].first;
            else
                cout << vp[i].second << vp[i].first;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1204
#include<iostream>
#include<algorithm>

using namespace std;
int main(){
int N;
cin >> N;
int W;
cin >>W;
long long weight[110],value[110];
for(int i=0;i<N;i++){
cin >>weight[i]>>value[i];
}

long long dp[110][100010];
//初期条件dp[0][W]=0;
  for(int i=0;i<=W;i++){
  dp[0][i]=0;
  }
for(int i=0;i<N;++i){
    for(int w=0;w<=W;++w){
        if(w>=weight[i]){//大きさは範囲内、価値を比較}
            dp[i+1][w]=max(dp[i][w-weight[i]]+value[i],dp[i][w]);
        }else
        {
            dp[i+1][w]=dp[i][w];//重さが大きすぎるので選ばない。
        }
        
    }
}
cout << dp[N][W]<<endl;

 return 0;
}

Measured memory_bytes: 80384
#include<stdio.h>
main(){
	int n,x;
	int i,j,k;
	int num;
	int sum;

	while(1){
		num = 0;
		scanf("%d %d",&n,&x);
		if(n == 0 && x == 0) break;
		for(i=1;i<=n;i++){
			for(j=i+1;j<=n;j++){
				for(k=j+1;k<=n;k++){
					sum = i+j+k;
					if(sum == x){
						num++;
						// printf("%d %d %d\n",i,j,k);
					}
				}
			}
		}
		printf("%d\n",num);
	}
	return 0;
}

Measured memory_bytes: 1028
N=int(input())

if (N%4)==0:
    print("Yes")
elif(N%7)==0:
    print("Yes")
elif(N%11)==0:
    print("Yes")
elif(1):
    while N>0:
        i=1
        N=N-11*i
        if(N<0):
            print("No")
            break
        if(N%4)==0 or (N%7)==0:
            print("Yes")
            break
        i=i+1

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

int main(){
  int N,M,Q;
  cin >> N >> M >> Q;
  vector< int > a(50), b(50), c(50), d(50), m(10);
  REP(i,Q) {
    cin >> a[i]  >> b[i]  >> c[i]  >> d[i] ;
    a[i]--; b[i]--;
  }
  
  REP(i,10) {
    if ( i < M ) m[i] = M+1;
    else m[i] = 0;
  }
  vector< int > A(10,0);
  int ans = 0;
  for (A[0]=1; A[0]<M+1; A[0]++ )
    for( A[1]=A[0]; A[1]<M+1; A[1]++ )
      for( A[2]=A[1]; A[2]<M+1; A[2]++ )
        for( A[3]=A[2]; A[3]<M+1; A[3]++ )
          for( A[4]=A[3]; A[4]<M+1; A[4]++ )
            for( A[5]=A[4]; A[5]<M+1; A[5]++ )
              for( A[6]=A[5]; A[6]<M+1; A[6]++ )
                for( A[7]=A[6]; A[7]<M+1; A[7]++ )
                  for( A[8]=A[7]; A[8]<M+1; A[8]++ )
                    for( A[9]=A[8]; A[9]<M+1; A[9]++ ) {
                      int sum = 0;
                      REP(i,Q) {
                        if ( A[b[i]]-A[a[i]] == c[i] ) sum += d[i];
                      }
                      ans = max( ans, sum );
                    }

  cout << ans << endl;
}


Measured memory_bytes: 3636
#include<stdio.h>

int main(void)


{


int W,H,x,y,r;


scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);


if(!(-100<=x&&x<=100)){


return 0;


}


if(!(-100<=x&&x<=100)){


return 0;


}

if(!(-100<=y&&y<=100)){


return 0;


}

if(!(0<W&&W<=100)){


return 0;


}

if(!(0<H&&x<=100)){


return 0;


}

if(!(0<r&&r<=100)){


return 0;


}


if(y+r<=H &&  y-r>=0 && x+r<=W && x-r>=0){


printf("Yes\n");


}


else{


printf("No\n");


}


return 0;


}

Measured memory_bytes: 584
import sys
from math import gcd
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
mx = max(a)
table = [0] * (mx + 1)
for x in a: table[x] += 1
g = 0
for x in a: g = gcd(g, x)
for i in range(2, mx + 1):
  c = 0
  for j in range(i, mx + 1, i): c += table[j]
  if c > 1:
    if g == 1: print("setwise coprime")
    else: print("not coprime")
    exit(0)
print("pairwise coprime")

Measured memory_bytes: 193136
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n; cin>>n;
    ll wa=0,tle=0,ac=0,re=0;
    while(n--)
    {
        string s; cin>>s;
        if(s=="WA") wa++;
        else if(s=="AC") ac++;
        else if(s=="TLE") tle++;
        else if(s=="RE") re++;
    }
    cout<<"AC x "<<ac<<"\n";
    cout<<"WA x "<<wa<<"\n";
    cout<<"TLE x "<<tle<<"\n";
    cout<<"RE x "<<re<<"\n";
    return 0;
}

Measured memory_bytes: 3628
program main
   implicit none
   integer(8)::n,i
   real(8)::su,u
   character(3) a
   read(*,*)n
   su=0
   do i=1,n
      read(*,*)u,a
      if(a=="JPY")then
         su=su+u
      else
         su=su+u*380000.0
      endif
   enddo
   write(*,*)su
end program main


Measured memory_bytes: 512
N = int(input())
C = input()

r_cnt = 0
for c in C:
    if c == 'R':
        r_cnt += 1

ans = r_cnt
r2w = r_cnt
w2r = 0

for c in C:
    if c == 'W':
        w2r += 1
    elif c == 'R':
        r2w -= 1
    ans = min(ans, max(r2w, w2r))
print(ans)



Measured memory_bytes: 9376
n = int(input())
L = []
for i in range(n):
  s = input()
  cur = []
  for j in range(10):
    cur.append(s[j])
  cur.sort()
  t = ''
  for j in range(10):
    t += cur[j]
  L.append(t)
L.sort()
ans = 0
L.append('end')
temp = 1
for i in range(1,n+1):
  if L[i] != L[i-1]:
    ans += temp*(temp-1)//2
    temp = 1
  else:
    temp += 1
print(ans)

Measured memory_bytes: 59864
def main():
    n, k = map(int, input().split())
    a = list(map(lambda x: int(x)-1, input().split()))
    visited = [0]
    visited_set = {0}
    now = 0
    for i in range(2*n):
        now = a[now]
        if now in visited_set:
            break
        else:
            visited.append(now)
            visited_set.add(now)
    l = len(visited)
    v = visited.index(now)
    if k < v:
        print(visited[k]+1)
    else:
        k -= v
        k %= (l-v)
        k += v
        print(visited[k]+1)


main()


Measured memory_bytes: 32348
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
int n; cin >> n;
cout << 180*(n-2)<< endl;
}


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

int main(){
  int A,B,C;cin>>A>>B>>C;
  int K;cin>>K;
  rep(i,K){
    if(A>=B) B*=2;
    else if(B>=C) C*=2;
    else C*=2;
  }
  if(A<B && B<C) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

 using namespace std;

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

   vector<vector<int>> X(N, vector<int>(D));

   for (int i = 0; i < N; i++) {
     for (int j = 0; j < D; j++) {
       cin >> X.at(i).at(j);
     }
   }

   double distance2;
   int counter = 0;

   for (int i = 0; i < N - 1; i++) {
     for (int j = i + 1; j < N; j++) {
       distance2 = 0;
       for (int k = 0; k < D; k++) {
         distance2 += (X.at(i).at(k) - X.at(j).at(k)) * (X.at(i).at(k) - X.at(j).at(k));
       }
       if (sqrt(distance2 * 1.0) == (int)sqrt(distance2 * 1.0)) counter++;
     }
   }

   cout << counter << endl;
}


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

#define forn(i,m,n) for(int i=m;i<n;i++)
#define vv vector
#define vi vv<int>
#define ii pair<int,int>
#define vii vv<ii>
#define mp make_pair
#define pb push_back
#define PI 3.141592653589
#define ll long long
#define pll pair<ll,ll>
#define vl vv<ll>
#define ff first
#define ss second
#define MOD 1000000007

bool is_prime[1000001];
vi prime;
void sieve(int n)
{
    memset(is_prime,true,sizeof(is_prime));
    for(int i=2;i*i<=n;i++)
    {
        if(is_prime[i])
        {
            for(int j=i*i;j<=n;j+=i)
            {
                is_prime[j]=false;
            }
        }
    }
    forn(i,2,n+1)
    {
        if(is_prime[i])
            prime.pb(i);
    }
}


ll ex(ll a,ll b)
{
    ll res=1;
    a=a%MOD;
    while(b)
    {
        if(b%2){res=(res*a)%MOD;b--;}
        b/=2;
        a=(a*a)%MOD;
    }
    return res;
}

ll fermat_inv(ll a){ return ex(a,MOD-2); }
ll max(ll a,ll b){ return a>b?a:b; }
ll min(ll a,ll b){ return a<b?a:b; }


int main()
{
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        #ifndef ONLINE_JUDGE
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
        #endif
    //sieve(1000000);
    int te=1;
    //cin>>te;
    while(te--)
    {
        int n,m;
        cin>>n>>m;
        ll dp[n][m];
        char ch;
        forn(i,0,n)
        {
            forn(j,0,m)
            {
                cin>>ch;
                if(i==0 && j==0)
                    dp[i][j]=1;
                else
                {
                    if(ch=='.')
                    {
                        dp[i][j]=0;
                        if(j-1>=0 && dp[i][j-1]!=-1)
                            dp[i][j]+=dp[i][j-1];
                        if(i-1>=0 && dp[i-1][j]!=-1)
                            dp[i][j]+=dp[i-1][j];
                        dp[i][j]%=MOD;
                    }
                    else
                        dp[i][j]=-1;
                }
            }
        }
        cout<<dp[n-1][m-1];        
    }
}


Measured memory_bytes: 11384
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    string S;
    cin >> S;
    const string keyence = "keyence";
    const int removeNum = S.length() - keyence.length();
    for (int i = 0; i + removeNum < S.length(); ++i)
    {
        const string T = S.substr(0, i) + S.substr(i + removeNum);
        if (T == keyence)
        {
            cout << "YES" << endl;
            return;
        }
    }
    cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

template<typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
    fill((T*)array,(T*)(array+N),val);
}

const int MOD = INF+7;

int main(){
    int n;cin>>n;
    ll res = 0;
    REP(i,1,n){
        if(i%3==0)continue;
        if(i%5==0)continue;
        res += i;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3196
import itertools
import math
n = int(input())
x = []
y = []
for i in range(n):
  sam1, sam2= input().split()
  x.append(int(sam1))
  y.append(int(sam2))
    
a = list(itertools.permutations(range(n)))
kyori = 0
for i in a:
  for j in range(n-1):
    p = int(i[j])
    q = int(i[j+1])
    dx = x[p] - x[q]
    dy = y[p] - y[q]
    tmp = math.sqrt(dx * dx + dy * dy)
    kyori = kyori + tmp
print(kyori / len(a))

Measured memory_bytes: 7972
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long int


signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	cout << n*n*3;
}

Measured memory_bytes: 256
while True:
    x, y = map(int, input().split())
    count = 0
    
    if x == 0 and y == 0:
        break
    if x < y:
        x, y = y, x

    while y > 0:
        x, y = y, x%y
        count += 1
    print(x, count)


Measured memory_bytes: 5612
# Flog 2

N, K = map(int, input().split())
h_list = list(map(int, input().split()))

cost_list = [10**9 for i in range(N+1)] # iまでのコスト最小値

# コスト最小値の生成
cost_list[1] = 0 # 初期化
for i in range(1,N):
    # ステップごとのコスト更新
    for step in range(1,K+1):
        p = i + step
        if p>N:
            continue
        cost = cost_list[i] + abs(h_list[p-1]-h_list[i-1])
        if cost<cost_list[p]: # 小さければコスト更新
            cost_list[p] = cost

print(cost_list[N])


Measured memory_bytes: 56544
from math import *
a,b,h,m = map(int, input().split())
h = h + m/60
theta_h = (h / 12) * 2 * pi
theta_m = (m / 60) * 2 * pi

distance = (a * cos(theta_h) - b * cos(theta_m))**2 + (a * sin(theta_h) - b * sin(theta_m))**2
print(sqrt(distance))


Measured memory_bytes: 62580
S = []
S.append(list(input()))
S.append(list(input()))
S.append(list(input()))

cur = 0 # A's turn
while True:
  #print(S)
  if not S[cur]:
    break
  cur = ord(S[cur].pop(0))-ord('a')
print(chr(ord('A')+cur))


Measured memory_bytes: 38256
N = int(input())

t = input().split()
T = []
for i in range(N):
    T.append(int(t[i]))

M = int(input())

time = []
total = sum(T)
for k in range(M):
    p,x = (int(i) for i in input().split())
    time.append(total - T[p-1] + x)

for i in range(M):
    print(time[i])

Measured memory_bytes: 3064
def solve(s, t):
    return t + s


def main():
    s, t = input().split()
    res = solve(s, t)
    print(res)


def test():
    assert solve("oder", "atc") == "atcoder"
    assert solve("humu", "humu") == "humuhumu"


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 2e9;
const int MOD = 1e9 + 7;

ll gcd(ll a, ll b) {
   if (b == 0) return a;
   return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
   int a, b;
   cin >> a >> b;
   ll ans = lcm(a, b);
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[0] + [float('inf')]*(n-1)
for i in range(n):
    for j in range(max(0,i-k),i):
        dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]))
print(dp[-1])

Measured memory_bytes: 86536
n=int(input())
s=[]
ans=0
for i in range(n):
    x=int(input())
    ans+=x
    if x%10!=0:s.append(x)
s=sorted(s)
if ans%10==0:
    if len(s)>=1:
        print(ans-s[0])
    else:
        print(0)
else:
    print(ans)



Measured memory_bytes: 62396
import sys

def solve(N, T, A, ls_H):
    li = [abs(A-(T-(i*0.006))) for i in ls_H]
    n = li[0]
    for s in li:
        if n > s:
            n = s
    answer = li.index(n)+1 
    return answer

def readQuestion():
    ws = sys.stdin.readline().strip().split()
    N = int(ws[0])
    ws = sys.stdin.readline().strip().split()
    T = int(ws[0])
    A = int(ws[1])
    ws = sys.stdin.readline().strip().split()
    ls_H = list(map(int, ws))
    return (N, T, A, ls_H)

def main():
    print(solve(*readQuestion()))

main()

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}

inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple

struct P {
  int x, y;
  void read(){ scanf("%d%d", &x, &y); }
  inline int dist(const P& a){ return sq(x - a.x) + sq(y - a.y); }
};
int closest_pair(P* a, int n){
  if (n <= 1) return 1 << 30;
  int m = n >> 1;
  int x = a[m].x;
  int d = min(closest_pair(a, m), closest_pair(a + m, n - m));
  inplace_merge(a, a + m, a + n, [](const P& a, const P& b){ return a.y < b.y; });
  deque<P> b;
  for (int i = 0; i < n; i++){
    if (sq(a[i].x - x) >= d) continue;
    for (const auto& bi : b){
      if (sq(a[i].y - bi.y) >= d) break;
      d = min(d, a[i].dist(bi));
    }
    b.push_front(a[i]);
  }
  return d; 
}
P A[500500];
int main()
{
  int n = in();
  for (int i = 0; i < n; i++) A[i].read();
  sort(A, A + n, [](const P& a, const P& b){ return a.x < b.x; });
  cout << closest_pair(A, n) << endl;
  return 0;
}

Measured memory_bytes: 9704
N = int(input())

A1 = [int(x) for x in input().split()]
A2 = [int(x) for x in input().split()]

s = 0
for i in range(N):
    _s = sum(A1[:i+1])
    _s += sum(A2[i:])
    s = max(_s, s)

print(s)

Measured memory_bytes: 3064
#include<iostream>
#include<map>
using namespace std;
map<int,long> m;
main()
{
	int n;cin>>n;int sto=n;
	for(int j=1;j<=n;j++)
	{
		int a=j;
		for(int i=2;i<=a;i++)
		{
			while(a%i==0)a/=i,m[i]+=1;
		}
	}
	long cnt=1LL;
	for(int i=1;i<=sto;i++)
	{
		cnt*=m[i]+1;
		cnt%=(long)(1e9+7);
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
typedef long long LL;
int main() {
  LL Q, H, S, D;
  scanf("%lld%lld%lld%lld", &Q, &H, &S, &D);
  LL N;
  scanf("%lld", &N);
  if (Q * 2 < H) H = Q * 2;
  if (H * 2 < S) S = H * 2;
  if (S * 2 < D) D = S * 2;
  LL ans = N / 2 * D + N % 2 * S;
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 128
local mfl = math.floor

local function comp(a, b)
  return a < b
end

local function lower_bound(ary, x)
  local num = #ary
  if num == 0 then return 1 end
  if not comp(ary[1], x) then return 1 end
  if comp(ary[num], x) then return num + 1 end
  local min, max = 1, num
  while 1 < max - min do
    local mid = mfl((min + max) / 2)
    if comp(ary[mid], x) then
      min = mid
    else
      max = mid
    end
  end
  return max
end

local n = io.read("*n")
local t = {}
for i = 1, n do
  t[i] = io.read("*n")
end
table.sort(t)
local ret = 0
for i = 1, n - 2 do
  for j = i + 1, n - 1 do
    local lb = lower_bound(t, t[i] + t[j]) - 1
    ret = ret + lb - j
  end
end
print(ret)

Measured memory_bytes: 2748
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string l;
    ll ans=0;
    ll o=0;cin>>l;
    ll arr[l.length()][2];
    arr[0][0]=2;
    arr[0][1]=1;
    Fr(i,l.length()-1){
        if(l[i]=='1'){
         arr[i][0]=(arr[i-1][0]*2)%1000000007;   
        }
        else arr[i][0]=arr[i-1][0];
    }
    Fr(i,l.length()-1){
        if(l[i]=='1') arr[i][1]=(arr[i-1][0]+arr[i-1][1]*3)%1000000007;
        else arr[i][1]=(arr[i-1][1]*3)%1000000007;
    }
    cout<<(arr[l.length()-1][1]+arr[l.length()-1][0])%1000000007;}


Measured memory_bytes: 5296
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: u32,
        b: u32,
        c: u32,
        d: u32,
    }
    println!("{}",
        if a + b < c + d {
            "Right"
        } else if a + b > c + d {
            "Left"
        } else {
            "Balanced"
        }
    );
}


Measured memory_bytes: 4352
// デバッグ実行：Ctrl+F5

using System;

class Program
{
    static void Main(string[] args)
    {
        String line;
        line = Console.ReadLine();
        String[] words = line.Split(' ');
        int N = int.Parse(line);
        int limit = (int)Math.Sqrt(N*2) + 1;
        int number = 0;
        for(int i = 1; i < limit; i++)
        {
            if (i * (i+1) == N * 2)
            {
                // 成功
                number = i;
                break;
            }
        }
        if(number == 0)
        {
            Console.WriteLine("No");
        }
        else
        {
            Console.WriteLine("Yes");
            Console.WriteLine(number + 1);
            int[] syuugou = new int[number * (number + 1)];
            int now = 1;
            for (int j = 0; j < number + 1; j++)
            {
                for(int i = j; i < number; i++)
                {
                    syuugou[i + j * number] = now;
                    syuugou[j + (i + 1) * number] = now;
                    now++;
                }
            }
            for(int j = 0; j < number + 1; j++)
            {
                Console.Write(number + " " + syuugou[j * number]);
                for (int i = 1; i < number; i++)
                {
                    Console.Write(" " + syuugou[i + j * number]);
                }
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 18136
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int func(int a) {
  return (a/100)*60 + a%100;
}

int main() {
  int n,p,q;
  while(cin>>n>>p>>q,n||p||q) {
    bool table[n][func(2500)];
    memset(table,0,sizeof(table));
    int pp = func(p), qq = func(q);
    REP(i,n) {
      int k;cin >>k;
      REP(j,k) {
        int st, go;
        cin >> st >> go;
        for (int l=func(st); l<func(go); ++l)
          table[i][l] = 1;
      }
    }
    int ans = 0, tmp = 0;
    for (int i=func(p); i<func(q); ++i) {
      bool f = 0;
      REP(j,n) {
        if (table[j][i]==0) {
          f = 1;
          break;
        }
      }
      if (f) {
        tmp++;
      } else
        tmp = 0;
      ans = max(ans, tmp);
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
n, a, b, c, d = map(int, input().split())
s = input()

if c < d:
    if ('##' in s[a-1:c]) or ('##' in s[b-1:d]):
        print('No')
    else:
        print('Yes')

else:
    if '##' in s[a-1:c]:
        print('No')
    elif '...' in s[b-2:d+1]:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define so(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pa pair
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<ll,ll>> vpl;
typedef vector<vector<pair<int,int>>> vvp;




int main()
{
    int X;
    cin >> X;
    int a = X/100;
    int b = X%100;
    
    if(a*5 >= b) out(1);
    else out(0);
    
    
    return 0;
}



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


int main() {
  int n; cin >> n;
  vector<int> a(n); rep(i,n)cin >> a[i];
  vector<int> b(n); rep(i,n)cin >> b[i];
  vector<int> c(n-1); rep(i,n-1)cin >> c[i];
  int ans = 0;
  rep(i,n)ans += b[i];
  rep(i,n-1){
    if(a[i+1] == a[i] + 1)ans += c[a[i]-1];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256