akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);
  bool begin = true;
  while(1) {
    int n; cin >> n;
    if(n == 0) break;
    if(begin) begin = false;
    else cout << endl;
    int a, b, c, d; cin >> a >> b >> c >> d;
    vi ans;
    int sum = 100;
    REP(i, a+1) {
      REP(j, b+1) {
        REP(k, c+1) {
          REP(l, d+1) {
            int s = 10 * i + 50 * j + 100 * k + 500 * l;
            if(s >= n) {
              int cnt = a + b + c + d - (i + j + k + l);
              s -= n;
              bool verbose = false;
              while(s >= 500) {
                if(l > 0) {
                  verbose = true;
                  break;
                }
                cnt++;
                s -= 500;
              }
              while(s >= 100) {
                if(k > 0 || verbose) {
                  verbose = true;
                  break;
                }
                cnt++;
                s -= 100;
              }
              while(s >= 50) {
                if(j > 0 || verbose) {
                  verbose = true;
                  break;
                }
                cnt++;
                s -= 50;
              }
              while(s >= 10) {
                if(i > 0 || verbose) {
                  verbose = true;
                  break;
                }
                cnt++;
                s -= 10;
              }
              if(cnt < sum && !verbose) {
                sum = cnt;
                ans = vi {i, j, k, l};
              }
            }
          }
        }
      }
    }
    if(ans[0]) cout << 10 << " " << ans[0] << endl;
    if(ans[1]) cout << 50 << " " << ans[1] << endl;
    if(ans[2]) cout << 100 << " " << ans[2] << endl;
    if(ans[3]) cout << 500 << " " << ans[3] << endl;
  }
}



Measured memory_bytes: 3020
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <map>
#define loop(i,a,b) for(int i=a; i<b; i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()

using namespace std;

typedef vector<int> vi;

string const res[] = { "NA", "OK" };

