akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define MAX 1000000
typedef long long llong;

int n, k;
llong T[MAX];

int check(llong P){
    int i = 0;
    int j;
    llong s;
    
    for(j = 0; j < k; j++){
        s = 0;
        while(s + T[i] <= P){
            s += T[i];
            i++;
            if(i == n) return n;
        }
    }
    return i;
}

int solve(){
    int v;
    llong left = 0;
    llong right = 100000 * 100000;
    llong mid;

    while(right - left > 1){
        mid = (left + right) / 2;
        v = check(mid);
        if(v >= n) right = mid;
        else left = mid;
    }
    return right;
}

int main(void){
    int i;
    llong ans;

    scanf("%d %d", &n, &k);
    for(i = 0; i < n; i++){
        scanf("%d", &T[i]);
    }
    ans = solve();
    printf("%d\n", ans);

    return 0;
}


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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

const int INF = 1e9;
const ll LINF = 1e18;


int main() {
    int n;
    cin >> n;

    vector<string> s(n);
    rep(i, n) cin >> s[i];

    sort(all(s));
    s.push_back("");

    string temp = "";
    int cnt = 0;
    int max = 0;
    vector<string> res;

    rep(i, n + 1) {
        if (temp == s[i]) {
            cnt++;
        } else {
            if (cnt == max) {
                if (temp != "")
                    res.push_back(temp);
            } else if (cnt > max) {
                max = cnt;
                res.clear();
                res.push_back(temp);
            }

            temp = s[i];
            cnt = 0;
        }
    }

    for (auto x : res)
        cout << x << endl;

    return 0;
}


Measured memory_bytes: 17892
import itertools,sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
A = LI()
ans = 0
for x in [x for x in itertools.product([-1,0,1],repeat=N)]:
    calc = 1
    for i in range(N):
        calc *= A[i]+x[i]
    if calc%2==0:
        ans += 1
print(ans)


Measured memory_bytes: 11252
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int n = sc.nextInt();
        long x = 1;
        for(int i = 1;i <= d;i++){
            x *= 100;
        }
        if(n < 100){
            System.out.println(x*n);
        }
        else{
            System.out.println(x*n+x);
        }
    }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
const int maxn=100100;
multiset<int> sak;
struct node{
	int x,y,op;
}a[maxn];
bool cmp(const node &A,const node &B){
	return A.x>B.x;
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a[i].x,&a[i].y);
		a[i].op=0;
	}
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a[i+n].x,&a[i+n].y);
		a[i+n].op=1;
	}
	sort(a+1,a+n*2+1,cmp);
	multiset<int>::iterator it;
	int ans=0;
	for(int i=1;i<=n*2;i++){
		if(a[i].op==1)
			sak.insert(a[i].y);
		else{
			it=sak.lower_bound(a[i].y);
			if(it!=sak.end()){
				ans++;
				sak.erase(it);
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "string"
using namespace std;

int main() {
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	int x = a + b + c + d;
	cout << x - min(min(a, b), min(c, d)) + max(e, f) << endl;
}


Measured memory_bytes: 3092
using System;
using System.Linq;

namespace atcoder.abc168.c
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inputArray = getIntParams();
            double A = (double)inputArray[0];
            double B = (double)inputArray[1];
            double H = (double)inputArray[2];
            double M = (double)inputArray[3];

            double angleA = (H + M / 60) * 30;
            double angleB = M * 6;
            double angle = angleA - angleB;

            // 余弦定理 a2 = b2 + c2 - 2bc * cos(A)
            double ret = Math.Sqrt(Math.Pow(A, 2) + Math.Pow(B, 2) - (2 * A * B * Math.Cos(angle * (Math.PI / 180))));

            Console.WriteLine(ret);
        }

        //↓↓↓ shared function ↓↓↓
        static int getIntParam()
        {
            return int.Parse(Console.ReadLine());
        }
        static int[] getIntParams()
        {
            return Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        }
        static long getLongParam()
        {
            return long.Parse(Console.ReadLine());
        }
        static long[] getLongParams()
        {
            return Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
        }
        static string getStringParam()
        {
            return Console.ReadLine();
        }
        static string[] getStringParams()
        {
            return Console.ReadLine().Split(' ');
        }
        static decimal getDecimalParam()
        {
            return decimal.Parse(Console.ReadLine());
        }
        static decimal[] getDecimalParams()
        {
            return Console.ReadLine().Split(' ').Select(i => decimal.Parse(i)).ToArray();
        }
    }
}


Measured memory_bytes: 28716
//
//  main.cpp
//  A - Red or Not
//
//  Created by Hashizo on 2019/08/18.
//  Copyright © 2019 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>

using namespace std;

#undef LONG_MAX
#undef LONG_MIN

