akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
#define PB push_back
#define INF 1e9+5;
#define F(i,a,b)  for(i=a;i<b;i++)
#define FE(i,a,b)  for(i=a;i<=b;i++)
#define FR(i,a,b) for(i=a;i>b;i--)
#define LL long long
#define MAX(a,b) (a<b?b:a)
#define ABS(x) (x<0?(-x):x)
#define ALL(c) (c).begin(),(c).end()
#define WATCH(x) cout << (#x) << " is " << (x) << endl
#define vi vector<int>
#define vs vector<string>
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl
using namespace std;
string ConvertToBin(LL s)
{
    string res = "";
    while(s != 0) {
        res += (char)('0' + s % 2);
        s /= 2;
    }
    reverse(res.begin() , res.end());
    return res;
}

void PrintVec(vector<int> &v)
{
    for(vector<int>::iterator it = v.begin() ; it != v.end(); ++it)
    cout<<*it<<" ";
}

vector<int> Populate(vector<int> &v,int n)
{
    int num;
    for(int i=0;i<n;i++)
    {
        cin>>num;
        v.push_back(num);
    }
    return(v);
}

int sumofdigits(int n)
{
    int sm=0;
    while(n)
    {
        sm=sm+(n-(n/10)*10);
         n=n/10;
    }
    return(sm);
}

bool isprime(int n)
{
    int i=0;
    FE(i,2,sqrt(n))
    {
        if(n%i==0)
        return(false);
    }
    return(true);
}




int dp[1001][1001];
int arr[1001][1001];
int fun(int row,int col,int i,int j)
{
   if(i>=row || j>=col)
   return(0);
   if(i==row-1 && j==col-1)
   return(1);
   if(arr[i][j]==1)
   return(0);
   if(dp[i][j]!=-1)
   return(dp[i][j]);
   dp[i][j]=(((fun(row,col,i,j+1)%(1000000007))+(fun(row,col,i+1,j)%(1000000007)))%(1000000007));
   return(dp[i][j]);
}






/*--------------------------time to code-------------------------------*/



int main()
{
    int row,col;
    cin>>row>>col;
    //int arr[1001][1001];
    char c;
    for(int i=0;i<row;i++)
    {
        for(int j=0;j<col;j++)
        {
            cin>>c;
            if(c=='.')
            arr[i][j]=0;
            else
            arr[i][j]=1;
        }
    }
    memset(dp,-1,sizeof(dp));
    cout<<fun(row,col,0,0);
    return(0);
}









Measured memory_bytes: 8192
import java.io.*;
import java.util.*;

import static java.lang.Integer.*;
import static java.lang.Long.parseLong;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter prnt = new PrintWriter(System.out);
        StringTokenizer st;
        int N = parseInt(read.readLine());
        long[] arr = new long[N];
        st = new StringTokenizer(read.readLine());
        for (int i = 0; i < N; i++) {
            arr[i] = parseLong(st.nextToken());
        }
        prnt.println(getSum(arr, N));
        prnt.close();
    }

    static long getSum(long[] arr, int N) {
        long mod = (long) (1e9 + 7);
        long Sum = 0;
        long[] preixSum = new long[N];
        preixSum[0] = arr[0];
        for (int i = 1; i < N; i++) {
            preixSum[i] += (preixSum[i - 1] + arr[i]);
        }
        for (int i = 0; i < N; i++) {
            Sum += ((arr[i] % mod) * ((preixSum[N - 1] - preixSum[i]) % mod)) % mod;
            Sum %= mod;
        }
        return Sum;
    }
}


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

int main(){
   int n, c;
   cin >> n >> c;
   priority_queue<pair<int, int> > v[31];
   int u[100010];
   for (int i = 0; i < n; i++){
     int s, t, cc;
     scanf("%d %d %d", &s, &t, &cc);
     v[cc].push(make_pair(-s, -t));
   }
   for (int i = 0; i < 100010; i++){
     u[i] = 0;
   }
   for (int i = 1; i <= c; i++){
     int prev = -1;
     while(!v[i].empty()){
       pair<int, int> d = v[i].top(); v[i].pop();
       if (-d.first != prev) u[-d.first-1] += 1;
       else u[-d.first] += 1;
       u[-d.second] += -1;
       prev = -d.second;
     }
   }

   int m = u[0];
   for (int i = 1; i < 100010; i++){
     u[i] += u[i-1];
     m = max(m, u[i]);
   }
   cout << m << "\n";
  return 0;
}

Measured memory_bytes: 1920
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramC
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            var list = new List<long>();
            for (var i = 0; i < n; i++)
            {
                list.Add(long.Parse(Console.ReadLine()));
            }

            Console.WriteLine(lcm(list));
        }

        // 最大公約数
        // ユークリッドの互除法を利用
        static long gcd(long a, long b)
        {
            if (b > a)
            {
                var tmp = a;
                a = b;
                b = tmp;
            }

            if (b == 0)
            {
                return a;
            }

            return gcd(b, a % b);
        }

        // 最大公約数
        static long gcd(List<long> list)
        {
            var result = list[0];

            for (var i = 1; i < list.Count; i++)
            {
                result = gcd(result, list[i]);
            }

            return result;
        }

        // 最小公倍数
        static long lcm(long a, long b)
        {
            return a / gcd(a, b) * b;
        }

        // 最小公倍数
        static long lcm(List<long> list)
        {
            var result = list[0];
            for (var i = 1; i < list.Count; i++)
            {
                result = lcm(result, list[i]);
            }

            return result;
        }
    }
}


