akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
using namespace std;

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

 long r[n];
 for( int i=0; i<n; i++ ){
   cin >> r[i];
 }

 long  minv = r[0];
 long maxv = -pow(10,9);
 for( int j=1; j<n; j++ ){
   maxv = max(maxv, r[j]-minv);
   minv = min(minv, r[j]);
 }

 cout << maxv << endl;

 return 0;
}


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

int main(){
  int n, sum = 0;
  cin >> n;
  int d[n];
  for(int i=0;i<n;i++){
    cin >> d[i];
  }
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      sum += d[i] * d[j];
    }
  }
  cout << sum << endl;
  return 0;
}

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

using namespace std;

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

    for (int i = 0; i <= n; i++) {
        int num = i * 1.08;
        if (num == n) {
            cout << i << endl;
            return (0);
        }
    }

    cout << ":(" << 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 h=sc.nextInt(); //縦
		int w=sc.nextInt(); //横
		
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				String str=sc.next();
				if(str.equals("snuke")){
					//数字をアルファベットに変換
					System.out.print((char)(j+'A'));
					System.out.println((i+1));
				}
			}
		}
	}
} 

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

#define int long long
#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define reps(i, n) for (int (i) = 1; (i) <= (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL << (n))
typedef vector<int> vint;
typedef pair<int, int> pint;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct SetUp {
    SetUp() {
        cout << fixed << setprecision(20);
        cerr << fixed << setprecision(20);
    };
} setUp;

int N, K;
vint t(110000), d(110000);
vint dv[110000];
deque<int> a, b;
signed main() {
    cin >> N >> K;
    rep(i, N) {
        cin >> t[i] >> d[i];
        dv[t[i]].push_back(d[i]);
    }
    reps(i, N) {
        if (dv[i].empty()) { continue; }
        sort(all(dv[i])), reverse(all(dv[i]));
        a.push_back(dv[i][0]);
        for (int j = 1; j < dv[i].size(); j++) { b.push_back(dv[i][j]); }
    }
    sort(all(a)), reverse(all(a));
    a.push_front(0);
    for (int i = 1; i < a.size(); i++) { a[i] += a[i - 1]; }
    sort(all(b)), reverse(all(b));
    b.push_front(0);
    for (int i = 1; i < b.size(); i++) { b[i] += b[i - 1]; }

    int ans = 0;
    for (int i = max(K - (int) b.size(), 0LL); i <= min((int) a.size(), K); i++) {
        chmax(ans, a[i] + b[K - i] + i * i);
    }
    cout << ans << endl;

}

Measured memory_bytes: 8448
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int h = Integer.parseInt(str[0]);
		int n = Integer.parseInt(str[1]);

		int a[] = new int[n];
		int b[] = new int[n];
		for (int i = 0; i < n; i++) {
			str = br.readLine().split(" ");

			a[i] = Integer.parseInt(str[0]);
			b[i] = Integer.parseInt(str[1]);
		}

		int dp[][] = new int[n + 1][h + 1];

		for (int i = 0; i <= n; i++) {
			Arrays.fill(dp[i], 1_000_000_000);
		}
		dp[0][0] = 0;

		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= h; j++) {
				dp[i + 1][j] = Math.min(dp[i + 1][j], dp[i][j]);
				dp[i + 1][Math.min(j + a[i], h)] = Math.min(dp[i + 1][Math.min(j + a[i], h)], dp[i + 1][j] + b[i]);
			}
		}

		System.out.println(dp[n][h]);
	}
}

Measured memory_bytes: 81228
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

//??§?¬??????§?§£??????
int main(void){
	int n, a, b;
	double kizi;
	cin >> n >> a >> b >> kizi;
	vector<int> debu(n + 1);//?????????????????\????????????
	rep(i, n) cin >> debu[i];
	sort(debu.begin(), debu.end());
	reverse(debu.begin(), debu.end());
	vector<double> ans(n + 1);
	//?????????????????????????????????????????????????????§??????
	rep(i, n + 1){//i????????????????????°????????¶??¨???
		double nedan = (double)a + (double)i * (double)b;
		double karori = kizi;
		rep(j, i) karori += debu[j];//i????????????????????°????????????????????????????????????????????????i???????????§??????
		ans[i] = karori / nedan;
	}
	sort(ans.begin(), ans.end());
	reverse(ans.begin(), ans.end());
	double max; max = ans[0];
	rep(i, n){
		if(max == ans[i]) printf("%d\n", int(floor(max)));
		else break;
	}
	return 0;
}

Measured memory_bytes: 3188
//\\//\\ * * * //\\// ||
#include <bits/stdc++.h> 

#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;

void Do(string s, int k) {
  cout << s << " " << 'x' << " " << k << '\n';
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, c0, c1, c2, c3;
  c0 = c1 = c2 = c3 = 0;
  cin >> n;
  while (n--) {
    string s;
    cin >> s;
    if (s == "AC") ++c0;
    if (s == "WA") ++c1;
    if (s == "TLE") ++c2;
    if (s == "RE") ++c3;
  }
  Do("AC", c0);
  Do("WA", c1);
  Do("TLE", c2);
  Do("RE", c3);
  return 0;
}


Measured memory_bytes: 3640
import sys
input = sys.stdin.readline
def inps():
    return str(input())