#define LONG_MAX	9223372036854775807
#define LONG_MIN	(-LONG_MAX  -1)

#define ll long long

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

int main(int argc, const char * argv[]) {
	ll a;
	string s;
	cin >> a >> s;

	if(3200 <= a)
		cout << s << endl;
	else
		cout << "red" << endl;

	return 0;
}


Measured memory_bytes: 256
h,w = map(int,input().split())
a_list = [input() for nesya in range(h)]

gyo = [False]*h
retsu = [False]*w
for i in range(h):
  for j in range(w):
    if a_list[i][j] == '#':
      gyo[i] = True
      retsu[j] = True
for k in range(h):
  if gyo[k]:
    for l in range(w):
      if retsu[l]:
        print(a_list[k][l], end='')
    print()

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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n;
	cin >> n;

	vector<ll> a(n);
	for (auto &v : a) {
		cin >> v;
	}

	ll sum = accumulate(begin(a), end(a), 0LL, [](ll res, ll v) {
		return res + v;
	});

	cout << (sum & 1 ? "NO" : "YES") << endl;
	return 0;
}


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

typedef long long ll;
typedef long double ld;

const int N=100100;
main(){
	cin.tie(0);cin.sync_with_stdio(0);
	ll n,x,m;cin>>n>>x>>m;
	ll res=0;
	set<ll>c;
	vector<ll>nums(N,0);
	for(ll i=0;i<n&&x%m;++i){
		if(c.count(x)){
			ll idx=0,sm=0,oversm=0;
			while(nums[idx]!=x)++idx;
			for(ll j=idx;j<i;++j)sm+=nums[j];
			ll len=i-idx;
			ll cnt=(n-i)/len;
			ll over=n-i-((n-i)/len*len);
			for(ll j=idx;j<idx+over;++j)oversm+=nums[j];
			res=res+cnt*sm+oversm;
			break;
		}
		c.insert(x);
		nums[i]=x;
		res+=x;
		x=x*x%m;
	}
	cout<<res<<endl;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

signed main() {
  int N, Q, sum = 0;
  cin >> N >> Q;
  string str = readString();
  vi isAC(N, 0);
  REP(i, N - 1) {
    if (str[i] == 'A' && str[i + 1] == 'C') {
      sum++;
      isAC[i] = sum;
    }
  }
  int l, r, ans;
  REP(i, Q) {
    l = read();
    r = read();
    ans = 0;
    for (int j = r - 2; j >= l - 1; j--) {
      if (isAC[j]) {
        ans = isAC[j];
        break;
      }
    }
    if (ans) {
      for (int j = l - 2; j >= 0; j--) {
        if (isAC[j]) {
          ans -= isAC[j];
          break;
        }
      }
    }
    print(ans);
  }
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i,n) for(ll i = 0;i < (ll)(n);i++)
#define INF 1000000001
#define MAXN 20001
#define MAXM 101
int main()
{
    int a,b,rec = 0;
    cin >> a >> b;
    for(int i = a;i <= b;i++){
        //if(i % 11111 == 0)rec++;
        if(i / 10000 == i % 10 && i % 10000 / 1000 == i % 100 / 10){
            //if(i % 1000 / 100 != i % 10000 / 1000 && i % 1000 / 100 != i % 1000 / 10){
                rec++;
            //}
        }

    }
    cout << rec << endl;


    return 0;
}
/*
    REP(i,a){
        REP(j,b){

        }
    }
    */



Measured memory_bytes: 256
// C - Green Bin
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, n, w, ans = 0, count = 0;
  string t;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> n;
  vs s(n);
  vlli d(26, 0);
  map<string, lli> g;
  rep(i, 0, n)
  {
    cin >> s[i];
    SORT(s[i]);
    if (g[s[i]] != 0)
    {
      g[s[i]]++;
      ans += g[s[i]] - 1;
    }
    else
    {
      g[s[i]]++;
    }
  }
  // for (auto x : g)
  // {
  //   ans += x.second;
  // }
  cout << ans << endl;
}

Measured memory_bytes: 14272
S=input()
ans=0
i=len(S)-1
while len(S)>1 and i>0:
  if S[i]!=S[i-1]:
    S=S[:i-1]+S[i+1:]
    if i==len(S)+1:
      i-=1
    ans+=2
  i-=1
