akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i <= (int)(n); i++)

int main(){
    int a, b, c, x;
    int count = 0;
    std::cin >> a >> b >> c >> x;

    REP(i, a)REP(j, b)REP(k, c)
            if(500 * i + 100 * j + 50 * k == x) ++count;
    std::cout << count;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main() {
    uint16_t n;

    cin >> n;

    vector<uint16_t> a(n);

    for (uint16_t i = 0; i < n; i++)
        cin >> a[i];

    for (uint16_t i = n; i > 0; i--)
        if (i == 1)
            cout << a[i-1] << endl;
        else
            cout << a[i-1] << " ";

    return 0;
}

Measured memory_bytes: 3016
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define YEAR 0
#define BOTH 1

int f(int num) {
    if (1 <= num && num <= 12) return BOTH;
    else return YEAR;

}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int up = (S[0] - '0') * 10 + (S[1] - '0');
    int down = (S[2] - '0') * 10 + (S[3] - '0');
    //cout << up << " " << down << endl;
    if (f(up) == YEAR && f(down) == YEAR) {
        cout << "NA" << endl;
    } else if (f(up) == YEAR && f(down) == BOTH) {
        cout << "YYMM" << endl;
    } else if (f(up) == BOTH && f(down) == YEAR) {
        cout << "MMYY" << endl;
    }  else {
        cout << "AMBIGUOUS" << endl;
    }
    

    return 0;
}


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

using namespace std;
typedef long long ll;
ll mod = 1e9+7;

int main(void)
{
  ll N;cin>>N;
  ll K;cin>>K;
  ll res = 0;
  while(N>0){
    N /=K;
    res++;
  }
  cout<<res<<endl;
}

Measured memory_bytes: 256
from collections import defaultdict
def main():
	S = input()
	ans = defaultdict(int)
	for c in S:
		ans[c] += 1
	if len(ans) == 2 and ans[S[0]] == 2:
		print("Yes")
	else:
		print("No")



if __name__ == '__main__':
	main()