def longest(s):
    max_now = 0
    max_glo = 0
    for i in range(len(s)):
        if s[i] == "R": max_now+=1
        else: max_now = 0
        if max_glo<max_now: max_glo=max_now
    return max_glo    

s = inps().rstrip()
print(longest(s))

    

Measured memory_bytes: 9032
import sys


def popcount(x: int):
    return bin(x).count("1")


def main():
    N = int(sys.stdin.readline().rstrip())
    X = sys.stdin.readline().rstrip()

    Xdec = int(X, 2)

    # 1回目の演算用
    md = popcount(Xdec)
    md_p, md_m = md + 1, md - 1

    tmp_p = Xdec % md_p
    if md_m > 0:
        tmp_m = Xdec % md_m

    for i in range(0, N, 1):
        if X[i] == "1":  # 1->0
            if md_m == 0:
                print(0)
                continue
            x_m = pow(2, (N - 1 - i), md_m)
            tmp = (tmp_m - x_m) % md_m

        if X[i] == "0":  # 0->1
            x_p = pow(2, (N - 1 - i), md_p)
            tmp = (tmp_p + x_p) % md_p

        cnt = 1
        while tmp:

            tmp = tmp % popcount(tmp)
            cnt += 1

        print(cnt)


main()


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

#define long long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define sz(x) (int)x.size()
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fill(a,v) memset(a,v,sizeof(a))
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define INF 0x3f3f3f3f//infinity for integers
#define JJ ios_base::sync_with_stdio(0); cin.tie(0)//input fast
#define MOD 1000000007
#define hash(n) unordered_map<int,int>mp(n)

 
int main() 
{ 
	JJ;
    int n; cin>>n;
    map<long,long> f;
    long x; long total=0;
    FOR(i,1,n+1){
    	cin>>x;
    	f[x]++;
    	total+=x;
    }
    // cout<<"initial sum = "<<total<<endl;
    long q; cin>>q;
    // int B[q+1],C[q+1];
    long B,C;
    FOR(i,1,q+1){
    	cin>>B>>C;
    	long oldnum=B;
    	if(f.find(B)!=f.end()){
    		total-=(oldnum*f[oldnum]);
    	long newno=C;
    	f[newno]+=f[oldnum];
    	total+=(f[oldnum]*newno);
    	f[oldnum]=0;
    	}
    	cout<<total<<endl;
    	
    }


    
} 

Measured memory_bytes: 8736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
#ifdef HOME
    freopen("in", "r", stdin);
#endif


    int n;
    while (cin >> n) {
        vector<pair<int, int> > a(n);
        for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;

        vector<int> p(n);
        iota(p.begin(), p.end(), 0);
        function<int(int)> get = [&](int x) {
            if (x == p[x]) return x;
            return p[x] = get(p[x]);
        };
        auto uni = [&](int u, int v) {
            u = get(u);
            v = get(v);
            if (u == v) return 0;
            p[v] = u;
            return 1;
        };

        map<int, vector<int> > mpx, mpy;
        for (int i = 0; i < n; i++) {
            mpx[a[i].first].push_back(i);
            mpy[a[i].second].push_back(i);
        }
        vector<int> vctx, vcty;
        for (auto it : mpx) {
            vctx.push_back(it.first);
            for (int i = 1; i < (int)it.second.size(); i++) uni(it.second[0], it.second[i]);
        }
        for (auto it : mpy) {
            vcty.push_back(it.first);
            for (int i = 1; i < (int)it.second.size(); i++) uni(it.second[0], it.second[i]);
        }

        vector<pair<int, pair<int, int> > > vct;
        for (int i = 1; i < (int)vctx.size(); i++) {
            vct.push_back({vctx[i] - vctx[i - 1], make_pair(mpx[vctx[i - 1]][0], mpx[vctx[i]][0])});
        }
        for (int i = 1; i < (int)vcty.size(); i++) {
            vct.push_back({vcty[i] - vcty[i - 1], make_pair(mpy[vcty[i - 1]][0], mpy[vcty[i]][0])});
        }
        sort(vct.begin(), vct.end());
        int ans = 0;
        for (auto o : vct) {
            if (uni(o.second.first, o.second.second)) {
                ans += o.first;
            }
        }
        cout << ans << endl;
    }


#ifdef HOME
    cerr << clock() / (double)CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

Measured memory_bytes: 29040
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			double x1 = sc.nextDouble();
			double y1 = sc.nextDouble();
			double x2 = sc.nextDouble();
			double y2 = sc.nextDouble();
			double x3 = sc.nextDouble();
			double y3 = sc.nextDouble();

			double a = x1*x1 - x2*x2 + y1*y1 - y2*y2;
			double b = 2*x2 - 2*x1;
			double c = 2*y2 - 2*y1;
			double d = x3*x3 - x2*x2 + y3*y3 - y2*y2;
			double e = 2*x2 - 2*x3;
			double f = 2*y2 - 2*y3;
