akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <set>
using namespace std;
set<int>s[11];
int n,cnt_r[2],cnt_c[2],cnt_s[2];
struct node
{
    int r,c,s,w;
}p[11],q[11];
int cal(char *s)
{
    int cnt=0;
    for(int i=0;s[i];i++)
    {
        if(s[i]!='.') break;
        cnt++;
    }
    return cnt;
}
bool check(int R,int C,int S)
{
    for(int i=0;i<n;i++)
    {
        int v=R*p[i].r+C*p[i].c+S*p[i].s;
        if(v!=p[i].w) return false;
    }
    return true;
}
int main()
{
    int m;
    while(scanf("%d%d",&n,&m)==2)
    {
        if(n==0&&m==0) break;
        memset(cnt_r,0,sizeof(cnt_r));
        memset(cnt_c,0,sizeof(cnt_c));
        memset(cnt_s,0,sizeof(cnt_s));
        char a[111];
        for(int i=0;i<n;i++)
        {
            scanf("%s",a);
            if(i==0)
            {
                p[i].r=0;
                p[i].c=0;
                p[i].s=0;
                p[i].w=0;
            }
            else
            {
                p[i].w=cal(a);
                p[i].r=cnt_r[0]-cnt_r[1];
                p[i].c=cnt_c[0]-cnt_c[1];
                p[i].s=cnt_s[0]-cnt_s[1];
            }
            for(int j=0;a[j];j++)
            {
                if(a[j]=='(') cnt_r[0]++;
                else if(a[j]==')') cnt_r[1]++;
                     else if(a[j]=='{') cnt_c[0]++;
                          else if(a[j]=='}') cnt_c[1]++;
                               else if(a[j]=='[') cnt_s[0]++;
                                    else if(a[j]==']') cnt_s[1]++;
            }
        }
        memset(cnt_r,0,sizeof(cnt_r));
        memset(cnt_c,0,sizeof(cnt_c));
        memset(cnt_s,0,sizeof(cnt_s));
        char b[111];
        for(int i=0;i<m;i++)
        {
            scanf("%s",b);
            if(i==0)
            {
                q[i].r=0;
                q[i].c=0;
                q[i].s=0;
            }
            else
            {
                q[i].r=cnt_r[0]-cnt_r[1];
                q[i].c=cnt_c[0]-cnt_c[1];
                q[i].s=cnt_s[0]-cnt_s[1];
            }
            for(int j=0;b[j];j++)
            {
                if(b[j]=='(') cnt_r[0]++;
                else if(b[j]==')') cnt_r[1]++;
                     else if(b[j]=='{') cnt_c[0]++;
                          else if(b[j]=='}') cnt_c[1]++;
                               else if(b[j]=='[') cnt_s[0]++;
                                    else if(b[j]==']') cnt_s[1]++;
            }
        }
        for(int i=0;i<=10;i++) s[i].clear();
        for(int i=1;i<=20;i++)
            for(int j=1;j<=20;j++)
                for(int k=1;k<=20;k++)
                {
                    if(!check(i,j,k)) continue;
                    for(int t=0;t<m;t++) s[t].insert(i*q[t].r+j*q[t].c+k*q[t].s);
                }
        set<int>::iterator it;
        if(s[0].size()!=1) printf("-1");
        else printf("%d",*(s[0].begin()));
        for(int i=1;i<m;i++)
        {
            printf(" ");
            if(s[i].size()!=1) printf("-1");
            else printf("%d",*(s[i].begin()));
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1208
#include <stdio.h>

int main(){
  int n,u,v,A[101][101],i,j,k;
  scanf("%d",&n);
  for(i=87;i<=n;i++)
    for(j=1;j<=n;j++)
      A[i][j]=0;
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      A[u][v]=1;
    }
  }
  for(i=1;i<=n;i++){
    for(j=1;j<n;j++){
      if(A[i][j]==1)
	printf("1 ");
      else printf("0 ");
    }
    if(A[i][n]==1)
      printf("1\n");
    else printf("0\n");
  }
  return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
using ll = long long;
using P = pair<ll,ll>;
#define PI 3.141592653589793238
 
int main (){
  double n;cin>>n;
  cout <<fixed << setprecision(10)<< 2*n*PI << endl;
}

Measured memory_bytes: 3776
#include <iostream>

using namespace std;

namespace {
size_t count(size_t n, size_t m)
{
    if (n > m) {
        swap(n, m);
    }
    if (n == 1) {
        if (m == 1) {
            return 1;
        } else {
            return m - 2;
        }
    }
    return (n - 2) * (m - 2);
}
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    size_t n, m;
    cin >> n >> m;
    cout << count(n, m) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int  long long 
#define speedrap ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int be(int a,int b,int mod) {if(b == 0) return 1; if(b%2 == 1) return (a*be(a,b-1,mod))%mod; else return (be(a,b/2,mod)*be(a,b/2,mod))%mod;}
const int mod = 1e9+7;
#define PI 3.14159265359
#define pf push_front
#define pb push_back
#define bitcount __builtin_popcount
#define sc(a) scanf("%d", &a);
#define sz(s) (int)s.size()
#define eb emplace_back
#define pf push_front
#define mkp(x,y) make_pair(x,y)
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
const int siz = 2*(2500 + 1);
const int logi = 21;
const double epsilon = 1e-6;
int prime[siz];
bool cmp(const int &a,const int &b)
{
  return (abs(a-b)>1);
}

signed main()
{
	#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#else
// online submission
	#endif 
	speedrap
	int t;
	t = 1;
	//cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		double n1 = (double) n ;
		n1 *= 2.0;
		n1 *= PI;
		std::cout << std::fixed;
    std::cout << std::setprecision(2);
    std::cout << n1;
}
}

Measured memory_bytes: 3804
import sys
import numpy as np

input = sys.stdin.readline
n,m = map(int, input().split())
ls = np.zeros([n,n])
for _ in range(m):
    a, b = map(int, input().split())
    if ls[a-1][b-1] == 0:
        ls[a-1][b-1] = 1
        ls[b-1][a-1] = 1

def dfs(a, visitedls):
    visitedls.append(a)
    for b in range(1,n+1):
        if ls[a-1][b-1] == 1 and b not in visitedls:
            dfs(b, visitedls)

def main():
    ans = 0
    for i in range(n):
        for j in range(n):
            if ls[i][j] == 1:
                ls[i][j] = 0
                visitedls = []
                dfs(i+1, visitedls)
                if len(visitedls) != n:
                    ans += 1
                ls[i][j] = 1
    print(int(ans/2))



if __name__ == "__main__":
    main()

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

const int INF = 1000000;

int c[10][1005];

int main() {
    int H, W, K;
    cin >> H >> W >> K;

    vector<string> S(H);
    rep(i, H) cin >> S[i];
    int ans = INF;

    rep(div, 1 << (H - 1)) {
        int g = 0;
        vector<int> id(H);
        rep(i , H) {
            id[i] = g;
            if (div >> i & 1) ++g;
        }
        ++g;
        rep(i, g)rep(j, W) c[i][j] = 0;
        rep(i, H)rep(j, W) c[id[i]][j] += (S[i][j] - '0');
        bool ok = true;
        rep(i, g)rep(j, W) if (c[i][j] > K) ok = false;
        if (!ok) continue;

        int num = g - 1;
        vector<int> now(g);
        auto add = [&](int j) {
            rep(i, g) now[i] += c[i][j];
            bool ok = true;
            rep(i, g) if (now[i] > K) return false;
            return true;
        };
        rep(j, W) {
            if (!add(j)) {
                num++;
                now = vector<int>(g);
                add(j);
            }
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
map<int,int>c;
int a[100001],b[100001],d[100001],i,j,k,n,m,x,y,z;
int main() {
	cin>>n;
	for(i=1; i<=n; i++) {
		scanf("%d",&a[i]);
		d[i]=a[i];
	}
	sort(d+1,d+n+1);
	for(i=1; i<=n; i++)c[d[i]]=i;
	for(i=1; i<=n; i++)a[i]=c[a[i]],b[a[i]]=i;
	for(i=1;i<=n;i++)
	if(i%2!=b[i]%2)m++;
	cout<<m/2<<endl;
}

Measured memory_bytes: 6144
#include <cstdio>
#include <cmath>
#include <complex>
#include <vector>

#define MAX 101
#define EPS 1e-5

typedef std::complex<double> P;
P p[MAX];

int n;

std::vector<P> point(P a, P b){
    std::vector<P> res;

    if(std::abs(std::abs(b - a) - 2.0) < EPS){
        P c = a + b;
        res.push_back(P(c.real() / 2, c.imag() / 2));
    }else if(abs(b - a) < 2.0){
        P xx = b - a;
        P ce = a + P(xx.real() / 2, xx.imag() / 2);
        P no1 = (xx * P(0, +1)) / std::abs(xx);
        P no2 = (xx * P(0, -1)) / std::abs(xx);
        double dis = sqrt(1 - pow(std::abs(xx) / 2, 2));
        P c = ce + no1 * dis;
        P q = ce + no2 * dis;

        res.push_back(c);
        res.push_back(q);
    }

    return res;
}

int main(){
    while(scanf("%d", &n)){
        if(n == 0) break;

        for(int i = 0; i < n; i++){
            double a, b;
            scanf("%lf,%lf", &a, &b);

            p[i] = P(a, b);
        }

        int ans = 1;
        for(int i = 0; i < n; i++){
            for(int j = i + 1; j < n; j++){
                std::vector<P> v = point(p[i], p[j]);

                if(v.empty()) continue;

                int cnt1 = 2, cnt2 = 2;
                for(int k = 0; k < n; k++){
                    if(k == i || k == j) continue;
                    if(std::abs(v[0] - p[k]) - 1.0 < EPS){ cnt1++; }
                    if(v.size() == 2 && std::abs(v[1] - p[k]) - 1.0 < EPS){ cnt2++; }
                }
                ans = std::max(ans, std::max(cnt1, cnt2));
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 2744
def main():
    N = int(input())

    i = 1
    out = 0
    while i*i <= N:
        if N%i == 0 and i < N//i-1:
            out += (N//i - 1)
        i += 1
    print(out)
    return

if __name__ == '__main__':
    main()


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  map<int, ll> mp;
  rep(i, n) mp[a[i]]++;
  ll ans = 0;
  for (auto m : mp) {
    if (2 <= m.second) {
      ans += (m.second * (m.second - 1) / 2);
    }
  }
  dump(mp);
  dump(ans);
  rep(i, n) {
    ll cnt1 = 0;
    ll cnt2 = 0;
    ll x = mp[a[i]];
    if (2 <= x) cnt1 = (x * (x - 1) / 2);
    x--;
    if (2 <= x) cnt2 = (x * (x - 1) / 2);
    cout << ans - cnt1 + cnt2 << endl;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

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

using namespace std;

#define int long long

const int N = 2e5 + 5;
int n, le, ri;
pair <int, int> a[N];
multiset <int> s;

main() {
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n;
  le = 1e9;
  for(int i = 1; i <= n; ++i) {
    int u, v;
    cin >> u >> v;
    if(u > v) swap(u, v);
    a[i] = make_pair(u, v);
    le = min(le, u);
    ri = max(ri, v);
    s.insert(u);
  }
  int mi = 1e9, ma = 0;
  for(int i = 1; i <= n; ++i) {
    ma = max(ma, a[i].first);
    mi = min(mi, a[i].second);
  }
  int ans = (ma - le) * (ri - mi);
  sort(a + 1, a + n + 1);
  ans = min(ans, (*s.rbegin() - *s.begin()) * (ri - le));
  for(int i = 1; i <= n; ++i) {
    s.erase(s.find(a[i].first));
    s.insert(a[i].second);
     ans = min(ans, (*s.rbegin() - *s.begin()) * (ri - le));
  }
  cout << ans;
}


Measured memory_bytes: 14876
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n, k, a, b = 0; cin >> n >> k;
	int dp[123432] = { 0 }, test[123456] = { 0 };
	for (int h = 0; h < 123432; h++) {
		dp[h] = 1;
	}
	for (int h = 0; h < k; h++) {
		cin >> a; test[h] = a;
		if (test[h - 1] + 1 == test[h]) {
			cout << 0 << endl; return 0;
		}
	}
	for (int h = 1; h <= n; h++) {
		if (h == test[b]) {
			b++; dp[h] = 0;
		}
		else if (h != 1) {
			dp[h] = dp[h - 2] + dp[h - 1];
			dp[h] = dp[h] % 1000000007;
		}
	}
	if (test[k - 1] == n) {
		cout << dp[n - 1] << endl; return 0;
	}
	cout << dp[n] << endl;
	cin >> n;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
const int d[]={1,-1};
int n,m;
ll x[1010],y[1010],z[1010],a[1010],ans=0;
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	cin>>n>>m;
	fo(i,0,n)cin>>x[i]>>y[i]>>z[i];
	fo(x1,0,2) fo(x2,0,2) fo(x3,0,2){
		memset(a,0,sizeof(a));
		fo(i,0,n)a[i]=x[i]*d[x1]+y[i]*d[x2]+z[i]*d[x3];
		sort(a,a+n);
		ll g=0;
		fo(i,0,m)g+=a[n-i-1];
		if(g>ans)ans=g;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



int main() {
    
    string str;
    cin >> str;
    
    rep(i, sz(str)) {
        if (i % 2 != 0) {
            if (str[i] != 'L' && str[i] != 'U' && str[i] != 'D') {
                cout << "No" << endl;
                return 0;
            }
            
        } else {
            if (str[i] != 'R' && str[i] != 'U' && str[i] != 'D') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
#include <string.h>
#include <cstring>
#include <stack>
#include <queue>

typedef long long ll;
#define ALL(obj) (obj).begin(),(obj).end()
#define MOD 1000000007


using namespace std;

long long GCD(long long x, long long y){
   long long r, tmp;
   if(x < y){
       tmp = x;
       x = y;
       y = tmp;
   }
   while(y!=0){
       r = x%y;
       x = y;
       y = r;
   }
   return x;
}
long long LCM(long long x, long long y){
   long long lcm = (x*y)/GCD(x, y);
   return lcm;
}

int bubblesort(int n){
    vector<int> data(n);
    int num=0;
    for(int end = n-1; end>0; end--){
        for(int j=0; j<end; j++){
            if(data[j+1] < data[j]){
                int temp = data[j];
                data[j] = data[j+1];
                data[j+1] = temp;
                num++;
            }
        }
    }
    return num;
}



int main(){
    char s[1000];
    cin >> s;
    int ln = strlen(s);
    if(s[ln-1]=='s'){
        cout << s << "es" << endl;
    }
    else cout << s << "s" << endl;
    return 0;
}


Measured memory_bytes: 3636
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vector<int, int> > vvi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    if(n>k){
        cout << k*x + y*(n-k);
    }
    else{
        cout << n*x;
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int i,a,b,c,ans;
    cin >> a >> b >> c;
    ans = 0;
    for(i=a;i<=b;i++)
    
    
    {
        if( c%i ==0 )
            ans = ans + 1;

    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3116
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		outside: for (int i = n;; i++) {
			for (int j = 2; j < n; j++) {
				if (i % j == 0) {
					continue outside;
				}
			}
			System.out.println(i);
			break;
		}
		
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>W(N);
  int min=10000;
  for(int i=0;i<N;i++){
cin>>W.at(i);
  }
  
  int sum=0;
  int sum1=0;
  
  for(int i=0;i<N-1;i++){
     int sum=0;
  int sum1=0;
  
    for(int j=0;j<i+1;j++){
      sum+=W.at(j);
    }
    for(int k=i+1;k<N;k++){
      sum1+=W.at(k);
    }
    
    if(abs(sum1-sum)<min){
min=abs(sum1-sum);
    }
  }
  cout<<min<<endl;
}

    
    
    

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define P 3.141592653589

int main(void){
    double r;
    double S,T;
    scanf("%lf",&r);
    
    if(r<=0||10000<=r){
        printf("error\n");
        return 0;
    }
    
    S=P*r*r;
    T=2*P*r;
    
    printf("%lf %lf\n",S,T);
    
    return 0;
}


Measured memory_bytes: 2104
#include<cstdio>
int main()
{
	int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        int x=100*a+10*b+c;
        x%=4;
        if(!x) printf("YES\n");
        else printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

#define PI 3.141592653589793

int main() {
  long double a, b, x; cin >> a >> b >> x;
  long double xx = x/a;
  long double yy = 2*xx/a - b;
  long double ans;
  if (xx < a*b/2) ans = atan(b*b/xx/2);
  else ans = atan((b-yy)/a);
  cout << setprecision(7) << (ans * 180 / PI) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using Graph=vector<vector<int>>;
using pp=pair<ll,pair<ll,ll>>;
#define MAX 1000000
#define MOD 1000000007
#define INF 1000000000000000000

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

  int dx[4]={1,0,-1,0};
  int dy[4]={0,1,0,-1};
  mf_graph<int> G(N*M+2);
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      if((i+j)%2==0){
        if(S[i][j]=='.'){
          G.add_edge(N*M,i*M+j,1);
          for(int k=0;k<4;k++){
            int ni=i+dx[k];
            int nj=j+dy[k];
            if(ni<0||nj<0||ni>=N||nj>=M){
              continue;
            }
            if(S[ni][nj]=='.'){
              G.add_edge(i*M+j,ni*M+nj,1);
            }
          }
        }
      }else{
        if(S[i][j]=='.'){
          G.add_edge(i*M+j,N*M+1,1);
        }
      }
    }
  }

  cout<<G.flow(N*M,N*M+1)<<endl;
  vector<mf_graph<int>::edge> a=G.edges();
  int n=a.size();
  for(int i=0;i<n;i++){
    if(a[i].from==N*M){
      continue;
    }
    if(a[i].to==N*M+1){
      continue;
    }
    if(a[i].flow==0){
      continue;
    }
    int i1=a[i].from/M;
    int j1=a[i].from%M;
    int i2=a[i].to/M;
    int j2=a[i].to%M;
    if(i1+1==i2){
      S[i1][j1]='v';
      S[i2][j2]='^';
    }else if(i1==i2+1){
      S[i1][j1]='^';
      S[i2][j2]='v';
    }else if(j1+1==j2){
      S[i1][j1]='>';
      S[i2][j2]='<';
    }else{
      S[i1][j1]='<';
      S[i2][j2]='>';
    }
  }

  for(int i=0;i<N;i++){
    cout<<S[i]<<endl;
  }
}


Measured memory_bytes: 5608
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String r = scan.nextLine();
		double rr = Double.parseDouble(r);
		double x = Math.PI;
		double area = rr * rr * x;
		double len = 2 * rr * x;
		System.out.printf("%f %f\n", area, len);
		
	}
}

Measured memory_bytes: 26448
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, K: int):
    if K == 1:
        print(0)
    else:
        print(N-K)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ln '\n';
int lim=1e6;
int inf=1e9+7;
int main()
{	
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll a,b,c;
	cin>>a>>b>>c;
	ll t=a+b;
	if(t<c){
		cout<<t+1+b<<ln;
	}else{
		cout<<c+b<<ln;
	}
}

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

int main(){
  char s[100];
  std::cin >> s;
  const int N = atoi(s);
  std::vector<int> numbers;
  for(int i = 0; i < N; i++) {
    std::cin >> s;
    numbers.push_back(atoi(s));
  }
  std::sort(numbers.rbegin(), numbers.rend());
  
  int count = 0;
  int psize = 10000;
  for(int i = 0; i < N; i++) {
    int size = numbers[i];
    if(psize > size) 
      count++;
    psize = size;
  }
  std::cout<<count<<std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
int main() {
	ll n, x, m,ans=0,flag=-1,pan=1,t=0,tt=0,k=150000;
	cin >> n >> x >> m;
	ll xx = x;
	for (ll i = 0; i < n; i++) {
		int p = 1;
		ans += x;
		x = x * x;	
		if (k > 1)k--;
		if (pan==1 &&flag==-1&&k==1)pan = 0, flag = x % m,p=0;
		x %= m;
		if (p && !pan && x == flag) {
			ll ttt = ((n - 1 - i) / tt);
			ans += ttt * t;
			i += ttt * tt;
			pan = 2;
			}
			else if (!pan) { t += x, tt++; }
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
// #define endl "\n"

ll left(ll i) {
    return 2*i+1;
}

ll right(ll i) {
    return 2*i + 2;
}

ll update(ll low, ll high, ll i, ll updatepos, ll updateval, vector<ll>& tree) {
    if (low == high) {
        return tree[i] = updateval;
    }

    ll mid = (low + high)/2;
    ll a, b;
    if (updatepos > mid) {
        a = tree[left(i)];
        b = update(mid+1, high, right(i), updatepos, updateval, tree);
    } else {
        a = update(low, mid, left(i), updatepos, updateval, tree);
        b = tree[right(i)];
    }
    return tree[i] = max(a, b);
}

ll query(ll low, ll high, ll i, ll l, ll r, vector<ll>& tree) {
    if (low > r || high < l) {
        return 0;
    }

    if (low >= l && high <= r) {
        return tree[i];
    }

    ll mid = (low+high)/2;
    ll a = query(low, mid, left(i), l, r, tree);
    ll b = query(mid+1, high, right(i), l, r, tree);
    return max(a, b);

}

int main(void) {
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);
    ll n;
    cin >> n;
    vector<ll> height (n);
    vector<ll> weight (n);
    for (ll i = 0; i < n; i++) {
        cin >> height[i];
    }
    for (ll i = 0; i < n; i++) {
        cin >> weight[i];
    }

    
    vector<ll> tree (4 * n + 10, 0);

    ll ans = 0;
    for (ll i = 0; i < n; i++) {
        ll prev = query(0, n, 0, 0, height[i]-1, tree);
        ll now = prev + weight[i];
        ans = max(ans, now);
        update(0, n, 0, height[i], now, tree);
    }
    cout << ans << endl;

    
    return 0;
}

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

//const double PI = acos(-1);
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second

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

    int n;
    cin >> n;
    int a[n];
    int mi = 0, mx = 0;
    REP(i,n) {
        cin >> a[i];
        mi = min(mi, a[i]);
        mx = max(mx, a[i]);
    }
    vector<pair<int,int>> ans;
    if (abs(mi) <= abs(mx)) {
        int p;
        REP(i,n) {
            if (a[i] == mx) p = i;
        }
        REP(i,n) {
            if (i == p) continue;
            ans.pb({p+1,i+1});
        }
        REP(i,n-1) {
            ans.pb({i+1,i+2});
        }
    } else {
        if (mx > 0) {
            int p;
            REP(i,n) {
                if (a[i] == mi) p = i;
            }
            REP(i,n) {
                if (i == p) continue;
                ans.pb({p+1,i+1});
            }
        }
        for (int i = n-1; i > 0; i--) {
            ans.pb({i+1,i});
        }
    }
    cout << ans.size() << endl;
    REP(i,sz(ans)) cout << ans[i].fi << ' ' << ans[i].se << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    int ans = 0;
    forn(i, 1, n+1) {
        string s = to_string(i);
        ans += SZ(s)&1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3688
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars
    }
    for (i,c) in s.into_iter().enumerate() {
        if (i+1) % 2 != 0 {
            print!("{}", c);
        }
    }
}


Measured memory_bytes: 4352
def depth(n):
    return 2**(n+2)-3

def totalp(n):
    return 2**(n+1)-1

def eat(n,x):
    if n == 0:
        return x
    elif x <= 1:
        return 0
    elif x >= depth(n)-1:
        return totalp(n)
    elif x == depth(n-1) + 2:
        return totalp(n-1) + 1
    elif x > depth(n-1)+2:
        return totalp(n-1) + 1 + eat(n-1,x-depth(n-1)-2)
    else:
        return eat(n-1,x-1)

(N,X) = map(int,input().split())
print(eat(N,X))

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

using namespace std;

int main() {
    int A, B;

    cin >> A >> B;

    int X = max(A, B);

    if(A == X) {
        A = A - 1;
    } else {
        B = B - 1;
    }

    X = X + max(A, B);

    cout << X << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;

typedef long long ll;

int
main(int argc, char *argv[])
{
  int n, d[1000];
  cin >> n;
  int x = 0, y = 0;
  rep(i, n) {
    cin >> d[i];
    x += d[i];
    y += d[i] * d[i];
  }
  cout << (x * x - y) / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
vector<int> X;
vector<int> Y;
vector<int> DX;
vector<int> DY;
int N;
double solve(double a)
{

	double mxx = -1e18;
	double mnx = 1e18;
	double mxy = -1e18;
	double mny = 1e18;


	for (int i = 0; i < N; i++)
    {
		double x = X[i] + a * DX[i];
		double y = Y[i] + a * DY[i];

		mxx = max(mxx, x);
		mnx = min(mnx, x);

		mxy = max(mxy, y);
		mny = min(mny, y);
	}

	return (mxx - mnx) * (mxy - mny);
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N;
	X.resize(N);
	Y.resize(N);
	DX.resize(N, 0);
	DY.resize(N, 0);
	char dd;
	for (int i = 0; i < N; i++)
    {
		cin >> X[i] >> Y[i] >> dd;

		if (dd == 'U')
        {
			DY[i] = 1;
		}
		else if (dd == 'D')
		{
			DY[i] = -1;
		}
		else if (dd == 'R')
		{
			DX[i] = 1;
		}
		else if (dd == 'L')
        {
			DX[i] = -1;
		}
	}
	double res = 1e18;

	double u = 1e9;
	double d = 0;

	for (int t = 0; t < 200; t++)
    {

		double uu = (u * 2 + d) / 3;
		double dd = (u + d * 2) / 3;

		double uv = solve(uu);
		double dv = solve(dd);
		res = min(res, uv);
		res = min(res, dv);
		if (dv < uv)
        {
			u = uu;
		}
		else
		{
			d = dd;
		}

	}


	cout << fixed << setprecision(15) << res << endl;
}


Measured memory_bytes: 3456
N = int(input())
flg = False
for i in range(N+1):
    if (i*(i+1))//2 == N:
        flg = True
        a = i
if flg == False:
    print('No')
    exit()
lis = [[0] * a for _ in range(a+1)]
p = 0
for i in range(a+1):
    for j in range(a):
        lis[i][j] = (i)*a+(j+1)-p
    p += (i+1)
#print(lis)
for i in range(1,a+1):
    for j in range(i):
        lis[i][j] = lis[j][i-1]
#print(lis)
print('Yes')
print(a+1)
for i in range(a+1):
    print(a,' '.join(map(str,lis[i])))






Measured memory_bytes: 75508
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
char s[200111];
int n,msk[200111];
int dp[200111];
map<int,int> mp;
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++)msk[i]=msk[i-1]^(1<<(s[i]-'a'));
	dp[0]=0;
	mp[0]=0;
	if(msk[n]==0)
	{
		cout<<1<<endl;
		return 0;
	}
	for(int i=1;i<=n;i++)
	{
		dp[i]=mod;
		for(int j=0;j<26;j++)
		{
			int tmp=msk[i]^(1<<j);
			if(mp.find(tmp)!=mp.end())
			{
				dp[i]=min(dp[i],mp[tmp]+1);
			}
		}
		if(mp.find(msk[i])==mp.end())mp[msk[i]]=dp[i];
		else mp[msk[i]]=min(mp[msk[i]],dp[i]);
	}
	cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 11520
#include<stdio.h>
#include<string.h>
#define LEN 100005
int min(int a, int b) {return a < b ? a : b;}

typedef struct pp
{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x)
{
  Q[tail] = x;
  if ( tail == LEN ) tail = 1;
  else tail++;
}

P dequeue()
{
  P x = Q[head];
  if ( head == LEN ) head = 1;
  else head++;
  return x;
}

int main()
{
  int elaps = 0, c, i, q;
  P u;
  scanf("%d %d", &n, &q);
  for ( i = 1; i <= n; i++) scanf("%s %d", Q[i].name, &Q[i].t);

  head = 1; tail = n+1;

  while( head != tail ){
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if ( u.t > 0 ) enqueue(u);
    else 
    {
      printf("%s %d\n",u.name, elaps);
    }
  }
  
  return 0;
}



Measured memory_bytes: 11948
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int y=k;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  int c=0;
  for(;;){
    c++;
    if(k>=n)
      break;
    else{
      k+=y-1;
      continue;
    }
  }
  cout<<c<<endl;
}

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

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define ull unsigned long long 
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll; 
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ;
// int ab  (int  x ) { return (x>0?x:-x); }
const int N = 1e5+5 ; 
const ll mod = 1e9+7 ; 
ll dp[N][2] ; 
vector<int> adj[N]; 
void dfs(int u,int p){

	ll WHITE = 1 , WB = 1 ; 
	bool canPaintBlack = 1 ; 
	for(int v : adj[u]){
		if(v!=p){
			dfs(v,u);	
			WB *= (dp[v][1] + dp[v][0])%mod ;
			WB %= mod ;
			WHITE *= dp[v][0] ;
			WHITE %=mod;
		
		}
	} 
	dp[u][1] = WHITE ; 
	dp[u][0] = WB; 
}

int main(){
int n ; 
cin >> n ; 
for(int i = 1 ; i < n ; i++ ){
	int u , v ; 
	cin >> u >> v; 
	adj[u].pb(v); 
	adj[v].pb(u) ;
}

dfs(1,0);
// for(int i =1 ; i<= n ; i++ )cout << " i "<<i << " white "<<dp[i][0]<<" black "<<dp[i][1]<<endl; 
cout << (dp[1][0]+dp[1][1])%mod << endl; 
}

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

#define MOD 1000000007

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


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const vector<vector<T>>&obj) {
    o << "[" << endl; for (int i = 0; i < (int)obj.size(); ++i) o << "  " << obj[i] << endl; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const queue<T>&obj) {
    queue<T> obj_cp = obj;
    bool first = true;
    o << "{";
    while (!obj_cp.empty()) { o << (!first ? ", " : "") << obj_cp.front(); obj_cp.pop(); first = false; }
    o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}


int main(int argc, char const *argv[]) {
    int A, B;
    cin >> A >> B;
    cout << A * B << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;

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

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

    int L[N];
    REP(0, i, N) {
        cin >> L[i];
    }

    sort(L, L + N);

    int acc = 0;
    REP(0, i, N) {
        acc += L[i];
    }

    if (acc > 2 * L[N - 1]) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int sort(const void *a, const void *b){
    return *(int*)a-*(int*)b ;
}

int main(void){
    int n,ans=0,count=0;
    scanf("%d",&n);
    int a[n];
    for (int i=0; i<n; i++){
        scanf("%d",&a[i]);
    }
    qsort (a,n,sizeof(int),sort);
    for (int i=1; i<n; i++){
        if (a[i]==a[i-1]){
            count++;
        }
    }
    ans=n-((count+1)/2)*2;
    printf("%d\n",ans);
	return 0 ;
}

Measured memory_bytes: 892
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

#define pb push_back

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

#define MOD(x, y) (((y) + (x) % (y)) % (y))

int N, K;
int ar[200001];

int main(int argc, char* argv[])
{
	scanf("%d%d", &N, &K);
	for (int i = 0; i < N; i++) {
		int t;
		scanf("%d", &t);
		ar[t]++;
	}

	sort(ar, ar + 200001, greater<int>());

	int sum = 0;
	for (int i = 0; i < K; i++) {
		sum += ar[i];
	}

	printf("%d\n", N - sum);

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
bool flag[250000] = {};

int main() {

  flag[0] = true;
  flag[1] = true;

  for ( long long int i = 2; i < 250000; i++ ) {

    if ( flag[i] == false ) {
      for ( long long int j = 2; j * i < 250000; j++ ) {
	flag[ j*i ] = true;
      }
    }

  }

  long long int n;

  while( true ) {

    cin >> n;

    if ( n == 0 ) break;

    long long int ans = 0;

    for ( long long int i = n + 1; i <= 2 * n; i++ ) {

      if ( flag[i] == false ) ans++;

    }

    cout << ans << endl;

  }

  return 0;

}

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

char S[200005];

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


	fread(S, 1, 200005, stdin);
	int L = 0, R = 200005;
	while (L + 1 < R) {
		int M = (L + R) / 2;
		if (S[M] >= '0') L = M;
		else R = M;
	}

	int N = R;
	int a = 0;
	int A[2020] = {};
	A[0] = 1;

	ll kotae = 0;
	int tmp = 0;
	int are = 1;
	int shou = N / 5;
	int i = N - 1;
	int amari = N % 5;
	rep(j, shou) {
		tmp += (S[i--] - '0') * are;
		tmp %= 2019;
		kotae += A[tmp]++;
		are *= 10;

		tmp += (S[i--] - '0') * are;
		tmp %= 2019;
		kotae += A[tmp]++;
		are *= 10;

		tmp += (S[i--] - '0') * are;
		tmp %= 2019;
		kotae += A[tmp]++;
		are *= 10;

		tmp += (S[i--] - '0') * are;
		tmp %= 2019;
		kotae += A[tmp]++;
		are *= 10;

		tmp += (S[i--] - '0') * are;
		tmp %= 2019;
		kotae += A[tmp]++;
		are *= 10;
		are %= 2019;
	}
	rep(j, amari) {
		tmp += (S[i--] - '0') * are;
		tmp %= 2019;
		kotae += A[tmp]++;
		are *= 10;
	}

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


	Would you please return 0;
}

Measured memory_bytes: 3896
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), ((a) + (n))
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define MODNUM (static_cast<int>(1e9 + 7))
#define MOD(x) ((x) % MODNUM)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

const int INF = 2e9;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

template <typename T>
int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T>
T square(T x) {
	return x * x;
}

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

constexpr bool is_prime(int n) {
	if(n == 2) {
		return true;
	}

	if(n % 2 == 0) {
		return false;
	}

	for(int i = 3; i * i <= n; i += 2) {
		if(n % i == 0) {
			return false;
		}
	}
	return true;
}

template <typename T>
std::vector<T> prime_list(T n) {
	std::vector<T> prime = prime_table(n);
	prime.erase(std::remove(prime.begin(), prime.end(), 0), prime.end());
	return prime;
}

int main() {
	int x;
	scanf("%d", &x);
	int i;
	for(i = x; !is_prime(i); i++)
		;
	printf("%d\n", i);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int A,B,C,D;
  A=N/1000;
  B=N%1000/100;
  C=N%100/10;
  D=N%10;
  
  
  if((A==B&&B==C)||(B==C&&C==D)){
  cout<<"Yes"<<endl;
  }
  else {
   cout << "No"<< endl;
  }
}

Measured memory_bytes: 3616
#include <map>
#include <set>
#include <unordered_set>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <climits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstring>
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>

using namespace std;
typedef long long ll;
#define ln '\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define drep(i,n) int i = 0;for(;i<(n);++i)
#define FOR(i,s,e) for(int i=s;i<=(e);++i)
#define DFOR(i,s,e) int i = s;for(;i<=(e);++i)
#define FORR(i,s,e) for(int i=s;i>=(e);--i)
#define DFORR(i,s,e) int i = s;for(;i>=(e);--i)
#define fore(a, x) for(auto& a : x)
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ft first
#define sd second
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define Fill(a,b) memset(a,b,sizeof(a))
template<typename T1, typename T2> bool Max(T1& a, T2 b) { return a<b ? a = b, 1 : 0; }
template<typename T1, typename T2> bool Min(T1& a, T2 b) { return a>b ? a = b, 1 : 0; }



const int N = 100001, inf = 10000;
int a[N], b[N], c[N];



void solve() {
  int n;
  cin >> n;
  rep(i, n)cin >> a[i];
  rep(i, n)cin >> b[i];
  rep(i, n)cin >> c[i];
  sort(a, a + n);
  sort(c, c + n);
  ll ans = 0;
  rep(i, n) {
    int e = b[i];
    ll t1 = lower_bound(a, a + n, e) - a;
    ll t2 = n - (upper_bound(c, c + n, e) - c);
    ans += t1*t2;
  }
  cout << ans << ln;
}





void init() {
  
}

int main(void) {
  ios::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
  //freopen("C:\\Users\\LENOVO\\Documents\\Visual Studio 2015\\Projects\\Test\\Input\\in.in", "r", stdin);

  init();
  int TC = 1;
#if 0
  cin >> TC; cin.get();
#endif
  FOR(TI, 1, TC) {
    //cout << "Case #" << TI << ": ";
    solve();
  }
  
  
  return 0;
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n;
  cin >> n;
  vvl f(n,vector<ll>(10));
  vvl p(n,vector<ll>(11));
  rep(i,n)rep(j,10) cin>>f[i][j];
  rep(i,n)rep(j,11) cin >> p[i][j];
  
  ll ans=-INF;
  for(int bit=0;bit<(1<<10);bit++){
    if(bit==0)continue;   
    ll res=0;
    rep(j,n){
      ll cnt=0;
      rep(i,10){
        if((bit & (1<<i)) && f[j][i])cnt++;
      }
      res+=p[j][cnt];
    }
    chmax(ans,res);
  }
  cout << ans << endl;
      
        
  
          
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<map>
#include<vector>
#define FAST ios::sync_with_stdio(false)
typedef long long ll;
const int mod = (int)1e9 + 9;
const int inf = 0x3f3f3f3f;
const int maxn = (int)1e5 + 5;
using namespace std;

int ans[100] = {1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64, 81, 100, 121, 125, 128, 144, 169, 196, 216, 225, 243, 256, 289, 324, 343, 361, 400, 441, 484, 512, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1000, inf};

int main()
{
	int x;
	cin >> x;
	int i;
	for(i = 0; i < 100; i++){
		if(x < ans[i]) break;
	}
	cout << ans[i-1] << endl;
	return 0;
}

Measured memory_bytes: 256