akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Dice {
    int first, second, third, fourth, fifth, sixth;

    Dice(int[] diceval) {
        this.first = diceval[0];
        this.second = diceval[1];
        this.third = diceval[2];
        this.fourth = diceval[3];
        this.fifth = diceval[4];
        this.sixth = diceval[5];
    }

    void N() {
        int temp = this.fifth;
        this.fifth = this.first;
        this.first = this.second;
        this.second = this.sixth;
        this.sixth = temp;
    }

    void S() {
        int temp = this.second;
        this.second = this.first;
        this.first = this.fifth;
        this.fifth = this.sixth;
        this.sixth = temp;
    }

    void E() {
        int temp = this.third;
        this.third = this.first;
        this.first = this.fourth;
        this.fourth = this.sixth;
        this.sixth = temp;
    }

    void W() {
        int temp = this.fourth;
        this.fourth = this.first;
        this.first = this.third;
        this.third = this.sixth;
        this.sixth = temp;
    }
}

public class Main {
    static int[] stringToInt(String[] str) {
        int elements[] = new int[str.length];
        for (int i = 0; i < str.length; i++) {
            elements[i] = Integer.parseInt(str[i]);
        }
        return elements;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        int[] elements = stringToInt(br.readLine().split(" "));
        char[] direction = br.readLine().toCharArray();

        Dice dice = new Dice(elements);
        for (int i = 0; i < direction.length; i++) {
            switch (direction[i]) {
            case 'N':
                dice.N();
                break;
            case 'S':
                dice.S();
                break;
            case 'E':
                dice.E();
                break;
            case 'W':
                dice.W();
                break;
            default:
                break;
            }
        }
        System.out.println(dice.first);
    }
}

Measured memory_bytes: 24456
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    string pre, s, suf;
    io.read(pre, s, suf);
    cout << pre[0] << s[0] << suf[0];
    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
 
#define _USE_MATH_DEFINES
#define mp       make_pair
#define pb       push_back
#define fst      first
#define snd      second
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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


int main()
{
    int N; cin >> N;
    vector<pii> red(N), blue(N);
    int a,b,c,d;
    rep(i, N) {
        cin >> a >> b;
        red[i] = mp(a, b);
    }
    rep(i, N) {
        cin >> c >> d;
        blue[i] = mp(c, d);
    }

    sort(red.begin(), red.end());
    sort(blue.begin(), blue.end());

    bool paired[100] = {false};
    int ans = 0;
    rep(b, N) {
        int i = -1;
        for(int r = 0; r < N && red[r].fst < blue[b].fst; r++) {
            if(!paired[r] && red[r].snd < blue[b].snd) {
                if(i == -1 || red[r].snd > red[i].snd) {
                    i = r;
                }
            }
        }
        if(i != -1) {
            ans++;
            paired[i] = true;
        }
    }

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


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int64 N, M;
int64 ptoi(int64 y, int64 x) {
  return y * M + x;
}

PLL itop(int64 p) {
  return PLL(p / M, p % M);
}

int64 dy[2] = {1, 0};
int64 dx[2] = {0, 1};

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

	constexpr int64 inf = 1000000, inf2 = INF*1000;
	cin >> N >> M;
	vector<string> s(N);
	REP(i, N) cin >> s[i];
	mcf_graph<int64, int64> mcf(2*N*M+2);
	int64 S = 2*N*M, G = 2*N*M+1;
	int64 cnt = 0;
	auto ok = make_v<int>(N*M, N*M);
	REP(i, N) {
	  REP(j, M) {
	    ok[ptoi(i, j)][ptoi(i, j)] = 1;
	    if (s[i][j] == '#') continue;
	    mcf.add_edge(N*M+ptoi(i, j), G, 1, 0);
	    if (s[i][j] == 'o') {
	      mcf.add_edge(S, ptoi(i, j), 1, 0);
	      cnt++;
	    }
	    REP(k, 2) {
	      int64 yy = i + dy[k], xx = j + dx[k];
	      if (yy >= N || xx >= M || s[yy][xx] == '#') continue;
	      ok[ptoi(i, j)][ptoi(yy, xx)] = 1;
	    }
	  }
	}
	REP(i, N*M) {
	  auto p1 = itop(i);
	  if (s[p1.fs][p1.sc] != 'o') continue;
	  vector<int> visited(N*M, 0);
	  visited[i] = 1;
	  queue<int> q;
	  q.push(i);
	  while (q.size()) {
	    int64 v = q.front(); q.pop();
	    int y = itop(v).fs, x = itop(v).sc;
	    mcf.add_edge(i, v+N*M, 1, INF-abs(y-p1.fs)-abs(x-p1.sc));
	    REP(k, 2) {
	      int yy = y + dy[k], xx = x + dx[k];
	      if (yy < N && xx < M && s[yy][xx] != '#' && !visited[ptoi(yy, xx)]) {
	        visited[ptoi(yy, xx)] = 1;
	        q.emplace(ptoi(yy, xx));
	      }
	    }
	  }
	}
	PLL ret = mcf.flow(S, G, cnt);
	int64 res = cnt * INF - ret.sc;
	for (auto &e : mcf.edges()) {
	  if (e.cap != 0 && e.flow != 0) {
	    if (e.from <= N*M && e.to <= 2*N*M) {
	      PLL p1 = itop(e.from), p2 = itop(e.to-N*M);
	    }
	  }
	}
	cout << res << endl;
}


