akhauriyash/Code-Regression huggingface dataset:
let (n1, n2, n_limit) = (4, 16, 45)

let goal = Array.init n2 (fun i -> (i + 1) mod n2)

let area = Array.make n2 []

let md = Array.make_matrix n2 n2 0

let initialize_area () =
  for i = 0 to n2 - 1 do
    let lst = [] in
    let lst = if i + n1 < n2 then (i + n1) :: lst else lst in
    let lst = if (i + 1) mod n1 <> 0 then (i + 1) :: lst else lst in
    let lst = if i - 1 >= 0 && (i - 1) mod n1 <> n1 - 1 then (i - 1) :: lst else lst in
    let lst = if i - n1 >= 0 then (i - n1) :: lst else lst in
    area.(i) <- lst;
  done

let initialize_md () =
  for i = 0 to n2 - 2 do
    for j = 0 to n2 - 1 do
      md.(i+1).(j) <- abs (i / n1 - j / n1) + abs (i mod n1 - j mod n1)
    done
  done

let idastar a limit space lower =
  let rec doit i space moved lower =
    if i = limit then
      if a <> goal then ()
      else begin
        Printf.printf "%d\n" limit;
        exit 0;
      end
    else
      List.iter (fun j ->
        let x = a.(j) in
        if x = moved then ()
        else
          let lower = lower - md.(x).(j) + md.(x).(space) in
          if lower + i > limit then ()
          else begin
            a.(j) <- 0;
            a.(space) <- x;
            doit (i + 1) j x lower;
            a.(j) <- x;
            a.(space) <- 0;
          end)
      area.(space) in
  doit 0 space (-1) lower

let findi a x =
  let n = Array.length a in
  let rec doit i =
    if i = n then assert false
    else if a.(i) = x then i
    else doit (i + 1) in
  doit 0

let () =
  initialize_area ();
  initialize_md ();
  let a = Array.init n2 (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  let space = findi a 0 in
  let lower =
    Array.fold_left (fun (i, sum) e -> (i + 1, sum + md.(e).(i))) (0, 0) a |> snd in
  for limit = lower to n_limit do
    idastar a limit space lower
  done

Measured memory_bytes: 4540
using System;
using System.Collections.Generic;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var L = new List<int>();
            for(int i = 0; i < 5; i++)
            {
                L.Add(int.Parse(Console.ReadLine()));
            }
            int k = int.Parse(Console.ReadLine());
            bool flag = false;
            if (L[5 - 1] - L[0] > k) flag = true;
            if (flag) Console.WriteLine(":(");
            else Console.WriteLine("Yay!");
        }
    }
}


Measured memory_bytes: 27712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define edl "\n"
#define ceils(s,n) (s+n-1)/n
#define str string
#define add insert
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, N = 1e5 + 10;
const ll LINF = LLONG_MAX;
int main() {
    fast();
    // #ifndef ONLINE_JUDGE
    //   freopen("input.txt", "r", stdin);
    //   freopen("output.txt","w",stdout);
    // #endif
    ll n;
    cin >> n;
    vec q(n);
    f(i,0,n){
        cin >> q[i];
    }
    ll t=0;
    f(i,0,n){
        f(j,0,n){
            if(i!=j){

                t+=(q[i]*q[j]);
            }
        }
    }
    cout<<t/2;

    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

Measured memory_bytes: 256
#pragma GCC optimize("Ofast","unroll-loops")
#pragma GCC push_options
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include <xmmintrin.h>
#include <immintrin.h>
using namespace::std;
__attribute__((constructor))void init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
template<typename T>using pbds=__gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T>using pbds_map=__gnu_pbds::tree<T,T,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T,typename E>using hash_map=__gnu_pbds::gp_hash_table<T,E>;
template<typename T>using pqueue =__gnu_pbds::priority_queue<T, less<T>,__gnu_pbds::rc_binomial_heap_tag>;
typedef long long lint;
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
template<typename T>inline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i<INF/2?i:"INF";f=1;}cout<<endl;}
template<typename T>inline void numout2(T t){for(auto i:t)numout(i);}
template<typename T>inline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}
template<typename T>inline void output2(T t){for(auto i:t)output(i);}
template<typename T>inline void _output(T t){bool f=0;for(int i=0;i<t.size();i++){cout<<f?"":" "<<t[i];f=1;}cout<<endl;}
template<typename T>inline void _output2(T t){for(int i=0;i<t.size();i++)output(t[i]);}
#define rep(i,n) for(lint i=0;i<lint(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(int)(b);++i)
#define rrep(i,n) for(int i=int(n)-1;i>=0;--i)
#define rrepi(i,a,b) for(int i=int(b)-1;i>=int(a);--i)
#define irep(i) for(int i=0;;++i)
#define all(n) begin(n),end(n)
inline lint gcd(lint A,lint B){return B?gcd(B,A%B):A;}
inline lint lcm(lint A,lint B){return A/gcd(A,B)*B;}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
const vector<lint> dx={-1,1,0,0,1,1,-1,-1};
const vector<lint> dy={0,0,-1,1,1,-1,1,-1};
#define SUM(v) accumulate(all(v),0LL)
auto call=[](auto f,auto... args){return f(f,args...);};

