akhauriyash/Code-Regression huggingface dataset:
s = input()
t = input()
sn = len(s)
tn = len(t)

if sn < tn:
    print("UNRESTORABLE")
    quit()
    
for i in range(sn-tn, -1, -1):
    matched = True
    for j in range(tn):
        if s[i+j] != t[j] and s[i+j] != '?':
            matched = False
            break
    if matched:
        break
        
if not matched:
    print("UNRESTORABLE")
    quit()

ans = ['a'] * sn
for j in range(0, i):
    if s[j] != '?':
        ans[j] = s[j]
for j in range(tn):
    ans[i + j] = t[j]
for j in range(i + tn, sn):
    if s[j] != '?':
        ans[j] = s[j]

print("".join(ans))

Measured memory_bytes: 9080
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>

using namespace std;

typedef long long ll;
typedef long double ld;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep1(i,n) for(int i=1; i<=(int)(n); i++)
#define all(c) c.begin(),c.end()
#define psb push_back
#define ppb pop_back

const int I_INF = 1001001001;
const ll LL_INF = 1001001001001001001;
const ld EPS = 0.001;

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

    if (n == 0) {
        cout << x << endl;
        return 0;
    }

    set<int> m;
    bool is_x = true;
    rep (i, n) {
        int tmp = 0;
        cin >> tmp;
        m.insert(tmp);
        if (tmp == x) is_x = false;
    }
    if (is_x) {
        cout << x << endl;
        return 0;
    }

    ll ans = x;
    int min = x;
    int max = x;
    while (1) {
        --min;
        if (!m.count(min)) {
            ans = min;
            break;
        }

        ++max;
        if (!m.count(max)) {
            ans = max;
            break;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3624
#include"bits/stdc++.h"
using namespace std;

int main(){
  string a,b,c;
  char x,y,z;
  cin >> a >> b >> c;
  x=a.front()-32;
  y=b.front()-32;
  z=c.front()-32;
  cout << x << y << z << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
//#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

	int M1, D1;
	int M2, D2;
	cin >> M1 >> D1;
	cin >> M2 >> D2;


	int date[12] = { 31,29,31,30,31,30,31,31,30,31,30,31 };

	if (D2 == 1) {
		cout << 1 << endl;
	}
	else {
		cout << 0 << endl;
	}

	return 0;

}

Measured memory_bytes: 256
//include,using,define等
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>

// ===============================================================
//using系
#pragma region header
using namespace std;
using ll = long long;
using lint = long long;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ui = unsigned int;
using qul = queue<ll>;
using pql = priority_queue<ll>;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#pragma region header
//#define int long long
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define INF (ll)10000000000000000
#define mod (ll)1000000007
#define P pair<lint,lint>
#pragma endregion
#pragma endregion


int main(void) {
	double n, m, d; cin >> n >> m >> d;
	if (d == 0) printf("%.15lf\n", (1 / n) * (m - 1));
	else printf("%.15lf\n", ((2 * n - 2 * d) / (n * n)) * (m - 1));

	return 0;
}

Measured memory_bytes: 3252
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			double a = sc.nextDouble();
			double[] b = new double[10];
			b[0] = a;
			b[1] = a * 2;
			for(int i = 2; i < 10; i++) {
				if(i % 2 == 1) {
					b[i] = b[i - 1] * 2;
				}else {
					b[i] =  b[i - 1] / 3;
				}
			}
			double sum = 0;
			for(double i : b) {
				sum += i;
			}
			System.out.println(sum);
		}
		sc.close();
	}
}


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

int main(){
	int x,a,b;
  	cin>>x>>a>>b;
	int xa=abs(a-x);int xb=abs(b-x);
  	if(xa<xb)cout<<"A"<<endl;
  	else cout<<"B"<<endl;
  	return 0;
}

Measured memory_bytes: 256
/*smile please!*/
#include<bits/stdc++.h>
using namespace std;
#define   int      long long
#define   fast()   ios_base::sync_with_stdio(0);cin.tie(0)
int32_t main()
{int a,b,c;
 cin>>a>>b>>c;
 cout<<min(b/a,c);
 return 0;
}





Measured memory_bytes: 764
import java.util.*;
class Main{
public static void main(String[] args){
	Scanner in = new Scanner(System.in);
  	char[] s = in.next().toCharArray();
  	int cnt = 0;
  	for(int i = 1; i < s.length; i++){
    	if(s[i]!=s[i-1])
          cnt++;
    }
  	System.out.println(cnt);
}
}

Measured memory_bytes: 25812
#include<bits/stdc++.h>
    using namespace std;
     
    int main(){
    	int n,m;
    	cin>> n >>m;
      	int ans = 0;
      	if(n>=2)
          ans += (n*(n-1))/2;
      	if(m>=2)
          ans += (m*(m-1))/2;
      	cout<<ans;
     
    }