Measured memory_bytes: 3444
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            string ans = "Good";
            for (int i = 0; i < 3; i++)
            {
                //入力しづらい
                if (s[i] == s[i+1])
                {
                    ans = "Bad";
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
  
}
int main(void){
  initialize();
  ll n,m,i,j,k,q,result=0,sum=0;
  ll a[LIMIT1]={0},b,c;
  
  cin >> n;
  rep(i,n){
    cin >> j;
    a[j]++;
    sum += j;
  }
  cin >> q;
  rep(i,q){
    cin >> b >> c;
    sum += (c-b)*a[b];
    a[c] += a[b];
    a[b] = 0;
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 5172
#abc174 d

import sys
input = sys.stdin.readline

N=int(input())
c=input().rstrip()
R =[0]*(N+1)
W =[0]*(N+1)

for i in range(1,N+1):
    if c[i-1]=='R':
        R[i] = R[i-1]+1
        W[i] = W[i-1]
    else:
        R[i] = R[i-1]
        W[i] = W[i-1]+1
Rall = R[-1]
Wall = W[-1]

ans = float('inf')

for i in range(N+1):
    tmp = min(W[i],Rall-R[i])+abs(W[i]-(Rall-R[i]))
    ans = min(ans,tmp)

print(ans)
    
        


Measured memory_bytes: 18716
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

vector<vi> G(1000);

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N, M;
    cin >> N >> M;

    REP(i, M) {
        int a, b; cin >> a >> b;
        --a; --b;
        G[a].pb(b);
    }

    // find loop
    vi loop;
    int len = inf;
    {
        REP(i, N){
            vector<bool> used(N, false);
            vector<int> prev(N);
            queue<int> q;
            q.push(i);
            while (!q.empty()) {
                int cur = q.front();
                q.pop();

                for (auto to: G[cur]) {
                    if (to == i) {
                        vi tmp;
                        int node = cur;
                        while (node != i) {
                            tmp.pb(node);
                            node = prev[node];
                        }
                        tmp.pb(i);

                        if (tmp.size() < len) {
                            loop.swap(tmp);
                            reverse(ALL(loop));
                            len = loop.size();
                            continue;
                        }
                    }

                    if (used[to]) continue;
                    q.push(to);
                    used[to] = true;
                    prev[to] = cur;
                }
            }
        }
    }

    if (loop.size() == 0) {
        print(-1);
        return 0;
    }

    print(loop.size());
    for(auto e: loop) {
        print(e + 1);
    }

}


Measured memory_bytes: 3688
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
using namespace std;
#define N 6005
#define INF 0x3f3f3f3f
#define LL long long
int n,MOD,f[4][N*2];
int rd()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1; c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+(c^48);c=getchar();}
	return f*x;
}
int main()
{
	n=rd(),MOD=rd();
	f[0][N]=1;
	for(int i=1;i<=3*n;i++)
	{
		int l=N-(i-1),r=N+(i-1);
		for(int j=l;j<=r;j++)
		{
			for(int k=3;k>=1;k--)
				f[k][j]=f[k-1][j];
			f[0][j]=0;
		}
		for(int j=l;j<=r;j++)
		{
			f[0][j+1]=(f[0][j+1]+f[1][j])%MOD;
			int del=i-1;
			f[0][j-1]=(f[0][j-1]+1ll*f[2][j]*del%MOD)%MOD;
			del=1ll*(i-1)*(i-2)%MOD;
			f[0][j]=(f[0][j]+1ll*f[3][j]*del%MOD)%MOD;
		}
	}
	int ans=0;
	for(int i=N;i<=N+3*n;i++)
		ans=(ans+f[0][i])%MOD;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<algorithm>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;
int main()
{
    fast_io
    ll t,i,j,n,h,w;
    cin>>h>>w;
    cout<<(h-1)*(w-1)<<endl;
    return 0;
}





Measured memory_bytes: 3608
N = int(input())
A = list(map(int,input().split()))

from collections import Counter
C = dict(Counter(A))  #辞書型にする
#print('C',C)
Ckey = list(C.keys())
#print('Ckey',Ckey)

B = sorted(Ckey)
#print('B',B)

out=0
table=[0]*(10**6)
for i in range(len(B)):
        if table[B[i]-1]==1:
            continue
        elif C[B[i]]==1:
            out+=1
        k=1
        while k*B[i]<=10**6:
            table[k*B[i]-1]=1
            k+=1

print(out)

Measured memory_bytes: 148312
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

int main(){
    int a,b;
    char s;
    cin>>a>>s>>b;
    if(s=='+')cout<<a+b<<endl;
    else if(s=='-')cout<<a-b<<endl;
    return 0;
}

Measured memory_bytes: 3604
#pragma region
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i = a; i <= n; ++i)
#define per(i, a, n) for (int i = n; i >= a; --i)
namespace fastIO {
#define BUF_SIZE 100000
#define OUT_SIZE 100000
//fread->R
bool IOerror = 0;
//inline char nc(){char ch=getchar();if(ch==-1)IOerror=1;return ch;}
inline char nc() {
    static char buf[BUF_SIZE], *p1 = buf + BUF_SIZE, *pend = buf + BUF_SIZE;
    if (p1 == pend) {
        p1 = buf;
        pend = buf + fread(buf, 1, BUF_SIZE, stdin);
        if (pend == p1) {
            IOerror = 1;
            return -1;
        }
    }
    return *p1++;
}
inline bool blank(char ch) { return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t'; }
template <class T>
inline bool R(T &x) {
    bool sign = 0;
    char ch = nc();
    x = 0;
    for (; blank(ch); ch = nc())
        ;
    if (IOerror) return false;
    if (ch == '-') sign = 1, ch = nc();
    for (; ch >= '0' && ch <= '9'; ch = nc()) x = x * 10 + ch - '0';
    if (sign) x = -x;
    return true;
}
inline bool R(double &x) {
    bool sign = 0;
    char ch = nc();
    x = 0;
    for (; blank(ch); ch = nc())
        ;
    if (IOerror) return false;
    if (ch == '-') sign = 1, ch = nc();
    for (; ch >= '0' && ch <= '9'; ch = nc()) x = x * 10 + ch - '0';
    if (ch == '.') {
        double tmp = 1;
        ch = nc();
        for (; ch >= '0' && ch <= '9'; ch = nc())
            tmp /= 10.0, x += tmp * (ch - '0');
    }
    if (sign)
        x = -x;
    return true;
}
inline bool R(char *s) {
    char ch = nc();
    for (; blank(ch); ch = nc())
        ;
    if (IOerror)
        return false;
    for (; !blank(ch) && !IOerror; ch = nc())
        *s++ = ch;
    *s = 0;
    return true;
}
inline bool R(char &c) {
    c = nc();
    if (IOerror) {
        c = -1;
        return false;
    }
    return true;
}
template <class T, class... U>
bool R(T &h, U &... t) { return R(h) && R(t...); }
#undef OUT_SIZE
#undef BUF_SIZE
};  // namespace fastIO
using namespace fastIO;
template <class T>
void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template <class T, class U>
void _W(const pair<T, U> &x) { _W(x.F), putchar(' '), _W(x.S); }
template <class T>
void _W(const vector<T> &x) {
    for (auto i = x.begin(); i != x.end(); _W(*i++))
        if (i != x.cbegin()) putchar(' ');
}
void W() {}
template <class T, class... U>
void W(const T &head, const U &... tail) { _W(head), putchar(sizeof...(tail) ? ' ' : '\n'), W(tail...); }
#pragma endregion
const int maxn = 2e5 + 5;
const ll mod = 1e9 + 7;
ll a[maxn];
int main() {
    int n;
    R(n);
    ll ans = 0, sum = 0;
    rep(i, 1, n) {
        R(a[i]);
        ans = (ans + sum * a[i]) % mod;
        sum = (sum + a[i]) % mod;
    }
    W(ans);
}

Measured memory_bytes: 4720
#include<stdio.h>
int loved[35];
int main(){
	int N,M;
	scanf("%d %d",&N,&M);
	for(int i=1;i<=M;i++){
		loved[i]=0;
	}
	for(int i=0;i<N;i++){
		int loved_amount;
		scanf("%d",&loved_amount);
		for(int j=0;j<loved_amount;j++){
			int food;
			scanf("%d",&food);
			loved[food]++;
		}
	}
	int ans=0;
	for(int i=1;i<=M;i++){
		if(loved[i]==N)
			ans++;
	}
	printf("%d",ans);
}

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

int main()
{
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	if(a>b)swap(a,b);
	if((b-a)&1)puts("Borys");else puts("Alice");
	return 0;
}


Measured memory_bytes: 256
<?php
$input=explode(' ',trim(fgets(STDIN))); // // 1 2 3 ……
$string = trim(fgets(STDIN)); //数字や文字列

$output = preg_match("/^[0-9]{{$input[0]}}[-][0-9]{{$input[1]}}$/", $string);

if ($output==1)
{
    echo "Yes\n";
}
else
{
    echo "No\n";
}

?>

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<int> P(M), Y(M);
  for (int i = 0; i < M; i++) {
    cin >> P[i] >> Y[i];
  }
  vector<int> idx(M);
  iota(idx.begin(), idx.end(), 0);
  sort(idx.begin(), idx.end(), [&](int a, int b) { return Y[a] < Y[b]; });
  vector<int> cnts(N + 1, 0);

