akhauriyash/Code-Regression huggingface dataset:
using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int m = sc.NextInt();

        Console.WriteLine(((n - 1) * n + (m - 1) * m) / 2);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13140
use std::io;

fn main() {
    loop {
        let mut line = String::new();
        io::stdin().read_line(&mut line).ok();
        let n = line.trim().parse::<usize>().unwrap();

        if n == 0 { break }

        let mut line = String::new();
        io::stdin().read_line(&mut line).ok();
        let s = line.split_whitespace().map(|n| n.parse::<i32>().unwrap()).collect::<Vec<_>>();
        let ave = s.iter().sum::<i32>() as f64 / n as f64;
        let var = s.iter().map(|&n| (n as f64 - ave).powi(2)).sum::<f64>() / n as f64;

        println!("{}", var.sqrt());
    }
}



Measured memory_bytes: 5064
import sys
import math
n, k = map(int, input().split())
ans=[False]*n
for i in range(k):
    tmp = int(input())
    li = list(map(int, input().split()))
    for j in li:
        if (ans[j - 1] == False):
            ans[j - 1] = True
cnt = 0
for i in ans:
    if not i:
        cnt += 1
print(cnt)

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

using namespace std;

#define maxn 100007
#define ll long long int
#define db(x) cout<<#x<<" -> "<<x<<" "<<endl
#define db2(x,y) cout<<#x<<"->"<<x<<", "<<#y<<" -> "<<y<<endl
#define db3(x,y,z) cout<<#x<<" -> "<<x<<" , "<<#y<<" -> "<<y<<" , "<<#z<<" -> "<<z<<endl
#define prt(x) for(auto it:x) { cout<<it<<" "; } cout<<endl
#define IN freopen("input.txt","r",stdin)
multiset< ll > S ;
vector< ll > V[maxn];
int x,y,z,k;
void BackTrack(int pos, ll total){
    if(S.size() > min(1LL * 5000,1LL * x * y * z ) ){
        return ;
    }
    if( pos > 3 ){
        S.insert(total);
        return ;
    }
    for(int i=0; i<V[pos].size(); i++){
        BackTrack(pos+1,total+V[pos][i]);
    }
}

