akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
int DBG = 0;										/* デバッグプリント 提出時は0 */
/* main *************************************************************/
int a[300001],x[300001],y[300001];
int n,q;
int main()
{
	int		ng = 0,p,xx,yy,b,c,i,j,k,m,ans = 0;
	
	scanf("%d", &n);
	scanf("%d",&a[1]);
	for(i=2;i<=n;i++) {
		scanf("%d",&a[i]);
		if (a[i-1] > a[i]) ng++;
	}
	scanf("%d", &q);
	for(i=1;i<=q;i++) scanf("%d %d",&x[i],&y[i]);

	if (DBG) printf("ng:%d\n\n",ng);
	if (ng==0) { printf("0\n"); return 0; }
	for(i=1;i<=q;i++) {
		xx = x[i];
		yy = y[i];
		if (xx > yy) {
			k = xx;
			xx = yy;
			yy = k;
		}
		if (xx!=1) {
			if ((a[xx] >= a[xx-1]) && (a[yy] < a[xx-1])) ng++;
			if ((a[xx] < a[xx-1]) && (a[yy] >= a[xx-1])) ng--;
		}
		if (yy-xx != 1) {
			if ((a[xx] > a[xx+1]) && (a[yy] <= a[xx+1])) ng--;
			if ((a[xx] <= a[xx+1]) && (a[yy] > a[xx+1])) ng++;
			if ((a[yy] >= a[yy-1]) && (a[xx] < a[yy-1])) ng++;
			if ((a[yy] < a[yy-1]) && (a[xx] >= a[yy-1])) ng--;
		} else {
			if (a[xx] > a[yy]) ng--;
			else ng++;
		}
		if (yy!=n) {
			if ((a[yy] > a[yy+1]) && (a[xx] <= a[yy+1])) ng--;
			if ((a[yy] <= a[yy+1]) && (a[xx] > a[yy+1])) ng++;
		}
		k = a[xx];
		a[xx] = a[yy];
		a[yy] = k;
		if (DBG) printf("ng:%d\n",ng);
		if (ng <0) { printf("Error\n"); }
		if (ng==0) { ans = 1; break; }
	}

	if (ans) printf("%d\n", i);
	else printf("-1\n");

	return 0;
}



Measured memory_bytes: 5356
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222


vll edge[MAX];

void dfs(ll cur, ll dep,ll pre) {
  if (ma < dep) {
    m = cur;
    ma = dep;
  }
  rep(i, edge[cur].size()) {
    ll to = edge[cur][i];
    if (pre == to) continue;
    dfs(to, dep + 1, cur);
  }
}

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


  cin >> n;
  rep(i, n - 1) {
    ll a, b;
    cin >> a >> b;
    edge[a].pb(b);
    edge[b].pb(a);
  }
  dfs(1, 0, -1);
  ma = -inf;
  ll x = m, y;
  dfs(x, 0, -1);
  
  if (ma % 3 != 1) cout << "First" << endl;
  else cout << "Second" << endl;


  return 0;
}

Measured memory_bytes: 24192
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		if(N % 2 == 1) {
			System.out.println("No");
		}else {
			if(S.substring(0,N/2).equals(S.substring(N/2,N))) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}
	}

}


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

void answer1() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int K, S;
  cin >> K >> S;
  int count = 0;
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      int z = S - x - y;
      if (0 <= z && z <= K) {
        count++;
      }
    }
  }
  printf("%d\n", count);
}

void answer2() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int K, S;
  cin >> K >> S;
  int count = 0;

  for (int x = 0; x <= K; x++) {
    int yz = S - x;

    // y:z = 0:yz, 1:yz-1, 2:yz-2, ..., yz:0
    if (0 <= yz && yz <= K) {
      count += yz + 1;
    }

    // yz = K + a -> a = yz - K
    // y:z = a:K, a+1:K-1, a+2:K-2, ..., K:a
    if (K < yz && yz <= 2 * K) {
      count += 2 * K - yz + 1;
    }
  }
  cout << count << endl;
}

int main() {
  //answer1();
  answer2();
}


Measured memory_bytes: 256
from math import sin, cos, pi, sqrt

A, B, H, M = map(int, input().split())

theta1 = 2*pi*((H*60+M)/720)
theta2 = 2*pi*(M/60)

X = [A*cos(pi/2-theta1), A*sin(pi/2-theta1)]
Y = [B*cos(pi/2-theta2), B*sin(pi/2-theta2)]

print(sqrt((X[0]-Y[0])**2 + (X[1]-Y[1])**2))

Measured memory_bytes: 9480
import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}

object Main extends App {
  val n = in.readInt
  val s = in.readLine
  val lf = mu.ListBuffer.empty[Char]
  val lb = mu.ListBuffer.empty[Char]
  val stack = mu.Stack.empty[Char]

  s.foreach { ch =>
    if(ch == '(') stack.push(ch)
    else{
      if(stack.isEmpty) '(' +=: lf
      else stack.pop
    }
  }

  while(stack.nonEmpty) {
    stack.pop
      ')' +=: lb
  }

  val ans = lf ++ s ++ lb.reverse
  println(ans.mkString)
}

