akhauriyash/Code-Regression huggingface dataset:
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


N = int(input())

ans = 0

for _ in range(N):
    L,R = map(int,input().split())
    ans += R - L + 1


print("%d"%(ans))

Measured memory_bytes: 3444
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node{
  int p, l, r;
};

struct Node T[MAX];

int n;
int Depth[MAX], Height[MAX];

int GetD(int u){
  int d = 0;
  while(1){
    u = T[u].p;
    if ( u == NIL ) break;
    d++;
  }
  return d;
}

int GetS(int u){
  if ( T[u].p == NIL ) return NIL;
  if ( T[T[u].p].l != u && T[T[u].p].l != NIL ) return T[T[u].p].l;
  if ( T[T[u].p].r != u && T[T[u].p].r != NIL ) return T[T[u].p].r;
  return NIL;
}

void print(int u){
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].p);
  printf("sibling = %d, ", GetS(u));

  int deg = 0;
  
  if ( T[u].l != NIL ) deg++;
  if ( T[u].r != NIL ) deg++;
  
  printf("degree = %d, ", deg);
  printf("depth = %d, ", Depth[u]);
  printf("height = %d, ", Height[u]);

  if ( T[u].p == NIL ){
    printf("root\n");
  }
  else if ( T[u].l == NIL && T[u].r == NIL ){
    printf("leaf\n");
  }
  else {
    printf("internal node\n");
  }
}

int main(){
  int i, v, l, r;
  
  scanf("%d", &n);

  for ( i = 0; i < n; i++ )
    T[i].p = NIL;

  for ( i = 0; i < n; i++ ){
    scanf("%d %d %d", &v, &l, &r);
    
    T[v].l = l;
    T[v].r = r;

    if ( l != NIL ) T[l].p = v;
    if ( r != NIL ) T[r].p = v;
  }

  for ( i = 0; i < n; i++ ){
    Depth[i] = GetD(i);
    Height[i] = 0;
  }

  for ( i = 0; i < n; i++ ){
    if ( T[i].l == NIL && T[i].r == NIL ) {
      Height[i] = 0;
      int p = T[i].p;
      int c = 1;

      while(1){
	if ( p == NIL ) break;
	if ( Height[p] < c ) Height[p] = c;
	c++;
	p = T[p].p;
      }
    }
  }

  for ( i = 0; i < n; i++ ) print(i);
  
  return 0;
}



Measured memory_bytes: 2104
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) std::cerr<< #x <<": "<<x<<"\n"
#define debug2(x,y) std::cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<"\n"
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