int main(){
//    IN ;
    cin>>x>>y>>z>>k;
    for(int i=1; i<=3; i++){
        int lim ;
        if(i==1){ lim = x ;}
        else if(i==2){ lim = y ; }
        else if(i==3){ lim = z ; }
        for(int j=1; j<=lim; j++){
            ll c;
            cin>>c;
            V[i].push_back(c);
        }
    }
    vector< ll > A ;
    for(auto i:V[1]){
        for(auto j:V[2]){
            ll x = i+j;
//            db2(i,j);
            A.push_back(x);
        }
    }
    sort(A.rbegin(),A.rend());
    A.resize(min(1LL * k, 1LL * x * y * z));
    vector< ll > ANS  ;
//    prt(A);
    for(auto i : A){
        for(auto j : V[3]){
            ll x = i+j;
            ANS.push_back(x);
        }
    }
    sort(ANS.rbegin(),ANS.rend());
    for(int i=0; i<k; i++){
        cout<<ANS[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 45560
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools

#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]



def main():
    n,a,b=map(int,input().split())
    mato=a+b
    amari=n%mato
    kazu=n//mato
    temp=0
    if amari<=a:
        temp=amari
    else:
        temp=a
    print(kazu*a+temp)


if __name__ == "__main__":
    main()

Measured memory_bytes: 38384
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvld;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

    int N;
    cin >> N;

    vll A(N);
    rep(i, N) cin >> A[i];

    ll ans = 0;

    rep(i, 60)
    {
        ll count = 0;
        rep(j, N)
        {
            count += A[j] % 2;
            A[j] /= 2;
        }

        ll tmp = 1LL << i;
        tmp %= MOD;
        tmp *= count;
        tmp %= MOD;
        tmp *= (N - count);
        tmp %= MOD;

        ans += tmp;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(void){
    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> v(n);
    for(int i = 0; i < n; i++){
        cin >> p.at(i);
        v.at(i) = i + 1;
    }
    int c = 0;
    for(int i = 0; i < n; i++){
        if(p.at(i) != v.at(i)) c++;
    }
    if(c == 0 || c == 2) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
import fractions
li = list(map(int,input().split()))
countC = li[1] // li[2] - (li[0]-1) // li[2]

countD = li[1] // li[3] - (li[0]-1) // li[3]

lcm = (li[2] * li[3]) // fractions.gcd(li[2], li[3])

countCD = li[1] // lcm - (li[0]-1) // lcm

re = (li[1] - li[0] + 1) - (countC +countD - countCD)

print(re)


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

int main(){
    long long A , B, K;
    cin >> A >> B >> K;
    long long a,b;
    a = A;
    b = B;
    if(A > K){
        a = A - K;
    }else{
        a = 0;
        K = K - A;
        b = B - K;
        if(b < 0) b = 0;
    }
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> pll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define out(x) cout << x << endl;
#define pb push_back
#define pair make_pair
const ll mod = 1000000007;

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

    vvl G(n);
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(b);
    }

    ll sv, tv;
    cin >> sv >> tv;
    sv--;  tv--;

    vvl dist(n, vl(3, -1));  // dist[i][j] : 移動距離がmod3でjとなる頂点svから頂点iまでの最短距離
    queue<pll> Q;

    dist[sv][0] = 0;
    Q.push(pair(sv, 0));
    while(!Q.empty()) {
        ll v = Q.front().first;
        ll c = Q.front().second;
        Q.pop();
        for(auto u : G[v]) {
            ll nc = (c + 1)%3;
            if(dist[u][nc] != -1) {
                continue;
            }
            dist[u][nc] = dist[v][c] + 1;
            Q.push(pair(u, nc));
        }
    }
    
    ll ans = dist[tv][0];
    if(ans != -1) {
        ans /= 3;
    }
    
    out(ans);
    return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string A, B, C;
  cin >> A >> B >> C;
  
  string turn;
  turn.push_back(A.at(0));
  
  while(true) {
    if(turn == "a") {
      if(A.empty()) {
        cout << "A" << endl;
        break;
      }
      
      turn = A.at(0);
      A.erase(A.begin());
    }
    if(turn == "b") {
      if(B.empty()) {
        cout << "B" << endl;
        break;
      }
      
      turn = B.at(0);
      B.erase(B.begin());
    }
    if(turn == "c") {
      if(C.empty()) {
        cout << "C" << endl;
        break;
      }
      
      turn = C.at(0);
      C.erase(C.begin());
    }
  }
}
 

Measured memory_bytes: 3660
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)







int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> cnt(51);
    ll ans = 0;
    REP(i, n){
        ll a;
        cin >> a;
        ans += a ^ k;
        for(ll j = 50; j >= 0; j--){
            if(a & (1LL << j)) cnt[j]++;
        }
    }
    for(ll i = 50; i >= 0; i--){
        if(!(k & (1LL << i))) continue;
        
        ll sum = 0;
        for(ll j = 50; j >= 0; j--){
            ll mask = 1LL << j;
            if(j > i){
                if(k & mask) sum += mask * (n - cnt[j]);
                else sum += mask * cnt[j];
            }
            else if(j == i){
                sum += mask * cnt[j];
            }
            else{
                sum += mask * max(cnt[j], n - cnt[j]);
            }
            if(j == 0 && sum == 15){
                cout << i << " " << j << endl;
            }
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main (void)
{
	int a, data[3] = {0}, i, j;

	scanf("%d %d %d", &data[0], &data[1], &data[2]);

	for (i=0; i<3-1; i++){
		for (j=i+1; j<3; j++){
			if (data[i] > data[j]){
				a = data[i];
				data[i] = data[j];
				data[j] = a;
			}
		}
	}

	printf("%d %d %d\n", data[0], data[1], data[2]);

	return 0;
}

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

int main(){
    for(int i = 0; i < 10000; i++){
        int a, b;
        char op;
        cin >> a >> op >> b;
        if(op == '+'){
            cout << a + b << endl;
        }
        if(op == '-'){
            cout << a - b << endl;
        }
        if(op == '*'){
            cout << a * b << endl;
        }
        if(op == '/'){
            cout << a / b << endl;
        }
        if(op == '?'){
            break;
        }
    }

       
}


Measured memory_bytes: 3088
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	LL N;
	cin>>N;
	LL ans = 1;
	for(LL i=1;i*i<=N;++i){
		ans = i*i;
	}
	cout<<ans<<endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lowbit(x) (x& -x)
#define oo 0x7fffffff
using namespace std;
const int MAXN=100010;
int bit[MAXN<<1],a[MAXN];
int n;
inline void add(int x,int k)
{
	for(;x<=2*n;x+=lowbit(x))
		bit[x]+=k;
}
int getsum(int x)
{
	int s=0;
	for(;x;x-=lowbit(x))
		s+=bit[x];
	return s;
}
int check(int mid)
{
	for(int i=1;i<=2*n;++i)
		bit[i]=0;
	long long tot=0,sum=0;
	add(n,1);
	for(int i=1;i<=n;++i)
		{
			sum+=mid<=a[i]?1:-1;
			tot+=getsum(sum+n);
			add(sum+n,1);
		}
	return tot>=1ll*n*(n+1)/4;
}
int main()
{
	scanf("%d",&n);
	int mmax=-oo,mmin=oo;
	for(int i=1;i<=n;++i)
		{
			scanf("%d",&a[i]);
			mmin=min(mmin,a[i]);
			mmax=max(mmax,a[i]);
		}
	int l=mmin,r=mmax;
	while(l<r)
		{
			int mid=(l+r+1)>>1;
			if(check(mid))
				l=mid;
			else
				r=mid-1;
		}
	printf("%d",l);
    return 0;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n, k;
    string s;

    cin >> n >> k >> s;

    k--;

    s[k] = s[k] +('a'-'A');

    cout << s << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int ta[100010],nt[200010],to[200010],co[200010];
void mkls(int v,int e,int *a,int *b,int *c){
  int i;
  for(i=0;i<v;i++)ta[i+1]=-1;
  for(i=0;i<e;i++){
    nt[i  ]=ta[to[i+e]=a[i]];
    nt[i+e]=ta[to[i  ]=b[i]];
    co[ta[b[i]]=i+e]=co[ta[a[i]]=i]=c[i];
  }
}
int main(){
  int n,m,d[100010],i,r,t,a[100010],b[100010],c[100010],q[100010];
  long long ev=0,od=0,ans;
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++)d[i+1]=-1;
  for(i=0;i<m;i++){
    scanf("%d %d",&a[i],&b[i]);
    c[i]=1;
  }
  mkls(n,m,a,b,c);
  q[t=0]=1;
  d[1]=0;
  for(r=1;r-t;t++){
    for(i=ta[q[t]];i+1;i=nt[i]){
      if(d[to[i]]==-1){
	d[to[i]]=d[q[t]]+1;
	q[r++]=to[i];
      }
      else if(d[q[t]]%2==d[to[i]]%2)goto END;
    }
  }
 END:;
  if(r==t){
    for(i=0;i<n;i++){
      if(d[i+1]%2)od++;
      else      ev++;
    }
    ans=od*ev;//printf("no\n");
  }
  else ans=n*(n-1LL)/2;
  printf("%lld\n",ans-m);
  return 0;
}


Measured memory_bytes: 4864
#include<stdio.h>
#define ll long long
ll b[200050] = {0};
ll c[200050] = {0};
int main(){
    ll n, i, sum = 0;
    scanf("%lld",&n);
    ll a[n];
    for(i = 0; i < n; i++)
        scanf("%lld",&a[i]);
    for(i = 0; i < n; i++)
        b[a[i]] ++;
    for(i = 1; i <= n; i++)
        c[i] = b[i] * (b[i] - 1) / 2;
    for(i = 1; i <= n; i++)
        sum += c[i];
    for(i = 0; i < n; i++){
        if(b[a[i]] == 0 || b[a[i]] == 1)
            printf("%lld\n",sum);
        else if(b[a[i]] == n)
            printf("%lld\n",(n - 2) * (n - 1) / 2);
        else{
            ll p = b[a[i]] - 1;
            ll ans = p * (p - 1) / 2;
            printf("%lld\n",sum - c[a[i]] + ans);
        }
    }
    return 0;
}

Measured memory_bytes: 6272
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void file(){
#ifndef ONLINE_JUDGE
	freopen("a_input.txt", "r", stdin);
	freopen("a_output.txt", "w", stdout);
#endif
}
void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
}
int dx[] = { 0, 0, -1, 1, 1, 1, -1, -1 };
int dy[] = { 1, -1, 0, 0, 1, -1, 1, -1 };
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
int main(){
	//file();
	fast();
	int n, k;
	cin >> n >> k;
	int a[100005];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	int mn = 1e9;
	for (int i = 0; i + k - 1 < n; i++)
		mn = min(mn, a[i + k - 1] - a[i]);
	cout << mn << endl;
}

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

int main(){
string s;
  cin>>s;
bool a=false,b=false,c=false;
if (s[0]=='a'||s[1]=='a'||s[2]=='a')
{
    /* code */
    a=true;
}
if (s[0]=='b'||s[1]=='b'||s[2]=='b')
{
    /* code */
    b=true;
}
if (s[0]=='c'||s[1]=='c'||s[2]=='c')
{
    /* code */
    c=true;
}

if (a&&b&&c)
{
    /* code */
    cout<<"Yes"<<endl;
}
else
{
    cout<<"No"<<endl;
}


}

Measured memory_bytes: 256
#!/usr/bin/env python3


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    # Failed to predict input format
    pass

if __name__ == '__main__':
    N, K = list(map(int, input().split()))
    snukes = [0] * N
    for i in range(K):
        d = input()
        A = list(map(int, input().split()))
        for a in A:
            snukes[a-1]+=1

    cnt = 0
    for snuke in snukes:
        if snuke==0:
            cnt += 1

    print(cnt)
    main()


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

int main()
{
  char a[26];
  for(int i = 0; i < 25; i++) {
        a[i + 65] = (char)(65 + i);  
    }
    int n;
    string s;
    cin >> n >> s;
    for(int i = 0; i < s.length(); i++) {
        if((int)(s[i]) + n <= 90) {
            s[i] = (char)((int)(s[i]) + n);   
        }
        else {
            s[i] = (char)((((int)s[i]) + n) - 90 + 64);    
        }
    }
    cout << s;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

		if (n == 0)
			return 0;

		int i[n], p[n], q[n], r[n], c[n];
		for (int x = 0; x < n; x++) {
			cin >> i[x] >> p[x] >> q[x] >> r[x];
			c[x] = p[x] * 4 + q[x] * 9 + r[x] * 4;
		}

		int P, Q, R, C;
		cin >> P >> Q >> R >> C;

		bool output = false;
		for (int x = 0; x < n; x++) {
			if (p[x] <= P && q[x] <= Q && r[x] <= R && c[x] <= C) {
				cout << i[x] << endl;
				output = true;
			}
		}

		if (!output)
			cout << "NA" << endl;
	}

	return 0;
}

Measured memory_bytes: 1176
import java.util.*;
import java.lang.Math;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int nump = s.length()-1;
    int count = (int)Math.pow(2,nump);
    boolean pluses[] = new boolean[nump];
    long sum = 0;
    long stack;
    int stack2;
    
    for(int i = 0;i < nump;i++) pluses[i] = false;
      
    for(int i = 0;i < count;i++){
    	stack = i;
      	for(int j = 0; j < nump && stack > 0;j++){
          if(stack%2 == 1) pluses[j] = true;
          else pluses[j] = false;
          stack /= 2;
        }
        stack = (int)s.charAt(nump) - 48;
      	stack2 = 1;
      	for(int j = 0; j < nump;j++){
          if(pluses[j]){
            stack += (int)s.charAt(nump - 1 - j) - 48;
            stack2 = 1;
          }else {
            stack += ((long)s.charAt(nump - 1 - j) - 48) * (long)Math.pow(10,stack2);
            stack2++;
          }
        }
      	sum += stack;
    }
    	
  	System.out.println(sum);

  }
}


Measured memory_bytes: 35428
#include <bits/stdc++.h>
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long ll;
void solve()
{
    ll n;
    cin>>n;
    ll ac=0,tle=0,wa=0,re=0;
    string s;
    while(n--)
    {
        cin>>s;
        if(s=="AC")
            ac++;
        else if(s=="TLE")
            tle++;
        else if(s=="WA")
            wa++;
        else
            re++;

    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;




}

int main()
{
//cout<<1900/1000<<endl;


    //#ifndef oj
    //freopen("in", "r", stdin);
    //freopen("out.txt","w",stdout);
    //#endif
    //system("cls");
    //getchar();
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }

}


Measured memory_bytes: 3628
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.util.concurrent.atomic.LongAdder;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 配列
        int[] a = new int[5];
        for(int i=0;i<5;i++){
            a[i] = sc.nextInt();
        }
        for(int i=0;i<5;i++){
            if(a[i] == 0)
        

        System.out.println(i+1);
        }
    }
}