int main(){
    int a, b, c;
    while (cin >> a >> b >> c && a | b | c){
        vi v{ a, b, c };
        double d = 1e50;
        rep(i, 3)rep(j, 3)if (i != j){
            d = min(d, sqrt(v[i] * v[i] + v[j] * v[j]));
        }
        int n; cin >> n;
        rep(i, n){
            double r; cin >> r;
            r *= 2;
            double const eps = 1e-9;
            cout << res[r - eps > d] << endl;
        }
    }
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
  #define debug(...) printf(__VA_ARGS__)
#else
  #define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int MAX = 1050;
char ans[MAX][MAX];

int main() {
  int N, M, A, B;
  cin >> N >> M >> A >> B;
  if (N % 2) {
    int y = 0;
    while (y + 2 <= M && A) {
      ans[N - 1][y] = '<';
      ans[N - 1][y + 1] = '>';
      y += 2;
      A--;
    }
  }
  if (M % 2) {
    int x = 0;
    while (x + 2 <= N && B) {
      ans[x][M - 1] = '^';
      ans[x + 1][M - 1] = 'v';
      x += 2;
      B--;
    }
  }
  debug("%d %d %d %d\n", A, B, N, M);
  debug("%d %d\n", (A + 1) / 2 + (B + 1) / 2, (N / 2) * (M / 2));
  int count = ((N / 2) * (M / 2)) - ((A + 1) / 2 + (B + 1) / 2);
  bool spe = false;
  if (A % 2 && B % 2 && N % 2 && M % 2)
    spe = true;
  if (count != -1)
    spe = false;
  if (count < 0 && !spe) {
    puts("NO");
    return 0;
  }
  if (spe)
    A--, B--;
  for (int i = 0; i + 2 <= N; i += 2) {
    for (int j = 0; j + 2 <= M; j += 2) {
      if (A) {
        ans[i][j] = '<';
        ans[i][j + 1] = '>';
        A--;
        if (A) {
          ans[i + 1][j] = '<';
          ans[i + 1][j + 1] = '>';
          A--;
        }
      }
      else if (B) {
        ans[i][j] = '^';
        ans[i + 1][j] = 'v';
        B--;
        if (B) {
          ans[i][j + 1] = '^';
          ans[i + 1][j + 1] = 'v';
          B--;
        }
      }
    }
  }
  if (spe) {
    strcpy(ans[N - 3] + (M - 3), "^<>");
    strcpy(ans[N - 2] + (M - 3), "v.^");
    strcpy(ans[N - 1] + (M - 3), "<>v");
  }
  assert(A == 0);
  assert(B == 0);
  for (int i = 0; i < N; i++)
    for (int j = 0; j < M; j++)
      if (!ans[i][j])
        ans[i][j] = '.';
  puts("YES");
  for (int i = 0; i < N; i++)
    puts(ans[i]);
  return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define PI 3.1415926535897932384626433
#define mod 1000000007
 
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
 
int lcm(int a, int b) { return a * b / gcd(a, b); }
 
int main(){
    int n, d;
    cin >> n >> d;
    int ans = n / (d * 2 + 1);
    if ((n % (d * 2 + 1) != 0))
    {
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def judge(s, t):
    for i in range(len(s)):
        if s[i] != t[i] and s[i] != "?":
            return False
    return True


s = input()
t = input()

res = ""
for i in reversed(range(len(s) - len(t)+1)):
    ss = s[i:i+len(t)]
    if judge(ss, t):
        res = s[:i] + t + s[i+len(t):]
        break
print(res.replace("?", "a") if res != "" else "UNRESTORABLE")



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n;
    cin>>n;
    vector<ll> v;
    for(ll i=0;i<n;i++){
        ll k;cin>>k;
        v.pb(k);
    }
    sort(v.begin(),v.end());
    cout<<v[n-1]-v[0]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define int long long
using namespace std;
int n,m,cnt=0;
int head[410000],nxt[410000],to[410000],val[410000];
int ma=0,mi=0;
int q[1000000],dis[100100],f[100100],vis[100100];
void addedge(int x,int y,int z)
{
    cnt++;
    nxt[cnt]=head[x];
    head[x]=cnt;
    to[cnt]=y;
    val[cnt]=z;
}
bool spfa(int x)
{
    int l=0,r=1;
    q[1]=x;vis[x]=1;dis[x]=0;
    while(l<r)
    {
        int u=q[++l];
        for(int i=head[u];i!=-1;i=nxt[i])
        {
            int v=to[i];
            if(dis[v]==12345678987654321)
            {
                dis[v]=dis[u]+val[i];
                ma=max(ma,dis[v]);
                mi=min(mi,dis[v]);
                if(ma-mi>1e9) return 0;
                vis[v]=1;
                if(!f[v]) q[++r]=v,f[v]=1;
            }
            else if(dis[v]!=dis[u]+val[i]) return 0;
        }
        f[u]=0;
    }
    return 1;
}
signed main()
{
//	freopen("line.in","r",stdin);
//	freopen("line.out","w",stdout);
    memset(head,-1,sizeof(head));
    for(int i=1;i<=100000;i++)
        dis[i]=12345678987654321;
    scanf("%lld%lld",&n,&m);
    if(!m) {printf("Yes");return 0;}
    for(int i=1;i<=m;i++)
    {
        int x,y,z;
        scanf("%lld%lld%lld",&x,&y,&z);
        addedge(x,y,z);
        addedge(y,x,-z);
    }
    for(int i=1;i<=n;i++)
        if(!vis[i]) {if(!spfa(i)) {printf("No");return 0;}}
    printf("Yes");
    return 0;
}

Measured memory_bytes: 19072
#include<cstdio>
#define RI register int
#define CI const int&
using namespace std;
const int N=605,mod=1e9+7;
int n,k,x,y,f[N][N],p[N],g[N],sum[N],ans;
inline void DP(CI l,CI r)
{
	if ((sum[r]-sum[l-1])&1) return; RI i;
	for (i=l;i<=r;++i) if (p[i]&&(p[i]<l||p[i]>r)) return;
	int ret=g[sum[r]-sum[l-1]]; for (i=l+1;i<=r;++i)
	if (f[l][i-1]) ret=(ret-1LL*f[l][i-1]*g[sum[r]-sum[i-1]]%mod+mod)%mod;
	f[l][r]=ret; (ans+=1LL*ret*g[n-(k<<1)-(sum[r]-sum[l-1])]%mod)%=mod;
}
int main()
{
	RI i,j; for (scanf("%d%d",&n,&k),n<<=1,i=1;i<=k;++i)
	scanf("%d%d",&x,&y),p[x]=y,p[y]=x;
	for (g[0]=1,i=2;i<=n;i+=2) g[i]=1LL*g[i-2]*(i-1)%mod;
	for (i=1;i<=n;++i) sum[i]=sum[i-1]+(!p[i]);
	for (j=1;j<=n;++j) for (i=n;i-j+1;--i) DP(i-j+1,i);
	return printf("%d",ans),0;
}

Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int ans;
int i,j;
int main(){
	string s;
	cin>>s;
	j=1;
	while(j<s.size()){
		if(s[i]==s[j])j++;
		else 
		    i=j,j++,ans++;
	}
	cout<<ans;
}


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

using namespace std;

int main()
{
  int n,i,j,x,y,cost,ans;
  vector <int> v;
  
  cin >> n;
  
  for(i=1;i<=n;i++){
    cin >> j;
    v.push_back(j);
  }
  
  x = *max_element(v.begin(),v.end());
  y = *min_element(v.begin(),v.end());
  
  ans = numeric_limits<int>::max();
  for(i=y;i<=x;i++){
    cost = 0;
    for(j=0;j<n;j++){
      cost += (v[j]-i)*(v[j]-i);
    }
    ans = min(ans,cost);
  }
  
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i,j,result1=7,result2=7;
	double data1,data2;
	double set1[7]={35.5,37.5,40,43,50,55,70};
	double set2[7]={71,77,83,89,105,116,148};
	
	while((scanf("%lf %lf",&data1,&data2)) != EOF){
	
		for(i=6;i>=0;i--){
			if(data1<set1[i])
				result1=i;
			if(data2<set2[i])
				result2=i;
		}
		
		if(result1>=result2)
			result1=result1;
		else
			result1=result2;
		
		switch(result1){
			case 0:
				printf("AAA\n");
				break;
			case 1:
				printf("AA\n");
				break;
			case 2:
				printf("A\n");
				break;
			case 3:
				printf("B\n");
				break;
			case 4:
				printf("C\n");
				break;
			case 5:
				printf("D\n");
				break;
			case 6:
				printf("E\n");
				break;
			default:
				printf("NA\n");
				break;
		}
	
		result1=7;
		result2=7;
	
	}
	
	return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int N, R;
  cin >> N >> R;
  if (N < 10) {
    R += 100 * (10 - N);
  }
  cout << R << '\n';
  return 0;
}

Measured memory_bytes: 3552
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]
word = set(S + T)
ans = 0

for w in word:
    amount = S.count(w) - T.count(w)
    ans = max(ans, amount)

print(ans)

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

bool isPrime(int p) {
    if (p <= 1) return false;
    for (int i = 2; i*i <= p; i++) {
       if (p % i == 0) return false;
    }
    return true;
}
  
int main() {
    int n, p, count = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> p;
        if (isPrime(p)) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>s;
	long long res=0;
	long long cnt=0;
	for(int i=0;i<s.size()-1;i++){
		if(s[i]=='B'&&s[i+1]=='C'){
			res+=cnt;
			i++;
		}
		else if(s[i]=='A'){
			cnt+=1LL;
		}
		else{
			cnt=0LL;
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	const int MAXN = 1e5 + 1;	
	int n, m, fim[MAXN];
	vector<int> comeco[MAXN];
	cin >> n >> m;
	memset(fim, 0, (n + 1) * sizeof(int));
	for(int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		++fim[b];
		comeco[a].push_back(b);
	}
	int low = 1, high = 1, rem = 0;
	while(high < MAXN) {
		if(fim[high]) {
			++rem;
			while(low < high) {
				for(int f : comeco[low])
					--fim[f];
				++low;
			}
		}
		++high;
	}	
	cout << rem << '\n';
	return 0;
}

Measured memory_bytes: 6144
N = int(input())
A = list(map(int,input().split()))
ans = 1
flag = None
for i in range(N-1):
  if flag is None:
    flag = 1 if A[i]<A[i+1] else -1 if A[i]>A[i+1] else 0
  else:
    if flag == 0:
      if A[i]<A[i+1]: flag = 1
      elif A[i]>A[i+1]: flag =- 1
    elif A[i]<A[i+1] and flag == -1:
      ans += 1
      flag = None
    elif A[i]>A[i+1] and flag == 1:
      ans += 1
      flag = None
print(ans)

Measured memory_bytes: 62704
import java.io.IOException;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int ans = (n * (n - 1) / 2) + (m * (m - 1)/ 2);
        System.out.println(ans);
    }
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb push_back
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<ii> vii;

const int MX = 150005;
const ll inf = 2e18;
int main () 
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    set<int> s;
    forr(i,0,3)
    {
        int num;
        cin>>num;
        s.insert(num);
    }
    if (s.size()==2)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

bool is_kaibun(string & s)
{
	string s2 = s;
	std::reverse(s2.begin(), s2.end());
	return s == s2;
}

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

	int n = s.length();
	int l = (n - 1) / 2;

	string sa = s.substr(0, l);
	string sb = s.substr(n - l, l);
	
	bool ok = is_kaibun(sa) && is_kaibun(sb) && is_kaibun(s);
	if (ok)
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 256
import sys
#input = sys.stdin.buffer.readline
 
def main():
    s = input()
    l = len(s)
    if "0" not in s or "1" not in s:
        print(l)
    else:
        ans = 10**6
        for i in range(l-1):
            if s[i] != s[i+1]:
                ans = min(ans,max(i+1,l-i-1))
        print(ans)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int L = sc.nextInt();
		sc.close();
		// N個のリンゴ全てを材料としてできるアップルパイの「味」
		int sum = 0;
		for(int i = 1; i <= N; i++) {
			sum += L + i - 1;
		}
		// System.out.println("sum = " + sum);
		// N - 1個のリンゴを材料としてできるアップルパイの「味」との差
		int min = Integer.MAX_VALUE;
		int r = sum;
		for(int i = 1; i <= N; i++) {
			int apple =  L + i - 1;
			int abs = Math.abs(apple);
			// System.out.println("apple = " + apple + " : " +  (sum - apple));
			if(abs < min) {
				min = abs;
				r = sum - apple;
			}
		}
		// System.out.println("min = " + min);
		System.out.println(r);
	}
}


Measured memory_bytes: 21332
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vi = vector<int>;
using vs = vector<string>;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repp(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define repd(i, n) for(ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(), x.end()

const ll M = 1e9 + 7;



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

	int n;
	cin >> n;

	int d1, d2;
	int num = 0;
	rep(i, n) {
		cin >> d1 >> d2;
		if(d1 == d2) num++;
		else num = 0;
		if(num == 3) return cout << "Yes" << endl, 0;
	}

	cout << "No" << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
const int MAX_N=105;
const int MAX_V=100050;
const long long INF=9e18;
long long dp[MAX_N][MAX_V];
int w[MAX_N],v[MAX_N];
int main()
{
	int n,W;
	scanf("%i %i",&n,&W);
	for(int i=1;i<=n;i++)
	{
		scanf("%i %i",&w[i],&v[i]);
	}
	for(int i=0;i<MAX_V;i++)
	{
		if(i==0) dp[0][i]=0;
		else dp[0][i]=INF;
	}
    for(int i=1;i<=n;i++)
	{
		for(int j=0;j<MAX_V;j++)
		{
			dp[i][j]=dp[i-1][j];
			if(j>=v[i])
			{
				dp[i][j]=min(dp[i][j],dp[i-1][j-v[i]]+w[i]);
			}
		}
	}
	int ans=0;
	for(int i=1;i<MAX_V;i++)
	{
		if(dp[n][i]<=W)
		{
			ans=i;
		}
	}
	printf("%i\n",ans);
	return 0;
}

Measured memory_bytes: 80128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Contest
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int kq = 0;
            for (int i = 1; i <= n; i++)
                if (i.ToString().Length % 2 == 1)
                    kq++;
            Console.WriteLine(kq);
        }
    }
}


Measured memory_bytes: 13268
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  vector<vector<int>> f(n, vector<int>(10, 0)), p(n, vector<int>(11));
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < 10; j++){
      cin >> f[i][j];
    }
  }
  for(int i = 0; i < n; i++){
    for(int j = 0; j <= 10; j++){
      cin >> p[i][j];
    }
  }
  ll ans = -1001001001001;
  for(int bit = 1; bit < (1 << 10); bit++) {
    ll sum = 0;
    for(int i = 0; i < n; i++) {
      int c = 0;
      for(int j = 0; j < 10; j++){
        if((bit >> j) & 1 && f[i][j]) {
          c++;
        }
      }
      sum += p[i][c];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }

int main()
{
  int N,K;
  cin >> N >> K;
  double ans = 0;
  REP(i,N){
    double bi = 0.5;
    int cnt = 0;
    while(K > (i+1)*(int)pow(2,cnt)){
      cnt++;
    }
    ans += pow(0.5,cnt)/N;
  }
  cout <<fixed << setprecision(20) << ans << endl; 
}

Measured memory_bytes: 256
/*	
	*  Sachin Mittal
	*/
	#include<bits/stdc++.h>
	#define int long long
	#define M 998244353
	#define mod 1000000007
	#define all(v) v.begin(),v.end()
	#define rep(i,j,n) for(int i=j;i<n;i++)
	#define F first
	#define S second
	#define lb lower_bound
	#define mem0(dp) memset(dp,0,sizeof(dp))
	#define mem1(dp) memset(dp,-1,sizeof(dp))
	#define pb push_back
	#define sz(s) (int)(s.size())
	#define debug(x) cout << #x << " = " << x << '\n';
	using namespace std;

	void solve()
	{
		int n;cin>>n;
		int ans=0;
		rep(i,1,n+1)
		{
			rep(j,1,n+1)
			{
				rep(k,1,n+1)
				{
					ans+=(__gcd(i,__gcd(j,k)));
				}
			}
		}
		cout<<ans;
	}

	int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	}

