akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
using namespace std;

template <int32_t MOD>
struct mint {
    int32_t value;
    mint() : value() {}
    mint(int64_t value_) : value(value_ < 0 ? value_ % MOD + MOD : value_ >= MOD ? value_ % MOD : value_) {}
    mint(int32_t value_, std::nullptr_t) : value(value_) {}
    explicit operator bool() const { return value; }
    inline constexpr mint<MOD> & operator += (mint<MOD> other) { this->value += other.value; if (this->value >= MOD) this->value -= MOD; return *this; }
};
template <int32_t MOD> std::ostream & operator << (std::ostream & out, mint<MOD> n) { return out << n.value; }

constexpr int MOD = 1e9 + 7;
mint<MOD> solve(int n, const vector<int> & a) {
    map<tuple<int, int, int>, mint<MOD> > cur;
    cur[make_tuple(0, 0, 0)] += 1;
    for (int a_i : a) {
        map<tuple<int, int, int>, mint<MOD> > prv;
        cur.swap(prv);
        for (auto it : prv) {
            int x, y, z; tie(x, y, z) = it.first;
            mint<MOD> cnt = it.second;
            if (x == a_i) cur[make_tuple(x + 1, y, z)] += cnt;
            if (y == a_i) cur[make_tuple(x, y + 1, z)] += cnt;
            if (z == a_i) cur[make_tuple(x, y, z + 1)] += cnt;
        }
    }
    mint<MOD> answer = 0;
    for (auto it : cur) {
        answer += it.second;
    }
    return answer;
}

int main() {
    int n; cin >> n;
    vector<int> a(n);
    REP (i, n) {
        cin >> a[i];
    }
    cout << solve(n, a) << endl;
    return 0;
}


Measured memory_bytes: 640
import java.util.*;
import java.io.*;
public class Main
{
  public static void main(String args[])throws Exception
  {
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    PrintWriter pw=new PrintWriter(System.out);
    int n=Integer.parseInt(br.readLine());
    String str[]=br.readLine().split(" ");
    int boss[]=new int[n+1];
    for(int i=0;i<n-1;i++)
    boss[Integer.parseInt(str[i])]++;
    for(int i=1;i<=n;i++)
    pw.println(boss[i]);
    pw.flush();
    pw.close();
  }
}

Measured memory_bytes: 62480
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Graph = vector<vector<int>>;

int main() {
  int s, w;
  cin >> s >> w;
  if (s <= w)
    cout << "unsafe" << endl;
  else
    cout << "safe" << endl;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  map<char, int> mp;
  rep(i, s.size()){
    mp[s.at(i)]++;
  }
  mint ans = 1;
  for(auto p : mp){
    ans *= (p.second+1);
  }
  ans -= 1;
  cout << ans.x << endl;
  return 0;
}

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

using namespace std;

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

  vector<int> h(n);
  vector<bool> f(n, true);
  for (int i = 0; i < n; ++i) cin >> h[i];

  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    if (h[--a] <= h[--b]) f[a] = false;
    if (h[b] <= h[a]) f[b] = false;
  }

  int cnt = 0;
  for (int i = 0; i < n; ++i) if (f[i]) cnt++;
  cout << cnt << endl;
}


Measured memory_bytes: 3740
import numpy as np

if __name__=="__main__":
    n = int(input())
    a  = [int(x) for x in input().split()]
    
    approved = True
    for i in range(n):
        if a[i]%2 == 0:
            if a[i]%3 == 0 or a[i]%5 == 0:
                continue
            else:
                approved = False
                break
    
    if approved:
        print("APPROVED")
    else:
        print("DENIED")


Measured memory_bytes: 21444
a,b,c,d=map(int, input().split())

import fractions

def lcm(x,y):
	return (x*y)//fractions.gcd(x,y)

lcmcd=lcm(c,d)
divc=b//c-(a-1)//c
divd=b//d-(a-1)//d
divcd=b//lcmcd-(a-1)//lcmcd

print(b-a+1-divc-divd+divcd)

