akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int mod = 1e9+7;
ll fac[1100],ifac[1100],f[610][610],p[610];
int vis[610][610],n,m,match[610],s[610];
ll calc(int n){return fac[n]*ifac[n/2]%mod*p[n/2]%mod;}
ll fp(ll a,ll k){
	ll ans=1;
	for(;k;k>>=1,a=a*a%mod)
		if(k&1) ans=a*ans%mod;
	return ans;
}
ll solve(int l,int r){
	if(l>r) return 1;
	if(vis[l][r]) return f[l][r];
	vis[l][r]=1;
	for(int i=l;i<=r;i++)
		if(match[i]&&(match[i]<l||match[i]>r)) return f[l][r]=0;
	ll now=calc(s[r]-s[l-1]);
	for(int i=l+1;i<r;i+=2){
		now=(now-solve(l,i)*calc(s[r]-s[i]))%mod;
	}
	return f[l][r]=(now+mod)%mod;
}
int main(){
	read(n);read(m);
	for(int i=1;i<=m;i++){
		int x,y;read(x);read(y);
		match[x]=y;
		match[y]=x;
	}
	for(int i=1;i<=2*n;i++)
		s[i]=s[i-1]+(match[i]==0);
	fac[0]=1;
	for(int i=1;i<=2*n;i++)
		fac[i]=fac[i-1]*i%mod;
	ifac[2*n]=fp(fac[2*n],mod-2);
	for(int i=2*n;i;i--)
		ifac[i-1]=ifac[i]*i%mod;
	for(int i=0;i<=2*n;i++)
		p[i]=fp(fp(2,i),mod-2);
	ll ans=0;
	for(int i=1;i<=2*n;i++)
		for(int j=i+1;j<=2*n;j+=2){
			ans=(ans+calc(s[i-1]+s[2*n]-s[j])*solve(i,j))%mod;
		}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 4480
n = int(input())
s = input()
ans = s.count('R') * s.count('G') * s.count('B')

for i in range(n - 2):
    for j in range(i + 1, n - 1):
        k = j + (j - i)
        if k < n and s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            ans -= 1
print(ans)


Measured memory_bytes: 9128
#pragma GCC optimize("Ofast")   //Comment optimisations for an interatcive problem - use endl
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cout<<"///REACHED///\n";
#define  deb1(x)        cout<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cout<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cout<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  unordered_map<ll,ll>  um;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int qq;
ll r;
//<<-----Implement Functions Here---->>//


//<<-----Start of Main--------------->>//

int main(){
	fastio;randomINIT;

	cin>>r;
	cout<<r*r;

    
}

Measured memory_bytes: 2560
N = int(input())
A = list(map(int, input().split()))
i = 0
j = 0
while i < N - 1:
  if A[i] == i+1 and A[i+1] == i+2:
    j += 1
    i += 2
  elif A[i] == i+1 and A[i+1] != i+2:
    j += 1
    i += 1
  else:
    i += 1
if i < N:
  if A[i] == i + 1:
    j += 1
print(j)

Measured memory_bytes: 14004
#include <iostream>
#include <assert.h>
#include <algorithm>
#include <vector>
#include <map>
#include <string>

struct city_type{
    int32_t pref;
    int64_t year;
    int32_t idx;
    std::string id;
};

bool compare_city(city_type& a, city_type& b){
    if(a.pref != b.pref){
        return a.pref < b.pref;
    }
    else{
        return a.year < b.year;
    }
}
bool compare_city_byidx(city_type& a, city_type& b){
    return a.idx < b.idx;
}

std::string get_id(int64_t pref, int64_t num){
    std::string upper = std::to_string(pref);
    std::string lower = std::to_string(num);
    //assert()
    upper = std::string(6 - upper.size(), '0') + upper;
    lower = std::string(6 - lower.size(), '0') + lower;
    return upper+lower;
}

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

    int64_t N, M;
    std::cin >> N >> M;

    std::vector<city_type> cities(M);
    for(int32_t i = 0; i < M; i ++){
        std::cin >> cities[i].pref >> cities[i].year;
        cities[i].idx = i;
    }

    std::sort(cities.begin(), cities.end(), compare_city);
    int64_t id_cnt = 1;
    int64_t prev_pref = 1;
    for(int32_t i = 0; i < M; i ++){
        if(cities[i].pref != prev_pref){
            prev_pref = cities[i].pref;
            id_cnt = 1;
        }
        cities[i].id = get_id(prev_pref, id_cnt);
        id_cnt++;
    }

    std::sort(cities.begin(), cities.end(), compare_city_byidx);
    for(auto& i : cities){
        std::cout << i.id << std::endl;
    }
    return 0;

}