int main() {
  int n, m, d;
  cin >> n >> m >> d;
  int cnt = 0;
  rep (i, n) {
    if (i - d >= 0) {
      cnt += 1;
    }
    if (i + d < n) {
      cnt += 1;
    }
  }
  if (d == 0) {
    cnt = n;
  }
  double ans = cnt;
  ans /= n;
  ans /= n;
  ans *= (m-1);
  printf("%.9f\n", ans);

  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define MAXN 100005

using namespace std;

int main (){
	
	//freopen("t.txt","r",stdin);
	int n, dp[MAXN][4],a,b,c;
	cin>>n;
	
	cin>>dp[1][1]>>dp[1][2]>>dp[1][3];
	
	for (int i=2;i<=n;i++){
		cin>>a>>b>>c;
		 dp[i][1] = max( dp[i-1][2] , dp[i-1][3] ) + a;
		 dp[i][2] = max( dp[i-1][1] , dp[i-1][3] ) + b;
		 dp[i][3] = max( dp[i-1][1] , dp[i-1][2] ) + c;
	}
	
	cout<<max ( dp[n][1], max (dp[n][2],dp[n][3]) );
	return 0; 
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

llong modpow(llong n, llong m) {
  if (m == 1) return n;

  llong ret = modpow(n, m/2);
  ret = ret * ret % mod;
  if (m & 1) ret = ret * n % mod;

  return ret;
}

int main() {
  llong n, a, b;
  cin >> n >> a >> b;

  llong res = modpow(2, n);
  llong dame = 1;
  for (int i = 1; i <= max(a, b); ++i) {
    dame = dame * (n - i + 1) % mod * modpow(i, mod - 2) % mod;
    if (i == a || i == b) {
      res = (res - dame + mod) % mod;
    }
  }

  cout << res - 1 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

int findsumofDigits(int n){
        int sum = 0;
        while(n >0){
            sum += n%10;
            n /= 10;
        }
        return sum;
    }

int main()
{
    int n,l,ans;
    cin >> n >> l;
    ans = 0;
    std::vector<string> vec(n);
    
    for(int i = 0; i < n; i++)
    {
        cin >> vec[i];
    }
    
    sort(vec.begin(),vec.end());

    for  (auto it = vec.begin(); it != vec.end(); ++it) cout << *it;
    
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  
  int n;
  cin>>n;
  string s;
  cin>>s;
  int i=0;
  int j=n-1;
  int ans=0;
  while(i<j)
  {
    if(s[i]=='R'&&s[j]=='W')
       {
           i++;
           j--;
       }
     else if(s[i]=='R')
     i++;
     else if(s[j]=='W')
     j--;
     else 
     {
         ans++;
         i++;
         j--;
     }
         
       
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3724
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
#define ll long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define clr(x,y) memset(x,y,sizeof(x))
#define in(a) a=read()
#define out(a) printf("%d\n",a)
inline ll read(){
    char c=getchar();ll f=1,x=0;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+(c-'0'),c=getchar();
    return x*f;
}
#define mod 1000000007
void MOD(int &x){if(x>=mod)x-=mod;}
#define maxn 100010
#define inf (1<<30)
int b[maxn],a[maxn],c[maxn];
int main(){
	int n;
	in(n);
	FOR(i,1,n){
		in(a[i]);
	}
	sort(a+1,a+n+1);
	int cnt=0;
	a[0]=-1;
	FOR(i,1,n){
		if(a[i]!=a[i-1])b[++cnt]=a[i];
		c[cnt]++;
	}
	if(cnt>3)puts("No");
	else {
		if(n%3==0){
			if(cnt==3){
				if(c[1]==c[2]&&c[2]==c[3]){
					if((b[1]^b[2])==b[3]||(b[2]^b[3])==b[1]||(b[3]^b[1])==b[2])puts("Yes");
					else puts("No");
				}
				else puts("No");
			}
			if(cnt==2){
				if(c[1]==c[2]*2){
					if((b[1]^b[2])==b[1]||(b[1]^b[1])==b[2])puts("Yes");
					else puts("No");
				}
				else if(c[2]==c[1]*2){
					if((b[2]^b[1])==b[2]||(b[2]^b[2])==b[1])puts("Yes");
					else puts("No");
				}
				else puts("No"); 
			}
			if(cnt==1){
				if((b[1]^b[1])==b[1])puts("Yes");
				else puts("No");
			}
		}
		else if(cnt<=1&&(b[1]^b[1])==b[1])puts("Yes");
		else puts("No");
	}
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    float a;
    cin>>n;
    priority_queue<float, vector<float>, greater<float> > pq;
    
    for(int i=0; i<n; i++)
    {
        cin>>a;
        pq.push(a);
    }
    
    while(pq.size() !=1 )
    {
        float x = pq.top();
        pq.pop();
        float y = pq.top();
        pq.pop();
        
        pq.push((x+y)/float(2));
    }
    
    cout<<pq.top();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

int N;
string S, T;
int main(){
    cin >> N >> S >> T;
    for (int i = 0; i < N; i++) {
        putchar(S[i]); putchar(T[i]);
    }
    return 0;
}

Measured memory_bytes: 256
Scanf.scanf "%d %d" @@ fun n x ->
  if x = 1 || x = 2*n-1 then print_endline "No"
  else begin
    print_endline "Yes";
    let rec constr i y =
      if i > 2*n-1 then []
      else if i = n-1 then (x-1) :: x :: (x+1) :: constr (i+3) y
      else if y = x-1 then constr i (x+2)
      else y :: constr (i+1) (y+1)
    in constr 1 1 |> List.iter (Printf.printf "%d\n")
  end


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

bool IsEven(int num){
    if(num % 2 == 0) {
        return true;
    } else {
        return false;
    }
}

int main()
{
    int A[100000][3];
    int N;

    cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> A[i][j];
        }
    }

    int now_time = 0;
    int now_x = 0;
    int now_y = 0;
    for (int i = 0; i < N; i++) {
        int t = A[i][0] - now_time;
        int dist = abs(A[i][1] - now_x) + abs(A[i][2] - now_y);

        if(dist > t || IsEven(dist) != IsEven(t)) {
            cout << "No" << endl;
            return 0;
        } 

        now_time = A[i][0];
        now_x = A[i][1];
        now_y = A[i][2];
    }
    cout << "Yes" << endl;

    return 0;
}

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

def main():
    N = int(input())
    F = []
    for _ in range(N):
        F.append(list(map(int, input().split())))
    P = []
    for _ in range(N):
        P.append(list(map(int, input().split())))

    ans = -10**7*N
    for i in range(1, 1<<10):
        tmp = 0
        for s,f in enumerate(F):
            c = 0
            for j in range(10):
                if (i>>j)&1&f[j]:
                    c += 1
            tmp += P[s][c]
        ans = max(ans, tmp)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
# https://atcoder.jp/contests/tenka1-2018-beginner/tasks/tenka1_2018_c
from collections import deque
n = int(input())
nums = []
for _ in range(n):
    nums.append(int(input()))
nums.sort()
ans = 0
l = 0
r = n - 1
q = deque()
while l <= r:
    left = nums[l]
    right = nums[r]
    if not q:
        ans += abs(right - left)
        q.append(left)
        q.append(right)
        l += 1
        r -= 1
    else:
        s = max(abs(q[-1] - right), abs(q[0] - right))
        t = max(abs(q[-1] - left), abs(q[0] - left))
        if s >= t:
            if abs(q[-1] - right) > abs(q[0] - right):
                ans += abs(q[-1] - right)
                q.append(right)
            else:
                ans += abs(q[0] - right)
                q.appendleft(right)
            r -= 1
        else:
            if abs(q[-1] - left) > abs(q[0] - left):
                ans += abs(q[-1] - left)
                q.append(left)
            else:
                ans += abs(q[0] - left)
                q.appendleft(left)
            l += 1
print(ans)

Measured memory_bytes: 61784
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
 
typedef long long ll;
typedef pair<int, int> ii;

int main() {
	int a, b, n;
	cin >> a >> b >> n;
	bool flag = false;
	rep(i, n){
		int s, f;
		cin >> s >> f;
		if(b <= s || f <= a) continue;
		flag = true;
 	}
	cout << flag << endl;
}

Measured memory_bytes: 3100
open System.Collections.Generic

let A = new List<int []>()

for i in [ 1..3 ] do
    stdin.ReadLine().Split()
    |> Array.map int
    |> A.Add

let N = stdin.ReadLine() |> int

let b = new List<int>()

for i in [ 1..N ] do
    stdin.ReadLine()
    |> int
    |> b.Add

let mutable C = new List<bool []>()

for i in [ 1..3 ] do
    [| false; false; false |] |> C.Add

for i in [ 0..N - 1 ] do
    for j in [ 0..2 ] do
        for k in [ 0..2 ] do
            if A.[j].[k] = b.[i] then C.[j].[k] <- true

let mutable result = false

for i in [ 0..2 ] do
    if C.[i].[0] && C.[i].[1] && C.[i].[2] then result <- true
    if C.[0].[i] && C.[1].[i] && C.[2].[i] then result <- true
if C.[0].[0] && C.[1].[1] && C.[2].[2] then result <- true
if C.[2].[0] && C.[1].[1] && C.[0].[2] then result <- true

if result then "Yes"
else "No"
|> stdout.WriteLine

Measured memory_bytes: 11732
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<sstream>
#include<cstdio>

using namespace std;
using ll = long long;

const int INF = 1001001001;
const int MOD = 1000000007;


int main() {
	int N, K;cin >> N >> K;
	priority_queue <int, vector<int>, greater<int>> p;
	for (int i = 0;i < N;i++){
		int tmp;
		cin >> tmp;
		p.push(tmp);
	}

	int ttl = 0;
	for (int i = 0;i < K;i++){
		ttl += p.top();p.pop();
	}

	cout << ttl;
	return 0;
}

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

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=21;

int n,k,t;
int f[2][N][1<<N];
int Lg[1<<N],rev[1<<N],sum[1<<N];
pii trs[N][1<<N][2],ans;
char s[1<<N];

int main(){
	//freopen("01.txt","r",stdin);
	For(i,1,1<<N) Lg[i]=Lg[i>>1]+1;
	n=IN(),k=IN();
	For(i,0,n+1) For(x,0,1<<i){
		if (x==(1<<i)-1){
			trs[i][x][0]=mp(-1,-1);
		} else{
			int w=Lg[(x+1)&-(x+1)];
			trs[i][x][0]=mp(i-w,x>>w);
		}
		if (x==0){
			trs[i][x][1]=mp(-1,-1);
		} else{
			int w=Lg[x&-x];
			trs[i][x][1]=mp(i-w,x>>w);
		}
	}
	For(i,0,n+1){
		scanf("%s",s);
		For(j,1,1<<i) rev[j]=(rev[j>>1]>>1)|(j&1)<<i-1;
		For(j,0,1<<i) if (s[j]=='1') f[t^1][i][rev[j]]=1;
	}
	For(i,0,n+1){
		memset(sum,0,sizeof(sum));
		t^=1;
		For(j,0,n-i+1) For(k,0,1<<i+j)
			if (f[t][j][k]){
				int x=k>>i,y=k&(1<<i)-1;
				For(w,0,2){
					pii P=trs[j][x][w];
					if (P.fi==-1) continue;
					f[t^1][P.fi][P.se<<(i+1)|y<<1|w]+=f[t][j][k];
				}
				sum[y]+=f[t][j][k];
				f[t][j][k]=0;
			}
		For(x,0,1<<i) if (sum[x]>=k){
			ans=mp(i,x);
			break;
		}
	}
	for (int i=ans.fi-1;~i;i--) printf("%d",ans.se>>i&1);
	puts("");
}

Measured memory_bytes: 308608
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
 
		char[] n = sc.next().toCharArray();
	    int k = sc.nextInt();

	    int l = n.length;
	    int dp0[][] = new int[l+1][k+1];
	    int dp1[][] = new int[l+1][k+1]; //確定小於N
	    
	    dp0[0][0] = 1;

	    for(int i=0;i<l;i++){
	        for(int j=0;j<=k;j++){
	            if(dp0[i][j]==1){
	                for(int h=0;h<=n[i]-'0';h++){
	                    if(h+'0' == n[i]){
	                        if(n[i]=='0'){
	                            dp0[i+1][j] = 1;
	                        }
	                        else{
	                            if(j+1<=k)
	                                dp0[i+1][j+1] = 1;
	                        }
	                    }
	                    else{
	                        if(h==0){
	                            dp1[i+1][j] += 1;
	                        }
	                        else{
	                            if(j+1<=k)
	                                dp1[i+1][j+1] += 1;
	                        }
	                    }
	                }
	            }

	            dp1[i+1][j] += dp1[i][j];
	            if(j+1<=k)
	                dp1[i+1][j+1] += 9*dp1[i][j];
	        }
	    }


	    System.out.println(dp0[l][k]+dp1[l][k]);
	}
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void uniq(vector<int> &vec){sort(vec.begin(), vec.end());vec.erase(unique(vec.begin(), vec.end()), vec.end());}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
    int n,l,ans=0,c=INF;
    cin>>n>>l;
    Vi a(n);
    REP(i,0,n){
        a[i]=l+i;
        ans+=a[i];
    }
    REP(i,0,n) chmin(c,abs(a[i]));
    if(a[a.size()-1]<0) c*=-1;
    cout<<ans-c<<endl;
    return 0;
}


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

/* -------------------------------- Template -------------------------------- */

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

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

template<typename T> T inf() { assert(false); }
template<> constexpr int inf<int>() { return 1e9; }
template<> constexpr ll inf<ll>() { return 1e18; }
template<> constexpr ld inf<ld>() { return 1e30; }

/* -------------------------------- Library -------------------------------- */

/* ---------------------------------- Main ---------------------------------- */

int main() {
  int H, W, N, a, b;
  map<pair<int,int>,int> ma;
  cin >> H >> W >> N;
  for (int i = 0; i < N; ++i) {
    cin >> a >> b; --a; --b;
    REP(j,3) REP(k,3) ma[make_pair(a-j, b-k)] += 1;
  }
  vector<ll> res(10);
  for (auto p: ma) {
    auto co = p.first;
    int num = p.second;
    int x, y; tie(x, y) = co;
    if (0 <= x && x + 2 < H &&
        0 <= y && y + 2 < W) ++res[num];
    // cout << x << " " << y << " " << num << endl;
  }
  ll sum = accumulate(ALL(res), 0);
  res[0] = ll(H - 2) * (W - 2) - sum;
  for (ll i: res) cout << i << endl;
  return 0;
}


Measured memory_bytes: 56448
#include <stdio.h>

int main(void)
{
	char a, b;
	char here = 'A';

	while (scanf(" %c,%c", &a, &b) != EOF){
		if (here == a){
			here = b;
		}
		else if (here == b){
			here = a;
		}
	}

	printf("%c\n", here);

	return (0);
}

Measured memory_bytes: 540
import collections
import itertools
n = int(input())
l = list(map(int, input().split()))

l_col = collections.Counter(l)
keys = list(l_col.keys())
res = 0
for x in itertools.combinations(keys, 3):
    if max(x)*2 < sum(x):
        c = 1
        for d in x:
            c *= l_col[d]
        res += c
print(res)

Measured memory_bytes: 9476
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k=0;
  string str;
  cin>>str;
  if(str.at(0)==str.at(1)&&str.at(2)==str.at(3)){
    k=1;
    if(str.at(1)==str.at(2)){
      k=0;
    }
  }
  if(str.at(0)==str.at(2)&&str.at(1)==str.at(3)){
    k=1;
    if(str.at(1)==str.at(2)){
      k=0;
    }
  }
  if(str.at(0)==str.at(3)&&str.at(2)==str.at(1)){
    k=1;
    if(str.at(0)==str.at(2)){
      k=0;
    }
  }
  if(k==1){
    cout<<"Yes";
  }
  if(k==0){
    cout<<"No";
  }
}

Measured memory_bytes: 256
s = input()
t = input()
if s.count(t):
    print(0)
else:
    len_t = len(t)
    cnt = 0
    for i in range(len(s) - len_t + 1):
        c = 0
        for j in range(len_t):
            if s[i+j] == t[j]: c += 1
        cnt = max(cnt, c)
    print(len_t - cnt)

Measured memory_bytes: 8976
#include<cstdio>
using namespace std;
int main()
{
	int n,m,s,total1,total2;
	scanf("%d%d%d",&n,&m,&s);
	total1=s/n;
	total2=s/m;
	if (s%n!=0) total1++;
	if (s%m!=0) total2++;
	if (total1<total2) printf("%d",total1);
	else	printf("%d",total2);
} 

Measured memory_bytes: 128
A = []
for i in range(3):
    A.append(input().split())
N = int(input())
B = []
for i in range(N):
    B = input()
    for j in range(3):
        for k in range(3):
            if A[j][k] == B:
                A[j][k] = 0

if A[0][0] == 0 and A[0][1] == 0 and A[0][2] == 0:
    print('Yes')
elif A[1][0] == 0 and A[1][1] == 0 and A[1][2] == 0:
    print('Yes')
elif A[2][0] == 0 and A[2][1] == 0 and A[2][2] == 0:
    print('Yes')
elif A[0][0] == 0 and A[1][0] == 0 and A[2][0] == 0:
    print('Yes')
elif A[0][1] == 0 and A[1][1] == 0 and A[2][1] == 0:
    print('Yes')
elif A[0][2] == 0 and A[1][2] == 0 and A[2][2] == 0:
    print('Yes')
elif A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
    print('Yes')
elif A[0][2] == 0 and A[1][1] == 0 and A[2][0] == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38256
#include<bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=1e4,INF=1e8;
int dp[MAX_N+1][10];
int N,M,A[9],mat[9]={2,5,5,4,5,6,3,7,6};
int dig;
void dfs(int d){
	if(d==dig)return;
	for(int i=M-1;i>=0;i--){
		if(N>=mat[A[i]-1] && dp[N-mat[A[i]-1]][M]==dig-1-d){
			N-=mat[A[i]-1];
			cout<<A[i];
			dfs(d+1);
			return;
		}
	}
}
int main(){
	cin>>N>>M;
	REP(i,M)cin>>A[i];
	sort(A,A+M);
	REP(i,N){
		dp[i+1][0]=-INF;
	}
	dp[0][0]=0;
	REP(i,M){
		REP(j,N+1){
			dp[j][i+1]=dp[j][i];
			if(j>=mat[A[i]-1]){
				dp[j][i+1]=max(dp[j][i+1],dp[j-mat[A[i]-1]][i+1]+1);
			}
		}
	}
	dig=dp[N][M];
	dfs(0);
	cout<<endl;
}

Measured memory_bytes: 640
# ABC058C - 怪文書 / Dubious Document (ARC071C)
from collections import Counter
from string import ascii_lowercase


def main():
    N = int(input())
    D = tuple(Counter(input()) for _ in range(N))
    ans = ""
    for s in ascii_lowercase:
        if all(s in d for d in D):
            ans += s * min(d[s] for d in D)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3768
// ABC097D - Equals

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

typedef unsigned long long int ull;
typedef long long int ll;

struct UnionFind {
	vector<int> par;
	vector<int> rank;
	vector<int> count;

	// n要素で初期化
	UnionFind(int n) {
		par.resize(n);
		rank.resize(n, 0);
		count.resize(n, 1);
		for (int i = 0; i < n; i++) {
			par[i] = i;
		}
	}

	// 木の根を求める。
	int find(int x) {
		if (par[x] == x) {
			return x;
		} else {
			return par[x] = find(par[x]);
		}
	}

	// xとyの属する集合を併合
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) {
			return;
		}
		
		count[x] += count[y];
		count[y] = count[x];
		if (rank[x] < rank[y]) {
			par[x] = y;
		} else {
			par[y] = x;
			if (rank[x] == rank[y]) {
				rank[x]++;
			}
		}
	}

	// xとyが同じ集合に属するか否か
	bool same(int x, int y) {
		return find(x) == find(y);
	}

	// xと同じ集合の要素数を返す。
	int getCount(int x) {
		return count[x];
	}
};

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

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

	UnionFind tree(N+1);
	for (int i = 0; i < M; i++) {
		int x, y;
		cin >> x >> y;
		tree.unite(x, y);
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (tree.same(tree.find(p[i]), i + 1)) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4840
/**
*    created: 27.06.2020 19:11:46
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcountll(bit)
#define mod 1000000007
#define pi acos(-1.0)
using namespace std;
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;}

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;
    if (s[0] != 'A' || !islower(s[1]) || !islower(s[s.size()-1])) {
        cout << "WA" << endl;
        return 0;
    }
    int cnt = 0;
    for (int i = 2; i <= s.size()-2; i++) {
        if (s[i] == 'C') {
            if (cnt == 1) {
                cout << "WA" << endl;
                return 0;
            }
            else cnt++;
        }
        else if (!islower(s[i])) {
            cout << "WA" << endl;
            return 0;
        }
    }
    if (cnt == 0) {
        cout << "WA" << endl;
        return 0;
    }
    cout << "AC" << endl;
    return 0;
}

Measured memory_bytes: 3628
#pragma GCC optimize ("-Ofast")
#include<bits/stdc++.h>
using namespace std ;
#define int long long
#define ld long double
#define _ ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL);
#define F(i,b) for(int i= 0; i<(int)(b);i++)
#define FI(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define inp(a) for(auto& i : a) cin >> i;
#define out(a) for(auto i : a){cout << i << ' ';}cout << endl;
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pii pair<int,int>
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
#define MOD 1000000007
const int N = 2e5+7 ;
string s ;

int32_t main(){_
	int n,k ;
	cin >> n >> k ;
	int t = n/k ;
	int ans = t*t*t ;
	if(k%2 == 0){
		t = (n+(k/2)) / k ;
		ans += (t*t*t) ;
	}
	cout << ans << endl ;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
typedef long long ll;
const int INF = 1e9+1;
const int MOD = 2e9 + 9;
const ll LINF = 1e18;
using namespace std;

int two(int n) {
	int cnt = 0;
	int m = n;
	for (int i = 0; i < m; i++) {
		if (n % 2 != 0)return cnt;
		else {
			cnt++;
			n = n / 2;
		}
	}
	return cnt;
}

int main(){
	int n;
	int ans = 0;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)cin >> a.at(i);
	for (int i = 0; i < n; i++) {
		ans = ans + two(a.at(i));
	}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<ll> a(n),sum(n+1);
    rep(i,n){
        cin >> a[i];
        sum[i+1]=sum[i]+a[i];
    }
    ll ans=INF;
    for(int i=2;i<n-1;i++){
        ll l=sum[i],r=sum[n]-sum[i];
        int u=upper_bound(sum.begin(),sum.end(),l/2)-sum.begin();
        int v=upper_bound(sum.begin(),sum.end(),l+r/2)-sum.begin();
        rep(j,2){
            rep(k,2){
                vector<ll> d(4);
                d[0]=sum[u-j];
                d[1]=sum[i]-sum[u-j];
                d[2]=sum[v-k]-sum[i];
                d[3]=sum[n]-sum[v-k];
                sort(d.begin(),d.end());
                chmin(ans,d[3]-d[0]);
            }
        }
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;

#define int ll

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

template<class T>
inline T GET() {
	T x;
	cin >> x;
	return x;
}

void init();
void solve();

signed main()
{
	init();
	solve();
}

ll N, C;
vector<ll>  x, v, xr, vr;
int r1, r2, l1, l2;

void init()
{
	cin >> N >> C;
	rep(i, N) {
		x.PB(GET<ll>());
		v.PB(GET<ll>());
	}
	rrep(i, N) {
		xr.PB(C - x[i]);
		vr.PB(v[i]);
	}
}

void calc(vector<ll>& X, vector<ll>& V, vector<vector<ll>>& score) {
	ll sum = 0;
	score[0][0] = score[1][0] = 0;
	rep(i, N) {
		sum += V[i];
		score[0][i+1] = max(score[0][i], sum - X[i]);
		score[1][i+1] = max(score[1][i], sum - 2 * X[i]);
	}
}

void solve()
{
	vector<vector<vector<ll>>> score;
	score.RS(2, vector<vector<ll>>(2, vector<ll>(N+1, 0)));
	calc(x, v, score[0]);
	calc(xr, vr, score[1]);
	ll res = max(score[1][0][N], score[0][0][N]);
	rep(i, 2) {
		rep(j, 2) {
			rep(k, N+1) {
				cerr << score[i][j][k] << " ";
			}
			cerr << endl;
		}
		cerr << endl;
	}
	reps(i, 1, N) {
		res = max(res, score[0][0][i] + score[1][1][N-i]);
		res = max(res, score[0][1][i] + score[1][0][N-i]);
	}
	cout << res << endl;
}





Measured memory_bytes: 8980
N=int(input())
A=[int(x) for x in input().split()]
B=[0]*9
for i in range(N):
  R=A[i]//400
  if R>8:
    R=8
  B[R] +=1
answer_min=0
for i in range(8):
  if not B[i]==0:
    answer_min +=1
answer_max=answer_min+B[8]
if answer_min==0:
  answer_min=1
print(answer_min,answer_max)

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

#define rep(i,a,b)                for(ll i=a;i<b;i++)
#define re(i,b)                for(ll i=0;i<b;i++)
#define repr(i,n)                for(ll i=n-1;i>=0;i--)
#define ll long long
#define ld long double
#define llu long long unsigned
#define vll std::vector<ll>
#define mll std::map<ll, ll>
#define pll std::pair<ll, ll>
#define mpll std::map<pair<ll,ll>, ll>
#define sll std::set<ll>
#define fi first
#define se second
#define msll std::multiset<ll>
#define all(c) c.begin(), c.end()
#define allr(c) c.rbegin(), c.rend()
#define srt(x) sort(all(x))
#define rsrt(x) sort(allr(x))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define s(yy) ll yy;cin>>yy
#define mod 1000000007
#define maxlong 9223372036854775808


/*
###################################################### 
#                                                    #
#                     @author                        #
#                  Parth Lathiya                     #
#      https://www.cse.iitb.ac.in/~parthiitb/        #
#                                                    #
###################################################### 
*/

// vll primes;
// vll primefac[10000001];

// void sieve(ll n)
// {
// 	rep(i,2,n+1)
// 	{
// 		if(primefac[i].empty())
// 		{	
// 			primes.pb(i);
// 			for(ll j=i;j<=n;j+=i)
// 				primefac[j].pb(i);
// 		}
// 	}
// }


int main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	#ifdef PARTH_LATHIYA_HOME

		freopen("B_in.txt","r",stdin);
	
		ll ttt,bkkk;
		cin>>ttt;
		bkkk=ttt;
		while(ttt--) {
			cout<<"Testcase - "<<bkkk-ttt<<"\n";
	#endif

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


	s(n);
	ll a[n];
	re(i,n)
		cin>>a[i];
	sort(a,a+n);

	cout<<a[n-1]-a[0];

//--------------------------------------------------------------------------------------
	
	#ifdef PARTH_LATHIYA_HOME
		cout<<"\n"; }
	#endif

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long N, A, B, R, C, D;
int main() {
	cin >> N >> C >> D >> A >> B;
	R = (A ? (A * 100 - 1) / C + 1 : 0) + (B ? (B * 100 - 1) / D + 1 : 0);
	cout << (N - R < 0 ? -1 : N - R) << endl;
	return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    ld a, b, p, q, r; cin >> a >> b >> p >> q >> r;
    ld d = p * b - (b - a) * q;
    cout << fixed << setprecision(15) << b + d / (q + r) << "\n";
}



Measured memory_bytes: 3296
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define ld long double
#define mkp make_pair
#define sz(x) (int)x.size()
#define pi pair<long long, long long>
#define watch(x) cout << (#x) << " is " << (x) << endl; cout.flush()
#define endl '\n'
#define _ << ' '
#define FAST_LOG2(x) (sizeof(unsigned long)*8 - 1 - __builtin_clzl((unsigned long)(x)))
#define clog2(x) (((x) - (1 << FAST_LOG2(x))) ? FAST_LOG2(x) + 1 : FAST_LOG2(x))
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> idxset;
//find_by_order(i) : iterator to the value at index i, order_of_key(x) : the index of value x
const ll mod = (ll)1e9+7;
const ll INF = (ll)1e9+1;


int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
   // freopen("B.txt", "r", stdin);
    #endif
    int n, a[222], ans=0;
    cin >> n;
    for(int i=1; i<n; i++){
        cin >> a[i];
    }
    a[0] = 111111;
    a[n] = a[n-1];
    for(int i=0; i<n; i++){
        ans += min(a[i], a[i+1]);
    }
    cout << ans;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.ArrayDeque;
import java.util.Queue;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
public class Main{
	 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		int n = t.length();
		if((t.substring(0, n-1)).equals(s)) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
	 }
}

