akhauriyash/Code-Regression huggingface dataset:
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
const double EPS = 1e-9;
#define INF (1LL<<60)
#define fs first
#define sc second
#define pb push_back
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);  
  //問題文を読む時間をケチらない！！
  //未定義動作に気を付ける！！
  //DPや二分探索の範囲に気をつける！！
  
  string s;
  cin >> s;
  
  stack<char> st;
  int ans = 0;
  REP(i,s.size()){
    if(st.size() == 0 || st.top() == s[i]) st.push(s[i]);
    else ans+= 2, st.pop();
    //debug(ans);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cmath>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;

int main(){
   string s;
   cin >> s;
   int c = 0;
   if(s[0] == '1')c++;
   if(s[1] == '1')c++;
   if(s[2] == '1')c++;

   cout << c << endl;
 
    return 0;  
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;


int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	if (A > B) swap(A, B);
	if (A <= C && C <= B) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3612
n, k = gets.chomp.split.map(&:to_i)
r, s, p = gets.chomp.split.map(&:to_i)
t = gets.chomp

point = 0

n.times do |i|
  if (i - k >= 0) && t[i] == t[i - k]
    t[i] = 'a'
    next
  end

  point += if t[i] == 'r'
             p
           elsif t[i] == 's'
             r
           else
             s
           end
end
puts point


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#include <string>
using namespace std;
int intinput() {
	int x;
	cin >> x;
	return x;
}
vector<int> forintinput(int n) {
	vector<int> x(100000);
	for(int i = 0;i < n;i++) cin >> x[i];
	return x;
}
int main(){
	char a;
	cin >> a;
	int cnt = 0;
	if(a == 'a'){
		cnt++;
	}
	if(a == 'b'){
		cnt++;
	}
	if(a == 'c'){
		cnt++;
	}
	if(a == 'd'){
		cnt++;
	}
	if(a == 'e'){
		cnt++;
	}
	if(a == 'f'){
		cnt++;
	}
	if(a == 'g'){
		cnt++;
	}
	if(a == 'h'){
		cnt++;
	}
	if(a == 'i'){
		cnt++;
	}
	if(a == 'j'){
		cnt++;
	}
	if(a == 'k'){
		cnt++;
	}
	if(a == 'l'){
		cnt++;
	}
	if(a == 'm'){
		cnt++;
	}
	if(a == 'n'){
		cnt++;
	}
	if(a == 'o'){
		cnt++;
	}
	if(a == 'p'){
		cnt++;
	}
	if(a == 'q'){
		cnt++;
	}
	if(a == 'r'){
		cnt++;
	}
	if(a == 's'){
		cnt++;
	}
	if(a == 't'){
		cnt++;
	}
	if(a == 'u'){
		cnt++;
	}
	if(a == 'v'){
		cnt++;
	}
	if(a == 'w'){
		cnt++;
	}
	if(a == 'x'){
		cnt++;
	}
	if(a == 'y'){
		cnt++;
	}
	if(a == 'z'){
		cnt++;
	}
	if(cnt == 0){
		cout << 'A' << endl;
	}else{
		cout << 'a' << endl;
	}
}

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

#define DEBUG(x) cerr << "L" << __LINE__ << " " << #x << " = " << x << endl

const int MAX_N = 300000;

const int INF = 1e9;
const int sqrtN = 550;

int data[(MAX_N + sqrtN - 1) / sqrtN * sqrtN];
int add[(MAX_N + sqrtN - 1) / sqrtN];
int min1[(MAX_N + sqrtN - 1) / sqrtN];

struct SegmentArray {
  const int B;
  SegmentArray(int n) : B((n + sqrtN - 1) / sqrtN) { }
  void update(int a, int b, int v) {
    for(int k = 0; k < B; ++k) {
      int l = k * sqrtN, r = (k + 1) * sqrtN;
      if(r <= a || b <= l) continue;
      if(a <= l && r <= b) {
        add[k] += v;
        continue;
      }
      min1[k] = INF;
      int st = std::max(a, l), en = std::min(b, r);
      for(int i = k * sqrtN; i < (k + 1) * sqrtN; ++i) {
        if(st <= i && i < en) data[i] += v;
        if(min1[k] > data[i]) min1[k] = data[i];
      }
    }
  }
  int search(int p) {
    int a = 0;
    int b = p + 1;
    for(int k = B - 1; k >= 0; k--) {
      int l = k * sqrtN, r = (k + 1) * sqrtN;
      if(r <= a || b <= l) continue;
      if(a <= l && r <= b) {
        if(add[k] + min1[k] < 2) {
          for(int j = sqrtN - 1; j >= 0; --j) {
            if(add[k] + data[k * sqrtN + j] < 2) {
              return k * sqrtN + j + 1;
            }
          }
        }
      }
      else {
        int st = std::max(a, l), en = std::min(b, r);
        for(int i = en - 1; i >= st; --i) {
          if(add[k] + data[i] < 2) {
            return i + 1;
          }
        }
      }
    }
  }
};

char S[300001];

int main() {
  int N, Q; scanf("%d%d", &N, &Q);
  scanf("%s", S);
  SegmentArray seg1(N);
  set<int> seg2;
  for(int i = 0; i < N; ++i) { 
    seg1.update(i, N, (S[i] == '(' ? 1 : -1));
    if(S[i] == ')') seg2.insert(i);
  }
  for(int q = 0; q < Q; ++q) {
    int p; scanf("%d", &p);
    --p;
    if(S[p] == '(') {
      S[p] = ')';
      seg2.insert(p);
      seg1.update(p, N, -2);
      int np = *seg2.begin();
      S[np] = '(';
      seg2.erase(np);
      seg1.update(np, N, +2);
      printf("%d\n", np + 1);
    }
    else {
      S[p] = '(';
      seg2.erase(p);
      seg1.update(p, N, +2);
      int np = seg1.search(p);
      S[np] = ')';
      seg2.insert(np);
      seg1.update(np, N, -2);
      printf("%d\n", np + 1);
    }
  }
}

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

using namespace std;

#define PB push_back
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;

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

vector<pii> arr[3000000];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    int dif = 0;
    int dif2 = 0;
    for(int i=0; i<n; i++)
    {
        string s;
        cin >> s;
        deque<char> d;
        for(int j=0; j<s.size(); j++)
        {
            if(!d.empty() && s[j] == ')' && d.back() == '(')
                d.pop_back();
            else
                d.push_back(s[j]);
        }
        if(!d.empty() && d[0] == '(')
            dif += d.size();
        else
        {
            int dsc = 0;
            int cl = 0;
            for(int j=0; j<d.size(); j++)
            {
                if(d[j] == '(')
                    dsc++;
                else
                    cl++;
            }
            if(!dsc)
                dif2 += cl;
            else
            {
                arr[1000000 + dsc - cl].PB({cl, dsc});
            }
        }
    }
    multiset<pii> prd;
    for(int i=1000001; i<=2000000; ++i)
    {
        for(auto pr: arr[i])
        {
            prd.insert(pr);
        }
    }
    while(!prd.empty())
    {
        pii xx = *prd.begin();
        if(dif >= xx.f)
        {
            dif = dif - xx.f + xx.s;
            prd.erase(prd.lower_bound(xx));
        }
        else
        {
            cout << "No";
            return 0;
        }
    }
    for(int i=1000000; i>=0; i--)
    {
        for(auto pr: arr[i])
        {
            if(dif < pr.f)
            {
                cout << "No";
                return 0;
            }
            dif = dif - pr.f + pr.s;
        }
    }
    dif -= dif2;
    if(dif == 0)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 75644
#include<bits/stdc++.h>
using namespace std;
int main(){
	int Max = 0,gcd = 0;
	int n,k;
	scanf("%d%d",&n,&k);
	while (n--){
		int x;
		scanf("%d",&x);
		Max = max(Max,x);
		gcd = __gcd(gcd,x);
	}
	puts(k<=Max && (k % gcd == 0)?"POSSIBLE":"IMPOSSIBLE"); 
	return 0;
}

Measured memory_bytes: 256
from itertools import product


def solve(string):
    n, s = string.split()
    r, g, b = [], [], []
    r2, g2, b2 = set([]), set([]), set([])
    for i, _s in enumerate(s):
        if _s == "R":
            r.append(i)
            r2.add(2 * i)
        if _s == "G":
            g.append(i)
            g2.add(2 * i)
        if _s == "B":
            b.append(i)
            b2.add(2 * i)
    ans = len(r) * len(g) * len(b)
    for i, j in product(r, g):
        ans -= 1 if i + j in b2 else 0
    for i, j in product(g, b):
        ans -= 1 if i + j in r2 else 0
    for i, j in product(b, r):
        ans -= 1 if i + j in g2 else 0
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


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

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

  long long ans = 0;
  int mod = 1000000007;

  vector<long long> b(n,0);
  b[n-1] = a[n-1];
  for (int i = n-2; i >= 0; i--) {
    b[i] = a[i] + b[i+1];
    b[i] %= mod;
  }

  for (int i = 0; i < n-1; i++) {
    ans += a[i] * b[i+1];
    ans %= mod;
  }

  cout << ans << endl;
}

Measured memory_bytes: 6420
#include <iostream>

using namespace std;

int main(){
  int n,x,i,j,N,m;
  while (1) {
    N=0;
    cin >> n >> x;
    if (n+x==0) break;
    for (i=1;i<=n-2;i++) {
      if (i>x/3 -1) break;
      for (j=i+1;j<=n-1;j++) {
        if ((i+j+j+1)>x) break;
        m=x-i-j;
        if (m>0 && m<=n && m!=i && m!=j) N+=1;
      }
    }
    cout << N <<endl;
  }
  return 0;
}



Measured memory_bytes: 3084
/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define rall(x) x.rbegin() , x.rend()
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
using ll = long long;
using ii = pair <int , int>;
void in(int &x);
// const int N = ;
#define singleCase
// #define multipleCase
int a,b;

void work() {
   in(a); in(b);
   if (b < 0) {
      puts((b - a + 1) & 1 ? "Negative" : "Positive");
   } else if (a > 0) {
      puts("Positive");
   } else {
      puts("Zero");
   }
   return;
}

int main() {
   #ifdef multipleCase
      int nQ; in(nQ);
      while (nQ--)
         work();
   #endif
   #ifdef singleCase
      work();
   #endif
   return 0;
}

void in(int &x) {
	bool neg = false;
	register int c;
	x = 0;
	c = getchar();
	if(c == '-') {
		neg = true;
		c = getchar();
	}
	for (; c > 47 && c < 58; c = getchar())
	  x = (x << 1) + (x << 3) + c - 48;
	if (neg) x *= -1;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define TR(X) ({ if(1) cerr << "Trace: " << (#X) << " = " << (X) << endl; })

int const P = 1e9 + 7;
const int N = 3001;
int dp[N][N], prfx[N][N];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; string s;
	cin >> n >> s;
	dp[1][1] = 1;
	for(ll k = 2; k <= n; k++) {
		for(ll i = 1; i <= k - 1; i++) prfx[k - 1][i] = (prfx[k - 1][i - 1] + dp[k - 1][i]) % P;
		for(ll lst = 1; lst <= k; lst++) {
			if(s[k - 2] == '<') (dp[k][lst] += prfx[k - 1][lst - 1]) %= P;
			else (dp[k][lst] += prfx[k - 1][k - 1] - prfx[k - 1][lst - 1] + P) %= P;
		}
	}
	int ans = 0;
	for(int lst = 1; lst <= n; lst++) (ans += dp[n][lst]) %= P;
	cout << ans << '\n';
}


Measured memory_bytes: 69376
import math

def prime_division(n):
    ans = []
    m = int(n ** 0.5)
    i = 2
    while i <= m:
        if n % i == 0:
            cnt = 0
            while n % i == 0:
                n //= i
                cnt += 1
            ans.append((i, cnt))
            m = int(n ** 0.5)
        i += 1
    if n != 1:
        ans.append((n, 1))
    return ans

def combination(n, r):
    ans = 1
    if n - r < r:
        r = n - r
    for i in range(r):
        ans *= n - i
    ans //= math.factorial(r)
    return ans

#  aabaaba  count+(N-1) C (N-1)

N,M=map(int,input().split())
pms=prime_division(M)
ans = 1
for pm in pms:
    #print(pm)
    ans *= combination(pm[1]+(N-1), N-1)

print(ans % (10 ** 9 + 7))


Measured memory_bytes: 3064
N=int(input())
p=list(map(int,input().split()))

ans=0
for i in range(N):
    if p[i]==i+1:
        if i==N-1:
            c=p[i]
            p[i]=p[i-1]
            p[i-1]=c
        else:
            c=p[i]
            p[i]=p[i+1]
            p[i+1]=c
        ans+=1

print(ans)

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

using namespace std;

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

	int sum = 0;
	int x;

	cin >> x;

	for(int i=1; ;i++)
	{
		sum += i;
		if(sum >= x)
		{
			cout << i << '\n';
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
int n,m,i,sum,p,x;
int a[100+5];

int main()
{
    cin>>n;
    for(i=1; i<=n; i++)
        cin>>a[i],sum+=a[i];
    cin>>m;
    for(i=1; i<=m; i++)
        cin>>p>>x,cout<<sum-a[p]+x<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <queue>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
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 N;
void f(ll cur, int use, ll &cnt) {
    if (cur > N) return;
    if (use == 0b111) ++cnt;

    f(cur * 10 + 7, use|0b001, cnt);
    f(cur * 10 + 5, use|0b010, cnt);
    f(cur * 10 + 3, use|0b100, cnt);
}

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

    cin >> N;
    ll res = 0;
    f(0, 0, res);
    cout << res << '\n';

    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int N;
    int flag=0;
    scanf("%d", &N);
    if(N%2==0)
    {
    char str[N];
    scanf("%s", str);
    for(int b=0; b<(N/2) ;b++)
    {
        if(str[b]!=str[(N/2)+b])
        flag=1;
      }
    if(flag==1)
        printf("No");
    else
    printf("Yes");
    }
    else
     printf("No");
    return 0;
    
}

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

namespace _0030
{
    class Gyo
    {
        internal int dot;
        internal int sharp;

        public Gyo()
        {
            this.dot = 0;
            this.sharp = 0;
        }
    }

    class Program
    {

        
        static void Main(string[] args)
        {

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

            int n = int.Parse(str[0]);
            int m = int.Parse(str[1]);

            char[,] data = new char[n, m];

            var delete_i =new List<int>();  //取り除く行
            var delete_j =new List<int>();  //取り除く列
            var gyo_delete_j = new Gyo[m];  //各列が削除対処かどうかの判断

            //gyo_delete_jのインスタンスを作成
            for(int j = 0; j < m; j++)
            {
                gyo_delete_j[j] = new Gyo();
            }

            int count_dot = 0;
            
            string strer;

            //i行j列
            for(int i = 0; i < n; i++)
            {
                strer = Console.ReadLine();
                count_dot = 0;
                
                for(int j = 0; j < m; j++)
                {
                    data[i, j] = strer[j];

                    //ドットとシャープをカウント
                    //ドットとシャープがあったら1で存在を証明
                    if(strer[j] == '.')
                    {
                        count_dot++;
                        gyo_delete_j[j].dot = 1;
                    }
                    else
                    {                      
                        gyo_delete_j[j].sharp = 1;
                    }

                    //取り除く行
                    //m個ならんでたら取り除く
                    if(count_dot == m)
                    {                      
                        delete_i.Add(i);
                    }
                    
                }        
            }

            //削除する列の発見
            for(int j = 0; j < m; j++)
            {
                //どっちも1（存在している）だったら削除しない
                if(gyo_delete_j[j].dot == 1 && gyo_delete_j[j].sharp == 0)
                {
                    delete_j.Add(j);
                }
                
            }

            //Console.WriteLine();           

            //削除する行と列以外を表示
            for(int i = 0; i < n; i++)
            {
                if (delete_i.Contains(i))
                {
                    continue;
                }
                for(int j = 0; j < m; j++)
                {
                    if (delete_j.Contains(j))
                    {
                        continue;
                    }
                    Console.Write(data[i, j]);
                }
                Console.WriteLine();
            }

        }
    }
}

Measured memory_bytes: 11192
D, G = map(int, input().split())
problems = []
for i in range(0, D):
	problems.append(list(map(int, input().split())))
min = 5000000000000000
for i in range(0, 2**D):
	cnt = 0
	sum = 0
	m = i
	notyet = []
	for j in range(0, D):
		if m % 2 == 1:
			cnt += problems[j][0]
			sum += (j+1)*100*problems[j][0]+problems[j][1]
		else:
			notyet.append(j)
		m //= 2
	if sum >= G:
		if cnt < min:
			min = cnt
	else:
		notyet.sort(reverse = True)
		flag = False
		for j in range(0, len(notyet)):
			for k in range(1, problems[notyet[j]][0]):
				cnt += 1
				sum += (notyet[j]+1) * 100
				if sum >= G:
					if cnt < min:
						min = cnt
					flag = True
					break
			if flag:
				break
print(min)

Measured memory_bytes: 41840
#include <iostream>
#include<algorithm>
using namespace std;
int main()
{
    int A,B,sum,diff,mult;
    cin>>A >> B;
    sum=A+B;
    diff=A-B;
    mult=A*B;
    if(sum>mult and sum>diff)
        cout<< sum;
    else if (mult>sum and mult>diff)
        cout<< mult;
    else
        cout<< diff;

}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long
#define PINT pair<int,int>
#define f1 first
#define s2 second
const int INF = 1e9 + 7;

using namespace std;

int main(){
    cin.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n],b[n];
    REP(i,n) cin >> a[i];
    REP(i,n) cin >> b[i];

    ll bit[29];
    REP(i,29) bit[i]=0;
    for(int i=29;i>0;--i){
        REP(j,n) a[j] = a[j]%(1<<i);
        REP(j,n) b[j] = b[j]%(1<<i);
        sort(b,b+n);

        REP(j,n){
            bit[i-1] += lower_bound(b,b+n,(1<<i)-a[j])-lower_bound(b,b+n,(1<<(i-1))-a[j]);
            bit[i-1] += lower_bound(b,b+n,(2<<i)-a[j])-lower_bound(b,b+n,(3<<(i-1))-a[j]);
        }
    }

    int ans=0;
    REP(i,29){
        if(bit[i]%2==0) continue;
        else ans += (1<<i);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n; cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	int ans = 0, ans2 = 0;
	for (int i = 0; i < n-1; i++) {
		if (h[i] >= h[i + 1]) {
			ans++;
		}
		else {
			ans2 = max(ans, ans2);
			ans = 0;
		}
	}
	ans2 = max(ans, ans2);
	cout << ans2 << endl;
	return 0;
}

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

public class Main {

  private static void solve() {
    int n = nextInt();
    int[] h = new int[n];

    for (int i = 0; i < n; i++) {
      h[i] = nextInt();
    }

    int[] dp = new int[n];

    Arrays.fill(dp, Integer.MAX_VALUE);
    dp[0] = 0;
    for (int i = 0; i < n - 1; i++) {
      if (i + 1 < n) {
        dp[i + 1] = Math.min(dp[i + 1], dp[i] + Math.abs(h[i + 1] - h[i]));
      }

      if (i + 2 < n) {
        dp[i + 2] = Math.min(dp[i + 2], dp[i] + Math.abs(h[i + 2] - h[i]));
      }
    }

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

  private static void run() {
    br = new BufferedReader(new InputStreamReader(System.in));
    out = new PrintWriter(System.out);

    solve();

    out.close();
  }

  private static StringTokenizer st;
  private static BufferedReader br;
  private static PrintWriter out;

  private static String next() {
    while (st == null || !st.hasMoreElements()) {
      String s;
      try {
        s = br.readLine();
      } catch (IOException e) {
        return null;
      }
      st = new StringTokenizer(s);
    }
    return st.nextToken();
  }

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

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

  public static void main(String[] args) {
    run();
  }
}


Measured memory_bytes: 30856
/**
*    created: 20.06.2020 13:34:47
**/
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;
    int mn = 1000;
    rep(i,s.size()-2) {
        mn = min((int)(abs(stoi(s.substr(i,3))-753)), mn);
    }
    cout << mn << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<math.h>
void convertToAlpha(long long int num);
int main()
{
    long long int i = 0;
    scanf("%lld",&i);
    convertToAlpha(i);
}

void convertToAlpha(long long int num)
{
    long long int q = num;
    long long int r = 0;
    if (num < 1)
        return;
    r = q % 26;
    q = q / 26;
    if (r == 0)
    {
        q = q - 1;
        r = 26;
    }
    if (q == 0)
        printf("%c", (char) (r + 'a' - 1));
    else
    {
        convertToAlpha(q);
        printf("%c", (char) (r + 'a' - 1));
    }
    return;
}

Measured memory_bytes: 1660
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int A[200010], B[200010];
ll sumA[200010], sumB[200010];
int main()
{
	int N, M, K;
	cin >> N >> M >> K;
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < M; i++) cin >> B[i];
	for (int i = 0; i < N; i++) sumA[i + 1] = sumA[i] + A[i];
	for (int i = 0; i < M; i++) sumB[i + 1] = sumB[i] + B[i];
	int ans = 0;
	for (int i = 0; i <= N; i++) {
		ll sum = sumA[i];
		int ok = 0;
		int ng = M + 1;
		while (abs(ok - ng) > 1) {
			int mid = (ok + ng) / 2;
			if (sum + sumB[mid] <= K) ok = mid;
			else ng = mid;
		}
		if (sum <= K) ans = max(ans, i + ok);
	}
	cout << ans << endl;
}

Measured memory_bytes: 8332
long long D[3060],*d=D;n,v,j;main(i){for(;~scanf("%d",n?&v:&n);--i+n||printf("%lld\n",d[v]),d+=30)for(j=21;j--;)d[30+j]=i|j-v?d[j-v]+d[j+v]:1;}

Measured memory_bytes: 0
import java.io.*;
import java.util.*;
//import java.util.Map.Entry;
//import java.util.stream.*;
//import java.math.*;

public class Main {

    public static int gcd(int a, int b) {
        return (b == 0) ? a : gcd(b, a % b);
    }

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

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        Scanner sc = new Scanner(System.in);
        int a[] = new int[26];
        char array[] = br.readLine().toCharArray();
        boolean b = true;
        for (int i = 0; i < array.length; i++) {
            a[array[i] - 97]++;
        }
        for (int i = 0; i < 26; i++) {
            if (a[i] > 1) {
                b = false;
                break;
            }
        }
        System.out.println(b ? "yes" : "no");
        bw.flush();
    }
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//

    static class Pair implements Comparable<Pair> {

        int a, b;

        public Pair(int x, int y) {
            a = x;
            b = y;
        }

        @Override
        public int compareTo(Pair p) {
            return a - p.a;
        }
    }

    static void forl_0(int n, int[] array, Scanner sc) {
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
    }

    static void forl_1(int n, int[] array, Scanner sc) {
        for (int i = 1; i <= n; i++) {
            array[i] = sc.nextInt();
        }
    }

    static void two_d(int n, int m, int[][] array, Scanner sc) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                array[i][j] = sc.nextInt();
            }
        }
    }

    static boolean isPrime(long n) {
        if (n < 2) {
            return false;
        } else if (n == 2 || n == 3) {
            return true;
        } else if (n % 2 == 0 || n % 3 == 0) {
            return false;
        }
        long sqrtN = (long) Math.sqrt(n) + 1;
        for (long i = 6L; i <= sqrtN; i += 6) {
            if (n % (i - 1) == 0 || n % (i + 1) == 0) {
                return false;
            }
        }
        return true;
    }
}


Measured memory_bytes: 27012
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.util.InputMismatchException;
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;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int t = in.nextInt();

            int min = Integer.MAX_VALUE;
            for (int i = 0; i < n; i++) {
                int c = in.nextInt();
                int time = in.nextInt();

                if (time <= t) min = Math.min(min, c);
            }

            out.println(min == Integer.MAX_VALUE ? "TLE" : min);
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int i=100;
	for(;i>0&&c>0;--i){
		if(a%i==0&&b%i==0){
			c--;
		}
	}
	cout<<i+1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long;
using ll = long long;
#define rep(i,n) for(lint (i) = 0;(i) < (lint)(n);(i)++)
#define repInRange(i,start,end) for(lint (i) = (start);(i) < (end);++(i))
using lpair = pair<lint,lint>;
using vl = vector<lint>;
using vll = vector<long long>;
using Llist = list<lint>;
using vs = vector<string>;
#define all(v) (v).begin(),(v).end()
#define out1(x) cout << (x) << '\n';

ll pow(ll k,ll l) {
	ll ret = 1;
	rep(i,l) {
		ret *= k;
	}
	return ret;
}


void Main() {
	int K,A,B;
	cin >> K >> A >> B;
	repInRange(i,A,B+1) {
		if (i % K == 0) {
			out1("OK");
			return;
		}
	}
	out1("NG");
}

signed main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	Main();
	return 0;
}


Measured memory_bytes: 3648
def read_list(t): return [t(x) for x in input().split()]
def read_line(t): return t(input())
def read_lines(t, N): return [t(input()) for _ in range(N)]

def rec(state, v):
    if dp[state][v] >= 0:
        return dp[state][v]
    if (1 << V) - 1 == state and v == 0:
        dp[state][0] = 0
        return 0

    try:
        dp[state][v] = min(INF, min(rec(state | 1 << to, to) + cost for to, cost in edge[v] if not (state >> to & 1)))
    except:
        dp[state][v] = INF
    return dp[state][v]

INF = 1<<27
V, E = read_list(int)
edge = [[] for _ in range(V)]
for _ in range(E):
    fr, to, cost = map(int, input().split())
    edge[fr].append((to, cost))

dp = [[-1] * V for _ in range(1<<V)]
print(dp[0][0] if rec(0, 0) != INF else -1)

Measured memory_bytes: 17036
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <utility>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
using LLI = long long int;

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

const int N_MAX = 100 + 1;
const int SUM_V_MAX = 100 * 1000 + 1;
const LLI INF = 1e16;

int main(int argc, char *argv[])
{
    int N, W;
    cin >> N >> W;
    vector<LLI> w(N_MAX, INF);
    vector<int> v(N_MAX, 0);
    Rep(i, N) {
        cin >> w[i+1] >> v[i+1];
    }
    // dp[k][p]: 1,...,k番目の品物で価値Pにするときの最小の重さ
    vector<vector<LLI>> dp(N_MAX, vector<LLI>(SUM_V_MAX, INF));

    // 初期値
    dp[0][0] = 0;
    for (int j=1; j<N_MAX; j++) {
        dp[0][j] = INF;
    }

    // 順に計算
    for (int i=1; i<N_MAX; i++) {
        Rep(p, SUM_V_MAX) {
            if (p < v[i]) {
                dp[i][p] = dp[i-1][p];
            } else {
                dp[i][p] = min(dp[i-1][p], dp[i-1][p-v[i]] + w[i]);
            }
        }
    }

    // Wを超えない最大の位置を求める
    int max_p = 0;
    Rep(i, N_MAX) {
        for (int p=max_p; p<SUM_V_MAX; p++) {
            if (dp[i][p] <= W) {
                max_p = p;
            }
        }
    }

    cout << max_p << endl;

    return 0;
}

Measured memory_bytes: 80256
#include <stdio.h>

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

    int d;
    int flag[N];

    int i, j, a;

    for(i = 0; i < N; i++) {
        flag[i] = 0;
    }


    for(i = 0; i < K; i++) {
        scanf("%d", &d);

        for(j = 0; j < d; j++) {
            scanf("%d", &a);
            flag[a - 1] = 1;
        }
    }

    int ans = 0;
    for(i = 0; i < N; i++) {
        if(flag[i] != 1) {
            ans += 1;
        }
    }

    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 1728
using System;
class Program
{
	static void Main(string[] args)
	{
		int ct = int.Parse(Console.ReadLine());
		string[] input = Console.ReadLine().Split(' ');
		int[] v = new int [ct];
		int count = 0;
		for (var i = 0; i < ct; i++)
		{
			v[i] = int.Parse(input[i]);
		}
		for (var i = 1; i < ct-1; i++)
		{
			if (v[i] <= v[i-1])
			{
				if (v[i] > v[i+1])
				{
					count++;
				}
			}
			else
			{
				if (v[i] <= v[i+1])
				{
					count++;
				}
			}
		}
		Console.WriteLine(count);
	}
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef pair<int,int> P;
map<P,int> mp,mpc;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	int N;
	cin>>N;
	rep(i,N){
		int x,y,w;
		cin>>x>>y>>w;
		mp[P(x,y)]=w;
	}
	int ans=0;
	mpc=mp;
	for(auto pp:mpc){
		P p=pp.fs;
		int x=p.fs,y=p.sc;
		rep(i,4){
			int tmp=mp[P(x,y)]
			+mp[P(x+dx[i],y+dy[i])]
			+mp[P(x+dx[(i+1)%4],y+dy[(i+1)%4])]
			+mp[P(x+dx[i]+dx[(i+1)%4],y+dy[i]+dy[(i+1)%4])];
			chmax(ans,tmp);
		}
	}
	cout<<ans<<" / 1\n";
}

Measured memory_bytes: 63696
#include <iostream>
#include <algorithm>
#include <string>
#include <bits/stdc++.h>

using namespace std;

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

  int N = min(s.size(), t.size());
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());
  // cout << s << endl << t << endl;
  bool can = true;
  for (int i = 0; i < N; i++){
    if (s.at(i) > t.at(i)){
      can = false;
      break;
    }else if (s.at(i) < t.at(i)){
      can = true;
      break;
    }else if (i >= t.size()-1){
      can = false;
      break;
    }
  }
  if (can)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(long long i = 0; i<n; i++)
