akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;
int N, K;
vector<int> A;

bool solve(int num){
	vector<int> B, sum;
	
	for(int i = 0; i < N; i++){
		if(A[i]%num) B.push_back(A[i]%num);
	}
	
	if(B.size() == 0)return true;  
	
	sort(B.begin(), B.end());
	
	sum.resize(B.size()+1);
	
	// cout<<endl;
	// cout<<"num = "<<num<<endl;
	
	for(int i = 0; i < B.size(); i++){
		sum[i+1] += sum[i] + num - B[i];
		// cout<<"B = "<<B[i]<<" "<<sum[i+1]<<endl;
	}
	
	for(int i = 0, s = 0; i < B.size(); i++){
		// cout<<s<<" == "<<sum[B.size()] - sum[i]<<endl;
		if(s == sum[B.size()] - sum[i] && s  <= K) return true;
		s += B[i];
	}
	
	return false;
}
signed main(){
	cout<<fixed<<setprecision(10);
	
	
	int sum = 0;
	int ans = 1;
	
	cin>>N>>K;
	
	A.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
		sum += A[i];
	}
	
	for(int i = 1; i * i <= sum; i++){
		if(sum%i) continue;
		if(solve(i)) ans = max(ans, i);
		if(solve(sum/i)) ans = max(ans, sum/i);
	}
	
	cout<<ans<<endl;
	
	return 0;
}

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

int main ()
{
    int n,a,b;
    cin >> n >> a >> b;
    int sum = 0;
    
    for(int i = 1; i <= n; i++){
        int d_sum = 0;
        int k = i;
        for(int j = 0; j <= 4; j++){
            d_sum += k % 10;
             k = k / 10;
        }
        if(d_sum >= a && d_sum <= b){
            sum += i;
        }
    }
    cout << sum << endl;
}

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

using i64 = int64_t;

i64 cum_left[100005]={0}, cum_right[100005]={0};

i64 gcd(i64 m, i64 n) {
    return (n == 0 ? m : gcd(n, m % n));
}