Measured memory_bytes: 35828
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;
import java.util.*;

/**
 * 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;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            int a[] = new int[N];
            int res[] = new int[9];
            int res1[] = new int[9];

            int ans=0;
            int ans1 = 0;
            for(int i=0; i<N; i++){
                a[i] = in.nextInt();
            }
            Arrays.sort(a);
            for(int i=0; i<N; i++){
                int div = a[i]/400;
                if(div<8){
                    res[div] = 1;
                    res1[div] = 1;
                }

                if(div>=8){
                    ans++;
                }
            }
            for(int i=0; i<9; i++){
                if(res[i]==1) ans++;
                if(res1[i]==1) ans1++;
            }

            out.print(Math.max(1,ans1)+" "+ans);
            out.println();
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}

Measured memory_bytes: 23380
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL M, D;
	in >> M >> D;

	LL ans = 0;
	for (LL m = 1; m <= M; ++m)
	{
		for (LL d = 1; d <= D; ++d)
		{
			LL d1 = d % 10, d2 = d / 10;
			if (d1 >= 2 && d2 >= 2 && d1 * d2 == m) ++ans;
		}
	}
	out << ans << std::endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
w,h,n=map(int,input().split())

l=[[0,0,0] for _ in range(n)]
for i in range(n):
    l[i][0],l[i][1],l[i][2]=map(int,input().split())
#print(l)

s=[0,w,0,h]
for i in range(n):
    if l[i][2]==1:
        s[0]=max(s[0],l[i][0])
    elif l[i][2]==2:
        s[1]=min(s[1],l[i][0])
    elif l[i][2]==3: 
        s[2]=max(s[2],l[i][1])
    elif l[i][2]==4:
        s[3]=min(s[3],l[i][1])
print((s[1]-s[0])*(s[3]-s[2]) if s[1]>=s[0] and s[3]>=s[2] else 0)

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

int main() {
    
  vector<vector<int>> card(3, vector<int>(3));
 
  for (int i = 0; i < card.size(); i++) {
    for (int j = 0; j < card.at(0).size(); j++) {
      cin >> card.at(i).at(j);
    }
  }
  
  int input_size;
  cin >> input_size;
  
  vector<int> input_num(input_size, 0);
  for (int i = 0; i < input_num.size(); i++) {
    cin >> input_num.at(i);
  }
  
  // ビンゴ表
  vector<vector<bool>> check(3, vector<bool>(3, false));
  for (int num : input_num) {
    for (int i = 0; i < card.size(); i++) {
      for (int j = 0; j < card.at(0).size(); j++) {
        if (card.at(i).at(j) == num) check.at(i).at(j) = true;
      }
    }
  }
  
  // ビンゴ判定
  string result = "No"; 
  if (check.at(0).at(0) == true 
      && check.at(1).at(1) == true 
      && check.at(2).at(2) == true) result = "Yes";
  
  if (check.at(0).at(2) == true 
      && check.at(1).at(1) == true 
      && check.at(2).at(0) == true) result = "Yes";
    
  for (int i = 0; i < check.size(); i++) {
    if (check.at(i).at(0) == true 
        && check.at(i).at(1) == true 
        && check.at(i).at(2) == true) result = "Yes";
  }
  
  for (int i = 0; i < check.size(); i++) {
    if (check.at(0).at(i) == true 
        && check.at(1).at(i) == true 
        && check.at(2).at(i) == true) result = "Yes";
  }
  
  cout << result << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define M 1000000007

int main(void)
{
    long long int n, i, sum=1;
    scanf("%lld",&n);
    for(i = 1; i <= n; i++)
    {
        sum=sum*i;
        sum=sum%M;
    }

    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#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()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int h, w;
int dir[5] = {1, 0, -1, 0, 1};

int main() {
    cin >> h >> w;
    Vs s(h);
    REP(i, h) cin >> s[i];

    int res = 0;
    REP(i, h) REP(j, w) {
        if (s[i][j] == '#') continue;

        int maxi = 0;
        VVi v(h, Vi(w, -1));
        queue<Pii> q;
        q.push({i, j});
        v[i][j] = 0;
        while (!q.empty()) {
            int y = q.front().first, x = q.front().second;
            q.pop();
            REP(k, 4) {
                int Y = y+dir[k], X = x+dir[k+1];
                if (Y < 0 || Y >= h || X < 0 || X >= w) continue;
                if (s[Y][X] == '#') continue;
                if (v[Y][X] != -1) continue;
                q.push({Y, X});
                v[Y][X] = v[y][x] + 1;
                maxi = max(maxi, v[Y][X]);
            }
        }

        res = max(res, maxi);
    }
    std::cout << res << '\n';

    return 0;
}


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

bool isprime(int a) {
	for (int i = 2;i*i <= a;i++) {
		if (a%i == 0)return false;
	}
	return a != 1;
}

int main() {
	int n;
	while (cin >> n, n) {
		int ans;
		int sp, bp;
		if (isprime(n))ans = 0;
		else {
			for (int i = n;i > 0;i--) {
				if (isprime(i)) {
					sp = i;
					break;
				}
			}
			for (int i = n;i < 1300000;i++) {
				if (isprime(i)) {
					bp = i;
					break;
				}
			}
			ans = bp - sp;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 2976
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      long a,b,c,N,S,ans;
      cin >> N;

      S=(1+N)*N/2;
      

      a=(N/3)*(3+3*(N/3))/2;
     

      b=(N/5)*(5+5*(N/5))/2;
      

      c=(N/15)*(15+15*(N/15))/2;
      

      ans=S-(a+b-c);

      cout << ans << endl;
      
    }


Measured memory_bytes: 3568
#include<bits/stdc++.h>
#define ll long long
#define ljc 998244353
using namespace std;
inline ll read(){
	ll x=0,f=1;char ch=getchar();
	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
	while (isdigit(ch)){x=x*10ll+ch-'0';ch=getchar();}
	return x*f;
}
inline ll fast_pow(ll a,ll b,ll p){
    ll t=1;a%=p;
    while (b){
        if (b&1) t=t*a%p;
        b>>=1;a=a*a%p;
    }
    return t;
}
char s[10101];
int dp[303][303][303],n,K;
signed main(){
	scanf("%s",s+1);
	K=read();n=strlen(s+1);
	for (int i=1;i<=n;i++){
		for (int j=0;j<=K;j++){
			dp[i][i][j]=1;
		}
	}
	for (int len=2;len<=n;len++){
		for (int i=1;i+len-1<=n;i++){
			int j=i+len-1;
			for (int k=0;k<=K;k++){
				dp[i][j][k]=max(dp[i][j-1][k],dp[i+1][j][k]);
				if (s[i]==s[j]) dp[i][j][k]=max(dp[i][j][k],dp[i+1][j-1][k]+2);
				else if (k) dp[i][j][k]=max(dp[i][j][k],dp[i+1][j-1][k-1]+2);
			}
		}
	}
	cout<<dp[1][n][K];
	return 0;
}


Measured memory_bytes: 58096
#include<bits/stdc++.h>
using namespace std;
int n,m,c;
int dp[1001];
int d[1000];

int main(){
  scanf("%d %d",&n,&m);
  fill(dp,dp+n+1,1e9);
  dp[0]=0;
  for(int i=0;i<n;i++)scanf("%d",&d[i]);  
  for(int i=0;i<m;i++){
    scanf("%d",&c);
    for(int j=n;j>0;j--)dp[j]=min(dp[j],dp[j-1]+c*d[j-1]);
  }
  printf("%d\n",dp[n]);
  return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl;
#define INF 1ll<<60;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

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

int main(){
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    if(x/d>k){
        out(abs(x-k*d));
    }
    else{
        if((k-x/d)%2==0){
            out(abs(x-d*(x/d)))
        }
        else{
            out(abs(x-d*(x/d+1)));
        }
    }
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll N, Q;
ll A[100005];
ll X[100005];

//! でかいほうから交互に取った場合の累積和
ll B[100005];
//! 累積和
ll C[100005];

//! 青木がxを選んだ時の高橋の取得点数
ll calc(ll x)
{
    //! 青木が最初にとるindex
    int s = 0;
    {
        int ok = N - 1, ng = -1;
        while (abs(ok - ng) > 1)
        {
            int mid = (ok + ng) / 2;
            if (x <= A[mid])
                ok = mid;
            else
                ng = mid;
        }
        s = ok;
        if (ok - 1 >= 0 && abs(A[ok - 1] - x) <= abs(A[ok] - x))
            s = ok - 1;
    }

    if (s == N - 1)
    {
        //! 青木が最初に取る予定のものが一番大きいなら、どうせ交互になっていく
        return B[N];
    }

    ll sum = 0;
    //! 高橋が連続して取れる個数を求める
    {
        int ok = 1, ng = N / 2 + 1;
        if (N % 2 == 1)
            ng++;
        while (abs(ok - ng) > 1)
        {
            int mid = (ok + ng) / 2;

            //! 高橋が連続して取る最後のindex
            int li = N - mid;
            if (li - s >= mid)
            {
                ok = mid;
                continue;
            }
            if (li <= s)
            {
                ng = mid;
                continue;
            }
            if (abs(A[li - mid + 1] - x) <= abs(A[li] - x))
            {
                ok = mid;
            }
            else
            {
                ng = mid;
            }
        }

        //! 高橋はN-1からliまでとり、青木はli-1からli-okまで連続で取る
        //! その後は交互にとっていく
        sum = (C[N] - C[N - ok]) + B[std::max(N - ok - ok, (ll)0)];
    }
    return sum;
}

int main()
{
    cin >> N >> Q;
    B[0] = C[0] = 0;
    REP(i, N)
    {
        cin >> A[i];
        C[i + 1] = A[i];
        C[i + 1] += C[i];
        if (N % 2 != i % 2)
            B[i + 1] = A[i];
        B[i + 1] += B[i];
    }
    REP(i, Q)
    {
        ll x;
        cin >> x;
        X[i] = calc(x);
    }
    REP(i, Q)
    {
        cout << X[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=3.14159265358979323846;
using namespace std;
vector<int> dy={1,0,-1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    cin>>n;
    vector<int> l(n);
    rep(i,n) cin>>l[i];
    sort(all(l));
    
    int ans=0;
    for(int i=0;i<n;i++) {
        for(int j=i+1;j<n;j++) {
            int left=max((int)(lower_bound(all(l),l[i]+l[j])-l.begin()),j+1);
            int right=max((int)(upper_bound(all(l),abs(l[i]-l[j]))-l.begin()),j+1);
            ans+=left-right;
            //cout<<right<<" "<<left<<endl;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rlcfpoj(x) scanf("%I64d",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define plcfpoj(x) printf("%I64d",x)
#define lfd() printf("\n")
#define sp() printf(" ")
#define inrep(x) int x;scanf("%d",&x);while(x--)
#define mod 1000000007
string s;
int dp[100100][14];
int dabiao[13]={0,4,8,12,3,7,11,2,6,10,1,5,9};
int addup(int x){//x+?*13 /10
	return dabiao[x];
}	
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>s;
	int n=s.size();
	s="$"+s;
	dp[0][0]=1;//余零 
	for(int i=1;i<=n;i++){
		for(int j=0;j<13;j++){
			if(s[i]=='?'){
				for(int k=0;k<=9;k++){
					dp[i][j]+=dp[i-1][addup((j+13-k)%13)];
					dp[i][j]%=mod;
				}
			}
			else{
				dp[i][j]+=dp[i-1][addup((j+13-s[i]+'0')%13)];
				dp[i][j]%=mod;
			}
		}
	} 
	cout<<dp[n][5]<<endl;
	return 0;
}


Measured memory_bytes: 5868
#include <iostream>
using namespace std;
typedef long long ll;
ll a, b, x;
inline ll f(ll n) {
	if (-1 == n) {
		return 0;
	} else {
		return n/x + 1;
	}
}
int main() {
	cin >> a >> b >> x;
	cout << f(b) - f(a-1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,N); for (int i = 0; i<N; i++)
#define in(N); cin >> N
#define out(ans); cout << ans << endl;
 
int main() {
  int N;
  string N1;
  in(N);
  N1=to_string(N);
  if (N1.at(0)=='7' || N1.at(1)=='7' || N1.at(2)=='7') cout << "Yes" << endl;
  else cout << "No" << endl;
 
}

Measured memory_bytes: 3696
/*
___ is a raging sadist.
*/
//Destroy all WA at test 2
// Stay cool
// Pass the 4th wall..

