akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(){
	int x,y,k,ans;
	scanf("%d %d %d",&x,&y,&k);
    
	

    int i = x;
	while(1){
		if(x%i==0&&y%i==0){
			k--;
			ans = i;
		}
		i--;
		if(k==0){
			printf("%d",ans);
			return 0;
		}
	}
}



Measured memory_bytes: 128
N=int(input())
dp=[[0,0,0] for _ in range(N+1)]
for i in range(1,N+1):
    a,b,c=map(int,input().split())
    dp[i][0]=max(dp[i-1][1]+b,dp[i-1][2]+c)
    dp[i][1]=max(dp[i-1][0]+a,dp[i-1][2]+c)
    dp[i][2]=max(dp[i-1][1]+b,dp[i-1][0]+a)
print(max(dp[-1]))

Measured memory_bytes: 28684
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n, x; cin >> n >> x;
    ll gcd = INFLL;
    rep(i, n){
        ll in; cin >> in;
        in = abs(in-x);
        if(gcd == INFLL) gcd = in;
        else gcd = __gcd(gcd, in);
    }
    cout << gcd << endl;
}

Measured memory_bytes: 256
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  int a,b,max=0;
  string s[100],t[100];
  std::cin >> a ;
  for(int i=0; i<a; i++) std::cin >> s[i];
  std::cin >> b;
  for(int i=0; i<b; i++) std::cin >> t[i];

  for(int i=0; i<a; i++){
    int cntr=0,cntb=0;
    for(int j=0; j<b; j++){  if(s[i]==t[j]) cntb--;}
    for(int k=0; k<a; k++){ if(s[i]==s[k] ) cntr++;}

    if(max<cntr+cntb) max=cntr+cntb;
  }
  std::cout << max << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>


using namespace std;
int main()
{/*二日目*/
	int n;cin >> n;
	long long sum = 0;
	for (int i = 1;i <= n;i++) {
		if (i % 3 != 0 and i % 5 != 0) {
			sum += i;
		}
	}cout << sum;
}

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

#define ll long long int

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

  vector<vector<int>> ptj(m);
  for(int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    if(a < m) ptj[a].push_back(b);
  }

  priority_queue<int> queue;
  ll ans = 0;
  for(int i = 0; i < m; i++) {
    for(int j = 0; j < ptj[i].size(); j++) queue.push(ptj[i][j]);
    if(!queue.empty()) {
      ans += queue.top();
      queue.pop();
    }
  }

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

Measured memory_bytes: 5504
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 W = Integer.parseInt(sc.next());
        
        int[] w = new int[N+1];
        long[] v = new long[N+1];
        
        long[][] dp = new long[N+1][W+1];
        
        for(int i = 0; i < N; i++) {
            w[i+1] = Integer.parseInt(sc.next());
            v[i+1] = Integer.parseInt(sc.next());
        }
        
        for(int i = 1; i <= N; i++) {
            for(int j = 0; j <= W; j++) {
                if(j - w[i] >= 0) {
                    dp[i][j] = max(dp[i-1][j], dp[i-1][j - w[i]] + v[i]); 
                }else {
                    dp[i][j] = dp[i-1][j];
                }
            }
        }
        
        long ans = dp[N][W];
        System.out.println(ans);
    }
    
    public static long max(long a, long b) {
        if(a >= b) {
            return a;
        }else {
            return b;
        }
    }
    
    public static int min(int a, int b) {
        if(a >= b) {
            return b;
        }else {
            return a;
        }
    }
}

Measured memory_bytes: 123988
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;

int gcd(int a, int b) { //最大公約数
  if (b==0) return a;
  else return gcd(b, a%b);
}

int lcm(int a, int b) { //最小公倍数
  return a * b / gcd(a, b);
}