Measured memory_bytes: 35604
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>

using namespace std;

#define ll long long

int main(void){
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n);
    for(ll i = 0;i < n;++i)    cin >> h[i];

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

    ll ans = 0;
    for(ll i = 0;i < n-k;++i){
        ans += h[i];
    }    

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define set_bits(a) __builtin_popcount(a)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define fi first
#define se second
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


int main()
{
    ll n,i,j;
    cin>>n;
    ll arr[n];
    ll ans=0;
    unordered_map<ll,ll>mp;
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
        mp[arr[i]]++;
    }
    unordered_map<ll,ll>mpp;

    for(auto it:mp)
    {
        mpp[it.first] = (it.second)*(it.second-1)/2;
    }
    ll sum=0;

    for(auto it:mpp)
    {
        sum+=(it.second);
    }
//    cout<<sum<<endl;
    ll nn=n-1;
    ll p = nn*(nn-1)/2;


    ll y = sum;

    for(i=0;i<n;i++)
    {
        ll aa = mp[arr[i]];

        ll itne_tarike_bachenge = y- (aa*(aa-1))/2;
        aa--;

        itne_tarike_bachenge += (aa*(aa-1))/2;
        cout<<itne_tarike_bachenge<<endl;
    }
}





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


int gcd(int a, int b) {
	if (a == b) {
		return a;
	}
	if (b > a) {
		return gcd(b - a, a);
	}
	return gcd(a - b, b);
}