Measured memory_bytes: 5304
/*  TAHMID RAHMAN
    DAMIAN FOREVER
     MATH LOVER
    NEVER GIVE UP
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define fi first
#define se second
#define in insert
#define mp make_pair
#define GCD(a,b) __gcd(a,b);
#define endl "\n"
#define FRU freopen("out.txt","w",stdout)
#define FRO freopen("in.txt","r",stdin)
#define INFLL 9223372036854775807
#define debug 0
#define MAXN   100001
#define ar array
const int mxN=2e5;
const int MOD=1e9+7;
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
//Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;
int main()
{
    fastio;
    ll n;
    cin>>n;
    ll ans=0;
    ll temp1=n/500;
    ll temp2=n%500;
    ll temp3=temp2/5;
    ans=temp1*1000+temp3*5;
    cout<<ans<<endl;
}


Measured memory_bytes: 3620
#include <stdio.h>

int main(void) {

  long n,m;
  scanf("%ld %ld", &n, &m);
  long a[m],b[m];
  for (long i = 0; i < m; i++) {
    scanf("%ld %ld", &a[i], &b[i]);
  }
  int from1[n],toN[n];
  for (long i = 0; i < n; i++) {
    from1[i] = 0;
    toN[i] = 0;
  }
  for (long i = 0; i < m; i++) {
    if (a[i] == 1) {
      from1[b[i]-1] = 1;
    }
    if (b[i] == 1) {
      from1[a[i]-1] = 1;
    }
    if (a[i] == n) {
      toN[b[i]-1] = 1;
    }
    if (b[i] == n) {
      toN[a[i]-1] = 1;
    }
  }
  for (long i = 1; i < n-1; i++) {
    if (from1[i] == 1 && toN[i] == 1) {
      printf("POSSIBLE\n");
      return 0;
    }
  }
  printf("IMPOSSIBLE\n");

  return 0;
}

Measured memory_bytes: 4864
from sys import stdin
data = stdin.readlines()

n = int(data[0].split()[0])
m = int(data[0].split()[1])

k = int(data[0].split()[2])

A = [int(s) for s in data[1].split()]
B = [int(s) for s in data[2].split()]

a = [0]
b = [0]

for i in range(n):
    a.append(a[i]+A[i])
for i in range(m):
    b.append(b[i]+B[i])

ans = 0
j = m
for i in range(n+1):
    if a[i] > k:
        break
    else:
        while a[i]+b[j] > k:
            j -= 1
        ans = max(ans, i+j)
print(ans)

Measured memory_bytes: 135400
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define INF 1000000000
int i,j;
int main(){
    int n;cin>>n;
    vector<int> a(n+1);
    for(i=1;i<=n;i++){cin>>a[i];}

    int ok=1,ans=0;;
    for(i=1;i<=n;i++){
        if(ok==a[i]){ok++;}
        else{ans++;}
    }

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define ld long double
const int mod=1e9 +7;







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


  
 double a,b,x;
  cin>>a>>b>>x;

cout<<setprecision(10)<<fixed;

if(2*x<=a*a*b){
double  k=(b*b*a)/x;
k/=2;

double ans=atan(k);
ans=ans*(180.0)/(3.14159265359);
cout<<setprecision(8)<<ans<<"\n";
}

else
{
    double k=a*a*b - x;
  k=k*2.0;
  k=k/(a*a*a);
 double  ans=atan(k)*180.0;
  ans=ans/(3.14159265359);
 cout<<setprecision(10)<<ans<<"\n";
 
}

  

   
}

 

 
 
 
 
 

Measured memory_bytes: 256
import heapq

N, M = [int(v) for v in input().split()]
items = [[] for _ in range(M)]
for i in range(N):
    a, b = (int(v) for v in input().split())
    if M - a >= 0:
        items[M - a].append(b)
q = []
res = 0
for i in range(M - 1, -1, -1):
    for v in items[i]:
        heapq.heappush(q, -v)
    if q:
        res += heapq.heappop(q)
print(-res)

Measured memory_bytes: 18308
def solve():
  m, n = map(int,input().split())
  k = int(input())
  mp = [input() for i in range(m)]
  dp = [[[0] * 3 for j in range(n + 1)] for i in range(m + 1)]
  dic = {"J":0, "O":1, "I":2}

  for i in range(1, m + 1):
    dpi = dp[i]
    dpi_1 = dp[i - 1]

    for j in range(1, n + 1):
      dpij = dpi[j]
      dpij_1 = dpi[j - 1]
      dpi_1j = dpi_1[j]
      dpi_1j_1 = dpi_1[j - 1]

      for p in range(3):
        #dp[i][j][p] = dp[i][j - 1][p] + dp[i - 1][j][p] - dp[i - 1][j - 1][p]
        dpij[p] = dpij_1[p] + dpi_1j[p] - dpi_1j_1[p]

      #dp[i][j][mp[i - 1][j - 1]] += 1
      dpij[dic[mp[i - 1][j - 1]]] += 1
     
  ans = ""
  for i in range(k):
    x1,y1,x2,y2 = map(int,input().split())
    dpx2 = dp[x2]
    dpx1 = dp[x1 - 1]
    dpx2y2 = dpx2[y2]
    dpx2y1 = dpx2[y1 - 1]
    dpx1y2 = dpx1[y2]
    dpx1y1 = dpx1[y1 - 1]
    #print(dp[x2][y2][0] - dp[x1 - 1][y2][0] - dp[x2][y1 - 1][0] + dp[x1 - 1][y1 - 1][0], dp[x2][y2][1] - dp[x1 - 1][y2][1] - dp[x2][y1 - 1][1] + dp[x1 - 1][y1 - 1][1], dp[x2][y2][2] - dp[x1 - 1][y2][2] - dp[x2][y1 - 1][2] + dp[x1 - 1][y1 - 1][2])
    ans += str(dpx2y2[0] - dpx1y2[0] - dpx2y1[0] + dpx1y1[0]) + " " + str(dpx2y2[1] - dpx1y2[1] - dpx2y1[1] + dpx1y1[1]) + " " + str(dpx2y2[2] - dpx1y2[2] - dpx2y1[2] + dpx1y1[2]) + "\n"
  ans = ans.rstrip()
  print(ans)


solve()


Measured memory_bytes: 200052
/*
???????????´??°?????????????????????????????????????°??????????????????????????????????????????°?????????????????????????????????
*/

#include <iostream>

// ?????????????´??????°??????????????????????????¬??????
template
<
	typename TYPE,
	std::size_t SIZE