//			System.out.println(c);
//			System.out.println(f);
			double px = (c*d - f*a) / (f*b - c*e);
			double py;
			if (f != 0) py = - (d + e*px) / f;
			else py = - (a + b*px) / c;

			double rr = (px - x1)*(px - x1) + (py - y1)*(py - y1);
			double r = Math.sqrt(rr);

			BigDecimal dpx = new BigDecimal(px);
			BigDecimal dpy = new BigDecimal(py);
			BigDecimal dr = new BigDecimal(r);
			dpx = dpx.setScale(3, BigDecimal.ROUND_HALF_UP);
			dpy = dpy.setScale(3, BigDecimal.ROUND_HALF_UP);
			dr = dr.setScale(3, BigDecimal.ROUND_HALF_UP);

			System.out.printf("%.3f %.3f %.3f\n",
					dpx.doubleValue(), dpy.doubleValue(), dr.doubleValue());
		}
	}

}

Measured memory_bytes: 29184
n, k = map(int, input().split())
hh = [0] * n
for i in range(n):
    hh[i] = int(input())

diff = float('inf')
hh = sorted(hh)
for i in range(n - k + 1):
    diff = min(diff, hh[i + k - 1] - hh[i])
print(diff)

Measured memory_bytes: 8240
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            int[] P = in.nextIntArray(N);

            int max = N + 1;
            int ans = 0;
            for (int i = 0; i < N; i++) {
                if (P[i] <= max) {
                    max = P[i];
                    ans++;
                }
            }
            out.println(ans);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

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

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

    }
}



Measured memory_bytes: 47592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const int inf = int(1e10);
//const ll inf = ll(1e19);
const int mod = int(1e9) + 7;

//a^nの計算(mod)
ll modpow(ll a, ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll res = 0;
int main(){
    int n; cin >> n;
    res = modpow(10, n, mod) - 2 * modpow(9, n, mod) + modpow(8, n, mod);
    while(res < 0){
        res += mod;
    }
    res = res % mod;
    cout << res << endl;
}

Measured memory_bytes: 3628
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var o = ReadLine();
            var e = ReadLine();
            string ans = "";

            if (o.Length == e.Length)
            {
                for (int i = 0; i < o.Length; i++)
                {
                    ans += o[i];
                    ans += e[i];
                }
            }
            else if (Math.Max(o.Length, e.Length) == o.Length)
            {
                for (int i = 0; i < e.Length; i++)
                {
                    ans += o[i];
                    ans += e[i];
                }
                ans += o[o.Length - 1];
            }
            else if (Math.Max(o.Length, e.Length) == e.Length)
            {
                for (int i = 0; i < o.Length; i++)
                {
                    ans += o[i];
                    ans += e[i];
                }
                ans += e[e.Length - 1];
            }
            WriteLine(ans);
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}

Measured memory_bytes: 11092
n = int(input())
x = [0 for i in range(0, n)]
y = [0 for i in range(0, n)]

for i in range(0, n):
    x[i], y[i] = [int(i) for i in input().split(" ")]

mod2 = (x[0] + y[0]) % 2
imp = False

for i in range(1, n):
    if (x[i] + y[i]) % 2 != mod2:
        print(-1)
        imp = True
        break
        
if not imp:
    if mod2 == 0:
        x = [i + 1 for i in x]

    u = [x[i] + y[i] for i in range(0, n)]
    v = [x[i] - y[i] for i in range(0, n)]

    mode = ["L", "D", "U", "R"]
    m = 31

    if mod2 == 0:
        print(m + 1)
        print("1 " + " ".join([str(2**(i - 1)) for i in range(1, m + 1)]))
    else:
        print(m)
        print(" ".join([str(2**(i - 1)) for i in range(1, m + 1)]))

    for i in range(0, n):
        w = ""
        if mod2 == 0:
            w = "L"
        ui = (u[i] + 2**m - 1) // 2
        vi = (v[i] + 2**m - 1) // 2
        for l in range(0, m):
            ul = ui % 2
            ui = ui // 2
            vl = vi % 2
            vi = vi // 2
            w += mode[ul * 2+ vl]
        print(w)

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

int main(){
	string s;
	cin >> s;
	int ans = 0;
	rep(i, s.size()){
		if(s.at(i) == 'o') ans++;
	}
	if(ans + 15 - s.size() >= 8){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int a, b, c, d; cin >> a >> b >> c >> d;
    cout << max(a*b, c*d) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		 Scanner sc = new Scanner(System.in);
	        int ab = sc.nextInt();
	        int bc = sc.nextInt();
	        int ca = sc.nextInt();
	        
	        int ans = 0;
	        
	        ans = (ab * bc)/2;
	        System.out.println(ans);

	}

}

Measured memory_bytes: 22228
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793



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

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

int main() 
{
	int i,n;
	cin >> n;
	for(i=0;i<n;i++)
	{
		string str;
		cin >> str;
		st.insert(str);
	}
	cout<<st.size()<<endl;
	return 0;
}


Measured memory_bytes: 19228
n=int(input())
a=list(map(int,input().split()))
nl=[0 for i in range(8)]
c=0
for i in range(len(a)):
    if a[i]>=3200:
        c+=1
    for j in range(8):
        if 400*j<=a[i] and a[i]<400*(j+1):
            nl[j]=1
if sum(nl)==0:
    m=1
else:
    m=sum(nl)
print(m,sum(nl)+c)

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


