akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define rep(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQI;
typedef priority_queue<int,vector<int>,greater<int> > PQSI;
typedef priority_queue<ll> PQL;
typedef priority_queue<ll,vector<ll>,greater<ll> > PQSL;

const int MOD = 1000000007;
struct mint { int n; mint(int n_ = 0) : n(n_) {} };
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};
void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) { check_fact(abs(n)); return n >= 0 ? I_[n] : -I_[n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T>
vector<T> enum_div(T n){
    vector<T> ret;
    for(T i=1;i*i<=n;i++){
        if(n%i==0){
            ret.push_back(i);
            if(i*i!=n) ret.push_back(n/i);
        }
    }
    //sort(ret.begin(), ret.end());
    return ret;
}
template<typename T>
T gcd(T x, T y){
    if (y == 0) return x;
    else return gcd(y, x % y);
}
template<typename T>
T lcm(T x, T y){
    return (x / gcd(x, y)) * y;
}

string S, T;
int main(void){
    cin >> S;
    cin >> T;
    int count = 0;
    rep(i,3){
        if(S[i] == T[i]) count++;
    }
    cout << count << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, c;
    cin >> n >> c;
    VVI d(c, VI(c));
    REP(i,c) REP(j,c) d[i][j] = in();
    VVI a(n, VI(n));
    REP(i,n) REP(j,n) a[i][j] = in() - 1;

    vector<vector<P> > rank(3, vector<P>(c));
    REP(m,3){
        REP(x,c){
            int tmp = 0;
            REP(i,n) REP(j,n){
                if ((i + j) % 3 == m) tmp += d[a[i][j]][x];
            }
            rank[m][x] = P(tmp, x);
        }
        sort(ALL(rank[m]));
    }

    int ans = 1e9 + 100;
    REP(x,3) REP(y,3) REP(z,3){
        if (rank[0][x].second == rank[1][y].second) continue;
        if (rank[0][x].second == rank[2][z].second) continue;
        if (rank[2][z].second == rank[1][y].second) continue;
        ans = min(ans, rank[0][x].first + rank[1][y].first + rank[2][z].first);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
     
    double x, y;
    double a, b, p;
    double c, d, q;
 
    while (cin >> a >> b >> p >> c >> d >> q){
 
        x = (double)((p * d - b * q) / (a * d - b * c));
        y = (double)((a * q - p * c) / (a * d - b * c));
        if (x == 0)x = 0;
        if (y == 0)y = 0;
        printf("%.3f %.3f\n", x, y);
    }
}

Measured memory_bytes: 1240
{-# LANGUAGE OverloadedStrings #-}

import qualified Data.ByteString.Char8 as B
import Data.Attoparsec.ByteString.Char8
import qualified Data.List as L

type Input = (Int, Int, Int)

input :: Parser Input
input = (,,)
  <$> decimal <* space
  <*> decimal <* space
  <*> decimal <* endOfLine

main :: IO ()
main = B.interact
  $ B.pack . show . either (error "parse err") solve . parseOnly input

solve :: Input -> Int
solve (a, b, k) = L.head
  $ L.drop (k - 1)
  $ [ i | i <- [100, 99 .. 1], a `mod` i == 0 && b `mod` i == 0 ]

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

public class Main {
    public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] a = new int[N];
    for(int i = 0; i<N; i++){
        a[i] = sc.nextInt();
    }
    Arrays.sort(a);
    System.out.println((a[a.length-1] - a[0]));
    }

}


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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		int ans = 0;
		for (int i = 3; i <= n; i += 2) {
			int cnt = 0;
			for (int j = 1; j <= i; j++) {
				if (i % j == 0) {
					cnt++;
				}
			}
			
			if (cnt == 8) {
				ans++;
			}
		}

		pr.println(ans);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 23252
#include <iostream>
#include <vector>

using namespace std;
template<class T> inline bool chmax(T &a, T b){ if(a < b){a = b; return true;} return false;}

struct Edge{
    int from,to,weight;
    Edge(int f,int t,int w) : from(f), to(t), weight(w){}
};

using Edges = vector<Edge>;
using Graph = vector<Edges>;

class Tree{
    public:
        Tree(int size) : mGraph(size) {}
        void add_edge(int s, int t, int w = 1){
            mGraph[s].emplace_back(s,t,w);
            mGraph[t].emplace_back(t,s,w);
        }

        // diameter of a tree
        pair<int,int> dfs(int v, int pv){
            pair<int,int> ret(0,v);
            for(Edge nv : mGraph[v]){
                if(nv.to == pv) continue;
                pair<int,int> tmp = dfs(nv.to,v);
                if(chmax(ret.first,tmp.first + nv.weight)){
                    ret.second = tmp.second;
                }
            }
            return ret;
        }

        int diameter(){
            pair<int,int> s = dfs(0,-1);
            pair<int,int> t = dfs(s.second,-1);
            return t.first;
        }
        //
    private:
        Graph mGraph;
};

int main(){
    int n,s,t,w;
    cin >> n;
    Tree tree(n);
    for(int i = 0; i < n-1; ++i){
        cin >> s >> t;
        --s;--t;
        tree.add_edge(s,t);
    }
    cout << (tree.diameter() % 3 != 1 ? "First" : "Second") << '\n';
    return 0;
}

Measured memory_bytes: 19200
import java.util.Scanner;

public class Main {
  private static final int MOD = (int) Math.pow(10, 9) + 7;

  public static void main(String[] args) {
    Long result = null;

    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    boolean isOddN = (N % 2 == 1);
    int[] a = new int[N];
    for (int i = 0; i < N; i++) {
      int tmpA = sc.nextInt();
      if (tmpA % 2 == 1) {
        if (isOddN) {
          result = Long.valueOf(0);
          break;
        }
        if (a[tmpA - 1] != tmpA) {
          a[tmpA - 1] = tmpA;
        } else if (a[tmpA] != tmpA) {
          a[tmpA] = tmpA;
        } else {
          result = Long.valueOf(0);
          break;
        }
      } else {
        if (!isOddN) {
          result = Long.valueOf(0);
          break;
        }
        if (tmpA == 0) {
          if (a[0] == 1) {
            result = Long.valueOf(0);
            break;
          }
          a[0] = 1;
        } else if (a[tmpA - 1] != tmpA) {
          a[tmpA - 1] = tmpA;
        } else if (a[tmpA] != tmpA) {
          a[tmpA] = tmpA;
        } else {
          result = Long.valueOf(0);
          break;
        }
      }
    }
    sc.close();

    if (result != null) {
      System.out.println(0);
      return;
    }

    int mlt = N / 2;
    result = Long.valueOf(1);
    for (int i = 0; i < mlt; i++) {
      result = (result * 2) % MOD;
    }
    System.out.println((int) result.longValue());
  }
}


Measured memory_bytes: 50896
#include <cstdio>
#include <map>

using namespace std;

int main() {
	while (true) {
		int N;
		scanf("%d", &N);

		if (N == 0) break;

		int gem[21][21] = {};
		for (int i = 0; i < N; i++) {
			int x, y;
			scanf("%d %d\n", &x, &y);
			gem[x][y] = 1;
		}

		pair<int, int> bot = make_pair(10, 10);

		int M;
		scanf("%d%*c", &M);

		int x = 10, y = 10;
		int cnt = 0;
		for (int i = 0; i < M; i++) {
			char c;
			int l;
			scanf("%c %d%*c", &c, &l);

			pair<int, int> d;
			if (c == 'N') d = make_pair(0, 1);
			if (c == 'E') d = make_pair(1, 0);
			if (c == 'W') d = make_pair(-1, 0);
			if (c == 'S') d = make_pair(0, -1);
			for (int j = 0; j < l; j++) {
				x += d.first;
				y += d.second;
				cnt += gem[x][y];
				gem[x][y] = 0;
			}
		}

		if (cnt == N) printf("Yes\n");
		else printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 1012
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const int MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

ll fac[1] = {1}, inv[1] = {1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}
ll cmb(ll r, ll c) {return (c>r||c<0) ? 0:fac[r] * inv[c] % MOD * inv[r - c] % MOD;}

// 3이상만 사용 가능

int n;
ll dp[2001];
ll go(int o) {
    if (o > n) return 0;
    if (o == n) return 1;
    if (dp[o] != -1) return dp[o];

    ll ret = 0;
    for (int i = 3; i <= 2000; i++) {
        ret += go(o + i);
    }
    return dp[o] = ret % MOD;
}

int main() {
    memset(dp, -1, sizeof(dp));
    scanf("%d", &n);
    printf("%lld", go(0));
}


// author: rdd6584


Measured memory_bytes: 3864
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    long[] A;
    int N;
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        N = int.Parse(Console.ReadLine());
        string[] str = Console.ReadLine().Split(' ');
        A = new long[N];
        for(int i=0;i<N;i++){
            A[i] = long.Parse(str[i]);
        }
        long bf = 0;
        long bl = 510000000000000000/N;
        while(bf != bl){
            long bc = (bf+bl)/2;
            if(check(bc*N)){
                bl = bc;
            }
            else{
                bf = bc+1;
            }
        }
        if(bf == 0){
            sb.Append("0\n");
            return;
        }
        for(long bc=(bf-1000)*N+1;bc<=bf*N;bc++){
            if(bc >= 0 && check(bc)){
                sb.Append(bc+"\n");
                return;
            }
        }
    }
    bool check(long bc){
        long count = 0;
        for(int i=0;i<N;i++){
            long X = A[i]+bc;
            if(X < N){
                continue;
            }
            if((X-N+1) % (N+1) == 0){
                count += (X-N+1) / (N+1);
            }
            else{
                count += (X-N+1) / (N+1) + 1;
            }
        }
        return count <= bc;
    }
}

Measured memory_bytes: 11220
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
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; }
using namespace std;


int main(){
  int N;
  cin>>N;
  int X[N],Y[N];
  REP(i,N) cin>>X[i]>>Y[i];
  
  double SUM=0;
  
  for(int i=0; i<N-1; ++i){
    for(int j=i+1; j<N; ++j){
      SUM+=sqrt(pow(X[i]-X[j],2)+pow(Y[i]-Y[j],2));
    }
  }
  
  SUM=SUM*2/N;
  
  cout<<setprecision(8)<<SUM<<endl;
  
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
const int N = 1000 * 1000 + 10, mod = 1e9 + 7;
int r[N], c[N];
long long ans = 1, sr, sc;
int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		x--;
		r[x] = 1;
	}
	for (int i = 0; i < m; i++) {
		int x;
		cin >> x;
		x--;
		c[x] = 1;
	}
	for (int i = n * m - 1; i >= 0; i--) {
		if (!r[i] && !c[i]) {
			if (sr * sc - (n * m - i - 1) <= 0) {
				cout << 0;
				return 0;
			}
			ans = (ans * (sr * sc - (n * m - i - 1))) % mod;
			continue;
		}
		if (!r[i]) {
			if (!sc) {
				cout << 0;
				return 0;
			}
			ans = ans * sc % mod;
			sr++;
			continue;
		}
		if (!c[i]) {
			if (!sr) {
				cout << 0;
				return 0;
			}
			ans = ans * sr % mod;
			sc++;
			continue;
		}
		sr++, sc++;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 2304
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

int main() {
  int a, b; std::cin >> a >> b;
  if (a < b) {
    for (int i = 0; i < b; ++i) std::cout << a;
  } else {
    for (int i = 0; i < a; ++i) std::cout << b;
  }
  std::cout << std::endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    private static final long MOD = 1_000_000_007;

    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final List<Long> list = IntStream.range(0, n)
            .mapToObj(i -> scanner.nextLong())
            .collect(Collectors.toList());
        final long[] sums = new long[n];
        sums[n - 1] = list.get(n - 1);
        for (int i = n - 1; i > 0; i--) {
            sums[i - 1] = (list.get(i - 1) + sums[i]) % MOD;
        }

        IntStream.range(0, n - 1)
            .mapToLong(i -> list.get(i) * sums[i + 1] % MOD)
            .reduce((a, b) -> (a + b) % MOD)
            .ifPresent(System.out::println);
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }
    }
}