Measured memory_bytes: 25368
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#define _GLIBCXX_DEBUG
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    int  N,M;
    cin >> N >> M;
    vector<int> L(M);
    vector<int> R(M);
    int min_R;
    int max_L;
    for(int i=0;i<M;i++){
        cin >> L[i] >> R[i];
    }
    for(int i=0;i<M;i++){
        if(i==0){
            min_R = R[i];
            max_L = L[i];
        }
        else if(min_R > R[i]){
            min_R = R[i];
        }
        else if(max_L < L[i]){
            max_L = L[i];
        }
    }
    int ans;
    ans = min_R - max_L + 1;
    if(ans<=0){
        ans = 0;
    }
    cout << ans << endl;
    
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int,int> PII;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    int n, d, m, c; cin >> n >> d >> m >> c;
    if(m != n) cout << 1 << '\n';
    else cout << 0 << '\n';
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static int cnt;
    static int a;
    static int b;
    static String p;
    static String q;
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        p = genStrWithoutSpace(sc.nextLine());
        q = genStrWithoutSpace(sc.nextLine());
        List<Integer> list = genList(n);
        permutation(list, new StringBuilder(), n);
        System.out.println(Math.abs(a - b));
    }
    
    static List<Integer> genList(int size) {
        List<Integer> res = new ArrayList<>();
        for(int i = 0; i < size; ++i) res.add(i + 1);
        return res;
    }
    
    static void permutation(List<Integer> list, StringBuilder sb, int size) {
        if(sb.length() == size) {
            String resPerm = sb.toString();
            ++cnt;
            if(resPerm.equals(p)) a = cnt;
            if(resPerm.equals(q)) b = cnt;
        } else {
            for(int i = 0, f = list.size(); i < f; ++i) {
                sb.append(list.get(i));
                permutation(genSublist(list, i), sb, size);
            }
        }
        if(sb.length() > 0) sb.deleteCharAt(sb.length() - 1);
    }
    
    static List<Integer> genSublist(List<Integer> list, int skipIndex) {
        List<Integer> sublist = new ArrayList<>();
        for(int i = 0, f = list.size(); i < f; ++i) {
            if(i != skipIndex) sublist.add(list.get(i));
        }
        return sublist;
    }
    
    static String genStrWithoutSpace(String s) {
        StringBuilder sb = new StringBuilder();
        for(int i = 0, f = s.length(); i < f; ++i) {
            char c = s.charAt(i);
            if(c != ' ') sb.append(c);
        }
        return sb.toString();
    }
}

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

using namespace std;

int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    vector<long long>a1(n+1), b1(m+1);
    for(int i=1;i<=n;i++){
        cin>>a1[i];
        a1[i]+=a1[i-1];
    }

    for(int i=1;i<=m;i++){
        cin>>b1[i];
        b1[i]+=b1[i-1];
    }
    int mx=0;
    for(int i=0;i<=n;i++){
        vector<long long>::iterator it=upper_bound(b1.begin(),b1.end(),(k-a1[i]));
        if(it==b1.begin())
            continue;
        it--;
        mx=max(mx,(int)(i+it-b1.begin()));

    }
    cout << mx << endl;
    return 0;
}
/***
5 4 1
1000000000 1000000000 1000000000 1000000000 1000000000
1000000000 1000000000 1000000000 1000000000
3 4 730
60 90 120
80 150 80 150
*/


Measured memory_bytes: 6420
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;ll t;
ll b[3000000];

vector<vector<ll> >graph;
vector<bool>vis;
void dfs(ll src,ll &c)
{
    //cout<<src<<" ";
    b[c]=src;
    c++;
    vis[src]=true;

    
    
    for(auto it:graph[src])
    {
    
        
        if(!vis[it])
        {
           
            dfs(it,c);
        
            
        }
    }
    //cout<<"     ";
}
int main()
{  
    ll n,m; //__number_of_nodes_and_edges__
    cin>>n>>m;
    ll kff;
    cin>>kff;
    ll a[n+1111]={0};
    
   // ll i1=1;
  //  while(i1<=n)
 //   {
  //      cin>>a[i1];//__aceepting the values of all nodes!
   //     i1++;
   // }
    map<ll,ll> gf,jf;
    graph.assign(n+3,vector<ll>());
    vis.assign(n+4,false);
    for(ll i=1;i<=m;i++)
    {
        ll x,y;
       cin>>x>>y;
        graph[x].push_back(y);
        graph[y].push_back(x);
        
      
    }
    ll connected=0;

    for(ll i=1;i<=n;i++)
    {
        ll c=0;
        if(!vis[i])
        {
       
//cout<<"Required-guys:--->";     
            dfs(i,c);
            
            
            
           
            
           // cout<<"Elements  ";
            ll j=0;
            while(j<c)
            {   
            
               // cout<<b[j]<<" ";     
                     gf[b[j]]=c;
                     jf[b[j]]=connected+1;
                j++;
            }
            
            
            //cout<<"\n";
            
                         connected++;
             //cout<<c<<"     "<<connected<<"\n";
        }
      
        
      
    }
    
    
    //cout<<"\n";
    map<ll,ll> a1;
   ll i=1;
   while(i<=kff)
   {
        ll x,y;
       cin>>x>>y;
      
       if(jf[x]==jf[y])
       { //cout<<x<<" "<<y<<"\n";
           a1[x]++;
           a1[y]++;
       }
       
       i++;
   }
   
   
    i=1;
   while(i<=n)
   {
     //  cout<<i<<" ";
       ll m1=gf[i];
       m1--;
       ll gfff=graph[i].size();
      // cout<<gfff<<"\n";
       ll m2=abs(m1-gfff);
       ll m3=abs(m2-a1[i]);
       cout<<m3;cout<<" ";
       i++;
   }
    
 return 0;
}

