akhauriyash/Code-Regression huggingface dataset:
N, P = map(int, input().split())
S = input()

mods = [0] * (N+1)
for i in range(N-1, -1, -1):
  mods[i] = (int(S[i])*pow(10, N-i-1, P)+mods[i+1]) % P
c = dict()
for m in mods:
  c[m] = c.get(m, 0)+1

ans = 0
if P == 2 or P == 5:
  for i, s in enumerate(S):
    s = int(s)
    if s % P == 0:
      ans += i+1
else:
  for key in c:
    ans += c[key]*(c[key]-1)//2

print(ans)

Measured memory_bytes: 17168
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main()
{
    int r,g,b;
    cin >> r >> g >> b;
    int num = r * 100 + g * 10 + b;
    if(num % 4 == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

inline void InitRand()
{
    srand((unsigned int)time(NULL));
}

int main() {
    InitRand();
    int D; cin >> D;
    veci C(26);
    vecveci S(D,veci(26));
    veci T(D);
    REP(i,26) cin >> C[i];
    REP(i,D) REP(j,26) cin >> S[i][j];
    REP(i,D) {
        T[i] = rand()%26;
    }

    veci last_d(26);
    ll old_ans = 0;
    REP(i,D) {
        int d = i+1;
        last_d[T[i]] = d;
        old_ans += S[i][T[i]];
        REP(j,26) {
            old_ans -= C[j]*(d-last_d[j]);
        }
    }

    clock_t s = clock();

    while(1) {
        int B = rand()%D;
        int Q = rand()%26;
        int old_p = T[B];
        T[B] = Q;
        ll score = 0;
        veci last(26);
        REP(j,D) {
            int d = j+1;
            last[T[j]] = d;
            score += S[j][T[j]];
            REP(k,26) {
                score -= C[k]*(d-last[k]);
            }
        }
        if(old_ans < score) {
            old_ans = score;
        }
        else {
            T[B] = old_p;
        }
        clock_t e = clock();
        const double time = static_cast<double>(e - s) / CLOCKS_PER_SEC * 1000.0;
        if(time >= 1980) break;
    }
    REP(i,D) cout << T[i]+1 << endl;
}

Measured memory_bytes: 3704
#include <iostream>


using namespace std;

int main()
{
	int c = 0;
	while(true)
	{
		int x;
		cin >> x;
		if(x == 0)
		{
			break;
		}
		c++;
		cout << "Case " << c << ": " << x << endl;
	}
	return 0;
}


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

int gcd(int a,int b){
  if(a < b) swap(a,b);
  if(b == 0) return a;
  return gcd(b,a%b);
}

signed main(){

  int n,m; cin >> n >> m;
  string s,t; cin >> s >> t;

  bool f = 1;
  for(int i = 0; i <= n*m; i++){
    if(i*(n/gcd(n,m)) >= s.size() || i*(m/gcd(n,m)) >= t.size()) break;
    if(s[i*(n/gcd(n,m))] != t[i*(m/gcd(n,m))]) f = 0;
    //cout << s[i*(n/gcd(n,m))] << " " << t[i*(m/gcd(n,m))] << endl;
  }
  cout << (f == 1 ? n/gcd(n,m)*m : -1) << endl;

  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
int main(){
	int n,m;
	cin>>n;
	vector<string> s(n);
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	cin>>m;
	vector<string> t(m);
	for(int i=0;i<m;i++){
		cin>>t[i];
	}
	int ans=0;
	auto calc = [&](string x) {
        int buf = 0;
        for (string y: s) {
            if (y == x) buf++;
        }
        for (string y: t) {
            if (y == x) buf--;
        }
        return buf;
    };
	for (string y: s) {
        ans = max(ans, calc(y));
    }
 
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int n,m;
  while(cin>>n>>m,n+m){
    string in;
    rep(i,n)in = (char)(i) + in;
    //rep(i,n)cout<<int(in[i]+1)<<endl;
    rep(i,m){
      int a,b;
      cin>>a>>b;
      in = in.substr(a-1,b)+in.substr(0,a-1)+in.substr(a+b-1);
    }
    cout<<int(in[0]+1)<<endl;
  }
  
}

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

int main()
{
  int A, V, B, W;
  int64_t T;
  cin >> A >> V >> B >> W >> T;
  
  int64_t D, S;//Dは2人の距離,SはAがBに迫る速度
  if(B > A){D = B - A;}
  else{D = A - B;}
  S = V - W;
  
  if(S <= 0){cout << "NO" << endl;}
  else
  {
    if(S * T < D){cout << "NO" << endl;}
    else{cout << "YES" << endl;}
  }
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N; cin >> N; vector<ll> a(N); rep(i, N){cin >> a.at(i);}
    ll S = a.at(0);
    rep(i, N - 1){
        S = (S ^ a.at(i + 1));
    }
    rep(i, N){cout << (S ^ a.at(i)) << " ";}
}

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


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

int main() {

  int q = 0;
  int t = 0;
  int f = 0;
  int rc = 0;
  bool rm = false;
  long long p;
  string s,a,c;

  cin >> s >> q;

  for ( int i=1 ; i <= q ; ++i ) {
    cin >> t;
    if (t==1){
      if (rm) {
        rm = false;
      } else {
        rm = true;
      }
    }
    if (t==2) {
        cin >> f >> c; 
        if (((f==1)&&(!rm)) || ((f==2)&&(rm)))
        {
          s.insert(0,c);
        }
        else {
          s.append(c);
        }
    }
  }
  if (rm) reverse(s.begin(),s.end());
  cout << s << endl;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL<<60;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,m,n) for(int i=m;i<n;i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
static const double pi = 3.14159265358979323846;

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        ll k = n / i;
        ans += i * k * (k+1) / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  string S;
  cin >> S;
  int N = S.size();
  rep(i,N/2)
  {
    rep(j,2) S.pop_back();
    int n = S.size() / 2;
    if(S.substr(0,n)==S.substr(n,n))
    {
      cout << n * 2 << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3604
def main():
    result = sub()
    print(result)


def sub():
    a, b = [int(x) for x in (input().split())]
    result = 0
    if a > b:
        result += a
        a = a - 1
    else:
        result += b
        b = b - 1

    if a > b:
        result += a
        a = a - 1
    else:
        result += b
        b = b - 1
    return result


if __name__ == '__main__':
    main()


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

using namespace std;

const int MX = 1000001, md = 1000000007;

long long f[MX], inv[MX], f_inv[MX];

int main() {
	f[0] = f[1] = inv[1] = f_inv[0] = f_inv[1] = 1;
	for (int i = 2; i < MX; i++) {
		f[i] = f[i - 1] * i % md;
		inv[i] = md - (md / i) * inv[md % i] % md;
		f_inv[i] = f_inv[i - 1] * inv[i] % md;
	}
	
	int n;
	ignore = scanf("%d", &n);
	
	if (n == 2) {
		printf("%d\n", 1);
		return 0;
	}
	
	int ans = 0, sum = 0;
	for (int k = 2; k < n; k++) {
		if (n - 1 - k > k - 1) continue;
		
		int x = f[k - 1] * f[k] % md * f_inv[2 * k - n] % md;
		ans = (ans + (x - sum + md) * (long long)(k)) % md;
		sum = x;
	}
	
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;



int main(){//mapを使えば重複を数えやすい、二項係数を使う時はn*(n-1)/2を使うとO(N)で早い
    ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    V a(n);
    ll cnt=0;
    map<int,ll> mp;
    REP(i,n) {
        cin >> a[i];
        mp[a[i]]++;//a[i]をキーとする値がカウントするたびに１つ増える
        
    }

    for(auto x:mp){//全ての二項係数の和を計算した
        //cout << x.first << " " << x.second << endl;
        cnt += (ll)x.second*(x.second -1)/2;
        
    }

    REP(i,n){
    cout << cnt -(mp[a[i]]-1)<< endl;//i番目の整数と同じ数のボールmp[a[i]]個のうち、i番目のボールとmp[a[i]]-1個の内から１つボールをとる組み合わせmp[a[i]]-1を引いてやれば良い
    }

}

Measured memory_bytes: 10368
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    string S, T, Z, X;

    cin >> S;
    cin >> T;


    Z = S.substr(0, S.size()) + S.substr(0, S.size());

    for(int i = 0; i < S.size(); i++){
        X.clear();
        X = Z.substr(i, S.size());
        if (X == T){
            cout << "Yes" <<endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

int check(int num){
  int count=0;
  int tmp=1; 
  while(num>tmp){
  	tmp=tmp*2;
  	count++;
  }
  return count;
}




double calc(int n,int m,int l){
  int num,tmp;
  if(m%n==0){
    tmp=m/n;
  }else{
  	tmp=(m/n) +1;
  }
  return pow(0.5,check(tmp))/l;
}


int main(){
  int a,b;
  double prob;
  cin >>a>>b;
  for(int i=1; i<a+1;i++){
  	double tmp;
  	tmp=calc(i,b,a);
  	prob = prob+tmp;
  }
  printf("%.12f\n", prob);
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<iomanip>


using namespace std;

int main(){
    
    int N;
    int Alice=0;
    int Bob=0;
    int tmp,jtmp;

    cin >> N;

    int a[N];

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

    for(int i=1;i<N;++i){
        tmp = a[i];
        jtmp = i;
        for(int j=i-1;j>=0;--j){
            if(tmp>a[j]){
                a[j+1] = a[j];
                jtmp = j;
            }
        }
        a[jtmp] = tmp;
    }


    for(int i=0;i<N/2;++i){
        Alice += a[2*i];
        Bob += a[2*i+1];
    }
    
    if(N%2){
        Alice += a[N-1];
    }

    cout << fixed << setprecision(20) << Alice - Bob;

}



Measured memory_bytes: 256
x,n = map(int,input().split())
p = list(map(int,input().split()))
flag = [True] * 102

for i in p:
    flag[i] = False

for i in range(101):
    low = max(x-i, 0)
    high = min(x+i, 101)
    if flag[low]:
        print(low)
        break
    elif flag[high]:
        print(high)
        break


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

int main() {
  int n, m, ans = 0;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    ans += a;
  }
  cout << max(n - ans, -1) << endl;
}

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

int main() {
  char A;
  cin >> A;
  if(A == 'A'){
    cout << 'T' << endl;
  }
  else if(A == 'T'){
    cout << 'A' << endl;
  }
  else if(A == 'G'){
    cout << 'C' << endl;
  }
  else if(A == 'C'){
    cout << 'G' << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <climits>
using namespace std;
 
int main() {
	int n;
	cin >> n;
	vector<int> v;
	for (int i=0; i<n; ++i) {
		int a;
		cin >> a;
		v.push_back(a);
	}
	long snuke_ = accumulate(v.begin(), v.end(), (long long) 0);
	long raccoon = 0;
	long res = LONG_MAX;
	for (int i=n-1; i>0; --i) {
		int a = v[i];
		snuke_ -= a;
		raccoon += a;
		res = min(res, abs(snuke_-raccoon));
	}
	cout << res << endl;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			long[] a = in.nextLongArray(n);
			long count = 0;
			for (int i = n - 1; i > 0; i--) {
				count += a[i] / 2;
				a[i] -= (a[i] / 2) * 2;
				if (a[i] == 1 && a[i-1] >= 1) {
					count++;
					a[i-1]--;
					a[i]--;
				}
			}
			count += a[0] / 2;
			out.println(count);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

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

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

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

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

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}
}


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

int main() {
	// your code goes here
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b+c>=22){
		cout<<"bust";
	}
	else{
		cout<<"win";
	}
	
	// SUN, MON, TUE, WED, THU, FRI, or SAT, 
	return 0;
}

Measured memory_bytes: 256
import sys
import collections

sys.setrecursionlimit(10 ** 8)
ni = lambda: int(sys.stdin.readline())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
ns = lambda: sys.stdin.readline().rstrip()


def solve():
    N, M = nm()
    uf = UnionFind(M)
    lang_spoken = set()
    for i in range(N):
        k, *lang = nm()
        assert len(lang) == k
        roots = {uf.find(l - 1) for l in lang}
        lang_spoken |= roots
        rit = iter(roots)
        x = next(rit)
        for y in rit:
            uf.union(x, y)
    lang1 = next(iter(lang_spoken))
    return uf.size(lang1) == len(lang_spoken)


class UnionFind:
    def __init__(self, n):
        # total number of nodes.
        self.n = n
        # node id -> root node id
        self._root_table = list(range(n))
        # root node id -> group size
        self._size_table = [1] * n

    def find(self, x):
        """Returns x's root node id."""
        r = self._root_table[x]
        if r != x:
            # Update the cache on query.
            r = self._root_table[x] = self.find(r)
        return r

    def union(self, x, y):
        """Merges two groups."""
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        # Ensure that x is the larger (or equal) group.
        if self._size_table[x] < self._size_table[y]:
            x, y = y, x

        self._size_table[x] += self._size_table[y]
        self._root_table[y] = x

    def size(self, x):
        return self._size_table[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self._root_table) if x == i]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return "\n".join("{}: {}".format(r, self.members(r)) for r in self.roots())


print(["NO", "YES"][solve()])


Measured memory_bytes: 12620
# -*- coding: utf-8 -*-
K, N = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
D = []
D.append(A[N-1]-A[0])
for i in range(1, N):
  D.append(A[i-1]+K-A[i])

print(min(D))


Measured memory_bytes: 26444
n,k = map(int, input().split())
r,s,p = map(int, input().split())
t = list(input())
ans = 0

hand = []

for i in range(k):
    if t[i] == 'r':
        ans += p
        hand.append('p')
    elif t[i] == 's':
        ans += r
        hand.append('r')
    else:
        ans += s
        hand.append('s')

for i in range(k, n):
    if t[i] == 'r':
        if hand[i - k] != 'p':
            ans += p
            hand.append('p') 
        else:
            if i + k < n:
                if t[i + k] == 's':
                    hand.append('s')
                elif t[i + k] == 'p':
                    hand.append('r')
                else:
                    hand.append('s')
            else:
                hand.append('s')
    elif t[i] == 's':
        if hand[i - k] != 'r':
            ans += r
            hand.append('r') 
        else:
            if i + k < n:
                if t[i + k] == 'r':
                    hand.append('s')
                elif t[i + k] == 'p':
                    hand.append('p')
                else:
                    hand.append('s')
            else:
                hand.append('s')
    else:
        if hand[i - k] != 's':
            ans += s
            hand.append('s') 
        else:
            if i + k < n:
                if t[i + k] == 'r':
                    hand.append('r')
                elif t[i + k] == 's':
                    hand.append('p')
                else:
                    hand.append('r')
            else:
                hand.append('r')
print(ans)

Measured memory_bytes: 4828
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ld PI = 2 * acos(0.0);
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    ll d=power(a,b/2,m);
    d=(d*d)%m;
    if(b&1)
        d=(d*a)%m;
    return d;
}
const ll mod=1e9+7;
int MOD(int a)
{
    if(a<0)
        a+=mod;
    if(a>=mod)
        a%=mod;
    return a;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int a;
    ld b;cin>>a>>b;
    // int b1=b*100.0;
    int ans=a*b;
    // ans/=100;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3784
#include <stdio.h>
#include <math.h>
#define MAX 1000
#define LENGTH 168

typedef struct {
  int prime;
  int cnt;
} Number;

int main(void)
{
  int i, j;
  int k = 0;
  int p[MAX];
  int N_0;
  Number q[LENGTH];
  long long n = 1;
  long long m = 7+pow(10,9);

  //---初期化---
  for(i=0 ; i<MAX ; i++) {
      p[i] = 0;
      p[0] = 1;
  }

  for (i=0;i<LENGTH;i++){
      q[i].cnt = 1;
      q[i].prime = 0;
  }


  //---倍数を除外---
  for(i=2 ; i<=MAX/2 ; i++){
    for(j=2 ; i*j<=MAX ; j++){
      if(p[i*j-1] == 0){
          p[i*j-1] = 1;
      }
    }
  }
  for(i=0 ; i<MAX ; i++){
    if(p[i] == 0){
        q[k].prime = i+1;
        //printf("%d\n", q[k].prime);
        k++;
    }

  }

//   for(int test = 0; test < 168; test++){
//       printf("%d\n", q[test]);
//   }

  //ここから一つずつの素数をカウント

  scanf("%d",&N_0);

  for(i = 1; i <= N_0; i++){
      for(j = 0; j < LENGTH; j++){
          if(q[j].prime <= i){
              int k = i;
              while(k%q[j].prime == 0){
                  q[j].cnt++;
                  k = k/q[j].prime;
                  //printf("%d\n",k);
              }
          }
      }
  }

  for(i = 0; i < LENGTH; i++){
      //printf("%d -> %d\n",q[i].prime,q[i].cnt);
      n = n * q[i].cnt;
      if(n > m){
          n = n % m;
      }
  }

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

  return 0;
}

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

using namespace std;

long inv(int a, int m) {
	long i = 1, j = 0;
	for (int b = m; a > 1; swap(i, j), swap(a, b)) {
		j = (j + b / a * (m - i)) % m;
		b %= a;
	}
	return i;
}
int m = 1e9 + 7, f[1111] = { 1 };
long P[2][1111], c[2], q[3], r = 1;
int main() {
	int n, d = 1;
	string s;
	cin >> n >> s;
	if (s[0] != 'X')
		P[0][0] = c[0] = 1, r = m - 1;
	for (int i = 1; i < n; i++) {
		f[i] = f[i - 1] * inv(i, m) % m;
		P[0][d] = r;
		P[1][d++] = 0;
		r = (m - r) % m;
		if (s[i] != 'X') {
			for (int j = 0; j < 2; j++) {
				c[j] = (P[j][d - 1] + r * j) % m;
				for (int k = 1; k < d; k++)
					(c[j] += P[j][d - 1 - k] * f[k]) %= m;
			}
			if (s[i - 1] != 'X')
				d = 1, P[0][0] = P[1][0] = r = 0;
			continue;
		}
		for (int j = 0; j < 2; j++) {
			(P[j][d - 1] += c[j]) %= m;
			(P[j][d - 2] += m - c[j]) %= m;
		}
		if (s[i - 1] == 'X') {
			cout << "0 0 0" << endl;
			return 0;
		}
	}
	q[0] = r * inv(2, m) % m;
	q[2] = (m - q[0]) % m;
	for (int i = 0; i < d; i++) {
		for (int j = 0; j < 2; j++) {
			(q[j] += P[j][d - 1 - i]) %= m;
			(q[j + 1] += P[j][d - 1 - i] * (m - f[i])) %= m;
		}
		(f[i + 1] += f[i]) %= m;
	}
	if (s[n - 1] != 'X')
		for (int j = 0; j < 2; j++)
			(q[j + 1] += c[j]) %= m;
	cout << q[0] << ' ' << q[1] << ' ' << q[2] << endl;
	return 0;
}


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

dct_a_tmp = {}
dct_b = {}
for n in range(N):
  a,b = map(int, input().split())
  dct_a_tmp[n] = a
  dct_b[n] = b

# 安い順にkeyをソート
list_a = sorted(dct_a_tmp.items(), key=lambda x: x[1])


# 安い順に買っていく
'''
1.不足本数を計算
2.不足本数と購入できる本数を比較する
a.全部購入していいようなら通常購入
b.ダメなら、購入していい本数だけ購入
'''
cnt_buied = 0
cost = 0
inf = 10 ** 18


for i in range(inf):
  want_buy = M - cnt_buied 
  
  if dct_b[list_a[i][0]] <= want_buy:
    cost += list_a[i][1] * dct_b[list_a[i][0]]
    cnt_buied += dct_b[list_a[i][0]] 
  else:
    cost += list_a[i][1] * want_buy
    cnt_buied += want_buy
    
  if cnt_buied >= M:
    break

print(cost)

Measured memory_bytes: 33476
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int a,p; cin >> a >> p;
    p += a*3;
    cout << p/2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

int main() {
  int q,l;
  cin>>l>>q;
  string s;
  cin>>s;
  int ez_accepted[s.length()+1];
  for(int i=0;i<s.length();i++){
    ez_accepted[i]=0;
  }
  int counter = 0;
  for(int i=0;i<s.length();i++){
    ez_accepted[i]=counter;
     if(s[i]=='A'&&s[i+1]=='C'){
        counter++;
     }
  }
  for(int i=0;i<q;i++){
    int l,r;
    cin>>l>>r;
    l--;
    r--;
    cout<<ez_accepted[r]-ez_accepted[l]<<endl;
  }
  return 0;
}


Measured memory_bytes: 1408
s = input()
f = int(s[0:2])
l = int(s[2:])

if 1 <= f <= 12:
	if 1 <= l <= 12:
		print("AMBIGUOUS")
	else:
		print("MMYY")
else:
	if 1 <= l <= 12:
		print("YYMM")
	else:
		print("NA")

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define LiangJiaJun main
using namespace std;
int n;
struct data{
    int c,s,f;
}a[504];
int LiangJiaJun(){
    scanf("%d",&n);
    for(int i=1;i<n;i++)scanf("%d%d%d",&a[i].c,&a[i].s,&a[i].f);
    for(int i=1;i<n;i++){
        int T=a[i].s;
        T+=a[i].c;
        for(int j=i+1;j<n;j++){
            if(T<a[j].s)T=a[j].s;
            else{
                while((T-a[j].s)%a[j].f!=0)++T;
            }
            T+=a[j].c;
        }
        printf("%d\n",T);
    }
    puts("0");
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int nums[101]={0};
    int i, n, max=0;

    while(scanf("%d", &n) != EOF){
        nums[n]++;
    }

    for(i=0; i<=100;i++){
        if(max < nums[i]){
            max = nums[i];
        }
    }

    for(i=0; i<=100;i++){
        if(nums[i] == max){
            printf("%d\n",i);
        }
    }

    return 0;
}

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

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    List<Integer> heights = new ArrayList<Integer>();

    for (int i = 0; i < 10; i++) {
      int val = sc.nextInt();
      heights.add(val);
    }

    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
        if (heights.get(i) > heights.get(j)) {
          int tmp = heights.get(i);
          heights.set(i, heights.get(j));
          heights.set(j, tmp);
        }
      }
    }

    for (int i = 0; i < 3; i++) {
      System.out.println(heights.get(i));
    }
  }
}

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

int main(){
    int N;
    cin >> N;
    
    vector<pair<int,int>> robot;
    rep(i,N){
        int x,l;
        cin >> x >> l;
        robot.push_back(pair(x+l,x-l));
    }
    
    sort(robot.begin(), robot.end());
    
    int ans=1;
    int now=robot[0].first;
    
    for (int i = 1; i < N; i++) {
        int y = robot[i].second;
        if(y>=now){
            now = robot[i].first;
            ans++;
        }
    }
    
    cout << ans << endl;
    
    // rep(i,N){
    //     int x,y;
    //     x = robot[i].first;
    //     y = robot[i].second;
    //     cout << x << " " << y << endl;
    //}
}


Measured memory_bytes: 4296
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <climits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstring>
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>

using namespace std;
typedef long long ll;
#define ln '\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define drep(i,n) int i = 0;for(;i<(n);++i)
#define FOR(i,s,e) for(int i=s;i<=(e);++i)
#define FORR(i,s,e) for(int i=s;i>=(e);--i)
#define fore(a, x) for(auto& a : x)
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ft first
#define sd second
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define Fill(a,b) memset(a,b,sizeof(a))
template<typename T1, typename T2> bool Max(T1& a, T2 b) { return a<b ? a = b, 1 : 0; }
template<typename T1, typename T2> bool Min(T1& a, T2 b) { return a>b ? a = b, 1 : 0; }
struct UnionFind {
  vector<int> data;
  void init(int n) { data.assign(n, -1); }
  bool un(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool same(int x, int y) { return root(x) == root(y); }
  int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
  int size(int x) { return -data[root(x)]; }
};


const int N = 300, K = 17, inf = 1e9 + 1;
ll a[N][N];
ll d[N][N];


void solve() {
  int n;
  cin >> n;
  vector<pair<int, pii>> vec;
  rep(i, n)rep(j, n)cin >> a[i][j];
  rep(i, n)rep(j, n)vec.emplace_back(a[i][j], pii(i, j));
  sort(all(vec));
  rep(i, n)rep(j, n)d[i][j] = inf;
  rep(i, n)d[i][i] = 0;
  ll ans = 0;
  fore(e, vec) {
    int x = e.sd.ft, y = e.sd.sd;
    if (Min(d[x][y], e.ft)) {
      d[y][x] = d[x][y];
      ans += e.ft;
      rep(i, n)rep(j, n) {
        Min(d[i][j], d[i][x] + d[y][j] + e.ft);
        Min(d[i][j], d[i][y] + d[x][j] + e.ft);
        if (d[i][j] < a[i][j]) {
          cout << -1 << ln;
          return;
        }
      }
    }
  }
  cout << ans << ln;
}



void init() {
}

int main(void) {
  ios::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
  //freopen("C:\\Users\\LENOVO\\Documents\\Visual Studio 2015\\Projects\\Test\\Input\\in.in", "r", stdin);

  init();
  int TC = 1;
#if 0
  cin >> TC; cin.get();
#endif
  FOR(TI, 1, TC) {
    //cout << "Case #" << TI << ": ";
    solve();
  }
  
  
  return 0;
}



Measured memory_bytes: 2804
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int main(){
    #define int long long
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    cin >> n >> m;
    vector <int> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    int ans = 0;
    for(int i = -1; i < n; ++i){
        for(int j = n; j > i; --j){
            int sc = 0;
            vector <int> bad;
            int y = 0;
            for(int i1 = 0; i1 <= i; ++i1){
                ++y;
                if(a[i1] < 0)bad.push_back(a[i1]);
                sc += a[i1];
            }
            for(int i1 = j; i1 <= n-1; ++i1){
                ++y;
                if(a[i1] < 0)bad.push_back(a[i1]);
                sc += a[i1];
            }
            if(y > m)continue;
            else {
                sort(bad.begin(), bad.end());
                for(int i1 = 0; i1 < min(m-y,(int)bad.size()); ++i1){
                    sc -= bad[i1];
                }
                ans = max(sc, ans);
            }
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
def main():
    a, b, c, x, y = map(int, input().split())
    ans = []
    ans.append(x * a + y * b)
    if x > y:
        ans.append(a * (x - y) + c * y * 2)
    else:
        ans.append(b * (y - x) + c * x * 2)
    ans.append(max(x, y) * c * 2)
    print(min(ans))


if __name__ == '__main__':
    main()

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll N; cin>>N;
  vector<ll> A(N);
  rep(i,N) cin>>A[i];
  sort(A.bg,A.ed);
  cout<<A[N-1]-A[0];
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
const int mod = 1000000007;
int N, W;
int main() {
	cin >> N >> W;
	vector<int> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];
	sort(a.begin(), a.end());
	int ret = 0, sum = 0;
	for (int i = 0; i < N; i++) {
		if (i >= 1) sum += a[i - 1];
		if (sum > W) break;
		vector<vector<int> > dp(N - i, vector<int>(W - sum + 1, 0));
		dp[0][0] = 1;
		for (int j = 0; j < N - i - 1; j++) {
			for (int k = 0; k <= W - sum; k++) {
				dp[j + 1][k] += dp[j][k];
				if (k >= a[j + i + 1]) {
					dp[j + 1][k] += dp[j][k - a[j + i + 1]];
					if (dp[j + 1][k] >= mod) dp[j + 1][k] -= mod;
				}
			}
		}
		for (int k = 0; k <= W - sum; k++) {
			if (k > W - sum - a[i]) {
				ret += dp[N - i - 1][k];
				if (ret >= mod) ret -= mod;
			}
		}
	}
	sum += a[N - 1];
	if (sum <= W) {
		ret++;
		if (ret >= mod) ret -= mod;
	}
	cout << ret << endl;
	return 0;
}

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



Measured memory_bytes: 2120
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = n % 10;
        n /= 10;
        int b = n % 10;
        n /= 10;
        int c = n % 10;
        n /= 10;
        int d = n % 10;
        if (a == b && b == c) {
            System.out.println("Yes");
        } else if (b == c && c == d) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

}

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

int main(){
  string A,B;
  cin >> A >> B;
  if(A.size()>B.size()){
    cout << "GREATER" << endl;
    return 0;
  }else if(A.size()<B.size()){
    cout << "LESS" << endl;
    return 0;
  }
  int N=A.size();
  for(int i=0;i<N;i++){
    if(A[i]>B[i]){
      cout << "GREATER" << endl;
      return 0;
    }else if(A[i]<B[i]){
      cout << "LESS" << endl;
      return 0;
    }
  }
  cout << "EQUAL" << endl;
}

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

int main()
{
    int a, b;
    string s;
    int f = 0, cnt = 0;
    cin >> a >> b >> s;
   if(s.size() != a+b+1) {cout << "Yes" << endl; return 0;}
   for(int i = 0; i < s.size(); i++)
   {
       if(s[i] == '-') cnt++;
       if(!(s[i]>='0' || s[i]<= '9' || s[i]=='-'))
        { f = 1; break; }
   }
   if(f) {cout << "No" << endl; return 0;}
    if (s[a] != '-') {cout << "No" << endl; return 0;}
    if(cnt > 1) {cout << "No" << endl; return 0;}
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long LL;

using namespace std;
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    LL a[n];
    LL sum=0;
    for(int i=0;i<n;i++){
        int b;
        cin >> b;
        sum += b;
        a[i] = 2*b;
    }
    sum -= a[0];
    LL min=abs(sum);
    for(int i=1;i<n-1;i++){
        sum-=a[i];
        if(min>abs(sum)) min=abs(sum);
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 1792
def resolve():
    '''
    code here
    '''
    S = [item for item in input()]

    res = 0
    w_cnt = 0
    for i, v in enumerate(S):
        if v == 'W':
            res += i+1
            w_cnt += 1

    res -= w_cnt * (w_cnt + 1)//2
    print(res)
if __name__ == "__main__":
    resolve()


Measured memory_bytes: 5096
extern crate num;

use std::collections::HashMap;

macro_rules! get_one {
    ($t:ty) => {{
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse::<$t>().unwrap()
    }};

    ($t:ty; $n:expr) => {
        (0..$n).map(|_| get_one!($t)).collect::<Vec<_>>()
    };
}

fn main() {
    let s = get_one!(String);
    let s_rev = s.chars().rev();

    // 10^n を 2019 で割ったときの余り
    let mut res_pow_10 = 1;
    // s を右から数えて n 桁とってきたときの数字を 2019 で割ったときの余り
    let mut res = 0;
    // res を格納していく
    let mut v_res = vec![0];
    for c in s_rev {
        let num = c.to_digit(10).unwrap();
        res = (res + res_pow_10 * num) % 2019;
        res_pow_10 = (res_pow_10 * 10) % 2019;
        v_res.push(res);
    }

    let mut map_count: HashMap<u32, u32> = HashMap::new();
    for res in v_res {
        map_count.entry(res)
            .and_modify(|e| {*e += 1})
            .or_insert(1);
    }

    let ans: u32 = map_count.into_iter().map(|(_, v)| v * (v - 1) / 2).sum();

    println!("{}", ans);

}


Measured memory_bytes: 3336
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#include <cctype>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)

#define AAA (1000000007) 


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;
typedef vector<int> vecI;

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll powD(ll a, ll b) {
	ll ans = 1;
	a %= AAA;
	for (int i = 0; i < b; i++)
	{
		ans *= a;
		ans %= AAA;
	}
	return ans;
}


int main() {
	int i, j, k;
	int N, M, K;
	
	string S;
	cin >> S;
	int ans = 0;
	int num = 0;
	num += (S[0] == 'R');
	rep(i,1, 3) {
		num += (S[i] == 'R');
		if (S[i - 1] == 'R' && S[i] == 'R')ans++;
	}
	cout << ans + (num > 0);
	return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>

using namespace std;

int main(){
  string s;
  cin >> s;
  
  int price = 700;
  if(s[0] == 'o') price += 100;
  if(s[1] == 'o') price += 100;
  if(s[2] == 'o') price += 100;
  
  cout << price;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define int long long
using namespace std;
signed main() {
	int X, a, b;
	cin >> X >> a >> b;

	if (abs(a - X) > abs(b - X)) {
		cout << "B" << endl;
	}
	else {
		cout << "A" << endl;
	}
}

Measured memory_bytes: 3648
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
long long dp[62][2][2][2] = {};

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  long long l, r; cin >> l >> r;
  dp[61][0][0][0] = 1;
  for (int i = 61; i > 0; --i) REP(j, 2) REP(k, 2) REP(m, 2) {
    REP(x, 2) REP(y, 2) {
      if (x == 1 && y == 0) continue;
      int nx_j = j;
      if (j == 0) {
        if (l >> (i - 1) & 1) {
          if (x == 0) continue;
        } else {
          if (x == 1) nx_j = 1;
        }
      }
      int nx_k = k;
      if (k == 0) {
        if (!(r >> (i - 1) & 1)) {
          if (y == 1) continue;
        } else {
          if (y == 0) nx_k = 1;
        }
      }
      int nx_m = m;
      if (m == 0) {
        if (x == 0 && y == 1) continue;
        if (x == 1 && y == 1) nx_m = 1;
      }
      (dp[i - 1][nx_j][nx_k][nx_m] += dp[i][j][k][m]) %= MOD;
    }
  }
  long long ans = 0;
  REP(j, 2) REP(k, 2) (ans += dp[0][j][k][1]) %= MOD;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
# AGC018
import fractions
import functools

def gcd_list(num_list):
    return functools.reduce(fractions.gcd, num_list)

N, K = map(int, input().split())
A = list(map(int, input().split()))
A = list(set(A))
if K in A:
    print("POSSIBLE")
    exit()

if K > max(A):
    print("IMPOSSIBLE")
    exit()

#print(gcd_list(A))
tmp = gcd_list(A)
if tmp == 1 or K % tmp == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 16460
#include<stdio.h>
  int main(void)
  {
   int A,B; //年齢Aと基本料金B
   
    scanf("%d",&A);
    scanf("%d",&B);
   if(A>=13){
     printf("%d",B);
   }else if(A>=6 && A<=12){
     B=B/2;
     printf("%d",B);
   }else{
     B=0;
     printf("%d",B);
   }
 
   return 0;
 }


Measured memory_bytes: 128
a1 = gets.split.map(&:to_i)
a2 = gets.split.map(&:to_i)
a3 = gets.split.map(&:to_i)
n = gets.to_i
nums = []
n.times do
  nums << gets.to_i
end

combinations = [
  a1,
  a2,
  a3,
  [a1[0], a2[0], a3[0]],
  [a1[1], a2[1], a3[1]],
  [a1[2], a2[2], a3[2]],
  [a1[0], a2[1], a3[2]],
  [a1[2], a2[1], a3[0]],
]

exist = combinations.any? do |comb|
  (comb - nums).empty?
end

if exist
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 1788
N,M,C = map(int, input().split())

B = list(map(int,input().split()))
    
A = []
for i in range(N):
    A.append(list(map(int,input().split())))
    
count = 0
for i in range(N):
    su = 0
    for j in range(M):
        su += A[i][j] * B[j]
    if su + C > 0:
        count += 1
        
print(count)

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

int x,r;
vector <int> d;

long long f(long long a,long long b)
{
	return a*a*a*a+b*b*b*b+a*b*b*b+b*a*a*a+a*a*b*b;
}

int main()
{
	cin>>x;
	r=sqrtl(x);
	for(int i=1;i<=r;i++)
	{
		if(x%i!=0) continue;
		d.push_back(i);
		d.push_back(x/i);
	}

	if(r*r==x) d.pop_back();
	//a5 - b5 = ( a - b ) × ( a4 + a3b + a2b2 + ab3 + b4 )

	for(auto diff:d)
	{
		for(int b=1;b<=200;b++)
		{
			int a=b+diff;
			long long val=f(a,b);
			if(val==x/diff) return 0 * printf("%d %d",a,b);
			if(val>x/diff) break;
		}

		for(int b=-1;b>=-200;b--)
		{
			int a=b+diff;
			long long val=f(a,b);
			if(val==x/diff) return 0 * printf("%d %d",a,b);
		}
	}
}

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

int main() {
  int k, x;
  cin >> k >> x;
  string ans = 500 * k >= x ? "Yes" : "No";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  int n, k;
  cin >> n >> k;
  vector<bool> v(n, false);
  int ans = n;
  rep(i, k){
    int d;
    cin >> d;
    rep(j, d){
      int a;
      cin >> a;
      a--;
      if(!v[a]){
        ans--;
        v[a] = true;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef pair<int,int> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr> PQ;
const int SIZE=2*5+1e5;
const int INF=10+1e9;
const LL p =7+1e9;

int main(){
	LL x;
	cin >> x;
	LL ans=x/11*2;
	if(x%11==0);
	else if(x%11>6) ans+=2; 
	else ans++;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256