Measured memory_bytes: 10880
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int H,W,D; cin>>H>>W>>D;
  vector<pii> A(H*W+1);
  vector<map<int,int>> B(1+H*W);
  rep(i,0,H){
    rep(j,0,W){
      int X; cin>>X;
      A[X].first=i;
      A[X].second=j;
    }
  }
  vector<bool> F(H*W+1);
  REP(i,1,H*W){
    if(F[i])
      continue;
    int sum=0;
    B[i][i]=0;
    F[i]=1;
    REP(j,1,(H*W-i)/D){
      F[i+j*D]=1;
      sum+=(abs(A[i+j*D].first-A[i+(j-1)*D].first)+abs(A[i+j*D].second-A[i+(j-1)*D].second));
      B[i][i+j*D]=sum;
    }
  }
  int Q; cin>>Q;
  rep(_,0,Q){
    int L,R; cin>>L>>R;
    int P=(L-1)%D+1;
    cout<<B[P][R]-B[P][L]<<endl;
  }
  }


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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
int main() 
{
    int n, m ,x;
    cin >> n >> m >> x;
    vector<vector<int>> mat(n, vector<int>());
    vector<int> costs;
    for (int i = 0; i < n; i++)
    {
        int c;
        cin >> c;
        costs.push_back(c);
        for (int j = 0; j < m; j++)
        {
            int num;
            cin >> num;
            mat[i].push_back(num);
        }
    }
    long long minCost = INT32_MAX;
    for (int i = 0; i < std::pow(2, n); i++)
    {
        long long currCost = 0;
        vector<int> val (m, 0);
        for (int j = 0; j < n; j++)
        {
            if ((i & (1 << j)) != 0)
            {
                currCost += costs[j];
                for (int k = 0; k < m; k++)
                {
                    val[k] += mat[j][k];
                }
            }
        }
        bool isOkay = true;
        for (int j = 0; j < m; j++)
        {
            if (val[j] < x)
            {
                isOkay = false;
                break;
            }
        }
        if (isOkay && currCost < minCost)
        {
            minCost = currCost;
        }
    }
    if (minCost == INT32_MAX)
        cout << -1 << endl;
    else
        cout << minCost << endl;
    
    
}

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

using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
	char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
	vector<char*> v({token});
	while(token = strtok(NULL,", ")) v.push_back(token);
	return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
	debug() << " [" << args.back() << ": " << H << "] ";
	args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=1e9+7;
const int MX=0x3f3f3f3f;

int main(){
	IOS;
	string s;
	cin>>s;
	int i,ans=0;
	REP(i,0,sz(s)-1) (ans+=s[i]-'0')%=9;
	cout<<(ans?"No":"Yes");
	return 0;
}

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