int main()
{
  ll n,p[100010];
  ll ans=0;
  cin>>n;
  rep(i,n)cin>>p[i];
  rep(i,n-1){
    if(p[i]==i+1){
      ll tmp=p[i];
      p[i]=p[i+1];
      p[i+1]=tmp;
      ans++;
    }
  }
  if(p[n-1]==n)ans++;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4328
import kotlin.math.max
import kotlin.math.min

fun main() {
    val n = readInt()
    val colors = readLine()!!

    var red = colors.count { it == 'R' }
    var white = 0

    var best = max(white, red)
    for (i in 0 until n) {
        if (colors[i] == 'W') white++
        else red--

        best = min(best, max(white, red))
    }
    println(best)
}

private fun readInt() = readLine()!!.toInt()
private fun readInts() = readLine()!!.split(" ").map { it.toInt() }
private fun readLongs() = readLine()!!.split(" ").map { it.toLong() }


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

struct UnionFind {
  vector<int> par;
  vector<int> rank;

  UnionFind(int n) : par(n), rank(n, 1) {
    for(int i=0; i<n; ++i) par[i] = i;
  }

  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (rank[x] < rank[y]) swap(x, y);
    par[y] = x;
    rank[x] += rank[y];
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

typedef double Cost;

struct edge{
    int src, dst; Cost cost;
    edge(int s, int t, Cost c) : src(s), dst(t), cost(c) {}
    bool operator < (const edge &rhs) const {return cost < rhs.cost;}
};

Cost kruskal(int V, vector<edge> &edges) {
    UnionFind uf(V);
    sort(edges.begin(), edges.end());
    Cost ans = 0;
    for(auto e : edges) {
        if(!uf.same(e.src, e.dst)) {
            uf.unite(e.src, e.dst);
            ans += e.cost;
        }
    }
    return ans;
}

int main(void) {
    int n;
    while(cin >> n && n) {
        vector<double> x(n), y(n), z(n), r(n);
        vector<edge> edges;
        REP(i, n) {
            cin >> x[i] >> y[i] >> z[i] >> r[i];
        }
        REP(i, n)  {
            REP(j, n) {
                if(i == j) continue;
                double c = sqrt(pow(x[i]-x[j], 2.0) + pow(y[i]-y[j], 2.0) + pow(z[i]-z[j], 2.0)) - r[i] - r[j];
                edges.push_back(edge(i, j, max(0.0, c)));
            }
        }
        printf("%.3f\n", kruskal(n, edges));
    }
}

Measured memory_bytes: 3368
#include <bits/stdc++.h>
using namespace std;
signed main(){
	int n;
	cin >> n;
	int xo[n];
	int allxor = 0;
	for(int i = 0; i < n; i++){
		cin >> xo[i];
		allxor ^= xo[i];
	}
	for(int i = 0; i < n; i++){
		xo[i] ^= allxor; cout << xo[i] << " ";
	}
	return 0;
}

Measured memory_bytes: 4304
#include <iostream>
#include <vector>
#include <string>

int main() {
    int n, m;
    std::cin >> n >> m;

    std::vector<bool> aced(n, false);
    std::vector<int> was(n, 0);
    while (m--) {
        int i;
        std::string s;
        std::cin >> i >> s;
        --i;
        if (aced[i]) continue;
        if (s == "AC") {
            aced[i] = true;
        } else {
            ++was[i];
        }
    }

    int ac = 0, wa = 0;
    for (int i = 0; i < n; ++i) {
        if (!aced[i]) continue;
        ++ac;
        wa += was[i];
    }

    std::cout << ac << " " << wa << std::endl;
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#define Maxn 100005
int n,ans,a[Maxn],rmq[Maxn*4],s[Maxn];
void add(int x) {for (;x<Maxn*4;x+=x&-x) rmq[x]++;}
int sum(int x) {int res=0;for (;x;x-=x&-x) res+=rmq[x];return res;}
int main()
{
	scanf("%d",&n);
	for (int i=0;i<n;++i) scanf("%d",a+i);
	for (int l=0,r=1e9;l<=r;)
	{
		__builtin_memset(rmq,0,sizeof(rmq));
		int mid=l+r>>1;
		long long S=0;
		add(n+1);
		for (int i=0;i<n;++i)
		{
			s[i]=(i?s[i-1]:0)+(a[i]>=mid?1:-1);
			S+=sum(s[i]+n+1);
			add(s[i]+n+1);
		}
		if (S>=1LL*n*(n+1)/2-S) ans=mid,l=mid+1;
		else r=mid-1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define INF 100000000
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < n; ++i)
#define out(x) cout << x << endl;
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;


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

	out(3*r*r);

	return 0;
}

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

int main(){
    ll n;
    cin >> n;
    if(n%2==1){
        cout << "0" << endl;
        return 0;
    }
    
    ll x=10,ans=0;
    
    while(x<=n){
        ans+=n/x;
        x=x*5;
    }
    
    cout << ans << endl;
    

    return 0;
}

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

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

  string s; cin >> s;

  bool flag = false;
  bool foundC = false;
  rep(i, s.size()) {
    if(s[i] == 'C') foundC = true;
    if(foundC && s[i] == 'F') flag = true;
  }

  cout << (flag ? "Yes" : "No") << '\n';
  return 0;
}


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

int main (){
   int h,w,n,flag=0;
   int ans,total=0;
   scanf("%d\n%d\n%d\n",&h,&w,&n);
   /*if((n <= h)||(n <= w)){
         ans = 1;
         printf("%d\n",ans);
      }*/
   if(w < h)flag=1;

   if(flag == 1){
      for(int i = 1;i <= w;i++){
         total += h;
         if(total >= n){
            printf("%d\n",i);
            break;
         }
      }
   }else{
      for(int i = 1;i <= h;i++){
         total += w;
         if(total >= n){
            printf("%d\n",i);
            break;
         }
      }
   }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 100000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};
int main(void){
    int n,m;
    cin>>n>>m;
    int a[m],b[m];
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        a[i]--;
        b[i]--;
    }
    int ans=0;
    for(int i=0;i<m;i++){
        UnionFind uf(n);
        for(int j=0;j<m;j++){
            if(i!=j)uf.unionSet(a[j],b[j]);
        }
        int c=0;
        for(int j=0;j<n;j++){
            if(uf.root(j)==j){
                c++;
            }
        }
        if(c>1)ans++;
    }
    cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
/* C Quick Sort */

#include<stdio.h>
int n; /* 1<=n<=100000 */

int Partition(int A[], char M[], int p, int r);
void QuickSort(int A[], char M[], int p, int r);
void MergeSort(int A[], char M[], int l, int r);
void Merge(int A[], char M[], int l, int m, int r);

int main(){
  int i;
  int q;
  int stable_judge=0;

  scanf("%d%*c",&n);
  int A[n]; /* card number */
  char M[n];/* card mark */
  int A2[n];/* copy of A[n] */
  char M2[n];/* copy of M[n] */

  for(i=0;i<n;i++){
    scanf("%c%d%*c",&M[i],&A[i]);
  }
  /* copy */
  for(i=0;i<n;i++){
    A2[i]=A[i];
    M2[i]=M[i];
  }

  QuickSort(A, M, 0, n-1);
  MergeSort(A2, M2, 0, n); 
  
  for(i=0;i<n;i++){
    if(M[i]!=M2[i])stable_judge++;
  } 

  if(stable_judge>0){
    printf("Not stable\n");
  }else{
    printf("Stable\n");
  }

  for(i=0;i<n;i++){
    printf("%c %d\n",M[i],A[i]);
  }
  return 0;
}

int Partition(int A[], char M[], int p, int r){
  int i, j, x;
  int tempi;
  char tempc;

  x=A[r];
  i=p-1;
  for(j=p;j<=r-1;j++){
    if(A[j]<=x){
      i=i+1;
      tempi=A[i]; /* exchange */
      A[i]=A[j];
      A[j]=tempi;
      tempc=M[i];
      M[i]=M[j];
      M[j]=tempc;
    }
  }
  tempi=A[i+1]; /* exchange */
  A[i+1]=A[r];
  A[r]=tempi;
  tempc=M[i+1];
  M[i+1]=M[r];
  M[r]=tempc;
  return i+1;
}

void QuickSort(int A[], char M[], int p, int r){
  int q;
  if(p<r){
    q=Partition(A, M, p, r);
    QuickSort(A, M, p, q-1);
    QuickSort(A, M, q+1, r);
  }
}

void Merge(int A[], char M[], int l, int m, int r){
  int n1, n2, i, j, k;
  int L[500001], R[500001];
  char Lc[500001],Rc[500001];
  n1=m-l;
  n2=r-m;
  for(i=0; i<=n1-1; i++){
    L[i]=A[l+i];
    Lc[i]=M[l+i];
  }
  for(j=0;j<=n2-1;j++){
    R[j]=A[m+j];
    Rc[j]=M[m+j];
  }
  L[n1]=1000000001;
  R[n2]=1000000001;
  i=0;
  j=0;
  for(k=l;k<=r-1;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      M[k]=Lc[i];
      i=i+1;
    }else{
      A[k]=R[j];
      M[k]=Rc[j];
      j=j+1;
    }
  }
}
 
void MergeSort(int A[], char M[], int l, int r){
  int m;
  if(l+1<r){
    m=(l+r)/2;
    MergeSort(A, M, l, m);
    MergeSort(A, M, m, r);
    Merge(A, M, l, m, r);
  }
}

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

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

    ll t = (ll)sqrt((double)n);
    ll a=1;
    for (ll i=1; i <= t; i++) {
        if ((n%i) == 0) a = i;
    }
    ll b = n/a;
    cout << a+b-2 << endl;

	return 0;
}


Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace app152
{
    class Program
    {
        static void Main(string[] args)
        {
            decimal N = decimal.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');
            decimal[] p = new decimal[(int)N];
            for(int i = 0; i<N; i++)
            {
                p[i] = decimal.Parse(str[i]);
            }


            decimal[] min = new decimal[(int)N];
            decimal curmin = p[0];
            for(int i = 0; i<N; i++)
            {
                if(curmin > p[i])
                {
                    curmin = p[i];
                }
                min[i] = curmin;
            }

            int ans = 1;
            for(int i =1; i<N; i++)
            {
                if(p[i] <= min[i-1])
                {
                    ans += 1;
                }
            }

            Console.Write(ans);
        }
    }
}


