akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
#define boost                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for (auto &z : v)
#define sp << ' ' <<
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353
#define PI_2 1.57079632679489661923

ll power(ll base, ll exp, ll mod) // O(logn) time
{
    ll ans=1LL;
    while(exp){
        if(exp&1LL) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exp>>=1LL;
    }
    return ans%mod;
}

int main() {
    ll tt = 1, n, m, l, r, c, i, j, k, w, x, y;
    boost;
    
    // cin >> tt;
    ll ans = 1001;

    for(int _ = 1; _ <= tt; _++) {
        // cout << "Case #" << _ << ": ";
        cin >> n;
        ans = 0;
        ll sum = 0, sq = 0;
        
        for(i = 0; i < n; i++){
            cin >> x;

            sum += x;
            sum %= fat;

            sq += x*x;
            sq %= fat;
        }

        ans = ((sum*sum - sq + fat)%fat)*power(2, fat - 2, fat);
        cout << ans%fat << nl;
    }
}

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

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

    vector<int> k(n);
    vector<vector<int>> a(n, vector<int>(m));
    for(int i=0; i<n; i++){
        cin>>k[i];
        for(int j=0; j<k[i]; j++){
            cin>>a[i][j];
        }
    }

    bool check=false;
    int count=0,loved=0;

    for(int i=1; i<=m; i++){
        for(int j=0; j<n; j++){
            int k=0;
            while(check==false && k<m){
                if(a[j][k]==i){
                    check=true;
                }
                k++;
            }
            if(check==true){
                count++;
            }
            check=false;
        }
        if(count==n){
            loved++;
        }
        count=0;
    }

    cout<<loved<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>

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

using namespace std;

int main()
{
	int i,x[5];
	req(i,5){
		cin >> x[i];
		if(x[i] == 0)
			cout << i + 1 << endl;
	}

}


Measured memory_bytes: 3152
#include <stdio.h>

int main(int ac, char **argv) {
  int data[10], i, j, k;
  for(i = 0; i < 10; i++) {
    scanf("%d", &data[i]);
  }
  for(i = 0; i < 10; i++) {
    for(j = 9; j > i; j--) {
      if(data[j] < data[j - 1]) {
        k = data[j];
        data[j] = data[j - 1];
        data[j - 1] = k;
      }
    }
  }
  printf("%d\n%d\n%d\n", data[9], data[8], data[7]);
  return 0;
}

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

int main(){

  int S,h,m,s;

  cin >> S;
  h = S / 3600;
  m = (S % 3600) / 60;
  s = S - h*3600 - m*60;

 cout << h << ":" << m << ":" << s << endl;

}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
#define PI 3.14159265
#define INF 2147483647
using namespace std;
using ll = long long;
void self_max(int &a,int b){
	a = max(a,b);
}
void self_min(int &a,int b){
	a = min(a,b);
}
int main(){
	int n ; cin >> n;
	int arr[n] = {};
	rep(i,n) cin >> arr[i];

	vector<int> cnt;
	int cur = 1;

	rep(i,n){
		if(arr[i] == cur){
			cnt.push_back(cur);
			cur++;
		}
	}
	if(cnt.size()==0 ){
		cout << -1 << endl;
	}else{
		cout << n - cnt.size() << endl;	
	}

	return 0;
}

Measured memory_bytes: 2168
n = int(input())
plist = list(map(int,input().split()))

islow = True
counter = 0
min = 0

for i in range(len(plist)):
    islow = True
    if i == 0:
        counter += 1
        min = plist[i]
        current_min = i
    elif min > plist[i]:
        counter += 1
        min = plist[i]
        current_min = i
        
print(counter)        

Measured memory_bytes: 26012
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl '\n'
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repab(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define  printarr(v) for(auto x:v){cout<<x<<" "; }
#define debug1(a) cout<<#a<<" "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" "<<(a)<<" "<<#b<<" "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" "<<(a)<<" "<<#b<<" "<<(b)<<" "#c<<" "<<(c)<<endl;
typedef long double ld;
void solve()
{
	string s;
	cin >> s;
	if (s[s.length() - 1] != 's')
	{
		cout << s + 's' << endl;
	}
	else
	{
		cout << s + 'e' + 's' << endl;
	}


}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
}


Measured memory_bytes: 3608
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	int N;
	int[] X;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		N = Integer.parseInt(in.readLine());
		String[] tokens = in.readLine().split(" ");
		X = new int[N];
		for (int i = 0; i < N; ++i) {
			X[i] = Integer.parseInt(tokens[i]);
		}
	}

	void calc() {
		// まず平均値を求める
		double ave = 0.0;
		for (Integer x : X) {
			ave += x;
		}
		ave /= N;
		int ave0 = (int) Math.floor(ave);
		int ave1 = ave0 + 1;
		// 分散を求める
		double var0 = 0.0;
		for (Integer x : X) {
			var0 += (x - ave0) * (x - ave0);
		}
		double var1 = 0.0;
		for (Integer x : X) {
			var1 += (x - ave1) * (x - ave1);
		}
		var0 = Math.min(var0, var1);
		System.out.println((int)(var0));
	}

	void showResult() {

	}
}


Measured memory_bytes: 22484
#include <stdio.h>