int gcd(int a, int b, int c) {
	return gcd(a, gcd(b, c));
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	
	int sum = 0;
	
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			for (int k = 1; k <= n; ++k) {
				sum += gcd(i, j, k);
			}
		}
	}
	
	cout << sum << endl;
	
	
	return 0;
}


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

using namespace std;
using vi = vector<int>;
using ll = long long;

#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<endl
const int MOD = 1000000007;

int main() {
  IN(N);

  vi A(N);
  REP(i, N) cin >> A[i];
  SORT(A);
  if (N % 2 == 0) {
    REP(i, N) {
      if (A[i] == A[i+1] && A[i] == i+1) {
        ++i;
        continue;
      }
      OUT(0); return 0;
    }
  } else {
    if (A[0] != 0) {
      OUT(0); return 0;
    }
    FOR(i, 1, N) {
      if (A[i] == A[i+1] && A[i] == i + 1) {
        ++i;
        continue;
      }
      OUT(0); return 0;
    }
  }
  ll ans = 1;
  REP(i, N / 2) {
    ans *= 2;
    ans %= MOD;
  }
  OUT(ans);

  return 0;
}


Measured memory_bytes: 640
from queue import Queue

k = int(input())

q = Queue()
for i in range(1, 10):
    q.put(i)

for _ in range(k):
    x = q.get()
    if x % 10 != 0:
        q.put(10 * x + (x % 10) - 1)
    q.put(10 * x + (x % 10))
    if x % 10 != 9:
        q.put(10 * x + (x % 10) + 1)