Measured memory_bytes: 27804
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Dhanin Gupta
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BFizzBuzzSum solver = new BFizzBuzzSum();
        solver.solve(1, in, out);
        out.close();
    }

    static class BFizzBuzzSum {
        public void solve(int testNumber, InputReader in, PrintWriter w) {

            long n = in.nextLong();
            long ans = 0;
            for (int i = 1; i <= n; i++) {
                if (i % 3 == 0 && i % 5 == 0)
                    continue;
                if (i % 3 == 0 || i % 5 == 0)
                    continue;

                ans += i;
            }
            w.println(ans);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 32680
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int count = 0;
        for(int i=0; i<s.length();i++) {
            if(s.charAt(i)!=t.charAt(i)) {
                count++;
            }
        }
        System.out.print(count);
    }
}

Measured memory_bytes: 41292
#include<iostream>
using namespace std;
int main(){
  string S;
  char s_i;
  cin >> S;
  long int black_start, white_start;
  black_start =0;
  white_start =0;
  for(int i=0; i<S.length(); i++){
    s_i = S[i];
    if(i%2 == 0){
      if(s_i == '0'){
        white_start++;
      }else{
        black_start++;
      }
    }else{
      if(s_i == '0'){
        black_start++;
      }else{
        white_start++;
      }
    }
  }
  if(black_start > white_start){
    cout << white_start << endl;
  }else{
    cout << black_start << endl;
  }
  return 0;
}

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

#define rep(i,start,end) for(int i=start;i<(int)(end);i++)
#define rrep(i,start,end) for(int i=start-1;i>=(int)(end);i--)
#define each(it,v) for(auto &it : v)
#define all(v) (v).begin(),(v).end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using vpii = vector<Pii>;
using vpll = vector<Pll>;

const ll mod=1e9+7;
const int intINF=INT_MAX;
const ll  longINF=LONG_LONG_MAX;

main()
{
        int n,k; cin>>n>>k;
        int ans=0;
        rep(i,0,n)
        {
                int a;
                cin>>a;
                ans+=min(a,abs(k-a));
        }
        cout<<ans*2<<endl;
}

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

long nonzerogcd(long p,long q){
    if(p<q){long temp=p;p=q;q=temp;}
    if(p%q==0){return q;}
    else{return nonzerogcd(q,p-q);}
}

void solve(int N, std::vector<long> A){
    long ans=A[0];
    for(int i=0;i<N;i++){
        ans=nonzerogcd(ans,A[i]);
    }
    printf("%ld\n",ans);
}