>
std::size_t array_length(const TYPE(&)[SIZE])
{
	return SIZE;
}

int main() {
	int num[3];
	int tmp;
	std::cin >> num[0] >> num[1] >> num[2];

	for (int i = 0; i < array_length(num); i++)
	{
		for (int j = i+1; j < array_length(num); j++)
		{
			// ??????????????\?????????
			if (num[i] > num[j]) {
				tmp = num[i];
				num[i] = num[j];
				num[j] = tmp;
			}			
		}
	}
	std::cout << num[0] << " " << num[1] << " " << num[2] << std::endl;
	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll ans=0;
ll divisor(ll n) {
    vector<ll> res;
    for (ll i=1; i*i<=n; i++){
        if (n%i==0&&i<n/i-1){
            ans+=n/i-1;
        }
    }
    return ans;
}
ll N;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    cout <<divisor(N)<<"\n";
}

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

int main() {
    int N; cin >> N;
    vector<vector<int>> C(10, vector<int>(10));
    for (int i = 1; i <= N; i++) {
        int left = i, right = i % 10;
        while (left > 9) {
            left /= 10;
        }
        C[left][right]++;
    }
    long long ans = 0;
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            ans += 1ll * C[i][j] * C[j][i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
from collections import defaultdict
def input(): return sys.stdin.readline().rstrip()

def main():
    H, W, K = map(int, input().split())
    S = [input() for _ in range(H)]

    ans = 10 ** 9

    for bit in range(1 << (H-1)):
        canSolve = True
        ord = defaultdict(int)
        N = 0
        for i in range(H):
            if bit & 1 << i:
                ord[i+1] = ord[i] + 1
                N += 1
            else:
                ord[i+1] = ord[i]
        add = 0
        nums = defaultdict(int)
        for w in range(W):
            one = defaultdict(int)
            ok = True
            for h in range(H):
                one[ord[h]] += int(S[h][w])
                nums[ord[h]] += int(S[h][w])
                if one[ord[h]] > K:
                    canSolve = False
                if nums[ord[h]] > K:
                    ok = False
            if not ok:
                add += 1
                nums = one
        if canSolve and ans > N + add:
            ans = N + add
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 48740
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public long MOD = 1000000007;

        public void Run()
        {
            N = Input.ReadInt();
            while (true)
            {
                if (OK(N))
                {
                    Console.WriteLine(N);
                    return;
                }
                N++;
            }
        }

        public bool OK(int n)
        {
            int b = n % 10;
            n /= 10;
            while (n > 0)
            {
                if (n % 10 != b) return false;
                n /= 10;
            }

            return true;
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13140
function Main(input) {
	input = input.split("\n")
	var araresN = parseInt(input[0])
	var arares = input[1].split(" ")

	console.log(arares.indexOf("Y") == -1 ? "Three": "Four")
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
nn= int(input())
for _ in range(0,nn):
    gx,gy = map(int,input().split())
    p=int(input())
    m_vert,m_horiz=[],[]
    for _ in range(0,p):
        a,b,c,d = map(int, input().split())
        if a==c:
            if b < d:  # b > d nisuru
                b,d = d,b
            m_vert.append([a,b])
        elif b==d:
            if a < c:
                a,c= c,a
            m_horiz.append([a,b])

    ans= [[0]*(gx+100) for _ in range(gy+100)]
    horiz= [[True]*(gx+100) for _ in range(gy+100)]
    vert= [[True]*(gx+100) for _ in range(gy+100)]
    for i in m_horiz:
        horiz[i[0]][i[1]] = False
    for i in m_vert:
        vert[i[0]][i[1]] = False

    for i in range(0,gx+1):
        for j in range(0,gy+1):
            if i==0 and j==0:
                ans[0][0]=1
            if i!=0 and horiz[i][j] :
                ans[i][j] += ans[i-1][j]
            if j!=0 and vert[i][j] :
                ans[i][j] += ans[i][j-1]

    if ans[gx][gy]==0:
        print("Miserable Hokusai!")
    else:
        print(ans[gx][gy])            
    #print(ans)
        


        
        


Measured memory_bytes: 6068
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

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

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

    int n;
    cin >> n;
    vector<ll> a(3 * n);

    priority_queue<ll, vector<ll>, greater<ll>> q1;
    priority_queue<ll> q2;
    vector<ll> sum1(n + 1, 0), sum2(n + 1, 0);
    rep(i, 3 * n) {
        cin >> a[i];
        if(i < n) {
            q1.push(a[i]);
            sum1[0] += a[i];
        }
        if(i >= 2 * n) {
            q2.push(a[i]);
            sum2[0] += a[i];
        }
    }

    rep(i, n) {
        q1.push(a[n + i]);
        sum1[i + 1] = sum1[i] + a[n + i] - q1.top();
        q1.pop();
        q2.push(a[2 * n - 1 - i]);
        sum2[i + 1] = sum2[i] + a[2 * n - 1 - i] - q2.top();
        q2.pop();
    }

    ll ans = -inf;
    rep(i, n + 1) chmax(ans, sum1[i] - sum2[n - i]);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6516
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)

	ans := c - (a - b)
	if ans >= 0 {
		fmt.Println(ans)
	} else {
		fmt.Println(0)
	}
}


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

int main(){
    int A[3][3], N, b[101];
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin >> A[i][j];
        }
    }
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> b[i];
        for(int j=0; j<3; j++){
            for(int k=0; k<3; k++){
                if(A[j][k] == b[i]){
                    A[j][k] = 0;
                }
            }
        }
    }

    bool result = false;
    for(int i=0; i<3; i++){
        if(A[i][0] == A[i][1]){
            if(A[i][1] == A[i][2]){
                result = true;
            }
        }
    }
    for(int i=0; i<3; i++){
        if(A[0][i] == A[1][i]){
            if(A[1][i] == A[2][i]){
                result = true;
            }
        }
    }
    if(A[0][0]==A[1][1]){
        if(A[1][1]==A[2][2]){
            result = true;
        }
    }
    if(A[0][2]==A[1][1]){
        if(A[1][1]==A[2][0]){
            result = true;
        }
    }

    if(result){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {
    while (true) {
        int x, h;
        cin >> x >> h;
        if (x == 0 && h == 0) {
            break;
        }

        double s = 0;
        s += x * x;
        s += 2 * x * sqrt(pow((double)x / 2, 2) + pow(h, 2));
        printf("%.6f\n", s);
    }
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
using namespace std;
#define ll long long

vector<int> s(4);
string S;

int main(){
  cin >> S;
  for(int i=0; i<4; i++){
    s[i] = S[i]-'0';
  }
  if(s[0]+s[1]+s[2]+s[3] == 7) cout << s[0] << "+" << s[1] << "+" << s[2] << "+" << s[3] << "=7" << endl;
  else if(s[0]+s[1]+s[2]-s[3] == 7) cout << s[0] << "+" << s[1] << "+" << s[2] << "-" << s[3] << "=7" << endl;
  else if(s[0]+s[1]-s[2]+s[3] == 7) cout << s[0] << "+" << s[1] << "-" << s[2] << "+" << s[3] << "=7" << endl;
  else if(s[0]+s[1]-s[2]-s[3] == 7) cout << s[0] << "+" << s[1] << "-" << s[2] << "-" << s[3] << "=7" << endl;
  else if(s[0]-s[1]+s[2]+s[3] == 7) cout << s[0] << "-" << s[1] << "+" << s[2] << "+" << s[3] << "=7" << endl;
  else if(s[0]-s[1]+s[2]-s[3] == 7) cout << s[0] << "-" << s[1] << "+" << s[2] << "-" << s[3] << "=7" << endl;
  else if(s[0]-s[1]-s[2]+s[3] == 7) cout << s[0] << "-" << s[1] << "-" << s[2] << "+" << s[3] << "=7" << endl;
  else if(s[0]-s[1]-s[2]-s[3] == 7) cout << s[0] << "-" << s[1] << "-" << s[2] << "-" << s[3] << "=7" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; 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;
    cout << N * 800 - (N/15) * 200 << endl;


    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int result = IntStream.range(0,n).map(i->{
            int a = sc.nextInt();
            if( k-a < a ){
                a = k-a;
            }
            return  a*2;
        }).sum();

        System.out.print(result);
    }
}

Measured memory_bytes: 28740
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<unordered_map>

using namespace std;
typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int DP[110000][15] = {};

int main(){
  string S;
  cin >> S;
  DP[0][0] = 1;
  for(int i = 0; i < S.size(); i++){
    if(S[i] == '?'){
      for(int j = 0; j < 13; j++){
        for(int num = 0; num <= 9; num++){
          DP[i + 1][(j * 10 + num) % 13] += DP[i][j];
          DP[i + 1][(j * 10 + num) % 13] %= MOD;
        }
      }
    }else{
      int num = S[i] - '0';
      for(int j = 0; j < 13; j++){
        DP[i + 1][(j * 10 + num) % 13] += DP[i][j];
        DP[i + 1][(j * 10 + num) % 13] %= MOD;
      }
    }
  }
  cout << DP[S.size()][5] << endl;
  return 0;
}


Measured memory_bytes: 12800
import java.util.Scanner;

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

		int k = sc.nextInt();
		int s = sc.nextInt();
		int sum = 0;

		for (int h = 0; h <= k; h++) {
			for (int i = 0; i <= k; i++) {
				if (h + i + k >= s && h + i <= s) {
					sum = sum + 1;
				}
			}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PI acos(-1)
#define X real()
#define Y imag()

typedef long long lli;
typedef complex<lli> P;
const lli MaX = 100005 , infi =1110111110111 , mod = 1000000007 ;
typedef pair<int,int> pii;
const int MX = 100005;

double a , b;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>a>>b;
    cout<<a/b;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=1000005;
int g[maxn],sum[maxn],n;
const int mod=1e9+7;
int main(){
	read(n);
	g[0]=1;
	g[1]=n;g[2]=1ll*n*n%mod;
	sum[0]=g[0];
	sum[1]=(sum[0]+g[1])%mod;
	sum[2]=(sum[1]+g[2])%mod;
	rep(i,3,n){
		g[i]=(g[i-1]+1ll*(n-1)*(n-1))%mod;
		g[i]=(g[i]+(n-i+1))%mod;
		if(i>=3)g[i]=(g[i]+sum[i-3])%mod;
		sum[i]=(sum[i-1]+g[i])%mod;
	}
	printf("%d\n",g[n]);
	return 0;
}


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

int main()
{
  int a, b;
  char op;
  while (1) {
    cin >> a >> op >> b;
    if (op == '?') break;
    if (op == '+') cout << a + b << endl;
    else if (op == '-') cout << a - b << endl;
    else if (op == '*') cout << a * b << endl;
    else if (op == '/') cout << a / b << endl;
  }
  return 0;
}



Measured memory_bytes: 3092
import sys
from itertools import starmap
readline = sys.stdin.readline
EPS = 1e-9
ONLINE_FRONT = -2
CLOCKWISE = -1
ON_SEGMENT = 0
COUNTER_CLOCKWISE = 1
ONLINE_BACK = 2
class Segment(object):
    __slots__ = ('fi', 'se')
    def __init__(self, fi, se):
        self.fi = fi
        self.se = se
def cross(a, b):
    return a.real * b.imag - a.imag * b.real
def dot(a, b):
    return a.real * b.real + a.imag * b.imag
def norm(base):
    return abs(base) ** 2
def project(s, p2):
    base = s.fi - s.se
    r = dot(p2 - s.fi, base) / norm(base)
    return s.fi + base * r
def reflect(s, p):
    return p + (project(s, p) - p) * 2.0
def ccw(p1, p2, p3):
    a = p2 - p1
    b = p3 - p1
    if cross(a, b) > EPS: return 1
    if cross(a, b) < -EPS: return -1
    if dot(a, b) < -EPS: return 2
    if norm(a) < norm(b): return -2
    return 0
def intersect4(p1, p2, p3, p4):
    return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 and
			ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0)
def intersect2(s1, s2):
    return intersect4(s1.fi, s1.se, s2.fi, s2.se)
def getDistance(a, b):  return abs(a - b)
def getDistanceLP(l, p):
    return abs(cross(l.se - l.fi, p - l.fi) / abs(l.se - l.fi))
def getDistanceSP(s, p):
    if dot(s.se - s.fi, p - s.fi) < 0.0: return abs(p - s.fi)
    if dot(s.fi - s.se, p - s.se) < 0.0: return abs(p - s.se)
    return getDistanceLP(s, p)
def getDistances(s1, s2):
    if intersect2(s1, s2): return 0.0
    return min(getDistanceSP(s1, s2.fi), getDistanceSP(s1, s2.se),
               getDistanceSP(s2, s1.fi), getDistanceSP(s2, s1.se))
def getCrossPoint(s1, s2):
	base = s2.se - s2.fi
	d1 = abs(cross(base, s1.fi - s2.fi))
	d2 = abs(cross(base, s1.se - s2.fi))
	t = d1 / (d1 + d2)
	return s1.fi + (s1.se - s1.fi) * t
n = int(readline())
for _ in [0] * n:
    p0, p1, p2, p3 = starmap(complex, zip(*[map(int, readline().split())] * 2))
    p = getCrossPoint(Segment(p0, p1), Segment(p2, p3))
    print("{0:.10f} {1:.10f}".format(p.real, p.imag))

Measured memory_bytes: 7908
# n,m = map(int,input().split())
n = int(input())
# n = input()
a = list(map(int,input().split()))
b = list(map(int,input().split()))
cnt = 0
left = 0
for i in range(n):
    a1,b1 = a[i],b[i]
    if a1 <= b1 + left:
        cnt += a1
        left = min(b1 - a1 + left,b1)
    else:
        cnt += b1 + left
        left = 0
if a[n] <= left:
    cnt += a[n]
else:
    cnt += left
print(cnt)


Measured memory_bytes: 19116
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll n;
	cin>>n;
	if(n<1200)
		cout<<"ABC"<<endl;
	else if(n>=1200 && n<2800)
	cout<<"ARC"<<endl;
	else
	cout<<"AGC"<<endl; 
}

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