Measured memory_bytes: 35692
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int main() {
	int a, b;
	cin >> a >> b;
	if ((a + b) % 2==0) cout << (a + b) / 2;
	else cout << (a + b) / 2 + 1;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

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

    vector<long long> R(N+1), G(N+1), B(N+1);
    for(int i=N-1; i>=0; i--){
        R[i] = R[i+1];
        if(S[i] == 'R') R[i]++;
    }
    for(int i=N-1; i>=0; i--){
        G[i] = G[i+1];
        if(S[i] == 'G') G[i]++;
    }
    for(int i=N-1; i>=0; i--){
        B[i] = B[i+1];
        if(S[i] == 'B') B[i]++;
    }
    long long ans = 0;
    for(int i=0; i<N-1; i++){
        for(int j=i+1; j<N-1; j++){
            char c1 = S[i];
            char c2 = S[j];
            if(c1 == c2) continue;
            int k = j+1;
            if((c1 == 'R' && c2 == 'G') || (c1 == 'G' && c2 == 'R')) ans += B[k];
            if((c1 == 'B' && c2 == 'G') || (c1 == 'G' && c2 == 'B')) ans += R[k];
            if((c1 == 'B' && c2 == 'R') || (c1 == 'R' && c2 == 'B')) ans += G[k];
            int kk = 2*j-i;
            if(kk >= N) continue;
            char c3 = S[kk];
            if(!(c1==c3||c2==c3)) ans--;
        }
    }
    cout << ans << endl;
    return 0;
}


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