print(ans)

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

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

  vector<char> sv;
  for (char c: s) sv.push_back(c);
  sort(sv.begin(), sv.end());
  vector<char> tv;
  for (char c: t) tv.push_back(c);
  sort(tv.begin(), tv.end());
  reverse(tv.begin(), tv.end());

  bool ans = false;
  for (int i = 0; i < min(s.size(), t.size()); i++) {
    if (sv.at(i) < tv.at(i)) {
      ans = true;
    }
    else if (sv.at(i) == tv.at(i)) {
      if (i != min(s.size(), t.size())-1) {
        continue;
      }
      else {
        if (s.size() < t.size()) ans = true;
        break;
      }
    }
    else {
      break;
    }
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
  // ここにプログラムを追記
  int N;
  cin >> N;
  int sum = 0;
  int num = N;
  while(1){
    sum += num%10;
    num /= 10;
    if(num==0)break;
  }
  if(N%sum==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    int N,W;cin>>N>>W;
    vector<vector<ll> > v(4);
    vector<vector<ll> > sv(4);
    ll w1, v1;
    cin>>w1>>v1;
    v[0].push_back(v1);
    for(int i=1;i<N;i++){
      ll ww,vv; cin>>ww>>vv;
      v[ww-w1].push_back(vv);
    }
    for(int j=0;j<4;j++){
      sort(v[j].rbegin(), v[j].rend());
      sv[j].push_back(0);
    }

    for(int j=0;j<4;j++){
      for(int i=0;i<v[j].size();i++){
        sv[j].push_back(sv[j][i]+v[j][i]);
      }
    }

    ll ans=0;
    for(int a=0;a<=v[0].size();a++){
      for(int b=0;b<=v[1].size();b++){
        for(int c=0;c<=v[2].size();c++){
          for(int d=0;d<=v[3].size();d++){

            ll temp_w = (a+b+c+d)*w1 + b + c*2 + d*3;
            if(temp_w <= W) ans = max(ans, sv[0][a]+sv[1][b]+sv[2][c]+sv[3][d]);

          }
        }
      }
    }

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


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int mae = Integer.parseInt(s.substring(0,2));
		int usi = Integer.parseInt(s.substring(2,4));
		String ans;
		if(mae <= 12 && usi <= 12 && mae != 0 && usi != 0){
			ans = "AMBIGUOUS";
		}else if(mae <= 12 && mae != 0){
			ans = "MMYY";
		}else if(usi <= 12 && usi != 0){
			ans = "YYMM";
		}else{
			ans = "NA";
		}
		System.out.print(ans);
	}
}


Measured memory_bytes: 22612
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

class Program{
  public static void Main(){

    var input = Console.ReadLine().Split();
    int r = int.Parse(input[0]);
    int g = int.Parse(input[1]);
    int b = int.Parse(input[2]);
    if((10*g + b) % 4 == 0) Console.WriteLine("YES");
    else Console.WriteLine("NO");
  }
}

Measured memory_bytes: 11092
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);


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

    auto gcd = [&](long long a, long long b) {
        while (a != 0) {
            b %= a;
            swap(a, b);
        }
        return b;
    };

    auto lcm = [&](long long a, long long b) {
        return a / gcd(a, b) * b;
    };

    long long res = 1;
    for (int i = 0; i < n; ++i) {
        res = lcm(res, T[i]);
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

constexpr size_t N = 55;
ll p[N];
ll b[N];

void precalc(int n) {
    p[0] = 1;
    b[0] = 1;
    FOR(i,1,n) {
        p[i] = p[i-1] * 2 + 1;
        b[i] = b[i-1] * 2 + 3;
    }
}

ll countputty(ll lev,ll &layer) {
    //cerr << lev << " " << layer << endl;
    ll ret = 0;
    if (lev == 0) {
        layer--;
        return 1;
    } else {
        layer--;
        if (layer >= b[lev-1]) {
            ret = p[lev-1];
            layer -= b[lev-1];
        } else if (layer > 0){
            ret = countputty(lev-1,layer);
        }
        //cerr << "c " << lev << " " << layer << endl;
        if (layer > 0) {
            ret++;
            layer--;
        }
        if (layer >= b[lev-1]) {
            ret += p[lev-1];
            layer -= b[lev-1];
        } else if (layer > 0) {
            ret += countputty(lev-1,layer);
        }
    } 
    return ret;
}

int main(void)
{
    IOS
    ll n,x;
    cin >> n >> x;
    precalc(n);

    cout << countputty(n,x) << endl;


    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    Integer h = scan.nextInt();
    Integer w = scan.nextInt();
    StringBuilder sb = new StringBuilder();
    for(int i = 0; i < w + 2; i++) {
      sb.append("#");
    }
    System.out.println(sb);
    for(int i = 0; i < h; i++) {
      sb.delete(0, sb.length());
      sb.append("#");
      sb.append(scan.next());
      sb.append("#");
      System.out.println(sb);
    }
    sb.delete(0, sb.length());
    for(int i = 0; i < w + 2; i++) {
      sb.append("#");
    }
    System.out.println(sb);
  }
}

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