int main(void){
    int N, T;
    scanf("%d%d", &N, &T);
    int c[N],t[N];
    for (int i = 0; i < N; i++){
        scanf("%d%d", &c[i], &t[i]);
    }

    int x = 0;
    int min = c[0];
    for(int i = 0; i < N; i++){
        if (t[i] > T){
            x += 1;
        }
        else{
            if (min > c[i]){
                min = c[i];
            }
        }
    }
    
    if (x == N){
        printf("TLE\n");
    }
    else{
        printf("%d\n", min);
    }

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define PI 3.1415926535
double angle(double h, double m)  
{  
    
    if (h == 12) h = 0;  
    if (m == 60) m = 0;  
    
    double hour_angle = 0.5 * (h * 60 + m);  
    double minute_angle = 6 * m;  
  
    
    double angle = abs(hour_angle - minute_angle);  
  
    
    angle = min(360 - angle, angle);  
  
    return angle;  
}  
int main(){
   double  a,b,c,d,ans,x;
  
   cin>>a>>b>>c>>d;
   x=angle(c,d);
   ans=sqrt((a*a) + (b*b) -2*a*b*cos(x*(PI)/180.0));
   
   cout<<setprecision(10)<<ans;
    
}

Measured memory_bytes: 4164
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i) 
const long long INF = 1000000007;
typedef long long ll;
using namespace std;
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; }
bool comp(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	/
	/
	/
	*/
	string s;
	cin >> s;
	bool a = true;
	int ans = 0;
	rep0(i,(int)s.size()) {
		if ((i + 1) % 2 != 0) {
			if (s[i] == 'R' || s[i] == 'U' || s[i] == 'D') {
				ans++;
			}
			else {
				a = false;
			}
		}
		else {
			if (s[i] == 'L' || s[i] == 'U' || s[i] == 'D') {
				ans++;
			}
			else {
				a = false;
			}
		}
	}
	if (a == false) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
from collections import Counter

input = open(0).read

n, *v = map(int, input().split())


def main():
    e = Counter(v[::2])
    o = Counter(v[1::2])

    em = e.most_common(2)
    om = o.most_common(2)

    # 要素は最低でも 2 つ
    em.append((0, 0))
    om.append((0, 0))

    if em[0][0] == om[0][0]:
        print(min(n - em[0][1] - om[1][1], n - em[1][1] - om[0][1]))
    else:
        print(n - em[0][1] - om[0][1])

    return


main()


Measured memory_bytes: 18604
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  double a,b,c,d,e,f,x,y;
  while(cin>>a>>b>>c>>d>>e>>f){
    y=(f-d*c/a)/(e-d*b/a);
    x=(c-b*y)/a;
    printf("%.3f %.3f\n",x,y);
  }
}

Measured memory_bytes: 3056
#include"bits/stdc++.h"
using namespace std;