int main()
{
  int a, b, t;
  cin >> a >> b >> t;
  int a0 = a, c = 0;
  while (a < t + 0.5)
  {
    c += b;
    a = a + a0;
  }
  cout << c << endl;
  return 0;
}

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

using namespace std;

int main() {
    int n; cin>>n;
    vector<int> pn;
    for (int i=0;i<n;i++) {
        int p; cin>>p;
        pn.push_back(p);
    }

    int cnt=0;
    for (int i=0;i<n-2;i++) {
        int a=min({pn[i],pn[i+1],pn[i+2]});
        int b=max({pn[i],pn[i+1],pn[i+2]});
        //cout << pn[i] << "," << pn[i+1] << "," << pn[i+2] << endl;
        if (pn[i+1]!=a && pn[i+1]!=b) {
            cnt++;
        }
    }

    cout << cnt << endl;
    
    return 0;
}

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

struct Edge
{
    int nxt, to;
} e[100010];
int head[100010], cnt;

void add_edge(int a, int b)
{
    e[++cnt] = (Edge) { head[a], b };
    head[a] = cnt;
}

int dfs(int nod, int tata)
{
    vector <int> fii;
    for (int i(head[nod]); i; i = e[i].nxt)
        fii.push_back(dfs(e[i].to, nod));
    sort(fii.rbegin(), fii.rend());

    int dmax(0);
    for (int i(0); i < fii.size(); i++)
        dmax = max(dmax, i + 1 + fii[i]);

    return dmax;
}

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

    for (int i(2); i <= n; i++) {
        cin >> x;
        add_edge(x, i);
    }

    cout << dfs(1, 0);
    return 0;
}