/// Info.
///****************************************************************************************************************************************///
/// author                : BAHAA El-DEEN OSAMA .
/// Problem name          : Q - H and V
/// Method                : brute force
/// Online judge          : vjudge(Contest)
/// Date                  : 8/7/2020
///****************************************************************************************************************************************///
#define ll   long long int



bool a[10][10];
int n,m,k,ans;
char st[10];

int main() {
	scanf("%d%d%d",&n,&m,&k);
	for (int i=1;i<=n;++i) {
		scanf("%s",st+1);
		for (int j=1;j<=m;++j)
		if (st[j]=='#') a[i][j]=1;
	}

	for (int x=0;x<(1<<n);++x)
	for (int y=0;y<(1<<m);++y) {
		int sl=0;
		for (int i=1;i<=n;++i)
		if ((1<<i-1)&x)
			for (int j=1;j<=m;++j)
			if ((1<<j-1)&y)
			if (a[i][j])
			++sl;
		if (sl==k) ++ans;
	}
	printf("%d\n",ans);

	return 0;
}


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

using namespace std;
using ll = long long;

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

	int y = 0, m = 0, d = 0;
	for (int i = 0; i < 10; ++i) {
		int x = s[i] - '0';
		if (i < 4) {
			y *= 10;
			y += x;
		}
		if ((i > 4) && (i < 7)) {
			m *= 10;
			m += x;
		}
		if (i > 7) {
			d *= 10;
			d += x;
		}
	}

	if ((y >= 2019) && (m > 4)) { cout << "TBD" << endl; }
	else { cout << "Heisei" << endl; }

	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
q = int(input())
bc = [list(map(int, input().split())) for i in range(q)]

sumA = 0
num = [0]*100001
for aa in a:
    num[aa] += 1
    sumA += aa

for b, c in bc:
    sumA = sumA + ((c - b) * num[b])
    num[c] += num[b]
    num[b] = 0
    print(sumA)


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

