akhauriyash/Code-Regression huggingface dataset:
// ABC099_C

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    cin >> n;
    
    vector<int> a;
    vector<int> b;
    int tmp = 1;
    int ttmp = 1;
    while(tmp < 100000) {
        tmp *= 6;
        a.push_back(tmp);
    }
    
    while(ttmp < 100000) {
        ttmp *= 9;
        b.push_back(ttmp);
    }
    
    int ans = n;
    for(int i = 0; i <= n; i++) {
        int t = i;
        int cc = 0;
        
        int cnt = 0;
        while(t > 0) {
            while(a[cnt] <= t) {
                cnt++;
            }
            if(cnt != 0) {
                cc += t / a[cnt - 1];
                t -= a[cnt - 1] * (t / a[cnt - 1]);
            }
            else{
                cc += t;
                t = 0;
            }
            cnt = 0;
        }
        
        t = n - i;
        cnt = 0;
        while(t > 0) {
            while(b[cnt] <= t) {
                cnt++;
            }
            if(cnt != 0) {
                cc += t / b[cnt - 1];
                t -= b[cnt - 1] * (t / b[cnt - 1]);
            }
            else {
                cc += t;
                t = 0;
            }
            cnt = 0;
        }
        
        if(ans > cc) {
            ans = cc;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int n;
void A();
void B();
int main() {
	fscanf(stdin, "%d", &n);
	if (n == 2) A();
	else B();
	return 0;
}

void A(){
	int a, b, d=1, i;
	fscanf(stdin, "%d%d", &a, &b);
	if (a % 2 == 1 || b % 2 == 1)d=2;
	n = a < b ? a : b;
	for (i = 1; i <= n; i += d)
		if (!(a%i) && !(b%i)) fprintf(stdout, "%d\n", i);
	return;
}

void B() {
	int a, b, c,d = 1, i;
	fscanf(stdin, "%d%d%d", &a, &b,&c);
	if (a % 2 || b % 2||c%2)d = 2;
	n = a < b ? a < c ? a : c : b < c ? b : c;
	for (i = 1; i <= n; i += d)
		if (!(a%i) && !(b%i)&&!(c%i))fprintf(stdout, "%d\n", i);
	return;
}

Measured memory_bytes: 600
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	dic := make([]map[rune]bool, len(s))
	flg := false

	for i := range s {
		dic[i] = make(map[rune]bool)
		dic[i][rune(s[i])] = true
	}
	for {
		for c := 'a'; c <= 'z'; c++ {
			for i := 0; i < len(dic); i++ {
				if !dic[i][rune(c)] {
					goto exitLoop
				}
			}
			flg = true
		exitLoop:
		}
		for i := 0; i < len(dic)-1; i++ {
			for j := range dic[i+1] {
				dic[i][j] = true
			}
		}
		if flg {
			break
		}
		dic = dic[:len(dic)-1]
	}
	fmt.Println(len(s) - len(dic))
}


Measured memory_bytes: 512
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
temp=9999
for i in range(len(h)):
    if temp>abs((t-h[i]*0.006)-a):
        temp=abs((t-h[i]*0.006)-a)
        ans=i+1
print(ans)



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

using namespace std;
#define BUF (1000)

int n;
int a[BUF];

int main(void){

	cin >> n;
	int even = 0;
	for(int i=1;i<=n;i++){
		int tmp = 0;
		cin >> tmp;
		if(tmp%2==0) even++;
	}

	cout << pow(3,n)-pow(2,even) << endl;

	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll n,l;
	cin >> n;
	vector<ll> a(n+2);
	a[0] = 0;
	a[n+1] = 0;
	ll sum = 0;
	for(ll i = 1; i <= n; i++) {
		cin >> l;
		a[i] = l;
	}
	vector<ll> d(n+1);
	for(ll i = 1; i <= n+1; i++) {
		d[i] = abs(a[i] - a[i - 1]);
		sum += d[i];
	}
	for(int i = 1; i <= n; i++) {
		cout << sum - abs(a[i] - a[i - 1]) - abs(a[i] - a[i+1]) + abs(a[i - 1] - a[i+ 1]) << endl;
	}
	return 0;
}

Measured memory_bytes: 2816
use proconio::input;

fn main() {
    input! {
        (n, k): (usize, usize)
    }

    const MOD: usize = 1_000_000_007;
    let mut count = 0;
    for i in k..=n + 1 {
        let min = (i - 1) * i / 2;
        let max = (2 * n - i + 1) * i / 2;

        count += (max - min + 1) % MOD;
    }

    println!("{}", count % MOD);
}


Measured memory_bytes: 2148
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int Solve(int N, int[] P)
        {
            int min = int.MaxValue;
            int count = 0;
            foreach (int p in P)
            {
                if (p < min)
                {
                    min = p;
                    ++count;
                }
            }
            return count;
        }

        static void Main(string[] args)
        {
            int N = ReadInt();
            int[] P = ReadInts();
            Console.WriteLine(Solve(N, P));
        }
    }
}


