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

// 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 { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    vector<int> s, t;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (a[i] < 0)
            t.push_back(a[i]);
        else
            s.push_back(a[i]);
    }

    int S = s.size();
    int T = t.size();
    bool ok = false;
    if (S > 0) {
        if (n == k)
            ok = (T % 2 == 0);
        else
            ok = true;
    } else {
        ok = (k % 2 == 0);
    }

    mint ans = 1;
    if (!ok) {
        sort(a.begin(), a.end(), [](int x, int y) {
            return abs(x) < abs(y);
        });
        rep(i, k) ans *= a[i];
    } else {
        sort(s.begin(), s.end());
        sort(t.rbegin(), t.rend());
        if (k % 2 == 1) {
            ans *= s.back();
            s.pop_back();
        }
        vector<ll> p;
        while (s.size() >= 2) {
            ll x = s.back();
            s.pop_back();
            x *= s.back();
            s.pop_back();
            p.push_back(x);
        }
        while (t.size() >= 2) {
            ll x = t.back();
            t.pop_back();
            x *= t.back();
            t.pop_back();
            p.push_back(x);
        }
        sort(p.rbegin(), p.rend());
        rep(i, k / 2) ans *= p[i];
    }

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

Measured memory_bytes: 6356
def findSumOfDigits(n):
    sum = 0
    while n > 0.1:
        sum = sum + (n % 10)
        #print(n % 10)
        n = n - (n % 10)
        n = n / 10
        #print(n)
    return sum

# スペース区切りの整数の入力
n, a, b = map(int, input().split())

ans = 0

for i in range(1,n+1):
    #print(i)
    test = findSumOfDigits(i)
    if a <= test <= b:
        ans = ans + i

print(ans)


Measured memory_bytes: 2940
import java.util.*;

public class Main {

		public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        int x = sc.nextInt();
	        boolean is360 = false;
	        int n = 1;
	        
	        while (!is360) 
	        	if (n*x % 360 != 0) {
	        		n++;
	        	}else {
	        		is360 = true;
	        	}
	        	
	        
	       
	        System.out.println(n);
	}
}

Measured memory_bytes: 35676
# -*- coding utf-8 -*-

N, A, B = map(int, input().split())

maxNum = A
if B < maxNum:
    maxNum = B

# 新聞XとYの重複がなかった場合
oneRead = A+B
if N < oneRead:
    minNum = oneRead - N
else:
    minNum = 0


print(maxNum, minNum)

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

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

  int a = 0, b = 0, c = 0;

  for(const char ch : s){
    switch (ch){
      case 'a':
        a++;
        break;
      case 'b':
        b++;
        break;
      case 'c':
        c++;
        break;
    }
  }  

  if(abs(a-b) <= 1 && abs(b-c) <= 1 && abs(c-a) <= 1){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }

  return 0;
}


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