Measured memory_bytes: 3648
n=int(input())
p=list(map(int, input().split()))
answer=0
for i in range(len(p)-2):
    if p[i]<p[i+1] & p[i+1]<p[i+2]:
        answer+=1
    if p[i]>p[i+1] & p[i+1]>p[i+2]:
        answer+=1
print(answer)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>

using namespace std;
static const int INF = 1e9;
int ans = INF;
int dp[1001][1001];

void solve()
{
	int N, M;
	cin >> N >> M;
	vector<int> D(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> D[i];
	}
	vector<int> C(M);
	for (int i = 0; i < M; ++i)
	{
		cin >> C[i];
	}
	for (int i = 0; i <= N; ++i)
	{
		for (int j = 0; j <= M; ++j)
		{
			dp[i][j] = INF;
		}
	}
	for (int i = 0; i < M; ++i)
	{
		dp[0][i] = 0;
	}
	for (int i = 0; i < N; ++i)
	{
		for (int j = 0; j < M; ++j)
		{
			dp[i + 1][j + 1] = min(dp[i + 1][j], dp[i][j] + D[i] * C[j]);
		}
	}
	cout << dp[N][M] << endl;
}

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

Measured memory_bytes: 4380
n=int(input())
lst = []
cnt = 1000
while n > 0:
    lst.append(n%10)
    n //= 10 # 必須