//【参考】https://qiita.com/nomikura/items/590922f179f6f6ce69c2
//
int main() {

	int N, K;
	cin >> N >> K;


	//題意を満たすための1つ目の条件は(a%K, b%K, c%K) = (0, 0, 0)なので、
	//「x % K = 0」となるxを探す
	long long ans1 = 0;
	for (int x = 1; x <= N; x++)
	{
		if (x % K == 0) {
			ans1++;
		}
	}
	ans1 = ans1 * ans1 * ans1; //a,b,cのそれぞれがxパターンなので3乗


	//題意を満たすための2つ目の条件は(a%K, b%K, c%K) = (K/2, K/2, K/2)なので、
	//「x % K = K/2」となるxを探す
	long long ans2 = 0;
	if (K % 2 == 0) { //a,b,cは整数なのでKが奇数のときは調べなくて良い(Kは整数なので、もしKが奇数だとa,b,c(= K/2)は非整数になってしまう)
		for (int x = 1; x <= N; x++)
		{
			if (x % K == K / 2) {
				ans2++;
			}
		}
		ans2 = ans2 * ans2 * ans2; //a,b,cのそれぞれがxパターンなので3乗
	}

	cout << ans1 + ans2 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
	ll n;cin>>n;
	ll a[n];rep(i,0,n)cin>>a[i];

	//dp[i][j] : [i,j)でのX-Yの値
	ll dp[n+1][n+1];rep(i,0,n+1)rep(j,0,n)dp[i][j]=0;
	rep(len,1,n+1){
		for(ll i=0;i+len<=n;i++){
			ll j = i+len;
			if((n - len) % 2 == 0){ //先手=最大化
				dp[i][j] = max(dp[i+1][j]+a[i], dp[i][j-1]+a[j-1]);
			}else{ //後手=最小化
				dp[i][j] = min(dp[i+1][j]-a[i], dp[i][j-1]-a[j-1]);
			}
		}
	}
	cout << dp[0][n] << endl;

}

Measured memory_bytes: 70656
import java.util.*;
public class Main {

		public static void main(String[] args){
			Scanner sc = new Scanner(System.in);
			// 整数の入力
			int A = sc.nextInt();
			// スペース区切りの整数の入力
			int B = sc.nextInt();
			int T = sc.nextInt();
			int s = T/A;
			System.out.println( s*B);
		
	}

}


Measured memory_bytes: 23636
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int>v(n);

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

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

	double ans = v[0];

	for (int i = 1; i < n; i++) {
		ans = (ans + v[i]) / 2;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np
from math import ceil as C, floor as F, sqrt
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
 
ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

n = I()

print(1000 * C(n / 1000) - n)

Measured memory_bytes: 26960
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
using namespace std;

int inf = 2147483647;
int64_t inf64 = 9223372036854775807;
int mod = 1e+7;

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

  int64_t a, b, n;
  cin >> a >> b >> n;
  int64_t x = min(n, b-1);
  cout << a * x / b - a * (x / b) << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <queue>
#define ll long long int
using namespace std;


const int N = 3e5 + 10;
ll x, y, a, b, ans1, ans2;

int main(int argc, char** argv) {

    cin >> x >> y >> a>>b;
    ans1 = a - x;
    ans2 = b - y;
    if (x == a) {
        cout << a - ans2 << " " << b - ans1 << " " << x - ans2 << " " << y - ans1;
    } else if (x > a) {
        cout << a - ans2 << " " << b + ans1 << " " << x - ans2 << " " << y + ans1;
    } else {
        cout << a - ans2 << " " << b + ans1 << " " << x - ans2 << " " << y + ans1;
    }
    return 0;
}

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

int main(void)
{
  int n, i;
  double x1, y1, x2, y2, x3, y3, A, B, C, D, E, F, x, y, r;

  scanf("%d",&n);
  i = 0;
  while (i < n){
    scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);

    A = 2 * (x2 - x1);
    B = 2 * (y2 - y1);
    C = (x1 * x1) - (x2 * x2) + (y1 * y1) - (y2 * y2);
    D = 2 * (x3 - x1);
    E = 2 * (y3 - y1);
    F = (x1 * x1) - (x3 * x3) + (y1 * y1) - (y3 * y3);

    x = ((B * F) - (E * C)) / ((A * E) - (D * B));
    y = ((C * D) - (F * A)) / ((A * E) - (D * B));

    r = sqrt((x1 - x) * (x1 - x) + (y1 - y) * (y1 - y));
    
    printf("%.3f %.3f %.3f\n", x, y, r);
    i++;
  }
  return 0;
  }


Measured memory_bytes: 2044
import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
ans=n*(n+1)//2
x,y,z=n//3,n//5,n//15
ans-=3*(1+x)*x//2
ans-=5*(1+y)*y//2
ans+=15*(1+z)*z//2
print(ans)

Measured memory_bytes: 9132
#include <cstdio>