Measured memory_bytes: 10752
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n;
		cin >> n;
		int ok =0;
		fn
		{
			int x;
			cin>>x;
			if(!(x&1)){
				if(x%3==0 || x%5==0){

				}
				else
					ok=1;
			}
		}
		cout << (ok==0 ?"APPROVED":"DENIED");
	
	}
	cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

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

// calculate |gcd|.
// if  ether num is 0, return 0
long long GCD(long long left, long long right) {
  if(left == 0 || right == 0) return 0;
  if(left < 0) left *= -1;
  if(right < 0) right *= -1;
  if(left < right) swap(left, right);
  long long nextnum, ansgcd = -1;
  while(ansgcd == -1) {
    nextnum = left % right;
    if(nextnum == 0) ansgcd = right;
    left = right;
    right = nextnum;
  }
  return ansgcd;
}

long long LCM(long long left, long long right) {
  return left / GCD(left, right) * right;
}

long long p, q, a, n, ans = 0, pq = 0;

void solve(long long child, long long mother,
           long long maxnum, long long now);

int main() {
  while(1) {
    cin >> p >> q >> a >> n;
    if(p + q + a + n == 0) break;
    ans = 0;
    pq = GCD(p, q);
    p /= pq;
    q /= pq;
    solve(0, 1, 1, 0);
    cout << ans << endl;
  }
  return 0;
}