#include "bits/stdc++.h"
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ld long double
#define pow power
#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define siz(a) int((a).size())
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define endl "\n"
#define pi 3.14159265
const ll mod = 1000 * 1000 * 1000 + 7;
const ll mod1 = 998244353;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7; 
using namespace std;

ll power(ll x, ll y) 
{ 
   ll res = 1;      
  
   
    while (y > 0) 
    { 
       
        if (y & 1) 
            res = (long long)(res*x); 
  

        y = y>>1; 

        if (x<=100000000)
        x = (long long)(x*x);

        //cout<<x<<'\n'; 
    } 
    return res; 
} 






int main()
{

#ifndef ONLINE_JUDGE    
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif

fastio();

    ll n,x,t;
    cin>>n>>x>>t;

    n+=x-1;
    ll ans=t*(n/x);
    cout<<ans;

return 0;
}

// check all product based operations for integer overflow

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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("5");
            //11
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("86");
            //939587134549734843
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int N = int.Parse(InputList[0]);

        long[] RyokaArr = new long[N + 1];
        RyokaArr[0] = 2;
        RyokaArr[1] = 1;
        for (int I = 2; I <= N; I++) {
            RyokaArr[I] = RyokaArr[I - 1] + RyokaArr[I - 2];
        }
        Console.WriteLine(RyokaArr[N]);
    }
}