int main(int argc, char const* argv[]) {
	int a,b,ans;
	char op;
	std::cin >> a >> op >> b;
	while (op!='?') {
		switch (op) {
			case '+':
				ans = a + b;
				break;
			case '-':
				ans = a - b;
				break;
			case '*':
				ans = a * b;
				break;
			case '/':
				ans = a / b;
				break;
			default:
				ans = 0;
				break;
		}
		std::cout << ans << std::endl;
		std::cin >> a >> op >> b;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <cstring>
#include <set>
const int MAXN = 1e5 + 10;

char str[MAXN];
int n, a[MAXN];
namespace solver1 {
  void main() {
    int ans = n;
    for (int i = 1; i < n; i++) {
      if (a[i] != a[i + 1]) ans = std::min(ans, std::max(i, n - i));
    }
    printf("%d\n", ans);
  }
}
int main() {
  scanf("%s", str + 1);
  n = strlen(str + 1);
  for (int i = 1; i <= n; i++) {
    a[i] = str[i] - '0';
  }
  solver1::main();
}


Measured memory_bytes: 640
using System;
class Program{
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		Array.Sort(s);
		int ans=0;
		for(int i=0;i<n;i++){ans+=Math.Min(s[i*2],s[i*2+1]);}
		Console.WriteLine("{0}",ans);
	}
}

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


int main() {
	string s,t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if (s < t)
	{
		cout << "Yes";
	}
	else cout << "No";

}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define all(v) (v).begin(),(v).end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define pb push_back
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;

int func(int a,int b){
    //if(a<b)return func(b,a);
    if(b==0)return a;
    return func(b,a%b);
}

int main(){
    int n,x;
    cin>>n>>x;
    vint a(n);
    rep(i,n)cin>>a[i];
    int first=abs(x-a[0]);
    reps(i,0,n-1){
        first=func(first,abs(a[i]-a[i+1]));
    }
    cout<<first<<endl;
}

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

int h, w, dp[1005][1005];
char grid[1005][1005];
const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> h >> w;
    for(int i=1; i<=h; i++)
        for(int j=1; j<=w; j++)
            cin >> grid[i][j];

    dp[1][1] = 1;
    for(int i=1; i<=h; i++)
        for(int j=1; j<=w; j++) {
            if(grid[i][j]=='#' || (i==1&&j==1)) continue;
            if(grid[i-1][j]=='.' && grid[i][j-1]=='.') dp[i][j] = dp[i-1][j] + dp[i][j-1];
            else if(grid[i-1][j]=='.' && grid[i][j-1]!='.') dp[i][j] = dp[i-1][j];
            else if(grid[i-1][j]!='.' && grid[i][j-1]=='.') dp[i][j] = dp[i][j-1];
            dp[i][j] %= MOD;
        }
    cout << dp[h][w] << endl;

    return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 25, M = 1e6 + 25, oo = 1e9, mod = 1e9 + 7;
const long long OO = 1e18+25;

int n,m, mem[N][N];
char s[N][N];

bool vaild(int i,int j)
{
    return (i < n && j < m && s[i][j] != '#');
}

int dp(int i=0, int j=0)
{
    if(i == n-1 && j == m-1) return 1;
    int &ret = mem[i][j];
    if(ret != -1) return ret;
    return ret = ((vaild(i+1,j)?dp(i+1,j):0) + (vaild(i,j+1)?dp(i,j+1):0)) % mod;
}

int main()
{
    memset(mem, -1, sizeof mem);
    scanf("%d%d",&n,&m);
    for(int i=0;i<n; i++) scanf("%s",&s[i][0]);
    printf("%d\n",dp());
    return 0;
}
	     		 					   	 	 								 	

Measured memory_bytes: 5504
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

S = input()
ans = "AC"
if S[0] != 'A' or S[2:-1].count('C') != 1 or S[-1] == 'C' or S[1] == 'C':
  ans = "WA"
for i in range(1, len(S)):
  if S[i].isupper() == True and S[i] != 'C':
    ans = "WA"
print(ans)

Measured memory_bytes: 38256
#include <stdio.h>

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

    for (i = 0; i < 4; i++){
        for (j = 0; j < 3; j++){
            for (k = 0; k < 10; k++){
                count[i][j][k] = 0;
            }
        }
    }

    scanf("%d", &n);

    for (i = 0; i < n; i++){
        scanf("%d %d %d %d", &b, &f, &r, &v);
        count[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", count[i][j][k]);
            }
            printf("\n");
        }
        if (i < 3)
            printf("####################\n");
    }
  
    return 0;
}

Measured memory_bytes: 612
#include<stdio.h>
#include<string.h>

int main()
{
	char str[101];
	int i, check= 0;

	scanf("%s", str);

	for(i= 0; i< strlen(str); i++)
	{
		if(str[i]== 'C')
		{
			check++;
			break;
		}
	}
	for(; i< strlen(str); i++)
	{
		if(str[i]==  'F')
		{
			check++;
			break;
		}
	}

	if(check== 2)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);

//union by size + path having
class UnionFind{
    public:
    vector<long long> par; // 各元の親を表す配列
    vector<long long> siz; // 素集合のサイズを表す配列(1 で初期化)


    // Constructor
    UnionFind(long long sz_) : par(sz_), siz(sz_,1LL){
        for (long long i = 0; i < sz_; ++i)
        par[i] = i; // 初期では親は自分自身
    }
    void init(long long sz_){
        par.resize(sz_);
        siz.assign(sz_,1LL); // resize だとなぜか初期化されなかった
        for (long long i = 0; i < sz_; ++i)
            par[i] = i; // 初期では親は自分自身
    }
    // Member Function