void solve(long long child, long long mother,
           long long maxnum, long long now) {
  // check ans
  long long momq = mother * q, momp = mother * p,
            chilq = child * q, x;
  if(momq % (momp - chilq) == 0) {
    x = momq / (momp - chilq);
    if(x * mother <= a && x >= maxnum) ++ans;
  }
  if(now == n - 1) return;
  // dfs
  long long fin = (n - now) * (momq + momp - chilq - 1) /
                  (momp - chilq);
  for(int i = maxnum; i <= fin && mother * i <= a; ++i) {
    long long nextchil = child * i + mother,
              nextmom = mother * i;
    if(nextmom * p <= nextchil * q) continue;
    solve(nextchil, nextmom, i, now + 1);
  }
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define edl "\n"
#define ceils(s,n) (s+n-1)/n
#define str string
#define add insert
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, N = 1e5 + 10;
const ll LINF = LLONG_MAX;
int main() {
    fast();
    // #ifndef ONLINE_JUDGE
    //   freopen("input.txt", "r", stdin);
    //   freopen("output.txt","w",stdout);
    // #endif
    str s;
    cin >> s;
    str s1=s.substr(0,4);
    if(s1=="YAKI")
    {
        cout<<"Yes";
    }    
    else
        cout<<"No";

    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let a: Vec<Vec<i32>> = read_vec2(3);
    let n: i32 = read();
    let b: Vec<i32> = (0..n).map(|_| read()).collect();

    let mut table = [[false; 3]; 3];
    let mut yes = false;

    for (i, row) in a.iter().enumerate() {
        for (j, col) in row.iter().enumerate() {
            for v in &b {
                if v == col {
                    table[i][j] = true;
                }
            }
        }
    }

    // yoko
    for i in table.iter() {
        if i.iter().all(|&x| x) {
            yes = true;
            break;
        }
    }

    // tate
    if yes != true {
        for i in 0..3 {
            let mut temp = 0;
            for j in 0..3 {
                if table[j][i] {
                    temp += 1;
                }
            }
            if temp == 3 {
                yes = true;
                break
            }
        }
    }

    // naname
    if yes != true {
        if table[0][0] && table[1][1] && table[2][2] {
            yes = true;
        }

        if table[0][2] && table[1][1] && table[2][0] {
            yes = true;
        }
    }

    println!("{}", if yes {"Yes"} else {"No"});
}


Measured memory_bytes: 4352
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int quant = sc.nextInt();
 
        Queue<TimeTask> que = new ArrayDeque<>();
        for (int i = 0; i < n; i++) {
            que.add(new TimeTask(sc.next(), sc.nextInt()));
        }
         
        int timePoint = 0;
        while (!que.isEmpty()) {
            TimeTask head = que.poll();
 
            if (head.time > quant) {
                timePoint += quant;
                head.addTime(-quant);
                que.add(head);
                 
            } else {
                timePoint += head.time;
                System.out.println(head.task + " " + timePoint);
            }
        }
    }
     
    static class TimeTask {
        String task;
        int time;
        TimeTask (String task, int time) {
            this.task = task;
            this.time = time;
        }
         
        void addTime(int add) {
            time += add;
        }
    }
}


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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second

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

const ll MOD = 1e9+7;
	
ll gcd(ll a, ll b){
	return (b ? gcd(b, a%b) : a);
}

ll mmc(ll a, ll b){
	return a/gcd(a,b) * b;
}

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

	ll n, m; cin >> n >> m;
	vector<ll> v(n);
	for(auto& p: v) {cin >> p; p/=2;}

	ll mc = v[0];

	for(int i = 1; i < n; i++)
		mc = mmc(mc, v[i]);

	int cnt = 0;
	for(int i = 0; i < n; i++)
		if((mc/v[i])%2) cnt++;
	
	if(cnt == n) cout << (m/mc) - (m/mc)/2 << '\n';
	else cout << "0\n";

	return 0;
}

