akhauriyash/Code-Regression huggingface dataset:
// Problem: B - Substring
// Contest: AtCoder - AtCoder Beginner Contest 177
// URL: https://atcoder.jp/contests/abc177/tasks/abc177_b
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

#define int long long
#define endl "\n"
#define deb(x) cout << #x << " -> " << x << endl;
#define print(x)                         \
    for (auto x_ : x) cout << x_ << " "; \
    cout << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define mod 1000000007  // 1e9 + 7
#define prec(x, y) fixed << setprecision(y) << x

void solve() {
    string s, t;
    cin >> s >> t;
    int s_l = s.length(), t_l = t.length();
    int ans = INT_MAX;
    for (int i = 0; i <= s_l - t_l; ++i) {
        string check = s.substr(i, i + t_l);
        int res = 0;
        for (int k = 0; k < t_l; ++k) {
            res += (check[k] != t[k]);
        }
        ans = min(ans, res);
    }
    cout << ans << endl;
}

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

    int tc = 1;
    // cin >> tc;
    while (tc--) {
        solve();
    }
}

Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=acos(-1);
const ll INF = 1LL<<62;
const ll MINF = -(1LL<<62);

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)


int main() {
	IO;
	ll x;
	cin>>x;
	//~ set<ll> jo;
	
	//~ for(ll x=1;x<=1000;++x) {
		
		//~ for(ll a=1;a<=x;++a) {
			//~ ll masik=a*a*a*a*a-x;
			//~ ll val=pow(masik,1.0/5);
			//~ while(val*val*val*val*val<masik) val++;
			//~ while(val*val*val*val*val>masik) --val;
			//~ if(a*a*a*a*a-masik*masik*masik*masik*masik==x) {
				//~ cout<<a<<" "<<masik<<" ez\n";
				//~ jo.insert(x);
				//~ break ;
			//~ }
		//~ }
	//~ }
	//~ for(auto i:jo) cerr<<i<<"\n";
	for(ll d=1;d*d<=x;++d) {
		for(ll a=1;a*a*a*a<=x;++a) {
			ll b=a-d;
			if(a*a*a*a*a-b*b*b*b*b==x) {
				cout<<a<<" "<<b<<"\n";
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3636
import numpy as np
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
M = [list(map(int, input().split()))for _ in range(N)]
count = 0
for i in M:
    if np.dot(np.array(B),np.array(i))+ C >0:
        count += 1
print(count)


Measured memory_bytes: 12428
#include<bits/stdc++.h>
#define dbug printf("I am here\n");
#define Fast ios_base::sync_with_stdio(false); cin.tie(0);
#define vs              v.size()
#define sot(v)        sort(v.begin(),v.end())
#define rev(v)        reverse(v.begin(),v.end())
#define ii                pair<int,int>
#define ll                long long
#define ull              unsigned long long
#define pb              push_back
#define mpp          make_pair
#define Okay         0
#define pi               3.14159

static ll int inf = 1e9;
const int cont = 10e5+10;
using namespace std;


void solve(){
    int m,n;
    cin>>n>>m;
    vector<string>v(n);
    for(int i=0; i<n;i++)cin>>v[i];
    sot(v);
   for(int i=0; i<n; i++){
    cout<<v[i];
   }
   cout<<endl;
}

int main(){

solve();

	return Okay;
}


Measured memory_bytes: 3616
import queue
import copy
import math
from collections import deque
import bisect
from decimal import Decimal

# そのまま入力文字列の入力
x = Decimal(input())

ans = 0
m = 100
while True:
    m = math.floor(m * 1.01)
    ans += 1
    if x <= m:
        break

print(ans)

Measured memory_bytes: 10424
#include <bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353
#define MEM_SIZE 101010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template <typename T>
void DEBUG(T e)
{
  if (DEBUG_OUT == false)
    return;
  std::cout << e << " ";
}
template <typename T>
void DEBUG(const std::vector<T> &v)
{
  if (DEBUG_OUT == false)
    return;
  for (const auto &e : v)
  {
    std::cout << e << " ";
  }
  std::cout << std::endl;
}
template <typename T>
void DEBUG(const std::vector<std::vector<T>> &vv)
{
  if (DEBUG_OUT == false)
    return;
  for (const auto &v : vv)
  {
    DEBUG(v);
  }
}
template <class T, class... Ts>
void DEBUG(T d, Ts... e)
{
  if (DEBUG_OUT == false)
    return;
  DEBUG(d);
  DEBUG(e...);
}
template <class T>
void corner(bool flg, T hoge)
{
  if (flg)
  {
    cout << hoge << endl;
    abort();
  }
}
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); }

//BELOW
//solve

//BELOW
struct UnionFind
{
  int num;
  vector<int> rs, ps;
  UnionFind() {}
  UnionFind(int n) : num(n), rs(n, 1), ps(n, 0) { iota(ps.begin(), ps.end(), 0); }
  int find(int x)
  {
    return (x == ps[x] ? x : ps[x] = find(ps[x]));
  }
  bool same(int x, int y)
  {
    return find(x) == find(y);
  }
  void unite(int x, int y)
  {
    x = find(x);
    y = find(y);
    if (x == y)
      return;
    if (rs[x] < rs[y])
      swap(x, y);
    rs[x] += rs[y];
    ps[y] = x;
    num--;
  }
  int size(int x)
  {
    return rs[find(x)];
  }
  int count() const
  {
    return num;
  }
};
void solve(void)
{
  int n, m;
  cin >> n >> m;
  vector<vector<int>> graph(n);
  UnionFind uf(n);
  for (int i = 0; i < m; i++)
  {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    uf.unite(a, b);
  }
  for (int i = 0; i < n; i++)
  {
    uf.find(i);
  }
  int res = 1;
  for (int i = 0; i < n; i++)
  {
    chmax(res, uf.size(i));
  }
  cout << res << endl;

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 11108
import numpy as np

s = np.array([ord(x) for x in input()])
t = np.array([ord(x) for x in input()])

tlen = len(t)
res = tlen
for i in range(len(s)-tlen+1):
    tmp = s[i:i+tlen] - t
    c = tlen - list(tmp).count(0)
    res = min(res, c)
    if res == 0:
        break
print(res)

Measured memory_bytes: 27212
n = int(input())
a = list(map(int,input().split()))
jiyuu = 0
cnt = [0] * 8
for i in a:
    if i >= 3200:
        jiyuu += 1
    else:
        cnt[i // 400] += 1
p = 0
for i in cnt:
    p += (i > 0)
print(max(1, p), max(1, p + jiyuu))


Measured memory_bytes: 3060
#include <iostream>
#include<string>
using namespace std;
int main(void){
 char c;
 cin >> c;
 if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
     cout << "vowel" << endl;
 }
 else{
     cout << "consonant" << endl;
 }
}


Measured memory_bytes: 256
from collections import deque
#空のリスト 作った後は普通にappend使えばOK
n,m,k=map(int,input().split())
 
tomodati=[[] for i in range(n+1)]
 
group=[0]*(n+1)

group_cnt=[0]*(n+1)
 
block=[0]*(n+1)
 
tansaku=deque()
 
for i in range(m):
    a,b=map(int,input().split())
    tomodati[a].append(b)
    tomodati[b].append(a)
 
num=1
 
for i in range(1,n+1):
    if group[i]==0:
        tansaku.append(i)
        group[i]=num
        group_cnt[num]+=1
    else:
        continue
    while len(tansaku)>0:
        for j in tomodati[tansaku[0]]:
            if group[j]==0:
                group[j]=num
                group_cnt[num]+=1
                tansaku.append(j)
        tansaku.popleft()
    num+=1
 
for i in range(k):
    c,d=map(int,input().split())
    if group[c]==group[d]:
        block[c]+=1
        block[d]+=1
 
ans=[]
 
for i in range(1,n+1):
    ans.append(group_cnt[group[i]]-len(tomodati[i])-block[i]-1)
 
print(*ans)

Measured memory_bytes: 106244
//17:30
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>

using namespace std;
typedef long long ll;
ll max(ll a, ll b){return(a>b)?a:b;}
ll min(ll a, ll b){return(a<b)?a:b;}
ll abss(ll a){return(a<0)?-a:a;}

char S[2*100000+1];
char T[2*100000+1];

char mp1[26];  //s->t
char mp2[26];

int main(){
        scanf("%s",S);
        scanf("%s",T);

        map<char, char> mp1,mp2;
        for(int i = 0; i < 26; i++){
                mp1[i]=mp2[i]=0;
        }

        int lenS=strlen(S);
        int lenT=strlen(T);
        for(int i = 0; i < lenS; i++){
                if(mp1[S[i]] == 0){
                        mp1[S[i]] = T[i];
                }else{
                        if(mp1[S[i]] != T[i]){
                                puts("No");
                                return 0;
                        }
                }
        }
        for(int i = 0; i < lenT; i++){
                if(mp2[T[i]] == 0){
                        mp2[T[i]] = S[i];
                        //printf("added T[i]=%c, mp2[T[i]]=%c\n",T[i],mp2[T[i]]);
                }else{
                        //printf("T[i]=%c, mp2[T[i]=%c\n",T[i],mp2[T[i]]);
                        if(mp2[T[i]] != S[i]){
                                puts("No");
                                return 0;
                        }
                }
        }
        puts("Yes");

}

Measured memory_bytes: 768
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

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

    long long ans = 0l;
    rrep (i, 1, N) {
        if (i % 3 == 0 and i % 5 == 0) continue;
        else if (i % 3 == 0 or i % 5 == 0) continue;
        else ans += i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3596
#include <vector>
#include <complex>
#include <cstdio>
#include <cassert>
#include <cmath>
using namespace std;

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

const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

bool intersectLL(const L &l, const L &m) {
  return abs(cross(l[1]-l[0], m[1]-m[0])) > EPS || // non-parallel
         abs(cross(l[1]-l[0], m[0]-l[0])) < EPS;   // same line
}
bool intersectLS(const L &l, const L &s) {
  return cross(l[1]-l[0], s[0]-l[0])*       // s[0] is left of l
         cross(l[1]-l[0], s[1]-l[0]) < EPS; // s[1] is right of l
}
bool intersectLP(const L &l, const P &p) {
  return abs(cross(l[1]-p, l[0]-p)) < EPS;
}
bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
bool intersectSP(const L &s, const P &p) {
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}

P projection(const L &l, const P &p) {
  double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
  return l[0] + t*(l[0]-l[1]);
}
P reflection(const L &l, const P &p) {
  return p + (projection(l, p) - p)*2.0;
}
double distanceLP(const L &l, const P &p) {
  return abs(p - projection(l, p));
}
double distanceLL(const L &l, const L &m) {
  return intersectLL(l, m) ? 0 : distanceLP(l, m[0]);
}
double distanceLS(const L &l, const L &s) {
  if (intersectLS(l, s)) return 0;
  return min(distanceLP(l, s[0]), distanceLP(l, s[1]));
}
double distanceSP(const L &s, const P &p) {
  const P r = projection(s, p);
  if (intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0] - p), abs(s[1] - p));
}
double distanceSS(const L &s, const L &t) {
  if (intersectSS(s, t)) return 0;
  return min(min(distanceSP(s, t[0]), distanceSP(s, t[1])),
             min(distanceSP(t, s[0]), distanceSP(t, s[1])));
}

int main(){
	int T,x1,y1,x2,y2;
	for(scanf("%d",&T);T--;){
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		L A(P(x1,y1),P(x2,y2));
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		L B(P(x1,y1),P(x2,y2));
		printf("%.9f\n",distanceSS(A,B));
	}
}

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

int main()
{
    int n,i,x,kount=0;
    cin>>n;
    vector<int>vec;
    vector<int>sorted;


    for(i=0;i<n;i++)
    {
        cin>>x;
        vec.push_back(x);
        sorted.push_back(x);
    }

    sort(sorted.begin(),sorted.end());

    for(i=0;i<vec.size();i++)
    {
        if(sorted[i]!=vec[i])kount++;
    }
   // cout<<kount<<endl;
    if(kount==2||kount==0)cout<<"YES";
    else cout<<"NO";

    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ll = long long;
using ull = unsigned long long;

int main(int argc, char* argv[]) {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  /* */
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  int h = ty - sy;
  int w = tx - sx;

  for (int i = 0; i < h; ++i) putchar('U');
  for (int i = 0; i < w; ++i) putchar('R');
  for (int i = 0; i < h; ++i) putchar('D');
  for (int i = 0; i < w; ++i) putchar('L');
  putchar('L');
  for (int i = 0; i < h + 1; ++i) putchar('U');
  for (int i = 0; i < w + 1; ++i) putchar('R');
  putchar('D');
  putchar('R');
  for (int i = 0; i < h + 1; ++i) putchar('D');
  for (int i = 0; i < w + 1; ++i) putchar('L');
  putchar('U');
  putchar('\n');
  /* */

  return EXIT_SUCCESS;
}


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

const int MAX_N=202020;
ll inv[MAX_N+1], fact[MAX_N+1], ifact[MAX_N+1];

ll comb(int n, int k){
  if(n<k) return 0;
  return fact[n]*ifact[k]%MOD*ifact[n-k]%MOD;
}

void prepare(){
  inv[1]=fact[0]=fact[1]=ifact[0]=ifact[1]=1LL;
  for(int i=2;i<=MAX_N;i++){
    inv[i]=inv[MOD%i]*(MOD-MOD/i)%MOD;
    fact[i]=fact[i-1]*i%MOD;
    ifact[i]=ifact[i-1]*inv[i]%MOD;
  }
}


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  prepare();
  int N,K; cin>>N>>K;
  ll ans=1+1LL*N*(N-1);
  for(int i=2;i<=min(N-1,K);i++){
    (ans+=comb(N,i)*comb(N-1,i)%MOD)%=MOD;
  }
  cout<<ans<<endl;
  return 0;
}

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

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string[] ss = { "SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN", };
            for (int i = 0; i < ss.Length; i++)
            {
                if (s == ss[i])
                {
                    Console.WriteLine(i+1);
                }
            }
        }
    }
}