char str[110];
bool tmp[110][110];
int main() {
	scanf("%s", str);
	int n = strlen(str);
	int ans = 110;
	for (int k = 0; k < 26; k++) {
		for (int i = 0; i < n; i++) {
			tmp[0][i] = (str[i] == 'a' + k);
		}
		
		for (int p = 0; p < n; p++) {
			bool flag = false;
			for (int i = 0; i < n - p; i++) {
				if (!tmp[p][i])flag = true;
			}
			if (!flag) {
				ans = std::min(ans, p);
				break;
			}
			for (int i = 0; i < n - p; i++) {
				tmp[p + 1][i] = tmp[p][i] || tmp[p][i + 1];
			}
		}
	}
	printf("%d", ans);

}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long N) {
  if (to_string(N).find("7") != -1) {
    cout << YES << endl;
  } else {
    cout << NO << endl;
  }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 3832
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


Graph G;
vector<int> road;
vector<int> dist;

int main() {
  int N,M; cin >>N >>M;
  G.assign(N, vector<int>());
  rep(i, M){
    int a,b; cin >>a >>b; a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  road.assign(N, -1);
  dist.assign(N, -1);
  dist[0] = 0;
  queue<int> que; que.push(0);
  while (!que.empty()){
    int v = que.front(); que.pop();
    if (v == 0) road[0] = 0;
    for (int nv : G[v]){
      if (dist[nv] != -1) continue;
      road[nv] = v+1;
      dist[nv] = dist[v] + 1;
      que.push(nv);
    }
  }
  cout <<"Yes" <<endl;
  for (int i=1; i<N; i++){
    cout <<road[i] <<endl;
  }
}


Measured memory_bytes: 10656
// g++ -std=c++14

/*

Today might be the chance to grasp the chance to let your talent bloom.
May be tomorrow, the day after, or next year...
May be even when you are 30. I'm not sure if physique has anything to do with it
but if you think that it will never come, it probably never will.

- Tooru Oikawa.

*/


#include<bits/stdc++.h>

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

#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define endl "\n"
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define LET(x, a)  __typeof(a) x(a)
#define foreach(it, v) for(LET(it, v.begin()); it != v.end(); it++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define all(c) c.begin(),c.end()
#define inf 1000000000000000001

#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename S, typename T>
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;}

template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
ll l=v.size();for(ll i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

#define int ll

string get(int no){
	string q = "";
	while(no){
		int curr = no % 10;
		q += char(curr + '0');
		no /= 10;
	}
	while((int)q.size() < 6){
		q += '0';
	}
	reverse(all(q));
	return q;
}


int32_t main(){ _
	int n, m;
	cin >> n >> m;
	vector<pair<int, int> > v, arr;
	map<pair<int, int>, string> ans;
	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		v.pb(mp(a, b));
		arr.pb(mp(a, b));
	}
	sort(all(v));
	int curr = -1;
	int cnt = 1;
	for(auto i: v){
		if(i.fi != curr){
			curr = i.fi;
			cnt = 1;
			string q = get(curr) + get(cnt);
			ans[i] = q;
		}
		else{
			cnt++;
			string q = get(curr) + get(cnt);
			ans[i] = q;
		}
	}
	for(auto i: arr){
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 17124
#include <iostream>
#include <vector>
#include <string>
#include <time.h> 
using namespace std;


int main(){
  int maxv;
  int minv;
  int temp;
  int N;
  cin >> N;
  vector<int> R(N);
  for (int i = 0; i < N; i++)
  {
    cin >> R.at(i); /* code */
  }

  maxv = R.at(1)-R.at(0);
  minv = R.at(0);
  for (int i = 1; i < N; i++)
  {
    maxv = max(maxv, R.at(i)-minv);/* code */
    minv = min(minv, R.at(i));
  }
  

  // maxv = R.at(1)-R.at(0);
  // for (int i = 0; i < R.size()-1; i++)
  // {
  //   for (int j = i+1; j < R.size(); j++)
  //   {
  //     temp = R.at(j) - R.at(i);/* code */
  //     if(temp>maxv){
  //       maxv = temp;
  //     }
  //   }
  //   /* code */
  // }
  cout << maxv << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <complex>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <string>
#include <functional>
#include <cstdlib>
#include <queue>
#include <tuple>
#include <map>
#include <cmath>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define SORT(v, n) sort(v, v+n)

using namespace std;

const double EPS =1e-9;
const long INF =999999999;
const long MINF =-999999999;

int main(){
	int i,j,r;
	int x,a,b;
	cin>>x>>a>>b;
	if(abs(a-x)>abs(b-x)) puts("B");
	else puts("A");


	return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 27 17:56:34 2019

@author: yuta
"""

n = list(map(int,input().split()))

def main(n,a,b):
    somesum = 0
    for i in range(1,(n+1)):
        x = [0]*5
        for j in range(1,5):
            x[j] = int(i/(10**j)) % 10
            x[0] = i % 10
            s = sum(x)
        if a <= s <= b:
            somesum += i
    print(somesum)
main(n[0],n[1],n[2])

Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {
	char s[100];
	int count=0;
	int i;
	scanf("%s",s);
	for(i=0;i<100;i++){
		if(i%2==0){
			if(s[i]=='L'){
				count=1;
			}
		}else{
			if(s[i]=='R'){
				count=1;
			}
			
		}
	}
	if(count==0){
		printf("Yes");
	}else{
		printf("No");
	}
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N, M;
    ll maxi = 0;
    ll ans;
    vector<ll> X, diff;
    cin >> N >> M;
    X.resize(M);
    for(ll i = 0;i < M;i++) cin >> X[i];
    sort(X.begin(), X.end());
    diff.resize(M - 1);
    for(ll i = 1;i < M;i++) diff.push_back(X[i] - X[i - 1]);
    sort(diff.begin(), diff.end(), greater<>());
    ans = X.back() - X.front();
    for(ll i = 0;i < min((ll)diff.size(), N - 1);i++) ans -= diff[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
main(){
  vector<int> v;
  for(int i=0; i<3; i++){int a; cin>>a; v.push_back(a);}
  sort(v.begin(), v.end());
  for(int i=0; i<2; i++) cout<<v[i]<<" ";
  cout<<v[2]<<"\n";
}


Measured memory_bytes: 3144
#include <stdio.h>
 
#define S 0
#define H 1
#define C 2
#define D 3
 
int main(){
  int n, num, l, i, j, c[5][16] = {};
  char m;
  scanf("%d", &n);
  for(i = 0;i < n;i++){
    scanf(" %c %d", &m, &num);
    switch(m){
    case 'S': c[S][num] = -1; break;
    case 'H': c[H][num] = -1; break;
    case 'C': c[C][num] = -1; break;
    case 'D': c[D][num] = -1; break;
    }
  }
 
  for(i = 0;i < 4;i++){
    for(j = 1;j < 14;j++){
      if(c[i][j] != -1){
    switch(i){
    case S: putchar('S'); break;
    case H: putchar('H'); break;
    case C: putchar('C'); break;
    case D: putchar('D'); break;
    }
    printf(" %d\n", j);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 600
while True:
	H,W = map(int, raw_input().split(" "))
	if H == 0 and W == 0:
		break
	else:
		for h in xrange(H):
			if h == 0 or h == H - 1:
				print "#" * W
			else:
				print "#" + ("." * (W-2)) + "#"
		print ""

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection) (collection).begin(), (collection).end()  // begin to end
#define each(e, collection) for(auto& e: collection)              // for each
#define rep(i, begin, end) for (ll i = begin; i < end; i++)       // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)      // repeat reverse
#define size(collection) ((ll) (collection).size())               // collection size

#endif

int main(void)
{
	ll n, k; cin >> n >> k;

	ll max = (n - 1) * (n - 2) / 2;
	if (max < k)
	{
		cout << -1;
		return 0;
	}

	vector<pair<ll, ll>> ans;
	ans.push_back({ 0, 1 });
	rep(i, 2, n)
		ans.push_back({ 1, i });

	rep(e, 2, n)
	{	// 0と[2, n)の頂点を接続することで最短距離2を減らしていく
		if (max == k)
			break;

		ans.push_back({ 0, e });
		max--;
	}

	rep(s, 2, n - 1)
	{	// [2, n-1)と[3, n)の頂点を接続することで最短距離2を減らしていく
		if (max == k)
			break;

		rep(e, s + 1, n)
		{
			if (max == k)
				break;

			ans.push_back({ s, e });
			max--;
		}
	}

	cout << size(ans) << endl;
	each(e, ans)
		cout << e.first + 1 << " " << e.second + 1 << endl;

	return 0;
}



Measured memory_bytes: 512
# C WA
# -*- coding: utf-8 -*-
import numpy as np
N = int(input())

first_num = 0
second_num = 0
min_diff = N
for i in range(1, int(np.sqrt(N) + 1)):
    now_diff = N // i - i
    if N % i == 0 and min_diff > now_diff:
        first_num = i
        second_num = N // i
        min_diff = now_diff
print(max(first_num + second_num - 2, 0))

Measured memory_bytes: 14456
s=int(input())
S=[]
x=0
y=0
z=0
m=0
if s==1 or s==2 or s==4:
    while True:
        if s%2==0:
            s=s//2
            x+=1
            if s==4:
                y+=1
            elif s==2:
                z+=1
            elif s==1:
                m+=1
        else:
            s=3*s+1
            x+=1
            if s==4:
                y+=1
            elif s==2:
                z+=1
            elif s==1:
                m+=1
        if y==2 or z==2 or m==2:
            break
    print(x)

else:
    while True:
        if s%2==0:
            s=s//2
            x+=1
            if s==4:
                y+=1
            elif s==2:
                z+=1
            elif s==1:
                m+=1
        else:
            s=3*s+1
            x+=1
            if s==4:
                y+=1
            elif s==2:
                z+=1
            elif s==1:
                m+=1
        if y==2 or z==2 or m==2:
            break
    print(x+1)

Measured memory_bytes: 3064
import java.util.*;

public class Main{
    public static void main(String args[]){ 

	Scanner scn = new Scanner(System.in);
	int N = scn.nextInt();
	int M = scn.nextInt();
    int C = scn.nextInt();
      
  	int[][] A = new int[N][M];
    int[] B = new int[M];
    int[] ans = new	int[N];
    int count =0;

    for(int k=0;k<M;k++){
    	B[k] = scn.nextInt();
    }
    for(int m=0;m<N;m++){
    	ans[m] +=C;
    }
      
	for(int i=0;i<N;i++){
    	for(int j=0;j<M;j++){
        A[i][j]=scn.nextInt();
        ans[i] += A[i][j]*B[j];
        }
    }
    
    for(int m=0;m<N;m++){
    	if(ans[m]>0){
        count++;
        }
    }

      System.out.print(count);

    }
}

Measured memory_bytes: 23380
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please



int A[200001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N;
	scanf("%d ", &N);
	char S[4001];
	fread(S, 1, N, stdin);

	int R[4010], G[4010], B[4010];
	int r = 0, g = 0, b = 0;
	rep(i, N) {
		if (S[i] == 'R') R[r++] = i + i;
		if (S[i] == 'G') G[g++] = i + i;
		if (S[i] == 'B') B[b++] = i + i;
	}
	R[r] = 20000;
	G[g] = 20000;
	B[b] = 20000;

	ll kotae = ll(r) * g * b;
	int maer = 0;
	int maeg = 0;
	int maeb = 0;
	int tmp;
	rep(i, N) {
		if (S[i] == 'R') {
			while (G[maeg] < i + i) maeg++;
			tmp = maeg;
			while (G[tmp] - i < N) {
				kotae -= (S[G[tmp++] - i] == 'B');
			}

			while (B[maeb] < i + i) maeb++;
			tmp = maeb;
			while (B[tmp] - i < N) {
				kotae -= (S[B[tmp++] - i] == 'G');
			}
		}
		else if (S[i] == 'G') {
			while (B[maeb] < i + i) maeb++;
			tmp = maeb;
			while (B[tmp] - i < N) {
				kotae -= (S[B[tmp++] - i] == 'R');
			}

			while (R[maer] < i + i) maer++;
			tmp = maer;
			while (R[tmp] - i < N) {
				kotae -= (S[R[tmp++] - i] == 'B');
			}
		}
		else {
			while (G[maeg] < i + i) maeg++;
			tmp = maeg;
			while (G[tmp] - i < N) {
				kotae -= (S[G[tmp++] - i] == 'R');
			}

			while (R[maer] < i + i) maer++;
			tmp = maer;
			while (R[tmp] - i < N) {
				kotae -= (S[R[tmp++] - i] == 'G');
			}
		}
	}

	printf("%lld\n", kotae);

	Would you please return 0;
}

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

typedef long long ll;
const ll nax = 2e5 + 5;

ll nums[nax];

int main() {
	ios_base::sync_with_stdio(0);
	ll n, k, ans, a;
	cin >> n >> k;

	// vector<ll> nums(n + 1, 0);
	for (int i = 1; i <= n; i++) {
		cin >> a;
		a--;
		nums[i] = nums[i - 1] + a;
	}

	ll j = 0;
	unordered_map<ll, ll> cnt;
	cnt[0]++;
	for (int i = 1; i <= n; i++) {
		ll temp = nums[i] % k;
		if (i - j + 1 > k) {
			cnt[nums[j] % k]--;
			j++;
		}
		ans += cnt[temp];
		cnt[temp]++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 10056
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>

using namespace std;
typedef pair<int, int> P;
typedef vector<P> pairs;

int main(){
    string S,T;
    int N, M, a, b, x, ans = 0;
    int ind = -1;
    pairs vi;
    cin >> S >> T;
    for(int i = 0; i < S.size() - T.size() + 1; i++){
        int j = 0;
        while(S[i+j] == T[j] || S[i+j] == '?'){
            j++;
            if(j == T.size()){ 
                ind = i;
                break;
            }
        }
    }
    if(ind != -1){
        for(int i = 0; i < T.size(); i++){
            S[i+ind] = T[i];
        }
    }

    for(int i = 0; i < S.size(); i++){
        if(S[i] == '?') S[i] = 'a';
    }

    if(ind == -1){
        cout << "UNRESTORABLE" << endl;
    }else{
        cout << S << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n; i++)
#define all(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    bool f= false;
    rep(i, s.size())for(int j=i; j<s.size(); j++){
        if(s.substr(0, i)+s.substr(j, s.size()-j) == "keyence"){
            f = true;
            break;
        }
    }
    cout << (f ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long int
#define ff first
#define ss second
#define u128 __int128
#define pb push_back

#define N 100010
#define MOD 1000000007
#define mod 998244353

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(10);

	int n;
	cin >> n;
	int no = 0;
	string s;
	cin >> s;
	for (int i = 0; i < n; ++i)
	{
		no++;
		while(i + 1 < n && s[i + 1] == s[i])
			i++;
	}
	cout << no;
	return 0;	 
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007
#define INF -99999999 
using namespace std;



int main(){
    ll N; cin >> N;
    ll x = 2;
    ll ans = 1;
    if(N == 2) ans--;
    while(true){
        if(x*x>=N-1) break;
        else{
            if((N-1)%x == 0) ans += 2;
        }
        x++;
    }
    if(x*x == N-1) ans++;
    vector<ll> n;
    x = 2;
    n.push_back(N);
    while (true){
        if(x*x>=N) break;
        else{
            if(N%x == 0){
                n.push_back(x);
                n.push_back(N/x);
            }
        }
        x++;
    }
    if(x*x==N) n.push_back(x);
    for (int i = 0; i < n.size(); i++)
    {
        ll Ncopy = N;
        while (Ncopy%n[i] == 0)
        {
            Ncopy /= n[i];
        }
        if(Ncopy%n[i] == 1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B;
    cin >> A >> B;
    int i=0;
    while(i<1000){
        if(B<=i*A+1-i){
        cout << i;
        break;
        }
        else i++;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
using namespace std;

int main() {
  int n, h, w;
  cin >> n >> h >> w;
  int ans = 0;
  for (int i = 0; i < n; i++) {
	  int a, b;
	  cin >> a >> b;
	  if (a >= h && b >= w) {
		  ans++;
		}
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace _065
{
    class Program
    {
        static void Main(string[] args)
        {
            // 065-B

            var n = int.Parse(Console.ReadLine());

            var a = new int[n];
            var f = new bool[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(Console.ReadLine());
                f[i] = false;
            }

            var light = 1;
            var count = 0;
            for (int i = 0; i < n; i++)
            {
                light = a[light-1];
                count++;
                if(light == 2)
                {
                    break;
                }
            }
            if(light == 2)
            {
                Console.WriteLine(count);
            }
            else
            {
                Console.WriteLine(-1);
            }
        }
    }
}


Measured memory_bytes: 15200
N = int(input())
A = [int(input()) for i in range(N)]
p = 1
count = 0
se = set([1])
while p!=2:
  count += 1
  p = A[p-1]
  if p == 2:
    print(count)
  elif p in se:
    print('-1')
    break
  se.add(p)

Measured memory_bytes: 13220
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;

int main(){
    int n, d[105];
    cin >> n;
    REP(i, n) cin >> d[i];

    sort(d, d+n);
    int ans = 1;
    for(int i = 1; i < n; ++i){
        if(d[i-1] != d[i]) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n, ma, mb = map(int, input().split())
abc = [list(map(int, input().split())) for _ in range(n)]

dp = [5000 for i in range(170000)]
dp[0] = 0

for a, b, c in abc:
    dpn = dp[:]
    for i in range(170000):
        nex = 401 * b + a + i
        if nex >= 170000:
            break
        dpn[nex] = min(dpn[nex], dp[i] + c)
    dp = dpn

ans = 50000

for i in range(1,170000):
    a = i % 401
    b = i // 401
    if ma * b == mb * a:
        ans = min(ans, dp[i])

if ans == 5000:
    print(-1)
else:
    print(ans)



Measured memory_bytes: 135940
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))
#define INF INT_MAX

using namespace std;
using LL=long long;

int main(){
    vector<int> A;
    int n,a;
    cin>>n;
    LP(i,n){
        cin>>a;
        A.push_back(a);
    }
    sort(A.begin(),A.end());
    for(int i=1;i<A[0];i++){
        if(n==2){
            if(A[0]%i==0&&A[1]%i==0) cout<<i<<endl;
        }
        else{
            if(A[0]%i==0&&A[1]%i==0&&A[2]%i==0) cout<<i<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3160
object Main extends App {
	val pw = new java.io.PrintWriter(System.out)

	@scala.annotation.tailrec
	def loop(start: Int, end: Int)(f: Int => Unit): Unit =
		if (start < end) {
			f(start)
			loop(start + 1, end)(f)
		}

	pw.println(
		Seq.fill(Scanner.nextInt)(Scanner.nextLong).foldLeft((0L,0L)) { case ((acc, p), ai) =>
			val updated = if (p < ai) ai else p
			(acc + updated - ai, updated)
		}._1
	)
	pw.flush()
}

object Scanner {
	private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0

	@inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
	@inline private def hasNextByte(): Boolean = if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else true
	@inline private def hasNext(): Boolean = {
		while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
		hasNextByte()
	}
	@inline private def readByte(): Byte = if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else -1

	def next(): String = {
		if(!hasNext()) ???
		val sb = new StringBuilder; var b = readByte()
		while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
		sb.toString
	}

	def nextInt(): Int = {
		val n = nextLong()
		if (n < Int.MinValue || Int.MaxValue < n) ???
		n.toInt
	}

	def nextLong(): Long = {
		if(!hasNext()) ???
		var minus = false; var b = readByte()
		if (b == '-') { minus = true; b = readByte() }

		@scala.annotation.tailrec
		def go (b: Byte, n: Long = 0): Long = if ('0' <= b && b <= '9') go(readByte(), n * 10 + b - '0') else if (minus) -n else n

		go(b)
	}

	def nextDouble(): Double = next().toDouble
}


Measured memory_bytes: 66760