int main() {
	int X;
	cin >> X;
	int x = 1;
	for (int b = 1;b <= 31;++b) {
		for (int p = 2;p <= 9;++p) {
			if (x < pow(b, p) && pow(b, p) <= X) {
				x = pow(b,p);
			}
		}
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    k,n = IL()
    a = list(IL())
    a.sort()
    dist = []
    for i in range(n):
        if i<n-1:
            dist.append(a[i+1]-a[i])
        else:
            dist.append(k-a[i]+a[0])
    x = max(dist)
    print(k-x)
    return

if __name__=='__main__':
    Main()

Measured memory_bytes: 50772
#include<bits/stdc++.h> 
using namespace std;
 
#define ll long long int
#define absdiff(a,b) (a>b)?a-b:b-a
#define debug cout<<"debug";
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);
#define MOD 1000000007
#define ll_MAX 19223372036859
#define endl "\n"
ll fast_expo(ll x,ll p){if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
ll gcd(ll a,ll b){if(a==0||b==0) return a+b;  else return gcd(b%a,a); }

const ll s=6500;
ll dp[2][81][2*s+1];

int main()
{
    ll t;t=1;
    // cin>>t;
    for(ll x=0;x<t;++x){
        ll r,c;cin>>r>>c;
        pair<ll,ll> mat[r+1][c+1];
        for(ll i=1;i<=r;++i){
            for(ll j=1;j<=c;++j){
                cin>>mat[i][j].first;
            }
        }
        
        for(ll i=1;i<=r;++i){
            for(ll j=1;j<=c;++j){
                cin>>mat[i][j].second;
            }
        }
        
        ll last,curr;
        dp[0][1][s]=1;
        
        for(ll i=1;i<=r;++i){
            if(i%2==0) curr=0;
            else curr=1;
            last=1-curr;
            
            for(ll j=1;j<=c;++j){
                ll diff=mat[i][j].second-mat[i][j].first;
                for(ll k=0;k<2*s+1;++k)
                {   
                    if(dp[curr][j-1][k]){
                        dp[curr][j][k+diff]=1;
                        dp[curr][j][k-diff]=1;
                    }
                    if(dp[last][j][k]){
                        dp[curr][j][k+diff]=1;
                        dp[curr][j][k-diff]=1;
                    }
                }
            }
            for(ll j=0;j<=c;++j){
                for(ll k=0;k<2*s+1;++k)
                {   
                    dp[last][j][k]=0;
                }
            }
        }

        ll ans=INT_MAX;
        if(r%2==0) curr=0;
        else curr=1;
    
        for(ll i=0;i<2*s+1;++i){
            if(dp[curr][c][i]){
                if(i>=s){
                    ans=min(ans,i-s);
                }
                else ans=min(ans,s-i);
            }
        }
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 16896
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        int sqrN = (int)Math.sqrt(n);

        long res = Integer.MAX_VALUE;
        for (int i = 1; i <= sqrN; ++i) {
            if (n % i == 0) {
                long b = n / i;

                long tmp = Math.max(func(i), func(b));
                if (tmp < res) res = tmp;
            }
        }

        System.out.println(res);
    }

    static long func(long n) {
        long cnt = 0;
        while (n != 0) {
            n /= 10;
            ++cnt;
        }
        return cnt;
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<int> A;
map<int,int> Cnt;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        Cnt[a]++;
        A.push_back(a);
    }
}

int solve(){ 
    int ans=0;
    for(auto c:Cnt){
        DBG(c.first)
        DBG(c.second)
        if(c.first==c.second) continue;
        else if(c.first>c.second) ans+=c.second;
        else if(c.first<c.second) ans+=min(c.second-c.first,c.second);
    } 
    cout << ans << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 5112
n, x = map(int,input().split())
a = list(map(int, input().split()))

a.sort()
ans = 0
for i in range(n):
    if i != n-1 and a[i] <= x:
        x -= a[i]
        ans += 1
    elif i == n-1 and a[i] == x:
        x -= a[i]
        ans += 1
    else:
        x = 0
        break

print(ans)

Measured memory_bytes: 3064
number = []
number = input().split()

start_number = int(number[0])
end_number = int(number[1])
count = 0

while start_number <= end_number:
    l = []
    for s in str(start_number):
        l.append(s)
    if l[0] == l[4] and l[1] == l[3]:
        count += 1
    start_number += 1

print(count)

Measured memory_bytes: 3064
/**
 *    author:  morato
 *    created: 19.09.2020 18:06:04
**/
#include <bits/stdc++.h>

using namespace std;

const long long mod = 998244353;

const int N = 1e6 + 5;

long long bit[N];
int n, k;

long long oo(long long a, long long b = mod) {
  a = (a + b) % b;
  return a;
}

void update(int i, long long val) {
  while (i <= n) {
    bit[i] = oo(bit[i] + val);
    i += (i & -i);
  }
}

long long query(int i) {
  long long ret = 0;
  while (i > 0) {
    ret = oo(ret + bit[i]);
    i -= (i & -i);
  }
  return ret;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  vector<pair<int, int>> aa(k);
  for (int i = 0; i < k; i++) {
    cin >> aa[i].first >> aa[i].second;
  }
  sort(aa.begin(), aa.end());
  update(1, 1);
  for (int i = 2; i <= n; i++) {
    for (int j = 0; j < k; j++) {
      int r = i - aa[j].first;
      int l = i - aa[j].second;
      long long val = oo(query(r) - query(l - 1));
      update(i, val);
    }
  }
  cout << oo(query(n) - query(n - 1)) << '\n';
  return 0;
}

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

int gcd(int x, int y){
    if (y == 0)
        return x;
    x = x % y;
    gcd(y, x);
}

int check(int i,int ans){
    if(i<2) return ans;
    ans=i*check(i-2,ans);
}
main(){
    int i;
    cin>>i;
    int ans=0;
    if(i%2!=0){
        cout<<0<<endl;
    }
    else{
        for(int j=1;j<=36;j++){
            int b=10;
            for(int p=1;p<=j;p++){
            b*=5;
            }
            ans=ans+i/b;
        }
        ans+=i/10;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios_base::sync_with_stdio(0);
    int a; cin >> a;
    cout << a + a*a + a*a*a << endl;
}


Measured memory_bytes: 3620
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			int sz = Integer.parseInt(sc.nextLine());
			String[] vals = sc.nextLine().split("\\s+");

			int[] arr = new int[vals.length];
			for (int i=0; i<vals.length; i++) arr[i] = Integer.parseInt(vals[i]);

			int res = 0;
			int cur = 1;
			for (int x : arr) {
				if (x != cur) {
					res ++;
				} else {
					cur ++;
				}
			}

			if (res == arr.length) res = -1;
			
			System.out.println(res);
		}
	}

}


Measured memory_bytes: 59096
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main() {
    long a, b, c, d;
    cin>>a >> b>> c>> d;
    long aa=a*c;
    long bb=a*d;
    long cc=b*c;
    long dd=b*d;
    long ans=max(aa,bb);
    ans=max(ans,cc);
    ans=max(ans,dd);
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <cstdio>
using namespace std;
typedef long long ll;

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

int lcm(int a,int b){
    return a*b/gcd(a,b);
}

int main(){
    double b,c,d,e,k,l,m,n,o=0,p,q,r,x,y,z,max1=0,ans=0,a1,b1;
    string s,t,u;
    ll a[7][7];
    
    cin>>b;
    cout<<b*b<<endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep(i,n) FOR(i,0,n-1)
#define int long long
#define MOD 998244353
#define MAXN  100005
#define P pair<int,int>

signed main(){
	
	int n,a,b;cin>>n>>a>>b;
	string s;cin>>s;

	int nai = 0,gai=0;
	rep(i,n)
	{
		if(s[i]=='c') 
		{
			cout <<"No"<<endl;
			continue;
		}
		
		if(s[i] == 'a')
		{
			if(nai < a+b )
			{
				cout << "Yes"<<endl;
				nai++;
			}
			else cout << "No" <<endl;
			continue;
		}
		
		if(s[i] == 'b')
		{
			if(nai < a+b and gai < b)
			{
				cout << "Yes"<<endl;
				nai++,gai++;
			}
			else cout << "No" << endl;
		}
	}
}

//cout << ans << endl;

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+5;
inline int read(){
	char c=getchar();int t=0,f=1;
	while((!isdigit(c))&&(c!=EOF)){if(c=='-')f=-1;c=getchar();}
	while((isdigit(c))&&(c!=EOF)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
int n,l,res,t[maxn],le[maxn],ri[maxn],x[maxn],del[maxn]; 
signed main(){
	n=read();l=read(),res=n+1;
	for(int i=1;i<=n;i++)x[i]=read();
	for(int i=1;i<=n;i++){
		res+=(t[i]=read())/(l<<1);t[i]%=(l<<1);
	}
	for(int i=1;i<=n;i++){
		if(!t[i]){
			res--;del[i]=1;
			continue;
		}
		del[i]=!((le[i]=2*(l-x[i])>=t[i])|(ri[i]=2*x[i]>=t[i]));
	}
	res-=le[n];
	int sum=0,top=0,pos=n;
	for(int i=1;i<n;i++){
		if(del[i])continue;
		if(!le[i]){
			pos=i;break;
		}
		ri[i]?++top:(top?--top,--res:0);
	}
	sum+=top;top=0;
	for(int i=n-1;i>=pos;i--){
		if(del[i])continue;
		if(!ri[i])break;
		le[i]?++top:(top?--top,--res:0);
	}
	printf("%lld\n",2ll*l*(res-=sum+top>>1));
	return 0;
}


Measured memory_bytes: 6144
#include <iostream>
#include <iomanip>
#include <cstdio>
using namespace std;

int main(void) {
    // insert code here...
    int num;
    cin >> num;
    double heads[num];
    double tail[num];
    
    for(int i = 0; i < num; i++){
        cin >> heads[i];
        tail[i] = 1 - heads[i];
//        cout << heads[i] << endl;
    }
    
    double proba[num][num + 1];
    proba[0][0] = tail[0];
    proba[0][1] = heads[0];
    
    for(int i = 1; i < num; i++){
        proba[i][0] = proba[i - 1][0] * tail[i];
        proba[i][i + 1] = proba[i-1][i] * heads[i];
    }
    
    for(int i = 1; i < num; i++){
        for(int j = 1; j <= i; j++){
            proba[i][j] = proba[i - 1][j - 1] * heads[i] + proba[i - 1][j] * tail[i];
        }
    }
    
    double probaAns = 0;
    for(int i = (num + 1)/2; i < num + 1; i++){
        probaAns += proba[num - 1][i];
    }
    
    cout << fixed << setprecision(10) << probaAns << endl;
    
    return 0;
}


Measured memory_bytes: 70400
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n;
    cin>>n;
    string s;
    cin>>s;
    rep(i,s.size()){
        ((s[i]-'A')+n>=26?s[i]=s[i]+n-26:s[i]=s[i]+n);
    }
    out(s);
}

Measured memory_bytes: 3604
import sys

def main():
    input = sys.stdin.readline
    N,M = map(int,input().split())
    full = 2**N
    dp = [float("inf")]*full
    dp[0] = 0


    for m in range(M):
        a,b = map(int, input().split())
        C = list(map(int, input().split()))
        #鍵mで開く宝箱を二進法で表記
        state = 0
        for c in C:
            state += 2**(c-1)

        #状態iに対して鍵mを使い、状態i|stateにいく場合と、元から入っている場合の大小を比較
        #状態i|state即ち状態iに対して鍵mを使った後の状態
        for i in range(full):
            if dp[i] != float("inf"):
                dp[i|state] = min(dp[i]+a,dp[i|state])

    if dp[-1]==float("inf"):
    #dp[-1]はdp[full-1]でも同じ
        return -1

    return dp[-1]

print(main())


Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int ans = c - (a - b);
	if (ans < 0) ans = 0;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
using namespace std;
const int MAX_N=1e5; // 1e8=x, 1e7=? 1e6=o                                                                                     
int n[MAX_N+1]={};
int prime[MAX_N+1];
void eratos_sieve(){
  for(int i=2;i<=MAX_N;i++){
    if(!n[i]){
      prime[i]=1;
      for(int j=i;j<=MAX_N;j+=i) n[j]=1;
    }
  }
}
int main(){
  vector <int> same;
  eratos_sieve();
  for(int i=3;i<100000;i+=2) if(prime[i]&&prime[(i+1)/2]) same.push_back(i);
  //for(int i=0;i<same.size();i++) cout<<same[i]<<" ";                                                                         
  int q,l,r;
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>l>>r;
    int r0=0;
    for(int j=0;j<(int)same.size();j++) if(l<=same[j]&&same[j]<=r) r0++;
    cout<<r0<<endl;
  }
  return 0;
}
 
 

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

#include <bits/stdc++.h>
#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")  // disable
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define lll __int128
#define lp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define vec(v, type, sz) vector<type> v(sz)
#define in(v) \
    for (auto &i : v) cin >> i
#define all(v) v.begin(), v.end()
#define prv(v)                         \
    for (auto i : v) cout << i << " "; \
    cout << "\n"
#define MOD 1000000007
#define INF 1000000000
#define INFL 1000000000000000000ll
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vi vector<int>
#define vl vector<ll>
#define vii(v, n, m, val) vector<vector<int>> v(n, vector<int>(m, val))
#define viii(v, i, j, k, val)        \
    vector<vector<vector<int>>> v(i, \
                                  vector<vector<int>>(j, vector<int>(k, val)))
#define pii pair<int, int>
#define pb push_back
#define tos(x) string(1,x)
#define file_io                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define testc   \
    int tcc;    \
    cin >> tcc; \
    for (int tc = 1; tc <= tcc; tc++)
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while (!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(vector<string> __attribute__((unused)) args,
               __attribute__((unused)) int idx,
               __attribute__((unused)) int LINE_NUM) {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if (idx > 0)
        cerr << ", ";
    else
        cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss;
    ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef DB
#define debug(...) \
    debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
//#define int ll

signed main() {
	fast_io;
	ld n,d; cin>>n>>d;
	int cnt=0;
	lp(i,0,n){
		ld x,y; cin>>x>>y;
		if(x*x+y*y<=d*d) cnt++;
	}
	cout<<cnt;
}
// code!=think
// least efficient code to get ac


Measured memory_bytes: 3848
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import deque 
def main():
    K = int(readline())
    dq = deque() 
    cnd = []
    for i in range(1, 10):
        dq.append(i)
        cnd.append(i)
    
    while len(dq)>0:
        v = dq.popleft()
        r = v%10 
        if r == 0:
            nx = v*10
            dq.append(nx)
            cnd.append(nx)
            nx = v*10+1
            dq.append(nx)
            cnd.append(nx)
        elif r == 9:
            nx = v*10+8
            dq.append(nx)
            cnd.append(nx)
            nx = v*10+9
            dq.append(nx)
            cnd.append(nx)
        else:
            nx = v*10+(r-1)
            dq.append(nx)
            cnd.append(nx)
            nx = v*10+r
            dq.append(nx)
            cnd.append(nx)
            nx = v*10+(r+1)
            dq.append(nx)
            cnd.append(nx)
        if len(cnd) > K: 
            break
    print(cnd[K-1])
if __name__ == '__main__':
    main()

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

/*input
6
aba 1
def 1
gh 1
hgf 1
edcb 1
a 10

4
eg 1
abab 2
fcbabad 3
cfbabage 5

4
ab 1
ab 2
baba 3
baba 2

2
aba 1
aba 2

2
abc 1
cba 2

5
abcdef 5
edcba 5
abcd 3
efd 3
cba 3

*/

#define RIGHT 0
#define REV 1

typedef pair<string, int> si;
typedef pair<long long, si> lsi;

string rev(string s){
    string ans = "";
    for(int i = s.size() - 1; i >= 0;i --){
        ans += s[i];
    }
    return ans;
}

// truncate the part one have over other
si getNext(string a, string b){
    int type = (a.size() > b.size() ? 0 : 1);
    if(a.size() <= b.size()) swap(a, b);
    string s = "";
    int asize = a.size();
    int bsize = b.size();
    int dif = asize - bsize;
    for(int i = 0; i < bsize; i++){
        if(a[i] != b[i]) return si("", -1);
    }
    if(dif <= 1) return si("", type); // for example "abc" and "ab"
    for(int i = 0; i < dif; i++){
        s += a[bsize + i];
    }
    return si(s, type);
}

int main(){
    #ifdef DEBUG
    freopen("F.inp", "r", stdin);
    freopen("F.out", "w", stdout);
    #endif // DEBUG
    int n;
    cin >> n;
    const long long MAX = 1e18;
    vector<si> edge[2];
    long long _min = MAX;
    for(int i = 0; i < n; i++){
        string s;
        int c;
        cin >> s >> c;
        string revS = rev(s);
        edge[RIGHT].push_back(si(s, c));
        edge[REV].push_back(si(revS, c));
        if(s == revS) _min = min(_min, (long long) c);
    }
    map<si, long long> path; // si for (string, type: right or reverse)
    priority_queue<lsi, vector<lsi>, greater<lsi> > pq; // lsi = cost, string, type
    pq.push(lsi(0, si("", RIGHT)));
    pq.push(lsi(0, si("", REV)));
    path[si("", RIGHT)] = MAX;
    path[si("", REV)] = MAX;
    while(!pq.empty()){
        lsi t = pq.top();
        pq.pop();
        long long cost = t.first;
        string crt = t.second.first;
        int crtType = t.second.second;
        int type = !t.second.second; // next type
        int edgeType = edge[type].size();
        if(crt == rev(crt)){
            _min = min(_min, path[si(crt, crtType)]);
        }
        for(int i = 0; i < edgeType;i ++){
            string edgeStr = edge[type][i].first;
            int edgeCost = edge[type][i].second;
            si next = getNext((crtType == RIGHT ? crt : edgeStr),
                                    (crtType == REV ? crt : edgeStr));
            string nextStr = next.first;
            int nextType = next.second;
            if(nextType == -1) continue;
            if((path.find(next) == path.end()) ||
                        (0LL + cost + edgeCost < path[next])){
                #ifdef DEBUG2
                cout << "\t" << crt << " -> " << nextStr << "\n";
                cout << "\t" << "Cost " << cost + edgeCost << "\n";
                #endif // DEBUG2
                path[next] = 0LL + cost + edgeCost;
                pq.push(lsi(0LL + cost + edgeCost, next));
            }
        }
    }
    if(path[si("", 0)] == MAX && path[si("", 1)] == MAX && _min == MAX){
        cout << -1;
    } else{
        cout << min(_min, min(path[si("", 0)], path[si("", 1)]));
    }

}


Measured memory_bytes: 3672
//do not think about past and stay in this moment
//organize and work - Abhinav IIITA
#include <bits/stdc++.h>
#include <ctime>
using namespace std;
#define int long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end() 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int arr[3000000];
void input(int n){
	for(int i=0;i<n;++i)
	cin>>arr[i];
}
// -----------------------------------------------------------------------



void solve(){
	vector<int> v(3);
	for(int i=0;i<3;++i)
	cin>>v[i];
	sort(all(v));
	int ap=v[0]+v[1];
	if(ap==v[2])
	cout<<"Yes\n";
	else
	cout<<"No\n";
}


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


int32_t main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); 	
	int t=1;
//	cin>>t;
	while(t--)
	solve();
	return 0;
}


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

long long temp, X, sum;
int main(){
    cin >> X;
    temp = sqrt(X);
    sum = temp*(1 + temp)/2;
    while (sum < X){
        temp++;
        sum = temp*(1 + temp)/2;
    }
    cout << temp << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

struct channel
{
    int s,t,c;

    bool operator<(const channel& a) const
    {
        return t > a.t;
    }
};

int main()
{
    int n,c;
    cin >> n >> c;
    vector<channel> tv(n);
    for(int i = 0; i < n; i++)
    {
        cin >> tv[i].s >> tv[i].t >> tv[i].c;
    }

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

    // printf("\n");
    // printf("\n");
    // for(int i = 0; i < n; i++)
    // {
    //     cout << tv[i].s << " " << tv[i].t << endl;
    // }
    // printf("\n");
    // printf("\n");

    vector<channel> sol;

    sol.push_back(tv[0]);

    for(int i = 1; i < n; i++)
    {
        int j = 0;
        while(1)
        {
            if (j >= sol.size())
            {
                sol.push_back(tv[i]);
                break;
            }
            if (sol[j].c == tv[i].c)
            {
                sol[j] = tv[i];
                break;
            }else
            {
                if (sol[j].s > tv[i].t)
                {
                    sol[j] = tv[i];
                    break;
                }else
                {
                    j++;
                }
            }
        }
    }

    // for(int i = 0; i < sol.size(); i++)
    // {
    //     cout << i+1 << "   " << sol[i].s << " "  << sol[i].t << endl;
    // }

    cout << sol.size() << endl;

    return 0;
}

Measured memory_bytes: 1408
<?php
fscanf(STDIN, "%d %d", $l, $n);
$input = array();
for ($i = 0; $i < $l; $i++) {
    fscanf(STDIN, "%s", $data);
    $input[] = substr($data, 0, $n);
}
sort($input);
foreach($input as $data) {
    echo $data;
}
?>

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

int main()
{
  int n;
  cin >> n;
  
  int p[n];
  for(int i = 0; i < n; i++){
    cin >> p[i];
  }
  
  int ans = 0;
  for(int i = 1; i < n-1; i++){
    if( ((p[i-1] < p[i]) && (p[i] < p[i+1])) || ((p[i-1] > p[i]) && (p[i] > p[i+1])) ){
      ans++;
    }
  }
      
   cout << ans << endl;   
}

Measured memory_bytes: 3560
//AOJ0523

#include <iostream>

int main(){
	int n;
	while (std::cin >> n, n){
		int taro[201], hanako[201];
		for (int i = 0; i < 201; ++i)taro[i] = 0, hanako[i] = 0;
		for (int i = 0; i < n; ++i){
			int a;
			std::cin >> a;
			taro[a] = 1;
		}
		for (int i = 1; i <= 2 * n; ++i){
			if (taro[i] != 1)hanako[i] = 1;
		}
		int t = n, h = n;
		int ba = 0;
		char turn = 't';
		bool f = true;
		while (t > 0 && h > 0){
			switch (turn){
			case 't':
				f = true;
				for (int i = 0; i <= n * 2; ++i){
					if (ba < i && taro[i] == 1){
						t--;
						ba = i;
						taro[i] = 0;
		//				std::cout << i << std::endl;

						f = false;
						break;
					}
				}
				if (f)ba = 0;
				turn = 'h';
				break;
			case 'h':
				f = true;
				for (int i = 0; i <= n * 2; ++i){
					if (ba < i && hanako[i] == 1){
						h--;
						ba = i;
						hanako[i] = 0;
	//					std::cout << i << std::endl;
						f = false;
						break;
					}
				}
				if (f)ba = 0;
				turn = 't';
				break;
			}
		}
		std::cout << h << std::endl;
		std::cout << t << std::endl;
	}
	//system("pause");
}

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

int main() {
  int K,S;
  cin>>K>>S;
  
  int sum=0;
  for(int i=0;i<=K;i++){
    for(int j=0;j<=K;j++){
      if(i+j>S){
      }
      else{
        if(K>=S-i-j){
        sum+=1;
        }
      }
    }
  }
  cout<<sum<<endl;
}
   

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

long long int break_time[200000];
long long int length[200000];

typedef pair<int, int> P;

int main(){
	
	int N, L;
	
	cin >> N >> L;
	
	for(int i = 0; i <= N + 1; i++){
		break_time[i] = -1;
	}
	
	vector<P> v;
	
	for(int i = 1; i <= N; i++){
		cin >> length[i];
		P p;
		p.first = length[i];
		p.second = i;
		v.push_back(p);
	}
	
	sort(v.begin(), v.end());
	
	for(int i = N - 1; i >= 0; i--){
		P p = v[i];
		int index = p.second;
		int rest = L - length[index];
		if(break_time[index - 1] == -1 && break_time[index + 1] == -1){
			break_time[index] = rest;
		}else{
			break_time[index] = rest + max(break_time[index - 1], break_time[index + 1]);
		}
	}
	
	long long int ans = -1;
	
	for(int i = 1; i <= N; i++){
		if(ans < break_time[i]){
			ans = break_time[i];
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 5368
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long n,m,sum=0,a;
  cin >> n >> m;
  for(long i=0;i<m;i++){
    cin >> a;
    sum +=a;
  }
  if (sum > n){
    cout << -1 << endl;
  } else {
    cout << (n - sum) << endl;
  }
}

Measured memory_bytes: 3640
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
	"strings"
)

type Card struct {
	Mark string
	Num int
}

func main() {
	var n int
	fmt.Scan(&n)

	sc := bufio.NewScanner(os.Stdin)
	cards := make([]Card, n)
	cards2 := make([]Card, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		arr := strings.Split(sc.Text(), " ")
		num, _ := strconv.Atoi(arr[1])
		cards[i] = Card{arr[0], num}
		cards2[i] = Card{arr[0], num}
	}

	quickSort(&cards, 0, len(cards)-1)
	mergeSort(&cards2, 0, len(cards))

	stable := true
	for i := 0; i < n; i++ {
		if cards[i].Mark != cards2[i].Mark {
			stable = false
			break
		}
	}

	if stable {
		fmt.Println("Stable")
	} else {
		fmt.Println("Not stable")
	}

	for i := 0; i < n; i++ {
		fmt.Println(cards[i].Mark, cards[i].Num)
	}
}

func quickSort(a *[]Card, p, r int) {
	if p < r {
		q := partition(a, p, r)
		quickSort(a, p, q-1)
		quickSort(a, q+1, r)
	}
}

func partition(a *[]Card, p, r int) int {
	x := (*a)[r].Num
	i := p
	for j := p; j < r; j++ {
		if (*a)[j].Num <= x {
			(*a)[i], (*a)[j] = (*a)[j], (*a)[i]
			i++
		}
	}
	(*a)[i], (*a)[r] = (*a)[r], (*a)[i]
	return i
}

func mergeSort(a *[]Card, l, r int) {
	if l + 1 < r {
		m := (l + r) / 2
		mergeSort(a, l, m)
		mergeSort(a, m, r)
		merge(a, l, m, r)
	}
}

func merge(a *[]Card, l, m, r int) {
	ll := append([]Card{}, (*a)[l:m]...)
	rr := append([]Card{}, (*a)[m:r]...)

	// 番兵
	ll = append(ll, Card{"-", 1 << 30})
	rr = append(rr, Card{"-", 1 << 30})

	i, j := 0, 0
	for k := l; k < r; k++ {
		if ll[i].Num <= rr[j].Num {
			(*a)[k] = ll[i]
			i++
		} else {
			(*a)[k] = rr[j]
			j++
		}
	}
}



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

int N;
int r[105];
int s[105], p[105], c[105];
int inits, initp, initc;

void initialize() {
    s[1] = inits;
    p[1] = initp;
    c[1] = initc;
}

bool clear() {
    //cerr << s[1] << " " << p[1] << " " << c[1] << endl;
    vector<int> score(N + 1);
    vector<int> ss(N), ps(N), cs(N);
    for(int i = 1; i <= N; i++) {
        ss[i-1] = -s[i];
        ps[i-1] = -p[i];
        cs[i-1] = -c[i];
    }
    sort(ss.begin(), ss.end());
    sort(cs.begin(), cs.end());
    sort(ps.begin(), ps.end());
    for(int i = 1; i <= N; i++) {
        auto itr = lower_bound(ss.begin(), ss.end(), -s[i]);
        int rank = distance(ss.begin(), itr) + 1;
        score[i] -= r[rank];
        //cerr << "s rank " << rank << endl;
        itr = lower_bound(cs.begin(), cs.end(), -c[i]) + 1;
        rank = distance(cs.begin(), itr);
        score[i] -= r[rank];
        itr = lower_bound(ps.begin(), ps.end(), -p[i]) + 1;
        rank = distance(ps.begin(), itr);
        score[i] -= r[rank];
   }
   int myscore = score[1];
   sort(score.begin(), score.end());
   auto itr = lower_bound(score.begin(), score.end(), myscore);
   if (distance(score.begin(), itr) <= 7) return true;
   else return false;
}

int main() {
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> r[i];
    for(int i = 1; i <= N; i++) cin >> s[i] >> p[i] >> c[i];
    inits = s[1];
    initp = p[1];
    initc = c[1];
    int ans = 1e9;
        while(!clear()) {
            //cerr << "CALLING S" << endl;
            if(s[1] > 100) break;
            s[1]++;
        }
        if(s[1] <= 100) ans = min(ans, s[1] - inits);
        initialize();
        while(!clear()) {
            //cerr << "CALLING C" << endl;
            if(c[1] > 100) break;
            c[1]++;
        }
        if(c[1] <= 100) ans = min(ans, c[1] - initc);
        initialize();
        while(!clear()) {
            //cerr << "CALLING P" << endl;
            if(p[1] > 100) break;
            p[1]++;
        }
        if(p[1] <= 100) ans = min(ans, p[1] - initp);
        initialize();
    if(ans == 1e9) {
        cout << "Saiko" << endl;
        return 0;
    }
    cout << ans << endl;
}


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

int main(){
	int n;
	cin >> n;
	set<string> s;
	for(int i = 0;i<n;i++){
		string r;
		cin >> r;
		s.insert(r);
	}
	cout << s.size() << "\n";
}

Measured memory_bytes: 19152
import numpy as np

n, m = [int(i) for i in input().split()]

N, M = [], []
for i in range(n):
    N.append(list(input()))
for i in range(m):
    M.append(list(input()))

N, M = np.array(N), np.array(M)

# print(N)
# print(M)

def match():
    for i in range(n - m + 1):
        for j in range(n - m + 1):
            # print(i, i+m, j, j+m)
            if (N[i:i+m, j:j+m] == M).all():
                return "Yes"
    return "No"

print(match())

Measured memory_bytes: 18072
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

int N,M;
list<long long int>ans;

int main() {
	ios::sync_with_stdio(false);
	cin >> N >> M;
	vector<vector<int>>a(2, vector <int>(4));
	while (N) {
		long long int dp[152][100][10];
		vector<vector<int>>stone(N + 1);
		vector<int>have(N + 2);
		for (int i = 1; i <= N; i++) {
			int a;
			cin >> a;
			have[i] = a;
			for (int j = 0; j < a; j++) {
				int b, c;
				cin >> b >> c;
				stone[i].push_back(b);
				stone[i].push_back(c);
			}
			//cout << "hijiki";
		}
		for (int i = 1; i <= N; i++) {
			for (int j = 0; j <= M; j++) {
				for (int k = 0; k < 10; k++)dp[i][j][k] = INT_MAX;
			}
		}
		//cout << "hijiki";
		for (int i = 0; i < have[1]; i++) {
			dp[1][0][i] = 0;
		}
		if (M) {
			for (int i = 0; i < have[2]; i++) {
				dp[2][1][i] = 0;
			}
		}
	//	cout << "hijiki";
		for (int i = 1; i < N; i++) {
			for (int j = 0; j <= M; j++) {
				for (int k = 0; k < have[i]; k++) {
					for (int l = 0; l < have[i + 1]; l++) {
						if(j)dp[i + 1][j][l] = min(dp[i + 1][j][l], dp[i + 1][j][l]);
						dp[i + 1][j][l] = min(dp[i + 1][j][l], dp[i][j][k] + (stone[i][k * 2 + 1] + stone[i + 1][l * 2 + 1])*(abs(stone[i][k * 2] - stone[i + 1][l * 2])));
					}
					if (j != M) {
						for (int l = 0; l < have[i + 2]; l++) {
							dp[i + 2][j + 1][l] = min(dp[i + 2][j][l], dp[i + 2][j + 1][l]);
							dp[i + 2][j + 1][l] = min(dp[i + 2][j + 1][l], dp[i][j][k] + (stone[i][k * 2 + 1] + stone[i + 2][l * 2 + 1])*(abs(stone[i][k * 2] - stone[i + 2][l * 2])));
						}
					}
				}
			}
		}
		long long int box = INT_MAX;
		for (int i = 0; i < M; i++) {
			for (int j = 0; j < have[N - 1]; j++) {
				box = min(box, dp[N - 1][i][j]);
			}
		}
		for (int i = 0; i <= M; i++) {
			for (int j = 0; j < have[N]; j++) {
				box = min(box, dp[N][i][j]);
			}
		}
		//for (int i = 1; i <= N; i++) {
		//	for (int j = 0; j <= M; j++) {
		//		for (int k = 0; k < have[i]; k++) {
		//			//cout << i << " " << j << " " << k << " " << dp[i][j][k] << endl;
		//		}
		//	}
		//}
		ans.push_back(box);
		cin >> N >> M;
	}
	for (auto i : ans)cout << i << endl;
	return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

ll dp[2010][710];
ll mod = 1e9+7;

int main(){
    rep(i,2010){
        rep(j,710){
            dp[i][j] = 0;
        }
    }
    dp[3][1] = 1;


    int s;
    cin >> s;
    reps(i,4,2010){
        rep(j,701){
            dp[i][j] = dp[i-1][j];
            if(i-3>=0 && j>=1)  dp[i][j] = (dp[i][j] + dp[i-3][j-1]) % mod;
        }
    }

    
    ll ans = 0;
    rep(i,700){
        ans = (ans + dp[s][i] ) % mod; 
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14752
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
inp = sys.stdin.buffer.readline
def inpS(): return inp().rstrip().decode()
readlines = sys.stdin.buffer.readlines 
 

def resolve():
    N, A, B, C = map(int, inp().split())
    S = [inpS() for _ in range(N)]
 
    ans = []
    def dfs(now, a, b, c):
        if now == N:
            return True
        if S[now] == "AB":
            if a == 0 and b == 0:
                return False
            if 0 < a and dfs(now+1, a-1, b+1, c):
                ans.append("B")
                return True
            if 0 < b and dfs(now+1, a+1, b-1, c):
                ans.append("A")
                return True
            return False
        if S[now] == "AC":
            if a == 0 and c == 0:
                return False
            if 0 < a and dfs(now+1, a-1, b, c+1):
                ans.append("C")
                return True
            if 0 < c and dfs(now+1, a+1, b, c-1):
                ans.append("A")
                return True
            return False
        if S[now] == "BC":
            if c == 0 and b == 0:
                return False
            if 0 < b and dfs(now+1, a, b-1, c+1):
                ans.append("C")
                return True
            if 0 < c and dfs(now+1, a, b+1, c-1):
                ans.append("B")
                return True
            return False
 
    dfs(0, A, B, C)
    if len(ans) == 0:
        print("No")
        return
    else:
        print("Yes")
        [print(a) for a in ans[::-1]]
 
 
if __name__ == "__main__":
    resolve()

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(int i = 0; i < n; ++i)
  {
    cin >> a[i];
  }
  sort(ALL(a));
  ll ans = accumulate(ALL(a), 0LL);
  if (ans % 10 == 0)
  {
	for(int i = 0; i < n; ++i)
	{
	  if (a[i] % 10 != 0)
	  {
	    ans -= a[i];
		cout << ans;
		return;
	  }
	}
  }
  cout << (ans % 10 == 0 ? 0 : ans);
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
long long n,x[111111],p[111111],y[111111],siz[111111],cir[111111],m,k,sum;
bool vis[111111];
int main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&x[i]),p[i]=i,y[i]=x[i]-x[i-1];
	scanf("%lld%lld",&m,&k);
	for(int i=1,a;i<=m;i++)scanf("%lld",&a),swap(p[a],p[a+1]);
	for(int i=1,c,pos,cnt=0;i<=n;i++)if(!vis[i]){
		++cnt,c=0,pos=i;
		while(!vis[pos])vis[pos]=1,cir[pos]=cnt,++c,pos=p[pos];
		siz[cnt]=c;
	}
	for(int i=1;i<=n;i++){
		int t=k%siz[cir[i]],pos=i;
		while(t--)pos=p[pos];
		printf("%lld.0\n",y[pos]+sum),sum+=y[pos];
	}
}


Measured memory_bytes: 5632
import java.math.BigInteger;
import java.util.*;

public class Main {

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

        String str = scanner.next();
        char[] s = str.toCharArray();
        int n = s.length;
        int p = 2019;

        long ans = 0;
        int now = 0;
        int base = 1;
        int[] cnt = new int[p];
        cnt[0] = 1;

        for (int i = n - 1; i >= 0; i--) {
            int x = Integer.parseInt(String.valueOf(s[i]));
            x *= base;
            x %= p;
            now += x;
            now %= p;
            ans += cnt[now];
            cnt[now]++;
            base *= 10;
            base %= p;
        }

        System.out.println(ans);

    }

}

Measured memory_bytes: 50032