  vector<pair<int, int>> res(M);

  for (auto i : idx) {
    res[i] = make_pair(P[i], cnts[P[i]]++);
  }

  for (int i = 0; i < M; i++) {
    cout << setfill('0') << right << setw(6) << res[i].first;
    cout << setfill('0') << right << setw(6) << res[i].second + 1;
    cout << '\n';
  }
  return 0;
}


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

using namespace std;

int main(){
    int n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    vector<pair<char,char>> op(q);
    for (int i = 0; i < q; ++i) {
        char a,b;
        cin>>a>>b;
        op[i]=make_pair(a,b);
    }
    int ng=-1,ok=n;
    int mid=(ng+ok)/2;
    while(ok-ng!=1){//左に消える（ngは絶対に消える）
        mid=(ok+ng)/2;
        int pos=mid;
        for(auto it:op){
            if(s[pos]!=it.first)continue;
            else{
                if(it.second=='L')--pos;
                else ++pos;
            }
            if(pos<0||pos>=n)break;
        }
        if(pos<0)ng=mid;
        else ok=mid;
    }
    int llimit=ng;

    ng=n;ok=-1;
    mid=(ng+ok)/2;
    while(ng-ok!=1){
        mid=(ok+ng)/2;
        int pos=mid;
        for(auto it:op){
            if(s[pos]!=it.first)continue;
            else{
                if(it.second=='L')--pos;
                else ++pos;
            }
            if(pos<0||pos>=n)break;
        }
        if(pos>=n)ng=mid;
        else ok=mid;
    }
    int rlimit=ng;

    cout<<n-(llimit+1)-(n-rlimit)<<endl;
    return 0;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var N = ReadInt();
            Println(N * 800 - (N / 15 * 200));
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static void YESOrNO(bool e) => Println(e ? "YES" : "NO");

        static void YesOrNo(bool e) => Println(e ? "Yes" : "No");

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
#define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        3e18
 #define sm         -2e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
   
    #endif
}

int ar[100005] , dp[100005];
void solve()
{
  
  int n;
  cin >> n;

  forf(i,0,n+1) cin >> ar[i];

  for(int i=n;i>=0;i--)
  {
    if(i==n) dp[i]=ar[i];
    else dp[i] = ar[i]+dp[i+1];
  }

  int an = 0 , bl=0,cur=1;
  

  for(int i=0;i<=n;i++)
  {
    if(cur < ar[i]) bl=1;
    cur = min(dp[i],cur);
    an += cur;
    cur-=ar[i];
    cur*=2;
  }

  
  if(bl)
  {
    cout<<"-1\n";
    return ;
  }

  cout<<an<<endl;

}