int main(){
    int n;
    cin >> n;
    vector<i64> v;
    for(int i=0;i<n;++i){
        i64 a;
        cin >> a;
        v.push_back(a);
    }
    for(int i=1;i<=n;++i){
        cum_left[i] = gcd(cum_left[i-1], v[i-1]);
        cum_right[n-i+1] = gcd(cum_right[n-i+2], v[n-i]);
    }
    i64 ans = 0;
    for(int i=1;i<=n;++i){
        ans = max(ans, gcd(cum_left[i-1], cum_right[i+1]));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2676
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=100000+10;
const int mod=1e9+7;
int qpow(int a,int b) { int c=1;
	for (;b;b>>=1,a=1ll*a*a%mod) if (b&1) c=1ll*c*a%mod;
	return c;
}

int n,a[N];

int main() {
	n=read();
	for (int i=1;i<=n;++i) a[i]=read();
	sort(a+1,a+n+1);
	if (n&1) {
		int flag=(a[1]==0);
		for (int i=2;i<=n;i+=2)
			if (a[i]!=i||a[i+1]!=i) { flag=0; break; }
		if (flag) printf("%d\n",qpow(2,n/2));
		else puts("0");
	} else {
		int flag=1;
		for (int i=1;i<=n;i+=2)
			if (a[i]!=i||a[i+1]!=i) { flag=0; break; }
		if (flag) printf("%d\n",qpow(2,n/2));
		else puts("0");
	}
	return 0;
}

Measured memory_bytes: 4068
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  long long int h,w;
  scanf("%lld %lld\n",&h,&w);
  if(h==1 || w==1){
    printf("1\n");
    return 0;
  }
  if(h*w%2==0){
    printf("%lld\n",h*w/2);
  }
  else{
    printf("%lld\n",h*w/2+1);
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef unsigned long long ll;

ll gcd(ll a, ll b)
{
  if(a==0)return b;
  return gcd(b%a, a);
}

ll lcm(ll a, ll b)
{return a*b/gcd(a,b);}
int main()
{
	ll A,B,C,D; cin>>A>>B>>C>>D; ll E = lcm(C,D);
  	ll AC,AD,BC,BD,AE,BE,AS,BS;
  	AC = (A-1)/C; AD = (A-1)/D; AE = (A-1)/E;
  	BC = B/C; BD = B/D; BE = B/E;
 	AS = AC+AD-AE; BS = BC+BD-BE;
  	ll answer=B-(A-1)-(BS-AS);
  	cout<<answer<<endl;
  	return 0;
  
  
  
}

Measured memory_bytes: 632
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
struct A {
	string s;
	int p, m;
	bool operator<(A a) {
		if (s != a.s) return s < a.s;
		return p > a.p;
	}
};
A a[200];
signed main() {
	int n = read();
	for (int i = 0; i < n; i++) {
		cin >> a[i].s >> a[i].p;
		a[i].m = i + 1;
	}
	sort(a, a + n);
	for (int i = 0; i < n; i++) {
		cout << a[i].m << endl;
	}
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
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);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long a = in.nextInt();
            long b = in.nextInt();
            if (a % b == 0) {
                out.println(-1);
            } else {
                for (int i = 2; i < 1000; i++) {
                    if (a * i % b != 0) {
                        out.println(a * i);
                        break;
                    }
                }
            }
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21588
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 1000000000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;

vector<ll> P(250000,0);

void era(){
    for (int i=2; i<250000; i++) {
        if(P[i]==0) continue;
        int j=i;
        while(j<250000) {
            j+=i;
            if(j>=250000)break;
            P[j]=0;
        }
    }
}


int main(){
    rep(i,P.size()) P[i]=i;
    era();
    for (;;) {
        int n;
        cin >> n;
        if(!n)break;
        ll ans=0;
        for (int i=n+1; i<=2*n; i++) {
            if (P[i]!=0) {
                ans++;
            }
        }
        cout << ans <<endl;
    }
    return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
int main()
{
    string s;
    cin >> s;
    string ans="";
    rep(i, s.size()){
        if(s[i] =='1' || s[i]=='0') ans.push_back(s[i]);
        else if(s[i]=='B' && ans.size() !=0){
            ans.erase(ans.size()-1);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
N = int(input())
MOD = 10 ** 9 + 7

ans = 1
ans9 = 1
ans8 = 1

for i in range(N):
  ans = ans * 10 % MOD
  ans9 = ans9 * 9 % MOD
  ans8 = ans8 * 8 % MOD

print((ans - ans9 * 2 + ans8) % MOD)


Measured memory_bytes: 9164
S = input().split(" ")
N = int(S[0])
M = int(S[1])

def calculate(n,m,baseP,i):

    s = (0.5 ** m)
    successP = s * baseP
    failureP = baseP * (1 - s)

    time =  successP * ( (n - m) * 100 + m * 1900) * i

    if successP < 1e-9:
        return time
    else:
        return time + calculate(n,m,failureP,i+1)


result = calculate(N,M,1,1)
print(round(result))


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

#define all(x) (x).begin(), (x).end()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

int main() {
  _upgrade;
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long res = a * c;
  res = max(res, a * d);
  res = max(res, b * c);
  res = max(res, b * d);
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 3640
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 305;

int dp[2][MAX_N][MAX_N];
char S[MAX_N];

int main() {
  scanf("%s", S + 1);
  int N = strlen(S + 1), K;
  scanf("%d", &K);

  memset(dp, -0x3f, sizeof dp);

  int o = 0, p, result = 1;
  for (int i = 1; i <= N + 1; ++i) dp[0][i][0] = 0;
  
  for (int i = 1; i <= N; ++i) {
    p = o, o ^= 1;
    memset(dp[o], -0x3f, sizeof dp[o]);
    dp[o][N + 1][0] = 0;
    for (int j = N; j > i; --j)
      for (int k = 0; k <= K; ++k) {
	dp[o][j][k] = max(dp[o][j + 1][k], dp[p][j][k]);
	if (S[i] == S[j]) dp[o][j][k] = max(dp[o][j][k], dp[p][j + 1][k] + 1);
	else if (k > 0) dp[o][j][k] = max(dp[o][j][k], dp[p][j + 1][k - 1] + 1);
      }
    for (int k = 0; k <= K; ++k) {
      result = max(result, dp[o][i + 1][k] * 2);
      result = max(result, dp[o][i + 2][k] * 2 + 1);
    }
  }

  printf("%d\n", result);
  return 0;
}


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

int main(int argc, const char * argv[]) {
    int W, H, x, y, r;
    
    cin >> W >> H >> x >> y >> r;
    
    W=W-r;
    H=H-r;
    
    if(x<r || x>W){
        cout << "No" << endl;
    }else if(y<r || y>H){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    
    
    return 0;
}



Measured memory_bytes: 3136
N,M,Q=map(int,input().split())

LR=[None]*M
for i in range(M):
    LR[i]=list(map(int,input().split()))

pq=[None]*Q
for i in range(Q):
    pq[i]=list(map(int,input().split()))


LIST=[None]*(N+1)
for i in range(N+1):
    LIST[i]=[0 for j in range(N+1)]


for i in range(M):
    LIST[LR[i][0]][LR[i][1]]+=1

for i in range(N-1,-1,-1):
    for j in range(N+1):
        LIST[i][j]=LIST[i+1][j]+LIST[i][j]

for i in range(N+1):
    for j in range(1,N+1):
        LIST[i][j]=LIST[i][j-1]+LIST[i][j]

for i in range(Q):
    print(LIST[pq[i][0]][pq[i][1]])


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

template<typename T>
struct Bit
{
  int N; // 2のべき乗でなくてもOK
  vector<T> node;
  Bit(int N) : N(N), node(N + 1, 0) {}
  void add(int i, T w) // node[i] += w
  {
    for (int x = ++i; x <= N; x += x & -x)
      node[x] += w;
  }
  T sum(int i) // return sum [0, i)
  {
    T ans = 0;
    for (int x = i; x > 0; x -= x & -x)
      ans += node[x];
    return ans;
  }
  T sum(int i, int j) // return sum [i, j)
  {
    return sum(j) - sum(i);
  }
};

void solve() {
  int N, K;
  cin >> N >> K;
  vector<ll> a(N);
  rep(i, N) cin >> a[i];
  rep(i, N) a[i] -= K;
  dump(a);

  vector<ll> b(N + 1);
  b[0] = 0;
  for (int i = 0; i < N; i++) {
    b[i + 1] = b[i] + a[i];
  }
  dump(b);

  // 座標圧縮
  map<ll, int> mp;
  rep(i, b.size()) mp[b[i]] = 0;
  int j = 0;
  for (auto& x : mp) x.second = j++;
  rep(i, b.size()) b[i] = mp[b[i]];
  dump(b);

  ll ans = 0;
  Bit<ll> bit(N + 1);
  bit.add(b[0], 1);
  for (int i = 1; i <= N; i++) {
    ans += bit.sum(b[i] + 1); // 以下なので+1
    bit.add(b[i], 1);
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 17408
N, Y = map(int, input().split())
for x in range(N + 1):
  for y in range(N - x + 1):
    z = N - x - y
    if x * 10000 + y * 5000 + z * 1000 == Y:
      print(x, y, z)
      exit()
print(-1, -1, -1)

Measured memory_bytes: 3316
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<vector>
#define FAST ios::sync_with_stdio(false)
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 7;
const int maxn = (int)1e5 + 5;
using namespace std;

int pre[maxn], p[maxn], pos[maxn];

int find(int x){
	int r = x;
	while(pre[r] != r)
		r = pre[r];
	int i = x, t;
	while(i != r){
		t = pre[i];
		pre[i] = r;
		i = t;
	}
	return r;
}

void join(int x, int y){
	int fx = find(x), fy = find(y);
	if(fx != fy) pre[fx] = fy;
}

int main()
{
	int n, m; scanf("%d %d", &n, &m);
	for(int i = 1; i <= n; i++)	scanf("%d", p + i), pre[i] = i, pos[p[i]] = i;
	for(int i = 1; i <= m; i++){
		int x, y; scanf("%d %d", &x, &y);
		join(x, y);
	}
	for(int i = 1; i <= n; i++) find(i);
	int ans = 0;
	for(int i = 1; i <= n; i++){
		if(pre[i] == pre[pos[i]]) ans++;
	}
	printf("%d\n", ans);
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'A' || s[i] == 'C'|| s[i] == 'G' || s[i] == 'T') {
            int num = 1;
            for (int j = i + 1; j < s.size(); j++) {
                if (s[j] == 'A' || s[j] == 'C' || s[j] == 'G' || s[j] == 'T')
                    num++;
                else
                    break;
            }
            ans = max(ans, num);
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
  vector<int> a;
  rep(i, 9)
  {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }

  int n;
  cin >> n;

  vector<int> b;
  rep(i, n)
  {
    int tmp;
    cin >> tmp;
    b.push_back(tmp);
  }

  // row
  int counter = 0;
  bool bingo_flag = false;
  rep(i, 3)
  {
    rep(j, n)
    {
      if(b[j] == a[i * 3])
      {
        counter++;
      }
      if(b[j] == a[i * 3 + 1])
      {
        counter++;
      }
      if(b[j] == a[i * 3 + 2])
      {
        counter++;
      }
    }
    
    if (3 == counter)
    {
      bingo_flag = true;
    }
    
    counter = 0;
  }
  
  // col
  rep(i, 3)
  {
    rep(j, n)
    {
      if(b[j] == a[i])
      {
        counter++;
      }
      if(b[j] == a[i + 3])
      {
        counter++;
      }
      if(b[j] == a[i + 6])
      {
        counter++;
      }
    }
    
    if (3 == counter)
    {
      bingo_flag = true;
    }

    counter = 0;
  }
  
  // naname
  counter = 0;
  rep(j, n)
  {
    if(b[j] == a[0])
    {
      counter++;
    }
    if(b[j] == a[4])
    {
      counter++;
    }
    if(b[j] == a[8])
    {
      counter++;
    }
  }
  
  if (3 == counter)
  {
    bingo_flag = true;
  }
  
  counter = 0;
  rep(j, n)
  {
    if(b[j] == a[2])
    {
      counter++;
    }
    if(b[j] == a[4])
    {
      counter++;
    }
    if(b[j] == a[6])
    {
      counter++;
    }
  }
  
  if (3 == counter)
  {
    bingo_flag = true;
  }

  if (true == bingo_flag)
  {
    printf("Yes");
  }
  else
  {
    printf("No");
  }

  return 0;
}

Measured memory_bytes: 256
num_of_problems = int(input())
times = input().split()
for i in range(num_of_problems):
    times[i] = int(times[i])
num_of_drinks = int(input())
changes = []
for i in range(num_of_drinks):
    l = input().split()
    l[0] = int(l[0])
    l[1] = int(l[1])
    changes.append(l)
for i in changes:
    diff = times[i[0]-1] - i[1]
    times[i[0]-1] = i[1]
    print(sum(times))
    times[i[0]-1] += diff
    


    



Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
#define fr first
#define sc second
#define rep(i,n) for(int i = 0 ; i < n ; i++ )
typedef pair< int , int > Pt;
typedef long long ll;
const int dx[] = { 0, 1, -1, 0}, dy[] = { 1, 0, 0, -1};
struct P{
  Pt nkmr;
  vector< Pt > pnl,cnt;
  bool operator<(const P& right)const{
    return nkmr < right.nkmr;
  }
};
typedef pair< int , P > IP;
Pt Goal;
int h, w;
char mas[10][10];
int search_cnt(int y,int x,P& n){
  rep(i,n.cnt.size()) if(n.cnt[i] == Pt(y,x)) return i;
  return -1;
}
int search_panel(int y,int x,P& n){
  rep(i,n.pnl.size()) if(n.pnl[i] == Pt(y,x)) return i;
  return -1;
}
bool isused(map<ll,bool>& used,P& p){
  ll ret = (p.nkmr.fr << 4) + p.nkmr.sc;
  sort(p.pnl.begin(),p.pnl.end()),sort(p.cnt.begin(),p.cnt.end());
  for(int i = 0 ; i < p.pnl.size() ; i++ ){
    ret <<= 4;
    ret += p.pnl[i].fr;
    ret <<= 4;
    ret += p.pnl[i].sc;
  }
  for(int i = 0 ; i < p.cnt.size() ; i++ ){
    ret <<= 4;
    ret += p.cnt[i].fr;
    ret <<= 4;
    ret += p.cnt[i].sc;
  }
  if(used[ret]) return true;
  used[ret] = true;
  return false;
}
int Dijkstra(P& St){
  int dbk;
  priority_queue<pair<int,P>,vector<pair<int,P> >,greater<pair< int,P> > > que;
  map < ll , bool > used;
  que.push(IP(0,St));
  while(!que.empty()){
    int _cost = que.top().fr;
    P p = que.top().sc;
    que.pop();
    if(p.nkmr == Goal) return _cost;
    if(isused(used,p)) continue;
    rep(i,4){
      P next = p;
      int ny = p.nkmr.fr + dy[i], nx = p.nkmr.sc + dx[i],contena,panel;
      if(mas[ny][nx] == '#' || search_panel(ny,nx,next) != -1) continue;
      if((contena = search_cnt(ny,nx,next)) != -1){ //コンテナあった
        int ty = ny + dy[i], tx = nx + dx[i];
        if(mas[ty][tx] != '.' || search_cnt(ty,tx,next) != -1) continue;
        while(mas[ty][tx] == '.' &&
              search_cnt(ty,tx,next) == -1 && search_panel(ty,tx,next) == -1){
          ty += dy[i], tx += dx[i];
        }
        if((panel = search_panel(ty,tx,next)) != -1){
          next.cnt[contena] = Pt(-1,-1);
          next.pnl[panel] = Pt(-1,-1);
        }else next.cnt[contena] = Pt(ty - dy[i],tx - dx[i]);
        que.push(IP(_cost,next));
      }else{
        que.push(IP(_cost+1,(P){Pt(ny,nx),p.pnl,p.cnt}));
      }
    }
  }
  return -1;
}
int main(){
  while(cin >> h >> w , h ){
    P p = (P){Pt(),vector<Pt>(),vector<Pt>()};
    int cpa = 0,ccn = 0;
    rep(i,h) rep(j,w){
      cin >> mas[i][j];
      if(mas[i][j] == '@') p.nkmr = Pt(i,j), mas[i][j] = '.';
      else if(mas[i][j] == 'w'){
        p.pnl.push_back(Pt(i,j)), mas[i][j] = '.';
      }else if(mas[i][j] == 'c'){
        p.cnt.push_back(Pt(i,j)), mas[i][j] = '.';
      }else if(mas[i][j] == 'E') Goal = Pt(i,j), mas[i][j] = '.';
    }
    cout << Dijkstra(p) << endl;
  }
}

Measured memory_bytes: 4656
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <list>
#include <set>
#include <queue>
#include <iterator>
#include <bitset>
#include <bits/stdc++.h>
#include <vector>
#include <cctype>
#include <algorithm>
#define ll             long long
#define _              ios_base::sync_with_stdio(0);cin.tie(0);
#define loop           for(i=0;i<n;i++)
#define pb             push_back
#define tc()           int t;cin>>t;while(t--) 
#define pi             acos(-1)         
 
using namespace std;
 
ll i,j,temp;

 
int main()
{_
    
   long double A,B,M,H;
   long double Hourangle,Minuteangle,angle,length;
   cin>>A>>B>>H>>M;

   if(H==12){
   	H = 0;
   }
   
   Hourangle = H*30 + ((5*M)/60)*6;

   if(M==60){
   	M = 0;
   }
   
   Minuteangle = M*6;
   angle = pi*abs(Minuteangle - Hourangle)/180;

   length = A*A + B*B - 2*A*B*cos(angle);
   length = sqrt(length);
   if(angle == 180){
   	length = A+B;
   }
   if(angle == 0){
   	length = abs(A-B);
   }
   //cout<<angle<<endl;
   printf("%.25Lf\n",length);
   
 
return 0;
}

Measured memory_bytes: 4164
#include <stdio.h>

int main(void) {
	int i,ii, ary[10], k;
	for(i=0;i<10;i++){
		scanf("%d",&ary[i]);
	}
	for(ii=0;ii<10;ii++){
		for(i=ii+1;i<10;i++){
		if(ary[ii]<ary[i]){
			k= ary[ii];
			ary[ii]=ary[i];
			ary[i]=k;
		}
		}
		
	}
	
	for(i=0;i<3;i++){
		printf("%d\n",ary[i]);
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <vector>
using namespace std;
typedef long long int64;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<int64, int64> pll;

const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
const int SIZE = 100003;

const int MAX_N = 2e5;

map<pll,pii> cnt;
int64 A[MAX_N], B[MAX_N];
int64 gcd(int64 a,int64 b){
	if(b == 0)	return a;
	return gcd(b,a%b);
}
int power(int64 a,int64 n,int64 M){
	a %= M;
	int64 ret = 1;
	while(n){
		if(n&1)	ret = a*ret%M;
		a = a*a%M;
		n >>= 1;
	}
	return ret;
}


int solve(int N){
	int zero = 0, X = 0, Y = 0;
	int64 ret = 1;
	for (int i = 0; i < N; ++i){
		if(A[i] == 0 && B[i] == 0)	++zero;
		else if(A[i] == 0)	++X;
		else if(B[i] == 0)	++Y;
		else{
			int64 d = gcd(abs(A[i]),abs(B[i]));

			A[i] /= d, B[i] /= d;
			if(A[i] < 0)	A[i] = -A[i], B[i] = -B[i];

			if(B[i] > 0) cnt[pll(A[i],B[i])].first += 1;
			else		 cnt[pll(-B[i],A[i])].second += 1;
		}
	}

	for (map<pll,pii>::iterator itr = cnt.begin();
			itr != cnt.end(); ++itr){
		pii num = itr->second;
		ret = ret*((power(2,num.first,MOD)+power(2,num.second,MOD)-1)%MOD)%MOD;
	}
	ret = ret*(power(2,X,MOD)+power(2,Y,MOD)-1)%MOD;
	ret = (ret+zero)%MOD;
	ret = (ret-1+MOD)%MOD;
	assert(ret > 0);
	return ret;
}

int main(){
	int N;
	scanf("%d",&N);
	for (int i = 0; i < N; ++i)	scanf("%lld%lld",A+i,B+i);

	int ans = solve(N);
	printf("%d\n",ans);
}



Measured memory_bytes: 18672
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main () {
	int n, r;
	cin >> n >> r;
	if(n >= 10) {
		cout << r << "\n";
	}else {
		int diff = 10 - n;
		cout << (r + 100 * diff) << "\n";
	}
	return 0;
}

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

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		int y=Integer.parseInt(s.substring(0,4));
		int m=Integer.parseInt(s.substring(5,7));
		int d=Integer.parseInt(s.substring(8,10));
		
		if(y==2019&&4<m) {System.out.println("TBD");}
		if(y==2019&&m<=4) {System.out.println("Heisei");}
		if(y<2019) {System.out.println("Heisei");}
		if(2019<y) {System.out.println("TBD");}	
	}
}

Measured memory_bytes: 21716
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<cmath>
using namespace std;
#define ll long long
int main(){
    ll A,B;
    cin >> A >> B;
    cout << (B*1900+(A-B)*100)*pow(2,B);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)(n),(int)(n))
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
  int a[LIMIT2]={0};
  char s[LIMIT1][11];
int tmp(const void *p, const void *q){
  int n = strcmp(s[*(int *)p],s[*(int *)q]);
  if(n != 0) return n;
  else return a[*(int *)q]-a[*(int *)p];
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int c[LIMIT1];
  
  scanf("%lld",&n);
  rep(i,n) scanf("%s %lld",s[i],&a[i]);
  rep(i,n) c[i]=i;
  qsort(c,n,sizeof(int),tmp);
  rep(i,n) printf("%d\n",c[i]+1);
  
  return 0;
}



Measured memory_bytes: 128
import sys
input = sys.stdin.readline

N,M=map(int,input().split())
mod=10**9+7

FACT=[1]
for i in range(1,5*10**5+1):
    FACT.append(FACT[-1]*i%mod)

FACT_INV=[pow(FACT[-1],mod-2,mod)]
for i in range(5*10**5,0,-1):
    FACT_INV.append(FACT_INV[-1]*i%mod)

FACT_INV.reverse()

def Combi(a,b):
    if 0<=b<=a:
        return FACT[a]*FACT_INV[b]*FACT_INV[a-b]%mod
    else:
        return 0

ANS=0
for i in range(N+1):
    if i%2==0:
        ANS=(ANS+Combi(N,i)*FACT[M-i]*FACT_INV[M-N])%mod
    else:
        ANS=(ANS-Combi(N,i)*FACT[M-i]*FACT_INV[M-N])%mod

print(ANS*FACT[M]*FACT_INV[M-N]%mod)

Measured memory_bytes: 48628
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

typedef long long ll;

int main() {
	ll n,m;
	vector<pair<ll,ll>> a;
	cin >> n >> m;
	for(ll i = 0;i < n;i++) {
		ll t;
		cin >> t;
		a.push_back(make_pair(t,1));
	}
	for(ll i = 0;i < m;i++) {
		ll b,c;
		cin >> b >> c;
		a.push_back(make_pair(c,b));
	}
	sort(a.begin(),a.end(),std::greater<pair<ll,ll>>());
	ll res = 0;
	ll count = 0;
	for(auto itr = a.begin();count != n;itr++) {
		ll s = min(n - count,itr->second);
		count += s;
		res += itr->first * s;
	}
	cout <<res << endl;
}


Measured memory_bytes: 6256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,a[303030]={};
	cin>>n;
	FOR(i,0,3*n){
		cin>>a[i];
	}
	sort(a,a+3*n);
	LL ans=0,tmp=0;
	FORD(i,3*n,tmp){
		ans+=a[i-1];
		i--;
		tmp++;
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2168
def lscan; gets.split.map(&:to_i); end
def bye(s);puts s;exit 0;end

N_,A,B,C,D = lscan
N = N_-1

ba = (B-A).abs


0.upto(N) do |dcnt|
    icnt = N-dcnt
    
    l = C*icnt - D*dcnt
    r = -C*dcnt + D*icnt
    
    bye "YES" if l <= ba && ba <= r
    
end
bye "NO"



Measured memory_bytes: 1916
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <iomanip>

int main(void) {
	// in
	int n, l;
	std::cin >> n >> l;

	// apples
	std::vector<int> apples(n);
	int sum_taste = 0;
	for(int i = 0; i < n; ++i) {
		apples[i] = l + i;
		sum_taste += l + i;
	}
	
	// sort
	std::sort(apples.begin(), apples.end(), [](int &lhs, int &rhs) { return std::abs(lhs) < std::abs(rhs); });

	int sum_taste_1 = sum_taste - apples[0];

	std::cout << sum_taste_1 << std::endl;

	return 0;
}


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

int getSento(int x)
{
    while (x >= 10)
    {
        x /= 10;
    }
    return x;
}
constexpr int getMatsubi(int x) { return x % 10; }

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << setprecision(10);

    int n;
    cin >> n;
    vector<vector<int>> ab(10, vector<int>(10, 0));

    for (int i = 1; i <= n; i++)
    {
        int sento = getSento(i);
        int matsubi = getMatsubi(i);
        ab[sento][matsubi]++;
    }

    int count = 0;
    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            count += ab[i][j] * ab[j][i];
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
#define int long long
const int INF = 1145141919893810;
    vector <vector<int>> to(2600);
    vector <vector<int>> ot(2600);
bool cone1[2600];
bool conen[2600];
bool ok[2600];
vector <vector<int>> cost(2600,vector <int>(2600));
void dfs(int now){
    if(cone1[now]) return ;
    else cone1[now] = true;
    for(int i=0;i<to[now].size();i++){
        dfs(to[now][i]);
    }
}
void rdfs(int now){
    if(conen[now]) return ;
    else conen[now] = true;
    for(int i=0;i<ot[now].size();i++){
        rdfs(ot[now][i]);
    }
}
signed main(void){
    int n,m; cin>>n>>m;
    vector <tuple <int,int,int> > edges;
    rep(i,m){
        int a,b,c; cin>>a>>b>>c; a--; b--;
        cost[a][b] = -c;
        to[a].push_back(b);
        ot[b].push_back(a);
        edges.push_back(make_tuple(a,b,cost[a][b]));
    }
    dfs(0);
    rdfs(n-1);
    rep(i,n) ok[i] = cone1[i]&conen[i];
    /////
    vector <int> d(n,INF); 
    d[0] = 0;
    int step = 0;
    bool upd = true;
    while(upd){
        upd = false;
        int a,b,c; 
        rep(j,m){
        tie(a,b,c) = edges[j];
            if(!ok[a] || !ok[b]) continue;
            int nd = d[a] + c;
            if(d[b] > nd){
                
                upd = true;
                d[b] = nd;
            }
        }
        step++;
        if(step > n+10){
            puts("inf");
            return 0;
        }
    }
    
    int ans = -d[n-1];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 53376
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cstdlib>
#include <algorithm>
#define NMAX 10
#define MMAX 29
//コメントアウトするとdebug()を実行しない
#define DEBUG
 
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	std::fill( (T*)array, (T*)(array+N), val );
}
 
typedef pair<int ,int > P;
vector<int > land[NMAX];
vector<int > rest;
int A[MMAX],B[MMAX],C,N,M,W,H,ans = 0,dp[NMAX][NMAX] = {},flag[NMAX];
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
dy[8] = {1,1,0,-1,-1,-1,0,1};
void dfs(int a){
	if(rest.empty()){
		ans++;
	}
	// printf("%d :",a);
	for (int i = 0; i < land[a].size(); ++i)
	{
		// printf("%d\n",land[a][i]);
		if(find(rest.begin(), rest.end(),land[a][i]) != rest.end()){
			rest.erase(find(rest.begin(), rest.end(),land[a][i]));
			// printf("%d::::\n",land[a][i]);
			dfs(land[a][i]);
			rest.push_back(land[a][i]);
		}
	}
 
}
 
void solve(){
	
}
 
void debug(){
 
}
 
void answer(){
	cout << ans << "\n";
}
 
int main(){
	ios::sync_with_stdio(false);
	Fill(flag,1);
	cin >> N >> M;
	for (int i = 1; i < N; ++i)
	{
		rest.push_back(i+1);
	}
	for (int i = 0; i < M; ++i)
	{
		scanf("%d%d",&A[i],&B[i]);
		land[A[i]].push_back(B[i]);
		land[B[i]].push_back(A[i]);
	}
	// for (int i = 0; i < N; ++i)
	// {
	// 	for (int j = 0; j < land[i].size(); ++j)
	// 	{
	// 		printf("%d ",land[i+1][j]);
	// 	}
	// 	printf("\n");
	// }
	solve();
	#ifdef DEBUG
	debug();
	#endif
	dfs(1);
	answer();
 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define vvll vector<vll>
#define vvi vector<vector<int>>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define pii pair<int, int>
#define vpli vector<pair<long long, int>>
#define deb(x) cout << "deb " << #x << " " << x << endl
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define endl "\n"
template <typename T>
void printvec(vector<T> &v, int n, int start = 0)
{
    //cout << "\nprinting vector\n";
    for (int i = start; i < n; i++)
    {
        cout << v[i] << " ";
    }
    cout << "done printing";
    cout << endl;
}
const int mod = 1e9 + 7;

void solve()
{
    string s;
    cin>>s;
    int sum = 0;
    for(auto &x : s)
    {
        sum = (sum + (x-'0'))%9;
    }
    cout<<(sum%9 == 0?"Yes\n":"No\n");
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3708
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    h1,m1,h2,m2,k=parseMap(split(readline()))
    start=h1*60+m1
    e=h2*60+m2
    if e-start>=k
        print(e-start-k)
    else
        print(0)
    end
end
main()

Measured memory_bytes: 161564
from collections import Counter
N = int(input())
D = list(map(int,input().split()))
MOD = 998244353

if D[0]!=0:
    print(0)
    exit()
ctr = Counter(D)
if ctr[0] != 1:
    print(0)
    exit()

ans = 1
for i in range(len(ctr)-1):
    ans *= pow(ctr[i], ctr[i+1], MOD)
    ans %= MOD
print(ans)

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

int main() {
    string s;
    cin >> s;
    
    string ans = "";
    rep(i, 3) {
        ans += s[i];
    }

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

Measured memory_bytes: 3640
A, B, C, X, Y = map(int, input().split())

if Y == X:
    if C * 2 < A + B:
        res = C * X * 2
    else:
        res = A * X + B * Y
        
elif Y < X:
    if C * 2 <= A + B:
        res = C * Y * 2
        if C * 2 <= A:
            res += (X - Y) * 2 * C
        else:
            res += (X - Y) * A
    else:
        res = A * X + B * Y

else:
    if C * 2 <= A + B:
        res = C * X * 2
        if C * 2 <= B:
            res += (Y - X) * 2 * C
        else:
            res += (Y - X) * B
    else:
        res = A * X + B * Y

print(res)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;
int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> t;
	for (int i = 0; i < N; i++)
	{
		int e;
		cin >> e;
		t.push_back(e);
	}
	vector<bool> v(N);
	int ans{ 0 };
	int idx{ 1 };
	while (idx < N)
	{
		idx -= 1;
		ans += 1;
		idx += K;

	}
	cout << ans;


	return 0;
}

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

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

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define dump(x) cout << #x << " = " << (x) << endl
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(make_pair(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl

const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9 + 7;

int main() {
    string s;
    cin >> s;
    bool flag = true;
    for(ll i = 1; i <= s.length(); i++) {
        if(i % 2 == 0) {
            if(s[i - 1] == 'R') {
                flag = false;
                break;
            }
        } else {
            if(s[i - 1] == 'L') {
                flag = false;
                break;
            }
        }
    }
    Yes(flag);
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#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++)
typedef long long ll;

template<typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b%a, a);
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int n;
  cin >> n;
  ll ans = 0;
  rep(i, n) {
    if (i == 0) {
      cin >> ans;
    } else {
      ll temp;
      cin >> temp;
      ans = gcd(ans, temp);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(x) cerr << #x << " == " << (x) << '\n';
#define all(X) X.begin(), X.end()
#define sz(X) (int)X.size()

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;

mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

// xz

void chmax(ll& x, ll y) { if (x < y) x = y; }

int main()
{ _
    int R, C, k; cin >> R >> C >> k;

    vector grid(R + 1, vector(C + 1, 0LL));

    for (int z = 0; z < k; ++z)
    {
        int r, c; cin >> r >> c;
        cin >> grid[r][c];
    }

    int K = 4;
    vector dp(R + 1, vector(C + 1, vector(K, 0LL)));

    for (int i = 1; i <= R; ++i)
        for (int j = 1; j <= C; ++j)
        {
            for (int z = 0; z < K; ++z)
                chmax(dp[i][j][z], max(dp[i][j - 1][z], dp[i - 1][j][K - 1]));
            for (int z = 1; z < K; ++z)
                chmax(dp[i][j][z], grid[i][j] + max(dp[i][j - 1][z - 1], dp[i - 1][j][K - 1]));
        }

    ll ans = *max_element(all(dp.back().back()));
    cout << ans << endl;

    exit(0);
}



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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

ll s[333333], t[333333];

int main() {
   int n;
   cin >> n;
   vec<ll> a(3*n);
   rep (i, 3*n) {
      cin >> a[i];
   }

   pq<ll, vec<ll>, greater<ll>> Q;
   ll sum = 0;
   rep (i, 3*n) {
      Q.push(a[i]);
      sum += a[i];
      if (Q.size() > n) {
         sum -= Q.top();
         Q.pop();
      }
      s[i] = sum;
   }

   pq<ll> P;
   sum = 0;
   for (int i = 3*n-1; i >= 0; i--) {
      P.push(a[i]);
      sum += a[i];
      if (P.size() > n) {
         sum -= P.top();
         P.pop();
      }
      t[i] = sum;
   }

   ll ans = -1e18;
   for (int i = n-1; i < 2*n; i++) {
      ans = max(ans, s[i] - t[i+1]);
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 9332
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

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

  long long N;
  cin >> N;

  long long ans = N;
  for(long long i = 1; i <= sqrt(N); i++) {
    if(N % i == 0) {
      ans = min(ans, (i - 1) + ((N / i) - 1));
    }
  }

  cout << ans;

  return 0;
}


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

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

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

    int ans = 0;
    for(int i = 1; i < n - 1; i++){
        if(A[i - 1] < A[i] and A[i] < A[i + 1]){
            ans++;
            continue;
        }
        if(A[i - 1] > A[i] and A[i] > A[i + 1]){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $n, $m);
$r = array_fill(1, $n, 0);
for ($i = 0; $i < $m; $i++) {
	fscanf(STDIN, "%d %d", $a, $b);
	$r[$a]++;
	$r[$b]++;
}
echo implode("\n", $r);

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

int main() {
  char c;
  cin >> c;
  if((c=='a')||(c=='e')||(c=='u')||(c=='i')||(c=='o')){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 3572
<?php
fscanf(STDIN, "%s", $string);
if (preg_match('/^[0|1|B]+$/', $string) == 0) {
    exit();
}
$result = '';
for($i = 0; $i < strlen($string); $i++) {
    $result = $result . $string[$i];
    if ($string[$i] == 'B') {
        $result = substr($result, 0, strlen($result) - 2);
    }
}
echo $result;
?>

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 998244353
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li a[100100];
li b[100100];
PI ba[100100];

li aa[100100];
li bb[100100];

map<li, li> am;

int main() {
    li n;
    cin >> n;
    rin{
        cin >> a[i];
        aa[i] = a[i];
        am[a[i]] = 0;
    }
    rin{
        cin >> b[i];
        bb[i] = b[i];
    }
    rin{
        ba[i] = {b[i], a[i]};
    }

    sort(aa, aa + n);
    sort(bb, bb + n);
    rin{
        if (aa[i] > bb[i]) {
            puts("No");
            return 0;
        }
    }
    repp(i, 1, n) {
        if (aa[i] <= bb[i - 1]) {
            puts("Yes");
            return 0;
        }
    }

    sort(ba, ba + n);

    li order = 0;
    for (auto& kv : am) {
        am[kv.F] = order;
        order++;
    }
    rin{
        ba[i].S = am[ba[i].S];
    }

    li now = 0;
    li len = 1;
    while (ba[now].S != 0) {
        now = ba[now].S;
        len++;
    }
    cout << (len < n ? "Yes" : "No") << endl;


    return 0;
}

Measured memory_bytes: 11136