Measured memory_bytes: 60560
//is there any case of -1 or any special corner cases ?
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr));
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;while(t--) 
const int maxx  = 3*1e5 , limit = 9*1e18 , MOD=1e9+7;

string binary(int n){bitset<60>b(n) ;string p =b.to_string();return p;}

int decimal(string n) { int dec_value = 0;  int base = 1;  for (int i = n.size() - 1; i >= 0; i--) { if (n[i] == '1') 
dec_value += base; base = base * 2; } return dec_value; } 

bool isPrime(int n){if (n <= 1) return false; if (n <= 3) return true;if (n % 2 == 0 || n % 3 == 0) return false;

for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; }

int pow (int x, int n,int mod) {if (n == 0) return 1; int res = pow (x, n / 2,mod);res = (res * res) % mod;if (n % 2) res = (res * x ) % mod;return res;}
// int calcInverse(int a, int n = MOD){int t = 0, newt = 1;int r = n, newr = a;  while (newr != 0) {auto quotient = r /newr;tie(t, newt) = make_tuple(newt, t- quotient * newt);
// tie(r, newr) = make_tuple(newr, r - quotient * newr);}if (r > 1)throw runtime_error("a is not invertible");if (t < 0)t += n;t=t%n;    return t;}

#define boost  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n';