int32_t main()
{
  pr_init();
  fastio;
  solve();

 }
      

Measured memory_bytes: 5164
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define int long long
#define abs Abs
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int SMOD = 1000000007;
const int NMOD = 1000000009;
int dx[]={1,0,-1,0,1,1,-1,-1};
int dy[]={0,-1,0,1,-1,1,-1,1};
ll Abs(ll x){return (x<0 ? -x : x);}
bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
struct xyz{
    xyz(){
        cin.tie(0), ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
    };
}xyzzy;


signed main(){
    int a,b,c;

    cin >>a >> b >> c;
    cout <<(a*b)/2 fin;
  return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>
#include <stdio.h>
#include <functional>

using namespace std;
using ll = long long;
using ld = double;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
const ll INF = 1e17;
const ld eps = 1e-10;
const ll MOD = 1e9 + 7;

const double pi = acos(-1.0);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	cin >> N;
	map<ll, ll> cnt;
	for (int i = 0;i < N;i++) {
		ll a;
		cin >> a;
		if (cnt.find(a) == cnt.end())
			cnt[a] = 1;
		else
			cnt[a]++;
	}
	bool ans = false;
	if (cnt.size() == 1 && cnt.find(0) != cnt.end())
		ans = true;
	else if (cnt.size() == 3 && N % 3 == 0) {
		ans = true;
		vector<ll> el;
		for (auto i : cnt) {
			if (i.second != N / 3)
				ans = false;
			el.push_back(i.first);
		}
		if ((el[0] ^ el[1]) != el[2])
			ans = false;
	}
	else if (cnt.size() == 2 && cnt.find(0) != cnt.end() && N % 3 == 0) {
		ans = true;
		for (auto i : cnt) {
			if (i.first == 0) {
				if (i.second != N / 3)
					ans = false;
			}
			else {
				if (i.second != 2 * N / 3)
					ans = false;
			}
		}
	}
	if (ans)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}






Measured memory_bytes: 5120
# itertools.product()でお手軽bit全探索
from itertools import product
D, G = map(int, input().split())
Problems_info = {}
Problems = []
Bonus = []
for i in range(D):
    p, c = map(int, input().split())
    Problems_info[i] = p
    Problems += [100 * (i + 1)] * p
    Bonus.append(c)


# 点数が高い順にソート
Problems.sort(reverse=True)

ans = float('inf')
# bit全探索
for bs in product([0, 1], repeat=D):
    tmp_ans = 0  # これまでに解いた問題数を管理
    tmp_score = 0  # これまでの得点を管理
    solved_point = set()  # すでに解いた点数帯を管理するための集合

    for i in range(D):
        # ボーナスをとるなら
        if bs[i]:
            tmp_score += Bonus[i]
            tmp_score += Problems_info[i] * 100 * (i + 1)
            tmp_ans += Problems_info[i]
            solved_point.add(100 * (i + 1))

    for point in Problems:
        if tmp_score >= G:
            ans = min(ans, tmp_ans)
            break

        # ボーナスを未取得なら使える
        if point not in solved_point:
            tmp_ans += 1
            tmp_score += point

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(1){
    cin>>n;
    if(n==0) break;
    string s;
    cin>>s;
    vector<int> vec(n);
    for(int i=0;i<n;i++) vec[i]=0;
    int ba=0;
    for(int i=0;i<100;i++){
      if(s[i]=='M'){
	vec[(i+1)%n]++;
      }
      else if(s[i]=='S'){
	ba+=vec[(i+1)%n]+1;
	vec[(i+1)%n]=0;
      }
      else{
	vec[(i+1)%n]+=ba+1;
	ba=0;
      }
    }
    sort(vec.begin(),vec.end());
    for(int i=0;i<n;i++) cout<<vec[i]<<" ";
    cout<<ba<<endl;
    
  }

  return 0;
}



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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

int N,A,i,s;
int main(){
    scanf("%d%d", &N,&A);
    if(N<A*2-1){
        printf("NO");
    }else{
        printf("YES");
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
#include <sstream>
#include <queue>
using namespace std;
typedef long long ll;

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

  int d = 0;
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      d += abs(0-a[i]);
    } else {
      d += abs(a[i-1]-a[i]);
    }
  }
  d += abs(a[n-1]);

  for (int i = 0; i < n; i++) {
    if (i == 0) {
      cout << d - abs(0-a[i]) - abs(a[i]-a[i+1]) + abs(0-a[i+1]) << endl;
    } else {
      cout << d - abs(a[i-1]-a[i]) - abs(a[i]-a[i+1]) + abs(a[i-1]-a[i+1]) << endl;
    }
  }

  return 0;
}


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