Measured memory_bytes: 36828
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

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


Measured memory_bytes: 3084
import java.io.*;
import java.util.*;

public class Main{
	public static void main(String[] ar)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		
		int n = Integer.parseInt(br.readLine());
		if(n<1200)
          out.println("ABC");
      	else if(n>=1200 && n<2800)
          	out.println("ARC");
      	else
          	out.println("AGC");
      	out.flush();
    }
}

Measured memory_bytes: 23124
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

using ll = long long;
using Graph = vector<vector<int>>;

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(n);
  Vi A(n);
  VIN(A)
  z = VSUM(A);
  if(z % 10 != 0) OUT(z);
  else {
    SORT(A);
    REP(i,n){
      if((z-A[i])%10!=0){
        OUT(z-A[i]);
        return 0;
      }
    }
    OUT(0);
  }
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main()
{
  int length = 0;
  int height = 0;
  int area = 0;
  int cir = 0;
 
  scanf("%d %d", &length, &height);
  area = length * height;
  cir = length*2 + height*2;
 
  printf("%d %d\n", area, cir);
 
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int k;
  cin >> k;
  int ans = -1, num = 0;
  rep(i, k) {
    num = (num*10+7)%k;
    if (!num) {
      ans = i+1;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
#define Max 1000001
#define inf INT_MAX
#define llinf LONG_LONG_MAX
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define endl '\n'
const ll N=2e5+5,mod=1000000007,bit=31;
signed main()
{
    fast;
    ll pro=1,temp,t,i,j,l,r,n,m,mid,y,z,x,k,rem,carry=0,ind,ans=0,mx=-llinf,mn=llinf,cnt=0,curr=0,prev,nxt,sum=0,flag=1,i1=-1,i2=-1,u,v;
	cin>>n;
	ll dp[n+1],a[n+1];
	dp[0]=0;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	dp[1]=0;
	dp[2]=abs(a[2]-a[1]);
	for(i=3;i<=n;i++)
	{
		dp[i]=min(dp[i-2]+abs(a[i-2]-a[i]),dp[i-1]+abs(a[i-1]-a[i]));
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll inf = LONG_LONG_MAX / 2 - 1;
    ll n;
    cin >> n;
    vector<vector<ll>> a(n, vector<ll>(n)), g(n, vector<ll>(n));
    rep(i, n) {
        rep(j, n) {
            cin >> a[i][j];
            g[i][j] = a[i][j];
        }
    }
    rep(i, n) rep(j, n) rep(k, n) g[j][k] = min(g[j][k], g[j][i] + g[i][k]);
    rep(i, n) {
        rep(j, n) {
            if (a[i][j] != g[i][j]) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    rep(i, n) {
        rep(j, n) {
            rep(k, n) {
                if ((i == j) || (i == k) || (j == k)) continue;
                if (g[j][k] != (g[j][i] + g[i][k])) continue;
                g[j][k] = inf;
                g[k][j] = inf;
            }
        }
    }
    ll ans = 0;
    rep(i, n) {
        rep(j, n) {
            if (g[i][j] == inf) continue;
            ans += g[i][j];
        }
    }
    cout << (ans / 2) << endl;
    return 0;
}


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

int main() {
  int h, w, n; cin>>h>>w>>n;
  int sr, sc; cin>>sr>>sc;
  string s, t; cin>>s>>t;

  int l = 0, r = 0, u = 0, d = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'L') ++l;
    if (s[i] == 'R') ++r;
    if (s[i] == 'U') ++u;
    if (s[i] == 'D') ++d;
    if (sc - l <= 0 or sc + r > w or sr - u <= 0 or sr + d > h) {
      cout << "NO" << endl;
      return 0;
    }
    if (t[i] == 'R' and sc - (l - 1) <= w) --l;
    if (t[i] == 'L' and sc + (r - 1) > 0) --r;
    if (t[i] == 'D' and sr - (u - 1) <= h) --u;
    if (t[i] == 'U' and sr + (d - 1) > 0) --d;
  }
  cout << "YES" << endl;

  return 0;
}

Measured memory_bytes: 776
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

const MOD: i64 = 1_000_000_007;

fn fact(n: i64, memo: &mut [Option<i64>]) -> i64 {
    if let Some(v) = memo[n as usize] {
        v
    } else {
        let v = (1..n + 1).fold(1, |a, b| a * b % MOD);
        memo[n as usize] = Some(v);
        v
    }
}

fn pow(n: i64, k: i64) -> i64 {
    match k {
        0 => 1,
        a if a % 2 == 0 => pow(n * n % MOD, k / 2),
        _ => n * pow(n * n % MOD, k / 2) % MOD,
    }
}

fn combination(n: i64, k: i64, memo: &mut [Option<i64>]) -> i64 {
    (fact(n, memo) * pow(fact(k, memo), MOD - 2) % MOD) * pow(fact(n - k, memo), MOD - 2) % MOD
}

fn main() {
    let (h, w, a, b) = scan!(i64, i64, i64, i64);
    let mut memo = vec![None; (h + w) as usize];
    memo[0] = Some(1);
    for i in 0..memo.len() - 1 {
        memo[i + 1] = Some((i as i64 + 1) * memo[i].unwrap() % MOD);
    }

    let mut ans = 0;
    for i in 1..w - b + 1 {
        ans += combination(h - a + b + i - 2, h - a - 1, &mut memo)
            * combination(a + w - b + 1 - i - 2, a - 1, &mut memo)
            % MOD;
        ans %= MOD;
    }
    println!("{}", ans);
}


Measured memory_bytes: 8444
#include<stdio.h>
int main(void){
  char s[10];
  scanf("%s",s);
  int i,len,acgt,max=0;
  len=sizeof(s);
  for(i=0;i<len;i++){
    if(s[i]=='\0') break;
    if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T') acgt++;
    else acgt=0;
    if(max<acgt) max=acgt;
  }
  printf("%d",max);
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

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

        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            if (x % 2 == 0 && (x % 3 != 0 && x % 5 != 0)) {
                System.out.println("DENIED");
                return;
            }
        }
        System.out.println("APPROVED");
    }
}

Measured memory_bytes: 23380
/*-****************************************-*/

#define USE_CPP11

#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>

#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <bitset>
#ifdef USE_CPP11
# include <unordered_set>
# include <unordered_map>
# include <array>
# include <valarray>
#endif // USE_CPP11

#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>

using namespace std;

/*-****************************************-*/

typedef pair<int, int> pii;
typedef long long ll;

/*-****************************************-*/

#define mp make_pair

#define sz_array(a) (sizeof(a) / sizeof((a)[0]))

#define all(a) (a).begin(),(a).end()
#define r_all(a) (a).rbegin(), (a).rend()

#define exists(container, elem) ((container).find(elem) != (container).end())

/*-****************************************-*/

template<typename T> T MinAssign(T &a, T b) {
	if (a > b)
		a = b;
	return a;
}

template<typename T> T MaxAssign(T &a, T b) {
	if (a < b)
		a = b;
	return a;
}

template<typename T, size_t size> void Fill(void *ptr, T value) {
	fill((T *)ptr, (T *)ptr + size / sizeof(T), value);
}

/*-****************************************-*/

static const double EPS = 1e-10;
static const double PI = acos(-1.0);
static const int INF = 1 << 28;

/*-****************************************-*/

#ifdef DEBUG
#define ANSWER_PREFIX() cout << "[[ Answer ]] "
#else
#define ANSWER_PREFIX()
#endif // DEBUG

/*-****************************************-*/

//////////////////////////////////////////////////
//////////////////////////////////////////////////
//////////////////////////////////////////////////


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

	vector<int> L(2 * n);
	for (size_t i = 0; i < 2 * n; i++) {
		cin >> L[i];
	}

	sort(all(L), greater<int>());

	int ans = 0;
	for (size_t i = 0; i < n; i++) {
		ans += min(L[2 * i], L[2 * i + 1]);
	}

	ANSWER_PREFIX();
	cout << ans << endl;
}


Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const S = arg.slice(1, N + 1);
    
    const alphabets = "abcdefghijklmnopqrstuvwxyz".split("");
    
    let map = [...Array(27)].fill(0);
    let answer = [];
    
    for(let i in alphabets) {
        let contains = Infinity;
        
        for(let j in S) {
            let cnt = S[j].split("").filter(n=>n===alphabets[i]).length;
            
            if(cnt > 0) {
                contains = Math.min(cnt, contains);
            } else {
                contains = 0;
                break;
            }
        }
        
        for(let j=0; j<contains; j++) {
            answer.push(alphabets[i]);   
        }
    }
    
    console.log(answer.join(""));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7820
n,m=map(int,input().split())

tree=[set([]) for _ in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    tree[a-1].add(b-1)
    tree[b-1].add(a-1)

group=[-1]*n
num=-1
ans=0
for i in range(n):
    if group[i]==-1:
        ans_tmp=1
        num+=1
        stack=[i]
        group[i]=num
        while len(stack)>0:
            tmp=stack.pop()

            for j in tree[tmp]:
                if group[j]==-1:
                    stack.append(j)
                    group[j]=num
                    ans_tmp+=1
    ans=max(ans,ans_tmp)
print(ans)

            





    



Measured memory_bytes: 153908
// D - Non-decreasing

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int a[50];

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

	int max_i = 0;
	for (int i=0; i<N; i++) {
		cin >> a[i];
		if (abs(a[i]) > abs(a[max_i])) max_i = i;
	}

	cout << 2 * N - 1 << endl;

	for (int i=0; i<N; i++) {
		a[i] += a[max_i];
		cout << max_i+1 << " " << i+1 << endl;
	}


	if (a[max_i] >= 0) {
		for (int i=0; i<N-1; i++) {
			a[i+1] += a[i];
			cout << i+1 << " " << i+2 << endl;
		}
	} else {
		for (int i=N-1; i>0; i--) {
			a[i-1] += a[i];
			cout << i+1 << " " << i << endl;
		}
	}

	return 0;
}

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

typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<ll> v(n+1);
    map<ll,ll> mp;
    v.at(0) = 0;
    mp[0]++;
    for(int i=1; i<=n; i++){
        ll a;
        cin >> a;
        v.at(i) = v.at(i-1) + a;
        mp[v.at(i)]++;
    }

    auto itr = mp.begin();
    ll ans = 0;
    while(itr != mp.end()){
        if(itr->second > 1){
            ll x = itr->second;
            ans += x*(x-1)/2;
        }
        itr++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main(void){
    int N;
    const ll mod = 1000000007LL;
    cin >> N;
    vector<vector<ll>> dp(N + 1, vector<ll>(4, 0LL));
    dp[0][0] = 1;
    for(int i = 1; i <= N; i++){
        dp[i][0] = dp[i - 1][0] * 8;
        dp[i][1] = dp[i - 1][0] + dp[i - 1][1] * 9;
        dp[i][2] = dp[i - 1][0] + dp[i - 1][2] * 9;
        dp[i][3] = dp[i - 1][1] + dp[i - 1][2] + dp[i - 1][3] * 10;
        for(int j = 0; j < 4; j++) dp[i][j] %= mod;
    }
    cout << dp[N][3] << endl;
    return 0;
}


Measured memory_bytes: 73284
P = input()
A = int(P[0])
B = int(P[1])
C = int(P[2])
D = int(P[3])

if A+B+C+D == 7:
    print("{}+{}+{}+{}=7".format(A, B, C, D))
elif A-B+C+D == 7:
    print("{}-{}+{}+{}=7".format(A, B, C, D))
elif A+B-C+D == 7:
    print("{}+{}-{}+{}=7".format(A, B, C, D))
elif A-B-C+D == 7:
    print("{}-{}-{}+{}=7".format(A, B, C, D))
elif A+B+C-D == 7:
    print("{}+{}+{}-{}=7".format(A, B, C, D))
elif A-B+C-D == 7:
    print("{}-{}+{}-{}=7".format(A, B, C, D))
elif A+B-C-D == 7:
    print("{}+{}-{}-{}=7".format(A, B, C, D))
else:
    print("{}-{}-{}-{}=7".format(A, B, C, D))


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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    string s;
    in>>s;
    if(s=="AAA"||s=="BBB") puts("No");
    else puts("Yes");
}

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

#define MOD 1000000007
typedef unsigned long long ull;

int n = 0;

int main() {
  cin >> n;

  if ((n / 10) % 111 == 0 || (n % 1000) % 111 == 0) {
      cout << "Yes" << endl;
  } else {
      cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define rep3(i, x, n) for(int i = x; i > n; i--)
const long long MOD = 1e9+7;
const long long INF = 1e15;
typedef long long ll;
typedef pair<ll, ll> P;

int main(){
    ll N;
    ll K;
    cin >> N >> K;
    map<ll, ll> mp;
    set<ll> s[N];
    ll A[N];
    rep(i, N){
        cin >> A[i];
        if(!mp.count(A[i])){
            mp[A[i]] = i;
            s[i].insert(i);
        }
        else{
            int j = mp[A[i]];
            s[j].insert(i);
        }
    }
    ll step[70][N];
    rep(i, N){
        ll j = mp[A[i]];
        set<ll>::iterator ite, ite2;;
        ite = s[j].find(i);
        ite2 = s[j].find(i);
        ite2++;
        if(ite2 != s[j].end()) step[0][i] = *ite2 - *ite + 1;
        else step[0][i] = N + *s[j].begin() - *ite + 1;
    }
    rep2(i, 1, 70){
        rep(j, N){
            ll k = (j + step[i-1][j]) % N;
            step[i][j] = min(step[i-1][j] + step[i-1][k], N*K+1);
        }
    }
    ll pos = 0;
    while(true){
        if(pos + step[0][pos%N] >= N*K+1) break;
        else{
            int i = 0;
            while(pos + step[i+1][pos%N] <= N*K) i++;
            pos += step[i][pos%N];
        } 
    }
    for(ll i = pos; i < N*K;){
       ll j = i % N;
       if(i + step[0][j] - 1 >= N*K){
           cout << A[j] << endl;
           i++;
       }
       else{
           i += step[0][j];
       }
    }
}

Measured memory_bytes: 145536
import math
N = int(input())
ans = ''

for i in range(1, 99):
  if N <= 26 ** i:
    N -= 1
    for j in range(i):
      ans += chr(ord('a') + N % 26)
      N //= 26
    break
  else:
    N -= 26 ** i
    
print(ans[::-1])



    

Measured memory_bytes: 9152
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> T;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;
using Ki = vector<vector<int>>;
using vec = vector<int>;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int n;
    cin>>n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    vector<int> q(n);
    rep(i, n) cin >> q[i];
    vec a(n);
    vec aa(n);
    int nnn=1;
    rep(i,n){
        a[i]=i+1;
        aa[i]=i+1;
        nnn*=(i+1);
    }
    int g=0;
    int cnt=0;
    int k,l;
    while(true){
        cnt++;
        int bg=0;
        rep(i,n){
            if(p[i]==a[i]){
                bg++;
            }
        }
        if(bg==n) k=cnt;
        bg=0;
        rep(i,n){
            if(q[i]==a[i]){
                bg++;
            }
        }
        if(bg==n) l=cnt;
        next_permutation(all(a));
        if(cnt==nnn) break;
    }
    cout<<abs(k-l)<<endl;
    //debug(k);debug(l);
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int SIZE = 86 + 10;

ll lucas[SIZE] = {2, 1};

void init()
{
    for (int i = 2; i < SIZE; i++)
        lucas[i] = lucas[i - 1] + lucas[i - 2];
}

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

    init();

    int n;
    cin >> n;
    cout << lucas[n] << endl;

    return 0;
}

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

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl;
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   " << endl;
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}
 
int main(){

    ll N;
    cin >> N;

    vector<ll> num_divisors(N+1, 0);//num_divisors[i]: iの約数の個数
    for(ll i=1; i<=N; i++){
      for(ll j=1; i*j<=N; j++){
        num_divisors[i*j]++;
      }
    }

    ll ans = 0;
    for(ll i=1; i<=N; i++){
      ans += i*num_divisors[i];
    }

    cout << ans << endl;
    

}


Measured memory_bytes: 81400
import math
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
 
d1 = 0
d2 = 0
d3 = 0
d = [0] * n
 
for i in range(n) :
  d1 += abs(x[i] - y[i])
print(d1)
   
for j in range(n) :
  d2 += abs(x[j] - y[j]) ** 2
d2 = math.sqrt(d2)
print(d2)
 
for k in range(n) : 
  d3 += abs(x[k] - y[k]) ** 3
d3 = d3 ** (1/3)
print(d3)
 
for l in range(n) :
  d[l] = abs(x[l] - y[l])
di = max(d)  #infinity
print(di)


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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

int n;
char s[500005];
int a[500005];

int main() {
	n = readStr(s + 1) + 1;
	int now = 0;
	for (int i = 1; i <= n; ++i) {
		a[i] = now;
		if (i < n) {
			if (s[i] == '<') {
				++now;
			} else {
				now = 0;
			}
		}
	}
	now = 0;
	for (int i = n - 1; i >= 0; --i) {
		a[i + 1] = std::max(a[i + 1], now);
		if (i) {
			if (s[i] == '>') {
				++now;
			} else {
				now = 0;
			}
		}
	}
	long long ans = 0;
	for (int i = 1; i <= n; ++i) {
		ans += a[i];
	}
	print(ans);
}


Measured memory_bytes: 6536
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int x;
    cin >> x;

    unordered_map<long long int, int> nums;

    for (int i = 1; i <= 1000; i++)
    {
        long long int num = (long long int)pow(i, 5);

        nums.insert(make_pair(num, i));
        nums.insert(make_pair(num * -1, i * -1));
    }

    for (int i = 0; i <= 1000; i++)
    {
        long long int b5 = pow(i, 5);

        long long int xb5 = x + b5;
    
        auto itr = nums.find(xb5);
        if(itr != nums.end())
        {
            cout << itr->second << " " << i << endl;
            break;
        }

        xb5 = x - b5;
    
        auto itr2 = nums.find(xb5);
        if(itr2 != nums.end())
        {
            cout << itr2->second << " " << i*-1 << endl;
            break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 4020
#include<stdio.h>
int main(void){
int n;
  scanf("%d",&n);
  long a[n+1],b[n];
  for(long i=0;i<n+1;i++){
	scanf("%ld",&a[i]);
  }
   for(long i=0;i<n;i++){
	scanf("%ld",&b[i]);
  }
  long ans=0;
  for(long i=0;i<n;i++){
	long w1=a[i],w2=a[i+1];
    if(b[i]-a[i]>=0){		//次の街に攻撃猶予がある時
    a[i+1]=a[i+1]-(b[i]-a[i]);
     if(a[i+1]>=0)ans+=b[i]-a[i];	//次の街に攻撃できた分
      else {				//次の街を全滅できた時
            ans+=w2;
      		a[i+1]=0;
      }
    }
    	a[i]-=b[i];
  if(a[i]<0){a[i]=0;		//今の街を全滅した時
             ans+=w1;
            }
    else ans+=b[i]; 
  }
  printf("%ld",ans);
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<ld> vld;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define ALL(v) (v).begin(), (v).end()
#define endl "\n"

ll MOD = 1000000007;
ll INF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------

//-----------------------------------------

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

  ll a;
  cin >> a;
  if(a == 0) cout << 1 << endl;
  else cout << 0 << endl;
    
    
  return 0;
}



Measured memory_bytes: 3616
#include<stdio.h>
int main(void){
    int a,b;

    scanf("%d %d",&a,&b);
    if(a<b){
        printf("a < b\n");
    }
    else if(a>b){
        printf("a > b\n");
    }
    else if(a==b){
        printf("a == b\n");
    }
    return 0;
}



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

//#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) c.begin(),c.end()
static const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
static const int MOD = (int)(1e9 + 7);

signed main() {
	int N; cin >> N;
	string X; cin >> X;
	int D; cin >> D;
	string ans = X;
	rep(i, 0, X.size()) {
		if (D == 0) {
			cout << ans << endl;
			return 0;
		}
		if (X[i] == '0') {
			ans[i] = '1';
			D--;
		}
	}
	rrep(i, 0, X.size()) {
		if (D == 0) {
			cout << ans << endl;
			return 0;
		}
		if (X[i] == '1') {
			ans[i] = '0';
			D--;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int a,b;
    string s;
    cin >> a >> b;
    int ans = 0;
    if(a == 3)ans += 100000;
    else if(a == 2)ans += 200000;
    else if(a == 1)ans += 300000;

    if(b == 3)ans += 100000;
    else if(b == 2)ans += 200000;
    else if(b == 1)ans += 300000;

    if(a == 1 && b == 1)ans += 400000;
    cout << ans << endl;
}


Measured memory_bytes: 888
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll n,k;
double ans;
int main(){
	scanf("%lld%lld",&n,&k);
	rep(i,1,n+1){
		ll temp=i;
		double s=1.0/n;
		while(temp<k){
			temp*=2;
			s/=2;
		}
		ans+=s;
	}
	printf("%.15f",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,tong = 0,kq1 = 0,kq2 = 0;
ll a[101];
int main()
{
    cin >> n;
    for(int i = 1;i <= n;i ++)
    {
        cin >> a[i];
        tong += a[i];
    }
    tong /= n;
    for(int i = 1;i <= n;i ++)
    {
        kq1 += (a[i] - tong) * (a[i] - tong);
        kq2 += (a[i] - (tong + 1)) * (a[i] - (tong + 1));
    }
    cout << min (kq1 , kq2);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<ll> a;
	ll sum = 0;
	ll mp[111111]={0};
	for(int i=0;i<n;++i){
		ll val;
		cin>>val;
		++mp[val];
		sum += val;
		a.push_back(val);
	}
	ll q;
	cin>>q;
	while(q--){
		ll b,c;
		cin>>b>>c;
		if(!mp[b]){
			cout<<sum<<'\n';
			continue;
		}
		ll ans = sum - b*mp[b];
		ans += c*mp[b];
		mp[c] += mp[b];
		mp[b] = 0;
		sum = ans;
		cout<<ans<<'\n';
	}
}

Measured memory_bytes: 5152