lst.reverse()
for j in range(len(lst)-2):
  temp=lst[j]*100+lst[j+1]*10+lst[j+2]
  if abs(temp-753)<cnt:
    cnt=abs(temp-753)
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  string Ans = "Three";
  for (int i = 0; i < N; i++) {
    string H;
    cin >> H;
    if (H == "Y") {
      Ans = "Four";
      break;
    }
  }
  cout << Ans << endl;
}


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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (200006)
ll n, mod=1e9+7, inv[MAXN], depth[MAXN], st[MAXN], en[MAXN], co, p[MAXN][19], ans, dp[MAXN];
vector<int>v[MAXN],ppl,me[MAXN];
ll qexp(ll x,ll e){ll sum=1;for(;e;e>>=1,x*=x,x%=mod)if(e&1)sum*=x,sum%=mod;return sum;}
int main(){
	FOR(i,0,MAXN-1)inv[i]=qexp(i,mod-2);
	FAST
	cin>>n;
	FOR(i,1,n){
		ll p;
		cin>>p;
		v[p].eb(i);
	}
	function<void(ll)>dfs=[&](ll x){
		st[x]=co++;
		for(auto i:v[x]) depth[i]=depth[x]+1, p[i][0]=x, dfs(i);
		en[x]=co-1;
	};
	dfs(0);
	FOR(j,1,18)FOR(i,0,n)p[i][j]=p[p[i][j-1]][j-1];
	auto isp=[&](ll a,ll b){
		return st[a]<=st[b]&&en[a]>=en[b];
	};
	auto lca=[&](ll x,ll y){
		if(isp(x,y))return x;
		if(isp(y,x))return y;
		DEC(i,18,0)if(!isp(p[x][i],y))x=p[x][i];
		return p[x][0];
	};
	FOR(i,0,n)ppl.eb(i);
	sort(all(ppl),[](int x,int y){return depth[x]>depth[y];});
	FOR(i,0,n){
		vector<int> tmp, nodes;
		vector<pi> e;
		while(ppl.size()&&depth[ppl.back()]==i)tmp.eb(ppl.back()),ppl.pop_back();
		if(tmp.empty())continue;
		set<pi,greater<pi>> s;
		for(auto i:tmp)s.ins(pi(st[i],i));
		while(s.size() > 1){
			ll x=s.begin()->s, y=next(s.begin())->s;
			s.erase(s.begin());
			nodes.eb(x);
			if(isp(y,x)){
				e.eb(y,x);
				continue;
			}
			ll la=lca(x,y);
			e.eb(la,x);
			s.ins(pi(st[la],la));
		}
		if(s.size())nodes.eb(s.begin()->s);
		for(auto i:nodes) me[i].clear();
		for(auto i:e) me[i.f].eb(i.s); e.clear();
		sort(all(nodes),[](int x,int y){return depth[x]>depth[y];});
		for(auto i:nodes){
			dp[i]=0;
			if(me[i].empty()){
				dp[i]=inv[2];
			}else{
				ll mul=1;
				for(auto j:me[i]) mul *= ((1+mod-dp[j])%mod), mul %= mod;
				for(auto j:me[i]) dp[i]+=dp[j]*mul%mod*qexp(((1+mod-dp[j])%mod), mod-2)%mod, dp[i]%=mod;
			}
		}
		ans += dp[nodes.back()], ans %= mod;
	}
	FOR(i,0,n)ans*=2,ans%=mod;
	cout<<ans<<'\n';
}