Measured memory_bytes: 13140
import java.io.*;
import java.util.*;
import java.util.function.*;
import java.util.regex.*;
import java.util.stream.*;

final class Solver {
	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		int K = Integer.parseInt(sc.get());
		String S = sc.get();
		Pattern pattern = Pattern.compile("1+");
		Matcher matcher = pattern.matcher(S);
		int[] starts, ends;
		{
			IntStream.Builder startsBuilder = IntStream.builder();
			IntStream.Builder endsBuilder = IntStream.builder();
			while (matcher.find()){
				startsBuilder.add(matcher.start());
				endsBuilder.add(matcher.end());
			}
			starts = startsBuilder.build().toArray();
			ends = endsBuilder.build().toArray();
		}

		if (starts.length == 0){
			System.out.println(N);
			return;
		}

		int zeros = starts.length - 1;
		if (starts[0] != 0) zeros += 1;
		if (ends[ends.length - 1] != N) zeros += 1;

		if (K >= zeros) {
			System.out.println(N);
			return;
		}


		int max = 0;
		for (int i = 0; i < ends.length; i++) {
			max = Math.max(max, ends[i] - starts[Math.max(i - K, 0)]);
		}
		if (starts[0] != 0){
			max = Math.max(max, ends[Math.min(K, ends.length) - 1]);
		}
		if (ends[ends.length - 1] != N){
			max = Math.max(max, N - starts[Math.max(starts.length - K, 0)]);
		}