Measured memory_bytes: 33116
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  string c;
  cin >> c;
  int r, w;
  r = w = 0;
  rep(i, n) {
    if(c[i] == 'R') r++;
  }
  int ans = max(r,w);
  rep(i, n) {
    if(c[i] == 'R') r--;
    else w++;
    int m = max(r, w);
    ans = min(ans, m);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3676
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.D_Challenge
{
    class ABC_098
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] array = ReadInts();
            var twice = new int[n][];
            for(int i = 0; i < n; i++)
            {
                twice[i] = new int[20];
                int val = array[i];
                int digit = 0;
                while (val > 0)
                {
                    twice[i][digit] = val % 2;
                    val /= 2;
                    digit++;
                }
            }
            long res = 0;
            int r = 0;
            var sum = new int[20];
            for (int l = 0; l < n; l++)
            {
                bool sumed = false;
                for (; r < n; r++)
                {
                    for (int j = 0; j < 20; j++)
                    {
                        sum[j] += twice[r][j];
                        if (sum[j] > 1)
                        {
                            sumed = true;
                        }
                    }
                    if (sumed)
                    {
                        break;
                    }
                }
                res += r - l;

                for (int j = 0; j < 20; j++)
                {
                    sum[j] -= twice[l][j];
                    if (r < n)
                    {
                        sum[j] -= twice[r][j];
                    }
                }
            }
            Console.WriteLine(res);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define debug(x) cerr<<#x<<": "<<x<<endl;

#define fi first
#define se second

#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const int inf = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

bool SO[1001000];

void erast(int n){
    memset(SO,true,sizeof(SO));
    SO[1] = false;
    SO[0] = false;
    REP(i,2,sqrt(n)){
        if(SO[i]){
            REP(j,2,n){
                if(i*j>=1000100) break;
                SO[i*j] = false;
            }
        }
    }
}

int main(){
//    ifstream in("input.txt");
//    cin.rdbuf(in.rdbuf());
    erast(1000100);
    int a,d,n;
    while(cin >> a >> d >> n,a+d+n){
        rep(i,n){
            while(!SO[a]) a+=d;
            a+=d;
        }
        cout << a-d << endl;
    }



    return 0;
}


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

using namespace std;

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

int n;
int d[55];

int main(){
	cin >> n;
	rep(i, n) cin >> d[i];
	
	int ans = 0;
	rep(i, n) REP(j, i + 1, n) ans += d[i] * d[j];
	
	cout << ans << endl;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
list = [list(map(int,input().split())) for _ in range(M)]
list_pre = [[] for _ in range(N)]

for i,l in enumerate(list):
    list_pre[l[0]-1].append([l[1],i])

ans = []

for i,l in enumerate(list_pre):
    l.sort()
    for j,l2 in enumerate(l):
        ans.append([i+1,j+1,l2[1]])

ans.sort(key=lambda x:x[2])

for l in ans:
    print('%06d%06d' % (l[0],l[1]))

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

typedef unsigned long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;

#define INF (int)(1e9)

#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,start,end) for(int i=(start);i<=(end);i++)
#define all(n) begin(n),end(n)

#define DEBUG

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

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

using namespace std;

#define MAX_N 200000
int A[MAX_N];

inline int invert(int x) {
    int inv{1};
    while (inv <= x) inv <<= 1;
    return inv - x;
}

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

    int count{};
    multiset<int> inverted;
    for (int i{N-1}; i >= 0; --i) {
        const auto& found = inverted.find(A[i]);
        if (found != inverted.end()) {
            inverted.erase(found);
            ++count;
        } else {
            inverted.insert(invert(A[i]));
        }
    }

    printf("%d\n", count);
    return 0;
}


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

main() {
    string S; cin >> S;
    int cnt=0,cnt2=0;
    rep(i,S.size()){
        if(i%2==0) {if(S[i]=='0') cnt++;}
        else if(S[i]=='1') cnt++;
    }
    rep(i,S.size()){
        if(i%2==1) {if(S[i]=='0') cnt2++;}
        else if(S[i]=='1') cnt2++; 
    }
    cout << min(cnt,cnt2) << endl;

    return 0;
}

Measured memory_bytes: 512
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
// #define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

int w[100010], v[100010];
signed main(void)
{
  int n, q;
  scanf("%d %d", &n, &q);
  REP(i, q) {
    scanf("%d %d", &v[i], &w[i]);
    v[i]--, w[i]--;
  }

  REP(i, q) {
    if(n == 1) {
      printf("%d\n", v[i]+1);
      continue;
    }
    int d_v = 0, vv = v[i];
    while(vv > 0) vv = (vv-1)/n, d_v++;
    int d_w = 0, ww = w[i];
    while(ww > 0) ww = (ww-1)/n, d_w++;
    // cout << d_v << " " << d_w << endl;
    // cout << v[i] << " " << w[i] << endl;

    if(d_v < d_w) {
      REP(j, d_w-d_v) {
        // cout << v[i] << "," << w[i] << endl;
        w[i] = (w[i]-1)/n;
        // cout << v[i] << "," << w[i] << endl;
      }
    } else if(d_w < d_v) {
      REP(j, d_v-d_w) {
        v[i] = (v[i]-1)/n;
        // cout << v << " " << w << endl;
      }
    }

    while(w[i] != v[i]) {
      w[i] = (w[i]-1)/n;
      v[i] = (v[i]-1)/n;
      // cout << v << "," << w << endl;
    }

    printf("%d\n", w[i]+1);
  }

  return 0;
}


Measured memory_bytes: 2048
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

constexpr int INF = (1 << 30);

int D, G;
vector<int> p, c;

void input(void){
    cin >> D >> G;
    p.resize(D);
    c.resize(D);
    for (int i = 0; i < D; ++i)
        cin >> p[i] >> c[i];
}

void show(int f){
    for (int i = 0; i < D; ++i)
        cout << ((f & (1 << i)) ? 1 : 0);
}

// コンプリートするか否かのフラグがfであるときに解く最小の問題数
int calc(int f){
    /* cout << "called  ";
    show(f);
    cout << "  :  "; */
    int res = 0;
    int score = 0;
    for (int i = 0; i < D; ++i){
        if (f & (1 << i)){
            res += p[i];
            score += (i + 1) * 100 * p[i] + c[i];
        }
    }
    if (score >= G) return res;
    for (int i = D - 1; i >= 0; --i){
        if (!(f & (1 << i))){
            if (score + (i + 1) * 100 * p[i] < G){
                score += (i + 1) * 100 * p[i];
                res += c[i];
            }
            else{
                int need = G - score;
                int solve = need / ((i + 1) * 100);
                if (need % ((i + 1) * 100)) ++solve;
                return res + solve;
            }
            if (score >= G)
                return res;
        }
    }
    return INF;
}

int main(void){
    input();
    int ans = INF;
    for (int f = 0; f < (1 << D); ++f){
        int tmp = calc(f);
        /* cout << tmp << endl; */
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

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

int main(void){
	double n,i,j,k,ans,ap;
	scanf("%lf",&n);
	ans = 4/n;
	for (i=1;i<5000;i++)
	{
		for (j=1;j<5000;j++)
		{
			ap = ans - 1/i - 1/j;
			if (ap >0)
			{
				ap = 1.0/ap;
				ap = roundl(ap * 10000000) / 10000000;
				if ((int)(ap) == ap) 
				{
					printf("%d %d %d",(int)(i),(int)(j),(int)(ap));
					return 0;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
#define INF           1e9
#define INFL          static_cast<lint>(INF)
#define REP(i,n)      for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)     for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)     for(lint i=n-1;i>=0;--i)
#define REPR1(i,n)    for(lint i=n;i>0;--i)
#define REPI(i,ini,n) for(lint i=(ini),i##_len=(n);i<i##_len;++i)
#define REPC(i,obj)   for(auto i:obj)
#define R_UP(a,b)     (((a)+(b)-1)/(b))
#define ALL(obj)      (obj).begin(),(obj).end()
int main()
{
	map<string, int>m;
	int q = in();
	REP(i, q)
	{
		int n = in();
		string key;
		int x;
		switch (n)
		{
		case 0:
			key = in<string>();
			x = in();
			m[key] = x;
			break;
		case 1:
			key = in<string>();
			cout << m[key] << endl;
			break;
		}
	}
}


Measured memory_bytes: 27740
#include <bits/stdc++.h>
using namespace std;
#include <math.h> 
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	ll ch[200010];
	for(ll i=0;i<n;i++){
		cin>>ch[i];
	}
	ll ans=1;ll mi=ch[0];
	for(ll i=1;i<n;i++){
		if(ch[i]<=mi){
			ans++;
			mi=ch[i];
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 5180
N = int(input())
S = input()

if N%2 == 1:
    print("No")
else:
    count = 0
    for i in range(N//2):
        if S[i] == S[i+N//2]:
            count+=1
    if count == N//2:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <functional>

using namespace std;


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

    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);

    if((a+b)==(c+d)){
        printf("Balanced\n");
    }else if(a+b>c+d){
        printf("Left\n");
    }else{
        printf("Right\n");
    }


    return 0;
}


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

int K, S;

int main() {
  cin >> K >> S;
  int ans = 0;

  for (int x = 0; x <= K; ++x) {
    for (int y = 0; y <= K; ++y) {
      int z = S - x - y;
      if (0 <= z && z <= K) {
        ++ans;
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
x, n = map(int, input().split())
p = list(map(int, input().split()))

if x not in p:
   print(x)
   exit()

p.sort()
q = [i for i in range(0, 102) if i not in p]

diff = [0] * len(q)
for i in range(len(q)):
      diff[i] = abs(q[i] - x)

index = diff.index(min(diff))
print(q[index])


Measured memory_bytes: 9200
#include<iostream>
#include<cstdio>
#define _USE_MATH_DEFINES
#include<math.h>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<map>
#include<unordered_map>
#include<set>
#include <algorithm>
#include <utility>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::set;
using std::vector;
using std::pair;
using std::make_pair;
using std::priority_queue;

typedef unsigned long long ull;
typedef long long ll;

#define Prime1 1000000007
#define Prime2 9999973

#define INF 0x7fffffffffffffff

ull i, j, k, l, m, n;
ull H, W, Q;
ull a, b, c, x, y;
ll K, L, N, M;
string str;

int main()
{
	cin >> N >> L;
	if(L>0)
	{
		cout << N*(2 * L - 1 + N) / 2-L;
	}
	else if(L+N-1<0)
	{
		cout << N*(2 * L - 1 + N) / 2-L-N+1;
	}
	else
	{
		cout << N*(2 * L - 1 + N) / 2;
	}
	return 0;
}

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

ll RepeatSquare(ll x, ll p, ll m){
  if(p==0)
    return 1;
  if(p%2==0){
    ll t = RepeatSquare(x,p/2,m);
    return t*t%m;
  }
  return x*RepeatSquare(x,p-1,m)%m;
}

ll factrial(ll x,ll y,ll m){
  ll ans=1;
  for(ll i=x;i<=y;i++){
    ans *= i;
    ans %= m;
  }
  return ans;
}
  
int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  
  ll ans;
  ans = RepeatSquare(2,n,1000000007)-1;
  
  ll combi_a,combi_b;
  combi_a=factrial(n-a+1,n,1000000007);
  combi_b=factrial(n-b+1,n,1000000007);
  
  combi_a *= RepeatSquare(factrial(1,a,1000000007),1000000005,1000000007);
  combi_b *= RepeatSquare(factrial(1,b,1000000007),1000000005,1000000007);
  combi_a %= 1000000007;
  combi_b %= 1000000007;
  //cout << combi_a << " "<< combi_b << endl;
  ans -= (combi_a+combi_b);
  //cout << ans << endl;
  while(ans<0)
    ans += 1000000007;
  ans%=1000000007;
  cout << ans << endl;
  return 0;
}

  
  


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	double a;
	cin >> a;
	cout << fixed << setprecision(15) <<8*atan(1)*a;
}













Measured memory_bytes: 3796
#include<bits/stdc++.h>
    using namespace std;
    bool option(int a, int b){
        return a % 10 > b % 10;
    }
    int main(){
        vector<int> a;
        int ans = 0;
        for(int i =0; i<5; i++){
            int x; cin>>x;
            if(x % 10 ==0 ){
                ans += x;
            }
            else{
                a.push_back(x);
            }
        }
        sort(a.begin(), a.end(), option);
        /*cout<<"ans = "<<ans<<endl;
        for(int x: a){
            cout<<x<<" ";
        }cout<<endl;*/
        if(a.size() ==0){
            cout<<ans;
            return 0;
        }
        for(int i = 0; i+1 < a.size(); i++){
            ans += (10 - a[i] % 10);
            ans += a[i];
        }
        cout<<ans + a[a.size() - 1];
        return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;


int main() {
  int A;
  int i = 1;
  while(1) {
    cin >> A;
    if(A==0) {
      break;
    }
    cout << "Case " << i << ": " << A << endl;
    i++;
  }
}



Measured memory_bytes: 3096
s = gets.chomp!
left = s[0].chars
right = s[1, s.length-1].chars

require 'pp'

count = 0
while right.empty?.!
  if left[-1] != nil && (left[-1] != right[0])
    left.pop
    right.shift
    count += 2
  else
    left.push(right[0])
    right.shift
  end

  #puts left.join + "/" + right.join
end

puts count


Measured memory_bytes: 8828
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>=y?x:y)
#define min(x,y) (x<=y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define ios() ios::sync_with_stdio(false)
#define INF 1044266558
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll a[200005][30],ans;
char s[200005];
int main()
{
	while(scanf("%s",s+1)!=EOF)
	{
		memset(a,0,sizeof(a));
		int len=strlen(s+1);
		ans=0;
		for(int i=1;i<=len;i++)
		{
			for(int j=0;j<26;j++)
				a[i][j]=a[i-1][j];
			a[i][s[i]-'a']++;
		}
		for(int i=1;i<=len;i++)
			ans+=len-i-a[len][s[i]-'a']+a[i][s[i]-'a'];
		printf("%lld\n",ans+1);
	}
	return 0;
}

Measured memory_bytes: 47360
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#include<set>
#include<map>
using namespace std;
using ll = long long;

int main(){
  string str;
  cin >> str;
  if(str=="ABC")  cout << "ARC";
  else  cout << "ABC";
}

Measured memory_bytes: 3624
import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.Char
import           Data.Maybe
import qualified Data.Vector           as VB

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

getIntegerVec n =
  VB.unfoldrN n (BS.readInteger . BS.dropWhile isSpace) <$> BS.getLine

main = do
  n <- getInt
  as <- getIntegerVec n
  let m = VB.foldl' lcm 1 as
      as' = VB.map (\i -> m `div` i) as
  print $ (VB.sum as') `mod` 1000000007

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

vector<int32> to;
string s;
int32 n;

int32 calc(int32 x){
    if(to[x] != -1)return to[x];
    if(s[x] == 'L'){
        if(s[x-1] == 'R'){
            return to[x] = x-1;
        }else{
            return to[x] = calc(x-1);
        }
    }else{
        if(s[x+1] == 'L'){
            return to[x] = x+1;
        }else{
            return to[x] = calc(x+1);
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    n = s.size();
    to = vector<int32>(n, -1);
    vector<int32> ans(n, 0);
    REP(i,n){
        int32 c = calc(i);
        if(abs(c - i) % 2 == 0){
            // cout << c << " ";
            ans[c]++;
        }else{
            if(c < i){
                // cout << c + 1 << " ";
                ans[c+1]++;
            }else{
                // cout << c - 1 << " ";
                ans[c-1]++;
            }
        }
        // cout << calc(i) << " ";
    }
    REP(i,n)cout << ans[i] << " ";
    cout << endl;
    return 0;
}

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

long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}

string myrev(string s){
	string t=s;
	reverse(t.begin(),t.end());
	return t;
}


int main(){
	init();
	ll N,M,R;cin>>N>>M>>R;
	vector<ll>r(R);
	for(int i=0;i<R;i++){
		cin>>r[i];
		r[i]--;
	}
	//cout<<"our"<<endl;
	vector<vector<ll>>d(N,vector<ll>(N,INF));
	for(int i=0;i<M;i++){
		ll a,b,c;cin>>a>>b>>c;
		a--;b--;
		d[a][b]=c;
		d[b][a]=c;
	}
	
	for(int i=0;i<N;i++)d[i][i]=0;
	
	for (int k = 0; k < N; k++){
   		for (int i = 0; i < N; i++) {
   			for (int j = 0; j < N; j++) {
      		  d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
     		}
    	}
    }
    
    sort(r.begin(),r.end());
    ll ans=INF;
    do{
    	ll num=0;
    	for(int i=0;i<R-1;i++){
    		num+=d[r[i]][r[i+1]];
    	}
    	ans=min(num,ans);
    }while(next_permutation(r.begin(),r.end()));
    
    cout<<ans<<endl;
}


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

data = [int(i) for i in input().split()]

i = 0
def euq(x,y):
  a = max(x,y)
  b = min(x,y)
  if a % b == 0:
    return b
  else:
  	return euq(b, a % b)
  


while i < N-1:
  com =  euq(data[i],data[i + 1])
  data[i+1] = com
  i += 1
  
  

print(com)


Measured memory_bytes: 14252
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> P;

const ll INF = 1e10;
const double eps = 1e-6;
const ll MOD = 1000000007;

int main() {
	ll N;
	cin >> N;
	vector<vector<ll>> dp(2, vector<ll>(N, 0));
	vector<vector<ll>> ame(2, vector<ll>(N, 0));
	for (int i = 0;i < 2;i++)
		for (int j = 0;j < N;j++)
			cin >> ame[i][j];
	dp[0][0] = ame[0][0];
	dp[1][0] = ame[0][0] + ame[1][0];
	for (int from = 0;from < N - 1;from++) {
		dp[0][from + 1] = dp[0][from] + ame[0][from + 1];
		dp[1][from + 1] = max(dp[0][from + 1], dp[1][from]) + ame[1][from + 1];
	}
	cout << dp[1][N - 1] << endl;
	return 0;
}


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


int main() {
  string s,t;
  cin>>s;
  int q;
  cin>>q;
  while(q--) {
    int w1,w2;
    cin>>w1;
    if(w1==1) {
      swap(s,t);
    }else {
      char c;
      cin>>w2>>c;
      if(w2==1) {
        t+=c;
      }else {
        s+=c;
      }
    }
  }
  reverse(t.begin(),t.end());
  cout<<t<<s;
  return 0;
}

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

int main() {
  int n; cin >> n;
  long long sum = 0;
  vector<int> a;
  for (int i = 0; i < n; i++) {
    int x; cin >> x;
    if (x % 10) {
      a.push_back(x);
    }
    sum += x;
  }
  sort (a.begin(), a.end());
  for (auto x : a) {
    if (sum % 10) break;
    sum -= x;
  }
  if (sum % 10 == 0) {
    sum = 0;
  }
  cout << sum;

}


Measured memory_bytes: 3628
N,M=map(int,input().split())
A=[0]*M
import heapq
import collections
from itertools import permutations
table=collections.defaultdict(list)
AC=[[0,0] for i in range(M)]
C=[set() for i in range(M)]
for i in range(M):
  a,b=map(int,input().split())
  AC[i][0]=a
  tmp=set(map(int,input().split()))
  for x in tmp:
    AC[i][1] |= 1<<(x-1)
dp=[10**9]*(2**N)
dp[0]=0

for i in range(1,2**N):
  k=0
  s=set()
  for j in range(1,i):
    if i & j == j:
      dp[i]=min(dp[i],dp[j]+dp[i^j])
  for a,c in AC:
    if c&i == i:
      dp[i]=min(dp[i],a)
  #print(dp[i],bin(i))
  
if dp[-1]==10**9:
  print(-1)
else:
  print(dp[-1])
#print(dp)

  
  
#print(AC)


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

namespace ConsoleApp15
{
    class Class59
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = new int[N + 2];
            Console.ReadLine().Split().Select(int.Parse).ToArray().CopyTo(A, 1);
            A[N+1] = 0;A[0] = 0;
            int S = 0;
            for(int i = 0; i <= N; i++)
            {
                S += Abs(A[i] - A[i + 1]);
            }

            for(int i = 0; i < N; i++)
            {
                int ans = S + Abs(A[i] - A[i + 2]) - (Abs(A[i] - A[i + 1]) + Abs(A[i + 1] - A[i + 2]));
                Console.WriteLine(ans);
            }
        }
    }
}


Measured memory_bytes: 27612
use proconio::input;
use proconio::marker::Usize1;
use std::collections::VecDeque;

struct Node {
    to: Vec<usize>,
    from: Vec<usize>,
}

impl Node {
    fn new() -> Self
    {
        Node {
            to: Vec::new(),
            from: Vec::new(),
        }
    }
}

fn main()
{
    input! {
    n:usize,
    m:usize,
    edge:[(Usize1,Usize1);n+m-1],
    }

    let mut node = (0..n).map(|_| Node::new()).collect::<Vec<Node>>();
    for (a, b) in edge {
        node[a].to.push(b);
        node[b].from.push(a);
    }

    let mut cnt = vec![0; n];
    let mut ans = vec![0; n];

    let mut q = VecDeque::new();
    for i in 0..n {
        if node[i].from.len() == 0 {
            q.push_back(i);
            break;
        }
    }

    while let Some(idx) = q.pop_front() {
        for i in 0..node[idx].to.len() {
            let nxt = node[idx].to[i];
            cnt[nxt] += 1;
            if cnt[nxt] == node[nxt].from.len() {
                ans[nxt] = idx + 1;
                q.push_back(nxt);
            }
        }
    }

    for i in ans {
        println!("{}", i);
    }
}

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

const int mod = 1000000007;
struct mint {
    long long x;
    mint(long long x = 0): x((x % mod + mod) % mod) {}
    mint operator-() const {
        return mint(-x);
    }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) {
            x -= mod;
        }
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) {
            x -= mod;
        }
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        return mint(*this) += a;
    }
    mint operator-(const mint a) const {
        return mint(*this) -= a;
    }
    mint operator*(const mint a) const {
        return mint(*this) *= a;
    }
    mint pow(long long t) const {
        if (!t) {
            return 1;
        }
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) {
            a *= *this;
        }
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return *this *= a.inv();
    }
    mint operator/(const mint a) const {
        return mint(*this) /= a;
    }
};
istream& operator>>(istream& is, const mint& a) {
    return is >> a.x;
}
ostream& operator<<(ostream& os, const mint& a) {
    return os << a.x;
}

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

    int n;
    cin >> n;
    int zero = 0;
    map<pair<ll, ll>, pair<int, int>> mp;

    REP(i, n) {
        ll x, y;
        cin >> x >> y;
        if (x == 0 && y == 0) {
            zero++;
            continue ;
        }
        ll g = gcd(x, y);
        // ベクトルなので単位ベクトルに変換する
        x /= g;
        y /= g;
        // 条件はベクトルの内積が0(2つのベクトルのなす角度が90°)なので，
        // 2つのベクトルを同時に180°回転させても
        // 2つのベクトルのなす角度は変わらないので
        // 180°回転させる
        if (y < 0) {
            x = -x;
            y = -y;
        }
        if (y == 0 && x < 0) {
            x = -x;
            y = -y;
        }
        bool rot90 = false;
        if (x <= 0)
            rot90 = true;
        if (rot90) {
            ll tmp = x;
            x = y;
            y = -tmp;
        }
        if (rot90) // 90°回転させて場合の x, y はこっち
            mp[{x, y}].first++;
        else // 90°回転させてない場合の x, y はこっち
            mp[{x, y}].second++;
    }

    mint ans = 1;
    for (auto p : mp) {
        int s = p.second.first;
        int t = p.second.second;
        mint now = 1; // s, t どちらからも選ばない通り
        now += mint(2).pow(s) - 1; // s のみから1匹以上を選ぶ通り - 全員を選ばない通り
        now += mint(2).pow(t) - 1; // t のみから1匹以上を選ぶ通り - 全員を選ばない通り
        ans *= now;
    }

    ans -= 1; // どのグループからも選ばなかったときの通りを引く
    ans += zero; // (0, 0)単体だけを選ぶ場合を足す

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 16000
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

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

    int ans;
    for (ans = 111; ans < N; ans += 111) {}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int cnt[101]={};
int find(int num){
    int sum=0;
    for(int i=0;i<=n;i++){
        if(num<=cnt[i]) sum++;
    }
    return sum;
}
int main(){
    cin>>n;
    int so[101]={};
    for(int i=2;i<101;i++){
        if(so[i]==1) continue;
        for(int j=i+i;j<101;j+=i){
            so[j]=1;
        }
    }
    for(int i=2;i<=n;i++){
        int tmp=i;
        for(int j=2;j<101;j++){
            if(so[j]==1) continue;
            while(tmp%j==0){
                tmp/=j;
                cnt[j]++;
            }
        }
    }
    cout<<find(74)+find(24)*(find(2)-1)+find(14)*(find(4)-1)+find(4)*(find(4)-1)*(find(2)-2)/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int asc(const void *a, const void *b)
{
	return *(int *)a - *(int *)b;
}

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

	int *p = (int *)malloc(sizeof(int) * n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &p[i]);
	}

	qsort(p, n, sizeof(int), asc);

	int ans = 0;
	for (int i = 0; i < k; i++)
	{
		ans += p[i];
	}
	printf("%d\n", ans);

	free(p);

	return 0;
}

Measured memory_bytes: 1716
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAX_N=100000;
const int INF = 0x3f3f3f3f;

int a[100000];
int l[100000];
int main(){
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	
	for(int i=0;i<n;i++)
		cin>>a[i];
	l[0]=a[0];
	int length=1;	
	for(int i=1;i<n;i++){
		if(l[length-1]<a[i])
			l[length++]=a[i];
		else
			*lower_bound(l,l+length,a[i])=a[i];
	}
	cout<<length<<endl;
	return 0;
}




Measured memory_bytes: 3872
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define x first
#define y second
typedef pair <int, int> pi;

const int N = 1e5 + 10;
int n, u, v, v2, u2, ans, l, r, pa[N], sz[N];
vector <int> g[N];
pi p[N]; vector <pi> xx, yy;
struct edge { int u, v, w; };
bool operator < (edge a, edge b) { return a.w < b.w; }
vector <edge> e;

int root(int v) {
    return (pa[v] == v) ? v : pa[v] = root(pa[v]);
}

bool same(int u, int v) {
    return root(u) == root(v);
}

void merge(int u, int v) {
    u = root(u), v = root(v);
    if (u == v) return;
    if (sz[u] < sz[v]) swap(u, v);
    sz[u] += sz[v];
    pa[v] = u;
}

void kruskal() {
    for (int i = 0; i < n; ++i)
        pa[i] = i, sz[i] = 1;
    sort(e.begin(), e.end());
    for (auto i: e) {
        if (!same(i.u, i.v)) {
            merge(i.u, i.v);
            ans += i.w;
        }
    }
}

int f(int i, int j) {
    return min(abs(p[i].x - p[j].x), abs(p[i].y - p[j].y));
}

void make_graph() {
    for (int i = 0; i < n; ++i) {
        l = max(i - 3, 0ll), r = min(i + 3, n);
        v = xx[i].y;
        v2 = yy[i].y;
        for (int j = l; j < r; ++j) {
            u = xx[j].y;
            u2 = yy[j].y;
            if (v < u)
                e.push_back({v, u, f(v, u)});
            if (v2 < u2)
                e.push_back({v2, u2, f(v2, u2)});
        }
    }
}

main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> p[i].x >> p[i].y;
        xx.push_back({p[i].x, i});
        yy.push_back({p[i].y, i});
    }
    sort(xx.begin(), xx.end());
    sort(yy.begin(), yy.end());
    make_graph();
    kruskal();
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 23260
#include<iostream>
#include<math.h>
using namespace std;
int a[105];
int main(){
	int n;
	cin>>n;
	int tot = 0;
	for(int i = 0;i<n;i++){
		cin>>a[i]; tot+=a[i];
	}
	int temp = 0;
	int minim = 1e9;
	for(int i = 0;i<n;i++){
		temp+=a[i];
		if(abs(temp - (tot-temp)) < minim){
			minim = abs(temp - (tot-temp));
		}
	}
	cout<<minim<<"\n";
	return 0;
}

Measured memory_bytes: 384
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = input()

#i回目、jの手を出した時の点数の最大値
dp = [[0]*3 for _ in range(N)]

for i in range(N):
  if i>=1:
    dp[i][0] += max(dp[i-1][0],dp[i-1][1],dp[i-1][2])
    dp[i][1] += max(dp[i-1][0],dp[i-1][1],dp[i-1][2])
    dp[i][2] += max(dp[i-1][0],dp[i-1][1],dp[i-1][2])
    
  if T[i] == "s":
    dp[i][0] += R
  if T[i] == "p":
    dp[i][1] += S
  if T[i] == "r":
    dp[i][2] += P
    
  if i-K >= 0:
    dp[i][0] += max(dp[i-K][1],dp[i-K][2]) - max(dp[i-K][0],dp[i-K][1],dp[i-K][2])
    dp[i][1] += max(dp[i-K][2],dp[i-K][0]) - max(dp[i-K][0],dp[i-K][1],dp[i-K][2])
    dp[i][2] += max(dp[i-K][0],dp[i-K][1]) - max(dp[i-K][0],dp[i-K][1],dp[i-K][2])
  
print(max(dp[-1][0],dp[-1][1],dp[-1][2]))

Measured memory_bytes: 96232
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj),rend(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = (1 << 30);
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    fill((T*)array, (T*)(array + N), val);
}int n, m,a;
int main() {
    cin >> n; vector<vector<int>> a(n, vector<int>(n));
    rep(i, n) rep(j, n) cin >> a[i][j];
    vector<vector<bool>> exist(n, vector<bool>(n, 1));
    rep(i, n) { /// ワーシャルフロイド法
        rep(j, n) {
            rep(k, n) {
                if (a[i][j] > a[i][k] + a[k][j]) {
                    cout << -1 << endl;
                    return 0;
                }
                else if (k != i && k != j && a[i][j] == a[i][k] + a[k][j]) {
                    exist[i][j] = 0;
                }
            }
        }
    }ll ans = 0;
    rep(i, n) {
        rep(j, n) {
            if (exist[i][j]) ans += a[i][j];
        }
    }cout << ans / 2 << endl;
}

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

int main(){
    ll n, m; cin >> n >> m;
    ll a[m]; rep(i, m) cin >> a[i];
    ll sum = accumulate(a, a+m, 0);

    cout << ((sum > n) ? -1 : n - sum) << endl;

    return 0;
}

Measured memory_bytes: 3612
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        int q = Integer.parseInt(sc.next());
        int[] point = new int[n];
        Arrays.fill(point, k - q);
        for(int i = 0;i < q;i++){
            point[Integer.parseInt(sc.next()) - 1]++;
        }
        for(int i = 0;i < n;i++){
            if(point[i] >= 1){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }
    }
}

Measured memory_bytes: 58440
#include <iostream>
#include <vector>
#include <set>
#include <queue>

static bool is_con(
    const std::vector<std::vector<int>>& G,
    size_t n
)
{
    std::queue<int> w;
    std::set<int> fin;

    w.push(0);
    while (!w.empty()) {
        int i = w.front();  w.pop();
        fin.insert(i);
        for (size_t j = 0; j < n; j++) {
            if (G[i][j] == 1 && fin.find(j) == fin.end()) {
                w.push(j);
            }
        }
    }

    return fin.size() == n;
}

int main() {
    size_t n, m;
    std::cin >> n >> m;
    std::vector<std::vector<int>> G(n, std::vector<int>(n, 0));
    std::vector<std::pair<int, int>> E(m);
    for (size_t i = 0; i < m; i++) {
        int a, b;
        std::cin >> a >> b;
        a--; b--;
        E[i].first = a;  E[i].second = b;
        G[a][b] = G[b][a] = 1;
    }

    int c = 0;
    for (size_t i = 0; i < m; i++)
    {
        const auto& e = E[i];
        G[e.first][e.second] = G[e.second][e.first] = 0;
        if (!is_con(G, n)) {
            c++;
        }
        G[e.first][e.second] = G[e.second][e.first] = 1;
    }
    std::cout << c << std::endl;

    return 0;
}

Measured memory_bytes: 256
n, q = list(map(int, input().split()))
s = input()

a = [0 for i in range(n)]

for i in range(1, n):
  if s[i-1]=="A" and s[i]=="C":
    a[i]=a[i-1]+1
  else:
    a[i]=a[i-1]
    
for i in range(q):
  l, r = list(map(int, input().split()))
  print(a[r-1]-a[l-1])

Measured memory_bytes: 6224
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  ll N,X;
  cin>>N>>X;
  ll a;
  cin>>a;
  ll g=abs(X-a);
  for(ll i=0;i<N-1;i++){
    ll p;
    cin>>p;
    g=gcd(g,abs(p-X));
  }
  cout<<g;
return 0;}

Measured memory_bytes: 3588
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    double a,b,c;
    int cou1=0,cou2=0;
    while(scanf("%lf,%lf,%lf",&a,&b,&c)!=EOF){
        if(a*a+b*b==c*c)cou1++;
        if(a==b)cou2++;
    }
    printf("%d\n%d\n",cou1,cou2);
    return 0;
}

Measured memory_bytes: 1208
#include<cstdio>
#include<iostream>
#include<vector>
#define INF 0x3f3f3f3f
/*struct edge
{
	int v,w;
}
std::vector<edge> G[350];
void addEdge(u,v,w)
{
	G[u].push_back({v,w});
	G[v].push_back({u,w});
	return;
}*/
int G[301][301];
int f[301][301];
int matrix[301][301];
int main()
{
	int n,m,l;
	scanf("%d%d%d",&n,&m,&l);
	for(int i = 1;i <= n;i ++)
	{
		for(int j = 1;j <= n;j ++)
		{
			if(i != j)
			{
				G[i][j] = INF;
				f[i][j] = INF;
			}
		}
	}
	for(int i = 1;i <= m;i ++)
	{
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		G[u][v] = w;
		G[v][u] = w;
		f[u][v] = w;
		f[v][u] = w;
		//addEdge(u,v,w);
	}
	for(int k = 1;k <= n;k ++)
	{
		for(int i = 1;i <= n;i ++)
		{
			for(int j = 1;j <= n;j ++)
			{
				if(f[i][j] > f[i][k]+f[k][j])
				{
					f[i][j] = f[i][k]+f[k][j];
				}
			}
		}
	}
	for(int i = 1;i <= n;i ++)
	{
		for(int j = 1;j <= n;j ++)
		{
			matrix[i][j] = f[i][j] <= l ? 1 : INF;
			if(i == j)
				matrix[i][j] = 0;
		}
	}	
    for(int k = 1;k <= n;k ++)
    {
        for(int i = 1;i <= n;i ++)
            {
                for(int j = 1;j <= n;j ++)
                {
                    matrix[i][j] = std::min(matrix[i][j],matrix[i][k]+matrix[k][j]);
                }
            }
    }
    int q;
    scanf("%d",&q);
    while(q --)
    {
        int s,t;
        scanf("%d%d",&s,&t);
        if(matrix[s][t] >= INF)
        {
            printf("-1\n");
            continue;
        }
        printf("%d\n",matrix[s][t]-1);
    }
    return 0;
}


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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  cout << (s[2] == s[3] && s[4] == s[5]? "Yes\n":"No\n");
  return 0;
}


Measured memory_bytes: 256