Measured memory_bytes: 72788
#!/usr/bin/env python3
s = input()
k = int(input())
t = list(map(lambda c: ord(c)-ord('a'), s))
for i in range(len(t)):
    if t[i] != 0 and 26-t[i] <= k:
        k -= 26-t[i]
        t[i] = 0
if k:
    t[i] = (t[i]+k) % 26
    k = 0
ans = ''.join(map(lambda c: chr(c+ord('a')), t))
print(ans)


Measured memory_bytes: 4980
h,w = map(int, input().split())
li = []
for i in range(h):
    a = list(input())
    '''
    if all([a[i] == "." for i in range(w)]):
        continue
    else:
        li.append(a)
    '''
    if "#" in a:
      li.append(a)
for j in range(w):
    #if all([li[k][j] == "." for k in range(len(li))]):
    if all(li[k][j] == "." for k in range(len(li))):
        for k in range(len(li)):
            #li[k][j] == ""
            li[k][j] = ""
for m in range(len(li)):
    print("".join(li[m]))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <limits>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    ll N;
    cin >> N;
    vector<ll> nexts(N, -1);
    for (auto &&i: irange(0LL, N)){
        ll a;
        cin >> a;
        a--;
        nexts.at(i) = a;
    }

    vector<bool> visited(N, false);
    ll flickering{0};
    ll count{0};
    while (true){
        if (flickering == 1){
            cout << count << endl;
            return 0;
        }
        flickering = nexts.at(flickering);
        if (visited.at(flickering)){
            cout << -1 << endl;
            return 0;
        }
        visited.at(flickering) = true;
        count++;
    }
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#define MOD 1000000007
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;

	int ans = -1;
	for (size_t i = 0; i < 1251; i++)
	{
		if ((int)((float)i * 0.08f) == a && (int)((float)i * 0.1f) == b) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
//Resting_Prince
#include<bits/stdc++.h>
#define mod 1000000007
#define inf 1e18
#define PI 3.141592653589
#define fi first
#define se second 
#define sv(v) sort(all(v));reverse(all(v))
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mk make_pair
#define en '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double ld;

ll n,dp[200005][2];
vector<ll> g[200005];

void rec(ll node,ll p)
{
    for(auto y:g[node])
    {
        if(y==p)continue;
        rec(y,node);
        dp[node][0]*=(dp[y][0]+dp[y][1]);
        dp[node][0]%=mod;
        dp[node][1]*=(dp[y][0]);
        dp[node][1]%=mod;
    }
}

int main()
{
    ll i,j,k;
    cin>>n;
    rep(i,0,n-2)
    {
        cin>>j>>k;
        g[j].pb(k);
        g[k].pb(j);
    }
    rep(i,0,100005)dp[i][0]=1,dp[i][1]=1;
    rec(1,-1);
    cout<<(dp[1][0]+dp[1][1])%mod;
    return 0;
}


Measured memory_bytes: 16640
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
using namespace std;

int inf = 2147483647;
int64_t inf64 = 9223372036854775807;
int MOD = 1e+7;

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

  int n;
  cin >> n;
  priority_queue<double, vector<double>, greater<double>> foods;
  rep(i,n) {
    double v;
    cin >> v;
    foods.push(v);
  }

  double res = 0;
  res += foods.top();
  foods.pop();
  rep(i,n-1) {
    res += foods.top();
    foods.pop();
    res /= 2.0;
  }
  cout << prec(10) << res << endl;
  return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
a = list(map(int,input().split()))
cnt = 0
while True:
  if a[0] % 2 == 0:
    a[0] //= 2
    cnt += 1
  else:
    break
div = 2 ** cnt
if div != 1:
  m //= (div//2)
for i in range(1,n):
  if a[i] % div == 0:
    a[i] //= div
    if a[i] % 2 == 0:
      print(0)
      break
  else:
    print(0)
    break
  if cnt == 0:
    print(0)
    break
else:
  #print(a)
  lcm = a[0]
  for i in range(1,n):
    big,sml = a[i],lcm
    while sml != 0:
      big,sml = sml,big%sml
    lcm *= a[i] // big
  #print(lcm)
  ans = m // (2*lcm)
  #print(ans)
  if m % (2*lcm) >= lcm:
    ans += 1
  print(ans)

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

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int gcd(int a, int b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));}

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

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> h(n);
  REP(i, n) cin >> h[i];
  int ans = 0;
  int activate = 0;
  REP(i, n){
    if (h[i] < activate){
      activate = h[i];
    }
    else{
      ans += h[i] - activate;
      activate = h[i];
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main()
{
	long long n, buffer, max[2] = {0,0}, imax;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> buffer;
		if (buffer >= max[0])
		{
			max[1] = max[0];
			max[0] = buffer;
			imax = i;
		}
		else if (buffer > max[1]) max[1] = buffer;
	}
	for (int i = 0; i < n; i++)
	{
		if (i == imax) cout << max[1]<<endl;
		else cout << max[0]<<endl;
	}
}

Measured memory_bytes: 1664
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

int main() {
  int n, m;
  cin >> n >> m;
  int ans = 100 * (n - m);
  ans += 1900 * m;
  rep(i, m) { ans = ans << 1; }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int l = 0;
	while (l < n && s[l] == 'R') l++;
	int r = n - 1;
	while (r >= 0 && s[r] == 'W') r--;
	int ans = 0;
	while (l < r) {
		while (l < r && s[l] == 'R') l++;
		while (l < r && s[r] == 'W') r--;
		if (l >= r) {
			break;
		}
		swap(s[l], s[r]);
		ans++;
		l++;
		r--;
	}
	cout << ans;
}


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

using namespace std;

#define X first
#define Y second
#define eps  1e-5
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1e5+7;
const int INF  = 1<<30;
const int mod  = 1e9+7;

int s[maxn];
int n;
void solve(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>s[i];
    }
    long long ans = 0,cnt ;
    sort(s+1,s+1+n);
    for(int i=n;i;i--){
        for(int j=i-1;j;j--){
            cnt = upper_bound(s+1,s+1+n,s[i] - s[j]) - s;
           // printf("cnt = %lld\n",cnt );
            ans += max(0ll,(LL)(j-cnt));
        }
    }    
    cout<<ans<<'\n';
    return;
}