int main(void){
	int n, k;
	cin >> n >> k;
	double ans = 0;
	for(int i = 1; i <= n; ++i){
		int m = 1;
		while(true){
			if(i*m>=k) break;
			m *= 2;
		}
		ans += 1.0/m;
	}
	printf("%.10lf\n", ans/(double)n);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define mod 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol mem[100010];
bool f[10000];
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n[100];
    for(int i=1;i<=9;i++) cin >>n[i];
    int m;
    cin >>m;
    for(int i=0;i<m;i++){
	int a;
	cin >>a;
	f[a]=true;
    }
    bool yes=false;
    if(f[n[1]]){
	if(f[n[2]]&&f[n[3]]) yes=true;
	if(f[n[4]]&&f[n[7]]) yes=true;
	if(f[n[5]]&&f[n[9]]) yes=true;
    }
    if(f[n[2]]&&f[n[5]]&&f[n[8]]) yes=true;
    if(f[n[4]]&&f[n[5]]&&f[n[6]]) yes=true;
    if(f[n[7]]&&f[n[8]]&&f[n[9]]) yes=true;
    if(f[n[3]]&&f[n[6]]&&f[n[9]]) yes=true;
    if(f[n[3]]&&f[n[5]]&&f[n[7]]) yes=true;
    if(yes) cout <<"Yes\n";
    else cout <<"No\n";
    return (0);
}


Measured memory_bytes: 256
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
n
a1 b1
...
an bn

n 10^5
ai bi 10^9
 */
int n;
ll a[100000],b[100000];

int main(){
  cin>>n;
  REP(i,n){
    cin>>a[i]>>b[i];
  }

  ll inc=0;
  for(int i=n-1; i>=0; i--){
    if((a[i]+inc)%b[i]>0)
      inc+=b[i]-((a[i]+inc)%b[i]);
    LOG("a[%d]=%lld, b[%d]=%lld, inc=%lld\n", i,a[i],i,b[i],inc);
  }

  cout<<inc<<endl;

  return 0;
}


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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    char vec[100][100];
    rep(i,3){
        rep(j,3){
            cin >> vec[i][j];
        }
    }
    cout << vec[0][0];
    cout << vec[1][1];
    cout << vec[2][2];
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
 int a,b;
cin>>a>>b;
 	
if((a<=13)&&(a>=1))	 
if((b<=13)&&(b>=1))

	if((a==1)&&(a!=b))
	
	cout<<"Alice";
   else	if((b==1)&&(b!=a))
	
	cout<<"Bob";
	else if(a==b)
	cout<<"Draw";
	else
	{
	
     if(b>a)
	cout<<"Bob";
	else if(a>b)
	
	cout<<"Alice";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcd(long long a,long long b){return a*b / gcd(a,b) / gcd(a,b);}
int main()
{
	int N;
	cin>>N;
	string result;
	switch(N%10)
	{
		case 3:
			result = "bon";
			break;
		case 0:
		case 1:
		case 6:
		case 8:
			result = "pon";
			break;
		default:
			result = "hon";
	}
	cout<<result<<endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

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

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	ll r;
	cin >> r;
	
	cout << r * r << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long m = sc.nextLong();
        
        // to: 隣接リスト(有向)
        List<Integer>[] to = new List[n];
        for (int i = 0; i < n; i++) {
            to[i] = new ArrayList<Integer>();
        }
        for (int i = 0; i < m; i++) {
            int p = sc.nextInt() - 1;
            int q = sc.nextInt() - 1;
            to[p].add(q);
        }
        
        int start = sc.nextInt() - 1;
        int goal = sc.nextInt() - 1;
        
        // ans: ビルstartの0階からビルgoalの0階に行くまでの歩数
        // 但し、ビル移動毎に1階上がる(二次元の最短経路問題)
        int ans = 0;
        Queue<int[]> que = new ArrayDeque<int[]>();
        que.add(new int[]{start, 0, 0});
        boolean[][] visited = new boolean[n][3];
        while (!que.isEmpty()) {
            int[] cur = que.poll();
            int p = cur[0];
            int f = cur[1];
            int l = cur[2];
            
            if (visited[p][f] == true) continue;
            visited[p][f] = true;
            
            if (p == goal && f == 0) {
                ans = l;
                break;
            }
            
            // 子の次の階に歩数+1を配る
            for (Integer q : to[p]) {
                que.add(new int[]{q, (f + 1) % 3, l + 1});
            }
        }
        if (ans == 0) {
            System.out.println(-1);
        } else {
            // 3歩 = けんけんぱ1回分
            System.out.println(ans / 3);
        }
    }
}

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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