using namespace std;
typedef long long LL;
LL a,b;
int main(){
    scanf("%lld%lld",&a,&b);
    if(a==1||b==1){
        printf("1");
        return 0;
    }
    if((a*b)%2){
        printf("%lld",(a*b)/2+1);
    }
    else printf("%lld",a*b/2);
    return 0;
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(500000)

def get_cost(arr, n, dp):
  if dp[n] != float('inf'):
    return dp[n]
  if n == 1:
    dp[1] = abs(arr[1] - arr[0])
    return dp[1]
  elif n == 0:
    dp[0] = 0
    return dp[0]
  else:
    dp[n] = min(
      abs(arr[n] - arr[n-1]) + get_cost(arr, n-1, dp),
      abs(arr[n] - arr[n-2]) + get_cost(arr, n-2, dp)
    )
    return dp[n]


N = int(input())
arr = [int(num) for num in input().split()]
dp_arr = [float('inf')]*N
print(get_cost(arr, N-1, dp_arr))


Measured memory_bytes: 96656
def rotate(argstr):
    return argstr[len(argstr)-1] + argstr[0:len(argstr)-1]

str1 = input()
str2 = input()
ans = 'No'

if str1 == str2: ans = 'Yes'

for i in range(0, len(str1) - 1):
    str1 = rotate(str1)
    if str1 == str2: ans = 'Yes'

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 int main(){
   int A,B,C;
   cin>>A>>B>>C;
   int count=0;
   for(int i=A;i>0;i--){
     if(A%i==0){
     if(B%i==0){count++;
                if(count==C){
                  cout<<i<<endl;}
               }
     }
     }
 }

Measured memory_bytes: 256
n, m = map(int, input().split())
drinks = dict()
for _ in range(n):
    (a, b) = map(int, input().split())
    if not a in drinks:
        drinks[a] = 0
    drinks[a] += b
p = 0
keys = sorted(drinks.keys())
for k in keys:
    if drinks[k] < m:
        p += k * drinks[k]
        m -= drinks[k]
    else:
        p += k * m
        break
print(p)


Measured memory_bytes: 17880
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string.h>
using namespace std;
int main()
{
    char d[100];
    scanf("%s",d);
    int l=strlen(d);
    if(l==3)
    {
        for(int i=2;i>=0;i--)
        {
            printf("%c",d[i]);
        }
    }
    else printf("%s",d);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

//void linearSearch(int);

int main (){ 

  int n,q,i,j,count=0;
  int S[10000];
  int T[500];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);  
  for(j=0;j<q;j++){
    scanf("%d",&T[j]);
  }
  for(j=0;j<q;j++){
    for (i=0;i<n;i++){
      if(S[i]==T[j]){
	count++;
	break;
      }
    }
  }
  
  printf("%d\n",count);
  
  return 0;
}

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

int main(){
  int n,x,i,sum;
  cin >> n >> x;
  vector<int> l(n);
  vector<int> d(n+1);

  for(i=0;i<n;++i){
    cin >> l[i];
  }
  sum=0;
  for(i=0;i<n+1;++i){
    if(i==0){
      d[i]=0;
    }else{
    d[i]=d[i-1]+l[i-1];
  }

  if(d[i]<=x){
    sum=sum+1;
  }

  }

  cout << sum << endl;
  return 0;

}


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

int n, z, w;
vector<int> a;

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

  cin >> n >> z >> w;
  a.resize(n);
  for (int i = 0; i < n; ++i) cin >> a[i];

  cout << max(abs(w - a[n - 1]), ((n > 1) ? abs(a[n - 2] - a[n - 1]) : 0)) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  int ans = 0;
  string s;
  cin >> n >> s;
  for(int i = 0; i < n-2; i++){
    if(s.at(i) == 'A' && s.at(i+1) == 'B' && s.at(i+2) == 'C'){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int i, j, N, flag=1, temp, c=0;
  int A[100]={};

  scanf("%d",&N);

  for(i=0; i<N; i++){
    scanf("%d",&A[i]);
  }

  for(j=N-1; j>=i+1;){

  }

  for(i=0; i<N; i++){
    for(j=N-1; j>=i+1; j--){
      if(A[j]<A[j-1]){
	temp = A[j-1];       
	A[j-1] = A[j];
	A[j]= temp;
	c++;
      }
    }
  }

  for(i=0; i<N-1; i++){
    printf("%d ",A[i]);
      }

  printf("%d",A[N-1]);

  printf("\n%d\n",c);

  return 0;
}  

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int a,b,c,d;
    string s;cin>>s;
    a=s[0]-'0';b=s[1]-'0';c=s[2]-'0';d=s[3]-'0';
    s="";
    int bitt;
    for (int bit = 0; bit < (1<<3); ++bit){
        int ans = a;
        if(bit & (1<<0)){ans+=b;}else{ans-=b;}
        if(bit & (1<<1)){ans+=c;}else{ans-=c;}
        if(bit & (1<<2)){ans+=d;}else{ans-=d;}
        if(ans==7)
        bitt=bit;
    }
    s.push_back('0'+a);
    if(bitt & (1<<0)){s.push_back('+');}else{s.push_back('-');}
    s.push_back('0'+b);
    if(bitt & (1<<1)){s.push_back('+');}else{s.push_back('-');}
    s.push_back('0'+c);
    if(bitt & (1<<2)){s.push_back('+');}else{s.push_back('-');}
    s.push_back('0'+d);
    s.push_back('=');
    s.push_back('7');
    co(s);

}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

 int h, m, s, x;

 scanf("%d", &x);

 h = x/3600;

 m = (x%3600)/60;

 s = (x%3600)%60;

 printf("%d:%d:%d\n", h, m, s);

 return 0;

}


Measured memory_bytes: 2064
s=list(input())
t=list(input())
a=0
if len(t)-len(s) == 1:
  for i in range(len(s)):
    if s[i]!=t[i]:
      print("No")
      a=1
      break 