Measured memory_bytes: 28032
class UnionFind
	def initialize(n) @parent = (0..n).to_a end

	def unite(x,y)
		while @parent[x] != @parent[y]
			x, y = y, x if @parent[x] < @parent[y]
			break @parent[x] = @parent[y] if x == @parent[x]
			@parent[x], x = @parent[@parent[y]], @parent[x]
		end
	end

	def root(x)
		x = @parent[@parent[x]] while x != @parent[x]
		return x
	end
end

N = gets.to_i 
uf = UnionFind.new(N)

a = $<.read.split.map(&:to_i).each_slice(2).with_index
a = 2.times.flat_map do |i|
	a.sort_by { |x| x[0][i] }.each_cons(2).map { |x, y| [y[0][i]-x[0][i], x[1], y[1]] }
end

res = 0
a.sort_by{|x|x[0]}.each do |w, x, y|
	if uf.root(x) != uf.root(y)
		uf.unite(x, y)
		res += w
	end
end
p res


Measured memory_bytes: 58052
from itertools import permutations

n = int(input())
p = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]

l = list(permutations(range(1, n+1)))

p_idx = l.index(tuple(p))
q_idx = l.index(tuple(q))

print(abs(p_idx-q_idx))

Measured memory_bytes: 8052
if __name__ == '__main__':
    from sys import stdin
    # from collections import defaultdict
    # from collections import deque
    # from collections import Counter
    import copy
    # import numpy as np
    # import math
    # import random
    input = stdin.readline

    n, k = map(int, input().split())
    aa = list(map(int, input().split()))
    # n = 200000
    # k = 49
    # aa = [0]*n
    # aa = [0]*n
    if k >= 50:
        str_n = str(n)
        ans = [str_n]*n
        print(' '.join(ans))
        exit()
    copy_aa = copy.deepcopy(aa)
    next = [0]*n  
    for _ in range(k):
        calculation_list = [0]*(n+1)
        for index, a in enumerate(copy_aa):
            section_min = index-a if index-a>=0 else 0
            section_max = index+a+1 if index+a+1<=n else n
            calculation_list[section_min] += 1
            # print(section_max)
            calculation_list[section_max] -= 1
        now = 0
        for index, calculation in enumerate(calculation_list[:-1]):
            now += calculation
            copy_aa[index] = now
        # copy_aa = copy.deepcopy(next)
        # next = [0]*n
    print(' '.join(map(str, copy_aa)))
        