void solve() {
    Int n, k;
    cin >> n >> k;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }
    Int sum1 = 0;
    for (Int i = 0; i < n - 1; i++) {
        for (Int j = i + 1; j < n; j++) {
            if (a[i] > a[j]) {
                sum1++;
                sum1 %= mod;
            }
        }
    }
    sum1 = sum1 * k % mod;
    Int sum2 = 0;
    for (Int i = 0; i < n; i++) {
        for (Int j = 0; j < n; j++) {
            if (a[i] > a[j]) {
                sum2++;
                sum2 %= mod;
            }
        }
    }
    Int mul = k * (k - 1) / 2;
    mul %= mod;
    sum2 = sum2 * mul % mod;
    print((sum1 + sum2) % mod);
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[4], k, d;
	for (int i = 0; i < 3; i++) cin >> a[i];
	sort(a, a + 3);
	cin >> k;
	for (int i = 0; i < k; i++)
		{
			a[2] *= 2;
			sort(a, a + 3);
		}
	cout << a[0] + a[1] + a[2] << endl;
	return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

struct SegmentTree {
private:
  int n;
  vector<LL> node;

public:
  SegmentTree(int sz) {
      n = 1; while(n < sz) n *= 2;
      node.resize(2*n-1, 0);
  }
  LL getmax(int x) {
    x += (n - 1);
    LL ans=node[x];
    while(x > 0) {
        x = (x - 1) / 2;
        ans=max(ans,node[x]);
    }
    return ans;
  }
  void update(int a, int b, LL val, int k=0, int l=0, int r=-1) {
    if(r < 0) r = n;
    if(r <= a || b <= l) return;
    if(a <= l && r <= b){
      node[k]=max(node[k],val);
    }else{
      update(a, b, val, 2*k+1, l, (l+r)/2);
      update(a, b, val, 2*k+2, (l+r)/2, r);
    }
  }
};

int main(){
  int n;
  cin >> n;
  vector<LL> x(n),id(n);
  vector<pair<int,int>> xs(n);
  LL total=0;
  for(int i=0;i<n;i++){
    cin >> x[i];
    xs[i]={x[i],i};
    total+=x[i];
  }
  sort(all(xs));
  for(int i=0;i<n;i++){
    id[xs[i].second]=i;
  }
  SegmentTree seg(n);
  LL now;
  for(int i=0;i<n;i++){
    // for(int j=0;j<n;j++){
    //   cout << seg.getmax(j) << " ";
    // }
    // cout << endl;
    now=seg.getmax(id[i]);
    seg.update(id[i],n,now+x[i]);
  }
  // for(int j=0;j<n;j++){
  //   cout << seg.getmax(j) << " ";
  // }
  // cout << endl;
  cout << total-seg.getmax(n-1) << endl;
  return 0;
}



Measured memory_bytes: 7304
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"

int memo[2010][2010];
vector<int>sums, cs, aws;
int getnum(int l, int r) {
	if (memo[l][r])return memo[l][r];
	else {
		if (l + 1 == r)return 1;
		else {
			int amin = r-l;
			for (int m = l + 1; m <= r - 1; ++m) {
				const int lnum = getnum(l, m);
				const int rnum = getnum(m, r);
				if (m == l + 1) {
					if (rnum == 1) {
						if (sums[r-1] - sums[m - 1] <= cs[l]) {
							amin = 1;
						}
					}
				}
				if (m == r - 1) {
					if (lnum == 1) {
						if (sums[m - 1] - sums[l - 1] <= cs[r-1]) {
							amin = 1;
						}
					}
				}
				amin = min(amin, lnum + rnum);
			}
			return memo[l][r]=amin;
		}
	}
}

int main() {
	int N; 
	cin >> N;
	aws.resize(N+1);
	sums.resize(N + 1);
	cs.resize(N+1);
	for (int i = 0; i < N; ++i) {
		cin >> cs[i + 1];
		cin >> aws[i + 1];
		sums[i + 1] = sums[i] + aws[i + 1];
	}
	int ans = getnum(1, N + 1);
	cout << ans << endl;

	return 0;
}

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

priority_queue<int> g[100010];

int main(){
	int n,m;
	cin>>n>>m;
	
	long long res=0;
	

	for (int i=0; i<n; i++){
		int a,b;
		cin>>a>>b;
		g[a].push(b);
	}
	
	for (int i=1; i<=m; i++){
		if (g[i].empty()) continue;
		res+=g[i].top();
		g[i].pop();
		
		int p=i;
		
		while ((!g[i].empty()) and p<=m){
			g[p].push(g[i].top());
			g[i].pop();
			p++;
		}
	}
	
	cout<<res<<endl;

}