else:
  print("No")
  a=1
if a==0:
  print("Yes")

Measured memory_bytes: 9008
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0'; ch=getchar();} while ('0'<=ch&&ch<='9');t*=f;
}
typedef long long ll;
const int maxn=(1e5)+10;
ll sum,res;
int n,a[maxn],s[maxn];
int d2[maxn],tot,d[maxn];
pair<int,int> f[maxn];
int tr[2][maxn];
bool cmp(pair<int,int> x,pair<int,int> y) {
	if (x.first==y.first) return x.second>y.second;
	return x.first<y.first;
}
void add(int i,int x) {
	for (;x<=n+1;x+=x&(-x)) tr[i][x]++;
}
int q(int i,int x) {
	int res=0;
	for (;x>0;x-=x&(-x)) res+=tr[i][x];
	return res;
}
ll query(int mid) {
	s[0]=0;
	for (int i=1;i<=n;++i) {
		s[i]=s[i-1];
		if (a[i]>=mid) s[i]++;
		//printf("%d ",s[i]);
	}
	//printf("\n");
	res=0;
	/*
	for (int i=1;i<=n;i++)
	for (int j=i+1;j<=n;j+=2)
		if (s[j]-s[i-1]>=(j-i+1)-(j-i+1)/2) {
			res++;
			printf("%d %d\n",i,j);
		}
	printf("!%lld\n",res);
	*/
	for (int i=0;i<=n;++i)
		f[i]=make_pair(2*s[i]-i,i);
	sort(f,f+(n+1));
	res=0;
	memset(tr,0,sizeof(tr));
	for (int i=0;i<=n;++i) {
		res+=q(f[i].second&1,f[i].second+1);
		//printf("%d %d %d\n",f[i].first,f[i].second,q(i&1,f[i].second+1));
		add(f[i].second&1,f[i].second+1);
	}
	//printf("%lld\n",res);
	sort(f,f+(n+1),cmp);
	memset(tr,0,sizeof(tr));
	for (int i=0;i<=n;++i) {
		res+=q(f[i].second&1^1,f[i].second+1);
		add(f[i].second&1,f[i].second+1);
	}
	//printf("%d %lld\n",mid,res);
	return res;
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	for (int i=1;i<=n;i++) {
		read(a[i]); d2[i]=a[i];
	}
	sort(d2+1,d2+(n+1));
	for (int i=1;i<=n;i++)
		if (d2[i]!=d2[i-1]) d[++tot]=d2[i];
	sum=(ll)n*(n+1)/2;
	sum=(sum+1)/2;
	//printf("%lld\n",sum);
	int l=1,r=tot,res=0;
	while (l<=r) {
		int mid=(l+r)/2;
		if (query(d[mid])>=sum) l=mid+1,res=mid;
		else r=mid-1;
	}
	printf("%d\n",d[res]);
	return 0;
}

Measured memory_bytes: 3328
n, x = map(int, input().split())
ls = list(map(int, input().split()))
s = sum(ls)
if s < x:
    print(n - 1)
elif s == x:
    print(n)
else:
    ls.sort()
    a = 0
    for i in range(n):
        if ls[i] <= x:
            x -= ls[i]
            a += 1
        else:
            print(a)
            break


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

  int n;
  cin >> n;

  set<int> s;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;

    if (s.count(a)) {
      cout << "NO\n";
      return (0);
    }

    s.emplace(a);
  }

  cout << "YES\n";

  return (0);
}


Measured memory_bytes: 12968
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define rf(i,n) for(int i=n-1;i>=0;i--)
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repn(a,b,c) for(int a=b;a<=c;a++)
#define PI 3.1415926535897932384626433832795
#define fi first
#define se second
#define mp(x,y) make_pair(x,y)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define BIN(n,x) bitset<n>(x)  //bitshift works on 32 bit integers only
#define mod (ll)1000000007
using namespace std;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<ll,ll>> vpl;

//nC2
ll C2(ll n){
    ll ans= max(((n*(n-1))/2),(ll)0);
    return ans;
}
//square
ll sq(ll n){
    return n*n;
}

//GCD
ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    if(b==0){
        return a;
    }    
    else{
        return gcd(b,a%b);
    }
}

//LCM
ll lcm(ll a,ll b){
    if(a==0 || b==0){
        return 0;
    }
    else{
        return((ll)((a*b)/gcd(a,b)));
    }
}

//sort pair by second values
bool sortsec(const pair<ll,ll> &a, const pair<ll,ll> &b){ 
    return (a.second < b.second); 
}

//Binary Exponentiation
ll BinExp(ll a, ll b, ll m){
    a%=m;
    ll res =1;
    while(b>0){
        if(b&1){
            res = (res * a)%m;
        }
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}

//All Non-Empty SubSequences(O(2*n))
vvi SubSeq;
void allSub(vector<int> arr, int index,vector<int> subarr){
    if (index == arr.size()){ 
        int l = subarr.size(); 
        if (l != 0){
            SubSeq.pb(subarr); 
        }
    } 
    else{ 
        allSub(arr, index + 1, subarr); 
        subarr.push_back(arr[index]); 
        allSub(arr, index + 1, subarr); 
    } 
    return; 
} 

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

    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
    
    


    return 0;
}