int main() {
  int X, A, B;
  cin >> X >> A >> B;
  int overday = B - A;
  if(overday <= 0) cout << "delicious" << endl;
  else if(overday <= X) cout << "safe" << endl;
  else cout << "dangerous" << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <vector>
#include <fstream>
#include <list>
#include <string>
#include <map>
#include <numeric>
#include<unordered_map>
#include<queue>
#include <set>
#include<unordered_set>
#include <bitset>
#include <cmath>
#include <functional>
using namespace std;
int main()
{
	ifstream fin("input.txt");
	long long N, i = 0, a, ans = 0, j = 0;
	cin >> N;
	vector<long long>vec(N);
	while (i < N)
	{
		cin >> a;
		vec[i] = a;
		i++;
	}
	sort(vec.begin(), vec.end());
	i = 0;
	while (j < N && i < N)
	{
		if (vec[j] - vec[i] <= 2)
		{
			ans = max(ans, j - i + 1);
			j++;
		}
		else
			i++;
	}
	cout << ans << endl;
	
} 


Measured memory_bytes: 1024
/* ***************************************
Author        :Scau.ion
Created Time  :2016/09/11 20:42:25 UTC+8
File Name     :ion.cpp
*************************************** */

#include <bits/stdc++.h>

#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<PII>
#define X first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

using namespace std;

const int maxn=100010;

int x[maxn],y[maxn];
LL sum[20];

int main()
{
	IOS;
    LL h,w;
    int n;
    cin>>h>>w>>n;
    map<PII,bool> mp;
    for (int j=1;j<=n;++j)
    {
        cin>>x[j]>>y[j];
        mp[MP(x[j],y[j])]=1;
    }
    for (int j=1;j<=n;++j)
    {
        for (int xst=x[j]-2;xst<=x[j];++xst)
        {
            for (int yst=y[j]-2;yst<=y[j];++yst)
            {
                if (xst<1||yst<1||xst+2>h||yst+2>w) continue;
                int ss=0;
                for (int xx=0;xx<3;++xx)
                {
                    for (int yy=0;yy<3;++yy)
                    {
                        if (mp.count(MP(xst+xx,yst+yy))) ++ss;
                    }
                }
                ++sum[ss];
            }
        }
    }
    sum[0]=(h-2)*(w-2);
    for (int j=1;j<=9;++j)
    {
        sum[j]/=j;
        sum[0]-=sum[j];
    }
    for (int j=0;j<=9;++j)
    {
        cout<<sum[j]<<"\n";
    }
    cout<<flush;
	return 0;
}


Measured memory_bytes: 7424
#include<bits/stdc++.h>
#include <ext/rope>

#define min3(a,b,c)   min(a,min(b,c))
#define max3(a,b,c)   max(a,max(b,c))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max4(a,b,c,d) max(max(a,b),max(c,d))

#define count_one(a) __builtin_popcount(a)  // Returns the number of set bits(1) in a number(a). In long long use __builtin_popcountll(a)
#define parity(i)    __builtin_parity(i)  //even parity 0 and odd parity 1
#define blz(a)       __builtin_clz(a) //Returns the number of leading zeroes in a number(a)
#define btz(a)       __builtin_ctz(a) //Returns the number of trailing zeroes in a number(a)
#define gcd(a,b)     __gcd(a,b)
#define lcm(a,b)     (a*(b/gcd(a,b)))

#define pb   push_back
#define PI   M_PI
#define endl "\n"
#define sc   scanf
#define pf   printf

#define ll  long long
#define ull unsigned long long

#define W(t)            while(t--)
#define rep1(i,n)       for(int i = 0; i < n; i++)
#define rep2(a,b)       for(int i = a; i <= b; i++)
#define rep3(a,b,c)     for(int i = a; i <= b; i+=c)
#define irep(a,b,c)     for(int i = b; i >=a; i-=c)
#define repit(it,type)  for(it = type.begin(); it != type.end(); it++)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;
using namespace __gnu_cxx;

int main()
{
     IOS
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll n,d1=0,d2=0,i;
    cin>>n;

    for(i = 1; i <= sqrt(n); i++)
    {
         if(n%i==0)
         {
              d1 = i;
              d2 = n/i;
         }
    }
    cout<<d1+d2-2<<endl;

     return 0;
}



Measured memory_bytes: 3644
# solution

nim,mike=map(int,input().split())
data=input()
X=[]
Y=[0]
_s='2'
for i,s in enumerate(data):
  if _s!=s:
    _s=s
    X.append(i)
    Y.append((int(s)+1)%2)
import itertools
Y=list(itertools.accumulate(Y))
ans=[]
for i,x in enumerate(X):
  if Y[-1]-Y[i]<=mike:
    ans.append(nim-x)
    break
  else:
    if data[x]=='0':
      ans.append(X[i+2*mike]-x)
    else:
      ans.append(X[i+2*mike+1]-x)
print(max(ans))

Measured memory_bytes: 14340
#include <iostream>
#include <utility>

using namespace std;

int N,P;

int main() {
    cin>>N;
    for (int n = 0; n < N; n++) {
        pair<bool,bool> silvervine[16][16]; // first:left, second:up
        int routes[16][16] = {};
        pair<int,int> goal;
        cin>>goal.first>>goal.second>>P;
        for (int p = 0; p < P; p++) {
            int x1,y1,x2,y2;
            cin>>x1>>y1>>x2>>y2;
            if (x1 < x2) silvervine[x2][y2].first = true;
            else if (x1 > x2) silvervine[x1][y1].first = true;
            else if (y1 < y2) silvervine[x2][y2].second = true;
            else if (y1 > y2) silvervine[x1][y1].second = true;
        }

        routes[0][0] = 1;
        for (int x = 0; x <= goal.first; x++) {
            for (int y = 0; y <= goal.second; y++) {
                if (x >= 1 && silvervine[x][y].first == false) routes[x][y] += routes[x-1][y];
                if (y >= 1 && silvervine[x][y].second == false) routes[x][y] += routes[x][y-1];
            }
        }
        if (routes[goal.first][goal.second] == 0) cout<<"Miserable Hokusai!"<<endl;
        else cout<<routes[goal.first][goal.second]<<endl;
    }
}

Measured memory_bytes: 3068
def solve():
  n  = int(input())
  a = []
  for i in range(n):
    tp = list(int(i) for i in input().split())
    a.append(tp)
  a2 = []
  #warshall
  for k in range(n):
    for i in range(n):
      for j in range(n):
        if not k in [i,j]:
         if a[i][j] > a[i][k] + a[k][j]:
          #距離短縮可能
           print(-1)
           exit()
         elif a[i][j] ==  a[i][k] + a[k][j]:
          a2.append((i,j))
  for i,j in a2:
    a[i][j] = 0
  ans = 0
  for i in range(n):
    for j in range(n):
      if i < j:
        ans += a[i][j]
  print(ans)
solve()

Measured memory_bytes: 238892
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    a=[parseInt(readline()) for i in 1:5]
    k=parseInt(readline())
    ans="Yay!"
    for i in 1:5
        for j in i+1:5
            if a[j]-a[i]>k
                ans=":("
                break
            end
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 112672
// Problem : B - Distance 
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#define f first
#define s second
#define ll long long
#define vi vector<int>
#define pii pair<int, int>
#define si set<int>
#define y1 yy
#define debug if(printDebug)
using namespace std;
bool printDebug=false;
double dist(double x, double y){
	return sqrt((x*x)+(y*y));
}
int main(){
    //printDebug=true;
    /*freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);//*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);//*/
    int n, d;
    int x, y;
    cin >> n >> d;
    int ans=0;
    for(int i=0; i<n; i++){
    	cin >> x >> y;
    	if(ceil(dist(x,y))<=d) ans++;
    }
    cout << ans << "\n";
    return 0;
}


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

long ans;
string S,T;

int main(void) {

    cin >> S >> T;
    for (size_t i = 0; i < S.length(); i++) {
        if (S[i] != T[i]) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3900
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author IncubatorMan
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define long long long
typedef pair < long , long > pii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
class FDivisionOrSubstraction {
public:
    bool isPos(long n,long k){
        while (n>=k){
            if(n%k){
                n%=k;
            }
            else n/=k;
        }
        return n==1;
    }
	void solve(std::istream& in, std::ostream& out) {
	    long n;
	    in>>n;
	    set<int> ans;
	    for(long i=2;i*i<=n;i++){
	        if((n-1)%i==0){
	            ans.insert(i);
	            ans.insert((n-1)/i);
                continue;
	        }
	        if(isPos(n,i)) ans.insert(i);
	    }
	    ans.insert(n);
	    n--;
	    if(n>1) ans.insert(n);
	    out<<ans.size()<<endl;

	}
};


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


Measured memory_bytes: 256
function Main(input) {
	var inputdata = input.split(/\n|\s/);
	var sum = 0
	for(i=1;i<=inputdata[0];i++){
	    sum += 1/inputdata[i];
	}
	console.log(1/sum);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,p;cin>>n;
  string s;
  map<string,vector<P>> mp;
  rep(i,n) {
    cin>>s>>p;
    mp[s].emplace_back(p,i+1);
  }
  for(auto i:mp) {
    sort(RALL(i.second));
    for(P j:i.second) print(j.second);
  }
  return 0;
}

Measured memory_bytes: 3608
n = int(input())
s = input()

ans = 0
for i in range(10):
    a = s.find(str(i))
    if a == -1:
        continue

    for j in range(10):
        b = s.find(str(j), a+1)
        if b == -1:
            continue

        for k in range(10):
            if s.find(str(k), b+1) != -1:
                ans += 1

print(ans)


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
    {
        static void Main(string[] args)
        {
            int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int[,] b = new int[2, a[0]];
            for (int i = 0; i < a[0]; i++) {
                int[] c = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                b[0, i] = c[0];
                b[1, i] = c[1];
            }
            int[,] d = new int[2, a[1]];
            for (int i = 0; i < a[1]; i++) {
                int[] c = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                d[0, i] = c[0];
                d[1, i] = c[1];

            }
            new Calu().calu(a, b, d);
        }
        
        public class Calu{
            public void calu(int[] a, int[,] b, int[,] d){         
                for (int i = 0; i < a[0]; i++)
                {
                    int index = int.MinValue;
                    long min = long.MaxValue;
                    for (int j = 0; j < a[1]; j++) 
                    {                                                                                     
                        if (min > Math.Min(min, Math.Abs(b[0, i] - d[0, j]) + Math.Abs(b[1, i] - d[1, j])))
                        {
                            min = Math.Min(min, Math.Abs(b[0, i] - d[0, j]) + Math.Abs(b[1, i] - d[1, j]));
                            index = j + 1;
                        }
                    }
                    Console.WriteLine(index);
                }

            }
        }
    }

Measured memory_bytes: 13396
// Goods things are coming, just keep believing 
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
 
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll long long
#define hii cout << "hii" << endl
#define okay cout << "okay" << endl
// #define hey cout << "hey" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
// #define mpp make_pair
#define endl '\n'
#define ff first 
#define int long long
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()
 #define ld long double
#define INF 1000000000;
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
 
 
 
const int N = 2e5 + 5;
const int LG = 20;
const int mod = 1e9 + 7;

int arr[N];

int n, m;
int diff[N];
int pref[N];

void solve()
{
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	for(int i = 0; i < n; i++)
	{
		cout << s[i] << t[i];
	}
}
 
int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int t = 1;
	// cin >> t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 256
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

const long long MOD = 998244353;
// const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

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

  ll n;
  std::cin>>n;

  std::vector<std::vector<P>> graph(n);

  rep(i,0,n-1){
    ll u,v,w;
    std::cin>>u>>v>>w;
    u--;v--;
    graph[u].emplace_back(v,w);
    graph[v].emplace_back(u,w);
  }

  std::vector<ll> ans(n,-1);

  ans[0]=0;

  auto dfs=[&](auto f,ll now,ll par)->void{
    for(auto e:graph[now]){
      if(e.first==par)continue;
      if(e.second%2==0)ans[e.first]=ans[now];
      else ans[e.first]=ans[now]^1;
      f(f,e.first,now);
    }
  };

  dfs(dfs,0,-1);

  for(auto e:ans)std::cout<<e<<"\n";

  return 0;
}


Measured memory_bytes: 9728
import decimal,math
from collections import Counter,defaultdict
from fractions import gcd
from bisect import bisect_right,bisect_left
decimal.getcontext().prec = 10
s=raw_input()
t=raw_input()
index={}
for i in range(len(s)):
	if(index.get(s[i])):
		index[s[i]].append(i)
	else:
		index[s[i]]=[i]	
flag=0
for i in t:
	if(index.get(i)):
		continue
	else:
		flag=1
		break
if(flag==1):
	print -1
	exit()		
ans=len(s)
co=0
bad=0
arrr = [index[t[0]][0]]
# print index
# print index['t']
# print bisect_right(index['t'],3)
for i in range(1,len(t)):
	o = index[t[i]]
	l = bisect_right(o,arrr[-1])
	# print l,o
	if(l>=len(o)):
		arrr.append(o[0])
		# print 'ok'
	else:
		arrr.append(o[l])	
# print arrr		
for i in range(1,len(arrr)):
	if(arrr[i]<=arrr[i-1]):
		ans=ans+len(s)
print ans-(len(s)-arrr[-1]-1)		

Measured memory_bytes: 40344
#include<bits/stdc++.h>
#define ll long long
using namespace std;
map<ll,ll>dp;
ll mod=1e9+7;
ll f(ll x)
{
    if(x==0)return dp[0]=1;
    else if(x==1)return dp[1]=2;
    else if(dp[x])return dp[x];
    else
    {
    return dp[x]=(f(x/2)+f((x-1)/2)+f((x-2)/2))%mod;
    }
}
int main()
{
    ll x;
    cin>>x;
    cout<<f(x)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end());
using namespace std;
#define INF 2000000000
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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;

int main(){
	int n , m , x ; //n+1 このマス　初期　マスx 　0 か　nでゴール
	cin >> n >> m >> x ;
	int A[m];
	rep(i,m){
		cin>>A[i];
	}
	int leftcost = 0;
	int rightcost = 0 ;
	rep(i,m){
		if(A[i]<x){
			leftcost++;
		}
		else rightcost++;
	}
	int ans = min (leftcost,rightcost);
	cout<<ans<<endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define MOD 1000000007ULL;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	string S;
  	cin>>S;
  	
  	string divide[4]= {"dream","dreamer","erase","eraser"};
  	
  	reverse(S.begin(),S.end());
  	rep(i,4) reverse(divide[i].begin(),divide[i].end());
	  	
  	bool can=true;
  	for(int i=0;i<S.size();){
     	bool can2=false;
      	for(int j=0;j<4;j++){
         	string d =divide[j];
          	if(S.substr(i,d.size())==d){
            	can2=true;
              	i+=d.size();
            }
        }
      	if(!can2){
         	can=false;
          	break;
        }
    }
  
  	if(can) cout<<"YES"<<endl;
  	else cout<<"NO"<<endl;
}

Measured memory_bytes: 3772
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
	ll n;
	cin>>n;
	set<string> se;
	rep(i,0,n){
		string s;
		cin>>s;
		se.insert(s);
	}
	if(se.sz==3){
		cout << "Three" << endl;
	}
	else{
		cout << "Four" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
function main(input){
  input = input.trim();
  input = input.split('\n');
  const [n, k] = input[0].split(' ').map(x=>Number(x));
  const p = input[1].split(' ').map(x=>Number(x)).sort((a,b) => a-b);
  
  console.log(p.filter((x,i)=> i < k).reduce((sum, x)=> sum + x, 0));
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

vector<vector<ll>> num;

map<pair<ll, ll>, ll> dp;

ll solve_sub(ll used, ll last){
    const ll N = num.size();

    if(dp.count({used, last})){
        return dp.at({used, last});
    }

    vector<ll> not_used;
    REP(i, N){
        if(((used >> i) & 1) == 0){
            not_used.push_back(i);
        }
    }

    if(not_used.size() == 0){
        dp[{used, last}] = 0;
        return 0;
    }

    const ll cur_pos = N - not_used.size();
    ll ret = -1;
    for(ll j : not_used){
        if(num.at(j).at(cur_pos) < last){
            continue;
        }
        ll tmp = solve_sub(
            used | (1 << j),
            num.at(j).at(cur_pos)
        );
        if(tmp == -1){ continue; }
        for(ll j2 : not_used){
            tmp += (j2 < j);
        }
        if(ret == -1 || tmp < ret){
            ret = tmp;
        }
    }

    dp[{used, last}] = ret;
    return ret;
}

void solve(long long N, std::vector<long long> A, std::vector<long long> B){
    num.resize(N);
    REP(i, N){
        num.at(i).resize(N);
        REP(j, N){
            if((i - j) % 2 == 0){
                num.at(i).at(j) = A.at(i);
            }else{
                num.at(i).at(j) = B.at(i);
            }
        }
    }

    ll ans = solve_sub(0, -100);
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&B[i]);
    }
    solve(N, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 26112
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = str(ni() + 1)
m = len(n)
k = ni()


def C(n, k):
    if n < k or n < 0 or k < 0: return 0
    x = 1
    for i in range(k):
        x = x * (n-i)
        x = x // (i+1)
    return x

def p(x, k):
    y = 1
    for i in range(k):
        y *= x
    return y

e = 0
ans = 0
for i in range(m):
    d = ord(n[i]) - ord("0")
    if i == 0:
        if d > 1:
            ans += (d-1)*C(m-1, k-1)*p(9,k-1)
    else:
        ans += 9*C(m-1-i, k-1)*p(9,k-1)
        if d > 0:
            ans += (d-1)*C(m-1-i, k-1-e)*p(9,k-1-e)
            ans += C(m-1-i, k-e)*p(9,k-e)
    if d > 0:
        e += 1
print(ans)


Measured memory_bytes: 38384
S = input()
T = input()

s_len = len(S)
t_len = len(T)
ans_array = [[0] * (s_len + 1) for _ in range(t_len + 1)]

for t in range(1, t_len + 1):
    for s in range(1, s_len + 1):
        ans_array[t][s] = max(ans_array[t - 1][s], ans_array[t][s - 1])
        if T[t - 1] == S[s - 1]:
            ans_array[t][s] = ans_array[t - 1][s - 1] + 1

ans_r = []

s = s_len
t = t_len

while s > 0 and t > 0:
    if ans_array[t][s] == ans_array[t - 1][s]:
        t -= 1
    elif ans_array[t][s] == ans_array[t][s - 1]:
        s -= 1
    else:
        t -= 1
        s -= 1
        ans_r.append(S[s])

print("".join(reversed(ans_r)))




Measured memory_bytes: 113628
//#include<bits/stdc++.h>
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<cstring>
#include<utility>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
using namespace std;

#define ios ios::sync_with_stdio(false)
#define ll long long
#define pa pair<int,int>
#define mk make_pair
#define sc(n) scanf("%d",&n)
#define ss(s) scanf("%s",s)
#define fo(i, a, b) for(int i = a; i <= b; i++)
#define of(i, a, b) for(int i = a; i >= b; i--)
#define mem(a, b) memset(a, b, sizeof a)
#define copy(a,b) memcpy(a, b, sizeof b)
#define pi acos(-1)
#define in freopen("input.in", "r", stdin);
#define out freopen("output.out", "w", stdout);

const ll inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 10;
const ll M = 1e4 + 10;
const double eps = 1e-10;


ll fpow(ll a, ll b, ll p)
{
	ll res = 1;
	a %= p;
	while (b)
	{
		if (b & 1)
			res = res * a % p;
		a = a * a % p;
		b >>= 1;
	}
	return res;
}

ll C(ll n, ll m, ll p)
{
	m = min(m, n - m);
	ll res = 1;
	for (int i = 0; i < m; i++)
		res = res * (n - i) % p * fpow(i + 1, p - 2, p) % p;
	return res;
}

ll lucas(ll n, ll m, ll p)
{
	if (n < p && m < p)
		return C(n, m, p);
	return C(n % p, m % p, p) % p * lucas(n / p, m / p, p) % p;
}

int main()
{
	ll x, y;
	cin >> x >> y;
	if (2 * y - x < 0 || (2 * y - x) % 3 != 0 || 2 * x - y < 0 || (2 * x - y) % 3 != 0)
		puts("0");
	else
	{
		ll a = (2 * y - x) / 3, b = (2 * x - y) / 3;
		cout << lucas(a + b, b, mod) << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

int main()
{
    string s;
    int n;
    while(getline(cin, s))
    {
        int ans = 0;

        n = s.size();
        int cen = n / 2 ;
        REP(n/2)
        {

            if(s[i] == s[n-i-1] && (s[i] == 'i' || s[i] == 'w'))continue;
            if(s[i] == '(' && s[n-i-1] == ')') continue;
            if(s[i] == ')' && s[n-i-1] == '(') continue;
            ans += 1;
        }
        if((n % 2) == 1)
        {
            if(s[cen] == 'i' || s[cen] == 'w') ;
            else ans += 1;
        }
        
        cout << ans <<endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>

using namespace std;
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

const int maxn = 4e5;
const int MOD = 1e9 + 7;

class Modint {
public:
	long long val;

	Modint (long long _val = 0)
		: val(_val % MOD) {}

	Modint operator+ (Modint other) {
		return Modint(val + other.val);
	}

	void operator+= (Modint other) {
		val += other.val;
		val %= MOD;
	}

	Modint operator- () {
		return Modint(MOD - val);
	}

	Modint operator- (Modint other) {
		return Modint(val + MOD - other.val);
	}

	void operator-= (Modint other) {
		val += MOD - other.val;
		val %= MOD;
	}

	Modint operator* (Modint other) {
		return Modint(val * other.val);
	}

	void operator*= (Modint other) {
		val *= other.val;
		val %= MOD;
	}

	bool operator== (Modint other) {
		return val == other.val;
	}

	bool operator!= (Modint other) {
		return val != other.val;
	}
};

Modint exp (Modint a, int k) {
	if (k == 0) {
		return Modint(1);
	} else if (k % 2 == 0) {
		Modint half = exp(a, k / 2);
		return half * half;
	} else {
		return a * exp(a, k - 1);
	}
}

Modint inv (Modint a) {
	return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
	out << p.val;
	return out;
}

vector<Modint> fact(maxn + 1, 1);
vector<Modint> inv_fact(maxn + 1, 1);

void preC() {
	for (long long i = 1; i <= maxn; i++) {
		fact[i] = Modint(i) * fact[i - 1];
		inv_fact[i] = inv(i) * inv_fact[i - 1];
	}
}

Modint C(long long n, long long r) { // nCr % MOD
	if (n < r) return 0;
	return fact[n] * inv_fact[r] * inv_fact[n - r];
}


int main() {

	preC();
	long long  n, k; cin >> n >> k;
	Modint ans = 0;
	for (int i = 0; i <= min(k, n - 1); i++) {
		ans += C(n, i) * C(n - 1, i);
	}
	cout << ans;

	return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int a;cin >> a;
  string s; cin >> s;
  if(a >= 3200)cout << s << endl;
  else cout << "red" << endl;
  return 0;
}


Measured memory_bytes: 3572
import java.io.*;

public class Main{
    public static void main(String []args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            String line = reader.readLine();
            int t = Integer.parseInt(line);
            int h = t / 3600;
            int m = t % 3600 / 60;
            int s = t % 3600 % 60;
            System.out.println(h+":"+m+":"+s);

            
        }
        catch(IOException e){
            System.out.println(e);
        }
    }
}


Measured memory_bytes: 24184
import sys
n = int(input())

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

count = 0
cost = 0
temp = 0
temp2 = 0
ans1 = 0
ans2 = 0
nokori = 0
sum = sum(a)
half = int(sum/2)
if(sum%2 == 1):
  cost = 1

for i in (a):
  count += i
  if(count == half):
    print(cost)
    sys.exit()
  elif(count > half):
    temp = count
    nokori = sum - temp
    ans1 = temp - nokori
    #print(temp,nokori,ans1)
    break
    
#print(ans1)

a.reverse()
count = 0
#print(half)
for j in (a):
  count += j
  if(count > half):
    temp2 = count
    nokori = sum - temp2
    ans2 = temp2 - nokori
    if(ans1 > ans2):
      print(ans2)
    else:
      print(ans1)
    break

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

int main(){
  int n;
  int a[4];

  cin >> n;
  for(int i=0;i<4;i++){cin >> a[i]; a[i]--;}

  int m = 10000000;
  for(int i=1;i<n;i++){
    m = std::min(m,abs(a[0]/i-a[1]/i)+abs(a[0]%i-a[1]%i)+abs(a[2]/i-a[3]/i)+abs(a[2]%i-a[3]%i));
  }
  cout << m << endl;
}

Measured memory_bytes: 1160
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    string S;
    cin >> S;
    // int num = stoi(S);
    bitset<100000> A(S), P1(0), P2(0);
    for(int i = 0; i < S.size(); i++){
        if(i % 2 == 0){
            P1.set(i);
        }
    }
    P2 = ~P1;
    for(int i = S.size(); i < 100000; i++){
        P2.reset(i);
    }
    P1 ^= A;
    P2 ^= A;
    // cout << A << endl;
    // cout << P2 << endl;
    cout << min(P1.count(), P2.count()) << endl;

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;

int main()
{
   int n,k;cin >> n >> k;
   vector<int> a(n);
   map<int,int>  mp;
   rep(i,n)
   {
      cin >> a[i];
   }
   sort(ALL(a));
   int ans=INT_MAX;

   rep(i,n-k+1)
   {
      //cout<<a[i+k-1]-a[i]<<endl;
      ans = min (ans,a[i+k-1]-a[i]);
   }
   cout<<ans<<endl;

   return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<vector<int>> V(N, vector<int>(26));
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    for (int j = 0; j < S.size(); j++) {
      V.at(i).at(S.at(j) - 'a')++;
    }
  }
  for (int j = 0; j < 26; j++) {
    int x = 100;
    for (int i = 0; i < N; i++) {
      x = min(x, V.at(i).at(j));
    }
    for (int k = 0; k < x; k++) cout << (char)('a' + j);
  }
  cout << endl;
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"

int main()
{
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	for (int i = 0; i < n; ++i)
	{
		int temp;
		std::cin >> temp;
		while ((temp & 1) == 0)
		{
			temp /= 2;
			a[i]++;
		}
	}
	std::cout << *std::min_element(a.begin(), a.end()) << '\n';
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    string s;
    cin >> s;
    int K;
    cin >> K;
    int len_s = s.size();
    vector<string> vec(0);
    if (len_s == 1){
        cout << s << endl;
    }
    if (len_s == 2){
        vec.push_back(s.substr(0,1));
        vec.push_back(s.substr(1,1));
        vec.push_back(s.substr(0,2));
        sort(all(vec));
    }
    if (len_s == 3){
        rep(i,3){
            vec.push_back(s.substr(i,1));
        }
        vec.push_back(s.substr(0,2));
        vec.push_back(s.substr(1,2));
        vec.push_back(s.substr(0,3));
        sort(all(vec));
    }
    if (len_s == 4){
        rep(i,4){
            vec.push_back(s.substr(i,1));
        }
        rep(i,3){
            vec.push_back(s.substr(i,2));
        }
        vec.push_back(s.substr(0,3));
        vec.push_back(s.substr(1,3));
        vec.push_back(s.substr(0,4));
        sort(all(vec));
    }
    if (len_s >= 5){
        rep(i,len_s){
            vec.push_back(s.substr(i,1));
        }
        rep(i,len_s - 1){
            vec.push_back(s.substr(i,2));
        }
        rep(i,len_s - 2){
            vec.push_back(s.substr(i,3));
        }
        rep(i,len_s - 3){
            vec.push_back(s.substr(i,4));
        }
        rep(i,len_s - 4){
            vec.push_back(s.substr(i,5));
        }
        sort(all(vec));
    }
    if (len_s != 1){
        int count = 1;
        int len_vec = vec.size();
        vec.push_back("a");
        rep(i,len_vec){
            if (count == K){
                cout << vec[i] << endl;
                break;
            }
            if (vec[i] != vec[i + 1]){
                count++;
            }
        }
    }
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

bool kaibun(string s){
	bool ret=true;
	ll n=s.size();
	rep(i,n){
		ret&=(s[i]==s[n-1-i]);
	}
	return ret;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	ll n=s.size();
	Yn(kaibun(s.substr(0,n))&&kaibun(s.substr(0,n/2))&&kaibun(s.substr(n/2+1,n/2)));
}


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

using namespace std;

int main(int qtd, char* nome[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, x;
    cin >> n >> x;
    int l[n];
    int ans = 0;
    for (int i = 0; i < n; i++){
        cin >> l[i];
    }
    int c = 0;
    int bounce[n+1] = {0};
    for (int i = 0; i < n; i++){
        c += l[i];
        bounce[i] = c;
    }
    for (int i = 0; i <= n; i++){
        if(bounce[i] <= x)
            ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/*

Author : AllKilled
Date   : 201911166

Contest: AtCoder Beginner Contest 145.
Problem: Task D.
Result :

*/
#include<bits/stdc++.h>
using namespace std;

typedef long long LL;

const LL MOD = 1e9+7;
const LL MAXN = 1e6+7;

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

LL x, y, ans;

int check(LL a, LL b){
    LL sum = a + b;
    if (sum % 3) return 0;
    LL l = sum / 3;
    LL r = l + l;
    if (a < l || a > r || b < l || b > r) return 0;
    return 1;
}

LL qp(LL a, LL b, LL mod) {
    LL res = 1;
    for (; b; b >>= 1) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

LL getfac(LL &fn, LL n, LL mod) {
    fn = 1;
    for (LL i = 1; i <= n; ++i) fn = fn * i % mod;
}

LL nCr(LL n, LL r, LL mod) {
    LL fn, fr, fnsr;
    getfac(fn, n, mod);
    getfac(fr, r, mod);
    getfac(fnsr, n - r, mod);
    LL res = fn * qp(fr * fnsr % mod, mod - 2, mod) % mod;
    return res;
}

void get(LL a, LL b){
    LL n = (a + b) / 3;
    LL r = a - n;
    ans = nCr(n, r, MOD);
}

int main()
{
    cin >> x >> y;
    if (check(x, y)) get(x, y);
    cout << ans;
    return 0;
}


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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int MAX = 1002;
int n,m;
string res[MAX];
int a,b;
void addpoz(int i,int j){
  debug("poz",i,j);
  if(a){
    a--;
    res[i][j] = '<';
    res[i][j+1] = '>';
  }
}
void addpion(int i,int j){
  debug("pion",i,j);
  if(b){
    b--;
    res[i][j] = '^';
    res[i+1][j] = 'v';
  } 
}
void add(int i,int j){
  if(a){
    addpoz(i,j);
    addpoz(i+1,j);
  }else{
    addpion(i,j);
    addpion(i,j+1);
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n >> m >> a >> b;
  R(i,n){
    res[i].resize(m,'.');
  }
  if(n & 1){
    R(i,m/2){
      addpoz(n-1,i*2);
    }
  }
  if(m & 1){
    R(i,n/2){
      addpion(n - i*2 - 2,m-1);
    }
  }
  bool xxx = 0;
  if((n & 1) && (m & 1) && (a&1) && (b&1) && (n > 1) && (m > 1)){
    xxx = 1;
    addpoz(0,m-2);
    addpion(0,m-3);
  }
  R(i,n/2)R(j,m/2){
    if(xxx && i == 0 && j == m/2 - 1)continue;
    add(i*2,j*2);
  }
  if(a || b){
    cout << "NO\n";
  }else{
    cout << "YES\n";
    R(i,n)
      cout << res[i] << "\n";
  }
}


Measured memory_bytes: 2304
import java.math.*;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int M = sc.nextInt();
    int[] a = new int[A];
    int[] b = new int[B];
    int[] x = new int[M];
    int[] y = new int[M];
    int[] c = new int[M];
    for (int i = 0; i < A; i++) a[i] = sc.nextInt();
    for (int i = 0; i < B; i++) b[i] = sc.nextInt();
    for (int i = 0; i < M; i++) {
      x[i] = sc.nextInt();
      y[i] = sc.nextInt();
      c[i] = sc.nextInt();
    }
    sc.close();

    int minA = Integer.MAX_VALUE;
    for (int p : a)
      minA = Math.min(minA, p);
    int minB = Integer.MAX_VALUE;
    for (int p : b)
      minB = Math.min(minB, p);

    int ans = Integer.MAX_VALUE;
    for (int i = 0; i < M; i++) {
      int p = a[x[i] - 1] + b[y[i] - 1] - c[i];
      ans = Math.min(ans,p);
    }

    ans = Math.min(ans, minA + minB);
    System.out.println(ans);
  }
}


Measured memory_bytes: 155704
function main()
  
  c = zeros(3)
  c_sum = 0
  check = 0
  for i in 1:3
    c = parse.(Int, split(readline()))
    c_sum += sum(c)
    check += c[i]
  end

  check *= 3
  
  if c_sum == check
    println("Yes")
  else
    println("No")
  end
  
end

main()

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;

const int maxn = 2e5 + 5;

ll sum = 0;
map<ll, int> ma;
int N;

signed main(void)
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  if (fopen("A.INP", "r")){
    freopen("A.INP", "r", stdin);
    freopen("A.OUT", "w", stdout);
  }
  cin >> N;
  ma[0] = 1;
  ll res = 0;
  for (int i = 1; i <= N; ++i){
    int x; cin >> x;
    sum += x;
    res += ma[sum];
    ma[sum]++;
  }
  cout << res;
}


Measured memory_bytes: 12800