int32_t main(){
        
        int n;
        cin>>n;
        map<string ,int>cn;
        string s;
        // cin>>s;
        
        for(int i =0  ; i < n ; i++ ){
            cin>>s;
            cn[s]++;
        }
        cout<<"AC x "<<cn["AC"]<<endl;
        
        cout<<"WA x "<<cn["WA"]<<endl;
        
        cout<<"TLE x "<<cn["TLE"]<<endl;
        
        cout<<"RE x "<<cn["RE"]<<endl;
        
        
        
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define MAX (ll)(1e5 + 4)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(1e18)
#define PI (double)(3.14159265)
#define IO ios_base :: sync_with_stdio (false), cin.tie (nullptr);

using namespace std;
using ll = long long;
using ld = long double;

int main () {
	int a, n;
	cin >> a >> n;
	int ar[n];
	int su = 0;
	for (int i = 0; i < n; i++) {
		cin >> ar[i];
		su += ar[i];
	}
	if (su >= a) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}


Measured memory_bytes: 640
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
a = np.array(read().split(), np.int64)

mod = 10 ** 9 + 7
ans = 0

for i in range(61):
    b = a >> i & 1
    x = np.count_nonzero(b)
    y = n - x
    z = x * y
    z *= 2 ** i
    z %= mod
    ans += z
ans %= mod

print(ans)


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

using namespace std;
using ll = long long;
using ld = long double;

int v[3005][3005];
ll dp[3005][3005][4];

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int r,c,k;
    cin >> r >> c >> k;

    for(int i = 0; i < k; i++) {
        int tr,tc,tv;
        cin >> tr >> tc >> tv;
        tr--;
        tc--;
        v[tr][tc]=tv;
    }

    for(int i = 0; i < r; i++) {
        for(int j = 0; j < c; j++) {
            for(int k = 2; k >=0 ; k--) {
                dp[i][j][k+1]= max(dp[i][j][k+1],dp[i][j][k]+v[i][j]);
            }
            for(int k = 0; k < 4; k++) {
                dp[i+1][j][0] = max(dp[i+1][j][0],dp[i][j][k]);
                dp[i][j+1][k] = max(dp[i][j+1][k],dp[i][j][k]);
            }
        }
    }
    ll ans=0;
    for(int k = 0; k < 4; k++) {
        ans=max(ans,dp[r-1][c-1][k]);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 320588
#include <iostream>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <vector>
#include <map>
#include <string>
#include <set>
using namespace std;
typedef long long LL;
const LL maxn=1e6+10,p=9901,mod=1e9+7;
vector<LL>G[maxn];
LL hash_v[maxn];
map<LL,LL>mp;
map<LL,LL>::iterator it;

void dfs(LL u)
{
    hash_v[u]=1;
    for(LL i=0; i<G[u].size(); i++)
    {
        LL v=G[u][i];
        dfs(v);
        hash_v[u]=(hash_v[u]+hash_v[v]*p)%mod;
    }
    mp[hash_v[u]]++;
}
int main()
{
   ///freopen("in.txt","r",stdin);
    LL n;
    LL u,v;
    while(scanf("%lld",&n)!=-1)
    {
        for(LL i=0; i<=n; i++)
        G[i].clear();
        mp.clear();
        for(LL i=1; i<n; i++)
        {
            scanf("%lld%lld",&u,&v);
            G[u].push_back(v);
        }
        dfs(1);
        LL ans=0;
        for(it=mp.begin(); it!=mp.end(); it++)
            ans+=it->second*(it->second-1)/2;
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 44660
N = int(input())
L_lst = list(map(int,input().split()))
L_lst.sort()
cnt = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        for h in range(j + 1, N):
            if L_lst[i] != L_lst[j] and L_lst[j] != L_lst[h] and L_lst[h] != L_lst[i] and (L_lst[i]+L_lst[j])>L_lst[h]:
                cnt += 1
print(cnt)

Measured memory_bytes: 67960
#include<cstdio>
#include<iostream>
#include<map>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
typedef long long LL;
int main(){
	LL a;
	cin >> a;
	cout << a * 800 - a / 15 * 200 <<endl; 
	return 0;
	}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
long long n,s,i,j,sum,ans;
bool check(long long n,long long b)
{
	sum=0;
	for (;n;n/=b) sum+=n%b;
	return sum==s;
}
int main()
{
	cin>>n>>s;
	if (n==s)
	{
		cout<<n+1;
		return 0;
	}
	if (n<s)
	{
		cout<<-1;
		return 0;
	}
	n-=s;
	for (i=1;i<=sqrt(n+s);i++)
	{
		if (n%i==0&&n/i>0&&check(n+s,n/i+1))
		{
			ans=n/i+1;
		}
	}
	n+=s;
	for (i=2;i<=sqrt(n);i++) 
	{
		if (check(n,i))
		{
			cout<<i;
			return 0;
		}
	}
	if (ans) cout<<ans;
		else cout<<-1;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, h[100008];
string str;

int main(){
	cin >> n;
	for(ll i = 1; i <= n; i++){cin >> h[i];}
	
	ll upb = h[n];
	string ans = "Yes";
	for(ll i = n; i >= 1; i--){
		if(h[i]-upb <= 1){
			upb = min(h[i], upb);
		}
		else{
			ans = "No";
			break;
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-18 18:43:01
                2020-04-18 19:31:28 余計なものを取り除いた版
*/

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

#define MOD 1000000007

typedef unsigned long ul;

map<int, long> memo;

long fib(int n)
{
    if (n >= 2 && memo[n] > 0) return memo[n];
    else if (n >= 2) return memo[n] = fib(n-1)%MOD + fib(n-2)%MOD;
    else return memo[n];
}

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

    memo[-1] = 0;   //上ることができない
    memo[0] = 1;    //そのままジャンプするだけ
    memo[1] = 1;

    long ans;
    if (m == 0) {
        ans = fib(n)%MOD;
    } else {
        ans = (fib(a[0]-1)*fib(n-a[m-1]-1))%MOD;
        for (int i = 1; i < m; i++) {
            int A = a[i] - a[i-1];
            ans *= fib(A-2);
            ans %= MOD;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define lll __int128
#define ull unsigned long long
#define fi first
#define se second
#define db double
#define ld long double
#define lld __float128

/// order_of_key, find_by_order

template<class T, class COMP>
using custom_set = tree<T, null_type, COMP, rb_tree_tag, tree_order_statistics_node_update>;

template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<class T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<class T, class U>
using ordered_map = tree<T, U, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rnd_64(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
    int n, m; cin >> n >> m;
    int pr[(1 << n)][(1 << m)];
    if(n < m)
    {
        for(int i = 0; i < (1 << m); i++)
        {
            pr[0][i] = 0;
        }
        for(int i = 1; i < (1 << n); i++)
        {
            int tp = 0;
            int x = i-1;
            while(x % 2 == 1)
            {
                tp++; x /= 2;
            }
            tp = (1 << tp)-1;
            bool cur = 1;
            for(int j = 0; j < (1 << m); j++)
            {
                if((j & tp) == 0)
                {
                    cur ^= 1;
                }
                pr[i][j] = pr[i-1][j] ^ cur;
            }
        }
    }
    else
    {
        for(int i = 0; i < (1 << n); i++)
        {
            pr[i][0] = 0;
        }
        for(int i = 1; i < (1 << m); i++)
        {
            int tp = 0;
            int x = i-1;
            while(x % 2 == 1)
            {
                tp++; x /= 2;
            }
            tp = (1 << tp)-1;
            bool cur = 1;
            for(int j = 0; j < (1 << n); j++)
            {
                if((j & tp) == 0)
                {
                    cur ^= 1;
                }
                pr[j][i] = pr[j][i-1] ^ cur;
            }
        }
    }
    for(int i = 1; i < (1 << n); i++)
    {
        for(int j = 1; j < (1 << m); j++)
        {
            cout << (pr[i][j] ^ pr[i-1][j] ^ pr[i][j-1] ^ pr[i-1][j-1]);
        }
        cout << '\n';
    }
//    for(int i = 0; i < (1 << n); i++)
//    {
//        for(int j = 0; j < (1 << m); j++)
//        {
//            cout << pr[i][j];
//        }
//        cout << '\n';
//    }
}






































/// shche ne vmerla Ykraina


Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    string s;
    cin >> s;

    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
        std::cout << "Bad" << '\n';
    } else {
        std::cout << "Good" << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
const int N = 1e6+2;
int divisor_count[N];

int main(){
   int n;
   cin>>n;
   int i,j;
   memset(divisor_count,0,sizeof(divisor_count));
   for(i=1;i<=N;++i){
      for(j=i;j<=N;j+=i){
         divisor_count[j]++;
      }
   }
   ll ans=0;
   for(i=1;i<=n-1;++i){
      ans+=1LL*divisor_count[i];
   }
   cout<<ans;
}

Measured memory_bytes: 7548
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F(i,s,e) for(ll i=s;i<e;++i)

int main()
{
    ll n;
    cin >> n;
    ll a[n];
    ll sum=1;
    F(i,0,n){
        cin >> a[i];
        if(a[i]==0){
            cout << 0 << endl;
            return 0;
        }
    }
    F(i,0,n){
        if(sum>1000000000000000000/a[i]){
            cout << -1 << endl;
            return 0;
        }
        sum*=a[i];
    }
    cout << sum << endl;
    return 0;
}

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

using namespace std;



int main()
{
    long long a,b,p;

    cin >> a >>  b;

    long long k;

    k=min(a,b);

    p=abs(a-b);



    if(p%2!=0)
    {
        cout << "IMPOSSIBLE";
    }
    else
    {
        p=p/2;

        cout << k+p;
    }


    return 0;
}


Measured memory_bytes: 256
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>

using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)

#define shosu setprecision(10)

typedef long long ll;
typedef pair<int,int> P;
ll longinf=1ll<<60;
int inf=1<<29;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int a[3];

int main(){
  cin>>a[0]>>a[1]>>a[2];
  sort(a,a+3);
  cout<<10*a[2]+a[1]+a[0]<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <unordered_map>
#define M ((ll)1e9+7)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define pi acos(-1)
typedef long long ll;
using namespace std;
void solve()
{
    ll a,b;
    cin>>a>>b;
    ll g=__gcd(a,b);
    cout<<(a*b)/g<<endl;
}
int main()
{
   solve();
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {        
    vector<long long int> fac(1, 1);
    int n;
    cin >> n;
    const int mod = 1e9 + 7;
    for (int i = 1; i <= n; i++) {
        fac.push_back(fac.back() * i % mod);
    }
    cout << fac.back() << endl;
}


Measured memory_bytes: 4296
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n;i>0;i--)
#define rep1(i,s,n) for(int i=s;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c) 
using namespace std;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;

int main(){
    int n,m,count=0,k=0;
    ll ans=0;
    cin>>n>>m;
    lvec a(n);
    vec index(m);
    rep(i,n) cin>>a[i];
    plvec p(m);
    sort(a.begin(),a.end());
    rep(i,m){
        int b;
        ll c;
        cin>>b>>c;
        p[i]=make_pair(c,b);//pairの一番目はC(変更する先),二番目はB(変更できる個数)
    }
    sort(p.begin(),p.end());
    reverse(p.begin(),p.end());
    rep(i,m){
        index[i]=lower_bound(a.begin(),a.end(),p[i].first)-a.begin();
        if(p[i].first<=a[n-1]) index[i]--;
    }
    if(index[k]<=p[k].second-1){
        ans=p[k].first*(index[k]+1);
        count+=index[k]+1;
    }else{
        ans=p[k].first*(p[k].second);
        count+=p[k].second;
    }
    k++;
    while(k<m){
        if(count+p[k].second<=index[k]+1){
            ans+=p[k].second*p[k].first;
            count+=p[k].second;
            if(count>n){
                ans-=(count-n)*p[k].first;
                break;
            }
        }else if(index[k]+1>=count){
            ans+=(index[k]+1-count)*p[k].first;
            count+=index[k]+1-count;
            if(count>n){
                ans-=(count-n)*p[k].first;
                break;
            }
        }
        k++;
    }
    if(count<n){
        for(int i=count;i<n;i++) ans+=a[i];
    }
    cout<<ans;
}


Measured memory_bytes: 2944
import java.util.*;

public class Main{
  public static void main(String[] args){
    
    String S = new Scanner(System.in).nextLine();
    
    String[]  S_Array = new String[S.length()];
    
    for(int i=0; i<S.length(); i++){
        S_Array[i] = String.valueOf(S.charAt(i));
    }

    
    if(S_Array[2].equals(S_Array[3]) && S_Array[4].equals(S_Array[5])){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

    
    

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

int D;
long long G;
vector<long long> p, c;

int main() {
  cin >> D >> G;
  p.resize(D); c.resize(D);
  for (int i = 0; i < D; ++i) cin >> p[i] >> c[i];

  long long res = 1<<29;
  for (int bit = 0; bit < (1<<D); ++bit) {
    long long sum = 0;
    long long num = 0;
    for (int i = 0; i < D; ++i) {
      if (bit & (1<<i)) sum += c[i] + p[i] * 100 * (i+1), num += p[i];
    }
    if (sum >= G) res = min(res, num);
    else {
      for (int i = D-1; i >= 0; --i) {
        if (bit & (1<<i)) continue;
        for (int j = 0; j < p[i]; ++j) {
          if (sum >= G) break;
          sum += 100 * (i+1);
          ++num;
        }
      }
      res = min(res, num);
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int top,pop;
struct data
{   string s;
    int c;
}que[1000005],kq[100005];
int n,m,k,T;

void solve(){
    while (pop < top){
        data x = que[++pop];
        if (x.c > m) {
            top++;
            que[top].c = x.c - m;
            que[top].s = x.s;
            //*que[top].cs = x.cs;
            T+=m;
        }
        else {
            T += x.c;
            k++;
            kq[k].c = T;
            kq[k].s = x.s;
        }
    }
}

int main(){
  
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        top++;
        cin >> que[top].s >> que[top].c ;
    }
    solve();
    for (int i = 1; i <= k; i++)
        cout << kq[i].s << " " << kq[i].c << '\n';
}



Measured memory_bytes: 22592
#include <bits/stdc++.h>
using namespace std;
 
string S; int N, cnt;
 
int main() {
	int A,B;
    cin >> A >> B;
    int Ans;
    if((B-1)%(A-1)==0)Ans = (B-1)/(A-1);
    else Ans = (B-1)/(A-1)+1;
    cout << Ans << endl;
}

Measured memory_bytes: 3608
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a, count = [], 0
for _ in range(n):
    a.append(list(map(int, input().split())))
for k in range(n):
    s = 0
    for i, j in zip(a[k], b):
        s += i*j
    if s+c > 0:
        count += 1
print(count)

Measured memory_bytes: 9172
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
#include <iomanip>
#include <set>
#include <map>
#include <unordered_map>
#include <cassert>
#include <queue>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

int main(){
    int n,m;
    std::cin >> n >> m;
    std::priority_queue<ll> a;
    rep(i,n){
        ll ai; std::cin >> ai;
        a.push(ai);
    }

    rep(i,m){
        int max_a = a.top();
        a.pop();
        a.push(max_a/2);
    }

    ll ans = 0;
    while(!a.empty()){
        ans += a.top();
        a.pop();
    }
    std::cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 4324
//
//  main.cpp
//  Exercise
//
//

#include <algorithm>
#include <iostream>
#include <limits>
#include <math.h>
#include <tuple>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include "string.h"
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <set>

using namespace std;

using intll_t = long long;

int main() {
    int N, M, X;
    scanf("%d %d %d", &N, &M, &X);
    int costLeft = 0;
    int costRight = 0;
    for (int i = 0; i < M; i++) {
        int Ai;
        scanf("%d", &Ai);
        if (Ai < X) {
            costLeft++;
        } else {
            costRight++;
        }
    }
    printf("%d", min(costLeft, costRight));
    printf("\n");
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N;i++)
        cin >> A[i];

    int maxvl, maxid,maxvls;
    maxvl = 0;
    maxvls = 0;
    for (int i = 0; i < N;i++){
        if(maxvl < A[i]){
            maxvl = A[i];
            maxid = i;
        }
        if(maxvls < A[i] && maxid != i && A[i] <= maxvl)
            maxvls = A[i];
    }
    for (int i = 0; i < N;i++){
        if(i != maxid){
            cout << maxvl << endl;
        }else{
            cout << maxvls << endl;
        }
    }
    return 0;
}

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

int main() {

    int N;
    cin >> N;
    string S;
    cin >> S;
    int Q;
    cin >> Q;

    rep(i, Q) {
        int k;
        cin >> k;

        int n = N;
        // 半壊区間でやると良いかも
        // [left, right)
        int right = 0;
        ll ret = 0;
        int m = 0, c = 0;
        ll tot = 0;
        for (int left = 0; left < n; ++left) {
            if (S[left] == 'D') {
                while (right < n and (right - left < k)) {
                    if (S[right] == 'M') m++;
                    else if (S[right] == 'C') {
                        c++;
                        tot += m;
                    }
                    right++;
                }
                ret += tot;
            }
            else if (S[left] == 'M') {
                m--;
                tot -= c;
            }
            else if (S[left] == 'C') {
                c--;
            }
        }
        cout << ret << endl;
    }
}


Measured memory_bytes: 1412
n=int(input())
s=input()
r,g,b=[],[],[]
for i in range(n):
  if s[i]=='R':
    r+=[i+1]
  elif s[i]=='G':
    g+=[i+1]
  elif s[i]=='B':
    b+=[i+1]

ans=len(r)*len(g)*len(b)

for i in range(n-2):
  for dist in range(1,(n-i+1)//2):
    if s[i]!=s[i+dist] and s[i]!=s[i+dist*2] and s[i+dist]!=s[i+dist*2]:
      ans-=1
      

print(ans)

Measured memory_bytes: 73812
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

using P = pair<s64, int>;

s64 prim(vector< vector< P > >& g, int s)
{
    int n = g.size();
    static const s64 inf = 1e18;
    vs64 cost(n, inf);
    cost[s] = 0;

    priority_queue<P, vector<P>, greater<P>> pq;
    pq.push(P{cost[s], s});

    s64 ret = 0;
    vector< bool > used(n, false);
    while (!pq.empty())
    {
        auto p = pq.top(); pq.pop();
        int from = p.second;
        if (used[from]) continue;
        used[from] = true;
        ret += cost[from];

        for (auto x : g[from])
        {
            int to = x.first;
            s64 c = x.second;
            if (cost[to] > c)
            {
                cost[to] = c;
                pq.push(P{cost[to], to});
            }
        }
    }

    return ret;
}

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

    int n;
    cin >> n;

    vector< P > xi(n), yi(n);
    rep (i, n)
    {
        s64 x, y;
        cin >> x >> y;
        xi[i].first = x;
        xi[i].second = i;
        yi[i].first = y;
        yi[i].second = i;
    }

    sort(xi.begin(), xi.end());
    sort(yi.begin(), yi.end());

    vector< vector< P > > g(n);
    rep (i, n - 1)
    {
        g[xi[i].second].emplace_back(xi[i + 1].second, xi[i + 1].first - xi[i].first);
        g[xi[i + 1].second].emplace_back(xi[i].second, xi[i + 1].first - xi[i].first);
        g[yi[i].second].emplace_back(yi[i + 1].second, yi[i + 1].first - yi[i].first);
        g[yi[i + 1].second].emplace_back(yi[i].second, yi[i + 1].first - yi[i].first);
    }

    cout << prim(g, 0) << "\n";
    return 0;
}



Measured memory_bytes: 17268
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N ; cin >> N ;
    vector<ll> A;
    ll now = 0;
    rep(i,N){
        ll inp; cin >> inp;
        now += inp;
        if(inp == 0) {
            A.pb(now);
            now = 0;
        }
    }
    if(now != 0) A.pb(now);
    
    ll ans = 0;
    rep(i, A.size()){
        ans += ((A[i]/2));
    }
    
    cout << ans << endl;
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

int head(int n) {
  string s = to_string(n);
  return s[0] - '0';
}
int tail(int n) {
  string s = to_string(n);
  return s[s.length() - 1] - '0';
}

int main() {
  int h, w;
  cin >> h >> w;
  V<string> s(h);
  rep(i, h) cin >> s[i];

  V<V<int>> r(h, V<int>(w, 0));
  V<V<int>> c(h, V<int>(w, 0));

  rep(i, h) {
    rep(j, w) {
      if (s[i][j] == '#') continue;
      int p = (j == 0) ? 0 : r[i][j - 1];
      r[i][j] = p + 1;
    }
    for (int j = w - 2; j >= 0; j--) {
      if (s[i][j] == '#') continue;
      r[i][j] = max(r[i][j + 1], r[i][j]);
    }
  }
  rep(j, w) {
    rep(i, h) {
      if (s[i][j] == '#') continue;
      int p = (i == 0) ? 0 : c[i - 1][j];
      c[i][j] = p + 1;
    }
    for (int i = h - 2; i >= 0; i--) {
      if (s[i][j] == '#') continue;
      c[i][j] = max(c[i + 1][j], c[i][j]);
    }
  }

  int ans = 0;
  rep(i, h) rep(j, w) {
    int l = r[i][j] + c[i][j] - 1;
    ans = max(ans, l);
  }
  cout << ans << endl;
}


Measured memory_bytes: 42328
#include <vector>
#include <limits>



template<class T> struct AdjMat {
  using size_t = std::size_t;
  size_t n; T inf; std::vector<std::vector<T>> dat;
  AdjMat() {}
  AdjMat(size_t n, T inf) : n(n), inf(inf), dat(n, std::vector<T>(n, inf)) {}
  AdjMat(size_t n) : n(n), inf(), dat() { inf = std::numeric_limits<T>::max(); init(n); }
  void init(size_t n) { this->n = n; dat.resize(n); for(size_t i=0;i<n;++i) dat[i].assign(n, inf); }
  auto& operator[](size_t i) { return dat[i]; }
  void de(size_t i, size_t j, T t) { dat[i][j] = t; }
  void e(size_t i, size_t j, T t) { de(i, j, t); de(j, i, t); }
  auto begin() { return dat.begin(); }
  auto end() { return dat.end(); }
  size_t size() const { return n; }
};

template<class T> void WarshallFloyd(AdjMat<T> &g) {
  using size_t = std::size_t; T const inf = g.inf;
  for(size_t k=0; k<g.size(); ++k) for(size_t i=0; i<g.size(); ++i) for(size_t j=0; j<g.size(); ++j) {
    if(g[i][k] == inf || g[k][j] == inf) continue;
    T t = g[i][k] + g[k][j];
    if(g[i][j] == inf || t < g[i][j]) g[i][j] = t;
  }
}



#include <iostream>

void abc143_e() {
  using namespace std;
  int N, M; long long L;
  cin >> N >> M >> L;
  AdjMat<long long> g(N);
  for(int i=0;i<M;++i) {
    int A, B, C;
    cin >> A >> B >> C;
    g.e(--A, --B, C);
  }

  WarshallFloyd(g);
  for(auto& v : g) for(auto& e : v) e = (e != g.inf && e <= L ? 1 : g.inf);
  WarshallFloyd(g);

  int Q; cin >> Q;
  for(int i=0;i<Q;++i) {
    int s, t;
    cin >> s >> t;
    --s; --t;
    cout << (g[s][t] == g.inf ? -1 : g[s][t]-1) << '\n';
  }
}

signed main() {

  abc143_e();

  return 0;
}


Measured memory_bytes: 1280
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: u32 = sc.read();
    let m: u32 = sc.read();
    println!("{}", (1900u32*m+(n-m)*100u32)*2u32.pow(m));
}

// Thanks, kenkoooo(https://kenkoooo.hatenablog.com/entry/2019/05/07/101033)
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main()
{
    int c[4][4] = {0};
    bool ansFlag = false;

    int a1, a2, a3, b1, b2, b3;

    for (int i = 1; i <= 3; i++) {
        for (int j = 1; j <= 3; j++) {
            cin >> c[i][j];
        }
    }

    for (int i = 0; i <= 100; i++) {
        // a1 = iで固定した場合のb1〜b3の関係は以下の通り
        a1 = i;
        b1 = c[1][1] - i;
        a2 = c[2][1] - c[1][1] + i;
        b2 = c[1][2] - i;
        a3 = c[3][1] - c[1][1] + i;
        b3 = c[1][3] - i;

        if ((a1 + b1 == c[1][1]) && (a1 + b2 == c[1][2]) && (a1 + b3 == c[1][3]) 
             && (a2 + b1 == c[2][1]) && (a2 + b2 == c[2][2]) && (a2 + b3 == c[2][3])
             && (a3 + b1 == c[3][1]) && (a3 + b2 == c[3][2]) && (a3 + b3 == c[3][3])) {
            ansFlag = true;
            break;
        }
    }

    if (ansFlag) cout << "Yes" << endl;
    else         cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int64
	fmt.Scan(&n)
	var ans []byte
	for n > 0 {
		b := byte(n%26) + 'a' - 1
		if b < 'a' {
			b = 'z'
			n -= 26
		}
		ans = append(ans, b)
		n /= 26
	}
	for i := len(ans) - 1; i >= 0; i-- {
		fmt.Printf("%c", ans[i])
	}
	fmt.Println()
}


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

int main() {
  int a,b;
  cin >> a >> b;
  int x = a*b;
  if(x%2==0)cout <<"Even" << endl;
  else cout << "Odd" << endl;
  
}

Measured memory_bytes: 3588