    // Find
    long long root(long long x){ // 根の検索
        while (par[x] != x){
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }
    // 結合(Unite, Merge)
    bool merge(long long x, long long y){
        x = root(x);
        y = root(y);
        if (x == y){
            return false;
        }
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]){
            swap(x, y);
        }
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }


    // 連結判定(つながっているときはture,つながっていなければfalse)
    bool issame(long long x, long long y){ 
        return root(x) == root(y);
    }


    // 素集合のサイズ
    long long size(long long x){ 
        return siz[root(x)];
    }
};
int main(){
    int n,m;
    cin >>n>>m;
    V ans(m+2,0LL);
    ll conect=0LL;
    VP path(m+3);

    rep(i,m){
        cin>>path[i].F>>path[i].S;
        path[i].F--;
        path[i].S--;
    }
    UnionFind map(n);
    for(int i=m-1;i>=0;i--){
        ans[i] =(ll)n*(n-1)/2-conect;
        if (!map.issame(path[i].F, path[i].S)){
            conect+=(map.size(path[i].F)*map.size(path[i].S));
        }
            map.merge(path[i].F, path[i].S);

    }
    rep(i,m){
        cout<<ans[i]<<endl;
    }
}

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

int main() {
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    for (int i = 0; i <= n / r; i++) {
        for (int j = 0; j <= (n - r * i) / g; j++) {
            int residual = n - r * i - g * j;
            if (residual % b == 0) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

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

class dice{
public:
	int d[6], tmp[6];
	dice(int n[6]){
		for (int i = 0; i < 6; i++){
			d[i] = n[i];
		}
	}
	void throwdice(char c){
		for (int i = 0; i < 6; i++){
			tmp[i] = d[i];
		}
		if (c == 'N'){
			d[0] = tmp[1];
			d[1] = tmp[5];
			d[2] = tmp[2];
			d[3] = tmp[3];
			d[4] = tmp[0];
			d[5] = tmp[4];
		}
		else if (c == 'E'){
			d[0] = tmp[3];
			d[1] = tmp[1];
			d[2] = tmp[0];
			d[3] = tmp[5];
			d[4] = tmp[4];
			d[5] = tmp[2];
		}
		else if (c == 'W'){
			d[0] = tmp[2];
			d[1] = tmp[1];
			d[2] = tmp[5];
			d[3] = tmp[0];
			d[4] = tmp[4];
			d[5] = tmp[3];
		}
		else{
			d[0] = tmp[4];
			d[1] = tmp[0];
			d[2] = tmp[2];
			d[3] = tmp[3];
			d[4] = tmp[5];
			d[5] = tmp[1];
		}
	}
};
int main()
{
	int n[6];
	for (int i = 0; i < 6; i++){
		cin >> n[i];
	}
	dice dice1(n);
	string dir;
	cin >> dir;
	for (int i = 0; i < dir.length(); i++){
		dice1.throwdice(dir[i]);
	}
	cout << dice1.d[0] << endl;


	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 
int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> V(n, 0);
    for (ll i = 0; i < k; ++i) {
        ll d;
        cin >> d;
        for (ll j = 0; j < d; ++j) {
            ll a;
            cin >> a;
            --a;
            ++(V[a]);
        }
    }
    ll res = 0;
    for (auto v : V) {
        if (v == 0) ++ res;
    }
    cout << res << endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<algorithm>
#include<tuple>


int main(void){
	int N;
	int al=0,bo=0;
	std::priority_queue<int> pq;
	int m1;
	std::cin>>N;
	for(int i=0;i<N;i++){
		std::scanf("%d",&m1);
		pq.push(m1);
	}

	int m2;
	while(pq.empty()==false){
		m2=pq.top();
		pq.pop();
		al+=m2;
		if(pq.empty()==false){
			m2=pq.top();
			pq.pop();
			bo+=m2;
		}
	}
	std::cout<<al-bo<<std::endl;

	return 0;
}


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

int main() {
    ll n,ans=0;
    string hoge;
    map<string,bool> mp;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> hoge;
        mp[hoge] = true;
    }
    cout << mp.size() << endl;
    return 0;
}

Measured memory_bytes: 19224
/*

    idea: start from the end and try to reach the beginning taking the longest jumps possible.

*/


#include<bits/stdc++.h>


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 1;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;
vi v;

void solve(int testCase){

    scanf("%d %d" , &n , &m);

    string s;
    cin >> s;

    /// to start from the end
    reverse(s.begin() , s.end());

    for(int i = 0 ; s[i] ; i ++){
            if(s[i] == '0'){
                    /// store all positions of 0's
                    v.push_back(i);
            }
    }


    vi ans;

    /// initial position
    int curr = 0;

    while( true ){

            /// farthest place I can go
            int nxt = upper_bound(v.begin() , v.end() , curr + m) - v.begin() - 1;

            /// if I'm still in my place => no solution
            if(v[nxt] == curr){
                    printf("-1\n");
                    return;
            }

            /// insert the length of the jump into the answer
            ans.push_back(v[nxt] - curr);

            /// update position
            curr = v[nxt];

            /// Won
            if(curr == n)break;
    }

    /// print the answer backwards: from begin to end.
    reverse(ans.begin() , ans.end());

    for(int A : ans)printf("%d " , A);
    printf("\n");

}

main(){

    int t = 1;
    //scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


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

public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int[][] us = new int[n+1][n+1];
        int[] d = new int[n+1];
        for (int i = 0; i < n; i++) {
            int u = input.nextInt();
            int k = input.nextInt();
            while (k-- > 0) {
                int v = input.nextInt();
                us[u][v] = 1;
            }
            d[i+1] = -1;
        }
        d[1] = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 1; j <= n; j++) {
                if (d[j] == i) {
                    for (int k = 1; k <= n; k++) {
                        if (i != k && us[j][k] == 1 && d[k] == -1) {
                            d[k] = d[j]+1;
                        }
                    }
                }
            }
        }
        
        for (int i = 1; i <= n; i++) {
            System.out.println(String.format("%d %d", i, d[i]));
        }
    }
}

