akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
    ll ans=1;
    for(int i=1; i<=n; i++)
        ans*=a;
    return ans;
}

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

    ll n;
    cin>>n;
    if(__gcd(n,(ll)10)>1)
    {
        cout<<-1<<endl;
        return 0;
    }
    ll num=7%n,ans=1;
    while(num!=0)
    {
        ans++;
        num*=10;
        num=num+7;
        num%=n;
    }
    cout<<ans<<endl;

    return 0;
}



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

int main (){
  int N,K;
  cin >> N >> K;
  vector<int> vec(N);
  for (int i=0; i<N; ++i) {
    cin >> vec.at(i);
  }
  vector<int> cost(N);
  cost.at(1) = abs(vec.at(1)-vec.at(0));
  for (int j=2; j<N; ++j) {
    int k = min(K,j);
    int a = cost.at(j-1)+abs(vec.at(j-1)-vec.at(j));
    for (int s=2; s<k+1; ++s) {
      int b = cost.at(j-s)+abs(vec.at(j-s)-vec.at(j));
      a = min(a,b);
    }
    cost.at(j) = a;
  }
  cout << cost.at(N-1);
}


Measured memory_bytes: 1024
#include <iostream>

typedef long long ll;

int N;
ll A[2][101];

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

  std::cin >> N;
  for (int i = 0; i < N; ++i) {
    std::cin >> A[0][i];
    if (i)  A[0][i] += A[0][i-1];
  }
  for (int i = 0; i < N; ++i)
    std::cin >> A[1][i];
  for (int i = N-2; i >= 0; --i)
    A[1][i] += A[1][i+1];

  ll ans = 0;
  for (int i = 0; i < N; ++i)
    ans = std::max(ans, A[0][i] + A[1][i]);
  std::cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b;
	cin>>a>>b;
	if(a==b) {cout<<a;return 0;}
	if(a<b) for(int i=a;i<=b;i++) if(i-a==b-i) {cout<<i;return 0;}
	if(a>b) for(int i=b;i<=a;i++) if(i-b==a-i) {cout<<i;return 0;}
	cout<<"IMPOSSIBLE";
	return 0;
}

Measured memory_bytes: 256
A,B,C = list(map(int, input().split()))
K = int(input())

for _ in range(K + 1):
#    print(A, B, C)
    if(A >= B):
        B = 2 * B
        continue
    
    if(B >= C):
        C = 2 * C
        continue

    print("Yes")
    exit()


print("No")

Measured memory_bytes: 9180
#include<bits/stdc++.h>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
using namespace std;


bool isPrime (int a) {
  if (a == 1) {
    return false;
  } else if (a == 2) {
    return true;
  } else if (a % 2 == 0) {
    return false;
  } else {
    for (int j = 3; j <= sqrt (a); j += 2) {
      if (a % j == 0) {
        return false;
      }
    }
    return true;
  }
}