int main(){
    int N;
    scanf("%d",&N);
    std::vector<long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%ld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <string>
using namespace std;
using u8t = std::uint64_t;
using i8t = std::int64_t;
#define F(I,N) for(i8t I=0,I##_N=N;I<I##_N;I++)
#define FR(I,N) for(i8t I=N;I--;)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(_i,N){R(_x)V.push_back(_x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL1(line)
#define RM(V,L,C) std::vector<char> V;F(_i,L){RL(_l)F(_j,C)V.push_back(_l[_j]);}
#define P(X) std::cout<<(X)<<std::endl;
int main() {
  R(N)RL(dummy);
  RL(S);

  i8t nR=0,nG=0,nB=0;
  F(I,N){
    if(S[I]=='R')nR++;
    else if(S[I]=='G')nG++;
    else if(S[I]=='B')nB++;
  }
  i8t ntrip=nR*nG*nB;

  char mark[128];
  for(int d=1;d<=(N-1)/2;d++){
    F(I,N){
      if(!(I+d*2<N))break;
      mark['R']=0;
      mark['G']=0;
      mark['B']=0;
      mark[(int)S[I]]=1;
      mark[(int)S[I+d]]=1;
      mark[(int)S[I+d*2]]=1;
      if(mark['R']&&mark['G']&&mark['B'])
        ntrip--;
    }
  }
  //std::cout<<"["<<S<<"]"<<std::endl;
  P(ntrip);
  return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  int a[n], b[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  int c[m], d[m];
  for (int i = 0; i < m; i++) {
    cin >> c[i] >> d[i];
  }
  for (int i = 0; i < n; i++) {
    int min = abs(c[0] - a[i]) + abs(d[0]  - b[i]), index = 1;
    for (int j = 1; j < m; j++) {
      if (abs(c[j] - a[i]) + abs(d[j]  - b[i]) < min) {
        min = abs(c[j] - a[i]) + abs(d[j]  - b[i]);
        index = j + 1;
      }
    }
    cout << index << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		sc.close();

		int count = 0;
		for(int i = 1; i <= N; i++) {
			int numLen = String.valueOf(i).length();
			if(numLen % 2 == 1) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 28116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main() {
    ll N, a, H = 0, W = 0;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    sort(A.begin(), A.end());

    for(int i=N-1; i>=1; i--) {
        if(A[i] == A[i-1]) {
            if(H == 0) H = A[i];
            else if(W == 0) W = A[i];
            else break;
            i--;
        }
    }
    cout << H * W << endl;
}

Measured memory_bytes: 3780
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;

int main(){
    int n;
    cin >> n;
    bool three = true;
    REP(i, n){
        char c;
        cin >> c;
        if(c == 'Y') three = false;
    }
    if(three) cout << "Three" << endl;
    else cout << "Four" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			StringBuilder answer = new StringBuilder();
			String lb = System.getProperty("line.separator");
			
			String str = input.readLine();
			while (!"-".equals(str)) {
				final int m = Integer.parseInt(input.readLine());
				for (int i = 0; i < m; i++) {
					final int h = Integer.parseInt(input.readLine());
					str = (str.substring(h, str.length()) + str.substring(0, h));
				}
				answer.append(str).append(lb);
				str = input.readLine();
			}
			
			System.out.print(answer.toString());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

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

struct Node{
	int u, v, w;
};

vector <Node> ans;
int bits[25];

int main(){
	int L, rec;
	scanf("%d",&L);
	for (int i = 2; i <= 19; i++){
		ans.push_back((Node){i, i + 1, 0});
		ans.push_back((Node){i, i + 1, 1 << (19 - i)});
	}
	for (int i = 0; i <= 19; i++) bits[i] = (L & (1 << (19 - i)) ? 1 : 0);
	if (bits[0] == 1 && bits[1] == 1) ans.push_back((Node){1, 2, 1 << 19});
	if (bits[0] == 1) ans.push_back((Node){1, 2, 1 << 18});
	if (bits[0] + bits[1] >= 1) ans.push_back((Node){1, 2, 0});
	rec = (bits[0] << 19) + (bits[1] << 18);
	for (int i = 2; i <= 19; i++){
		if (bits[i] == 1) ans.push_back((Node){1, i + 1, rec});
		rec += (bits[i] << (19 - i));
	}
	printf("%d %d\n", 20, (int)ans.size());
	for (int i = 0; i < (int)ans.size(); i++)
		printf("%d %d %d\n", ans[i].u, ans[i].v, ans[i].w);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <cassert>
#include <iomanip>
#include <algorithm>
using namespace std;

#define EPS 1e-8
typedef complex<double> P;
typedef vector<P> G;

double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

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

bool intersectLS(const L &l, const L &s) {
  return cross(l[1]-l[0], s[0]-l[0])*       // s[0] is left of l
         cross(l[1]-l[0], s[1]-l[0]) < EPS; // s[1] is right of l
}

P crosspoint(const L &l, const L &m) {
  double A = cross(l[1] - l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
  if (abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
  return m[0] + B / A * (m[1] - m[0]);
}

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

bool notleft(P a, P b, P c)
{
	return (ccw(a,b,c)!=+1);
}

bool isIntoG(const G& g, const P& p)
{
	size_t sz = g.size();
	for(size_t i=0; i<sz; i++)
	{
		if( notleft(p, g[i], g[(i+1)%sz]) ) return false;
	}
	return true;
}

bool isfar(G& g, P& p)
{
	for(int i=0; i<g.size(); i++)
		if(abs(g[i]-p) < EPS) return false;
		
	return true;
}

#define CURR(P, i) P[i]
#define NEXT(P, i) P[(i+1)%P.size()]

bool ConvexCut(G& g, L& l, vector<G>& ret)
{
	int sp,inp=0;
	for(sp=0; sp<g.size(); sp++)
		if(intersectLS(l, L(g[sp], g[(sp+1)%g.size()]))) break;
		
	if(sp==g.size()) return false;
	
	ret.resize(2);
		
	P xp=crosspoint(l, L(g[sp], g[(sp+1)%g.size()]));
	sp++;
	
	for(int i=sp; i<sp+g.size(); i++)
	{
		if(isfar(ret[inp], g[i%g.size()])) ret[inp].push_back(g[i%g.size()]);
		if(intersectLS(l, L(g[i%g.size()], g[(i+1)%g.size()])))
		{
			P tx=crosspoint(l, L(g[i%g.size()], g[(i+1)%g.size()]));
			if(abs(tx-xp) < EPS) continue;
			
			xp=tx;
			for(int j=0; j<2; j++)
			{
				if(isfar(ret[j], xp)) ret[j].push_back(xp);
			}
			
			inp=(inp+1)%2;
		}
	}
	
	return true;
}

L trans(P a, P b)
{
	P med=(a+b);
	med=P(med.real()/2, med.imag()/2);
	P hoge=(a-b);
	hoge*=P(0,1);
	
	return L(med+hoge*P(1000,0), med-hoge*P(1000,0));
}

double Area(G& g)
{
	double ret=0;
	for(int i=0; i<g.size(); i++)
		ret+=cross(CURR(g,i), NEXT(g,i))/2;
		
	return ret;
}

int main()
{
	cout << setiosflags(ios::fixed) << setprecision(7);
	
	int N,M;
	while(cin >> N >> M, (N||M))
	{
		G g,pts;
		for(int i=0; i<N; i++)
		{
			double x,y;
			cin >> x >> y;
			g.push_back(P(x,y));
		}
		for(int i=0; i<M; i++)
		{
			double x,y;
			cin >> x >> y;
			pts.push_back(P(x,y));
		}
		
		for(int i=0; i<M; i++)
		{
			G f=g;
			for(int j=0; j<M; j++)
			{
				if(i==j) continue;
				L divide=trans(pts[i], pts[j]);
				vector<G> cut;
				if(!ConvexCut(f, divide,cut)) continue;
				if(isIntoG(cut[0], pts[i])) f=cut[0];
				else f=cut[1];
				
			}
			
			cout << Area(f) << endl;
		}
	}
}

Measured memory_bytes: 0
#include <cstring>
#include <cassert>
#include <utility>
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <bitset>
#include <chrono>
#include <cstdlib>
#include <functional>
#include <tuple>
#include <climits>
#include <limits>
#include <deque>
#include <list>
#include <array>
#include <stack>
#include <queue>
#include <random>
#include <complex>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
 
#define init ios::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL);
#define setpr(x) cout << setprecision((x))
#define PI atan(1)*4
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define in insert
#define er erase
#define mk(a , b) { min((a) , (b)) , max((a) , (b)) }
#define flush cout.flush()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endc "\n"
#define MOD 998244353
#define mod(x) (x) %= MOD
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;

// #define int ll
 
ll gcd(ll a, ll b){
    while(true){
        if(a>b)
            swap(a,b);
        if (a == 0) 
            return b; 
        ll p = b % a  , q = a;
        a = p;
        b = q;
    }
}
 
ll powerMod(ll x,ll y){
    ll res = 1;
    x %= MOD;
    while(y > 0){
        if(y & 1)res = (res*x)%MOD;
        y = y >> 1;
        x = (x * x)%MOD;
    }
    return res%MOD;
}
 
string binary(ll s) {
    string res = "";
    while(s != 0) {
        res += (char)('0' + s % 2);
        s /= 2;
    }
    reverse(res.begin() , res.end());
    return res;
}


//  =========     /\       /|    |====/|
//      |        /  \       |    |   / |
//      |       /____\      |    |  /  |
//      |      /      \     |    | /   |
//  ========= /        \  =====  |/====|  
//  code

int32_t main(){
    init;
    ll n,i,j,k,l,p;
    cin >> n;
    p = 0;
    set<int> s , ans;
    for(i = 2LL; i * i <= n; i++){
        if(n % i == 0){
            s.in(n / i);
            s.in(i);
        }
    }

    for(auto i : s){
        k = n;
        while(k % i == 0)k /= i;
        l = (k - 1) / i;
        if(i * l == k - 1 || k == 1){
            ans.in(i);
        }
    }


    for(i = 1LL; i * i <= n - 1LL; i++){
        if((n - 1LL) % i == 0){
            if(n % i)
                ans.in(i);
            if(n % ((n - 1LL) / i))
                ans.in((n - 1LL) / i);
        }
    }

    ans.in(n);
    cout << ans.size() << endc;
    return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;

int gcd(int x, int y);

const int INF = 1001001001;

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

int main() {
    ll n, d, ans = 0;
    cin >> d >> n;
    
    ans = n * pow(100, d);
    if (n == 100) {
        ans += 1 * pow(100, d);
    }

    cout << ans << endl;
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d,e;
	
	while(cin>>a>>b){
	d=a;
	e=b;
	if(b>a){
		d = a;
		a = b;
		b = d;
	}
	while(b!=0){
		c = a % b;
		a = b;
		b = c;
	}
std::cout<<a<<" "<<((e/a)*(d/a)*a)<<endl;
	}
}

Measured memory_bytes: 0
import sys
from functools import reduce
X, Y = map(int, input().split())
mod = 10**9 + 7

if (X+Y)%3 != 0:
    print(0)
    sys.exit()

if 2 * min(X, Y) < max(X, Y):
    print(0)
    sys.exit()

def f(n, A):
    if A == 0:
        return 1
    bunsi = reduce(lambda x, y: x*y%mod, range(n, n-A, -1))
    bunbo = reduce(lambda x, y: x*y%mod, range(1, A+1))
    return bunsi * pow(bunbo, mod-2, mod) % mod

ans = 0
r, d = 0, 0
if X == Y:
    r, d = X//3, Y//3
    ans = f(r+d, d)%mod
else:
    r = abs(X-Y) + ((X+Y) - 3*abs(X-Y))//6
    d = ((X+Y) - 3*abs(X-Y))//6
    ans = f(r+d, d)%mod

print(ans)

Measured memory_bytes: 3572
/* BISMILLAHIR RAHMANIR RAHIM */
#include <bits/stdc++.h>
using namespace std;

int main() 
{
	ios_base :: sync_with_stdio(0);  
	set<int> st;
	for(int i = 1, a; i <= 3; i++) {
		cin >> a;
		st.insert(a);
	}
	cout << st.size();
	return 0;
}

Measured memory_bytes: 256
import numpy as np
N = int(input())
A = list(map(int, input().split()))
B = [0] * (N+1)  # 累積和テーブル B[i] = sum(A[:i])
mod = 10**9 + 7
ans = 0

for i in range(N):
    B[i+1] = B[i] + A[i]  # 累積和

for i in range(N):
    sum = (B[N] - B[i+1]) % mod
    ans += A[i] * sum
    ans %= mod

print(int(ans))

Measured memory_bytes: 49988
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

struct SuffixArray {
    string s;
    size_t n;
    vector<size_t> sarray;
    vector<int> rank;
    SuffixArray(string s): s(s), n(s.length()) {
        sarray.assign(n+1, 0);
        rank.assign(n+1, 0);

        for (size_t i=0; i<=n; ++i) {
            sarray[i] = i;
            rank[i] = i<n? s[i]:-1;
        }

        vector<size_t> tmp(n+1);
        for (size_t k=1; k<=n; k<<=1) {
            auto comp=[&, k](size_t i, size_t j)->bool {
                if (rank[i] != rank[j])
                    return rank[i] < rank[j];

                int ri=i+k<=n? rank[i+k]:-1;
                int rj=j+k<=n? rank[j+k]:-1;
                return ri < rj;
            };
            sort(sarray.begin(), sarray.end(), comp);
                
            for (size_t i=1; i<=n; ++i)
                tmp[sarray[i]] = tmp[sarray[i-1]]+comp(sarray[i-1], sarray[i]);

            for (size_t i=0; i<=n; ++i)
                rank[i] = tmp[i];
        }
    }
    bool is_substr(string t) {
        size_t lb=0, ub=s.length();
        while (ub-lb > 1) {
            size_t mid=(lb+ub)>>1;
            (s.compare(sarray[mid], t.length(), t)<0? lb:ub) = mid;
        }
        return !s.compare(sarray[ub], t.length(), t);
    }
};

int main() {
    char buf[1<<20];
    scanf("%s", buf);
    string T(buf);

    SuffixArray sa(T);

    size_t Q;
    scanf("%zu", &Q);

    for (size_t i=0; i<Q; ++i) {
        scanf("%s", buf);
        string P(buf);

        printf("%d\n", sa.is_substr(P));
    }

    return 0;
}

Measured memory_bytes: 24928
import copy
import math
import time
import statistics
import math

# a = get_int()
def get_int():
    return int(input())
# a = get_string()
def get_string():
    return input()
# a_list = get_int_list()
def get_int_list():
    return [int(x) for x in input().split()]
# a_list = get_string_list():
def get_string_list():
    return input().split()
# a, b = get_int_multi()
def get_int_multi():
    return map(int, input().split())
# a_list = get_string_char_list()
def get_string_char_list():
    return list(str(input()))
# print("{} {}".format(a, b))
# for num in range(0, a):
# a_list[idx]
# a_list = [0] * a
'''
while (idx < n) and ():

    idx += 1
'''

def main():
    start = time.time()

    n, k = get_int_multi()
    a = get_int_list()
    ans = 10 ** 10 * 15

    for i in range(2 ** n):
        count = 0
        for ii in range(n):
            if (i >> ii) & 1:
                count += 1
        if count != k: #k個の1がない場合はスキップ
            continue

        wk_high = 0
        money = 0
        for ii in range(n):
            if (i >> ii) & 1:
                add_money = max(0, wk_high + 1 - a[ii])
                money += add_money
                wk_high = a[ii] + add_money
            else:
                wk_high = max(wk_high, a[ii])
        ans = min(ans, money)
    print(ans)




if __name__ == '__main__':
    main()




Measured memory_bytes: 11040
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cerr << #v "=" << (v) << endl;
#define ppa(v) cerr << "- " << #v << endl; rep(i,v.size()) cerr << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define INF 0x3f3f3f3f
#define LLINF 1000111000111000111LL
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;

int main() {
  ll n;cin>>n;
  if (n%2==1) {
    cout << 0 << endl;
    exit(0);
  }

  n /= 2;
  ll ans = 0;
  ll d = 5;
  rep(i,25) {
    ans += n/d;
    d *= 5;
  }
  cout << ans << endl;
}


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

typedef struct {
    char word[32];
    int count;
} DICT;

DICT list[1024];
int n;

void insert(char *str)
{
    strcpy(list[n].word, str);
    list[n++].count++;
}

void search(char *str)
{
    int i;
    for (i = 0; i < n; i++){
        if (strcmp(list[i].word, str) == 0){
            list[i].count++;
            return;
        }
    }
    insert(str);
}

int comp(const void *a, const void *b)
{
    DICT x, y;
    x = *(DICT *)a;
    y = *(DICT *)b;
    
    if (x.count == y.count){
        return (strcmp(x.word, y.word));
    }
    return (y.count - x.count);
}

int main(void)
{
    int N;
    char str[128][2048];
    char capital;
    int i, j;
    int show;
    char *p;
    
    while (1){
        scanf("%d", &N);
        if (N == 0){
            break;
        }
        getchar();
        for (i = 0; i < N; i++){
            fgets(str[i], 2048, stdin);
        }
        scanf("%c", &capital);
        getchar();
        
        n = 0;
        for (i = 0; i < 1024; i++){
            memset(list[i].word, '\0', sizeof(list[i].word));
            list[i].count = 0;
        }
        
        for (i = 0; i < N; i++){
            p = strtok(str[i], " \n");
            if (p != NULL && p[0] == capital){
                search(p);
            }
            while (p != NULL){
                p = strtok(NULL, " \n");
                if (p != NULL && p[0] == capital){
                    search(p);
                }
            }
        }
        
        qsort(list, n, sizeof(DICT), comp);
        
        if (n == 0){
            printf("NA\n");
        }
        else {
            show = 5 > n ? n : 5;
            for (i = 0; i < show; i++){
                printf("%s%c", list[i].word, i == show - 1 ? '\n' : ' ');
            }
        }
    }
    
    return (0);
}

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

int main(){
  int a,b, c, d;
  cin >> a >> b >> c >> d;
  while (true)
  {
    c-=b;
    if(c<=0){cout << "Yes" << endl; break;}
    a-=d;
    if(a<=0){cout << "No" <<endl; break;}
  }
  return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,mod=1000000007,f[100009],dp[100009],dp2[100009],pas;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a>>b;
	for(c=1; c<=a; c++) cin>>f[c];
	for(c=0; c<=f[1]; c++) dp[c]=1;
	for(c=1; c<=b; c++){
		dp[c]+=dp[c-1];
		dp[c]%=mod;
	}
	for(c=2; c<=a; c++){
		for(d=0; d<=b; d++){
			e=max(d-f[c],0LL);
			dp2[d]=dp[d];
			if(e!=0) dp2[d]=dp2[d]-dp[e-1]+mod;
			dp2[d]%=mod;
		}
		for(d=1; d<=b; d++){
			dp2[d]+=dp2[d-1];
			dp2[d]%=mod;
		}
		for(d=0; d<=b; d++){
			dp[d]=dp2[d];
			dp2[d]=0;
		}
	}
	pas=(dp[b]-dp[b-1]+mod*2)%mod;
	cout<<pas;
	return 0;
}

Measured memory_bytes: 1792
const processData = (lines) => {
  const r = +lines[0]
  console.log(r*Math.PI * 2)
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
  const {EOL} = require('os')
  const lines = i.split(EOL) /*your input text, split by lines*/
  processData(lines)
})


Measured memory_bytes: 29884
import java.util.Scanner;

public class Main{
	
	static final Scanner s=new Scanner(System.in);
	
	public static void main(String args[]){
		Dice d=new Dice();
		for(int i=0; i<6; i++)
			d.v[i]=s.nextInt();
		for(int i=s.nextInt(); i>0; i--){
			int c=0, u=s.nextInt(), f=s.nextInt();
			while(d.v[1]!=f){
				d.roll(c%2==0?'l':'n');
				c++;
			}
			while(d.v[0]!=u)
				d.roll('e');
			System.out.println(d.v[2]);
		}
	}
}

class Dice{
	
	public int v[]={1,2,3,4,5,6};
	
	/*
	 *    ####
	 *   #1 ##
	 *  #  # #
	 * ####3 #
	 * #2 # #
	 * #  ##
	 * ####
	 * 
	 */
	public Dice(){
	}
	
	public void roll(char direction){
		int buf=v[0];
		switch(direction){
		case 'n':
		case 'N':
			v[0]=v[1];
			v[1]=v[5];
			v[5]=v[4];
			v[4]=buf;
			return;
		case 's':
		case 'S':
			v[0]=v[4];
			v[4]=v[5];
			v[5]=v[1];
			v[1]=buf;
			return;
		case 'e':
		case 'E':
			v[0]=v[3];
			v[3]=v[5];
			v[5]=v[2];
			v[2]=buf;
			return;
		case 'w':
		case 'W':
			v[0]=v[2];
			v[2]=v[5];
			v[5]=v[3];
			v[3]=buf;
			return;
		
		case 'r':
		case 'R':
			buf=v[1];
			v[1]=v[2];
			v[2]=v[4];
			v[4]=v[3];
			v[3]=buf;
			return;
		case 'l':
		case 'L':
			buf=v[1];
			v[1]=v[3];
			v[3]=v[4];
			v[4]=v[2];
			v[2]=buf;
			return;
		default:
			throw new IllegalArgumentException("Illeagal direction");
		}
	}
}

Measured memory_bytes: 26140
N,T=map(int,input().split())
cost=float('inf')
flg=0
for i in range(N):
    c,t=map(int,input().split())
    if t<=T:
        if c<cost:
            cost=c
            flg=1
        
if flg==0:
    print('TLE')
else:
    print(cost)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define oo 0x3f3f3f3f
#define ooLL 0x3f3f3f3f3f3f3f3f
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define fastio() ios_base::sync_with_stdio(false); cin.tie(NULL)
const int mod = 1e9+7;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
 
int main(){
    int n;
    scanf("%d", &n);
    map<ll,int> m;
    vector<ll> B(n+1);
    ll ans = 0LL;
    for(int i = 1; i <= n ; ++i){
        int k;
        scanf("%d", &k);
        m[k+i]++;
        B[i] = i-k;
    }

    for(int i = 1; i <= n ; ++i){
        ans+= m[B[i]];
    }

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

    return 0;
}

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

int main() {
    long n, k, ans = LONG_MAX;
    cin >> n >> k;
    vector<long> x(n);
    rep(i, n) cin >> x.at(i);
    rep(i, n - k + 1) {
        long temp = min(abs(x.at(i)), abs(x.at(i + k - 1)));
        temp += abs(x.at(i) - x.at(i + k - 1));
        ans = min(ans, temp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.Arrays;


public class Main {
  public static void main (String[] args) {
    Scanner reader = new Scanner(System.in);
    int A = reader.nextInt();
    String[] list = new String[A];
    for (int i = 0; i < A; i++) {
    	list[i] = reader.next();
      	if (i > 0) {
          if (list[i-1].charAt(list[i-1].length() - 1) !=  list[i].charAt(0)) {
            System.out.print("No");
              return;
          }
          for (int j = i - 1; j >= 0; j--) {
          	if (list[j].equals(list[i])) {
             System.out.print("No");
              return;
            }
          }
        }
    }
    
    System.out.print("Yes");
    
}
  
}

Measured memory_bytes: 24916
program atcoder0404_B
  integer,dimension(:),allocatable::A
  read(5,*)N,M
  allocate(A(N))
  read(5,*)A
  do I=1,N-1
     TC=A(I)
     IC=I
     do J=I+1,N
        if(TC>A(J)) then
           TC=A(J)
           IC=J
        end if
     end do
     A(IC)=A(I)
     A(I)=TC
  end do
  if(A(N-M+1)*4*M>=sum(A)) then
     write(6,*)'Yes'
  else
     write(6,*)'No'
  end if
end program atcoder0404_B

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

int main(){
  double W,H,x,y;
  cin  >> W >>H >>x >>y;
  if(x == W/2 && y == H/2){
    cout << fixed << setprecision(10);
    cout << W * H / 2 ;
  cout  << " " << 1 <<endl;
  } 
  else{
    cout << fixed << setprecision(10);
    cout << W * H / 2 ;
    cout << " " << 0 << endl;
  }
}

  
    
    
    

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

class Main {

	public static void main(String[] args) throws IOException {

		Scanner scane = new Scanner(System.in);

		int[][] A = new int[3][10];
		int[][] B = new int[3][10];
		int[][] C = new int[3][10];
		int[][] D = new int[3][10];

		for(int i =0; i<3;i++){
			for(int j = 0; j<10; j++){
				A[i][j] =0;
				B[i][j] =0;
				C[i][j] =0;
				D[i][j] =0;
			}

		}

		int n = scane.nextInt();
		int b, f, r, v;

		for (int i = 0; i < n; i++) {
			b = scane.nextInt();
			f = scane.nextInt();
			r = scane.nextInt();
			v = scane.nextInt();

			if (b == 1) {
				A[f - 1][r - 1] = A[f - 1][r - 1]+v;
			} else if (b == 2) {
				B[f - 1][r - 1] = B[f - 1][r - 1]+v;
			} else if (b == 3) {
				C[f - 1][r - 1] = C[f - 1][r - 1]+v;
			} else if (b == 4) {
				D[f - 1][r - 1] = D[f - 1][r - 1]+v;
			}
		}
		for (int i = 0; i < A.length; i++) {
			for (int j = 0; j < A[0].length; j++) {
				System.out.print(" " + A[i][j]);
			}
			System.out.println("");
		}
		for (int i = 0; i < 20; i++) {
			System.out.print("#");
		}
		System.out.println("");


		for (int i = 0; i < B.length; i++) {
			for (int j = 0; j < B[0].length; j++) {
				System.out.print(" " + B[i][j]);
			}
			System.out.println("");
		}
		for (int i = 0; i < 20; i++) {
			System.out.print("#");
		}
		System.out.println("");

		for (int i = 0; i < C.length; i++) {
			for (int j = 0; j < C[0].length; j++) {
				System.out.print(" " + C[i][j]);
			}
			System.out.println("");
		}
		for (int i = 0; i < 20; i++) {
			System.out.print("#");
		}
		System.out.println("");


		for (int i = 0; i < D.length; i++) {
			for (int j = 0; j < D[0].length; j++) {
				System.out.print(" " + D[i][j]);
			}
			System.out.println("");
		}



	}
}

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
 
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	int gx,gy;
	cin >>s >>gx >>gy;
	
	
	int n=sz(s);
	
	VI ct(n);
	int cc=0;
	rep(i, n){
		if(s[i]=='T'){ cc++; continue;}
		ct[cc]++;
	}
	const int saz=20000;
	vector<char> bx(saz), by(saz);
	bx[ct[0]+10000] = 1;
	by[10000] = 1;
	rep2(i,1,n){
		if(ct[i]==0) continue;
		if(i%2 ==0){
			vector<char> nx(saz);
			rep(j,saz){
				if(bx[j]==1) nx[j-ct[i]] = nx[j+ct[i]] = 1;
			}
			swap(bx, nx);
		}else{
			vector<char> ny(saz);
			rep(j,saz){
				if(by[j]==1) ny[j-ct[i]] = ny[j+ct[i]] = 1;
			}
			swap(by, ny);
		
		}
	}

	if(bx[gx+10000]==0){ puts("No"); return 0;}
	if(by[gy+10000]==0){ puts("No"); return 0;}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main(){
	int  W,H,x,y,r;
	
	cin >> W >> H >> x >> y >> r ;
	
	if (( x - r >= 0 && x + r <= W )&& y - r >= 0 && y + r <= H){
		cout << "Yes" <<endl;
	}
	
	else if (( x - r < 0 || x + r > W)|| y - r < 0 || y + r > H){
		cout <<"No"<<endl;
	}

	return 0;
}

Measured memory_bytes: 1156
/*================================================================
*   Copyright (C) 2019 Sangfor Ltd. All rights reserved.
*
*   创 建 者： badcw
*   创建日期： 2019/12/29
*
================================================================*/
#include <bits/stdc++.h>

#define ll long long
using namespace std;

const int maxn = 1e5+50;
const int mod = 1e9+7;
ll qp(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

template <class T>
inline bool scan(T& ret) {
    char c;
    int sgn;
    if (c = getchar(), c == EOF) return 0; // EOF
    while (c != '-' && (c < '0' || c > '9')) c = getchar();
    sgn = (c == '-') ? -1 : 1;
    ret = (c == '-') ? 0 : (c - '0');
    while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
    ret *= sgn;
    return 1;
}

//template <class T>
//inline void out(T x) {
//    if (x > 9) out(x / 10);
//    putchar(x % 10 + '0');
//}

int n, k;
char a[maxn];
char t[] = "rpsrp";
int c[4];
vector<char> e[maxn];
int dp[maxn][3];

int main(int argc, char* argv[]) {
    scanf("%d%d", &n, &k);
    for (int i = 0; i < 3; ++i) scanf("%d", &c[i]);
    swap(c[1], c[2]);
//    scanf("%d%d%d", &r, &s, &p);
    scanf("%s", a);
    for (int i = 0; i < n; ++i) {
        e[i % k].push_back(a[i]);
    }
    ll ans = 0;
    for (int _ = 0; _ < k; _++) {
        for (int i = 0; i < 3; ++i) {
            if (t[i] == e[_][0]) {
                dp[0][i] = 0;
                dp[0][(i + 1) % 3] = c[(i + 1) % 3];
                dp[0][(i + 2) % 3] = 0;
                break;
            }
        }
        for (int i = 1; i < e[_].size(); ++i) {
            for (int j = 0; j < 3; ++j) {
                if (t[j] == e[_][i]) {
                    dp[i][j] = max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]);
                    dp[i][(j + 1) % 3] = max(dp[i - 1][(j + 2) % 3], dp[i - 1][(j + 3) % 3]) + c[(j + 1) % 3];
                    dp[i][(j + 2) % 3] = max(dp[i - 1][(j + 3) % 3], dp[i - 1][(j + 4) % 3]);
                }
            }
        }
        ans += max(dp[e[_].size() - 1][0], max(dp[e[_].size() - 1][1], dp[e[_].size() - 1][2]));
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 5504
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int x = 1, cnt = 0;
  bool ans = false;
  while (cnt < n) {
    if (x == 2) {
      ans = true;
      break;
    }
    cnt++;
    x = a[x - 1];
  }
  if (ans) cout << cnt << endl;
  else cout << -1 << endl;
}


Measured memory_bytes: 640
package main

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

const size = 1000000
var reader = bufio.NewReaderSize(os.Stdin,size)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for ;isPrefix; {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func Next2Ints() (int,int) {
  var x,y int
  var s []string = strings.Split(NextLine()," ")
  x,_ = strconv.Atoi(s[0])
  y,_ = strconv.Atoi(s[1])
  return x,y
}
func Next3Ints() (int,int,int) {
  var x,y,z int
  var s []string = strings.Split(NextLine()," ")
  x,_ = strconv.Atoi(s[0])
  y,_ = strconv.Atoi(s[1])
  z,_ = strconv.Atoi(s[2])
  return x,y,z
}

func main() {
  var n,k int = Next2Ints()
  var s []int = make([]int,100000)
  var t []int = make([]int,100000)
  var c []int = make([]int,100000)
  var sm []int = make([]int,200002)
  for i:=0;i<n;i++ {
    s[i],t[i],c[i] = Next3Ints()
  }
  for j:=1;j<=k;j++ {
    var tt []int = make([]int,200002)
    for i:=0;i<n;i++ {
      if c[i] == j {
        tt[2*s[i]-1]++
        tt[2*t[i]]--
      }
    }
    for i:=1;i<200002;i++ {
      tt[i] += tt[i-1]
    }
    for i:=0;i<200002;i++ {
      if tt[i] > 0 { sm[i]++ }
    }
  }
  var x int
  for i:=0;i<200002;i++ {
    if x < sm[i] { x = sm[i] }
  }
  fmt.Println(x)
}

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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

#define loop(i, n) for(int i = 0;i < n;i++)
#define IINF 2e9
#define MOD 1e9+7

int main(void){

    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;

    cout << 15-a-b-c-d-e << endl;

    return 0;
}

Measured memory_bytes: 3616
#include <cstdio>

using namespace std;

void next(int&y,int&m,int&d)
{
  bool bg = (y%3==0 || m%2!=0);
  ++d;
  if(bg) {
    if( d > 20 ) m++,d=1;
    if( m > 10 ) y++,m=1;
  } else {
    if( d > 19 ) m++,d=1;
    if( m > 10 ) y++,m=1;
  }
}

int sol(int y,int m,int d)
{
  int res = 0;
  while(y!=1000 || m!=1 || d!=1) {
    next(y,m,d);
    ++res;
  }
  return res;
}

int main(void)
{
  int n,y,m,d;
  scanf("%d",&n);
  for(int i = 0; i < n; i++) {
    scanf("%d%d%d",&y,&m,&d);
    printf("%d\n",sol(y,m,d));
  }
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
vector<long long> P;
vector<long long> Q;
int W, H;
cin>>W>>H;
int a;
for(int i = 0; i < W; ++i){
cin>>a;
P.push_back(a);
}
for(int j = 0; j < H; ++j){
cin>>a;
Q.push_back(a);
}
sort(Q.begin(), Q.end());
sort(P.begin(), P.end());
int ptr1 = 0;
int ptr2 = 0;
long long c1 = W + 1;
long long c2 = H + 1;
long long ans = 0;
while(ptr1 < W && ptr2 < H){
        if(P[ptr1] <= Q[ptr2]){
            ans += (long long)(c2 * P[ptr1++]);
            c1--;
        }
        else{
            ans += (long long)(c1 * Q[ptr2++]);
            c2--;
        }
    }
    while(ptr1 < W){
            ans += (long long)(c2 * P[ptr1++]);
            c1--;
    }
    while(ptr2 < H){
            ans += (long long)(c1 * Q[ptr2++]);
            c2--;
    }
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 2548
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    string s;
    cin >> s;
    
    int g_cnt = 0, p_cnt = 0;
    for(int i = 0; i < s.length(); ++i){
        if(s[i] == 'g')     g_cnt++;
        else                p_cnt++;
    }
    
    cout << (s.length() / 2) - p_cnt << endl;
}

Measured memory_bytes: 512
n,k=map(int,input().split())


if k==n+1:
  print(1)
  exit(0)

l=[]
temp=0
for i in range(n+1):
  temp+=i
  l.append(temp)

count=0
for i in range(k,n+2):
  if n-i<0:
    we=l[-1]-l[i-1]+1
  else:
    we=l[-1]-l[i-1]-l[n-i]+1
  count+=we
  
print(count%(10**9+7))

Measured memory_bytes: 19436
#include<bits/stdc++.h>
using namespace std;
#pragma region atcoder
//#include <atcoder/all>
//using namespace atcoder;
#pragma endregion
#pragma region macros
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vl = vector<ll>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n - 1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#pragma endregion
#pragma region debug for var, v, vv
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){cout << endl;int cnt = 0;for(const auto& v : vv){cout << cnt << "th : "; view(v); cnt++;} cout << endl;}
#pragma endregion

const ll mod = 1000000007;
const int inf = 1001001001;
const ll INF = 1001001001001001001;
const int MAX = 2000005;

//using mint = modint998244353;
//These are for segment tree
/*int op(int a, int b){return max(a, b);}
int e(){return -1;}
bool f(int v){ return v < target;}
*/

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

template<class T>bool chmax(T &a, const T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T b) { if (b<a) { a=b; return 1; } return 0; }
ll modpow(ll a, ll p){ll ret = 1; while(p){if(p & 1){ret = ret * a % mod;} a = a * a % mod; p >>= 1;} return ret;}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, x, m; cin >> n >> x >> m;
	vl rem(1);
	vb done(m + 1, false);
	rem[0] = x;
	done[x] = true;
	ll now = x;
	for(int i = 0; i <= m; i++){
		now *= now;
		now %= m;
		if(done[now]){
			break;
		}
		done[now] = true;
		rem.push_back(now);
	}
	int rsz = rem.size();
	int roop;
	for(int i = 0; i < rsz; i++){
		if(rem[i] == now) roop = i;
	}
	ll ans = 0;
	if(now == 0){
		for(int i = 0; i < min((ll)rsz, n); i++){
			ans += rem[i];
		}
		cout << ans << endl;
	}
	else{
		n -= roop;
		ll cnt = 0; //循環和
		ll roop_size = rsz - roop;
		for(int i = 0; i < roop; i++) ans += rem[i];
		for(int i = roop; i < rsz; i++) cnt += rem[i];
		ll time = n / roop_size;
		ll res = n % roop_size;
		ans += time * cnt;
		for(int i = roop; i < roop + res; i++){
			ans += rem[i];
		}
		cout << ans << endl;
	}
} 


Measured memory_bytes: 3848