Measured memory_bytes: 163456
#include<stdio.h>
#include<string.h>
int main()
{
    char s[11],t[12];
    int i,a=0;
    scanf("%s",s);
    scanf("%s",t);
    int d = strlen(s);
    for(i=0;i<d;i++){
        if(s[i]==t[i])a++;
    }
    if(a==d)printf("Yes\n");
    else printf("No\n");

}


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

#define BOLT ios_base::sync_with_stdio(0)
#define newline cout << "\n"
#define eline cerr << "\n"
#define IN_FILE freopen("input.txt", "r", stdin)
#define OUT_FILE freopen("output.txt", "w", stdout)

// g++ -o contest contest.cpp
long long path[100000];
long long dp[100000];
int n, k;

void USEFILE(){
    IN_FILE;
    OUT_FILE;
}

void reset(){
    memset(path, 0, sizeof path);
    memset(dp, -1, sizeof dp);
}

long long process(int i){
    long long ans = 1000000000000000000;
    if(i>=n) return 0;
    if(dp[i] != -1) return dp[i];
    
    for(int m = 1 ; m <= k ; m++){
        if(i+m>=n){
            break;
        }
        else 
            ans = min( abs( path[i]-path[i+m]) + process(i+m), ans);
    }   
    if(ans == 1000000000000000000) {
        ans = 0;
    }
    dp[i] = ans;
    return ans;
}


void solve(int kase){
    reset();
    cin >> n >> k;
    for(int i = 0 ; i < n; i++){
        cin >> path[i];
    } 
    cout << process(0);newline;
}


int main(){
    BOLT;
    // USEFILE();
    int t, kase = 0;
    // cin >> t;
    // while(t--)
    //      solve(++kase);
    solve(0);

    return 0;
}


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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
// #define int long long
// #define pow mypow

typedef pair<int,int> pii;
const int N = 5e5+5;
const int INF = 1e9+5;
const int MOD = 1e9+7;

int n, q, c[N];
vector<pii> query[N];
int fen[N];
int rightmost[N], ans[N];

void add(int i, int x){
	while(i<=n){
		fen[i] += x;
		i += (i&-i);
	}
}
int sum(int i) {
	int res = 0;
	while(i){
		res += fen[i];
		i -= (i&-i);
	}
	return res;
}
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n >> q;
	for(int i=1; i<=n; i++) cin >> c[i];
	for(int i=0; i<q; i++){
		int l, r; cin >> l >> r;
		query[r].push_back({l, i});
	}
	for(int i=1; i<=n; i++){
		if (rightmost[c[i]]) add(rightmost[c[i]], -1);
		rightmost[c[i]] = i;
		add(i, +1);
		for(pii x:query[i]) {
			ans[x.nd] = sum(i) - sum(x.st-1);
		}
	}
	for(int i=0; i<q; i++) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 33268
k = int(input())
ans=0

def gcd(a,b):
    return b if a%b == 0 else gcd(b,a%b)

for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            ans += gcd(gcd(a,b),c)

print(ans)

Measured memory_bytes: 80584
#include <stdio.h>

int main(){
	char S[4];
	scanf("%s", &S);
	int sum = 0;
	for(int i=0;i<4;i++){
		if(S[i] == '+') sum += 1;
		else sum -= 1;
	}
	printf("%d", sum);
	return 0;
}

Measured memory_bytes: 128
# Code for C - City Savers
# Use input() to fetch data from STDIN
n = input()
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

total = 0
for i in range(len(a) - 1):
    s = min(a[i], b[i])
    a[i] = a[i] - s
    b[i] = b[i] - s

    t = min(a[i+1], b[i])
    a[i+1] = a[i+1] - t
    b[i] = b[i] - t
    total += s + t


print(total)


Measured memory_bytes: 18436
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

ll dp[13][1<<13][10]; //桁数, 現在のエレベーター,　前の桁 

bool solve(){
  int n;
  int low[7], up[7];
  
  scanf("%d", &n);
  if(n == 0) return false;
  
  for(int i=0;i<n;i++) scanf("%d%d", low+i, up+i);

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

  dp[0][1][0] = 1;

  ll ans = 0;

  for(int i=0;i<n*2;i++){
    for(int j=0;j<(1<<(2*n));j++){
      for(int k=0;k<10;k++){
        int next[10] = {};

        for(int l=0;l<n;l++){
          //1桁目
          if((1 << (l*2)) & j){
            for(int x=max(1,low[l]);x<=min(9, up[l]);x++)
              next[x] |= 1 << (l*2+2);
            for(int x=max(1,low[l]/10);x<=min(9,up[l]/10);x++)
              next[x] |= 1 << (l*2+1);
          }
          //2桁目
          if((1 << (l*2+1)) & j){
            for(int x=max(0,(low[l]-k*10));x<=min(9, up[l]-k*10);x++)
              next[x] |= 1 << (l*2+2);
          }
        }

        for(int l=0;l<10;l++){
          dp[i+1][next[l] & ((1 << n*2) - 1)][l] += dp[i][j][k];
          if(next[l] & (1 << (n*2))) ans += dp[i][j][k];
        }
        
      }
    }
  }
  
  cout << ans << endl;
  return true;
}