typedef long long ll;
int main()
{
    string S;
    cin >> S;
    int ans = 0;
    if (S == "SUN")
    {
        ans = 7;
    }
    else if (S == "MON")
    {
        ans = 6;
    }
    else if (S == "TUE")
    {
        ans = 5;
    }
    else if (S == "WED")
    {
        ans = 4;
    }
    else if (S == "THU")
    {
        ans = 3;
    }
    else if (S == "FRI")
    {
        ans = 2;
    }
    else if (S == "SAT")
    {
        ans = 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N, M;
  cin >> N >> M;
  string ans = (N == M) ? "Yes" : "No";

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


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

int main()
{
	int N, K;
	cin >> N >> K;
	int ans = K;
	for (int i = 0; i < N - 1; i++) ans *= K - 1;
	cout << ans << endl;
}

Measured memory_bytes: 256
console.log((input=>{
  c=input.trim().split("\n").slice(1),a=w=t=r=0
  for(e of c){e=="AC"&&a++,e=="WA"&&w++,e=="TLE"&&t++,e=="RE"&&r++}
  return `AC x ${a}
WA x ${w}
TLE x ${t}
RE x ${r}`
})(require('fs').readFileSync('/dev/stdin','utf8')))

Measured memory_bytes: 41688
from collections import deque

def bfs(h, w):
    q = deque([[h, w]])
    dist[h][w] = 0

    while len(q) != 0:
        y, x = q.popleft()

        for step in steps:
            nx = x + step[0]
            ny = y + step[1]
            if nx < 0 or nx >= W or ny < 0 or ny >= H:
                continue
            if maze[ny][nx] == "#":
                continue
            if dist[ny][nx] != -1:
                continue
            dist[ny][nx] = dist[y][x] + 1
            q.append([ny, nx])


H, W = map(int, input().split())
maze = [[s for s in input()] for _ in range(H)]

steps = [[1, 0], [0, 1], [-1, 0], [0, -1]]
max_dist = [[0]*W for _ in range(H)]

for h in range(H):
    for w in range(W):
        if maze[h][w] == "#":
            continue
        dist = [[-1]*W for _ in range(H)]
        bfs(h, w)
        for row in dist:
            for d in row:
                max_dist[h][w] = max(max_dist[h][w], d)

ans = 0
for row in max_dist:
    for d in row:
        ans = max(ans, d)

print(ans)

Measured memory_bytes: 46172
from collections import deque
from heapq import heappush,heappop
import re

def int_raw():
    return int(input())

def ss_raw():
    return input().split()

def ints_raw():
    return list(map(int, ss_raw()))

INF = 1<<29

A,B = ints_raw()

def main():
        if A>=13:
                print(B)
        elif A<=5:
                print(0)
        else:
                print(B//2)

main()


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

using namespace std;

long double dp[301][301][301];
bool al[301][301][301];
int a, b, c, n;

long double f(int i, int j, int k){
    if(i + j + k == 0) return 0;

    long double &ret = dp[i][j][k];

    if(al[i][j][k]) return ret;
    
    al[i][j][k] = true;

    ret = 0;
    if(i) ret += f(i - 1, j, k) * i / (i + j + k);
    if(j) ret += f(i + 1, j - 1, k) * j / (i + j + k);
    if(k) ret += f(i, j + 1, k - 1) * k / (i + j + k);
    ret += (long double) n / (i + j + k);

    return ret;
}

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

    for(int i = 0; i < n; i++){
        int x; scanf("%d", &x);
        if(x == 1) a++;
        else if (x == 2) b++;
        else c++;
    }

    printf("%.12Lf\n", f(a, b, c));

    return 0;
}

Measured memory_bytes: 353664
#include <stdio.h>

int main(){

    int n,a,b;
    scanf("%d",&n);
    scanf("%d",&a);
    int sum=a;
    for(int i=1;i<n-1;i++){
        scanf("%d",&b);
        if(b>=a)
            sum+=a;
        else
            sum+=b;
        a=b;
        
    
    }
    sum+=a;
    printf("%d",sum);
    return 0;
    
}


Measured memory_bytes: 128
#include <stdio.h>

int main(){
	long long int n;
	long long int a , b, ans,c;
	
	scanf("%lld %lld %lld",&n,&a,&b);
	
	c = n/(a+b);
	ans = c*a;
	n%=(a+b);
	if(a<n){
		ans += a;
	}
	else {
		ans+=n;
	}
	printf("%lld",ans);
	
	return 0;
}


Measured memory_bytes: 1724
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
a,b,c = LI()
print(min(b//a,c))
#B

#C
"""
s = S()
n = len(s)
while len(s)>1:
    i = 0
    f = True
    while s[i] == s[i+1]:
        if i+1 == len(s)-1:
            f = False
            break
        i += 1
    if not f:break
    s.pop(i)
    s.pop(i)
print(n-len(s))
"""

#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int n, h; std::cin >> n >> h;
  vi a(n), b(n); rep(i, n) std::cin >> a[i] >> b[i];
  sort(rrng(a)), sort(rrng(b));
  int ans = 0;
  for (int i = 0; i < n && h > 0 && b[i] > a[0]; i++) {
    h -= b[i], ans++;
  }
  if (h > 0) {
    ans += (h+a[0]-1) / a[0];
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ans = 9999999;
  int R[N+1];
  R[0] = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'W') {
      R[i+1] = R[i] + 1;
    } else {
      R[i+1] = R[i];
    }
  }
  for (int i = 0; i < N; i++) {
    int res = (N - i - 1) - (R[N] - R[i+1]);
    res += R[i] - R[0];
    ans = min(ans,res);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1796
// 解き直し.
// AGC038解説.
// https://img.atcoder.jp/agc038/editorial.pdf
#include <bits/stdc++.h>
using namespace std;

int main(){
    
    // 1. 入力情報取得.
    int H, W, A, B;
    scanf("%d %d %d %d", &H, &W, &A, &B);
    
    // 2. 解説通り.
    // 0, 1 の 書き込み.
    int Matrix[H][W];
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(i < B && j < A)   Matrix[i][j] = 0;
            if(i < B && j >= A)  Matrix[i][j] = 1;
            if(i >= B && j < A)  Matrix[i][j] = 1;
            if(i >= B && j >= A) Matrix[i][j] = 0;
        }
    }
    
    // 3. 出力 ～ 後処理.
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++) printf("%d", Matrix[i][j]);
        printf("\n");
    }
    return 0;

}

Measured memory_bytes: 5120
N = int(input())
h = list(map(int, input().split()))


def rec(array):

    count = 0

    if sum(array) == 0:
        return count

    if 0 in array:
        none = array.index(0)

        count += rec(array[:none])
        count += rec(array[none + 1:])

    else:
        min_num = min(array)

        for i in range(len(array)):
            array[i] -= min_num
        count += min_num

        count += rec(array)

    return count


print(rec(h))