typedef long long ll;
using namespace std;

int main() {
  ll n,a,b;
  bool flag1=false,flag2=false;
  cin >> n;
  vector<ll> v(n,0);
  r(i,n)cin >> v[i];
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  r(i,n-1){
    if(!flag1){
      if(v[i]==v[i+1]){
        a=v[i]; flag1=true; i++;
      }
    }
      else if(flag2!=true&&v[i]==v[i+1]){
        b=v[i]; flag2=true;
      }
  }
  if(flag1&&flag2)cout << a*b<<endl;
  else cout << 0<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#pragma 03
using namespace std;
int main(){  
	int a, b;
	cin >> a >> b;
	if (a > 9 || b > 9) cout << -1;
	else cout << a * b << endl;
    return 0; 
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,b;
  list<int>a;
  cin>>n;
  string s;
  while(n--){
    cin>>s;
    if(s.size()<=6){
      cin>>b;
      if(s[0]=='i')a.push_front(b);
      else{
        list<int>::iterator it=a.begin();
        while(it!=a.end()){
          if(*it==b){a.erase(it);break;}
          it++;
        }
      }
    }
    else{
      if(s[6]=='F')a.pop_front();
      else a.pop_back();
    }
  }
  list<int>::iterator it=a.begin();
  for(int i=0;it!=a.end();it++,i++){
    if(i)cout<<' ';
    cout<<(*it);
  }
  cout<<endl;
}



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

int n, ans;

int main() {
  cin >> n;
  vector<int> l(n);
  rep (i, n) {
    cin >> l[i];
  }
  ans = 0;
  for (int i = 0; i < n ;i++) {
    for (int j = i+1; j < n; j++){
      for (int k = j+1; k < n; k++) {
        if (l[i] != l[j] && l[j] != l[k] && l[k] != l[i]) {
          if (abs(l[i]-l[j]) < l[k] && l[k] < l[i]+l[j]) ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    ll n, m;
    cin >> n >> m;
    ll sum = 0;
    rep(i, m){ ll tmp; cin >> tmp; sum+=tmp;}

    if (sum > n){
        cout << "-1" << endl;
    } else {
        cout << n-sum << endl;
    }

}



Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
using namespace std;

const int MAXS = 300000;
char str[MAXS];

int main() {
    scanf("%s", str);

    int N = strlen(str);
    const int MOD = 2019;

    int mul = 1;
    int prefixSum = 0;
    long long ans = 0;
    unordered_map <int, int> remainMap;

    for (int i = N-1; i >= 0; --i) {
        prefixSum += (str[i]-'0') * mul;
        prefixSum %= MOD;

        if (prefixSum == 0) {
            ++ans;
        }

        // int target = prefixSum;
        ans += remainMap[prefixSum];
        ++remainMap[prefixSum];

        mul *= 10;
        mul %= MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3908
mod reader {
    use std::fmt::Debug;
    use std::str::FromStr;
    use std::collections::VecDeque;
    use std::io::{self, Read};

    fn _read_line() -> String {
        let mut buf = String::new();
        let _ = io::stdin().read_to_string(&mut buf);
        buf
    }

    fn _read_vec_deque_string() -> VecDeque<String> {
        _read_line()
            .split_whitespace()
            .map(|s| s.to_string())
            .collect()
    }

    pub struct Reader {
        buf: VecDeque<String>,
    }

    #[allow(dead_code)]
    impl Reader {
        pub fn new() -> Reader {
            Reader { buf: VecDeque::new() }
        }

        fn update_buf(&mut self) {
            if self.buf.is_empty() {
                self.buf = _read_vec_deque_string();
            }
        }

        pub fn next<T>(&mut self) -> T
        where
            T: FromStr,
            T::Err: Debug,
        {
            self.update_buf();
            self.buf.pop_front().unwrap().parse::<T>().unwrap()
        }

        pub fn next_n<T>(&mut self, n: usize) -> Vec<T>
        where
            T: FromStr,
            T::Err: Debug,
        {
            let mut vec: Vec<T> = Vec::with_capacity(n);

            for _ in 0..n {
                vec.push(self.next());
            }
            vec
        }
    }
}

fn main() {
    let mut reader = reader::Reader::new();

    let n: usize = reader.next();
    let m: usize = reader.next();
    let mut a: Vec<usize> = reader.next_n(n);
    for i in 0..n {
        a[i] -= 1;
    }

    let mut cnt: Vec<i64> = vec![0; 4 * m];
    let mut sum: Vec<i64> = vec![0; 4 * m];
    let mut t: i64 = 0;
    for i in 0..n - 1 {
        t += ((m + a[i + 1] - a[i]) % m) as i64;
        if (a[i] < a[i + 1] && a[i] + 2 > a[i + 1]) ||
            (a[i] > a[i + 1] && a[i] + 2 > a[i + 1] + m)
        {
            continue;
        }
        for j in 0..3 {
            if a[i] < a[i + 1] {
                cnt[a[i] + 2 + m * j] += 1;
                cnt[a[i + 1] + 1 + m * j] -= 1;
                sum[a[i + 1] + 1 + m * j] -= (a[i + 1] - a[i] - 1) as i64;
            } else if j > 0 {
                cnt[a[i] + 2 + m * (j - 1)] += 1;
                cnt[a[i + 1] + 1 + m * j] -= 1;
                sum[a[i + 1] + 1 + m * j] -= (a[i + 1] + m - a[i] - 1) as i64;
            }
        }
    }

    let mut c = 0;
    let mut max = 0;
    for i in 1..m * 3 {
        // println!("i={}, cnt={}, sum={}", i, cnt[i], sum[i]);

        c += cnt[i];
        c = std::cmp::max(0, c);
        sum[i] += sum[i - 1] + c;
        max = std::cmp::max(max, sum[i]);
    }
    let ans = t - max;
    println!("{}", ans);
}

Measured memory_bytes: 16792
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <string>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define endl '\n'
const int INF = (1 << 30);
using namespace std;
typedef long long int ll;

void solve(){
    int n, t, a;
    ll ans=0, p1=1, p2=1;
    cin >> n;
    REP(i,n){
        cin >> t >> a;
        ll x = max((p2-1)/a+1, (p1-1)/t+1);
        p1 = t*x;
        p2 = a*x;
    }
    cout << p1 + p2 << endl;
}

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

}


Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

s = ns()
x,y = li()

command = s.split("T")

ud = set()
lr = set()

lr.add(len(command[0]))
ud.add(0)

for i, cm in enumerate(command[1:]):
    if i%2 == 1:
        new_lr = set()
        for element in lr:
            new_lr.add(element + len(cm))
            new_lr.add(element - len(cm))
            
        lr = new_lr
        
    else:
        new_ud = set()
        for element in ud:
            new_ud.add(element + len(cm))
            new_ud.add(element - len(cm))
            
        ud = new_ud

if (x in lr) and (y in ud):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 51676
#include<bits/stdc++.h>
using namespace std;
int main()
  {
  //while(1){//
  int n; cin>>n; int p; map<int,int> mp;
  vector<int> vec,sec;
  for(int i=0;i<n;i++) {cin>>p; mp[p]++;}
  for(auto x:mp) {vec.push_back(x.first); sec.push_back(x.second);}
  if (n%3==0) {
    if (vec.size()==3){ 
        if (((((vec[0]^vec[1])==vec[2]) && (sec[0]==sec[1])) && (sec[1]==sec[2]))) cout<<"Yes"; else cout<<"No";
      }
      else if (vec.size()==2) {
         if((vec[0]==0) && (sec[1]==2*sec[0])) cout<<"Yes"; else cout<<"No";
        }
        else if (vec.size()==1) {
          if(vec[0]==0) cout<<"Yes"; else cout<<"No";
          }
          else cout<<"No";
  }
  else {
     if(((vec.size()==1) && (vec[0]==0))) cout<<"Yes"; else cout<<"No";
  }
  //cout<<endl;}//
  return 0;
  }



Measured memory_bytes: 4860
#include <iostream>
#include <set>
#include <vector>
#include <numeric>
#include <cassert>

using namespace std;

#define forsn(i,s,n) for(int i = (s);i < (int)(n);i++)
#define forn(i,n) forsn(i,0,n)


int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n; cin >> n;
	
	if (n < 6) {
		if (n == 3) {
			cout << "2 5 63\n";
		} else if (n == 4) {
			cout << "2 5 20 63\n";
		} else if (n == 5) {
			cout << "3 4 5 6 12\n";
		}
	} else {
		int base = 0;
		while (n) {
			assert(n != 4);
			assert(n != 5);
			assert(base % 6 == 0);
			if (base > 0) cout << " ";
			if (n == 1) {
				cout << base + 6;
				n -= 1;
			} else if (n == 2) {
				cout << base + 6 << ' ' << base + 6 + 6;
				n -= 2;
			} else if (n == 3) {
				cout << base + 2 << ' ' << base + 4 << ' ' << base + 6;
				n -= 3;
			} else if (n == 6 || n == 12 || n == 13) {
				cout << base + 2 << ' ' << base + 3 << ' ' << base + 4 << ' '
					<< base + 2 + 6 << ' ' << base + 3 + 6 << ' ' << base + 4 + 6;
				n -= 6;
			} else if (n == 7) {
				cout << base + 2 << ' ' << base + 3 << ' ' << base + 4 << ' ' << base + 6 << ' '
					<< base + 2 + 6 << ' ' << base + 3 + 6 << ' ' << base + 4 + 6;
				n -= 7;
			} else if (n >= 8) {
				cout << base + 2 << ' ' << base + 3 << ' ' << base + 4 << ' ' << base + 6 << ' '
					<< base + 2 + 6 << ' ' << base + 3 + 6 << ' ' << base + 4 + 6 << ' ' << base + 6 + 6;
				n -= 8;
			}
			base += 12;
		}
		cout << endl;
	}
	
	
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int d, n;
  cin >> d >> n;
  int ans;

  if (n != 100) {
    if (d == 0)
      ans = n;
    else if (d == 1)
      ans = 100 * n;
    else
      ans = 10000 * n;
  } else {
    if (d == 0)
      ans = 101;
    else if (d == 1)
      ans = 100 * 101;
    else
      ans = 10000 * 101;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()
 
#define REP(i,s,e)	for(ll i=(s); i<(e); i++)
#define rep(i,n)	REP(i,0,n)
#define REPE(i,s,e)	for(ll i=s; i>e; i--)
#define repe(i,n)	REPE(i,n,-1)
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<vi> vvi;
 
const int IMAX=((1<<30)-1)*2+1;
const int INF=100000000;
const double EPS=1e-10;
//int mod=1000000007


vector<string> split(const string &s, char c = ' '){
	vector<string> ret;
	stringstream ss(s);
	string t;
	while(getline(ss,t,c)){
		ret.pb(t);
	}
	return ret;
}



int main(){
	string s;
	while(getline(cin,s)){
		if(s == "END OF INPUT") break;
		vector<string> v = split(s);
		for(int i = 0; i < v.size(); i++) cout<<v[i].size();
		cout<<endl;
	}
}

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


int main() {
  int d, t, s;
  cin >> d >> t >> s;

  if (d <= t * s) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}
/*
*/


Measured memory_bytes: 3640
#include<iostream>
#include<cstring>
using namespace std;
int x[100][2], y[100][20], n, a, b, c, d, e, f, g, h, p;
int main() {
	while (true) {
		memset(x, 0, sizeof(x));
		memset(y, 0, sizeof(y));
		cin >> n >> a >> b >> c;
		if (n == 0) {
			break;
		}
		for (int i = 0; i < c; i++) {
			cin >> d >> e >> f >> g;
			if (g!=0) {
				y[e][f] += 20;
			}
			else {
				x[e][1] += d + y[e][f];
				x[e][0]++;
			}
		}
		p = 0;
		for (int i = b; i >= 0; i--) {
			for (int j = 0; j <= 100000; j++) {
				h = 0;
				for (int k = a; k > 0; k--) {
					if (x[k][0]==i && x[k][1]==j) {
						if (h >= 1) {
							cout << '=';
						}
						else if (p >= 1) {
							cout << ',';
						}
						cout << k;
						p++;
						h++;
					}
				}
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 1172