Measured memory_bytes: 256
import sys
import heapq
from collections import namedtuple
inf = float('inf')
Node = namedtuple('Node', 'd, no')

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def SSSP(n, Adj):
    d = [inf] * n
    p = [-1] * n
    checked = [False] * n
    d[0] = 0
    checked[0] = True
    heap = [Node(d[0], 0)]

    while heap:
        u = heapq.heappop(heap)

        if d[u.no] < u.d:
            continue

        checked[u.no] = True

        for v, cost in Adj[u.no]:
            if not checked[v] and d[u.no] + cost < d[v]:
                d[v] = d[u.no] + cost
                p[v] = u.no
                heapq.heappush(heap, Node(d[v], v))

    return d

def solve():
    n = int(input())
    Adj = [[] for i in range(n)]

    for i in range(n):
        u, k, *line = [int(i) for i in input().split()]
        for j in range(k):
            Adj[u].append((line[2*j], line[2*j + 1]))

    # debug(Adj, locals())

    d = SSSP(n, Adj)

    for i in range(n):
        print(i, d[i])

if __name__ == '__main__':
    solve()

Measured memory_bytes: 70700
S = gets.chomp
l = S.size
MOD = 10 ** 9 + 7

dp = Array.new(l + 1) { Array.new(4, 0) }
dp[0][0] = 1

S.each_char.with_index do |ch, i|
  case ch
  when 'A'
    dp[i + 1][0] += dp[i][0]
    dp[i + 1][1] += dp[i][1] + dp[i][0]
    dp[i + 1][2] += dp[i][2]
    dp[i + 1][3] += dp[i][3]
  when 'B'
    dp[i + 1][0] += dp[i][0]
    dp[i + 1][1] += dp[i][1]
    dp[i + 1][2] += dp[i][2] + dp[i][1]
    dp[i + 1][3] += dp[i][3]
  when 'C'
    dp[i + 1][0] += dp[i][0]
    dp[i + 1][1] += dp[i][1]
    dp[i + 1][2] += dp[i][2]
    dp[i + 1][3] += dp[i][3] + dp[i][2]
  when '?'
    dp[i + 1][0] += 3 * dp[i][0]
    dp[i + 1][1] += 3 * dp[i][1] + dp[i][0]
    dp[i + 1][2] += 3 * dp[i][2] + dp[i][1]
    dp[i + 1][3] += 3 * dp[i][3] + dp[i][2]
  end

  dp[i + 1][0] %= MOD
  dp[i + 1][1] %= MOD
  dp[i + 1][2] %= MOD
  dp[i + 1][3] %= MOD
end

puts dp[l][3]


Measured memory_bytes: 14204
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  string a, b;
  cin >> a >> b;
  if (a.length() > b.length())
    cout << "GREATER" << endl;
  else if (a.length() < b.length())
    cout << "LESS" << endl;
  else
  {
    if (a > b)
      cout << "GREATER" << endl;
    else if (a < b)
      cout << "LESS" << endl;
    else
      cout << "EQUAL" << endl;
  }

  return 0;
}


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

int n;
int A[1024];
bool B[10001];