Measured memory_bytes: 38640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
	ll n; cin >> n;

	ll a_max = 0;

	vector<ll> a(n);
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
		a_max = max(a_max, a[i]);
	}

	if (n == 2) {
		sort(a.begin(), a.end());
		cout << a[1] << " " << a[0] << endl;
		return 0;
	}

	ll a_medean_index;
	ll diff = 9223372036854775807LL;

	for (ll i = 0; i < n; i++) {
		if (chmin(diff, abs(a_max / 2 - a[i]))) {
			a_medean_index = i;
		}
	}

	cout << a_max << " " << a[a_medean_index] << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    short hudou[1000][101];
    for(int i=0;i<1000;i++)
      for(int j=0;j<101;j++)
	hudou[i][j]=0;
    short num[1000][n];
    for(int i=0;i<n;i++){
      cin>>num[0][i];
    }
    int cnt=0;
    while(1){
      for(int i=0;i<n;i++)
	hudou[cnt][num[cnt][i]]++;
      for(int i=0;i<n;i++)
	num[cnt+1][i]=hudou[cnt][num[cnt][i]];
      int i,flag=1;
      for(i=0;i<n;i++){
	if(num[cnt][i]!=num[cnt+1][i]){
	  flag=0;
	  break;
	}
      }
      if(flag){
	cout<<cnt<<endl;
	for(int j=0;j<n;j++){
	  cout<<num[cnt][j];
	  if(j!=n-1)
	    cout<<" ";
	}
	cout<<endl;
	break;
      }else
	cnt++;
    }
  }
  return 0;
}

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

int nth_bit(int64_t num , int n){
    return (num>>n)&1;
}

int main(){
    int H, W, K;
    cin >> H >> W >> K;
    string S[6];
    for(int i=0;i<H;i++){
        cin>>S[i];
    }

    int ans = 0;

    for(int a=0;a<(1<<H);a++){
        for(int b=0;b<(1<<W);b++){
            int cnt=0;
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    if(nth_bit(a,i) && nth_bit(b,j) && S[i][j] == '#'){
                        cnt++;
                    }
                }
            }
            if(cnt == K){
                ans++;
            }
        }
    }

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

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define FILE(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout);

using namespace std;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int maxn = 500003;

int n, m, k, a[maxn], p[maxn], q[maxn];
int tot, head[maxn], ver[maxn * 2], nxt[maxn * 2];
int in[maxn], tr[maxn * 4];

inline void add(int u, int v)
{
	ver[++tot] = v, nxt[tot] = head[u], head[u] = tot, ++in[v];
}

inline int ls(int p) {return p << 1;}
inline int rs(int p) {return p << 1 | 1;} 

int getans(int ql, int qr, int l, int r, int p)
{
	if (ql == l && r == qr) return tr[p];
	int mid = (ql + qr) >> 1;
    if (r <= mid) return getans(ql, mid, l, r, ls(p));
	else if (l > mid) return getans(mid + 1, qr, l, r, rs(p));
	else return min(getans(ql, mid, l, mid, ls(p)), getans(mid + 1, qr, mid + 1, r, rs(p)));
}

void modify(int x, int z, int l, int r, int p)
{
	if (l == r) {tr[p] = z; return;}
	int mid = (l + r) >> 1;
	if (mid >= x) modify(x, z, l, mid, ls(p));
	else modify(x, z, mid + 1, r, rs(p));
	tr[p] = min(tr[ls(p)], tr[rs(p)]);
}

void build(int l, int r, int p)
{
	tr[p] = n + 1;
	if (l == r) return;
	int mid = (l + r) >> 1;
	build(l, mid, ls(p));
	build(mid + 1, r, rs(p));
}

inline void solve()
{
	build(1, n, 1);
	for (int i = n; i >= 1; i-=1)
	{
		int x;
		x = getans(1, n, max(1, q[i] - k + 1), q[i], 1);
		if (x <= n) add(q[i], q[x]);
		x = getans(1, n, q[i], min(n, q[i] + k - 1), 1);
		if (x <= n) add(q[i], q[x]);
		modify(q[i], i, 1, n, 1);
	}
	set <int> qq;
	for (int i = 1; i <= n; i+=1) 
	{
		if (!in[i]) qq.insert(i);
	}
	for (int i = 1; i <= n; i+=1) 
	{
		int x = q[i] = *qq.begin(); qq.erase(qq.begin());
		for (int j = head[x]; j; j = nxt[j])
		{
			int v = ver[j];
			if (!(--in[v])) qq.insert(v);
		}
	}
	for (int i = 1; i <= n; i+=1) p[q[i]] = i;
	for (int i = 1; i <= n; i+=1) printf("%d\n", p[i]);
}

int main()
{
	n = gi(), k = gi();
	for (int i = 1; i <= n; i+=1)
	{
		p[i] = gi();
		q[p[i]] = i;
	}
	solve();
	return 0;
}

Measured memory_bytes: 39296
#include <stdio.h>

int gcm(int a,int b){

  int c;

  if(a==0||b==0){return -1;}

  if(b>a){c=a;a=b;b=c;}

  //b is littler
  if(b>a){c=a;a=b;b=c;}

  while( (c = a%b) != 0 ){
    a=b;
    b=c;
  }

  if(b==0){b=1;}

  return b;

}


int main(void){
  int a,b;
  long long int abgcm;
  while( scanf("%d %d",&a,&b) != EOF ){
    abgcm=gcm(a,b);
      printf("%lld %lld\n",abgcm,(long long int)(a/abgcm*b));
  }
  return 0;
}

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