int main()
{
#ifndef ONLINE_JUDGE
   // freopen("in.txt","r",stdin);
#endif
//    freopen("out.txt","w",stdout);
//    ios::sync_with_stdio(false);
    int t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
#ifndef ONLINE_JUDGE
  //  printf("%.10f\n",1.0*clock()/CLOCKS_PER_SEC);
#endif
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <cstdlib>

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pi;

const ll MOD = 1e9+7;

static long gcd(long a, long b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}
/*
long long int facctorialMethod(int k){//階乗
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}*/

long long int tousasum(long long int n){//等差数列
    return n*(n+1)/2;
}

unsigned GetDigit(unsigned num){//桁数
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

bool IsPrime(int num)//素数判定
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

map< ll, ll > prime_factor(ll n) {//素因数分解
    map< ll, ll > ret;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

ll calcNumOfCombination(ll n, ll r){
    ll num = 1;
    for(ll i = 1; i <= r; i++){
        num = num * (n - i + 1) / i;
    }
    return num;
}

int bubblesort(vector<int> array,int size){//バブルソート　転倒数
    int kaisu = 0;
    for(int i = 0; i < size; i++){
        for(int j = i + 1; j < size; j++){
            if(array[i] > array[j]){
                int number = array[i];
                array[i] = array[j];
                array[j] = number;
                kaisu++;
            }
        }
    }
    return kaisu;
}

ll facctorialMethod(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum = (sum * i)%MOD;
    }
    return sum;
}

int main() {
    int A,B;
    cin >> A >> B;
    if(A<10&&B<10){
        cout << A*B <<endl;
    }else{
        cout << -1 << endl;
    }


}





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

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> grid(n, vector<int> (m));
    vector<int> row(n);
    vector<int> column(m);
    char c;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            cin >> c;
            if (c == '#') {
                grid[i][j] = 1;
                row[i]++;
                column[j]++;
            }
        }
    }
    for(int i = 0; i < n; i++) {
        if (row[i] != 0) {
            for(int j = 0; j < m; j++) {
                if(column[j] != 0) {
                    if (grid[i][j] == 0) {
                        cout << ".";
                    } else {
                        cout << "#";
                    }
                }
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 256
N, K = map(int, input().split())

S = input()

s_dic = {"A":"a", "B":"b", "C":"c", "D":"d",
         "E":"e", "F":"f", "G":"g", "H":"h",
         "I":"i", "J":"j", "K":"k", "L":"l",
         "M":"m", "N":"n", "O":"o", "P":"p", "Q":"q",
         "R":"r", "S":"s", "T":"t", "U":"u",
         "V":"v", "W":"w", "X":"x", "Y":"y", "Z":"z"
        }

output = ""
for i in range(len(S)):
    if i == K - 1:
        output += s_dic[S[i]]
    else:
        output += S[i]

print(output)

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


int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n){
    cin >> a[i];
  }
  vector<ll> b(n);
  rep(i,n){
    ll x;
    x = a[i];
    b[x-1]++;
  }
  ll ans = 0;
  rep(i,n){
    ll y;
    y = b[i];
    ll z;
    if(y == 0 || y == 1){
      z = 0;
    }
    else{
      z = y * (y-1) / 2;
    }
    ans = ans + z;
  }
  
  rep(i,n){
    ll p;
    if(b[a[i]-1] == 0){
      p = 0;
    }
    else{
    p = b[a[i]-1] - 1;
    }
    cout << ans - p << endl;
  }
  
    
  return 0;
}




Measured memory_bytes: 6404
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int ans = 0;
  for (int i = 1; i <= N; ++i) {
    if (to_string(i).size() % 2 == 1) {
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int L, R, d;
  cin >> L >> R >> d;
  int ans = 0;
  for(int i=L;i<=R;i++){
    if(i%d == 0){
      ans++;
    }
  }
  cout << ans << endl;
}
    


Measured memory_bytes: 3580
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();
        int[] t = new int[n];
        for (int i = 0; i < n; i++) {
            t[i] = sc.nextInt();
        }
        Arrays.sort(t);
        int preT = t[0];
        int sum = 0;
        long ans = 0;
        for (int i = 0; i < n; i++) {
            if(t[i] - preT > k){
                ans++;
                sum -= Math.min(sum, c);
                preT = t[i];
            }
            sum++;
            if(sum >= c){
                ans++;
                sum -= Math.min(sum, c);
                if(i < n-1) preT = t[i+1];
            }

        }
        if(sum > 0) ans++;
        System.out.println(ans);
        sc.close();
    }

}