		System.out.println(max);
	}
}

class Main {
	public static void main(String... args) {
		new Thread(null, () -> {
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			new Solver().solve(new Supplier<String>() {
				StringTokenizer line;

				public String get() {
					while (line == null || !line.hasMoreTokens()) try {
						line = new StringTokenizer(reader.readLine());
					} catch (IOException e) {
						throw new UncheckedIOException(e);
					}
					return line.nextToken();
				}
			});
			System.out.flush();
		}, "", Runtime.getRuntime().maxMemory()).start();
	}
}

Measured memory_bytes: 37660
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	var r int
	for i := 1; i <= n; i++ {
		if (i % 3 == 0 && i % 5 == 0) || (i % 3 == 0) || (i % 5 == 0) {
			continue
		}
		r += i
	}
	fmt.Println(r)
}

Measured memory_bytes: 1756
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const int MOD = 1000000007;
/* テンプレートここまで */

int main() {
  string s;
  cin >> s;
  int n = s.size() - 1;
  ll ans = 0;

  REP(i, 1 << n){
    ll sum = 0;
    int prev = 0;

    REP(j, n){
      //DUMP(prev);
      //DUMP(j);
      int mask = 1 << j;
      if( i & mask){
        sum += stoll(s.substr(prev, j - (prev-1)));
        prev = j + 1 ;
      }
    }
    //DUMP(prev);
    sum += stoll(s.substr(prev, n-prev+1));
    ans += sum;
  }

  cout << ans << endl;
}


Measured memory_bytes: 384
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll ans=0;
    for(ll i=1;i<=N;++i){
        ll k=N/i;
        ans+=i*k*(k+1)/2;
    }
    prt(ans);

    return 0;
}



Measured memory_bytes: 3644
N=int(input())

red_list=[]
for i in range(N):
  a,b=map(int,input().split())
  red_list.append((a,b))
red_list.sort()
  
blue_list=[]
for i in range(N):
  c,d=map(int,input().split())
  blue_list.append((c,d))
blue_list.sort()

#print(red_list)
#print(blue_list)