Measured memory_bytes: 174524
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int gcd(int a, int b) {
	if (a % b == 0)return b;
	else return gcd(b, a%b);
}
int n, x, ans, p;
signed main() {
	cin >> n >> x;
	for1(i, n) {
		cin >> p;
		if (i == 1)ans = abs(x - p);
		else ans = gcd(ans, abs(x - p));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*
import java.util.Comparator



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

fun problem143d(n: Int, l: List<Int>): Long {
    val l = l.sorted()
    var count = 0L
    for (i in 0 until n) {
        val a = l[i]
        for (j in i + 1 until n) {
            val b = l[j]
            val k = Math.abs(Collections.binarySearch(l, a + b, LowerBoundComparator())) - 1
            count += Math.max(k - (j + 1), 0)
        }
    }
    return count
}

internal class LowerBoundComparator<T : Comparable<T>> : Comparator<T> {
    override fun compare(x: T, y: T): Int {
        return if (x >= y) 1 else -1
    }
}

Measured memory_bytes: 48404
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = getLine >>= putStrLn . which "Good" "Bad" . ( ( == 4 ) . length ) . group

Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+10;
struct node{
    int x,y,x1,y1,id;
    node(int a=0,int b=0,int e=0,int f=0,int c=0){x=a,y=b,id=c;x1=e;y1=f;}
}e[N];
int n,m,k;
int cl(node p){
    if(p.x==0)return 0;
    else if(p.y==m)return 1;
    else if(p.x==n)return 2;
    else if(p.y==0)return 3;
    else return -1;
}
bool cmp(node a,node b){
    int t1=cl(a),t2=cl(b);
    if(t1!=t2){
        return t1<t2;
    }else {
        if(t1==0){
            return a.y<b.y;
        }else if(t1==1){
            return a.x<b.x;
        }else if(t1==2){
            return a.y>b.y;
        }else if(t2==3){
            return a.x>b.x;
        }
    }
}
stack<pair<int,int> >q;
int main()
{
    scanf("%d%d%d",&n,&m,&k);int cnt=0;
    for(int i=1,x1,x2,y1,y2;i<=k;i++){
        scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
        node p1=node(x1,y1,0,0,0);node p2=node(x2,y2,0,0,0);
        if(cl(p1)!=-1&&cl(p2)!=-1){
            ++cnt;
            if(cmp(p1,p2)){
                p1.x1=p2.x,p1.y1=p2.y;
                p1.id=0,p2.id=1;e[cnt]=p1,e[++cnt]=p2;
            }else{
                p2.x1=p1.x,p2.y1=p1.y;
                p1.id=1,p2.id=0;e[cnt]=p1,e[++cnt]=p2;
            }
        }
    }
    sort(e+1,e+cnt+1,cmp);int flag=0;
   // for(int i=1;i<=cnt;i++)cout<<e[i].x<<" "<<e[i].y<<" "<<e[i].x1<<" "<<e[i].y1<<" "<<e[i].id<<endl;
    for(int i=1;i<=cnt&&!flag;i++){
        if(e[i].id==0){
            q.push(make_pair(e[i].x1,e[i].y1));
        }else{
            if(q.empty())flag=1;
            else{
                pair<int,int>now=q.top();q.pop();
                if(now.first==e[i].x&&now.second==e[i].y){
                    continue;
                }else{
                    flag=1;
                }
            }
        }
    }
    if(flag)puts("NO");
    else puts("YES");
}


Measured memory_bytes: 6528
/*
    oj d https://atcoder.jp/contests/abc167/tasks/abc167_b
    g++ B.cpp
    oj t
    oj s https://atcoder.jp/contests/abc167/tasks/abc167_b B.cpp
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    
    if(K <= A + B){
        cout << min(K, A) << endl;
    }else{
        ll n = K - (A + B);
        cout << A - n << endl;
    }
    
}


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


int main(){
	int N;
	int count[100010];
	
	for(int i=0;i<100010;i++){
		count[i] = 0;//0回出てきた
	}
	
	cin >> N;
	int input;
	for(int i=0;i<N;i++){
		cin >> input;
		count[input]++ ;
	}
	
	if(N%2 == 0){//偶数
		for(int i=1;i<N;i=i+2){
			if(count[i]>=3){
				cout << 0 << endl;
				return 0;
			}
		}
	}else{
		for(int i=0;i<N;i=i+2){
			if(i==0){
				if(count[i]>=2){
					cout << 0<< endl;
					return 0;
				}
			}else{
				if(count[i]>=3){
					cout << 0 << endl;
					return 0;
				}
			}
		}
	}
	
	long long answer = 1;
	for(int i=1;i<=N/2;i++){
		answer = answer * 2 % 1000000007;
	}
	
	cout << answer << endl;
	//偶数の場合は、同じのが3個でてきたらアウト
	//奇数の場合は、同じのが3個もしくは0が2個出てきたらアウト
	
	return 0;
}

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

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

  string a, b; cin >> a >> b;
  string A = "", B = "";

  for (int i = 0; i < stoi(b); i++) {
    A.append(a);
  }

  for (int i = 0; i < stoi(a); i++) {
    B.append(b);
  }

  if (A < B)
    cout << A << endl;
  else
    cout << B << endl;

  return 0;
}


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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define int ll

int n;
vector<int> v;
vector<int> w;
map<int,int> mp;

signed main(){

  for(int i=2;i<100;i++){
    bool b=true;
    for(int j=2;j<i;j++){
      if(i%j==0) b=false;
    }
    if(b){
      v.PB(i);
    }
  }
  w.resize(v.size());

  cin>>n;

  for(int i=2;i<n+1;i++){
    int k=0;
    int m=i;
    while(k<v.size()){
      while(m%v[k]==0){
        w[k]++;
        m/=v[k];
      }
      k++;
    }
  }

  rep(i,w.size()){
    mp[w[i]]++;
  }

  rrep(i,100){
    mp[i]+=mp[i+1];
  }
  int ans=0;

  ans+=mp[74];
  ans+=(mp[2]-1)*mp[24];
  ans+=(mp[4]-1)*mp[14];
  ans+=(mp[2]-2)*mp[4]*(mp[4]-1)/2;

  cout<<ans<<endl;

}


Measured memory_bytes: 256
N = int(input())
Ans = 0
waru = 10
plus = 0
if N % 2 == 1:
  print(Ans)
else:
  for i in range(100):
    plus = N // waru
    
    if plus == 0:
      break
      
    Ans = Ans + plus
    waru = waru * 5

  print(Ans)

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forab(i, a, b) for(int i=(a);i<(b);++i)
#define foreach(i, n) for (__typeof(n.begin()) i = n.begin(); i != n.end(); ++i)
#define sqr(x) ((x)*(x))
#define clr(a, b) memset(a, b, sizeof(a))
#define SZ(a) ((int)a.size())
#define inf 0x3f3f3f3f
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
const double eps = 1e-8;
int dcmp(double x) { if (x < -eps) return -1; else return x > eps;}
#define se(x) cout<<#x<<" = "<<x<<endl

const int N = 510;
const int M = N * N;
int a[N][N];
int h, w;
int m;
pair<pii, pii> ans[M];

void solve() {
	m = 0;
	forab (i, 1, h) forab (j, 1, w+1) {
		if (a[i][j] % 2 == 0) {
			continue;
		}
		a[i][j]--;
		a[i+1][j]++;
		ans[m++] = make_pair(make_pair(i, j), make_pair(i + 1, j));
	}
	forab (j, 1, w) {
		if (a[h][j] % 2 == 0) {
			continue;
		}
		a[h][j]--;
		a[h][j+1]++;
		ans[m++] = make_pair(make_pair(h, j), make_pair(h, j+1));
	}
	printf("%d\n", m);
	forn (i, m) {
		printf("%d %d %d %d\n", ans[i].first.first, ans[i].first.second, ans[i].second.first, ans[i].second.second);
	}

	// printf("\n");
	// forab (i, 1, h+1) {
	// 	forab (j, 1, w+1) {
	// 		printf("%d ", a[i][j]);
	// 	}
	// 	printf("\n");
	// }
	// printf("\n");
}

int main(int argc, char *argv[]) {
	while (scanf("%d%d", &h, &w) != EOF) {
		forab (i, 1, h+1) forab (j, 1, w+1) {
			scanf("%d", &a[i][j]);
		}
		solve();
	}
	return 0;
}



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

int main() {
	long long N;
	vector<pair<long long, long long> > V;
	cin >> N;
	V.resize(N);
	for (int i = 0; i < N; i++) cin >> V[i].first >> V[i].second, V[i].second++;
	sort(V.begin(), V.end());
	long long LMAX = V[V.size() - 1].first, RMIN = 1000000000000, LenMax = 0;
	for (int i = 0; i < N; i++) {
		LenMax = max(LenMax, V[i].second - V[i].first);
		RMIN = min(RMIN, V[i].second);
	}
	long long ANS = LenMax + max(0LL, RMIN - LMAX);
	long long CurRMIN = 1000000000000;
	for (int i = N - 1; i >= 1; i--) {
		CurRMIN = min(CurRMIN, V[i].second);
		ANS = max(ANS, max(0LL, CurRMIN - LMAX) + max(0LL, RMIN - V[i - 1].first));
	}
	cout << ANS << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
//ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve() {
  ll n,m;
  cin>>n>>m;
  vvi v;
  rep(i,m) v.eb((vi){i+1});
  rep(t,n-1){
    ll k=v.size();
    rep(i,k){
      vi p=v[i];
      v[i].eb(p[t]);
      REP(j,p[t],m+1){
        p.eb(j);
        v.eb(p);
        p.pop_back();
      }
    }
  }
  //outvv(v);
  ll q; cin>>q;
  vi a(q),b(q),c(q),d(q);
  rep(i,q) cin>>a[i]>>b[i]>>c[i]>>d[i];
  ll ans=0;
  rep(i,(ll)v.size()){
    ll point=0;
    vi p=v[i];
    rep(j,q){
      if(p[b[j]-1]-p[a[j]-1]==c[j]) point+=d[j];
    }
    chmax(ans,point);
  }
  out(ans);
}

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


Measured memory_bytes: 461504
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define Vi vector<int>
#define pii pair<int,int>

using namespace std;

const int N=2010;
int n,a[N],vis[N]; Vi G[N];
int cnt,head[N],rd[N];
struct edge{int to,nxt;}e[N*N];

void adde(int x,int y){
	e[++cnt].to=y; e[cnt].nxt=head[x]; head[x]=cnt; rd[y]++;
}

void dfs(int u){
	vis[u]=1;
	for (auto v:G[u]) if (!vis[v]) adde(u,v),dfs(v);
}

int main(){
	scanf("%d",&n);
	rep (i,1,n) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	rep (i,1,n) rep (j,1,n) if (i!=j&&__gcd(a[i],a[j])!=1) G[i].push_back(j);
	rep (i,1,n) if (!vis[i]) dfs(i);
	priority_queue<int> q;
	rep (i,1,n) if (!rd[i]) q.push(i);
	while (!q.empty()){
		int x=q.top(); q.pop();
		printf("%d ",a[x]);
		for (int i=head[x],y;i;i=e[i].nxt)
			if (y=e[i].to,!--rd[y]) q.push(y);
	}
	return 0;
}

Measured memory_bytes: 15872
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
const int MAX =1e5+6;
const long long inf=1e18;
vector<int>adj[MAX];
int arr[MAX];
int vis[MAX];

int main(){
	long long n;
	cin>>n;
	long long res=n*(n-1)/2;
	cout<<res;

}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int ans = 0;
    int V[110], C[110];
    rep(i, N) cin >> V[i];
    rep(i, N) cin >> C[i];
    rep(i ,N) {
        ans += max(0, V[i] - C[i]);
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

vector<int> buildIncrementList(int N, const vector<long long> &A, const vector<long long> &B)
{
	vector<int> inc;
	for (int i = 0; i < N; ++i) {
		if (A[i] < B[i]) {
			inc.push_back(i);
		}
	}
	return inc;
}

vector<int> buildDecrementList(int N, const vector<long long> &A, const vector<long long> &B)
{
	vector<int> dec;
	for (int i = 0; i < N; ++i) {
		if (A[i] > B[i]) {
			dec.push_back(i);
		}
	}

	sort(dec.begin(), dec.end(), [&](int i, int j) {
		return A[i] - B[i] < A[j] - B[j];
	});

	return dec;
}

vector<long long> solve(int N, const vector<long long> &A, const vector<long long> &B)
{
	auto inc = buildIncrementList(N, A, B);
	auto dec = buildDecrementList(N, A, B);
	auto C = A;

	for (auto i : inc) {
		while (C[i] < B[i]) {
			int j = dec.back();
			long long x = min(B[i] - C[i], C[j] - B[j]);
			C[i] += x;
			C[j] -= x;
			if (C[j] == B[j]) {
				dec.pop_back();
			}
		}
	}
	
	return C;

}

int main()
{
	int N;
	cin >> N;
	vector<long long> A(N), B(N);
	for (auto &x : A) cin >> x;
	for (auto &x : B) cin >> x;

	long long sumA = accumulate(A.begin(), A.end(), 0LL);
	long long sumB = accumulate(B.begin(), B.end(), 0LL);

	if (sumA < sumB) {
		cout << -1 << endl;
	}
	else {
		auto C = solve(N, A, B);
		int ans = 0;
		for (int i = 0; i < N; ++i) {
			if (A[i] != C[i]) {
				++ans;
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3068
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

#define MAX 100

int main(void) {
  int n, i;
  double x[MAX], y[MAX], a[MAX];
  double P1, P2, P3, P4;

  P1 = P2 = P3 = 0;

  scanf("%d", &n);

  for(i=0; i<n; ++i) {
    scanf("%lf", &x[i]);
  }
  for(i=0; i<n; ++i) {
    scanf("%lf", &y[i]);
  }

  for(i=0; i<n; ++i) {
    a[i] = abs(x[i] - y[i]);
    P1 += a[i];
    P2 += pow(a[i], 2);
    P3 += pow(a[i], 3);
  }

  P4 = a[0];
  for(i=1; i<n; ++i) {
    if(P4 < a[i]) P4 = a[i];
  }

  printf("%f\n%f\n%f\n%f\n", P1, sqrt(P2), cbrt(P3), P4);
}



Measured memory_bytes: 2096
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;

int main() {
    long n, a;
    cin >> n;
    vector<long> as;
    REP(i,n) {
        cin >> a;
        as.push_back(a);
    }
    
    long s1 = 0, s2 = 0, ans1 = 0, ans2 = 0;
    bool fl = true;
    REP(i,n) {
        s1 += as[i];
        if (fl) {
            // s1 should be positive
            if (s1 <= 0) {
                ans1 += 1 - s1;
                s1 = 1;
            }
        } else {
            // s1 should be negative
            if (s1 >= 0) {
                ans1 += s1 + 1;
                s1 = -1;
            }
        }
        fl = !fl;
    }
    fl = false;
    REP(i,n) {
        s2 += as[i];
        if (fl) {
            // s2 should be positive
            if (s2 <= 0) {
                ans2 += 1 - s2;
                s2 = 1;
            }
        } else {
            // s2 should be negative
            if (s2 >= 0) {
                ans2 += s2 + 1;
                s2 = -1;
            }
        }
        fl = !fl;
    }
    cout << min(ans1, ans2) << endl;
}


Measured memory_bytes: 1400
import sys

N, X, M = map(int, sys.stdin.readline().split())

def f(x, m):
    return x**2 % m

a = []
a.append(X)

exists = set()
exists.add(X)
ans = a[0]
for i in range(1, N):
    tmp = f(a[i-1], M)
    if tmp in exists:
        start = a.index(tmp)
        # print("start", start)
        break
    ans += tmp
    a.append(tmp)
    exists.add(tmp)
else:
    # ループ未満で終了する場合
    print(ans)
    sys.exit()

# print(a)
# print("ans", ans) 
 
before_score = sum(a[:start])
# print("before_score", before_score)

loop = a[start:]
# print(loop)
loop_score = sum(loop)
# print("loop_score", loop_score)
loop_n = len(loop)
N -= start
res_n = N % loop_n
print(before_score + loop_score * (N // loop_n) + sum(loop[:res_n]))

Measured memory_bytes: 13664
<?php
fscanf(STDIN, "%d%d%d", $H, $W, $K);
$mod = 1000000007;
$map[0][0] = 1;
for($y = 1; $y <= $H; $y++){
    for($x = 0; $x < $W; $x++){
        for($i = 0; $i < 2**($W-1); $i++){
            $bits = sprintf("%0".($W-1)."b", $i);
            if(strpos($bits, "11") !== false)continue;
            $bits = "0".$bits."0";
            if($bits[$x] == 0 && $bits[$x+1] == 0){
                @$map[$y][$x] += $map[$y-1][$x];
            }elseif($bits[$x] == 1){
                @$map[$y][$x] += $map[$y-1][$x-1];
            }else{
                @$map[$y][$x] += $map[$y-1][$x+1];
            }
            $map[$y][$x] = $map[$y][$x] % $mod;
        }
    }
}
echo $map[$H][$K-1];

Measured memory_bytes: 4856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define loop(i,k,n) for (ll i = k ; i < n ; ++i)
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl

void Suhaib_Sawalha (){

    int x , n , a;
    cin >> x >> n;
    bitset <102> b;
    for (int i = 0 ; i < n ; ++i){
        cin >> a;
        b[a] = 1;
    }

    for (int i = x , j = x ; ; --i , ++j){
        if (!b[i]) {
            cout << i;
            return;
        }
        if (!b[j]) {
            cout << j;
            return;
        }
    }

}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<'\n')
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const int MOD = 1000000007; 


int main() {
   string s; cin >> s;
   cout << ((s == "ABC") ? "ARC" : "ABC") << endl;
   return 0;
}

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

#define ipow(a,b)+0.5 (int)pow(a,b)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fi first
#define se second

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

using namespace std;
typedef long long ll;
typedef long double ld;

class Task
{
public:
    void solve(istream& in,ostream& out)
    {
        int n;
        in>>n;

        out<<n*800-(n/15)*200<<endl;
    }
};


int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	Task solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in,out);
	out.flush();

    return 0;
}





Measured memory_bytes: 892
import sys
import numpy as np

n = int(input())
aaa = list(map(int, sys.stdin))
MOD = 998244353

s = sum(aaa)
dp1 = np.zeros(s + 1, dtype=np.int64)
dp2 = np.zeros(s + 1, dtype=np.int64)
dp1[0] = 1
dp2[0] = 1
for a in aaa:
    dp1a = np.roll(dp1, a)
    dp1 *= 2
    dp1 %= MOD
    dp1 += dp1a
    dp1 %= MOD

    dp2 += np.roll(dp2, a)
    dp2 %= MOD

h = (s + 1) // 2
ans = (pow(3, n, MOD) - dp1[h:].sum() * 3) % MOD
if s % 2 == 0:
    ans = (ans + dp2[h] * 3) % MOD
print(ans)


Measured memory_bytes: 17224
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;
 
ll mod = 1000000007;
 
int main(){
    string S; cin >> S;
    char a, b;
    a = S[0]; 
    ll t = 0;
    vector<char> k(0);
    for(int i=1; i<4; i++){
        if(S[i] != a){
            t++;
            k.emplace_back(S[i]);
        }
    }
    if(t == 2&&k[0]==k[1]){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

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

int compare_int(const void*,const void*);

int main(){
	int N,K;
	scanf("%d %d",&N,&K);
	int H[N];
	for(int i=0;i<N;i++) scanf("%d",&H[i]);
	qsort(H,N,sizeof(int),compare_int);
	unsigned long count=0;
	for(int i=0;i<N-K;i++) count+=H[i];
	printf("%lu",count);
	return 0;
}

int compare_int(const void *a,const void *b){
	const int *a0 = (const int*)a;
	const int *b0 = (const int*)b;
	return *a0-*b0;
}


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

int main(){
  string s;
  cin >> s;
  if(s.length() < 26) {
    rep(i,26) {
      string t = ""; t += 'a' + i;
      if(s.find(t) == string::npos) {
        cout << s + t << endl;
        return 0;
      }
    }
  }
  for(int i = 23; i >= 0; i--) {
    char c = 'z'+1;
    for(int j = i+2; j < 26; j++) {
      if(s[j] > s[i+1]) c = min(c,s[j]);
    }
    if(c != 'z'+1) {
      string ans = "";
      rep(j,i+1) ans += s[j];
      ans += c;
      cout << ans << endl;
      return 0;
    }
  }
  if(s == "zyxwvutsrqponmlkjihgfedcba") {
    cout << -1 << endl;
    return 0;
  }
  cout << ++s[0] << endl;
  return 0;
}

Measured memory_bytes: 256
import math
x=input()
x0=x.split()
x=int(x0[0])
k=int(x0[1])
d=int(x0[2])
if abs(x)>abs(k*d):
    print(abs(x)-abs(k*d))
else:
    c=math.floor(abs(x)/d)
    if abs(x)-c*d<abs(abs(x)-(c+1)*d):
        if (k-c)%2==0:
            print(abs(x)-c*d)
        else:
            print(abs(abs(x)-(c+1)*d))
    else:
        if (k-c)%2==0:
            print(abs(x)-c*d)
        else:
            print(abs(abs(x)-(c+1)*d))

Measured memory_bytes: 62192
use proconio::input;

fn main() {
    input! {
        a: i64,
        b: i64,
        k: i64,
    }

    solve(a, b, k);
}

fn solve(a: i64, b: i64, k: i64) {
    if a >= k {
        println!("{} {}", a - k, b);
        return;
    }
    println!("{} {}", 0, std::cmp::max(0, b - (k - a)));
}


Measured memory_bytes: 2108
#include <iostream>

using namespace std;

string s;
long long int rez;
int br[30];

int main(){

    cin >> s;
    rez =(long long)(s.size()*(s.size()+1))/2;

    for (int i=0; i<s.size(); i++){
        (long long)(br[s[i] - 97])++;
    }

    for (int i=0; i<s.size(); i++){
        if ((long long)(br[s[i] - 97])>0){
            rez -= ((long long)(br[s[i] - 97]) * ((long long)(br[s[i] - 97])+1)) / 2;
            br[s[i] - 97]=0;
        }
    }


    cout << rez + 1;

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%d", &arr[i]);
    }
    return 0;
}

#define NUM_MAX 100000

int asc(const void *a1, const void *a2) {
    return *(int*)a1 - *(int*)a2;
}

int main(void) {
    int num = get_int();
    static int arr[NUM_MAX];
    fget_array(arr, num);
    qsort(arr, num, sizeof(int), asc);

    int i;
    int bigger = arr[num-1];
    int smaller = 0;
    int arg = 0;
    for(i = 0; i < num-1; i++) {
        int target = min(bigger-arr[i], arr[i]);
        if(smaller < target) {
            smaller = target;
            arg = i;
        }
    }

    printf("%d %d\n", arr[num-1], arr[arg]);
    return 0;
}

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

int main(){
  int N, K;
  cin >> N >> K;
  
  int a[60];
  
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  
  sort(a, a+N, greater<int>());
  
  int ans = 0;
  for (int i = 0; i < K; i++) {
    ans += a[i];
  }
  
  cout << ans << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>

#define f first
#define s second
#define mp make_pair

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

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  int n; cin>>n;
  REP(c,n){
    int s; cin>>s;
    printf("Case %d:\n",c+1);
    REP(i,10){
      char buff[16];
      sprintf(buff,"%08d",s*s);
      buff[6] = '\0';
      sscanf(buff+2,"%d",&s);
      printf("%d\n",s);
    }
  }
  return 0;
}

Measured memory_bytes: 0
use std::io;

fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let N:f64 = read_line().parse::<f64>().unwrap();
    let X:Vec<i64> = read_line().split_whitespace().map(|x|x.parse::<i64>().unwrap()).collect::<Vec<i64>>();
    
    let x:i64 = X.iter().sum();
    let P:i64 = (x as f64/N).round() as i64; 
    let mut sum = 0;
    for i in X.iter() {
        sum+=(i-P)*(i-P)
    }

    println!("{}",sum);
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <map>
#define Z class
#define ln cout<<'\n'
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a < b) { a=b; return 1; }return 0;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) { a=b; return 1; }return 0;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

int main(){
    int N; cin >> N;
    ll res = 1;
    for(ll i = 1; i <= N; ++i){
        res *= i;
        res %= (ll)pow(10,9)+7; 
    }
    pr(res);
    
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;

int main(){
    double L; cin >> L;
    
    double res = L / 3;
    cout << fixed << setprecision(12) << res*res*res << endl;
}

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

using namespace std;

long long dp[87];
long long recFn(int i){
   if( i ==0) return 2;
   if(i ==1) return 1;
   if(dp[i] != -1) return dp[i];
   dp[i] = recFn(i-1) + recFn(i-2);
   return dp[i];
}

int main(){
  string in;
  cin>>in;
  if(in.size() != 4) return 0;
  int a,b,c,d;
  a=in[0]-'0'; 
  b=in[1]-'0'; 
  c=in[2]-'0'; 
  d=in[3]-'0'; 
  for(int i= 1;i >= -1; i-=2)
    for(int j= 1;j >= -1; j-=2)
      for(int k= 1;k >= -1; k-=2)
        for(int m= 1;m >=-1; m-=2)
        {
          if(i*a + j*b + k*c + m*d ==7)
          {
            if(i==-1)cout<<"-";
            cout<<a;
            if(j==-1)cout<<"-"; else cout<<"+";
            cout<<b;
            if(k==-1)cout<<"-"; else cout<<"+";
            cout<<c;
            if(m==-1)cout<<"-"; else cout<<"+";
            cout<<d;
            cout<<"=7"<<endl;
            return 0;
          }
        }
  return 0;
}

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

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		int[] p = new int[n];
		for( int i=0 ; i<n ; i++ ) {
			p[i] = sc.nextInt();
		}
		
		Arrays.sort(p);
		
		int s= 0;
		for( int i=0 ; i<k ; i++ ) {
			s += p[i];
		}
		
		System.out.println(s);
	}

}

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

int main(){
  	int x;
  	for (int i=1; i<=5; i++){
      	cin >> x;
      	if (x == 0) { cout << i << endl; return 0; }
    }
  	return 0;
}

Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int p = 2000;
		int j = 2000;
		int x = 0;
		
		for(int i = 0; i < 3; i++) {
			x = sc.nextInt();
			if(p > x)p = x;
			
		}
		for(int i = 0; i < 2; i++) {
			x = sc.nextInt();
			if(j > x)j = x;
		}
		System.out.println(p + j - 50);

	}

}

Measured memory_bytes: 26124
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
//typedef __int128_t Int;
#define DBG 1
#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 loop(n) rep(loop,(0),(n))
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

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

  int N; cin >> N;
  vector<int>v(N+2);rep(i,1,N+1)cin>>v[i];
  int sum=0;
  rep(i,1,N+2)sum+=abs(v[i]-v[i-1]);

  rep(i,1,N+1){
    int c=abs(v[i-1]-v[i])+abs(v[i]-v[i+1])-abs(v[i-1]-v[i+1]);
    cout<<sum-c<<endl;
  }


    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
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;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,a[100010],dp[100010];
signed main(){
    cin>>n;
    rep(i,n)cin>>a[i];
    fill(dp+1,dp+n,INF);
    rep(i,n-1){
        chmin(dp[i+1],dp[i]+abs(a[i+1]-a[i]));
        chmin(dp[i+2],dp[i]+abs(a[i+2]-a[i]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1792
S = input()
P = input()
is_ok = False
for i in range(len(S)):
    FLG = True
    for k in range(len(P)):
        if S[(i+k)%(len(S))]!=P[k]:
        
            FLG = False
            break
    if FLG:
        is_ok =True
        break
if is_ok:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5564