Measured memory_bytes: 3652
#include <iostream>

const int mod = 1000000007;

long long power(long long b, int p)
{
	long long ans = 1;
	while (p)
	{
		if (p % 2)
			ans = (ans * b) % mod;
		b = (b * b) % mod;
		p /= 2;
	}
	return ans;
}

const int size = 20005;

int fact[size]{ 1, 1 };

int df[size]{ 1, 1 };

void Compute()
{
	for (int i = 2; i < size; ++i)
	{
		fact[i] = (fact[i - 1] * static_cast<long long>(i)) % mod;
		df[i] = power(fact[i], mod - 2);
	}
}

long long ncr(int n, int r)
{
	if (r > n)
		return 0;
	return (((static_cast<long long>(fact[n]) * df[n - r]) % mod) * df[r]) % mod;
}

int main()
{
	Compute();
	int n, k;
	std::cin >> n >> k;
	for (int i = 1; i <= k; ++i)
		std::cout << (ncr(k - 1, i - 1) * ncr(n - k + 1, i)) % mod << '\n';
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		String str;
		Scanner scan=new Scanner(System.in);
		str=scan.next();
		scan.close();
		for(int i=str.length()-1;0<=i;i--){
			System.out.print(str.charAt(i));
		}
		System.out.println();
	}
}

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

using ll = long long; 
const ll INF = (ll)1e10;

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

  ll comA[N+2], comB[M+2];
  comA[0]=0;
  comA[N+1]=INF;
  comB[0]=0;
  comB[M+1]=INF;
  for (ll i = 1; i <= N; i++) {
    ll a;
    cin >> a;
    comA[i] = comA[i-1]+a;
  }
  for (ll i = 1; i <= M; i++) {
    ll b;
    cin >> b;
    comB[i] = comB[i-1]+b;
  }

  int okA = 0;
  int ngA = N+1;
  while (ngA-okA>1){
    int mid = (okA+ngA)/2;
    if (comA[mid]<=K) okA = mid;
    else ngA = mid;
  }
  
  int ans = 0;
  for (int i = okA; i >= 0; i--) {
    ll rest = K-comA[i];
    
    int okB = 0;
    int ngB = M+1;
    while (ngB-okB>1){
      int mid = (okB+ngB)/2;
      if (comB[mid]<=rest) okB = mid;
      else ngB = mid;
    }
    ans = max(ans, i+okB);
  }

  cout << ans << endl;
  

  return 0;
}

Measured memory_bytes: 6756
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MP make_pair
#define PB push_back
#define SZ(a) ((int)a.size())
typedef long long ll;

ll po (ll a, ll e) {
        ll r = 1;
        while (e) {
                if (e&1) r = r * a % MOD;
                e /= 2, a = a * a % MOD;
        }
        return r;
}

#define MAXN 100100
int N, a[MAXN], o[MAXN], rs, re;
ll fac[MAXN], invfac[MAXN];

ll ch (ll n, ll r) {
        if (n < r) return 0ll;
        return fac[n] * invfac[r] % MOD * invfac[n-r] % MOD;
}

int main () {
        fo(i, 0, MAXN) fac[i] = i ? fac[i-1] * i % MOD : 1;
        invfac[MAXN-1] = po(fac[MAXN-1], MOD-2);
        for (int i = MAXN-2; i >= 0;  i--) invfac[i] = invfac[i+1] * (i+1) % MOD;

        scanf("%d", &N);
        fo(i, 1, N+1) o[i] = -1;
        fo(i, 0, N+1) {
                scanf("%d", &a[i]);
                if (o[a[i]] != -1) rs = o[a[i]], re = i;
                else o[a[i]] = i;
        }

        fo(K, 1, N+2) {
                printf("%lld\n", (ch(N+1, K) - ch(N+1-(re-rs+1), K-1) + MOD) % MOD);
        }
        //rs and re are the repeated values
        //first find all subsequences, then remove the double counted ones?
        //double counted if nothing between rs and re are chosen, rs chosen in one, re chosen in other
        //so basically

        return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N, M, K;
  cin >> N >> M >> K;
  vl A(N + 1, 0), B(M + 1, 0);
  rep(i, N){
    cin >> A[i + 1];
    A[i + 1] += A[i];
  }
  rep(i, M){
    cin >> B[i + 1];
    B[i + 1] += B[i];
  }

  ll ans = -(ll)pow(10, 18);

  rep(i, N + 1){
    if(A[i] > K)
      break;

    ll tmp = upper_bound(B.begin(), B.end(), K - A[i]) - B.begin();
    ans = max(ans, i + tmp - 1);
  }

  cout << ans << "\n";
  
  return 0;
}


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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n;
    int a[100001];
    map<ll, ll> m;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        int tmp = m[a[i]];
        m.erase(a[i]);
        m.insert(make_pair(a[i], tmp + 1));
    }

    int cnt = 0;
    for (auto it = m.begin(); it != m.end(); it++)
    {
        if (it->second % 2 == 1)
            cnt++;
    }
    cout << cnt << endl;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> count(100010, 0);
  
  for (int i = 0; i < N; i++){
    int x;
    cin >> x;
    count[x]++;
  }
  
  
  int onecard = 0;   // 1枚しかないカードの枚数 
  int cards_num = 0; // 2枚以上のカードの種類
  for (int i = 1; i <= 100000; i++) {
    if (count[i] == 1) onecard++;
    if (count[i] > 1) cards_num++;
  }
  
  
  if ((cards_num - (N-onecard)) % 2) {
    cout << onecard + cards_num - 1<< endl;
  } else {
    cout << onecard + cards_num << endl;
  }
}