Measured memory_bytes: 1024
from sys import stdin
import bisect
def main():
    #入力
    readline=stdin.readline
    N=int(readline())
    S=readline().strip()

    res=0

    R=[]
    G=[]
    B=[]
    flags=[""]*N
    for i in range(N):
        if S[i]=="R":
            R.append(i)
            flags[i]="R"
        elif S[i]=="G":
            G.append(i)
            flags[i]="G"
        else:
            B.append(i)
            flags[i]="B"
    
    #Bが最後
    for i in range(len(R)):
        for j in range(len(G)):
            n=max(R[i],G[j])
            k=bisect.bisect_left(B,n)
            res+=len(B)-k
            if n+n-min(R[i],G[j])<N:
                if flags[n+n-min(R[i],G[j])]=="B":
                    res-=1
    
    for i in range(len(R)):
        for j in range(len(B)):
            n=max(R[i],B[j])
            k=bisect.bisect_left(G,n)
            res+=len(G)-k
            if n+n-min(R[i],B[j])<N:
                if flags[n+n-min(R[i],B[j])]=="G":
                    res-=1

    for i in range(len(B)):
        for j in range(len(G)):
            n=max(B[i],G[j])
            k=bisect.bisect_left(R,n)
            res+=len(R)-k
            if n+n-min(B[i],G[j])<N:
                if flags[n+n-min(B[i],G[j])]=="R":
                    res-=1

    print(res)
if __name__=="__main__":
    main()

Measured memory_bytes: 70424
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <utility>
#include <set>
#include <map>
#include <vector>
#include <queue>
#define LL long long
#define PII pair<int, int>
#define f first
#define s second
using namespace std;
const int MAXN = 2015;

int comp[3][3][8*MAXN];
string s[3];

void preprocess() {
    for (int i = 0; i < 3; i++) {
        for (int j = i + 1; j < 3; j++) {
            for (int p = -8000; p <= 8000; p++) {
                int &ok = comp[i][j][p + 8000];
                ok = 1;
                for (int k = 0; k < s[i].size(); k++) {
                    int opp = k - p;
                    if (0 <= opp && opp < (int) s[j].size() && s[i][k] != '?' && s[j][opp] != '?' && s[i][k] != s[j][opp]) {
                        ok = 0;
                        break;
                    }
                }
            }
        }
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);

    for (int i = 0; i < 3; i++) {
        cin >> s[i];
    }
    preprocess();

    int ans = 10000;
    for (int x = -4000; x <= 4000; x++) {
        if (!comp[0][1][x - 0 + 8000]) continue;
        for (int y = -4000; y <= 4000; y++) {
            if (!comp[1][2][y - x + 8000]) continue;
            if (!comp[0][2][y - 0 + 8000]) continue;
            int l = min({0, x, y});
            int r = max({0 + (int) s[0].size(), x + (int) s[1].size(), y + (int) s[2].size()});
            ans = min(ans, r - l);
        }
    }

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


Measured memory_bytes: 512
#include <stdio.h>

int main(void){
    int N, A, B,min;

    scanf("%d%d%d",&N,&A,&B);
    if(1<=N && N <=20 && 1 <= A && A<=50 && 1<=B && B <=50){
        if(N*A > B){
            min = B;
            printf("%d", min);
        }else{
            min = N*A;
            printf("%d", min);
        }
    }else{
        return 0;
    }
   
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

class Main {

	public static void main(String[] args) throws IOException {

		StringBuilder buider = new StringBuilder();

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] n = br.readLine().split(" ");

		System.out.println(new BigInteger(n[0]).gcd(new BigInteger(n[1])));

	}

}

Measured memory_bytes: 24536
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 a = 1;a<10;a++) {
			for(int b = 1;b<10;b++) {
				if(N==a*b) {
					System.out.println("Yes");
					System.exit(0);
				}
			}
		}
		System.out.println("No");

	}

}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
char s[2000500];
int n;
LL F[30],ans;
int main() {
	scanf("%s",s+1);
	n = strlen(s+1);
	for (int i=1;i<=n;i++) {
		F[ s[i]-'a' ]++;
		for (int j=0;j<26;j++) if (j != s[i]-'a') ans += F[j];
	}
	cout << ans+1 << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int n;
  cin>>n;
  int a[n];
  for (int i = 0; i < n; ++i)
  {
    /* code */
    cin>>a[i];
    if(i>0)a[0]=__gcd(a[0],a[i]);
  }
  cout<<a[0]<<endl;
  return 0;
}

Measured memory_bytes: 640
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T &v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)


inline int nth(int S, int i) {
  return (S>>i)&1;
}