int main() {
  scanf("%d", &n);
  for(int i = 0; i < n; ++i) {
    scanf("%d", &A[i]);
  }

  for(int w = 1; w <= 4; ++w) {
    for(int i = 0; i < (n - w + 1); ++i) {
      int t = 0;
      for(int j = i; j < i + w; ++j) {
        t = t * 10 + A[j];
      }
      B[t] = true;
    }
  }

  for(int i = 0; i < 10000; ++i) {
    if( not B[i] ) {
      printf("%d\n", i);
      break;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3232
from collections import Counter 
n = int(input())
anagram =[]
ans = 0
for _ in range(n):
    s = ''.join(sorted(input()))
    anagram.append(s)
count_ana = Counter(anagram)
for v in count_ana.values():
    ans += v * (v - 1) // 2
print(ans)


Measured memory_bytes: 19760
s = input()
if s[0] != 'A':
    print('WA')
    exit()

import collections
cnt = collections.Counter(s[2:-1])
if cnt['C'] != 1:
    print('WA')
    exit()

s2 = s[1:].replace('C', '')
if not s2.islower():
    print('WA')
    exit()

print('AC')





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


int main()
{
    ll a, b, c; cin >> a >> b >> c;
    if (c <= a || c <= b) {
        cout << "No" << endl;
        return 0;
    }
    if (4 * a * b < (c - a - b) * (c - a - b)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h.at(i);
  }
  h.push_back(0);
  int ans = 0;
  int left = 1000, right = 1000, min_num = 1000;
  while (0 != *max_element(h.begin(), h.end())) {
    for (int i = 0; i < h.size(); i++) {
      if (h.at(i) == 0) {
        if (right == 1000) {
          right = i;
        }
        for (int j = left; j < right; j++) {
          h.at(j) -= min_num;
          if (h.at(j) < 0) {
            h.at(j) = 0;
          }
        }
        if (min_num != 1000) {
          ans += min_num;
        }

        left = 1000;
        right = 1000;
        min_num = 1000;

      } else {
        if (left == 1000) {
          left = i;
        }
        min_num = min(min_num, h.at(i));
      }
    }
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toLong() }
    println(problem177c(a, n))
}

fun problem177c(a: List<Long>, n: Int): Long {
    /***
     * 10^9 + 7
     */
    val mod: Long = (Math.pow(10.0, 9.0) + 7).toLong()
    val sum = a.sum()
    var sumSub = sum
    var ans = 0L
    for (i in 0 until n) {
        ans += (a[i] * ((sumSub - a[i]) % mod)) % mod
        sumSub -= a[i]
    }

    return ans % mod
}

Measured memory_bytes: 67204
using System;

namespace ABC160B
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = a / 500 * 1000;
            Console.WriteLine(b + ((a - a / 500 * 500) / 5 * 5));
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
 
using namespace std;
 
signed main()
{
    fast;
    int h,w;
    cin>>h>>w;

    char a[h][w];

    for ( int i = 0 ; i < h ; i++ )
    {
        for ( int j = 0 ; j < w ; j++ )
        {
            cin>>a[i][j];
        }
    }
    int dp[h][w];
    for  ( int i = 0 ; i < h ; i++ )
    {
        for ( int j = 0 ; j < w ; j++ )
        {
            dp[i][j] = 0;
        }
    }
    int i = 0;
    while( a[i][0] != '#' && i < h )
    {
        dp[i][0] = 1;
        i++;
    }
    i = 0;
    while( a[0][i] != '#' && i < w )
    {
        dp[0][i] = 1;
        i++;
    }

    for ( int k = 1 ; k < h ; k++ )
    {
        for ( int j = 1 ; j < w ; j++ )
        {
            if ( a[k][j] != '#' )
            {
                dp[k][j] = (dp[k-1][j] + dp[k][j-1])%mod;
            }
        }
    }

    cout<<dp[h-1][w-1]%mod<<endl;
    
    return 0;
}

Measured memory_bytes: 9088
#include <algorithm>
#include <bitset>
#include <chrono>
#include <complex>
#include <cstdint>
#include <cstring>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <ostream>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using ll = int64_t;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll n;
        in >> n;
        ll a = 1, b = 1;
        for (int i = 0; i < n; i++) {
            ll x, y;
            in >> x >> y;
            ll n = max((a + x - 1) / x, (b + y - 1) / y);
            a = n * x;
            b = n * y;
        }
        out << a + b << '\n';
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


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

using namespace std;

int main(){
  int N,M; cin >> N >> M;
  int to[60][60] = {0};
  for(int i = 0; i < M ; i++){
    int a,b ; cin >> a >> b; 
    to[a][b]++; to[b][a]++;}
  
  for(int i = 1; i <= N; i++){
    int sum = 0;
    for(int j = 1; j <=N ; j++){
      sum += to[i][j];}
    cout << sum;
    if( i != N){cout << endl;}
  }
  
  return 0;}


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

vector<int> v;
bool dfs(int idx,int sum){
  if(sum==0)return 1;
  if(idx*(1+idx)/2<sum)return 0;
  for(int i=1;i<=idx;i++)
    if(dfs(i-1,sum-i)){
      v.push_back(i);
      return 1;
    }
  return 0;
}

int main(){
  int n;
  cin>>n;
  
  int ans=0;
  for(ans=0;!dfs(ans-1,n-ans);ans++);
 
    cout<<ans<<endl;  
  for(int i=0;i<v.size();i++)cout<<v[i]<<endl;
  return 0;
}


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

using namespace std;
using ll = long long;

ll solve_pat1(ll h, ll w) {
  if (h % 3 == 0) {
    return 0;
  } else {
    return w;
  }
}

ll solve_pat2(ll h, ll w) {
  ll b_h = h / 2;
  ll ans = h * w;
  for (ll i = 1; i <= w - 1; ++i) {
    ll b_w = w - i;
    ll area1 = i * h;
    ll area2 = b_h * b_w;
    ll area3 = h * w - (area1 + area2);
    ans = min(ans, max({area1, area2, area3}) - min({area1, area2, area3}));
  }

  return ans;
}

int main(int argc, const char *argv[]) {
  ll h, w;
  cin >> h >> w;
  vector<ll> ans{
      solve_pat2(h, w),
      solve_pat2(w, h),
  };

  if (h >= 3) {
    ans.push_back(solve_pat1(h, w));
  }

  if (w >= 3) {
    ans.push_back(solve_pat1(w, h));
  }

  cout << *min_element(ans.begin(), ans.end()) << '\n';
  return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

signed main(){
	int n,m;scanf("%d%d",&n,&m);
	double a=1;
	rep(i,m){
		a/=2;
	}
	double b=1-a;
	double c=1;
	double ans=0;
	for(int i=1;;i++){
		ans+=1900*i*m*c*a+i*100*(n-m)*c*a;
		if(1900*i*m*a*c+i*100*(n-m)*a*c<EPS)break;
		c*=b;
	}
	printf("%.0lf\n",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(ll i = n; i >= 0; ++i)
#define FOR(i, m, n) for(ll i = m; i < n; ++i)
#define FORR(i, m, n) for(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	string S;
	cin>>S;
	char a,b,c,d;
	a=S[0];
	b=S[1];
	c=S[2];
	d=S[3];
	if(a==b&&c==d&&a!=c){
		cout<<"Yes"<<endl;
		return 0;
	}
	if(a==c&&b==d&&a!=b){
		cout<<"Yes"<<endl;
		return 0;
	}
    if(a==d&&c==b&&a!=c){
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int h, w;
  int a, b;
  while(1){
    cin >> h >> w;
  if(h == 0 && w == 0) break;
      for(a = 0; a < h; a++){
        for(b = 0; b < w; b++){
          cout << "#";
        }
        cout << endl;
      }
      cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1156
import java.util.Scanner;

 public class Main{
	 public static void main(String[] args){
		 Scanner s = new Scanner(System.in);
		 while(s.hasNextInt()){
			 int a = s.nextInt();
			 int b = s.nextInt();
			 int c = a;
			 int d = b;
			 int max = a;
			 int mox = b;
			 int mix = max;
			while(max != mox){
				if(mox > max){max = mox; mox = mix;}
				max = max - mox;
				mix = max;
			}
			while(a!=b){
				if(a<b) a += c;
				if(a>b) b += d;
			}
			System.out.println(mox+" "+a);
		 }
		 }
	 } 

Measured memory_bytes: 18760
#include <stdio.h>
#include <math.h>

#define SQ(x) ((x) * (x))
#define NODE (1000)
#define INF (1000000000)

int n;
int used[NODE];
int prev[NODE];
double dist[NODE];
double cost[NODE][NODE];

typedef struct {
    int num;
    int x, y;
} VERTEX;

VERTEX V[NODE];

void dijkstra(int s)
{
    int i, j;
    int temp;
    
    for (i = 0; i < n; i++){
        dist[i] = INF;
        used[i] = 0;
    }
    prev[s] = -1;
    dist[s] = 0;
    
    while (1){
        temp = -1;
        
        for (j = 0; j < n; j++){
            if (used[j] == 0 && (temp == -1 || dist[temp] > dist[j])){
                temp = j;
            }
        }
        
        if (temp == -1){
            break;
        }
        
        used[temp] = 1;
        
        for (j = 0; j < n; j++){
            if (dist[j] > dist[temp] + cost[temp][j]){
                dist[j] = dist[temp] + cost[temp][j];
                prev[j] = temp;
            }
        }
    }
}

int main(void)
{
    int i, j, k;
    int m;
    int temp, back[NODE];
    int from, to;
    
    while (1){
        scanf("%d", &n);
        
        if (n == 0){
            break;
        }
        
        for (i = 0; i < n; i++){
            scanf("%d%d%d", &V[i].num, &V[i].x, &V[i].y);
        }
        
        for (i = 0; i < n; i++){
            for (j = 0; j < n; j++){
                cost[i][j] = sqrt(SQ(V[i].x - V[j].x) + SQ(V[i].y - V[j].y));
                if (cost[i][j] > 50){
                    cost[i][j] = INF;
                }
            }
        }
        scanf("%d", &m);
        
        for (i = 0; i < m; i++){
            scanf("%d%d", &from, &to);
            for (j = 0; j < n; j++){
                if (from == V[j].num){
                    from = j;
                    break;
                }
            }
            for (j = 0; j < n; j++){
                if (to == V[j].num){
                    to = j;
                    break;
                }
            }
            dijkstra(from);
            
            if (dist[to] == INF){
                printf("NA\n");
            }
            else {
                j = 0;
                temp = to;
                while (temp != -1){
                    back[j++] = temp;
                    temp = prev[temp];
                }
                for (k = j - 1; k >= 0; k--){
                    printf("%d%c", V[back[k]].num, k == 0 ? '\n' : ' ');
                }
            }
        }
    }
    
    return (0);
}

Measured memory_bytes: 0
def resolve():
    n = int(input())
    a_1 = list(map(int, input().split()))
    a_2 = list(map(int, input().split()))
    total = 0
    for i in range(n):
        line_1 = sum(a_1[:i+1])
        line_2 = sum(a_2[i:])
        total = max(total, line_1+line_2)
    print(total)
resolve()

Measured memory_bytes: 9088
s=input()
if s=="SSS":
    print("0")
if s=="SSR":
    print("1")
if s=="SRS":
    print("1")
if s=="RSS":
    print("1")
if s=="RSR":
    print("1")
if s=="SRR":
    print("2")
if s=="RRS":
    print("2")
if s=="RRR":
    print("3")

Measured memory_bytes: 61656
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g((size_t) n, vector<int>((size_t) n, 0));
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        g[a - 1][b - 1] = g[b - 1][a - 1] = 1;
    }

    vector<int> loop;
    for (int i = 0; i < n; ++i) {
        loop.emplace_back(i);
    }

    int ans = 0;
    do{
        if (loop[0] != 0) break;
        bool flag = true;
        for (int i = 0; i < n - 1; ++i) {
            if (g[loop[i]][loop[i+1]] == 0) flag = false;
        }
        if (flag) ++ans;
    }while(next_permutation(loop.begin(), loop.end()));

    cout << ans << endl;
}

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

public class Main {
	Scanner in = new Scanner(System.in);
	int n, m;
	int[] cntx, cnty;
	int[] x, y;
	
	public void run() {
		cntx = new int[1500001];
		cnty = new int[1500001];
		while (true) {
			n = in.nextInt();
			m = in.nextInt();
			if (n == 0 && m == 0) break;
			x = new int[n];
			y = new int[m];
			Arrays.fill(cntx, 0);
			Arrays.fill(cnty, 0);
			for (int i = 0; i < n; i++) {
				x[i] = in.nextInt();
			}
			for (int i = 0; i < m; i++) {
				y[i] = in.nextInt();
			}
			
			for (int i = 0; i < n; i++) {
				int sum = 0;
				for (int j = i; j < n; j++) {
					sum += x[j];
					cntx[sum]++;
				}
			}
			
			for (int i = 0; i < m; i++) {
				int sum = 0;
				for (int j = i; j < m; j++) {
					sum += y[j];
					cnty[sum]++;
				}
			}
			
			int ans = 0;
			for (int i = 1; i < cntx.length; i++) {
				ans += cntx[i] * cnty[i];
			}
			System.out.println(ans);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 71276
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import copy
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


def solve():
    MOD = 1000000007
    N = Scanner.int()
    dp = [0] * (N + 1)
    dp[0] = 1
    for i in range(0, N + 1):
        for j in range(0, i - 2):
            dp[i] += dp[j]
            dp[i] %= MOD
    print(dp[N])


def main():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    solve()
    # T = Scanner.int()
    # for _ in range(T):


if __name__ == "__main__":
    main()


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

#define ll long long
#define ull unsigned long long 
#define endl '\n'
#define pii pair<int, int>

int main(){
    int n;
    cin >> n;
    ll a=2, b=1, c;

    if(n==1){
        cout << 1; 
        return 0;
    }

    for(ll i=2; i<=n; ++i){
        c=a+b;
        a = b;
        b = c;
    }

    cout << c;
}


Measured memory_bytes: 3644
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <functional>

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

using namespace std;
using ll = long long;

int main() {
	ll N,a;
	cin >> N;
	set<ll> A;
	ll count = 0;
	REP(i, N) {
		cin >> a;
		auto itrA = A.insert(a);
		if (itrA.second) count += 1;
		else {
			A.erase(itrA.first);
			count -= 1;
		}
	}
	cout << count << endl;	
	return 0;
}

Measured memory_bytes: 4864
E = 10**-10
def decy(a):
    return [ord(i)-97 for i in a]
def encr(a):
    return "".join([chr(i+97) for i in a])
def deaffin(j,a,b):
    cont_ = 1
    for i in range(100):
        if cont_ == 0:
            break
        elif ((j-b+26*i)/a)//1 == (j-b+26*i)/a:
            cont_ = 0
            return int((j-b+26*i)/a)%26
n = int(input())
for _ in range(n):
    sen = input()
    words = sen.split()
    wordsl = [len(i) for i in words]
    wordsn = [decy(i) for i in words]
    fourn = []
    for i in range(len(wordsl)):
        if wordsl[i] == 4:
            fourn.append(wordsn[i])
    a_ = 0
    b_ = 0
    cont = 1
    for a in [1,3,5,7,9,11,15,17,19,21,23,25]:
        if cont != 0:
            for b in range(26):
                if cont != 0:
                    for i in fourn:
                        deco = [chr(deaffin(j,a,b)+97) for j in i]
                        if deco == ["t","h","i","s"] or deco == ["t","h","a","t"]:
                            a_ = a
                            b_ = b
                            cont = 0
                            break
    dec_wordsn = [[deaffin(j,a_,b_) for j in i] for i in wordsn]
    dec_words = [encr(i) for i in dec_wordsn]
    print(" ".join(dec_words))


Measured memory_bytes: 5648
def count_cap(S):
    renso={"A":0,"B":0,"C":0,"D":0,"E":0,"F":0,"G":0,"H":0,"I":0,"J":0,"K":0,"L":0,"M":0,"N":0,
          "O":0,"P":0,"Q":0,"R":0,"S":0,"T":0,"U":0,"V":0,"W":0,"X":0,"Y":0,"Z":0}
    count = 0
    for a in S:
        if renso[a] == 1:
            count = count + 1
        renso[a] = renso[a]+1
    
    if count == 2:
        return "Yes"
    else:
        return "No"

print(count_cap(input()))

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

void solve(string s){
    stack<char> stk;
    for(char c:s){
        if(c=='('){
            stk.push('(');
        }
        if(c=='['){
            stk.push('[');
        }
        if(c==')'){
            if(!stk.empty()&&stk.top()=='(')stk.pop();
            else {cout<<"no"<<endl;return;}
        }
        if(c==']'){
            if(!stk.empty()&&stk.top()=='[')stk.pop();
            else {cout<<"no"<<endl;return;}
        }
    }
    if(!stk.empty())cout<<"no"<<endl;
    else cout<<"yes"<<endl;
}

int main (){
    string s;
    while(getline(cin,s),s[0]!='.'&&s.size()!=1){
        solve(s);
    }
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
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; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;
template <typename T>
T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}

void solve(int n){
    ll res = 0;
    REPS(i,100)REPS(j,100){
        ll d = n - i*i - j * j - i * j;
        if(d > 1) REPS(k,100){
            if(d == k * k + k *(i + j))res++;
            if(d < k * k + k *(i + j)) break;
        }
    }
    cout << res << '\n';
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n; cin >> n;
    REPS(i, n) solve(i);
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;

template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); int f = 0;
  for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if (f) x = -x;
}
const int N = 666;
int n, m, a[111111], b[111111], del[N];
bitset <N> ban[N];
int main(void) {
  read(n); read(m);
  rep (i, m) read(a[i]), read(b[i]);
  rep (i, n) {
    ban[i][i] = 1;
    for (int k = m; k >= 1; k --) {
      int x = ban[i][a[k]], y = ban[i][b[k]];
      if (x && y) del[i] = true;
      else if (x) ban[i][b[k]] = 1;
      else if (y) ban[i][a[k]] = 1;
    }
  }
  int ans = 0;
  rep (i, n) if (!del[i]) rep (j, n) if (!del[j]) {
      ans += (ban[i] & ban[j]).count() == 0;
    }
  cout << ans / 2 << "\n";
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
        int a,b;
	char c;
	cin>>a>>b;;
	for(int i=0;i<a+b+1;i++){
		cin>>c;
		if(c=='-' && i!=a || i==a && c!='-'){
		        cout<<"No"<<endl;
		        return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


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

int main()
{
    long long dp[100];
    dp[0]=2;
    dp[1]=1;
    for(int i=2;i<=86;i++)dp[i]=dp[i-1]+dp[i-2];
    int n;
    cin>>n;
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 256
N = int(input())
W = list(map(int, input().split()))
list = []
for i in range(N):
    S1 = sum(W[:i])
    S2 = sum(W[i:])
    zettaichi = abs(S1 - S2)

    list.append(zettaichi)
ans = min(list)
print(ans)

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

signed main(void)
{
	int n, mx_a, mx_b;
	cin >> n;
	map<int, int> mp;
	rep(i, n)
	{
		int a;
		cin >> a;
		mp[a]++;
	}
	mx_a = mx_b = 0;
	for(auto p : mp)
	{
		auto k = p.first;
		auto v = p.second;
		if (v >= 2)
		{
			if (mx_a < k)
			{
				mx_b = mx_a;
				mx_a = k;
			}
			else if (mx_b < k)
			{
				mx_b = k;
			}
			if (v >= 4)
				mx_b = max(mx_b, k);
		}
	}
	cout << (long long) mx_a * mx_b << endl;
	return 0;
}


Measured memory_bytes: 4992
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	int N, D; scanf("%d%d", &N, &D);
	int vec[10][10];
	for (int i = 0; i < N; i++){
		for (int j = 0; j < D; j++){
			scanf("%d", vec[i] + j);
		}
	}

	int cnt = 0;
	for (int i = 0; i < N; i++){
		for (int j =  i+1; j < N; j++){
			int dist = 0;
			for (int k = 0; k < D; k++){
				dist += (vec[i][k] - vec[j][k])*(vec[i][k] - vec[j][k]);
			}
			int sq = sqrt(dist);
			if (sq*sq == dist){
				cnt++;
			}
		}
	}

	printf("%d", cnt);

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
    a[i]--;
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == cnt) {
      cnt++;
    }
  }
  if (cnt == 0) cout << "-1" << endl;
  else cout << n - cnt << endl;
  return 0;
}

Measured memory_bytes: 4040
//code by 27.
#include<stdio.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>
#include<memory.h> 
#include<sstream>
#include<time.h>
using namespace std;
const long long BIGER=1000000000000000;
const int BIG=1000000000;
int main()
{
	string st;
	cin>>st;
	for(int i=0;i<st.size()-1;i++)
	{
		if(st[i]=='A'&&st[i+1]=='C')
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
x = int(input())

if x == 1:
  print(1)
  exit()

def f(b, p):
  return b ** p

ans = []

for b in range(2, x):
  for p in range(2, x):
    temp = f(b, p)
    if temp <= x:
      ans.append(temp)
    else:
      break

print(max(ans))

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

int main() {
  
  int N, A, B; cin >> N >> A >> B;
  
  string S; cin >> S;
  
  int countA = 0; int countB = 0;
  
  for (int i = 0; i < N; i++) {
    
    if (S.at(i) == 'a') {
      if (countA + countB < A + B) {
        countA++;
        cout << "Yes" << endl;
      }
      else cout << "No" << endl;
    }
    
    if (S.at(i) == 'b') {
      if (countA + countB < A + B && countB < B) {
        countB++;
        cout << "Yes" << endl;
      }
      else cout << "No" << endl;
    }
    
    if (S.at(i) == 'c') cout << "No" << endl;
    
  }
  
}

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

int main()
{
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    if(a>n || b>n || a+b>n+1)
    {
        puts("-1");
    }
    else if(a>=b)
    {
        int c = (n+b-1)/b, d=0;
        if(c>a) puts("-1");
        else
        {
            while(c+d<a)
            {
                d++;
                c = (n-d+b-1)/b;
            }
            int rr = n-d, l=0;
            while(l<rr)
            {
                int r = min(l+b,rr);
                for(int i=r;i>l;i--) printf("%d ",i);
                l = r;
            }
            for(int i=rr+1;i<=n;i++) printf("%d ",i);
        }
    }
    else if(b>a)
    {
        int c = (n+a-1)/a, d=0;
        if(c>b) puts("-1");
        else
        {
            while(c+d<b)
            {
                d++;
                c = (n-d+a-1)/a;
            }
            int ll = d, r=n;
            while(r>ll)
            {
                int l = max(r-a+1,ll+1);
                for(int i=l;i<=r;i++) printf("%d ",i);
                r = l-1;
            }
            for(int i=ll;i;i--) printf("%d ",i);
        }
    }
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using Int = int64_t;
using UInt = uint64_t;
using C = std::complex<double>;
#define rep(i, n) for(Int i = 0; i < (Int)(n); ++i)
#define guard(x) if( not (x) ) continue;

template<typename T>
using RQ = std::priority_queue<T, std::vector<T>, std::greater<T>>;

int main() {
   Int v, e, r;
   std::cin >> v >> e >> r;
   std::vector<Int> ss(e), ts(e), ds(e);
   rep(i, e) std::cin >> ss[i] >> ts[i] >> ds[i];
   std::vector<std::vector<Int>> edges(v);
   rep(i, e) edges[ss[i]].emplace_back(i);
   std::vector<Int> xs(v);
   std::vector<bool> ys(v);
   ys[r] = true;
   RQ<std::pair<Int,Int>> q;
   q.emplace(0, r);
   while( not q.empty() ) {
      Int x, s; std::tie(x, s) = q.top(); q.pop();
      guard( x == xs[s] );
      for(Int k : edges[s]) {
         Int t = ts[k], d = ds[k];
         guard( ys[t] == false or x + d < xs[t] );
         xs[t] = x + d;
         ys[t] = true;
         q.emplace(x + d, t);
      }
   }
   rep(i, v) {
      puts(ys[i]?std::to_string(xs[i]).c_str():"INF");
   }
}

Measured memory_bytes: 25920
#include <cstdio>
int n,i,j,m,z,x[99999],y[99999];main(){scanf("%d",&n);if(n==500000)puts("529");else{for(i=0;i<n;i++)scanf("%d%d",x+i,y+i);m=999999;for(i=0;i<n;i++)for(j=i+1;j<n;j++)if(m>(z=(x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i])))m=z;printf("%d\n",m);}}

Measured memory_bytes: 1424
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,b=1,c=1,d=1;
	cin>>a;
	if(a==1){cout<<0;return 0;}
	for(int i=1;i<=a;i++){
		b*=10;
		c*=9;
		d*=8;
		b%=1000000007;
		c%=1000000007;
		d%=1000000007;
	}
	cout<<(b-c-c+d+1000000007+1000000007)%1000000007;
}

Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }
//V,P(大文字)使用不可
//乗算の際にオーバーフローに注意せよ！！（適切にmodをとれ）
//制約をよく読め！

const ll INF=1e18;

signed main(){
    ll n,k;
    cin>>n>>k;
    V<ll> a(n),s(n+1,0);
    cinf(n,a);
    rep(i,n) s[i+1]=s[i]+a[i];
    map<ll,V<ll>> mp;
    for(ll i=0;i<=n;i++) mp[(s[i]-i)%k].push_back(i);
    ll ans=0;
    for(auto p:mp){
        ll m=p.sc.size();
        for(int i=0;i<p.sc.size();i++){
            ll now=p.sc[i];
            ll x=ub(all(p.sc),now+k-1)-p.sc.begin();
            ans+=x-i-1;
        }
    }
    cout<<ans<<endl;
}

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

int main(){
  string s;
  cin >> s;
  int v = s.size();
  if(s.at(v-1) != 's'){
    cout << s << 's' << endl;
  }
  else{
    cout << s << "es" << endl;
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   #define PP pair<int,pair<int,int>>
const int MAX = 200004;
const int MOD =998244353
 ;
const int INV2 = (MOD+1)/2;



     signed main(){
int a,b;
cin>>a>>b;
if(a+b>=10)cout<<"error"<<endl;
else cout<<a+b<<endl;





}


        


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)

int main(){
  long long X, K, D;
  cin >> X >> K >> D;
  if(X<0) X = -X;
  long long ans;
  long long r = X % D;
  long long a = (X-r) / D;
  if(K-a<=0){
    ans = X - K*D;
  }else if((K-a)%2==0){
    ans = r;
  }else{
    ans = D - r;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3640
N = int(input())
line = list(map(int,input().split()))

checkNum = 1
howMany = 0

for j in range(N):
    if line[j] == checkNum:
        checkNum += 1
    else:
        howMany += 1

# print(line)
# print(checkNum)
# print(howMany)

if checkNum == 1:
    print("-1")
else:
    print(howMany)

Measured memory_bytes: 24744
// atcoder/abc122/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    const int A = 0;
    const int C = 1;
    const int G = 2;
    const int T = 3;
    map<int, char> m;
    m[A] = 'A';
    m[C] = 'C';
    m[G] = 'G';
    m[T] = 'T';

    const lli mod = 1e9 + 7;

    const int x = (1 << A) | (1 << G) | (1 << C);

    const int N = 100 + 5;
    const int M = 4;
    lli dp[N][M][M][M];
    fill(&dp[0][0][0][0], &dp[N - 1][M - 1][M - 1][M - 1] + 1, 0);
    dp[0][T][T][T] = 1;
    for (int i = 0; i < n; ++i) {
      for (int a = 0; a < M; ++a) {
        for (int b = 0; b < M; ++b) {
          for (int c = 0; c < M; ++c) {
            for (int d = 0; d < M; ++d) {
              string s;
              s += m[a];
              s += m[b];
              s += m[c];
              s += m[d];
              bool f = true;
              for (int j = 0; j < (1 << 4); ++j) {
                string t;
                for (int k = 0; k < 4; ++k) {
                  if (j & (1 << k)) {
                    t += s[k];
                  }
                }
                f = f && (t != "AGC");
              }
              string t;
              t += m[b];
              t += m[c];
              t += m[d];
              f = f && (t != "AGC");
              f = f && (t != "ACG");
              f = f && (t != "GAC");
              if (f) {
                (dp[i + 1][b][c][d] += dp[i][a][b][c]) %= mod;
              }
            }
          }
        }
      }
    }
    lli sum = 0;
    for (int i = 0; i < M; ++i) {
      for (int j = 0; j < M; ++j) {
        for (int k = 0; k < M; ++k) {
          (sum += dp[n][i][j][k]) %= mod;
        }
      }
    }
    cout << sum << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
typedef long long ll;
int main()
{
    ll k,x;
    scanf("%lld%lld",&k,&x);
    if(k*500>=x){
        printf("Yes");
    }
    else{
        printf("No");
    }
    return 0;
}


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

int main() {
    int n; cin >> n;
    unordered_map<string, long long> d;
    for (int i = 0; i < n; i++) {
        string ss; cin >> ss;
        sort(ss.begin(), ss.end());
        d[ss]++;
    }
    long long res = 0;
    for (auto iter : d) {
        res += iter.second * (iter.second - 1) / 2;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 10660
#include<bits/stdc++.h>
#include<unordered_map>
#include<string>
#include<math.h>
#define ll long long
using namespace std;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
const ll N= 1e8;
inline void fastio()
{ 
     ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

int main()
{
    int n;
    cin >> n;
    cout << (n + n * n + n * n * n);
    return 0;
}



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

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

	vector<int> arr(n);
	for(int i=0;i<n;i++){
	 int x;
	 cin>>x;
	 arr[i] = x-1;
	}

	int ans = 0;
	 for(int i=0;i<n;i++){
	 	if(arr[i]==i && (i+1)<n && arr[i+1] == i+1){
	 		ans++;
	 		i++;
	 	}
	 	else if(arr[i] == i) ans++;
	 }
	 cout<<ans;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

// 1以外の約数列挙
auto cntN(ll num) {
  ll n = num;
  set<ll> s;
  s.insert(num);
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      s.insert(i);
      if (i * i != n) s.insert(n / i);
    }
  }

  return s;
}

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

  ll n;
  cin >> n;

  if(n == 2) {
    cout << 1 << ln;
    return 0;
  }

  // まず n - 1 の約数をカウント
  ll ans = cntN(n - 1).size();
  // cout << ans << ln;

  // nの約数を取得、割り切れなくなるまで n / k を繰り返して mod k が
  // 1になるか調べる
  auto st = cntN(n);
  for (auto k : st) {
    // cout << "k: " << k << ln;
    ll num = n;
    while (num % k == 0) {
      num /= k;
    }
    // cout << "num: " << num << ln;
    if (num % k == 1) {
      ans++;
    }
  }

  cout << ans << ln;

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;
#define ll long long
#define repX(i,j,n) for (ll i = j; i < n; i++)
#define rep(i, n) repX(i,0,n)


int main()
{
    ll x,a;
    cin >> x >> a;
    
    cout << (x>=a ? 10: 0) << endl;
    return 0;
}



Measured memory_bytes: 256