Measured memory_bytes: 3788
n = int(input())
S = [input() for _ in range(n)]
m = [1000] * 26
al = 'abcdefghijklmnopqrstuvwxyz'
for s in S:
    k = [s.count(l) for l in al]
    m = [min(k[i], m[i]) for i in range(26)]
ans = str()
for i in range(26):
    ans += al[i]*m[i]
print(ans)


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


int dp[100100][3];

int main() {
  int n; cin >> n;
  vector<int> a(n), b(n), c(n);
  rep(i,n) cin >> a[i] >> b[i] >> c[i];
  memset(dp, 0, sizeof(dp));
  rep(i,n) {
    rep(j,3) {
      if(j==0) dp[i+1][0] = max(dp[i][1],dp[i][2])+a[i];
      if(j==1) dp[i+1][1] = max(dp[i][0],dp[i][2])+b[i];
      if(j==2) dp[i+1][2] = max(dp[i][0],dp[i][1])+c[i];
    }
  }
  cout << max(dp[n][0],max(dp[n][1],dp[n][2])) << endl;
  return 0;
}

Measured memory_bytes: 5620
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    
    vector<vector<int>> shop = vector<vector<int>>(100, vector<int>(10, 0));
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < 10; ++j)
        {
            cin >> shop[i][j];
        }
    }
    vector<vector<int>> gain = vector<vector<int>>(100, vector<int>(11, 0));
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < 11; ++j)
        {
            cin >> gain[i][j];
        }
    }
    vector<int> map = vector<int>(1024, 0);
    
    for (int i = 0; i < 1024; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            int count = 0;
            for (int k = 0; k < 10; ++k)
            {
                int num = ((i >> k) & 1);
                if (num & shop[j][k])
                {
                    count++;
                }
            }
            map[i] += gain[j][count];
        }
    }
    int ret = -2147483648;
    for (int i = 1; i < 1024; ++i)
    {
        ret = max(ret, map[i]);
    }
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 3616
import sys
import math

z=input()
n=list(map(int,input().split()))
k={}
L={}

for num in n:
  #yakusu no kazu wo kaesu
  i=num
  j=2
  k.clear()
  while i>1:
    if i%j==0:
      if j in k:
        k[j]+=1
      else:
        k[j]=1
      i/=j
      j=2
    else:
      j+=1
      
  for i in k:
    if i in L:
      if k[i]>L[i]:
        L[i]=k[i]
    else:
      L[i]=k[i]

#print(L)
ans=1
for i in L:
  ans*=i**L[i]

print(ans)



Measured memory_bytes: 5664
#include<bits/stdc++.h>
const int mod=1e9+7;
typedef long long ll;
const int N=2e5+5;
std::set<std::string> s;
int main()
{
	std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
	// freopen("a.in","r",stdin);
	// int T;scanf("%d",&T);while(T--){
	int n;
	std::string str;
	std::cin>>n;
	while(n--)
	{
		std::cin>>str;
		s.insert(str);
	}
	printf("%d\n",s.size());
	// }
	return 0;
}


Measured memory_bytes: 19324
#include <iostream>

using namespace std;

int n,A[20],s[20],b[10000000],bc=0,q,m;

bool rec(int i){
  if (i == n){
    int sum=0; 
    for(int j=0; j<n; ++j){
      //cout << s[j] << ",";
      if(s[j]) sum += A[j]; 
    }
    b[bc] = sum;
    ++bc;
    //cout << endl;
    return 0;
  }

  rec(i + 1);
  s[i] = 1;
  rec(i + 1);
  s[i] = 0 ;
}

void combi(){
  for(int i=0; i<n; ++i) ;
  rec(0);
}

bool judge(int in){
  for(int i=0; i<bc; ++i)
    if(in == b[i])
      return true;
  return false;
}


int main(){

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

  combi();

  cin >> q;
  for(int i=0; i<q; ++i){
    cin >> m;
    if(judge(m))
      cout << "yes";
    else
      cout << "no";
    cout << endl;
  }
  
  

  return 0;
}



Measured memory_bytes: 7096
/*#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define INF 1000000000000 //10^12:極めて大きい値,∞
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    int x,y;
    cin >> x >> y;
    cout << x*y << " " << x*2+y*2 << endl;
    return 0;
}


Measured memory_bytes: 2996
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let mut b: Vec<i32> = (0..n - 1).map(|_| read()).collect();

    let mut ans = vec![b[0]; 2];

    ans.pop();
    for b_i in b.windows(2) {
        if b_i[0] > b_i[1] {
            ans.push(b_i[1]);
        } else {
            ans.push(b_i[0]);
        }
    }
    if b.last().unwrap() > ans.last().unwrap() {
        let b_last = *b.last().unwrap();
        ans.push(b_last);
    } else {
        let ans_last = *ans.last().unwrap();
        ans.push(ans_last);
    }

    println!("{}", ans.iter().sum::<i32>());
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352