int main() {
  int n, m;
  vector<ll> A[3];
  in(n),in(m);
  loop(i,0,n) {
    loop(j,0,3) {
      ll a; in(a);
      A[j].push_back(a);
    }
  }
  
  ll ans = 0;
  for (int S=0; S<(1<<3); S++) {
    vector<ll> B;
    loop(i,0,n) {
      ll sum = 0;
      loop(j,0,3) {
        if (nth(S, j)) sum += A[j][i];
        else sum -= A[j][i];
      }
      B.push_back(sum);
    }
    sort(B.rbegin(), B.rend());
    ll sum = 0;
    loop(i,0,m) sum += B[i];
    ans = max(sum, ans);
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pie 3.142857143
#define ll long long int
#define fr(i,a,n) for(ll i=a;i<n;i++)
#define vi vector<int>
#define vlli vector<ll>
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fv(i,a) for(auto i:a)
#define sz(a) int((a).size())
#define all(c) (c).begin(),(c).end()
#define frv(i,c) for(auto i = c.begin(); i != c.end(); i++)
const int N = 1e5 + 5;
int dp[N][3];
int a[N][3];
ll yogi(int n, int k)
{
	ll x, y;
	if (k == 0)
	{
		x = 1;
		y = 2;
	}
	if (k == 1)
	{
		x = 0;
		y = 2;
	}
	if (k == 2)
	{
		x = 0;
		y = 1;
	}
	if (n == 0)
		return max(a[0][x], a[0][y]);
	if (dp[n - 1][0] == 0)
		dp[n - 1][0] = yogi(n - 1, 0);
	if (dp[n - 1][1] == 0)
		dp[n - 1][1] = yogi(n - 1, 1);
	if (dp[n - 1][2] == 0)
		dp[n - 1][2] = yogi(n - 1, 2);
	ll s = max(a[n][x] + dp[n - 1][x], a[n][y] + dp[n - 1][y]);
	return s;

}
void solve()
{
	ll n;
	cin >> n;
	fr(i, 0, n)
	cin >> a[i][0] >> a[i][1] >> a[i][2];
	ll x = a[n][0] + yogi(n - 1, 0);
	ll y = a[n][1] + yogi(n - 1, 1);
	ll z = a[n][2] + yogi(n - 1, 2);
	x = max(x, max(y, z));
	cout << x << endl;
}


int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen ("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	//cin>>t;
	t = 1;
	while (t--)
	{
		solve();
	}


	return 0;
}

Measured memory_bytes: 13764
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

#define MAX 70
char c[MAX][MAX];
int W, H;
string dp[MAX][MAX];

bool cmp(string a, string b) {
	return a.size() == b.size() ? a < b : a.size() < b.size();
}

//xy??§?¨???§?????±???????????¢?´¢
string dfs(int x, int y) {
	if (x < W&&y < H) {
		if (dp[x][y] != "$")return dp[x][y];
		if (isdigit(c[x][y]))
			return dp[x][y] = c[x][y] + max(dfs(x + 1, y), dfs(x, y + 1), cmp);
		else
			return dp[x][y] = "";
	}
	else
		return "";
}

int main() {
	for (; cin >> W >> H&&W;) {
		memset(c, 0, sizeof(c));
		fill(dp[0], dp[MAX], "$");
		for (int y = 0; y < H; y++) {
			for (int x = 0; x < W; x++) {
				cin >> c[x][y];
			}
		}

		vector<string> v;
		for (int y = 0; y < H; y++) {
			for (int x = 0; x < W; x++) {
				v.push_back(dfs(x, y));
			}
		}
		for (int i = 0; i < v.size(); i++) {
			for (int j = 0; j < v[i].size();) {
				if (v[i][j] == '0')
					v[i] = v[i].substr(1);
				else
					break;
			}
		}
		//for (int i = 0; i < v.size(); i++) {
		//	cout << v[i] << endl;
		//}
		sort(v.begin(), v.end(), cmp);
		cout << v[v.size() - 1] << endl;
	}

	return 0;
}

Measured memory_bytes: 1656
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 + 7;

vector<string> g;

int main() {
    
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    ll x;
    cin >> x;
    
    for (int i = -2000; i <= 2000; ++i)
    {
        for (int j = -2000; j <= 2000; ++j)
        {
            if ((ll)pow(i, 5) - (ll)pow(j, 5) == x)
            {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 4236
use std::io::stdin;
use std::str::FromStr;
#[allow(dead_code, unused_mut)]
fn read<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().expect("1")
}
#[allow(dead_code, unused_mut)]
fn read_vec<T: FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().expect("2"))
        .collect()
}
#[allow(dead_code, unused_mut)]
fn read_two<T: FromStr>() -> (T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code, unused_mut)]
fn read_three<T: FromStr>() -> (T, T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code)]
fn remove_whitespace(s: &str) -> String {
    s.chars().filter(|c| !c.is_whitespace()).collect()
}

#[allow(unused_imports)]
use std::io::{stdout, Write};
use std::collections::HashMap;
fn main() {
    let n: i32 = read();
    
    let mut v1:Vec<String> = Vec::new();
    for _i in 0..n {
        v1.push(read::<String>());
    }

    let m: i32 = read();
    let mut v2:Vec<String> = Vec::new();
    for _i in 0..m {
        v2.push(read::<String>());
    }

    let mut map = HashMap::new();

    for i in v1 {
        let count = map.entry(i).or_insert(0);
        *count += 1;
    }
    for i in v2 {
        let count = map.entry(i).or_insert(0);
        *count -= 1;
    }
    let mut ans = 0;
    for i in map {
        if ans < i.1 {
            ans = i.1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352