Measured memory_bytes: 50368
n=gets.chomp.to_i
a=gets.chomp.split(" ").map { |e| e.to_s }

count = 0

rec = {}

for x in a do
  if rec[x] == nil
    rec[x] = 1
  else
    rec[x] += 1
  end
end

rec.each{ |key,value|
  n = key.to_i
  if value >= n
    count += value - n
  else
    count += value
  end
}

puts count



Measured memory_bytes: 19460
import java.util.Scanner;

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

        long W = stdIn.nextLong();
        long H = stdIn.nextLong();
        int x = stdIn.nextInt();
        int y = stdIn.nextInt();

        System.out.println(W*H/2.0);
        if(2*x == W && 2*y == H){
            System.out.println(1);
        }else{
            System.out.println(0);
        }
    }
}


Measured memory_bytes: 21844
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	const inf = 1 << 60

	n := nextInt()
	a := make([][]int, n)
	for i := range a {
		a[i] = nextInts(n)
		a[i][i] = inf
	}

	sum := 0
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			// 経路i-k-j
			// 直通の道がなくても事足りるか
			eq := false
			for k := 0; k < n; k++ {
				if a[i][j] > a[i][k]+a[k][j] {
					puts(-1)
					return
				}
				eq = eq || (a[i][j] == a[i][k]+a[k][j])
			}
			if !eq {
				sum += a[i][j]
			}
		}
	}

	puts(sum)
}


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