class Scanner {
    BufferedReader r;
    StreamTokenizer st;
    
    public Scanner(InputStream in) {
        r = new BufferedReader(new InputStreamReader(in));
        st = new StreamTokenizer(r);
    }
    
    public String next() {
        nextToken();
        return st.sval;
    }
    
    public Integer nextInt() {
        nextToken();
        return (int)st.nval;
    }
    
    private int nextToken() {
        int token = st.TT_EOF;
        try {
            token = st.nextToken();
        } catch (IOException e) {
        }
        return token;
    }
}

Measured memory_bytes: 16980
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long mod = 1000000007LL;
//const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int n;
vector<vector<pair<int, int>>> g;

pair<int, int> dfs1(ll cur, ll pre) {
	pair<int, int> ret(0, cur);
	for (auto& next : g[cur]) {
		if (next.first == pre) continue;
		auto cost = dfs1(next.first, cur);
		cost.first += next.second;
		if (ret.first < cost.first) ret = cost;
	}
	return ret;
}


int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	scanf("%d", &n);
	g.resize(n);
	for (ll i = 0; i < n - 1; i++) {
		int s, t, w; scanf("%d %d %d", &s, &t, &w);
		g[s].emplace_back(t, w);
		g[t].emplace_back(s, w);
	}
	printf("%d\n", dfs1(dfs1(0, -1).second, -1).first);
	return 0;
}



Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int L,R,d;
    cin >> L >> R >> d;
    int ans = 0;
    for(int i = L; i <= R; i++){
        if(i%d == 0) ans++;
    }
    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 3584
s = input()

s = s.replace('BC','F')
s = s.replace('C','B')

s = s.split('B')

def cnt(st):
	i = 0
	res = 0
	for s in st:
		if s == "A":
			i += 1
		if s == "F":
			res += i
	return res

ans = 0
for part in s:
	ans += cnt(part)

print(ans)