print(x)


Measured memory_bytes: 18980
S = input()
N = len(S)
P = 2019

# ABC158
cnt = 0

table = [0] * P 
Ui = 0
ten = 1

S = S[::-1]
table[0] = 1 

for i in range(N):
    Ui = (Ui + int(S[i]) * ten) % P 
    
    cnt += table[Ui] 
    
    table[Ui] += 1 
    ten = (ten * 10) % P 
print(cnt)

Measured memory_bytes: 9256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long r, g, b, k, ct;

	cin >> r >> g >> b >> k;
	ct = 0;
	while (g <= r) {
		g *= 2;
		ct++;
	}
	while (b <= g) {
		b *= 2;
		ct++;
	}

	if (ct <= k) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}


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

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

#define vt          vector
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

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

    int n, m, l;
    cin >> n >> m >> l;
    vt<vt<int>> adj(n, vt<int>(n, l + 1));
    while (m--) {
        int u, v, w;
        cin >> u >> v >> w;
        u--, v--;
        adj[u][v] = adj[v][u] = w;
    }

    vt<vt<int>> adjFuel(n, vt<int>(n, n));
    for (int i = 0; i < n; i++) {
        for (int u = 0; u < n; u++) {
            for (int v = 0; v < n; v++) {
                adj[u][v] = 
                    min(adj[u][v], adj[u][i] + adj[i][v]);
                if (adj[u][v] <= l) adjFuel[u][v] = 1;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        for (int u = 0; u < n; u++) {
            for (int v = 0; v < n; v++) {
                adjFuel[u][v] = 
                    min(adjFuel[u][v], adjFuel[u][i] + adjFuel[i][v]);
            }
        }
    }

    int q;
    cin >> q;
    while (q--) {
        int u, v;
        cin >> u >> v;

        int c = adjFuel[--u][--v];
        cout << (c == n ? -1 : c - 1) << '\n';
    }
}


Measured memory_bytes: 4028
# include "iostream"
# include "cstdio"

using namespace std;

int n,now; 
long long ans; 

inline int tester(int n) {
    int count=0;
    while(n!=0){
		count++;
        if ((n & 1) == 1) {
            return count; 
        }
        n=n>>1;
    }
    return count;
}

int main(){
	register int i,j;
	scanf("%d",&n); 
	for(i=1;i<=n;i++){
		scanf("%d",&now);
		ans+=tester(now)-1; 
	}
	printf("%lld",ans); 
	return 0; 
} 

Measured memory_bytes: 256
N=int(input())
S=input()

# 各文字がどこまでにいくつ含まれるかを累積和で管理
R=[0]*N
G=[0]*N
B=[0]*N

dic={}
for c in ("R","G","B"):
  dic[c] = [0] * N

rp=0
gp=0
bp=0
for i in range(len(S)):
  if S[i]=="R":
    rp+=1
  elif S[i]=="G":
    gp+=1
  elif S[i]=="B":
    bp+=1
  dic["B"][i]=bp
  dic["R"][i]=rp
  dic["G"][i]=gp

def getRest(s1,s2):
  for c in ["R","G","B"]:
    if c not in (s1,s2):
      return c

ans = 0
for i in range(N-2):
  for j in range(i+1,N-1):
    # 最初の2つの文字を固定する
    if S[i] == S[j]:
      continue
    # 探すべき文字を特定
    rest = getRest(S[i],S[j])
    ans += dic[rest][-1] - dic[rest][j]
    
    if j + (j-i) < N and S[j + (j-i)] == rest:
      ans -= 1
    
print(ans)    

Measured memory_bytes: 69244
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int cnt[26][51] = {};
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string S[51];
    rep(i, n) cin >> S[i];
    rep(i, n) {
        rep(j, S[i].length()) {
            cnt[S[i][j] - 'a'][i]++;
        }
    }
    rep(i, 26) {
        int len = INF;
        rep(j, n) len = min(len, cnt[i][j]);
        rep(j, len) cout << (char)('a' + i);
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3632
#include<queue>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
using namespace std;
const int inf=1<<28;
struct node{
	int x,d;
	node() {}
	node(int a,int b) {x=a;d=b;}
};
bool operator < (node a,node b) {return a.d>b.d;}
priority_queue<node> q;
int k,dis[100010];
bool vis[100010];
int main()
{
	scanf("%d",&k);
	memset(vis,false,sizeof(vis));
	for(int i=0;i<k;i++) dis[i]=inf;
	for(int i=1;i<=min(9,k);i++) dis[i%k]=i,q.push(node(i%k,i));
	while(!q.empty())
	{
		node t=q.top();q.pop();
		int x=t.x;
		if(vis[x]) continue;
		vis[x]=true;
		for(int i=0;i<=9;i++)
		{
			int y=(x*10+i)%k;
			if(dis[y]>dis[x]+i) dis[y]=dis[x]+i,q.push(node(y,dis[y]));
		}
	}
	printf("%d",dis[0]);
}

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

#define yes "Yes"
#define no "No"
//int m,n;
//int i,j,k,l;
//int a,b,c,d,e,f,g;
//int sum,total;
//long long int ;
//float ;
//double ;
//char a[101],b[101],s[101],t[101],u[101];
int main()
{
    int x, y, i, j, k;
    cin >> x;
    cin >> y;
    for (size_t i = 0; i < x + 1; i++)
    {
        if ((i * 2) + ((x - i) * 4) == y)
        {
            cout << yes << endl;
            return 0;
        }
    }
    cout << no << endl;
}

Measured memory_bytes: 3636
import numpy as np
N, M = map(int, raw_input().split())
Trial = np.zeros(N, int)
Penalty = 0
Finish = np.zeros(N, bool)
for i in xrange(M):
    a, b = raw_input().split()
    A = int(a) - 1
    if not Finish[A]:
        if b == 'AC':
            Penalty += Trial[A]
            Finish[A] = True
        else:
            Trial[A] += 1
    else:
        pass
    
Accept = Finish.sum()
print Accept, Penalty

Measured memory_bytes: 16260
#!/usr/bin/env python
# coding: utf-8

# In[1]:


S = input()


# In[2]:


weather = ['Sunny', 'Cloudy', 'Rainy']


# In[3]:


if S == weather[0]:
    print(weather[1])
elif S == weather[1]:
    print(weather[2])
elif S == weather[2]:
    print(weather[0])


# In[ ]:






Measured memory_bytes: 2940
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

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

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int H,W,S;
int grid[32][32];
int sum[33][33];
P memo[33][33][33][33];

//[x1,x2) - [y1,y2)
int count(int x1,int y1,int x2,int y2){
  return sum[y2][x2] - sum[y2][x1] - sum[y1][x2] + sum[y1][x1];
}
P dfs(int x1,int y1,int x2,int y2){
  P &memory = memo[x1][y1][x2][y2];
  if(memory != P(-1,-1)) return memory;
  if(S - (count(0,0,W,H) - count(x1,y1,x2,y2)) < 0) return P(-INF,-INF);
  P res(1, S - (count(0,0,W,H) - count(x1,y1,x2,y2)));
  for(int vy = y1+1; vy < y2; vy++){
    P p1 = dfs(x1,y1,x2,vy);
    P p2 = dfs(x1,vy,x2,y2);
    P score = P(p1.first+p2.first, min(p1.second, p2.second));
    res = max(res, score);
  }
  for(int vx = x1+1; vx < x2; vx++){
    P p1 = dfs(x1,y1,vx,y2);
    P p2 = dfs(vx,y1,x2,y2);
    P score = P(p1.first+p2.first, min(p1.second, p2.second));
    res = max(res, score);
  }
  return memory = res;
}
int main(){
  while(cin>>H>>W>>S,H){
    memset(sum,0,sizeof(sum));
    memset(memo,-1,sizeof(memo));
    REP(y,H)REP(x,W)cin>>grid[y][x];
    REP(y,H)REP(x,W)sum[y+1][x+1] = sum[y+1][x] + sum[y][x+1] - sum[y][x] + grid[y][x];
    P ans = dfs(0,0,W,H);
    printf("%d %d\n",ans.first, ans.second);
  }

	return 0;
}

Measured memory_bytes: 9000
N = int(input())
D,X = map(int,input().split())
A = []
for i in range(N):
    A.append(int(input()))

ans = 0
for i in range(N):
    d = 1
    c = 0
    while True:
        d = (1+A[i]*c)
        if d > D:
            break
        ans += 1
        c += 1

print(ans + X)


Measured memory_bytes: 38768
#include<iostream>
#include<numeric>
#include<vector>
#include<cmath>
#include<climits>
#include<cfloat>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include<limits>
using namespace std;
typedef pair<int,bool> Pair;
int main(){
long N,i;
long count = 0;
cin >> N;


if(N%2 == 0) for(i = 1;(long)(2*(long)pow(5,i)) <= N;++i) count = count + (long)(N/(2*(long)pow(5,i)));

cout << count << endl;

return 0;

}

Measured memory_bytes: 512