int main () {
  int n, count = 0;
  cin >> n;
  int x [n];
  for (int i = 0; i <= n - 1; i++) {
    cin >> x [i];
    if (isPrime (x [i])) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3044
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<vector<P>> cond(n);
    rep(i, n) {
        int a;
        cin >> a;
        rep(j, a) {
            int x, y;
            cin >> x >> y;
            x--;
            cond[i].eb(x, y);
        }
    }
    int ans = 0;
    rep(bit, 1<<n) {
        bool ok = true;
        int cnt = 0;
        rep(i, n) {
            if (bit>>i&1) {
                cnt++;
                rep(j, sz(cond[i])) {
                    int x = cond[i][j].fi, y = cond[i][j].se;
                    if (y == 0) {
                        if (bit>>x&1) ok = false;
                    } else {
                        if (!(bit>>x&1)) ok = false;
                    }
                }
            }
        }
        if (ok) chmax(ans, cnt);
    }
    cout << ans << endl;
}

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

int main() {
  string S;
  ll K;
  cin >> S >> K;

  ll c_count = 1;
  vector<ll> ccs;
  ll ans = 0;

  bool isAllSame = true;
  char prev = '-';
  for(int i = 0; i < S.size(); ++i) {
    if(prev == S[i]) {
      c_count++;
    } else {
      if(prev != '-') {
        isAllSame = false;
        ccs.push_back(c_count);
      }
      ans += c_count / 2;
      c_count = 1;
    }
    prev = S[i];
  }
  ccs.push_back(c_count);
  ans += c_count / 2;
  if(isAllSame) {
    ans = S.size() * K / 2;
    cout << ans << endl;
    return 0;
  }
  ans *= K;
  if(S[0] == S[S.size() - 1]) {
    ans -= (ccs.front() / 2 + ccs.back() / 2 - (ccs.front() + ccs.back()) / 2) * (K - 1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <functional>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<ll, ll, ll, ll> tlglglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string N;
    cin >> N;
    ll len = N.size();
    ll num = 0;
    REP(i, 0, len) {
        num += N[i] - '0';
    }
    yesno(num % 9 == 0);
}


Measured memory_bytes: 3740
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int N, ss, sum = 0;
  cin >> N;
  vector<int> s(N); // 開会式N病後
  vector<int> c(N); // 累積和を作成する
  vector<int> f(N);
  vector<int> ans(N);

  rep(i, N-1){
    cin >> c[i] >> s[i] >> f[i];
  }

  for (int i = 0; i < N; i++) // i番目の駅について
  {
    int t = 0;
    for (int j = i; j < N - 1; j++) // 先のところを見る
    {
      if (t < s[j])
        t = s[j];
      else if (t % f[j] == 0){
        // 何もしない;
      }
      else {
        t = t + f[j] - t % f[j];
      }
      t += c[j];
    }
    printf("%d\n", t);
  }

}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

ll rec(ll val, map<ll, ll>& memo)
{
  if (memo.count(val)) { return memo[val]; }

  if (val == 0) { return 1; }
  else if (val == 1) { return 2; }

  ll ret = (rec(val / 2, memo) + rec((val - 1) / 2, memo)) % MOD;
  ret = (ret + rec((val - 2) / 2, memo)) % MOD;
  return memo[val] = ret;
}

int main()
{
  ll N; scanf("%lld", &N);
  map<ll, ll> memo;
  ll ans = rec(N, memo);
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
s=input()
flag=True
if s[0]!='A':
  flag=False
if 'C' not in s[2:-1]:
  flag=False
count=0
for i in range(len(s)):
  if s[i].islower():
    count+=1
if len(s)-count != 2:
  flag=False
if flag:
  print('AC')
else:
  print('WA')

Measured memory_bytes: 3064
import java.io.*;

public class Main {
	public static void main(String[] args) throws Exception {
		double max=0, min=0;
		boolean button = true;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input;
		while((input = br.readLine()) != null) {
			if(input.isEmpty()) break;
			double input2 = Double.parseDouble(input);
			if(button) {
				max = min = input2;
				button = false;
			}
			if(input2 > max) max = input2;
			else if(input2 < min) min = input2;
		}
		System.out.println(max-min);
	}
}

Measured memory_bytes: 16916
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
#define ll long long
const ll mod=998244353;
const int maxn=3005;
const int maxs=3005;
int a[maxn];
ll dp[maxs];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n,s;
    cin>>n>>s;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    dp[0]=1;
    for(int i=1;i<=n;i++)
        for(int sum=s;sum>=0;sum--)
            dp[sum]=(dp[sum]*2+(sum>=a[i]?dp[sum-a[i]]:0))%mod;
    cout<<dp[s]<<'\n';
    return 0;
}


Measured memory_bytes: 3680
from operator import mul
from functools import reduce
n,k = map(int,input().split())
a = list(map(int,input().split()))
m = 10**9+7
a.sort()
mn = 0
mx = 0
x = 1
if k == 1:
  print(0)
  exit()
def extgcd(a,b):
  r = [1,0,a]
  w = [0,1,b]
  while w[2]!=1:
    q = r[2]//w[2]
    r2 = w
    w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
    r = r2
    w = w2
  return [w[0],w[1]]
def mod_inv(a,m):
  x = extgcd(a,m)[0]
  return (m+x%m)%m
gy = 1
for i in range(1,k):
    gy = gy*mod_inv(i,m)%m
for i in range(n-k+1,n):
  x= x*i
for i in range(n-k+1):
  mn = (mn + a[i]*x)%m
  mx = (mx + a[n-i-1]*x)%m
  x = (mod_inv(n-i-1,m)*x*(n-i-k))%m
print(((mx-mn)*gy)%m)

Measured memory_bytes: 14544
import java.util.Scanner;
class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        
        if(str.equals("SUN")){
            System.out.println(7);
        }
        if(str.equals("MON")){
            System.out.println(6);
        }
        if(str.equals("TUE")){
            System.out.println(5);
        }
        if(str.equals("WED")){
            System.out.println(4);
        }
        if(str.equals("THU")){
            System.out.println(3);
        }
        if(str.equals("FRI")){
            System.out.println(2);
        }
        if(str.equals("SAT")){
            System.out.println(1);
        }
        scan.close();
    }
}