Measured memory_bytes: 5540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int D; //365
    cin >> D;
    int c[26];
    rep(i, 0, 26) {
        cin >> c[i];
    }
    int s[D][26];
    rep(i, 0, D) {
        rep(j, 0, 26) {
            cin >> s[i][j];
        }
    }
    ll t[D] = {};
    rep(i, 0, D) {
        t[i] = max(1, i % 27);
    }
    /*vector<int> last_day(26, -1);
    rep(i, 0, D) {
        if (i != 0) score[i] = score[i - 1];
        score[i] += s[i][t[i]];
        last_day[t[i]] = i;
        int decrease = 0;
        rep(j, 0, 26) {
            decrease += c[j] * (i - last_day[j]);
        }
        score[i] -= decrease;
    }*/
    rep(i, 0, D) {
        cout << t[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3600
from sys import stdin

if __name__ == '__main__':
    N = int(stdin.readline().rstrip())
    d = {}
    for i in range(N):
        poll = stdin.readline().rstrip()
        if not poll in d:
            d[poll] = 1
        else:
            d[poll] += 1
    maxv = max(d.values())
    max_k_list = [kv[0] for kv in d.items() if kv[1] == maxv]
    for key in sorted(max_k_list):
        print(key)

Measured memory_bytes: 33052
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char x;
    cin>>x;
    if(x=='A')cout<<"T"<<endl;
    if(x=='T')cout<<"A"<<endl;
    if(x=='G')cout<<"C"<<endl;
    if(x=='C')cout<<"G"<<endl;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  ll N; cin >> N;
  ll ans{};
  if (N % 2) {
    cout << ans << CRLF;
    return;
  }
  ll M = 10;
  while (N >= M) {
    ans += N / M;
    M *= 5;
  }
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define PI (4*atan(1))
int main(void){
	double a,b,c;
	scanf("%lf",&a);
	
	b = a*a*PI;
	c = a*2*PI;
	
	printf("%lf %lf\n",b,c);
	return 0;
}

Measured memory_bytes: 648
#include <bits/stdc++.h>
using namespace std;
long long a, b, x, ans;

long long f(long long n)
{
    if (n == -1) return 0;
    else return n / x + 1;
}

int main()
{
    scanf("%lld%lld%lld", &a, &b, &x);
    ans = f(b) - f(a - 1);
    printf("%lld\n", ans);
}

Measured memory_bytes: 384
N, M = map(int, input().split())
m = [i + 1 for i in range(M)]
for j in range(N):
  K = list(map(int, input().split()))
  n = K[0] + 1
  m = [K[k] for k in range(n) if k != 0 and (K[k] in m)]
print(len(m))

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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  int A = min(min(a, b),c);
  int C = max(max(a,b),c);
  int B = (a+b+c) - (A+C);
  cout << A << " ";
  cout << B << " ";
  cout << C << endl;
}




Measured memory_bytes: 3096
#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 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
long long dp[100002][2];
// 0index 桁　and 余裕
// 0余裕あり
int main() {
    string L;
    cin >> L;
    long long keta = L.length();
    dp[0][0] = 0;
    dp[0][1] = 1;
    REP(i, keta) {
        dp[i + 1][0] += (dp[i][0] * 3) % MOD;
        if(L[i] == '1') {
            dp[i + 1][1] += (dp[i][1] * 2) % MOD;
            dp[i + 1][0] += (dp[i][1]) % MOD;
        } else {
            dp[i + 1][1] += (dp[i][1]) % MOD;
        }
        dp[i + 1][0] %= MOD;
        dp[i + 1][1] %= MOD;
    }
    cout << (dp[keta][0] + dp[keta][1]) % MOD << endl;
}

Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

void stddev(int n){
	double a[n], m, sd;
  	m = 0;
  	for (int i = 0; i < n; i++){
    	cin >> a[i];
      	m += a[i];
    }
  	m /= n;
  	for (int i = 0; i < n; i++){
      	sd += pow(a[i] - m, 2);
  	}
  	sd /= n;
  	sd = sqrt(sd);
  	printf( "%.10f\n", sd);
  
}

int main(){
	int a, n;
  	a = 1;
  	while(a){
    	cin>> n;
      	if (n == 0) a = 0;
      	else stddev(n);
    }
}


Measured memory_bytes: 3292
x, y = map(int, input().split())
a = (1,3,5,7,8,10,12)
b = (4, 6, 9, 11)
c = (2, )

for g in (a, b, c):
  if x in g and y in g:
    print('Yes')
    break
else:
  print('No')



Measured memory_bytes: 2940
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();

		if(A>9||B>9) {
			System.out.println("-1");
		} else {
			System.out.println(A*B);
		}
	}
}


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

int main() {
	double w, h, x, y; cin >> w >> h >> x >> y;
    double s=w*h/2;
    bool flg=0;
    if(w==2*x && h==2*y) flg=1;
    cout << fixed << setprecision(6);
    cout << s << " " << flg <<endl;
}
//g++ -o c.exe c.cpp

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string str;
  cin >> str;
  int count = 0;
  for(int i =0; i< str.size(); i++){
    if(str.at(i) == '+'){
      count++;
    }
      else{
        count--;
      }
  }
  cout << count << endl;
  
}
    


Measured memory_bytes: 256
N = int(input())
TA = [list(map(int, input().split())) for i in range(N)]

t = 1
a = 1

for i in range(N):
    T, A = TA[i]
    if t > T or a > A:
        tmul = (t+T-1) // T
        amul = (a+A-1) // A
        mul = max(tmul, amul)
        T *= mul
        A *= mul
    t = T
    a = A
print(t+a)