int main(){
    lint n,m;
    cin>>n>>m;
    vec a(n);
    rep(i,n)cin>>a[i];
    rep(i,n)a[i]/=2;
    lint l=1;
    rep(i,n){
        l=lcm(l,a[i]);
        if(l>m){
            cout<<0<<endl;
            return 0;
        }
    }
    rep(i,n){
        if(l/a[i]%2==0){
            cout<<0<<endl;
            return 0;
        }
    }
    cout<<(m/l+1)/2<<endl;
}


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

#define MAX 40000000

int main(void)
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a.at(i);
    sort(a.begin(), a.end());
    unsigned long long sum ,ans =MAX;
    for (int i = a.at(0); i <= a.at(n-1); i++){
        sum = 0;
        for (int j = 0; j < n; j++){
            sum += (a.at(j) - i) * (a.at(j) - i);
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int W,H;
bool inrange(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define MP make_pair
signed main(){
    pair<ld, ld>sa,la,sb,lb;
    while(cin>>sa.first>>sa.second>>la.first>>la.second){
        cin>>sb.first>>sb.second>>lb.first>>lb.second;
        if(la.first<sb.first||lb.first<sa.first||lb.second<sa.second||la.second<sb.second)
            cout<<"NO"<<endl;
        else cout<<"YES"<<endl;
    }
}



Measured memory_bytes: 3144
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdio>
typedef long long ll;
using namespace std;
int a[105];
int main() {
	ll n, k, t;
	cin >> n >> k;
	n %= k;
	t = n > k - n ? k - n : n;
	cout << t << endl;
	return 0;
}

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

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

    int p[N];

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

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

    int sum = 0;
    bool flag = true;
    for(int i = 0; i < N; i++)
    {
        if(p[i] == pmax && flag == true)
        {
            sum += (pmax/2);
            flag = false;
        }
        else sum += p[i];
    }

    cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
signed main() {
    char X,Y;
    cin>>X>>Y;

    if(X==Y){
        cout<<'='<<endl;
    }
    else if(X<Y){
        cout<<'<'<<endl;
    }
    else{
        cout<<'>'<<endl;
    }
}

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


int main(){
    string a;
    cin >> a;
    vector<int> ans(26);
    
    for(int i=0;i<a.size();i++){
        switch(a.at(i)){
            case 'a':
                ans.at(0)++;
                break;
            case 'b':
                ans.at(1)++;
                break;
            case 'c':
                ans.at(2)++;
                break;
            case 'd':
                ans.at(3)++;
                break;
            case 'e':
                ans.at(4)++;
                break;
            case 'f':
                ans.at(5)++;
                break;
            case 'g':
                ans.at(6)++;
                break;
            case 'h':
                ans.at(7)++;
                break;
            case 'i':
                ans.at(8)++;
                break;
            case 'j':
                ans.at(9)++;
                break;
            case 'k':
                ans.at(10)++;
                break;
            case 'l':
                ans.at(11)++;
                break;
            case 'm':
                ans.at(12)++;
                break;
            case 'n':
                ans.at(13)++;
                break;
            case 'o':
                ans.at(14)++;
                break;
            case 'p':
                ans.at(15)++;
                break;
            case 'q':
                ans.at(16)++;
                break;
            case 'r':
                ans.at(17)++;
                break;
            case 's':
                ans.at(18)++;
                break;
            case 't':
                ans.at(19)++;
                break;
            case 'u':
                ans.at(20)++;
                break;
            case 'v':
                ans.at(21)++;
                break;
            case 'w':
                ans.at(22)++;
                break;
            case 'x':
                ans.at(23)++;
                break;
            case 'y':
                ans.at(24)++;
                break;
            case 'z':
                ans.at(25)++;
                break;
            }
    }
    for (int i = 0; i < 26;i++){
        if(ans.at(i)%2==1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

ll power(ll x,ll n){
    if(n==0) return 1;
    ll res=power(x*x%mod,n/2);
    if(n&1) res=res*x%mod;
    return res;
}

int main(){
  int n,k;
  cin>>n>>k;
  ll ans=0;
  ll cur[k+1];
  for(int i=k;i>0;i--){
    ll now=0;
    for(int j=2*i;j<=k;j+=i){
      now+=cur[j];
      now%=mod;
    }
    ll res=power(k/i,n)-now;
    if(res<0) res+=mod;
    cur[i]=res;
    ans+=i*res;
    ans%=mod;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4376
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    NN = [0] * (N + 1)
    for i in range(1, N + 1):
        if i % 3 != 0 and i % 5 != 0:
            NN[i] = i

    print(sum(NN))


if __name__ == "__main__":
    main()


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

int main(){
	int n;
	double x1,x2,x3,y1,y2,y3;
	double a1,a2,b1,b2,c1,c2;
	double px,py;

	cin >> n;
	while(n > 0){
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
	
	a1 = 2 * (x2 - x1);
	b1 = 2 * (y2 - y1);
	c1 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2;
	a2 = 2 * (x3 - x1);
	b2 = 2 * (y3 - y1);
	c2 = x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3;
	
	px = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1);
	py = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1);
	
	cout << fixed << setprecision(3) << px << " " << fixed << setprecision(3) << py << " " << fixed << setprecision(3) << hypot(px - x1, py - y1) << endl;
	n--;
	}

	return 0;
}

Measured memory_bytes: 1300
#include <iostream>

int a,b;
char op;
int main(){
	while(std::cin >> a >> op >> b && op != '?'){
		if(op == '+') std::cout << a+b << std::endl;
		else if(op == '-') std::cout << a-b << std::endl;
		else if(op == '*') std::cout << a*b << std::endl;
		else if(op == '/') std::cout << a/b << std::endl;
	}
}


Measured memory_bytes: 3104
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
int ctoi(char c){return (int)c-(int)'0';}
int main() {
    string N;
    cin>>N;
    int d=N.size();
    int K;cin>>K;
    int ans=0;
    if(K==1){
        ans=9*(d-1);
        ans+=ctoi(N[0]);
    }else if(K==2){
        if(d<2){
            cout<<0<<endl;
            return 0;
        }
        ans+=9*9*(d-1)*(d-2)/2;
        ans+=(ctoi(N[0])-1)*(d-1)*9;
        int i=1;
        while(i<d&&ctoi(N[i])==0)i++;
        if(i!=d){
            ans+=(d-1-i)*9;
            ans+=ctoi(N[i]);
        }
    }else if(K==3){
        if(d<3){
            cout<<0<<endl;
            return 0;
        }
        ans+=9*9*9*((d-3)*(d-2)*(2*d-5)/6+(d-3)*(d-2)/2)/2;
        ans+=(ctoi(N[0])-1)*(d-1)*(d-2)/2*9*9;
        int i=1;
        while(i<d&&ctoi(N[i])==0)i++;
        if(i<d){
            ans+=(ctoi(N[i])-1)*(d-1-i)*9;
            ans+=(d-i-1)*(d-i-2)/2*9*9;
        }
        int j=i+1;
        while(j<d&&ctoi(N[j])==0)j++;
        if(j<d){        
            ans+=(d-1-j)*9;
            ans+=ctoi(N[2]);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include <cstdio>
using namespace std;

int main()
{
  int N;
  int maxV=0, secV=0, maxP;
  scanf("%d", &N);
  int x;
  for (int i=0; i<N; i++) {
    scanf("%d", &x);
    if (maxV < x) {
      secV = maxV;
      maxV = x;
      maxP = i;
    } else if (secV < x) {
      secV = x;
    }
  }
  
  for (int i=0; i<N; i++)
  {
    if (i == maxP) printf("%d\n", secV);
    else printf("%d\n", maxV);
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  int fN;
  int a,b,c,d,e,f,g,h,i;
  a=N/100000000;
  b=N%100000000/10000000;
  c=N%100000000%10000000/1000000;
  d=N%100000000%10000000%1000000/100000;
  e=N%100000000%10000000%1000000%100000/10000;
  f=N%100000000%10000000%1000000%100000%10000/1000;
  g=N%100000000%10000000%1000000%100000%10000%1000/100;
  h=N%100000000%10000000%1000000%100000%10000%1000%100/10;
  i=N%100000000%10000000%1000000%100000%10000%1000%100%10;
  fN=a+b+c+d+e+f+g+h+i;
  if(N%fN==0){
    cout << "Yes" << endl;
  }else{
   cout << "No" << endl; 
  }
}


Measured memory_bytes: 3580
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>

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

using namespace std;

int main(){
	int A, B, C, D;
	int work, work1;
	cin >> A >> B >> C >> D;
	work = A * B;
	work1 = C * D;
	if(work < work1) cout << work1 << endl;
	else cout << work << endl;
	return 0;
}


Measured memory_bytes: 256
/**
 * Copyright (c) 2017, xehoth
 * All rights reserved.
 * 「ARC 081D」Coloring Dominoes 21-08-2017
 * dp
 * @author xehoth
 */
#include <bits/stdc++.h>

namespace Task {

const int MAXN = 52;
const int MOD = 1e9 + 7;

char s[2][MAXN];

inline void solve() {
    std::ios::sync_with_stdio(false), std::cin.tie(NULL), std::cout.tie(NULL);
    register int n;
    std::cin >> n >> s[0] >> s[1];
    register int ans, tot = 0;
    if (s[0][0] == s[1][0])
        ans = 3, tot = 1;
    else if (s[0][0] == s[0][1])
        ans = 6, tot = 2;
    for (; tot < n;) {
        if (s[0][tot] == s[1][tot]) {
            if (s[0][tot - 1] == s[1][tot - 1]) ans = ans * 2ll % MOD;
            tot++;
        } else if (s[0][tot] == s[0][tot + 1]) {
            if (s[0][tot - 1] == s[1][tot - 1])
                ans = ans * 2ll % MOD;
            else if (s[0][tot - 1] == s[0][tot - 2])
                ans = ans * 3ll % MOD;
            tot += 2;
        }
    }
    std::cout << ans;
}
}

int main() {
    Task::solve();
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<set>
using namespace std;
#define INF 1LL<<62
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
//typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll

//計算量はO(log max(a,b))
ll lcm(ll x,ll y){
  ll mindata,maxdata;
  mindata=min(x,y);
  maxdata=max(x,y);
  while(maxdata%mindata!=0){
    ll temp;
    temp=maxdata%mindata;
    maxdata=mindata;
    mindata=temp;
  }
  return x*(y/mindata);
}


signed main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll A,B;
    cin>>A>>B;
    cout<<lcm(A,B)<<endl;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include"math.h"
using namespace std;
int main(){
  string S;
  cin >> S;
  bool T=false;
  
  int n=S.size();
  for(int i=0;i<n;i++){
    if(i%2==0){
      if(S.at(i)=='L'){T=true;break;}}
      else{if(S.at(i)=='R'){T=true;break;}}}
if(T){cout << "No"<<endl;}
  else{cout << "Yes"<<endl;}}
    
         

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define BIGINF (int) 4e18 + 7
#define MOD7 1000000007
#define MOD9 1e9 + 9
#define INF  (int)2e9 + 7
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
typedef long long ll;
typedef long double ld;
typedef string str;
typedef double d;
typedef unsigned u;
typedef unsigned long long ull;

int main () {
	//#ifndef ONLINE_JUDGE
		//freopen("inputf.txt", "r", stdin);
		//freopen("outputf.txt", "w", stdout);
	//#endif
	int n, m, x;
	SCD(n);
	SCD(m);
	vector<int> a;
	double sum = 0;
	for (int i = 0; i < n; i++) {
		SCD(x);
		sum += x * 1.0;
		a.push_back(x);
	}
	sort(a.rbegin(), a.rend());
	bool OK = true;
	for (int i = 0; i < m; i++) {
		if (a[i] < (1 / (4.0 * m)) * 1.0 * sum) {
			OK = false;
			break;
		}
	}
	if (OK) printf("Yes");
	else printf("No");	
    return 0;

}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	char num;
	int sum;
	while(1) {
		scanf("%c",&num);
		if(num == '0') break;
		sum = num - '0';
		while(1) {
			scanf("%c",&num);
			if(num == '\n') break;
			sum += num - '0';
		}
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 536
#include <bits/stdc++.h>
#define int long long
#define double long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define M   1000000007 // 1e9 + 7
#define MAXN 100100
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,double> pdd;
inline int mod(int n, int m){int ret = n%m; if(ret < 0) ret += m; return ret;}
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }    else return mod(k*k,m);
}

int s[62];

int32_t main(){
	fastio;
   	int n;
   	cin>>n;
   	vector<int> v(n);
   	for(int i=0;i<n;i++)cin>>v[i];
   	
   	int r =0;
   	
   	for(int i=n-1;i>=0;i--){
	     
			 for(int j=0;j<60;j++){
			 	//cout<<v[i]<<" "<<(1LL<<j)<<endl;
				
			 	if(v[i]&(1LL<<j)){
                //quantos nao tem bit==1 : 
				 int x = n - 1 - i - s[j];
				 int y = (1LL<<j)%M;
				 r = mod(r+ x*y,M);
				 s[j]++;
				 }else{
					 int x = s[j];
					 int y = (1LL<<j)%M;
					 r = mod(r+x*y,M);
				 }
				 
			 }
		 	   
    }
   	cout<<r<<endl;
}

Measured memory_bytes: 2560
use proconio::*;

const MOD: u32 = 998244353;

#[derive(Clone, Copy)]
struct ModInt{
    value: u32,
}

impl std::ops::Add for ModInt {
    type Output = ModInt;

    fn add(self, rhs: Self) -> Self::Output {
        ModInt {
            value: (self.value + rhs.value) % MOD,
        }
    }
}

impl std::ops::AddAssign for ModInt {
    fn add_assign(&mut self, rhs: Self) {
        *self = *self + rhs;
    }
}

impl std::ops::Sub for ModInt {
    type Output = ModInt;

    fn sub(self, rhs: Self) -> Self::Output {
        ModInt {
            value: (MOD + self.value - rhs.value) % MOD,
        }
    }
}

impl std::ops::SubAssign for ModInt {
    fn sub_assign(&mut self, rhs: Self) {
        *self = *self - rhs;
    }
}

impl std::ops::Mul for ModInt {
    type Output = ModInt;

    fn mul(self, rhs: Self) -> Self::Output {
        ModInt {
            value: (self.value as u64 * rhs.value as u64 % MOD as u64) as u32,
        }
    }
}

impl std::ops::MulAssign for ModInt {
    fn mul_assign(&mut self, rhs: Self) {
        *self = *self * rhs;
    }
}

impl ModInt {
    pub fn new(n: u32) -> ModInt {
        ModInt {
            value: n % MOD,
        }
    }

    pub fn one() -> ModInt {
        ModInt {
            value: 1,
        }
    }

    pub fn pow(self, mut n: u32) -> ModInt {
        let mut ret = ModInt::one();
        let mut s = self;
        while n > 0 {
            if n & 1 > 0 {
                ret *= s;
            }
            s *= s;
            n >>= 1;
        }
        ret
    }
}

impl std::ops::Div for ModInt {
    type Output = ModInt;

    fn div(self, rhs: Self) -> Self::Output {
        self * rhs.pow(MOD-2)
    }
}

impl std::ops::DivAssign for ModInt {
    fn div_assign(&mut self, rhs: Self) {
        *self = *self / rhs;
    }
}

impl std::ops::Neg for ModInt {
    type Output = ModInt;

    fn neg(self) -> Self::Output {
        ModInt {
            value: if self.value == 0 { 0 } else { MOD - self.value },
        }
    }
}

struct Combination {
    inv: Vec<ModInt>,
    fact: Vec<ModInt>,
    inv_fact: Vec<ModInt>,
}

impl Combination {
    pub fn new(n: usize) -> Combination {
        let mut inv = vec![ModInt::one(); n];
        let mut fact = vec![ModInt::one(); n];
        let mut inv_fact = vec![ModInt::one(); n];
        for i in 2..n {
            inv[i] = ModInt::new(MOD / i as u32) * (-inv[MOD as usize % i]);
            fact[i] = fact[i-1] * ModInt::new(i as u32);
            inv_fact[i] = inv_fact[i-1] * inv[i];
        }

        Combination {
            inv: inv,
            fact: fact,
            inv_fact: inv_fact,
        }
    }

    pub fn get(&self, x: usize, y: usize) -> ModInt {
        self.fact[x] * self.inv_fact[y] * self.inv_fact[x-y]
    }
}

fn main() {
    input!{
        n: usize,
        m: usize,
        k: usize,
    }

    let comb = Combination::new(n+m);
    let mut ans = ModInt::new(0);
    let m = ModInt::new(m as u32);
    for i in 0..=k {
        ans += m * (m - ModInt::one()).pow((n-1-i) as u32) * comb.get(n-1, i);
    }

    println!("{}", ans.value);
}

Measured memory_bytes: 6728
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = s.length();
  vector<pair<int, int>> grh;
  s = '$' + s;
  if (s[1] == '0' || s[n - 1] == '0' || s[n] == '1') {
    cout << -1 << '\n';
    return 0;
  }
  int crr;
  stack<int> stk;
  for (int i = 1; i <= n / 2; i++) {
    if (s[i] != s[n - i]) {
      cout << -1 << '\n';
      return 0;
    }
    if (s[i] == '1') {
      crr = i;
      while (!stk.empty()) {
        int prv = stk.top();
        stk.pop();
        grh.push_back({prv, crr});
        grh.push_back({n + 1 - crr, n + 1 - prv});
      }
    }
    stk.push(i);
  }
  int lft = crr;
  int rgt = n + 1 - crr;
  if (lft + 1 == rgt) {
    grh.push_back({lft, rgt});
  } else if (lft + 1 < rgt) {
    int cen = lft + 1;
    grh.push_back({lft, cen});
    grh.push_back({cen, rgt});
    for (int i = cen + 1; i < rgt ; i++) {
      grh.push_back({cen, i});
    }
  }
  sort(grh.begin(), grh.end());
  for (auto e : grh) {
    cout << e.first << ' ' << e.second << '\n';
  }
  return 0;
}

Measured memory_bytes: 2532
#include <iostream>

int main(int argc, char **argv){
	int h = 0;
	int w = 0;

	while(std::cin >> h >> w, (h != 0 || w != 0)){
		for(int y = 0; y < h; y++){
			for(int x = 0; x < w; x++){
				int n = x + (y % 2 != 0 ? 1 : 0);
				if(n % 2 != 0){
					std::cout << ".";
				}
				else{
					std::cout << "#";
				}
			}
			std::cout << std::endl;
		}
		std::cout << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3068
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <math.h> // sqrt
using namespace std;

int gcd(int i, int j, int k) {
    int div;
    while (true) {
        if (i == j && j == k) {
            break;
        }
        div = min ({i, j, k});
        if (i != div) {
            i = i % div + div;
            if (div < i) {
                i -= div;
            }
        }
        if (j != div) {
            j = j % div + div;
            if (div < j) {
                j -= div;
            }
        }
        if (k != div) {
            k = k % div + div;
            if (div < k) {
                k -= div;
            }
        }
    }
    return i;
}

int main() {
    int K;
    cin >> K;
    int ans = 0;
    for (int i = 1; i < K + 1; i++) {
        for (int j = 1; j < K + 1; j++) {
            for (int k = 1; k < K + 1; k++) {
                ans += gcd(i, j, k);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3604
n=int(input())
nums=list(map(int,input().split()))
def partition(nums,p,r):
    i=p-1
    x=nums[r]
    for k in range(p,r):
        if nums[k]<=x:
            i+=1
            nums[i],nums[k]=nums[k],nums[i]

    nums[i+1],nums[r]=nums[r],nums[i+1]
    return i+1

i=partition(nums,0,n-1)
nums[i]="["+str(nums[i])+"]"
print(' '.join(map(str,nums)))



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


namespace ConsoleApplication2
{

    class Program
    {
        static void Main(string[] args)
        {

            string[] input = Console.ReadLine().Split(' ');

            int pluscard, zerocard, minuscard,totalcard,totalpoint;

            pluscard = int.Parse(input[0]);
            zerocard = int.Parse(input[1]);
            minuscard = int.Parse(input[2]);
            totalcard = int.Parse(input[3]);

            

            bool checker = false;

            int cost=0;

            if(totalcard>=pluscard)
            {
                totalpoint = pluscard;
                totalcard -= pluscard;
            }
            else
            {
                totalpoint = totalcard;
                totalcard = 0;
            }

            if (totalcard >= zerocard)
            {
                totalcard -= zerocard;
            }
            else
            {
                totalcard = 0;
            }

            if(totalcard!=0)
            {
                totalpoint -= totalcard;
            }

            Console.WriteLine(totalpoint);

            checker = false;

        }
    }
}


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

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

int H, W, dist[20][20];

char maze[20][20];

int bfs(int sx, int sy){

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            dist[i][j] = -1;
        }
    }

    queue< pair<int,int> > q;

    q.push(make_pair(sx, sy));
    dist[sx][sy] = 0;

    while( !q.empty() ){
        int h = q.front().first;
        int w = q.front().second;
        q.pop();

        for(int dir = 0; dir < 4; dir++){
            int next_h = h + dx[dir];
            int next_w = w + dy[dir];

            if(next_h < 0 || H <= next_h || next_w < 0 || W <= next_w ) continue;
            if(maze[next_h][next_w] == '#') continue;

            if(dist[next_h][next_w] == -1){
                dist[next_h][next_w] = dist[h][w] + 1;
                q.push(make_pair(next_h,next_w));
            }            
        }
    } 

    int max_dist = 0;
    for(int h = 0; h < H; h++){
        for(int w = 0; w < W; w++){
            max_dist = max(max_dist, dist[h][w]);
        }
    }

    return max_dist;
}

void solve(){
    int ans = 0;
    for(int h = 0; h < H; h++){
        for(int w = 0; w < W; w++){
            if(maze[h][w] == '#') continue;
            ans = max(ans,bfs(h,w));
        }
    }

    cout << ans << endl;
}

int main(){
    cin >> H >> W;
    rep(i,H)rep(j,W) cin >> maze[i][j];

    solve();

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    rep(i,V){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    rep(i,V){
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};
class UnionFind
{
public:
  int par[100005];
  int depth[100005];
  int nGroup[100005];
 
  UnionFind(int n) {
    init(n);
  }
 
  void init(int n) {
    for(int i=0; i<n; i++) {
      par[i] = i;
      depth[i] = 0;
      nGroup[i] = 1;
    }
  }
 
  int root(int x) {
    if(par[x] == x) {
      return x;
    } else {
      return par[x] = root(par[x]);
    }
  }
 
  bool same(int x, int y) {
    return root(x) == root(y);
  }
 
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return;
 
    if(depth[x] < depth[y]) {
      par[x] = y;
      nGroup[y] += nGroup[x];
      nGroup[x] = 0;
    } else {
      par[y] = x;
      nGroup[x] += nGroup[y];
      nGroup[y] = 0;
      if(depth[x] == depth[y])
        depth[x]++;
    }
  }
};
const ll MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
} 
int main() {
ll n; cin>>n;
graph G(n);
rep(i,n-1){
ll a,b,c; cin>>a>>b>>c;
G.add_edge(a-1,b-1,c);
G.add_edge(b-1,a-1,c);}
G.dijkstra(0);
cout << 0 << endl;
for(ll p=1; p<n; p++){
if(G.d[p]%2==0) cout << 0 << endl;
else cout << 1 << endl;}}


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

int main(){
	int n;
	int matrix[100][100];
	while(cin >> n){
		if(n==0) return 0;
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				cin >> matrix[i][j];
			}
		}
		int sumX[100],sumY[100],sum=0;		
		for(int i=0; i<n; i++){
			sumX[i]=0; sumY[i]=0;
			for(int j=0; j<n; j++){
				sumX[i] += matrix[j][i];
				sumY[i] += matrix[i][j];
			}
			sum+=sumX[i];
		}
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				printf("%5d",matrix[i][j]);
			}
			printf("%5d\n",sumY[i]);
		}
		for(int i=0; i<n; i++) printf("%5d",sumX[i]);
		printf("%5d\n",sum);
		
	}
}

Measured memory_bytes: 0
n_gram = lambda t, n: [t[i:i+n] for i in range(len(t) - n + 1)]

S = input()
T = input()

t_len = len(T)
count = t_len

s_list = n_gram(S, t_len)

for s in s_list:
    c = 0
    for i in range(len(s)):
        if s[i] != T[i]:
            c += 1
    count = min(count, c)

print(count)


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

using namespace std;

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

typedef int64_t ll;

ll INF = (1 << 31) - 1;

int get_n(int n) {
    int ret = 1; while(ret < n) ret <<= 1;

    return ret;
}

template<typename T>
struct LazySegTree {
    int N;
    vector<T> dat, lazy;

    LazySegTree(int n, T init = 0): N(get_n(n)), dat(2*N-1, init), lazy(2*N-1, 0) {}

    // add v to [a, b), current range: [l, r), node id: k
    void add (int a, int b, T v, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = N;

        if (r <= a || b <= l) return;

        if (a <= l && r <= b) {
            lazy[k] += v;
            return;
        }

        dat[k] += v * (min(b, r) - max(a, l));
        int mid = (l + r) / 2;
        add(a, b, v, 2 * k + 1, l, mid);
        add(a, b, v, 2 * k + 2, mid, r);
    }

    T sum(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = N;

        if (r <= a || b <= l) return 0;

        if (a <= l && r <= b) {
            return dat[k] + lazy[k] * (r - l);
        }

        T ret = lazy[k] * (min(b, r) - max(a, l));
        int mid = (l + r) / 2;
        ret += sum(a, b, 2 * k + 1, l, mid);
        ret += sum(a, b, 2 * k + 2, mid, r);

        return ret;
    }
};

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

    LazySegTree<ll> lst(n);

    REP(_, q) {
        int o, s, t;
        cin >> o >> s >> t;
        --s; --t;

        if (o == 0) {
            int x;
            cin >> x;
            lst.add(s, t + 1, x);
        } else {
            cout << lst.sum(s, t + 1) << endl;
        }
    }
}



Measured memory_bytes: 7064
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define mkp make_pair
//#define d double
void solve(){
	double a,b,x;
	cin>>a>>b>>x;
	double t=a*a*b;
	double rem=t-x;
	double mul=180/PI;
	if(rem<x){
		cout<<setprecision(10)<<fixed<<90-(atan(a*a*a/(2*rem))*mul);
	}
	else{
		cout<<setprecision(10)<<fixed<<90-(atan(2*x/(a*b*b))*mul);
	}
 
 
 
}
int32_t main(){
FIO;
int t=1;
//cin>>t;
while(t--){
	solve();
}
}



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

int main(){
  int a,b;
  cin >> a >> b;
  if(a%3 == 0 || b % 3 == 0 || (a+b)%3 == 0){
    cout << "Possible" << endl;
  }else{
    cout << "Impossible" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
def getSumRange(L, R):
    ans = sum[R][R] - sum[R][L - 1] - sum[L - 1][R] + sum[L - 1][L - 1]
    return ans

n, m, Q = map(int, input().split())
L = [0] * m
R = [0] * m
for i in range(m):
    L[i], R[i] = map(int, input().split())
p = [0] * Q
q = [0] * Q
for i in range(Q):
    p[i], q[i] = map(int, input().split())

sum = [[0] * (n + 1) for i in range(n + 1)]
for i in range(m):
    sum[L[i]][R[i]] += 1
for i in range(n + 1):
    for j in range(n + 1):
        sum[i][j] += sum[i - 1][j]
        sum[i][j] += sum[i][j - 1]
        sum[i][j] -= sum[i - 1][j - 1]

for i in range(Q):
    ans = getSumRange(p[i], q[i])
    print(ans)

Measured memory_bytes: 28048
#include <cstdio>
#include <complex>

using namespace std;

int main() {
  int n, t[100001], x[100001], y[100001];
  scanf("%d", &n);
  t[0] = x[0] = y[0] = 0;

  for (int i = 1; i <= n; ++i) {
    scanf("%d%d%d", &t[i], &x[i], &y[i]);
  }

  for (int i = 1; i <= n; ++i) {
    int timeDiff = t[i] - t[i - 1];
    int distance = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
    if (distance > timeDiff || (distance - timeDiff) % 2 != 0) {
      printf("No\n");
      return 0;
    }
  }

  printf("Yes\n");
  return 0;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

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

    vector<int> cnt(N, 0);
    for_(i,0,K) {
        int d;
        cin >> d;
        for_(j,0,d) {
            int a;
            cin >> a;
            --a;
            cnt[a]++;
        }
    }

    int ans = 0;
    for_(i,0,N) if (cnt[i]==0) ++ans;
    cout << ans << endl;
}

Measured memory_bytes: 3596
S = input()
mod_bucket = [0] * 2019
mod_bucket[0] = 1
 
_S = S[::-1]
mod = 0
p = 1
for i in range(len(S)):
    mod = (p * int(_S[i]) + mod) % 2019
    mod_bucket[mod] += 1
    p = p*10%2019

ans = sum([mod*(mod-1)/2 for mod in mod_bucket])
print(int(ans))

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

int main(void){
   int N;
   cin>>N;
   long long ans=1;
   int mod=1000000007;
   for(int i=1;i<=N;i++){
      ans*=i;
      ans=ans%mod;
   }
   cout<<ans<<endl;
   return 0;
}



Measured memory_bytes: 256
a, b, c, d, e, f = map(int, input().split())
water = []
for i in range(31):
    for j in range(31):
        if (a*i+b*j)*100<=f:
            water.append(a*i+b*j)
water = list(set(water))

result = [[0,a*100,0]]
for i in water:
    for x in range(301):
        for y in range(301):
            if i > 0 and c*x+d*y > 0 and c*x+d*y<=i*e and (c*x+d*y+100*i)<=f:
                result.append([100*(c*x+d*y)/(c*x+d*y+100*i), c*x+d*y+100*i, c*x+d*y])

result.sort(reverse=True)
print(result[0][1], result[0][2])

Measured memory_bytes: 38148
#include<iostream>
#include<string>
#include<cstring>
#include<cstdio>
#include <sstream>
#include <cctype>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#define all(a) (a).begin(),(a).end()

using namespace std;


string toString(int a){
  ostringstream oss;
  oss << a;
  return oss.str();
}

int toInt(string s){
  return atoi(s.c_str());
}

vector<int> toVec(string s){
  vector<int>res;
  for(int i=s.size()-1;i>=0;i--){
    res.push_back(s[i]-'0');
  }
  return res;
}

int VecToInt(vector<int>v){
  int res=0;
  for(int i=0;i<v.size();i++){
    res+=v[i]*pow(10.,(double)v.size()-i-1);
  }
  return res;
}

int main(void){

  string a;
  int L;

  while(cin >> a >> L,L){
    int cnt=1;
    map<string,int> p;
    p[a]=cnt;

    while(true){

      if(a.size()<L)
	for(int i=a.size();i<L;i++)a+='0';
      
      vector<int>num=toVec(a);
      sort(all(num),greater<int>());
      int Max=VecToInt(num);
      
      sort(all(num));
      int Min=VecToInt(num);
      
      a=toString(Max-Min);

      if(p[a]>0){
	cout << p[a]-1 <<" "<<  a << " " << cnt-p[a]+1 << endl;
	break;
      }
      cnt++;
      p[a]=cnt;
    }
    
  }
  
  return 0;
}

Measured memory_bytes: 1300
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int a[5];
  rep(i,5)cin>>a[i];
  sort(a,a+5,greater<int>());
  rep(i,5){
    if(i==4)cout<<a[i]<<endl;
    else cout<<a[i]<<" ";
  }
  return 0;
}



Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;
   scanf("%d",&n);
   for(int i = 1; i <= 9; i++){
    for(int j = 1; j<= 9; j++){
        if(i * j == n){
           printf("Yes\n");
           return 0;
        }
    }
   }
   printf("No\n");
   return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
int main(void){
  
  int r;
  
scanf("%d",&r);
  if(r<1200){
    printf("ABC");
  }
  else if(r<2800){
    printf("ARC");
  }
  else{
    printf("AGC");
  }
  
return 0;
}
  
  

Measured memory_bytes: 128
#include <stdio.h>


using namespace std;

class CSolver{
public:
	CSolver();
	int solve();
	int in_;
	int out_;
};

CSolver::CSolver(){
	in_ = 0;
	out_ = 0;
};

int CSolver::solve(){
	scanf("%d", &in_);
	out_ = in_ * in_ * in_;
	printf("%d\n",out_);
	return 0;
};

int main(){

	CSolver mysol;

	mysol.solve();

	return 0;
}

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

int main(){
    int n ; cin >> n ;
    for(int i=1;i<=n;i++){
        if(i%3==0) cout << " " << i ;
        else{
            int x = i ;
            while(1){
                if(x){
                    if(x%10==3){
                        cout << " " << i ;
                        break ;
                    }else{
                        x /= 10 ;
                    }
                }else{
                    break ;
                }
            }
        }
    }
    cout << endl ;
}


Measured memory_bytes: 3096
N = int(raw_input())
count = [0, 0, 0, 1]
for i in sorted([(int(i), 2) for i in raw_input().split(" ")] + [(int(i), 1) for i in raw_input().split(" ")] + [(int(i), 0) for i in raw_input().split(" ")]):
    count[i[1]] += count[i[1] + 1]
print count[0]

Measured memory_bytes: 39612
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
// #include <numeric> // gcdとかlcmとか C++17から
#include <time.h> // time_t timer; time(&timer); でtimerに現在時刻が代入される．
#include <unistd.h> // sleep関数．引数は秒単位．
using namespace std;

typedef long long ll;


// sortの仕方
// 	■ string s の場合
// 	昇順: sort(s.begin(), s.end())
// 	降順: sort(s.rbegin(), s.rend())
//
// 	■ ll a[N] の場合
// 	昇順: sort(a, a+N)
// 	降順: 不明

// vector の使い方
// 宣言：
// vector<int> v;
// vector<int> v(N);
// 初期化:
// vector<int> v(10, 5); 要素数10，全ての要素の値5．
// vector<int> v = {1, 2, 3};
// 代入：
// v[0] = 3;
// sort:
// sort(v.begin(), v.end());
//

// int alph2int(char character) {
//     int x = character - 'a';
//     return x;
// }

ll my_gcd(ll a, ll b){
	return (b==0) ? a : my_gcd(b, a%b);
}

ll my_lcm(ll a, ll b){
	return a*b / my_gcd(a,b);
}

ll factorial(ll a){
	ll ans = 1;
	for(ll i=a; i>0; i--){
		ans *= i;
	}
	return ans;
}

int main(int argc, char *argv[]){
	int D; cin >> D;
	if (D == 25) {
		cout << "Christmas" << endl;
	} else if (D == 24) {
		cout << "Christmas Eve" << endl;
	} else if (D == 23) {
		cout << "Christmas Eve Eve" << endl;
	} else if (D == 22) {
		cout << "Christmas Eve Eve Eve" << endl;
	}

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	long long n,m;
	cin >> n >> m;
  long long ans;
    if(n >2 && m>2){
      	ans = (n-2)*(m-2);
    }else if(n == 2 || m ==2){
      	ans = 0;
    }else if(n == 1 && m>2){
      ans = m-2;
    }
	  else if(m == 1 && n>2){
      ans = n-2;
    }else{
        ans = 1;
    }
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
while(true){
int a = scan.nextInt();
char op = scan.next().charAt(0);
int b = scan.nextInt();

if(op == '?'){break;}

if(op == '+'){System.out.println(a + b);}

if(op == '-'){System.out.println(a - b);}

if(op == '*'){System.out.println(a * b);}

if(op == '/'){System.out.println(a / b);}
}}}

Measured memory_bytes: 26392