using namespace std;

void f(long long &a, long long b) {
    a = max(a, b);
}

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

    long long n, w;
    cin >> n >> w;

    vector<long long> dp(w+1, 0);
    long long wi, vi;
    for (int i = 0; i < n; i++) {
        cin >> wi >> vi;
        for (int j = w-wi; j >= 0; j--) {
            f(dp[j+wi], dp[j] + vi);
        }
    }

    for (int i = 0; i < w; i++) {
        f(dp[i], dp[i+1]);
    }
    printf("%lld", dp[w-1]);

    return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n;i>0;i--)
#define rep1(i,s,n) for(int i=s;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    ll n;
    cin>>n;
    lvec a(n);
    rep(i,n) cin>>a[i];
    lvec s(n+1,0);
    for(int i=0;i<n;i++) s[i+1]=s[i]+a[i];
    ll m=lower_bound(s.begin(),s.end(),s[n]/2)-s.begin();
    if(s[m]==s[n]/2&&s[n]%2==0) cout<<0;
    else{
        ll p=s[n]-s[m],q=s[n]-s[m-1];
        cout<<min((ull)abs(p-s[m]),(ull)abs(q-s[m-1]));
    }
}

Measured memory_bytes: 3328
dp = [[0] * 3 for _ in range(10 ** 5 + 2)]

N = int(input())
for i in range(1, N + 1):
    inp = [int(_) for _ in input().split()]
    for j in range(3):
        dp[i][j] = max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]) + inp[j]

print(max(dp[N]))