Measured memory_bytes: 39408
#include<bits/stdc++.h>
using namespace std;
#define SET(a,e) memset(a,e,sizeof(a))
#define LL long long
#define pb push_back
#define x first
#define y second
#define PII pair<int,int>

int n, h[100055], dp[100055];

int main() {
	
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++) {
		scanf("%d", h + i);
	}
	
	dp[1] = abs(h[1] - h[0]);
	
	for (int i = 2; i < n; i++) {
		dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));
	}
	
	printf("%d\n", dp[n - 1]);
	
	return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n") 
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  string s;
  cin >> s;
  int n = s.size();
  cout << s[0] << n-2 << s[n-1] << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(a: int, b: int):
    print(-(-(a+b)//2))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(a, b)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;

int main() {
  ll A, B;
  cin >> A >> B;
  int K = (A+B)/2;
  if(K == (double)(A+B)/2.0)
    cout << K << endl;
  else
    cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map { it.toInt() }
    val h = readLine()!!.split(" ").map { it.toInt() }

    var s = 0
    for (i in h){
        if (i >=  K)s++
    }
    println(s)
}

Measured memory_bytes: 46264
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    string s,t;
    cin >> s >> t;
    if(s.size() < t.size()){
        pr("UNRESTORABLE");
        return 0;
    }
    RREP(i, s.size()-t.size()+1){
        string ss = s.substr(i, t.size());
        bool flag = true;
        REP(j, t.size()){
            if(ss[j]!='?' && t[j]!=ss[j]){
                flag = false;
                break;
            }
        }
        if(flag){
            REP(j, t.size()){
                s[i+j] = t[j];
            }
            REP(j, s.size()){
                if(s[j]=='?')s[j]='a';
            }
            pr(s);
            return 0;
        }
    }
    pr("UNRESTORABLE");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
   	#endif
    int n;
    cin>>n;
    int ans=100;
    for(int i=0;i<n;++i){
    	int a;
    	cin>>a;
    	int cnt=0;
    	while(a>0 && a%2==0){
    		a/=2;
    		++cnt;
    	}
    	ans=min(ans,cnt);
    }
    cout<<ans;
   return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using llong = long long;

const int INF = 100100100;
const int MOD = 1e9 + 7;

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

    llong M;
    cin >> M;

    llong sum = 0;
    llong ans = 0;
    REP(i, M) {
        llong d, c;
        cin >> d >> c;
        ans += c;
        sum += d * c;
    }

    cout << ((sum - 1) / 9) + ans - 1 << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
double A,B,n;
int main(){
	cin>>A>>B>>n;
	if(n<B)
		cout<<floor((n/B)*A);
	else
		cout<<floor(((B-1.0)/B)*A);
	return 0;
}

Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
#define MSG(a) cout << #a << " " << a << "\n";

int main(){
    int n,d; cin >> n >> d;
    vector<vector<int>> x(n, vector<int>(d));

    REP(i,n){
        REP(j,d){
            cin >> x.at(i).at(j);
        }
    }

    int ans = 0,x1,x2;
    double tmp = 0;

    // REP(i,n-1){
    //   REP(j,d){
    //       x1 = x.at(i).at(j);
    //       x2 = x.at(i+1).at(j);
    //       tmp += abs((x1-x2)*(x1-x2));
    //   }
    //   tmp = sqrt(tmp);
    //   if(floor(tmp) == tmp) ans++;
    //   tmp = 0;
    // }

    // REP(j,d){
    //     x1 = x.at(0).at(j);
    //     x2 = x.at(n-1).at(j);
    //     tmp += abs((x1-x2)*(x1-x2));
    // }
    // tmp = sqrt(tmp);
    // if(floor(tmp) == tmp) ans++;

    REP(i,n){
        for(int j = i+1; j < n;j++){
            REP(k,d){
                x1 = x.at(i).at(k);
                x2 = x.at(j).at(k);
                tmp += abs((x1-x2)*(x1-x2));
            }
            tmp = sqrt(tmp);
            if(floor(tmp) == tmp) ans++;
            tmp = 0;
        }
    }

    cout << ans << endl;

}

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

using namespace std;

int main(void){
	string S;
	int Y = 700;
	cin >> S;
	if(S[0] == 'o') Y += 100;
	if(S[1] == 'o') Y += 100;
	if(S[2] == 'o') Y += 100;

	cout << Y << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#define print(x) cout<<x<<endl;
using namespace std;


int main() {
    string n;
    cin>>n;
    int lossCount=0;
    for(unsigned int i=0; i<n.size();i++)
    {
        if(n.at(i)=='x'){
            lossCount++;
        }
            
    }
    if(lossCount>7){
        print("NO");
    }else{
        print("YES");
    }
    return 0;
}


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	if (24 <= n) {
		cout << 0 << endl;
		return 0;
	}
	int a[n];
	for (int &i : a) {
		cin >> i;
	}
	int ans = 0;
	for (int i = 0; i < (1 << n); i++) {
		int mini = numeric_limits<int>::max();
		bool puni[24]{};
		for (int j = 0; j < n; j++) {
			if ((i >> j) & 1) {
				if (puni[a[j]]) {
					goto next;
				} else {
					puni[a[j]] = true;
				}
			} else {
				int aa = (24 - a[j]) % 24;
				if (puni[aa]) {
					goto next;
				} else {
					puni[aa] = true;
				}
			}
		}
		if (puni[0]) {
			goto next;
		}
		puni[0] = true;
		for (int i = 0; i < 24; i++) {
			for (int j = 0; j < 24; j++) {
				if (i == j) {
					continue;
				}
				if (puni[i] && puni[j]) {
					mini = min({mini, abs(i - j), 24 - abs(i - j)});
				}
			}
		}
		ans = max(ans, mini);
		next:;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    double p = 0; //砂糖水の濃度
    int mw = a;   //水の量の最大値の100分の1
    int ms = 0;   //砂糖の量の最大値
    int w = 0;    //水の量の100分の1
    int s = 0;    //砂糖の量
    bool q = false;

    //操作1をi回行う( i = 0 ～ f/(100*a) )
    rep(i, f/(100*a) + 1) {
        //操作2をj回行う( j = 0 ～ f/(100*b) )
        rep(j, f/(100*b) + 1) {

            //操作1をi回, 操作2をj回行ったときの水の量の100分の1
            w = i*a + j*b;

            //水の量がf以上のときはダメ
            if(100*w >= f) {
                break;
            }

            //操作3をk回行う( k = 0 ～ e*w/c )
            rep(k, e*w/c + 1) {
                //操作4をl回行う( l = 0 ～ e*w/d )
                rep(l, e*w/d + 1) {

                    //操作3をk回, 操作4をl回行ったときの砂糖の量
                    s = k*c + l*d;

                    //水と砂糖の量の合計がfより大きいときはダメ
                    if(100*w + s > f) {
                        break;
                    }

                    //水と砂糖の量の合計がf以下で、水の量が0でないとき
                    if(100*w + s <= f && w != 0) {
                        
                        //砂糖が溶け残らず、pより濃度の高い砂糖水が作れるとき
                        if(e*w > s && p < s/(double)w) {
                            //現時点での水の最大値の100分の1をwに設定
                            mw = w;
                            //現時点での砂糖の最大値をsに設定
                            ms = s;
                            //現時点での濃度の最大値をpに設定
                            p = s/(double)w;
                        }

                        //理論上最適な砂糖水が作れるとき
                        if(e*w == s && p < s/(double)w) {
                            //水の最大値の100分の1をwに設定
                            mw = w;
                            //砂糖の最大値をsに設定
                            ms = s;
                            //濃度の最大値をpに設定
                            p = s/(double)w;
                            //qをtrueにして4重ループを抜ける
                            q = true;
                            break;
                        }
                    }
                    if(q) { break; }
                }
                if(q) { break; }
            }
            if(q) { break; }
        }
        if(q) { break; }
    }

    cout << 100*mw + ms << " " << ms << endl;
    return 0;
}

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

using namespace std;

int main(){
	while(true){
		vector<int> a, b;
		int n, m, sa = 0, sb = 0;
		cin >> n >> m;
		if(n == 0 && m == 0){ break; }
		a.resize(n);
		for(int i = 0; i < n; ++i){ cin >> a[i]; sa += a[i]; }
		b.resize(m);
		for(int i = 0; i < m; ++i){ cin >> b[i]; sb += b[i]; }
		bool found = false;
		int c, d;
		for(int i = 0; i < n; ++i){
			for(int j = 0; j < m; ++j){
				if(sa - a[i] + b[j] == sb - b[j] + a[i]){
					if(!found || c + d > a[i] + b[j]){
						c = a[i];
						d = b[j];
						found = true;
					}
				}
			}
		}
		if(found){
			cout << c << " " << d << endl;
		}else{
			cout << "-1" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0