Measured memory_bytes: 11092
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = 998244353LL;
const double pi = acos(-1.0);

int main() {
	int n, k; string s;
	cin >> n >> s >> k;
	rep(i, n)s[i] = s[i] == s[k - 1] ? s[i] : '*';
	Cout(s);
}

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

using namespace std;

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


int main()
{
  string s;
  cin >> s;
  for (int i = 0; i < 5; i++){
    cout << s[i];
  }
  cout << " ";
  for (int i = 6; i < 13; i++){
    cout << s[i];
  }
  cout << " ";
  for (int i = 14; i < 19; i++){
    cout << s[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
string s;
int ans=0;
signed main(){
  while(cin >> s && s!="0"){
    ans=0;
    for(int i=0;i<s.size();i++){
      ans+=s[i]-'0';
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3148
_,m=map(int,input().split())
work=sorted([tuple(map(int,input().split()))for k in range(_)],key=lambda x:(-x[0],x[1]))
from heapq import heapify, heappop, heappush
now=[]
#print(work)
ans=0
for i in range(1,m+1):
    while work and work[-1][0]<=i:
        a,b=work.pop()
        heappush(now,-b)
        #print(a,b)
    
    if now:
        ans-=heappop(now)
    #print(i,ans)
print(ans)

Measured memory_bytes: 34036
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);++i)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;--i)
#define FOR(i,s,n) for(int i = s;i < (int)n;++i)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;--i)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline void out(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
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;}
constexpr long long INF = 1e18;

signed main(){
	int N;
	cin >> N;
	map<string,int>mp;
	int ma = 0;
	REP(i,N){
		string s;
		cin >> s;
		mp[s]++;
		CHMAX(ma,mp[s]);
	}
	vector<string>v;
	for(auto e:mp){
		if(e.second==ma)v.push_back(e.first);
	}
	sort(ALL(v));
	for(auto e:v)out(e);
}

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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(abs(a-c) <= d || (abs(b-a) <= d && abs(b-c) <= d)){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#include <map>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
#define rn(i,n) for(int i=1;i<=n;i++)



int main (){
  string s;
  cin>>s;
  char ch='s';
  int cnt=0;
  r(i,s.size()){
      if(ch!=s.at(i)){ch=s.at(i);cnt++;}
      else continue;
  }
  cout<<cnt-1<<endl;

  return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <queue>
#include <cmath>
#include <iomanip>
#include <vector>
using namespace std;
typedef long long ll;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
#define MAX_V 100001
#define MOD 1000000007

int main(){
    int k;cin>>k;
    string s;cin>>s;
    if(s.size()<=k) cout<<s<<endl;
    else{
        for(int i=0;i<k;i++){
            cout<<s[i];
        }
        cout<<"..."<<endl;
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N; 
    cin >> N;
    vector<int> x(N);
    for (int i=0; i<N; i++){
        cin >> x.at(i);
    }
    int mi=100000000;
    for(int i=0; i<105; i++){
        int S=0;
        for(int j=0; j<N; j++){
            S += pow(x.at(j)-i,2);
        }
        mi = min(S, mi);
    }
    cout << mi << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
   int n;
   cin >> n;
   cout << setprecision(9)<<(double) ((n-(double)(n/2)) / n) << endl;
}



Measured memory_bytes: 256
n = int(input())
m = []
divisors = []
for i in range(1, int(n**0.5)+1):
    if n % i == 0:
        divisors.append(i)
        m.append(n//i)

for i in range(len(divisors)):
    if m[i]- divisors[i] < 2:
        m[i] = 1 


print(sum(m)-len(m))

Measured memory_bytes: 3296
from collections import Counter

n = int(input())
s = input()

c = Counter(s)

dbl = c["R"] * c["B"] * c["G"]
for l in range(1, n):
    for i in range(n):
        j = i + l
        k = j + l
        if j < n and k < n:
            if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
                dbl -= 1

print(dbl)


Measured memory_bytes: 68736
#include <iostream>
#include <algorithm>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <list>
#include <array>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <random>
#include <chrono>
#include <fstream>

#define PI 3.14159265359
#define mt make_tuple
#define mp make_pair
#define pii pair <int, int>
#define pll pair <long long, long long>
#define all(x) (x).begin(), (x).end()

//mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());

using namespace std;

const int MOD = 1000000007;

int main()
{
	long long N;
	cin >> N;
	long long answer = 1;
	for (int i = 1; i <= N; ++i)
		answer = 1LL * answer * 10 % MOD;
	long long sum = 2;
	for (int i = 1; i <= N; ++i)
		sum = 1LL * sum * 9 % MOD;
	long long prod = 1;
	for (int i = 1; i <= N; ++i)
		prod = 1LL * prod * 8 % MOD;
	answer = (1LL * answer - sum + prod + MOD) % MOD;
	cout << answer << "\n";
	return 0;
}


Measured memory_bytes: 3132
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

const INF: i64 = 1000000000;

fn main() {
   input! {
      n: usize,
      m: usize,
      rn: usize,
      r: [usize; rn],
      abc: [(usize, usize, i64); m],
   }
   let mut dp = vec![vec![INF; n]; n];
   for i in 0..n {
      dp[i][i] = 0;
   }
   for (a, b, c) in abc {
      dp[a - 1][b - 1] = c;
      dp[b - 1][a - 1] = c;
   }
   for k in 0..n {
      for i in 0..n {
         for j in 0..n {
            dp[i][j] = std::cmp::min(dp[i][j], dp[i][k] + dp[k][j]);
         }
      }
   }

   let mut ans = INF;
   let mut r: Vec<_> = r.iter().map(|&r| r - 1).collect();
   r.sort();
   loop {
      let mut a = 0;
      for i in 0..rn - 1 {
         a += dp[r[i]][r[i + 1]];
      }
      ans = std::cmp::min(ans, a);
      if !r.next_permutation() {
         break;
      }
   }
   println!("{}", ans);
}

pub trait LexicalPermutation {
   fn next_permutation(&mut self) -> bool;
   fn prev_permutation(&mut self) -> bool;
}
impl<T> LexicalPermutation for [T]
where
   T: Ord,
{
   fn next_permutation(&mut self) -> bool {
      if self.len() < 2 {
         return false;
      }
      let mut i = self.len() - 1;
      while i > 0 && self[i - 1] >= self[i] {
         i -= 1;
      }
      if i == 0 {
         return false;
      }
      let mut j = self.len() - 1;
      while j >= i && self[j] <= self[i - 1] {
         j -= 1;
      }
      self.swap(j, i - 1);
      self[i..].reverse();
      true
   }
   fn prev_permutation(&mut self) -> bool {
      if self.len() < 2 {
         return false;
      }
      let mut i = self.len() - 1;
      while i > 0 && self[i - 1] <= self[i] {
         i -= 1;
      }
      if i == 0 {
         return false;
      }
      self[i..].reverse();
      let mut j = self.len() - 1;
      while j >= i && self[j - 1] < self[i - 1] {
         j -= 1;
      }
      self.swap(i - 1, j);
      true
   }
}


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

int main(){
    int n, x;
    int count = 1, point = 0;

    cin >> n >> x;

    vector<int> line(n);
    for (int i = 0; i < n; i++){
        cin >> line.at(i);
    }

    for(int i=0; i<n; i++){
       if(point+line[i] <= x){
           count++;
           point += line[i];
       }
       else{
           break;
       }
    }

    cout << count << endl;
    return 0;    
}

Measured memory_bytes: 3632
n = int(input())
xy = []
for _ in range(n):
  xy.append(list(map(int,input().split())))
#print(xy)
xyxy = []
for i in range(n):
  tmp = []
  for j in range(n):
    tmp.append((((xy[i][0]-xy[j][0])**2)+(xy[i][1]-xy[j][1])**2)**.5)
  xyxy.append(tmp)
ans = 0
for i in range(n):
  for j in range(n):
    if i < j:
      ans += xyxy[i][j]
ans *= 2/n
print(ans)

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<pair<int,int> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int,pair<int,int> > iii;
#define PI 3.141592653589793
#define mod 1000000007
# define N 100005
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

ll cf[N];
ll fans[N];

int main()
{
	IOS;
	int n;
	cin >> n;
	vector<ll>v;
	ll a;
    ll ans=0,ans1=0;
	v.pb(0);
	ll prev=0;
	cf[0]=0;
	for(int i=1;i<=n;i++)
	{
		cin >> a;
		ans+=abs(a-prev);
		ans1+=(a-prev);
		cf[i]=ans;
		
		prev=a;
		v.pb(a);
	}
	ans+=abs(prev);
	ans1+=(-prev);
	
	cf[n+1]=ans;
	v.pb(0);

	for(int i=1;i<=n;i++)
	{
		fans[i]+=cf[i-1];
		fans[i]+=(cf[n+1]-cf[i+1]);
		fans[i]+=abs(v[i-1]-v[i+1]);

	}
	for(int i=1;i<=n;i++)
	{
		cout << fans[i]<<"\n";
	}
}

Measured memory_bytes: 3700
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();
    
    if (A == 1) {
      A = 14;
    }
    if (B == 1) {
      B = 14;
    }
    
    if (A == B) {
      System.out.println("Draw");
      return;
    }
    
    System.out.println(A > B ? "Alice" : "Bob");
  }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

struct UnionFind {
  vector<int> d;
  UnionFind(int n) : d(n, -1) {}
  int root(int x) {
    if(d[x] < 0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return false;
    if(d[x] > d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y); }
  int size(int x) { return -d[root(x)]; }
};

int main() {
  ll n, k;
  cin >> n >> k;
  UnionFind uf(n);
  vl p(n), c(n);
  rep(i, n) {
    cin >> p[i];
    p[i]--;
    uf.unite(i, p[i]);
  }
  rep(i, n) cin >> c[i];
  ll ans = -2e18;
  rep(i, n) {
    ll m = uf.size(i), it = i;
    vl sum(m + 1, 0);
    rep(j, m) {
      sum[j + 1] = sum[j] + c[it];
      it = p[it];
    }
    if(sum[m] > 0) {
      ll now1 = k / m * sum[m];
      now1 += *max_element(sum.begin(), sum.begin() + k % m + 1);
      ll now2 = -2e18;
      if(k / m > 0) {
        now2 = (k / m - 1) * sum[m];
        now2 += *max_element(sum.begin() + 1, sum.end());
      }
      ans = max(ans, max(now1, now2));
    } else {
      ll now = -2e18;
      rep(i, min(k, m)) now = max(now, sum[i + 1]);
      ans = max(ans, now);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3744
#include <cstdio>
#include <stack>
#include <iostream>

using namespace std;

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

int main(){
    int in,ans;
    char inc[3];
    
    scanf("%d",&ans);
    
    while(1){
        
        scanf("%s",inc);
        
        if(inc[0]=='='){
            printf("%d\n",ans);
            return 0;
        }
        
        scanf("%d",&in);
        
        switch (inc[0]) {
            case '+':
                ans+=in;
                break;
                
            case '-':
                ans-=in;
                break;
                
            case '*':
                ans*=in;
                break;
                
            case '/':
                ans/=in;
                break;
        }
    }
    
    return 0;
}
    

Measured memory_bytes: 1192
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


class UnionFind
{
public:
  UnionFind(int n)
  {
    parent=vector<int>(n,-1);
  }
  int root(int a)
  {
    if(parent[a]<0)return a;
    return parent[a]=root(parent[a]);
  }
  int size(int a)
  {
    return -parent[root(a)];
  }
  bool connect(int a,int b)
  {
    int A=root(a);
    int B=root(b);
    if(A==B)return false;
    if(size(A)>size(B))swap(A,B);
    parent[B]+=parent[A];
    parent[A]=B;
    return true;
  }
private:
  vector<int> parent;

};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,k,l;
  cin>>n>>k>>l;
  UnionFind uf1(n),uf2(n);
  rep(i,k)
  {
    int a,b;
    cin>>a>>b;
    a--;b--;
    uf1.connect(a, b);
  }
  rep(i,l)
  {
    int a,b;
    cin>>a>>b;
    a--;b--;
    uf2.connect(a, b);
  }
  map<pair<int,int>,int>ma;
  rep(i,n)
  {
    ma[{uf1.root(i),uf2.root(i)}]++;
  }
  rep(i,n)
  {
    cout<<ma[{uf1.root(i),uf2.root(i)}]<<" ";
  }
  cout<<flush;
  return 0;

}


Measured memory_bytes: 13568
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader buff = null;
		buff = new BufferedReader(new InputStreamReader(System.in));

		String[] box = buff.readLine().split(" ");
		int N = Integer.parseInt(box[0]);
		int M = Integer.parseInt(box[1]);

		String[] img = new String[ N ];
		int img_h = N;
		int img_w = 0;
		for (int i = 0; i < N; ++i) {
			img[i] = buff.readLine();
		}
		img_w = img[0].length();

		int h = 0;
		int w = 0;
		String[] pre_img = new String[ N ];
		String line = null;
		while ((line = buff.readLine()) != null) {
			if(line.equals("")){ break; }
			pre_img[h] = line;
			++h;
		}
		w = pre_img[0].length();
		boolean flag = false;

		for (int i = 0; i <= img_h - h; ++i) {
			for (int j = 0; j <= img_w - w; ++j) {

				int k = 0;
				int l = 0;

				for (k = 0; k < h; ++k) {
					for (l = 0; l < w; ++l) {
						if (img[i + k].charAt(j + l) != pre_img[k].charAt(l)) {
							break;
						}
					}
					if (l != w) {
						break;
					}
				}

				if (k == h && l == w) {
					flag = true;
					break;
				}
			}
		}

		if (flag) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 8276
n = int(input())
import numpy as np
a = np.array([list(map(int,input().split())) for _ in range(n)])
ans = 0
for i in range(n):
    a[i][i] = 10**9+1
for i in range(n):
    for j in range(i,n):
        if i==j:
            continue
        dp = np.min(a[i]+a[j])
        if a[i][j]<dp:
            ans += a[i][j]
        elif a[i][j]>dp:
            print(-1)
            exit()
print(ans)

Measured memory_bytes: 16360
#include <bits/stdc++.h>
using namespace std;
const int64_t INF=9999999999999999;

int main() {
 int N;
 cin>>N;
 vector<int>p(N);
 for(int i=0;i<N;i++){
   cin>>p[i];
 }
 int count=0;
 for(int i=0;i<N;i++){
   if(p[i]!=i+1){count++;}
 }
 if(count>2){cout<<"NO"<<endl;}
 else{cout<<"YES"<<endl;}
   return 0;
}

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

using namespace std;

int main()
{
        int n,m,a[100000],i,s=0,d;
        cin>>n>>m;
        for(i=0;i<m;i++)
        {
                cin>>a[i];
                s=s+a[i];
        }
        d=n-s;
        if(d<0)
                cout<<"-1"<<endl;
        else
                cout<<d<<endl;
        return 0;
}


Measured memory_bytes: 3692
#include <cstdio>
#include <cmath>
#include <complex>
#include <iostream>

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

using namespace std;

typedef complex<double> P;

const double PI = 3.1415926535;
P pos[40];
int n, m;
int fst;

double memo[41][41];

inline double outp(const P &a, const P &b){
  return (conj(a)*b).imag();
}

double solve(int p, int rest){
  if(p == n) return 0.0;
  if(rest > n - p) return 0.0;
  if(rest == 0) return 0.0;
  if(memo[p][rest] > -1.0)
    return memo[p][rest];
  double ret = 0.0;

  for(int i = p + 1; i < n; i++){
    double tmp = 0.0;

    if(rest != m - 1){
      P p1 = pos[fst];
      P p2 = pos[p];
      P p3 = pos[i];
      tmp += std::abs(outp(p2 - p1, p3 - p1) / 2.0);
      // printf("tmp: %f\n", tmp);
    }

    ret = max(ret, tmp + solve(i, rest - 1));
  }

  // printf("%d %d %d: %f\n", fst, p, rest, ret);
  return memo[p][rest] = ret;
}

int main(){
  while(scanf("%d%d", &n, &m), n + m){
    REP(i,n){
      double ang;
      scanf("%lf", &ang);
      pos[i] = P(cos(2 * PI * ang), sin(2 * PI * ang));
      // cout << "pos[" << i << "]=" << pos[i] << endl;
    }

    double ans = 0.0;
    REP(i,n){
      REP(j,n) REP(k,m) memo[j][k] = -2.0;
      fst = i;
      ans = max(ans, solve(i, m - 1));
    }

    printf("%.6f\n", ans);
  }
  return 0;
}

Measured memory_bytes: 956
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Programminng
{
    class AOJ_Volume0039
    {
        public static void Main(string[] args)
        {
            Dictionary<char, int> roman = new Dictionary<char, int>();
            roman.Add('I', 1);
            roman.Add('V', 5);
            roman.Add('X', 10);
            roman.Add('L', 50);
            roman.Add('C', 100);
            roman.Add('D', 500);
            roman.Add('M', 1000);

            while (true)
            {
                string s = Console.ReadLine();
                if (string.IsNullOrEmpty(s)) break;

                char[] c = s.ToCharArray();
                int ans = 0;
                for (int i = 0; i < c.Length -1; i++)
                {
                    if (roman[s[i]] >= roman[s[i + 1]]) ans += roman[s[i]];
                    else ans -= roman[s[i]];	
                }
                ans += roman[s[c.Length - 1]];
                Console.WriteLine(ans);

            }
        }
    }
}

Measured memory_bytes: 6048
#include <iostream>
#include <vector>
#include<algorithm>
#include <string>
#include <set>
#include <limits.h>
#include <map>
#include <queue>
#include <stack>

using namespace std;

#define rip(i,n,s) for (int i=(s);i<(int)(n);i++)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n,c;
    cin >> n >> c;
    vector<vector<bool>> da(c,vector<bool>(100001,false));
    int s,t,C;
    rip(i,n,0){
        cin >> s >> t >> C;
        rip(i,t,s-1){
            da[C-1][i]=true;
        }
    }
    int ans=0;
    rip(i,100001,0){
        int no=0;
        rip(j,c,0){
            if(da[j][i]){
                no++;
            }
        }
        ans=max(ans,no);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long,long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

const int INF = 1e9;
const int MAX_N = 1010;
const int MAX_H = 20010;

vecveci dp(1010,veci(20010,0));

int vec_max(veci A) {
    sort(A.begin(),A.end(),greater<int>());
    return A[0];
}

int main() {
    int N,H; cin >> H >> N;
    veci A(N),B(N);
    REP(i,N) cin >> A[i] >> B[i];
    REP(j,MAX_H) dp[0][j] = INF;
    dp[0][0] = 0;
    int H_max = H + vec_max(A);
    REP(i,N) REP(j,H_max+1) {
        if(j < A[i] && i > 0) dp[i+1][j] = dp[i][j];
        else {
            dp[i+1][j] = min(dp[i][j],dp[i+1][j-A[i]]+B[i]);
        }
    }
    int ans = INF;
    /*
    REP(i,N+1) {
        REP(j,H_max+1) cout << dp[i][j] << " ";
        cout << endl;
    }
    */
    for(int i = H; i <= H_max; i++) chmin(ans,dp[N][i]);
    cout << ans << endl;
}



Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
int MAX = 100;
int main()
{
    int N;
    cin >> N;
    int ans = 0;
    vector<int> d(MAX);
    for(int i = 0;i < N;i++){
        cin >> d.at(i);
    }
  int k = 0;
  for(int i = 0;i < N;i++){      
  	for(int j = 1;j < N;j++){
          ans += d.at(i) * d.at(j + k);
        }
    k++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
/* Bismillahir Rahmanir Rahim */

#include <bits/stdc++.h>

#define rep(i, n)	for(int i=0;i<n;i++)
#define repn(i, n)	for(int i=1;i<=n;i++)
#define set(i, n)	memset(i, n, sizeof(i))

#define pb	push_back

using namespace std;

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

const int N = 100005;
const int oo = 1e9;

struct data{
	int at, d, cl;
	data () {}
	data (int _at, int _d, int _cl){
        at = _at;
        d = _d;
        cl = _cl;
	}
};

int n, m, col[N], dis[N], Q;
vector<int>edge[N];
int X[N], D[N], C[N];
int vis[N][15];

void color(int xx, int dd, int cc){
    queue<data>q;
    if(vis[xx][dd]) return;
    q.push(data(xx, dd, cc));
    while(!q.empty()){
    	data f = q.front(); q.pop();
        int at = f.at, cl = f.cl, d = f.d;
        if(!col[at]) col[at] = cl; 
    	if(d == 0) continue;
    	d--;
        for(auto v : edge[at]){
            if(vis[v][d]) continue;
        	vis[v][d] = 1;
        	q.push(data(v, d, cl));
        }
    }
}

int main(){
    int x, y, c;
    scanf("%d %d", &n, &m);
    repn(i, m){
        scanf("%d %d", &x, &y);
        edge[x].pb(y);
        edge[y].pb(x);
    }
    scanf("%d", &Q);
    repn(i, Q){
        scanf("%d %d %d", &X[i], &D[i], &C[i]);
    }
    for(int i=Q;i>=1;i--) color(X[i], D[i], C[i]);
    repn(i, n) printf("%d\n", col[i]);
	return 0;
}


Measured memory_bytes: 14768
n = int(input())
s = input()
cur = [0, 0]
pref = []
for i in range(n):
	if s[i] == 'W':
		cur[0] += 1
	else:
		cur[1] += 1
	pref += [cur[:]]

# print(pref)

res = min(pref[-1][0], pref[-1][1])
for i in range(1, n):
	# print(i, res)
	rem = i - pref[i-1][1]
	ans = rem
	# print('a', ans, rem)

	rightred = pref[-1][1] - pref[i-1][1]

	if rightred >= rem:
		ans += rightred-rem
	else:
		ans += rem-rightred

	res = min(res, ans)

print(res)

Measured memory_bytes: 33268
def resolve():
    import fractions
    n=int(input())
    a=[int(i) for i in input().split()]
    g=1
    dx=fractions.gcd
    for i in a:
        g*=i//dx(g,i)
    suml=0
    mod=10**9+7
    for i in a:
        suml+=g*pow(i,mod-2,mod)
        suml%=mod
    print(suml)
resolve()

Measured memory_bytes: 6200
/*
Problem Statement
You are given strings s and t. Find one longest string that is a subsequence of both s and t.

Notes
A subsequence of a string x is the string obtained by removing zero or more characters from x
and concatenating the remaining characters without changing the order.

Constraints
s and t are strings consisting of lowercase English letters.1≤|s|,|t|≤3000
*/

#include<bits/stdc++.h>
using namespace std;
#define iso ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define clr(x) memset((x), 0, sizeof(x))
#define mod 1000000007
#define MAX 1000005
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll ,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_tree;*/
string st1,st2;
int l1,l2;

int dp[3005][3005];
int main()
{
    cin>>st1>>st2;
    int i,j;
    l1=st1.length();
    l2=st2.length();
    for(i=1;i<=l1;i++)
    {
        for(j=1;j<=l2;j++)
        {
            if(st1[i-1]==st2[j-1])
                dp[i][j]=dp[i-1][j-1]+1;
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);

        }
    }
    //cout<<dp[l1][l2];
    string ans;
    ans.clear();
    if(dp[l1][l2]!=0)
    {
        i=l1,j=l2;
        while(i>0&&j>0)
        {
            if(st1[i-1]==st2[j-1])
            {
                ans+=st1[i-1];
                i--;
                j--;
            }
            else if(dp[i-1][j]>dp[i][j-1])
                i--;
            else
                j--;
        }

    }
    if(ans.length()==0)
        cout<<" ";
    else
    {
        reverse(ans.begin(),ans.end());
        cout<<ans;
    }

}


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

int n;

bool check753(long long int x){
  bool Is_7 = false;
  bool Is_5 = false;
  bool Is_3 = false;
  
  while(x>0){
    if( x%10 == 7 ) Is_7 = true;
    if( x%10 == 5 ) Is_5 = true;
    if( x%10 == 3 ) Is_3 = true;
    x /= 10;
  }
  
  return Is_7 && Is_5 && Is_3;
}

int dfs(long long int x){
  int ret;
  if( x > n ) return 0;
  check753(x) ? ret=1 : ret=0;
  return ret + dfs(x*10+3) + dfs(x*10+5) + dfs(x*10+7);
}
  

int main(){
  cin >> n;
  
  cout << dfs(0) << endl;
  
  return 0;
}

Measured memory_bytes: 256
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
//list($N,$K) = explode(" ",trim(fgets(STDIN)));
//$a = explode(" ",trim(fgets(STDIN)));
//$H = explode(" ",trim(fgets(STDIN)));
if ($N==7 || $N==5 || $N==3) {
  printf("YES\n");
}
else {
  printf("NO\n");
}


Measured memory_bytes: 3828
#include<iostream>
#include<string>
#include<cstdlib>
#include<cmath>
#include<algorithm>

using namespace std;

int main() {
	int N;
	cin >> N;
	int value[N];
	for(int i=0; i<N; i++)
		cin >> value[i];

	long dp[1000][N-1];
	for(int i=0; i<1000; i++) {
		for(int j=0; j<N-1; j++)
			dp[i][j] = 0;
	}

	dp[value[0]][0] = 1;
	for(int i=1; i<N-1; i++) {
		for(int j=0; j<1000; j++) {
			if(dp[j][i-1] > 0) {
				if(j+value[i] >= 0 && j+value[i] <= 20) dp[j+value[i]][i] += dp[j][i-1];
				if(j-value[i] >= 0 && j-value[i] <= 20) dp[j-value[i]][i] += dp[j][i-1];
			}
		}
	}

	cout << dp[value[N-1]][N-2] << endl;

	return 0;
}

Measured memory_bytes: 1932
#include <bits/stdc++.h>
//#pragma GCC optimize ("02")
#define ll long long
#define oo 1000000007
using namespace std;

ll ans[200005];


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

	ans[1] = 0;
	for(int i=1; i<200005-1; i++){
		ans[i+1] = ans[i] + i;
	}

	ll n;
	map<ll, ll> mp;
	cin >> n;
	ll a[n+1];
	for(int i=0; i<n; i++){
		cin >> a[i];
		mp[a[i]]++;
	}
	ll sum = 0;
	for(auto it : mp){
		sum += ans[it.second];
	}

	for(int i=0; i<n; i++){
		ll s = sum;
		s = s - (ans[mp[a[i]]]-ans[mp[a[i]]-1]);
		cout << s << endl;
	}


    return 0;
}


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

typedef long long ll;
typedef long long LL;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#ifdef DEBUG
    #define cek(x) cout<<x
#else
    #define cek(x) if(false){}
#endif // DEBUG

#define fi first
#define se second
#define INF 1000000000
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define PI acos(-1.0)
#define pb push_back
#define TC() while(tc--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORN(i,n) for(int i=0;i<=n;i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define REPN(i,a,b) for(int i=a;i<=b;i++)
#define reset(a,b) memset(a,b,sizeof(a))
#define sc(x) scanf("%d",&x)

int main(void){
    #ifdef ccsnoopy
        freopen("D:/Code/in.txt","r",stdin);
    #endif

    int h,w;
    sc(h);sc(w);
    char str[10][10];
    FOR(i,h)scanf("%s", str[i]);
    int ct = 0;

    FOR(i,h){
        FOR(j,w){
            if(str[i][j] == '#')ct++;
        }
    }
    ii xy = ii(0,0);
    int dr[] = {1,0};
    int dc[] = {0,1};
    while(true){
        ct--;
        int x = xy.first;
        int y = xy.second;
        bool found = false;
        FOR(i,2){
            int xb = x+dr[i];
            int yb = y+dc[i];
            if(xb >= 0 && xb < h && yb >= 0 && yb < w && str[xb][yb] == '#'){
                xy = ii(xb,yb);
                found = true;
                break;
            }
        }

        if(!found)break;

    }

    //printf("%d\n", ct);

    printf("%s", ct ? "Impossible":"Possible");





    return 0;
}





Measured memory_bytes: 256