Measured memory_bytes: 22772
#include <iostream>
#include <vector>
using namespace std;
vector<vector<int>> A(3, vector<int>(3));
int b[10],N;
void set_b(int n) {
    for (int i=0; i<3; i++) {
        for (int j=0; j<3; j++) {
            if (A.at(i).at(j) == n) {
                A.at(i).at(j) = 0;
                return;
            }
        }
    }
}
bool chk_b() {
    for (int i=0; i<3; i++) {
        if (A.at(i).at(0)+A.at(i).at(1)+A.at(i).at(2)==0) return true;
    }
    for (int j=0; j<3; j++) {
        if (A.at(0).at(j)+A.at(1).at(j)+A.at(2).at(j)==0) return true;
    }
    if (A.at(0).at(0)+A.at(1).at(1)+A.at(2).at(2)==0) return true;
    if (A.at(0).at(2)+A.at(1).at(1)+A.at(2).at(0)==0) return true;
    return false;
}
int main() {
    for (int i=0; i<3; i++) {
        for (int j=0; j<3; j++) {
            cin>>A.at(i).at(j);
        }
    }
    cin>>N; for (int i=0; i<N; i++) cin>>b[i];
    bool flg=false;
    for (int i=0; i<N; i++) {
        set_b(b[i]);
        flg=chk_b();
        if (flg) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <vector>
#define ll long long int
#define mp make_pair
#define pb push_back
#define vi vector<int>
using namespace std;
const ll p=1e9 + 7;
ll solve(){
   int n;
   cin>>n;
   string s;
   cin>>s;
   ll dp[n][n];
   ll dpsum[n+1]={0};
   dpsum[0]=0;
   for(int i=0;i<n;i++){
       dp[0][i]=1;
       dpsum[i+1]=i+1;
   }
   for(int i=1;i<n;i++){
       if(s[i-1]=='<'){
            for(int j=0;j<n-i;j++){
                dp[i][j]=dpsum[n-i+1]-dpsum[j+1];
                dp[i][j]%=p;
            }
        }
        if(s[i-1]=='>'){
            for(int j=0;j<n-i;j++){
                dp[i][j]=dpsum[j+1];
                dp[i][j]%=p;
            }
        }
        dpsum[0]=0;
        for(int j=1;j<=n-i;j++){
            dpsum[j]=dpsum[j-1]+dp[i][j-1];
        }
   }
   return dp[n-1][0];
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<solve();
}

Measured memory_bytes: 69888
#include<iostream>

#include<cmath>
#include<string>
#include <algorithm> 

using namespace std;

# define p(s) cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) cout << (j ? "Yes" : "No") << endl;

string lpad(string l,int s,int n){
    string temp = to_string(n);
    string res = "";
    int loop = s - temp.size();
    while(loop--) res+=l;

    return res+temp;
}

int main()
{
    int n,i;
    cin >> n >> i ;

    p(n-i+1)
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int f(int n){
    int res=0;
    while(n){
        res+=n%10;
        n/=10;
    }
    return res;
}
int main(){
    int n;
    cin>>n;
    if(n%f(n)==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

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


int main()
{

    int a[5];
    for(int i=0; i<5; i++)
        cin>>a[i];
    int n;
    cin>>n;
    sort(a,a+5);
    if(a[4]-a[0]>n)
        cout<<":("<<endl;
    else
        cout<<"Yay!"<<endl;
    return 0;
}



Measured memory_bytes: 256
/* template.cpp [[[ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)s)
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)s)
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* ]]] */

int n;
pair<int, int> a[100000];

int main(){
  cin >> n;
  rep(i, n) cin >> a[i].fs, a[i].sc = i;
  sort(a, a + n);
  int c = 0;
  rep(i, n) c += (a[i].sc % 2 == 0) && (i % 2 == 1);
  cout << c << endl;
}


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

using namespace std;
using ll = long long;
using ld = long double;
using Vec = vector<int>;
using Graph = vector<vector<int>>;
int main(){
    
    int n,ac=0,wa=0,tle=0,re=0;
    cin>>n;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        if(s=="AC"){
            ac++;
        }
        if(s=="TLE"){
            tle++;
        }
        if(s=="WA"){
            wa++;
        }
        if(s=="RE"){
            re++;
        }
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;

    
}

Measured memory_bytes: 3624
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

# Written by NoKnowledgeGG @YlePhan

#import math
#mod = 10**9+7



def main():
  #print(ord('x')) z:122
  #print(ord('a')) a:97
  #print(chr(97)) 97:a
  s = input()
  dic = {}
  for a in s:
    if not a in dic.keys():
      dic[a] = 1
    else:
      pass
  for i in range(97,123):
    if not str(chr(i)) in dic.keys():
      print(chr(i))
      exit()
  print('None')
      
if __name__ == '__main__':
  main()

Measured memory_bytes: 3316
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
long long Combination(int n, int r)
{
	//n, rが負またはn<rの時は失敗
	if(n<0||r<0||n<r) return -1;

	//nCr=nCn-r
	r=(n<n-r)?n:(n-r);

	//r=0,1の時は計算する必要がない
	if(r==0) return 1;
	if(r==1) return n;

	vector<int> numerator(r), denominator(r);

	for(int k=0; k<r; k++){
		numerator[k]=n-r+k+1;
		denominator[k]=k+1;
	}

	for(int p=2; p<=r; p++){
		int pivot=denominator[p-1];
		if(pivot>1){
			int offset=(n-r)%p;
			for(int k=p-1; k < r; k+=p){
				numerator[k-offset]/=pivot;
				denominator[k]/=pivot;
			}
		}
	}

	long long result=1;
	for(int k=0; k<r; k++){
		if(numerator[k]>1) result*=numerator[k];
	}
	return result;
}
int main(void)
{
	unsigned long n, c[5]={}, ans=0;

	cin>>n;

	vs s(n);

	rep(i, n){
		cin>>s[i];
		if(s[i][0]=='M') c[0]++;
		if(s[i][0]=='A') c[1]++;
		if(s[i][0]=='R') c[2]++;
		if(s[i][0]=='C') c[3]++;
		if(s[i][0]=='H') c[4]++;
	}
	rep(i, 5){
		repr(j, i+1, 5){
			repr(k, j+1, 5){
				ans+=c[i]*c[j]*c[k];
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 6144
#include <iostream>

using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	int L = 1, R = N;
	for (int i = 0; i < M; ++i)
	{
		int l, r;
		cin >> l >> r;
		if (l > L)
			L = l;
		if (r < R)
			R = r;
	}
	if (R >= L)
		cout << R - L + 1 << endl;
	else
		cout << 0 << endl;
	return 0;
}

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

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N;
  cin >> N;
  
  int f = findSumOfDigits(N);
  
  
  if (N % f == 0) {
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String args[]) {
      Scanner read = new Scanner(System.in);
      String s = read.nextLine();
      for(int i = 0; i<s.length(); i++){
          if(i%2 == 0 && s.charAt(i) == 'L'){
              System.out.println("No");
              return;
          }
          else if(i%2 != 0 && s.charAt(i) == 'R'){
              System.out.println("No");
              return;
          }
      }
      System.out.println("Yes");
    }
}

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

#define MAXN (100010)

int n, k;
int a[MAXN];

int main(){
	scanf("%d%d", &n, &k);
	int gcd = 0;
	bool flag = false;
	for(int i = 1; i <= n; ++ i){
		scanf("%d", a + i);
		gcd = std::__gcd(gcd, a[i]);
		flag |= k <= a[i];
	}
	if(flag && k % gcd == 0){
		printf("POSSIBLE\n");
	}
	else{
		printf("IMPOSSIBLE\n");
	}
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    int n;
    cin >> n;
    int ans = 0;
    rep(i, n){
        string c;
        cin >> c;
        rep(j, s.size() - 1){
            c += c[j];
        }
        if(c.find(s) != -1){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3120