int main(){
  while(solve());
  
  return 0;
}



Measured memory_bytes: 11468
N = int(input())
input_list = [int(input())for _ in range(N)]

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)
  
def lcm(x, y):
    return (x * y) // gcd(x, y)
  
initial_num = 1
for i in input_list:
    t = lcm(initial_num, i)
    if  t > initial_num:
        initial_num = t
        
print(initial_num)

Measured memory_bytes: 3064
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
K = 17
N = int(input())
A = [0] * (2**K-1) + [int(a) for a in input().split()] + [0] * (2**K-N)
for i in range(2**K-1)[::-1]:
    A[i] = gcd(A[2*i+1], A[2*i+2])

def calc(i0):
    g = 0
    for k in range(K):
        i = (i0^(1<<k)) + (2**K-1)
        for l in range(k):
            i = (i-1) // 2
        g = gcd(g, A[i])
    return g
ma = 0
for i in range(N):
    ma = max(ma, calc(i))
print(ma)

Measured memory_bytes: 68068
#include <stdio.h>

int main(void)
{
	int n, b, f, r, v, i, j, k;
	int apert[4][3][10] = {};

	scanf("%d", &n);

	for (i = 0; i < n; i++)
	{
		scanf("%d %d %d %d", &b, &f, &r, &v);

		apert[b-1][f-1][r-1] += v;
	}

	for (i = 0; i < 4; i++)
	{
		for (j = 0; j < 3; j++)
		{
			for (k = 0; k < 10; k++)
			{
				printf(" %d", apert[i][j][k]);
			}
			printf("\n");
		}

		if (i != 3)
		{
			printf("####################\n");
		}
	}


	return 0;
}

Measured memory_bytes: 612
#include <iostream>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

int count = 0;

void Merge(int A[], int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1+1], R[n2+1];
  rep(i,n1) L[i] = A[left+i];
  rep(i,n2) R[i] = A[mid+i];
  L[n1] = R[n2] = 0x7FFFFFFF;
  i = j = 0;
  for (k = left; k < right; k++) {
    count++;
    if (L[i] < R[j]) { A[k] = L[i]; i++; }
    else { A[k] = R[j]; j++; }
  }
}

void MergeSort(int A[], int left, int right) {
  if (left+1 < right) {
    int mid = (left + right) / 2;
    MergeSort(A, left, mid);
    MergeSort(A, mid, right);
    Merge(A, left, mid, right);
  }
} 

int main () {
  cin.tie(0); // tie
  ios::sync_with_stdio(false); // sync
  int n, i;

  // input
  cin >> n;
  int A[n];
  rep(i,n) cin >> A[i];
  MergeSort(A, 0, n);

  // output
  rep(i,n) {
    cout << A[i];
    if (i < n-1) cout << " ";
  }
  cout << endl << count << endl;
  return 0;
}

Measured memory_bytes: 5108
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
    string a,b,c;
    cin>>a>>b>>c;
    if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0])cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	// we can assume that a is always greater than b
	
	public static int gcd(int a, int b) {
		return (b == 0)?  a : gcd(b, a % b);
	}
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int a = 0, b = 0;
		
		a = cin.nextInt();
		b = cin.nextInt();
		
		int c = Math.min(a,b);
		a = Math.max(a, b);
		
		System.out.println(gcd(a , c));
		
	
	}
}

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

const int INF = 1001001001;

int main(){
    long long  a;
    string b;
    cin >>a>>b;
    long long  ans;
    //
    b.erase(1,1);
    int c;
    c = stoi(b);
    ans=a*c;
    cout<<ans/100;

    return 0;
}



Measured memory_bytes: 3632
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val N: Int = sc.nextInt()
    val M: Int = sc.nextInt()

    val A = Array(N) { sc.nextInt() }

    val sumCount = A.sum()
    A.sortDescending()
    val ninnki = A.take(M)

    val minimalCount = sumCount / (4.0 * M)

    val yes = ninnki.all { !(it < minimalCount) }
    if (yes) {
        println("Yes")
    } else {
        println("No")
    }
}


Measured memory_bytes: 34132
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

int main()
{
    IOS();
    ll a,b,c,d;
    cin>>a>>b>>c;
    if(a + b >= c)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256