answer=0
selected_set=set()
for i in range(N):
  c,d=blue_list[i]
  max_y=-1
  maxarg_y=-1
  for j in range(N):
    a,b=red_list[j]
    if c<=a:
      break
    
    if b<d and b>max_y and not j in selected_set:
      max_y=b
      maxarg_y=j
      
  if maxarg_y!=-1:
    answer+=1    
    selected_set.add(maxarg_y)
    #print(red_list[maxarg_y],blue_list[i])
    
print(answer)


Measured memory_bytes: 3064
import sys

sys.setrecursionlimit(10000000)
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue

# import fractions

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B = il()
    print(A*B)



if __name__ == '__main__':
    main()


Measured memory_bytes: 10216
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

vector<ll>a;
ll n,k;

bool C(ll mid){
	ll res=0;
	rep(i,n){
		ll div=a[i];
		ll cnt=0;
		if(div>mid)cnt+=div/mid;
		res+=cnt;
	}
	return res<=k;
}

void solve()
{
	cin>>n>>k;
	a.resize(n);
	rep(i,n)cin>>a[i];
	ll l=0,r=1e9;
	while(r-l>1){
		ll mid=(l+r)/2;
		if(C(mid))r=mid;
		else l=mid;
	}
	cout<<r;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 4696
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;


int main(void) {
    long long N;
    cin >> N;
    vector<long long>nums(5);
    for(int i = 0; i < 5; i++) {
        cin >> nums[i];
    }

    long long min_num = 10e15;
    for(int i = 0; i < 5; i++) {
        if(nums[i] < min_num) min_num = nums[i];
    }
    long long ans;
    if(N % min_num == 0) {
        ans = 5 + (N / min_num) - 1;
    } else {
        ans = 5 + (N / min_num);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()

#pragma region 逆元
const int MAX = 10000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long COM(int n, int k)
{
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
#pragma endregion


int main()
{
	int n, a, b; cin >> n >> a >> b;
	vector<ll> v(n);
	rep(i, 0, n - 1)cin >> v[i];
	sort(all(v), greater<ll>());
	ll aNum;
	int aCnt = 0;
	int waku = 0;
	aNum = v[a - 1];
	rep(i, 0, n - 1)
		if (v[i] == aNum)
		{
			++aCnt;
			if (i < a)++waku;
		}

	double ave = 0;
	rep(i, 0, a - 1)ave += v[i];
	ave /= a;
	printf("%.6f\n", ave);
	if (v[0] == ave)
	{
		int x = min(aCnt, b);
		ll ans = 0;
		rep(i, a, x)
		{
			ll tmp = 1;
			rep(j, 0, i - 1)
			{
				ll y = aCnt - j;
				ll z = 1 + j;
				tmp = tmp * y / z;
			}
			ans += tmp;
		}
		cout << ans << endl;
	}
	else
	{
		ll ans = 1;
		rep(i, 1, waku)
		{
			ll x = aCnt - i + 1;
			ll y = i;
			ans = ans * x / y;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>

using namespace std;

const int N = 1e5 + 500;

int A[N][3], n, P[N], swp[N], loga[N], br[N];

void add(int x){
	for(; x < N ; x += x & -x)
		loga[x]++;
}

int query(int x){
	int ret = 0;
	for(; x ; x -= x & -x)
		ret += loga[x];
	return ret;
}

int main(){
	scanf("%d", &n);
	for(int j = 0;j < 3;j++)
		for(int i = 0;i < n;i++)		
			scanf("%d", &A[i][j]);
	for(int i = 0;i < n;i++){
		if(A[i][0] == A[i][1] + 1 && A[i][0] == A[i][2] + 2 && A[i][0] % 3 == 0){
			P[i] = -(A[i][0] / 3);
		}
		else if(A[i][2] == A[i][1] + 1 && A[i][2] == A[i][0] + 2 && A[i][2] % 3 == 0){
			P[i] = (A[i][2] / 3);
		}
		else{
			printf("No\n");
			return 0;
		}
		if((P[i] - i - 1) % 2 != 0){
			printf("No\n");
			return 0;
		}
		if(P[i] < 0){
			br[-P[i]]++;
			P[i] = -P[i];
		}
	}
	for(int i = 0;i < n;i++){
		if(i % 2) continue;
		int kol = ((i + 1) / 2) + P[i] / 2 - 2 * query(P[i]);
		br[P[i]] += kol;	
		int pos = i + 2 * ((P[i] / 2) - query(P[i]));
		add(P[i]);
		swp[P[i] - 1]++;
		swp[pos]--;
		//printf("pos = %d zelim = %d i = %d\n", pos, P[i] - 1, i);
	}
	for(int i = 1;i < n;i++)
		swp[i] += swp[i - 1];
	for(int i = 1;i < n;i += 2){
		br[P[i]] += swp[i];
	}
	memset(swp, 0, sizeof(swp));
	memset(loga, 0, sizeof(loga));
	for(int i = 0;i < n;i++){
		if(!(i % 2)) continue;
		int kol = (i / 2) + (P[i] - 1) / 2 - 2 * query(P[i]);
		br[P[i]] += kol;	
		int pos = i + 2 * ((P[i] - 1) / 2  - query(P[i]));
		add(P[i]);
		swp[P[i] - 1]++;
		swp[pos]--;
		//printf("pos = %d zelim = %d i = %d\n", pos, P[i] - 1, i);
	}
	for(int i = 1;i < n;i++)
		swp[i] += swp[i - 1];
	for(int i = 0;i < n;i += 2){
		br[i + 1] += swp[i];
	}
	
	//for(int i = 1;i <= n;i++){
	//	if(br[i] & 1) printf("-");
	//	printf("%d ", i);
	//}
	//printf("\n");
	for(int i = 1;i <= n - 3;i++){
		if(br[i] % 2){
			br[i]++; br[i + 1]++;
			br[i + 2]++; br[i + 3]++;
		}
	}
	if(br[n - 2] % 2){
		br[n]++; br[n - 2]++;
	}
	for(int i = 1;i <= n;i++){
		if(br[i] % 2){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
	
}

Measured memory_bytes: 4392
from collections import defaultdict
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    md = 10 ** 9 + 7
    n = int(input())
    cc = [int(input()) for _ in range(n)]
    dp = [0] * (n + 1)
    dp[0] = 1
    ll = defaultdict(int)
    pc = -1
    for r, c in enumerate(cc):
        dp[r + 1] = dp[r]
        if c == pc: continue
        dp[r + 1] = (dp[r + 1] + ll[c]) % md
        ll[c] = (ll[c] + dp[r]) % md
        pc = c
    print(dp[n])

main()


Measured memory_bytes: 31336
/*input
1
*/
#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 int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

void solve(){
  	int n;
  	cin >> n;
  	int ans = 0;
  	int x = n;
  	for(int i = 2;i*i <= x;i++){
  		if(n%i == 0){
  			int cur = 0;
  			while(n%i == 0){
  				cur++;
  				n/= i;
  			}
  			int fir = 1;
  			int all = 0;
  			while(all+fir <= cur){
  				all += fir;
  				ans++;
  				fir++;
  			}
  		}
  	}
  	if(n > 1)ans++;
  	cout << ans;
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 3608
s = input()
s1 = (int)(s[0] + s[1])
s2 = (int)(s[2] + s[3])

def check(t):
  if t > 0 and t < 13:
    return True
  return False


if check(s1):
  if check(s2):
    print("AMBIGUOUS")
  else:
    print("MMYY")
elif check(s2):
  print("YYMM")
else:
  print("NA")

Measured memory_bytes: 3064
# abc108_a.py
# https://atcoder.jp/contests/abc108/tasks/abc108_a

# A - Pair /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 100点

# 問題文
# 1以上 K以下の正の整数から、偶数と奇数ひとつずつの組を選ぶ方法の個数を求めてください。なお、選ぶ順番は考慮しません。

# 制約
#     2≤K≤100
#     Kは整数である

# 入力
# 入力は以下の形式で標準入力から与えられる。
# K

# 出力
# 1以上 K以下の正の整数から、偶数と奇数ひとつずつの組を選ぶ方法の個数を出力せよ。

# 入力例 1
# 3

# 出力例 1
# 2

# (2,1)と (2,3)が条件を満たします。

# 入力例 2
# 6

# 出力例 2
# 9

# 入力例 3
# 11

# 出力例 3
# 30

# 入力例 4
# 50

# 出力例 4
# 625


def calculation(lines):
    # N, K = list(map(int, lines[0].split()))
    N = int(lines[0])
    if N%2 == 0:
        ans = (N/2)**2
    else:
        ans = ((N+1)/2 * (N-1)/2)
    return [int(ans)]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['3']
        lines_export = [2]
    if pattern == 2:
        lines_input = ['6']
        lines_export = [9]
    if pattern == 3:
        lines_input = ['11']
        lines_export = [30]
    if pattern == 4:
        lines_input = ['50']
        lines_export = [625]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9332
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<vector<pair<int, int>>> rds(n + 1);
    for(int i = 0; i < m; i++){
        int l, r, d;
        cin >> l >> r >> d;
        rds[l].emplace_back(r, d);
        rds[r].emplace_back(l, -d);
    }
    unordered_set<int> checked;
    bool ok = true;
    for(int i = 1; i <= n && ok; i++){
        printd(checked);
        if(checked.count(i)){ continue; }
        queue<int> q;
        q.push(i);
        unordered_map<int, int> poss;
        while(ok && q.size()){
            int idx = q.front(); q.pop();
            checked.insert(idx);
            for(auto& rd : rds[idx]){
                int pos = poss[idx];
                int i2 = rd.first;
                int p2 = pos + rd.second;
                if(!checked.count(i2)){
                    checked.insert(i2);
                    q.push(i2);
                }
                if(!poss.count(i2)){
                    poss[i2] = p2;
                }else{
                    if(poss[i2] != p2){
                        ok = false;
                    }
                }
            }
            printd(poss);
        }
    }
    cout << (ok ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 16876
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
int main() {
    string s,t;
    cin>>s>>t;
    if(t.substr(0,s.length())==s)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
}

Measured memory_bytes: 3624
#include<stdio.h>
#include <stdlib.h>

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

int main() {
  int N,d,S[200001];
scanf("%d",&N);
for(int c=0;c<N;c++){
scanf("%d",&S[c]);
}
qsort(S, N, sizeof(int), compare_int);

for(d=0;d<N;d++){
if(S[d] == S[d+1]){
printf("NO");
break;
}
}
if(d == N){
  printf("YES");
          }

return 0;
}


Measured memory_bytes: 1788
mod = 1000000007
s = input()
ans = [0,1,0,0,0]
for c in s:
    if c == "?":
        for i in range(4,0,-1):
            ans[i] *= 3
            ans[i] += ans[i-1]
            ans[i] %= mod
    else:
        i = "00ABC".index(c)
        ans[i] += ans[i-1]
        ans[i] %= mod
print(ans[-1])

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <cmath>
#include <iomanip>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

template <class T>
inline bool chmin(T& a, T b)
{
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T& a, T b)
{
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <typename T>
T GCD(T x, T y)
{
    return (y ? GCD<T>(y, x % y) : x);
}



int main() {

        int N;
        cin >> N;
        vector<int> a(N);
        rep(i, N) cin >> a.at(i);

        vector<int> left(N + 1, 0), right(N + 1, 0);
        // left[p]:= [0, p)の最大公約数
        // right[p]:= [p, N)の最大公約数
        for (int i = 0; i < N; i++) {
            left.at(i + 1) = GCD(left.at(i), a.at(i));
        }
        for (int i = N - 1; i >= 0; i--) {
            right.at(i) = GCD(right.at(i + 1), a.at(i));
        }

        int res = 0;
        for (int i = 0; i < N; i++) {
            int l = left[i];
            int r = right[i + 1];

            chmax(res, GCD(l, r));
        }
        cout << res << endl;



    return 0;
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main()
{
    int a, b, c;
    string s;
    
    //scanf("%d %d %d", &a, &b, &c);
    cin >> s;

    int zero = 0;
    int one = 0;

    for(int i = 0;i<(int)s.length();i++){
        if((int)(s[i] - '0')==0){
            zero++;
        }else{
            one++;
        }
    }



    if(zero>one){
        cout << 2*one;
    }else{
        cout << 2*zero;
    }


    
    

}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define cometh_the_hour_cometh_the_man ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(x); cout<<#x<<"="<<x<<endl;
#define debug2(x,y); cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define int long long
using namespace std;

long long power(long long x,long long n,long long mod){
//(x^n)%mod
long long result=1;

    while(n){
        if(n%2)
            result=(result*x)%mod;
        x=(x*x)%mod;
        n/=2;
    }
    return result;
}

const int mod=1e9+7;

int32_t main()
{
    cometh_the_hour_cometh_the_man

    int n,k;
    cin>>n>>k;
    std::vector<int > arr(k+1);
    for(int i=k;i>=1;i--){
        int noofelements=k/i;
        int temp=power(noofelements,n,mod);
        for(int j=2*i;j<=k;j+=i){
            temp=(temp+mod-arr[j]);
            temp%=mod;
        }
        arr[i]=temp;

    }

    int ans=0;
    for(int i=1;i<=k;i++){
        int add=(arr[i]*i);
        add%=mod;
        ans+=add;
        ans%=mod;
    }
    cout<<ans;




    return 0;

}

    

Measured memory_bytes: 3956
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            // 11:16-

            int n = sc.nextInt();
            int[] vs = new int[n];

            for (int i = 0; i < vs.length; i++) vs[i] = sc.nextInt();
            Arrays.sort(vs);

            out.println(vs[vs.length / 2] - vs[vs.length / 2 - 1]);
        }
    }
}


Measured memory_bytes: 50936