Measured memory_bytes: 21716
#include <algorithm>
#include <climits>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main(){
    int N, C[21], V[21];
    
    cin >> N;
    for (int i=0; i<N; ++i) cin >> V[i];
    for (int i=0; i<N; ++i) cin >> C[i];
    
    int sum = 0;
    for (int i=0; i<N; ++i) {
        sum += max(0, V[i] - C[i]);
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
            #define ll long long
            #define MOD 1000000007
            #define maxx ((ll)1e6+5)
            #define zuciso ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
            #define test ll t; cin>>t; while(t--)
            #define int long long
            #define INF 1000000000000000005
            #define pb push_back
            #define pi 3.1415926
            #define MAX 300006
            #define MAX_N 1000000
            #define N 1000002
            #define fori(i,a,b) for(int i=a;i<b;i++)
            ll fpow(ll x,ll y,ll p=MOD){x=x%p;ll sum=1;while(y){if(y&1)sum=sum*x;sum%=p;y=y>>1;x=x*x;x%=p;}return sum;}
            ll fact[1000007]={0};
            void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%MOD;}
            ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(fpow(fact[r],MOD-2)))%MOD; res=(res*(fpow(fact[n-r],MOD-2)))%MOD; return res;}
            ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(fpow(fact[n-r],MOD-2)))%MOD; return res;}
            ll modmul(ll x, ll y){return (x*y)%MOD;}
            ll modadd(ll x, ll y){return (x+y)%MOD;}
            ll modsub(ll x, ll y){return (x-y+MOD)%MOD;}
            ll xx[4]={1,0,-1,0};
            ll yy[4]={0,1,0,-1};
           using namespace std;

            vector<int > v[1000005];
             int f[1000005]={0};


             void sieve(){
               for(int i=1;i<=N;i++){
                    for(int j=i;j<=N;j+=i){
                        v[j].push_back(i);
                    }
                }

             }
            signed main(){
                zuciso;
               // sieve();
                int n;
                cin>>n;
                int a[n];

                for(int i=0;i<n;i++){
                    cin>>a[i];
                    f[a[i]]++;
                }
                int c=0;
                for(int i=1;i<=1000000;i++){
                    if(f[i]==1)c++;
                    if(f[i]){
                        for(int j=i*2;j<=1000000;j+=i){
                            f[j]+=2;
                        }
                    }
                }
                cout<<c<<endl;


            }