using namespace std;


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

    long long res = 0;
    for (long long i = 1; i <= N; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            res += i;
        }
    }

    cout << res << endl;
    return 0;
}

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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	string s;
	string t;
	cin >> s >> t;
	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j < s.size(); j++) {
			if (j+i >=s.size()) {
				if (s[j] != t[j + i - s.size()]) {
					break;
				}
			}
			else {
				if (s[j] != t[j + i]) {
					break;
				}
			}
			if (j == s.size() - 1) {
				cout << "Yes";
				return 0;
			}
		}
	}
	cout << "No";
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
l =[]
r =[]
for id,h in enumerate(A,start=1):
    r.append(id -h)
    l.append(id +h)

r_cou =Counter(r)
l_cou =Counter(l)
ans =[]
for i in l_cou.keys():
    ans.append(l_cou[i] *r_cou.get(i,0))

print(sum(ans))

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

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

    int res = 0;
    if(x<=3){
        cout << 1 << endl;
        return 0;
    }

    for(int i=2; i<=(int)sqrt(x); i++){
        int tmp = i*i;
        while(tmp <= x){
            tmp *= i;
            if(tmp>x){
                tmp /= i;
                break;
            }
        }

        res = max(res,tmp);
    }

    cout << res << endl;

}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

max_count = 0
count = 0
for i in range(1, N):
    if H[i-1] >= H[i]:
        count += 1
    else:
        max_count = max(max_count, count)
        count = 0
        
max_count = max(max_count, count)
print(max_count)

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

using namespace std;

const int maxn = 1e5 + 10;
int h[maxn];
int n, k;
int dp[maxn];

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

	for(int i=0; i<n; i++){
		scanf("%d", &h[i]);
	}
	
	fill(dp, dp+n, 1e9);

	dp[0] = 0;
	for(int i=1; i<n; i++){
		for(int j=i-1; j>=max(0, i-k); j--){
			dp[i] = min(dp[i], dp[j] + abs(h[i]-h[j]));
		}
	}

	printf("%d\n", dp[n-1]);
}


Measured memory_bytes: 4516
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>

using namespace std;

int main()
{
  long long a, b, x;
  cin >> a >> b >> x;
  long long low = a / x + (a % x == 0 ? 0 : 1);
  long long high = b / x;
  cout << high - low + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  vector<int>num(51,0);
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    num.at(a-1)++;num.at(b-1)++;
  }
  for(int i=0;i<N;i++)cout<<num.at(i)<<endl;
}

Measured memory_bytes: 256