Measured memory_bytes: 36452
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextInt();
		long v = sc.nextInt();
		long b = sc.nextInt();
		long w = sc.nextInt();
		long t = sc.nextInt();

		if (a < b) {
			if (v > w) {
				if (v * t - w * t >= b - a) {
					System.out.println("YES");
				} else {
					System.out.println("NO");
				}
			} else {
				System.out.println("NO");
			}
		} else if (a > b) {
			if (v > w) {
				if (v * t - w * t >= a - b) {
					System.out.println("YES");
				} else {
					System.out.println("NO");
				}
			} else {
				System.out.println("NO");
			}
		} else {
			System.out.println("YES");
		}

		sc.close();
	}

}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>h(n); for(auto&i:h)cin>>i;
	int ans=0;
	for(int i=0;;i=0){
		if(count(h.begin(),h.end(),0)==n)break;
		while(i<n&&h.at(i)==0)++i;
		while(i<n&&h.at(i)!=0)--h.at(i),++i;
		++ans;
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;

struct UnionFind {
    vector<int> par; // 親を指すvector,-par[親]は木のサイズ
    UnionFind(int n):par(n, -1) {} // uniteで親を埋め込んでいく必要あり
    int root(int x) { // 親をたどる&データの整理
        if(par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    bool unite(int x, int y) { // データの結合
        x = root(x);
        y = root(y);
        if(x == y) return false;
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    bool same(int x, int y) {return root(x) == root(y);} // 所属判定
    int size(int x) {return -par[root(x)];} // 木のサイズ
};


struct edge {
    int u, v;
    int64_t cost;
    edge(int u=0, int v=0, int64_t cost=0):u(u), v(v), cost(cost) {}
};

bool comp(const edge& e1, const edge& e2) {
    return e1.cost < e2.cost;
}

vector<edge> es; // 初期化の必要あり
//最小全域木
int64_t kruskal(int V) { // Vは頂点数
    int E = es.size();
    sort(es.begin(), es.end(), comp);
    UnionFind uft(V);
    int64_t res = 0;
    for(int i = 0; i < E; ++i) {
        edge e = es[i];
        if(!uft.same(e.u, e.v)) {
            uft.unite(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}

int main() {
    int v, e;
    cin >> v >> e;
    es.resize(e);
    rep(i, e) {
        int s, t;
        ll w;
        cin >> s >> t >> w;
        es[i] = edge(s, t, w);
    }
    cout << kruskal(v) << endl;
}


Measured memory_bytes: 4428
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <string.h>
#include <string>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin >> s;
    int min_val = -1;
    for (int i=0; i<s.length()-2; i++) {
        string comp;
        for (int j=i; j<i+3; j++) comp += s[j];
        int val = stoi(comp);
        if (min_val == -1 or min_val > abs(753 - val)) min_val = abs(753 - val);
    }
    cout << min_val << '\n';
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  int n,i;
  ll a[100005],t[100005];
  const int mod=1e9+7;
  bool ak[100005]={false},tk[100005]={false};
  
  cin >> n;
  for (i=0;i<n;i++) cin >> a[i];
  for (i=0;i<n;i++) cin >> t[i];
  
  for (i=0;i<n;i++){
    if (i==0 || a[i]>a[i-1]) ak[i]=true;
    if (i==n-1 || t[i]>t[i+1]) tk[i]=true;
  }
  
  ll ans=1;
  for (i=0;i<n;i++){
    if ((ak[i] && tk[i] && a[i]!=t[i]) || (ak[i] && a[i]>t[i]) || (tk[i] && t[i]>a[i])){
      cout << 0 << endl;
      return 0;
    }
    if (ak[i] || tk[i]) continue;
    ans=ans*min(a[i],t[i])%mod;
  }
  
  cout << ans << endl;
  
  return 0;
}

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

void
pri(long long **, long long **, int, int, int);

long long **
Malloc(int, int);

void
Scanf(long long * [], int, int);

int
main(void)
{
    int n, m, l;
    long long **matrixA, **matrixB;

    scanf("%d %d %d", &n, &m, &l);
    matrixA = Malloc(n, m);
    matrixB = Malloc(m, l);
    
    Scanf(matrixA, n, m);
    Scanf(matrixB, m, l);

    pri((long long **) matrixA, (long long **) matrixB, n, m, l);
    return 0;
}

void
pri(long long **a, long long **b, int n, int m, int l)
{
    int i, j, k;
    long long sum;
    for (i = 0; i < n; i++)
        for (j = 0; j < l; j++) {
            sum = 0;
            for (k = 0; k < m; k++)
                sum += a[i][k] * b[k][j];
            printf("%lld", sum);
            if (j == l - 1)
                putchar('\n');
            else
                putchar(' ');
        }
}

long long **
Malloc(int n, int m)
{
    int i;
    long long **arr = (long long **) malloc(sizeof(long long *) * n);
    for (i = 0; i < n; i++)
        arr[i] = (long long *) malloc(sizeof(long long) * m);

    return arr;
}

void
Scanf(long long *arr[], int n, int m)
{
    int i, j;
    for (i = 0; i < n; i++)
        for (j = 0; j < m; j++)
            scanf("%lld", *(arr + i) + j);
}


Measured memory_bytes: 2100
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  vector<bool> prime(100001, true);
  prime[0] = prime[1] = false;
  FOR(i,2,100001)
	if(prime[i])
	  for(int j=i+i;j<100001;j+=i)
		prime[j] = false;
  
  int M, A, B;
  while(cin>>M>>A>>B, M){
	int rt = sqrt(M);
	int p = 2, q = 2;
	for(int i=2;i<=rt;++i){
	  if(prime[i]){
		int j;
		for(j=min(M/i,B*i/A);j>=i;--j)
		  if(prime[j]) break;
		
		if(prime[i] && prime[j] && i*j<=M && i*j > p*q)
		  p = i, q = j;
	  }
	}
	cout << p << " " << q << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 998244353ll;
//const ll MOD = 67280421310721ll;
const dou pi=3.141592653589793;
//メモ
//二次元配列のresizeのしかた
//vv.resize(n);
//for(size_t i=0; i<n; i++){
// vv[i].resize(n);
//}

//メモ
//負の辺を持つ最短経路問題では到達不可経路でも初期化値より小さくなりうるので注意しよう
int main(){
    ll h,w;
    std::cin >> h>>w;
    ll ans=INF64;
    if(h>=3){
    if(h%3==0){
        ans=0;
    }
    else{
        chmin(ans,w);
    }
    }
    if(w>=3){
    if(w%3==0){
        ans=0;
    }
    else{
        chmin(ans,h);
    }
    }
    
    rrep(i,1,h){
        ll a=(h-i)*w;
        ll b=(w+1)/2ll*i,c=w/2ll*i;
        chmin(ans,max({a,b,c})-min({a,b,c}));
    }
    rrep(i,1,w){
        ll a=(w-i)*h;
        ll b=(h+1)/2ll*i,c=h/2ll*i;
        chmin(ans,max({a,b,c})-min({a,b,c}));
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
N=int(input())
LS=list(input())
S=[int(s) for s in LS]
count=0
for i in range(10):
  if i in S:
    x=S.index(i)
    for j in range(10):
      if j in S[x+1:]:
        y=S[x+1:].index(j)
        for k in range(10):
          if k in S[x+y+2:]:
            count+=1
print(count)
      

Measured memory_bytes: 133216
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  string s;
  cin >> s;
  int n = s.length();
  string t[4] = {"dream", "dreamer", "erase", "eraser"};
  reverse(s.begin(), s.end());
  for(int i = 0; i < 4; i++) {
    reverse(t[i].begin(), t[i].end());
  }
  for(int i = 0; i < n - 5; i++) {
    if(s.substr(i, 5) == t[0]) {
      i += 4;
    } else if(s.substr(i, 7) == t[1]) {
      i += 6;
    } else if(s.substr(i, 5) == t[2]) {
      i += 4;
    } else if(s.substr(i, 6) == t[3]) {
      i += 5;
    } else {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  return 0;
}

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

set<int> memo[201][201];
vector<int> par_pos;

int number(string const& s, int p) {
    int res = 0;
    while(p < s.size() && isdigit(s[p])) {
        res *= 10;
        res += s[p++] - '0';
    }
    return res;
}

set<int> solve(string const& s, int l, int r) {
    auto& res = memo[l][r];
    if(res.size() != 0) {
        return res;
    }
    bool f = true;
    for(int i=l; i<=r; ++i) {
        f &= isdigit(s[i]);
    }
    if(f) {
        res.insert(number(s, l));
        return res;
    }
    if(par_pos[l] == r) {
        return res = solve(s, l+1, r-1);
    }
    vector<int> pare(s.size());
    for(int i=l; i<=r; ++i) {
        if(s[i] == '(') {
            pare[i] = 1;
        }
        if(s[i] == ')') {
            pare[i] = -1;
        }
        if(i != l) {
            pare[i] += pare[i-1];
        }
    }
    for(int i=l+1; i<r; ++i) {
        char c = s[i];
        if(pare[i] != 0) {
            continue;
        }
        if(c == '+' || c == '-' || c == '*' || c == '/') {
            set<int> s1 = solve(s, l, i-1);
            set<int> s2 = solve(s, i+1, r);
            for(auto x : s1) {
                for(auto y : s2) {
                    if(c == '+') {
                        res.insert(x + y);
                    } else if(c == '-') {
                        res.insert(x - y);
                    } else if(c == '*') {
                        res.insert(x * y);
                    } else {
                        if(y == 0) {
                            continue;
                        }
                        res.insert(x / y);
                    }
                }
            }
        }
    }
    return res;
}

int main() {
    string s;
    while(cin >> s, s != "#") {
        for(int i=0; i<201; ++i) {
            for(int j=0; j<201; ++j) {
                memo[i][j].clear();
            }
        }
        par_pos.assign(s.size(), -1);
        stack<int> p;
        for(int i=0; i<s.size(); ++i) {
            if(s[i] == '(') {
                p.push(i);
            }
            if(s[i] == ')') {
                par_pos[p.top()] = i;
                p.pop();
            }
        }
        cout << solve(s, 0, s.size()-1).size() << endl;
    }
}


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

int main() {
  int A,B,m,n;
  m = 1;
  n = 0;
  cin >> A >> B;
  
  if (B == 1) {
    cout << 0 << endl;
  } else if (A >= B) {
    cout << 1 << endl;
  } else {
    for (int i = 0; i < 9999; i++) {
      if (m >= B) {
        cout << n << endl;
        break;
      } else {
        m += A - 1;
        n++;
      }
    }
  }
}

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

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int MAX = 100000005;
int Pri[MAX];
bool flag[MAX];
int main()
{
	int n,x,ans = 0;
	cin >> n;
	for(int i = 2; i <= MAX; ++i)
	{
		if(!flag[i])
			Pri[++Pri[0]] = i;
		for(int j = 1; ((j <= Pri[0]) && (Pri[j]*i <= MAX)); ++j)
		{
			flag[Pri[j]*i] = true;
			if(i%Pri[j] == 0)
				break;
		}
	}
	while(n--)
	{
		cin >> x;
		if(!flag[x])
			++ans;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 123268
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;

int main() {
  ll N,X,M,i;
  cin>>N>>X>>M;
  vector<ll> idx(M,-1), a(M);
  ll x = X, len=0;
  while(idx[x] == -1) {
    idx[x] = len;
    a[len] = x;
    len++;
    x = x*x%M;
  }

  ll ans = 0;
  if (N<=len) {
    for (i=0;i<N;i++) ans += a[i];
  } else {
    for (i=0;i<len;i++) ans += a[i];
    N -= len;
    ll cycLen = len - idx[x];
    ll cycSum = 0;
    for (i=idx[x];i<len;i++) cycSum += a[i];
    ans += (N / cycLen) * cycSum;
    for (i=idx[x];i<idx[x]+(N % cycLen);i++) ans += a[i];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4376
#include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    int main()
    {
        ios::sync_with_stdio(0);
        cin.tie(0);
        ll n,cnt;
        string s;
        cin >>n;
	    cin >> s;
        ll r=count(s.begin(),s.end(),'R');
        ll  g=count(s.begin(),s.end(),'G');
        ll  b=count(s.begin(),s.end(),'B');
        cnt=r*g*b;
        for(ll i=0;i<n;i++){
            for(ll j=i+1;j<n;j++){
                if(j*2-i>=n)continue;
                set<char>st;
                st.insert(s[i]);
                st.insert(s[j]);
                st.insert(s[j*2-i]);
                if(st.size()==3)cnt--;
            }
        }
 
        cout << cnt << endl;
        return 0;
    }

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
int a[200000];
int main()
{
    long long int aa,b,n;
    cin>>n>>aa>>b;

    for( int i=0;i<n;i++)cin>>a[i];
    long long sum=0;
    long long s;
    for(int i=0;i<n-1;i++)
    {
        s=a[i+1]-a[i];
        s=s*aa;
        if(s<b)sum=sum+s;
        else sum=sum+b;
    }
  cout<<sum<<'\n';
return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
 
int main()
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if ((a != b) && (a != c) && (b != c)) {
		printf("No\n");
	}
	else if ((a == b) && (a == c)) {
		printf("No\n");
	}
	else {
		printf("Yes\n");
	}
	return 0;
}

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

//ABC 129 c.cpp
int main() {
    ll mod = 1000000007;
    int n,m;
    cin >> n >> m;

    vector<ll> dp(n+1);
    dp[0] = dp[1] = 1;
    vector<int> a(m);
    rep(i,m){
        cin >> a[i];
        dp[a[i]] = -1;
    }

    ll ans = 0;
    for(int i = 2;i < n+1;i++){
        if(dp[i] != -1){
            dp[i] = (dp[i-1] != -1)*dp[i-1] + (dp[i-2] != -1)*dp[i-2];
            dp[i] %= mod;
        }
    }
    ans = dp[n]%mod;
    cout <<ans<<endl;
}

Measured memory_bytes: 4220
using System;

class Calc
    {
        public int matricChainOrder(int[] p)
        {
            int n = p.Length-1, i;
            int[,] m = new int[n+1, n+1];
            for (i = 1; i <= n; i++)
            {
                m[i, i] = 0;
            }
            int l, j=0, k, q;
            for (l = 2; l <= n; l++)
            {
                for (i = 1; i <= n - l + 1; i++)
                {
                    j = i + l - 1;
                    m[i, j] = int.MaxValue;
                    for (k = i; k < j; k++)
                    {
                        q = m[i, k] + m[k + 1, j] + p[i - 1] * p[k] * p[j];
                        m[i, j] = min(m[i, j], q);
                    }
                }
            }
            return m[1, n];
        }

        public int min(int m, int q)
        {
            if (m<q)
            {
                return m;
            }
            else
            {
                return q;
            }
        }
    }

    class B10
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int n = int.Parse(input), i;
            string[] input2 = new string[2];
            int[] p = new int[n+1];
            Calc calc = new Calc();
            for (i = 0; i < n; i++)
            {
                input2 = Console.ReadLine().Split(' ');
                p[i] = int.Parse(input2[0]);
                p[i+1] = int.Parse(input2[1]);
            }
            Console.WriteLine(calc.matricChainOrder(p));
        }
    }


Measured memory_bytes: 17948
#include<stdio.h>
int main(void){
int n, s, sum, max, min, ave;

    while(1){
        scanf("%d", &n);
        if(!n) break;
 
        min = 1000; max = sum = 0;
        for(int i = 0; i < n; i++){
            scanf("%d", &s);
            
            if(max < s) max = s;
            if(min > s) min = s;
                
            sum += s;
        }
        ave = (sum - max - min)/(n - 2);
        printf("%d\n", ave);
    }
    return 0;
}



Measured memory_bytes: 1920
#include<stdio.h>
int main()
{
  int y, m, d;
  char dash[2];
  scanf("%d%c%d%c%d",&y,&dash[0],&m,&dash[2],&d);
  if (y<2019)
    printf("Heisei");
  else if(y==2019&&m<=4)
    printf("Heisei");
  else
    printf("TBD");
  return 0;
}

Measured memory_bytes: 128
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  solve <$> getl read <*> getl (map read . words) >>= print

solve :: Int -> [Int] -> Int
solve n xs = fst $ foldl f (1,H) $ map tr $ zip (tail xs) xs
  where
    tr (x, y)
      | x == y = H
      | x > y = D
      | otherwise = U
    f (c, prs) cts = case (prs, cts) of
      (H, H) -> (c, H)
      (H, U) -> (c, U)
      (H, D) -> (c, D)
      (U, H) -> (c, U)
      (U, U) -> (c, U)
      (U, D) -> (c+1, H)
      (D, H) -> (c, D)
      (D, U) -> (c+1, H)
      (D, D) -> (c, D)

data State = U | D | H

getl :: (String -> a) -> IO a
getl f = f <$> getLine


Measured memory_bytes: 36220
#include<iostream>
#include<algorithm> 
using namespace std;
long long a[3];
int main(){
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    cout<<((a[0]&1&a[1]&1&a[2]&1)?a[0]*a[1]:0)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using namespace std;

int main() {
    fastIO;
    int n, t;
    cin >> n >> t;

    vector<int> C(n);
    vector<int> T(n);

    rep(i, n) {
        cin >> C.at(i);
        cin >> T.at(i);
    }

    // output
    int min_cost = 1001;
    rep(i, n) {
        if (t >= T.at(i)) {
            min_cost = min(min_cost, C.at(i));
        }
    }

    if (min_cost != 1001)
        cout << min_cost << endl;
    else
        cout << "TLE" << endl;
}


Measured memory_bytes: 3660
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
using namespace std;
 
const int N = 200005, P = 1e9 + 7;
int T, n, m, p[N], sz[N], ans;
long long a[N], x, y;
int find(int x)
{
	return x == p[x] ? x : p[x] = find(p[x]);
}
int main()
{
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= n; ++i) p[i] = i, sz[i] = 1;
	ans = 1;
	for(int i = 0, x, y, a, b; i < m; ++i)
	{
		scanf("%d%d", &x, &y);
		a = find(x), b = find(y);
		if(p[a] == b) continue;
		p[a] = b;
		sz[b] += sz[a];
		ans = max(ans, sz[b]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5324
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
  
def main():
  s = input()
  slen = len(s)
  new = ""
  for i in range(slen):
    new += 'x'
  print(new)
if __name__ == '__main__':
  main()

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

int main() {
  int n;
  stack<int> stack;
  while(cin >> n) {
    if(n == 0) {
      cout << stack.top() << endl;
      stack.pop();
    } else {
      stack.push(n);
    }
  }

  return 0;
}

Measured memory_bytes: 1200
# coding: utf-8

# 13:42- kaisetsu and try again
# -14:03 giveup (WA*6) -> testcase


def main():
    N = int(input())
    A = sorted(list(map(int, input().split())))

    M = 10**6
    is_ans_flag = [0] * (M+1)
    n_appeared_in_A = [0] * (M+1)
    for a in A:
        n_appeared_in_A[a] += 1
        is_ans_flag[a] = 1

    for a in A:
        if n_appeared_in_A[a] == -1:
            continue

        if n_appeared_in_A[a] >= 2:
            is_ans_flag[a] = 0

        for i in range(2, M+1):
            if a*i > M:
                break
            is_ans_flag[a*i] = 0

        n_appeared_in_A[a] = -1

    return sum(is_ans_flag)


print(main())


Measured memory_bytes: 35628
#include <bits/stdc++.h>
using namespace std;
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }


const int MAX = 210000;
long long N, L;
long long a[MAX];


int main() {
    while (cin >> N >> L) {
        for (int i = 0; i < N; ++i) cin >> a[i];
        int place = -1;
        for (int i = 0; i < N; ++i) {
            if (a[i] >= L) place = i;
            if (i+1 < N && a[i] + a[i+1] >= L) place = i;
        }
        if (place == -1) {
            puts("Impossible");
        }
        else {
            puts("Possible");
            for (int i = 1; i <= place; ++i) {
                cout << i << endl;
            }
            for (int i = N-1; i > place; --i) {
                cout << i << endl;
            }
        }
    }
}














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

int main(){
  int N, Q; cin >> N >> Q;
  string s; cin >> s;
  vector<char> t(Q), d(Q);
  for(int i = 0; i < Q; i++) cin >> t[i] >> d[i];
  int left = -1, right = N;
  while(right - left > 1){
    int mid = (right + left) / 2, mid1 = mid;
    for(int i = 0; i < Q; i++){
      if(t[i] == s[mid] && d[i] == 'L') mid--;
      if(t[i] == s[mid] && d[i] == 'R') mid++;
      if(mid == N || mid == -1) break;
    }
    if(mid == -1) left = mid1;
    else right = mid1;
  }
  int ans_left = left;
  left = -1, right = N;
  while(right - left > 1){
    int mid = (right + left) / 2, mid1 = mid;
    for(int i = 0; i < Q; i++){
      if(t[i] == s[mid] && d[i] == 'L') mid--;
      if(t[i] == s[mid] && d[i] == 'R') mid++;
      if(mid == N || mid == -1) break;
    }
    if(mid == N) right = mid1;
    else left = mid1;
  }
  int ans_right = right;
  cout << ans_right - ans_left - 1 << endl;
}


Measured memory_bytes: 900
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  ll n,m;
  std::cin >> n >> m;
  ll a[200010],b[200010];

  for(ll i=0; i<m; i++){
    a[i]=0; b[i]=0;
  }

  for(ll i=0; i<m; i++){
    ll x,y;
    std::cin >> x >> y;
    if(x==1) a[y]=1;
    if(y==n) b[x]=1;
  }

  for(ll i=1; i<=n; i++){
    if(a[i]==1 && b[i]==1){
      std::cout << "POSSIBLE" << '\n';
      return 0;
    }
  }
   std::cout << "IMPOSSIBLE" << '\n';
  return 0;
}


Measured memory_bytes: 3328
'use strict';
function Main(input) {
  input = input.split(" ");
  let a = parseInt(Math.max.apply(null, input));
  let b = parseInt(Math.min.apply(null, input)); 
  let result = a * b;
  let mod=1;
  while(mod > 0){
    mod = a % b;
    a = b;
    b = mod;
  }
                   
  console.log(result / a);  	
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29436
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func fSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	w, h := iScan(), iScan()
	p, q := iSScan(w), iSScan(h)
	x := make([][]int, 0, w+h+2)
	for _, v := range p {
		x = append(x, []int{v, 0})
	}
	for _, v := range q {
		x = append(x, []int{v, 1})
	}
	sort.Slice(x, func(i, j int) bool { return x[i][0] < x[j][0] })
	ans := 0
	a, b := w+1, h+1
	for _, v := range x {
		if v[1] == 0 {
			ans += v[0] * b
			a--
		} else {
			ans += v[0] * a
			b--
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 13360
N = int(input())
H = [int(i) for i in input().split()]
dp = [0] * N

for i in range(N-1):
    if H[i] >= H[i+1]: 
        dp[i+1] = dp[i]+1
    else:
        dp[i+1] = 0
        
print(max(dp))

Measured memory_bytes: 14252
#include<iostream>
#include<cstdio>
#include<stack>
using namespace std;
 
int main(){
    string str ;
    while ( cin >> str ){
        int len = str.size() ;
        stack<char> container ;
        for ( int i = 0 ; i < str.size() ; i ++ ){
            if ( str[i] == 'T' ){
                if ( !container.empty() ){
                    if ( container.top() == 'S' ){
                        len -= 2 ;
                        container.pop() ;
                    }
                }else{
                    container.push(str[i]) ;
                }
            }else{
                container.push(str[i]) ;
            }
        }
        cout << len << endl ;
    }
    return 0 ;
}

Measured memory_bytes: 3720
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
using namespace std;


int main(void){
    map<int,int> table;
    int N;
    cin >> N;
    int cnt = 0;
    for(int i = 0; i < N; i++){
        int tmp;
        cin >> tmp;
        if(table[tmp] == 0){
            table[tmp] = 1;
            cnt++;
        }else{
            table[tmp] = 0;
            cnt--;
        }
    }
    cout << cnt << endl;
    return 0;
    
}   

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#include <atcoder/all>
#define LOCAL
using namespace std;
using namespace atcoder;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
//#define int long long
using P = pair<int,int>;
//#########################################
int main(){
    string ret;
    int a;cin >> a;
    while(a--)ret += "ACL";
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3632