akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
//typedef __int128_t lll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  string s;std::cin >> s;
  vll f(26, 0);
  re(i, n) f[s[i]-'a']++;
  ll ans = 1, P = 1000000007;
  re(i, 26) ans = (ans * (f[i]+1))%P;
  std::cout << (ans==0?P-1:ans-1) << '\n';
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, r = 0;
    char color;
    string S;
    cin >> S;
    N = (int)(S.length());
    color = S[0];
    for (int i = 0; i < N; i++)
    {
        if(color != S[i]){
            color = S[i];
            r++;
        }
    }
    cout << r << endl;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	int C[510] = { 0 }, S[510] = { 0 }, F[510] = { 0 };
	cin >> N;
	rep(i, 0, N - 1)
	{
		cin >> C[i] >> S[i] >> F[i];
	}

	rep(i, 0, N)
	{
		int res = 0;
		rep(j, i, N-1)
		{
			if (res < S[j])res = S[j];
			else if (res%F[j] != 0)res = (res / F[j] + 1)*F[j];
			res += C[j];
		}
		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    string s;
    int n;
    cin >> s >> n;
    for(int i = 0; i < s.size(); i += n) {
        cout << s[i];
    }
    cout << endl;
    return 0;
}

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

int main()
{

    int A, B, C;
    cin >> A >> B >> C;

    int target = A;

    bool ans = false;

    while (target % B != 0)
    {
        if (target % B == C)
        {
            ans = true;
            break;
        }
        target += A;
    }

    cout << (ans ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 3636
def threeArea(w, h, ans):
    for i in range(1, h):
        recA = w * i
        width = w//2
        recB = (h-i) * width
        recC = w * h - recA - recB
        diff = max(recA, recB, recC) - min(recA, recB, recC)

        height = (h - i) //2
        recB = w * height
        recC = w * h - recA - recB
        diff = min(diff, max(recA, recB, recC) - min(recA, recB, recC))
        if ans > diff:
            ans = diff
    return ans

H, W = (int(i) for i in input().split())

ans = float('inf')
ans = threeArea(W, H, ans)
ans = threeArea(H, W, ans)

print(ans)

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

bool kaibun(string s)
{
  int l = 0;
  int r = s.size() - 1;
  while (l < r)
  {
    if (s[l] != s[r])
      return false;
    l++;
    r--;
  }
  return true;
}

int main()
{
  string s;
  cin >> s;
  string s1 = s.substr(0, (s.size()-1)/2);
  string s2 = s.substr((s.size()+3)/2-1);
  if (!kaibun(s))
  {
    cout << "No" << endl;
    return 0;
  }
  if (!kaibun(s1))
  {
    cout << "No" << endl;
    return 0;
  }
  if (!kaibun(s2))
  {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AOJ1_3_D
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int c = int.Parse(str[2]);
            int x = 0;
            for (int i = a;i<=b;i++)
            {
                if(c%i==0)
                {
                    x++;
                }
            }
            Console.WriteLine(x);
        }
    }
}



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

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    rep(i,n) {
        cin >> c[i];
        rep(j,m) cin >> a[i][j];
    }
    ll ans = 1001001001;
    for(int i = 0; i < (1<<n); ++i) {
        vector<int> skill(m, 0);
        ll temp = 0;
        for(int j = 0; j < n; ++j) {
            if(i & (1 << j)) {
                temp += c[j];
                rep(ni, m){
                    skill[ni] += a[j][ni];
                }
            }
        }
        bool ok = true;
        for(int z : skill) if(z < x) ok = false; 
        if(ok) ans = min(ans, temp);
    }
    if(ans==1001001001) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3628
//#include <bits/stdc++.h>
#include <iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<sstream>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#define i64 long long
#define vi32 vector<int>
#define vi64 vector<long long>
#define  ii pair<int,int>
const long long mod = 1e9 + 7, inf = 1e9, linf = 1e18;
using namespace std;
#define pb push_back
#define mp make_pair
#define N 100005
using namespace std;
int f[N];
int main()
{
	f[0] = 1;
	int n;
	cin >> n;
	int sum = 0;
	
	for (int i = 0; i < n; i++)
	{
		cin >> f[i];
		sum += f[i];
	}
	for (int i = 1; i < n; i++)f[i] += f[i - 1];
	int res = inf;
	for (int i = 0; i < n; i++)
	{
		int l = f[i];
		int r = sum - l;
		res = min(res, abs(l - r));
	}
	cout << res;
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N;
    string S;
    cin >> N >> S;
    ll res = 1;
    ll cand = 0;
    for(ll i=0;i<2*N;i++){
        if(
            (S[i]=='B') && (cand%2==0)
         || (S[i]=='W') && (cand%2==1)
        ){
          cand++;
        }else{
          res *= cand;
          res %= 1000000007;
          cand--;
        }
    }
    if(cand!=0) res = 0;
    for(ll i=1; i<=N; i++){
        res *= i;
        res %= 1000000007;
    }
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n, m, a, h, p, q;
int y[1010][110];

int main(){
	while (cin >> n >> m >> a&&n + m + a){
		REP(i, 1010)REP(j, 110)y[i][j] = 0;
		REP(i, m){
			cin >> h >> p >> q;
			y[h][p] = q;
			y[h][q] = p;
		}
		for (int i = 1000; i > 0; i--){
			if (y[i][a] != 0)a = y[i][a];
		}
		cout << a << endl;
	}
}

Measured memory_bytes: 1592
def check(x)
  c = 0
  while x>0
    ppc = x.to_s(2).count('1')
    x %= ppc
    c += 1
  end
  return c
end
# x : 株, y : 金, b : 売買
# y(n+1) = y(n) + a(n)*x(n)
# y(k+1) = y(k) + a(k)*b(k)
# x(k+1) = x(k) - b(k)
# y(0) = 1000, x(0) = 0
# y(k)/a(k) <= b(k) <= x(k)

n = gets.strip.to_i
a = gets.strip.split.map(&:to_i)
y = 1000
amin = a[0]
amax = amin
f = 0
1.upto(n-1) do |i|
  if f == 0
    if a[i] < amin
      amin = a[i]
      amax = amin
    elsif a[i] > amin
      f = 1
      amax = a[i]
    end
  elsif f > 0
    if a[i] > amax
      amax = a[i]
    elsif a[i] < amax
      f = -1
      y += (y/amin)*(amax-amin)
      amin = a[i]
      amax = amin
    end
  else
    if a[i] < amin
      amin = a[i]
      amax = amin
    elsif a[i] > amin
      f = 1
      amax = a[i]
    end
  end
end
if amax > amin
  y += (y/amin)*(amax-amin)
end
p y


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

int main(void) {
  int n;
  cin >> n;
  vector<int> xs(n);
  for (int &x : xs) {
    cin >> x;
  }

  int result = 10000 * 200;
  for (int i = 1; i < 101; i++) {
    int sum = 0;
    for (int j = 0; j < n; j++) {
      sum += (xs[j] - i) * (xs[j] - i);
    }
    result = min(result, sum);
  }

  cout << result << endl;

  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
using namespace std;

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <stack>
#include <bitset>

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

	int x = 48 - M;
	cout << x << endl;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    double START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(15);

    i32 n,k; cin >> n >> k;
    vi a(n); rep(i,n) cin >> a[i];

    // ansをにぶたん？
    // ある長さansを定めて,各丸太をans以下の長さに分割する。
    // k以下の回数で済んだならもっと切れるからansをもっと小さく
    // k回を越えてしまうことは許されないので、そしたらansはもっと大きく

    i64 lb = 0, len, ub = infll;
    while(ub-lb > 1) {
        len = (ub+lb)/2;

        //debug
//        debug(ub);
//        debug(len);
//        debug(lb);


        i32 tmp = 0;
        for(auto aa : a) {
            if(aa > len) tmp += aa/len;
        }
        if(tmp <= k) ub = len;
        else lb = len;
    }

    //debug
//    debug(ub);
//    debug(len);
//    debug(lb);
//
//    bool can_lb = 1;
//    i32 cnt = 0;
//    for(auto aa : a) {
//        if(aa > lb) cnt += aa/lb;
//    }
//    if(cnt <= k) {
//        cout << lb << '\n';
//    }
//    else {
//        cout << ub << '\n';
//    }

    cout << ub << '\n';


//     printf("ElapsedTime: %5.3f ms\n",1000*((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 4748
#include <stdio.h>
 
int main(void){
  int i,j,k,n,m,l,a[100][100],b[100][100];
  long int s;
  scanf("%d%d%d",&n,&m,&l);
 
  for(i=0;i<n;i++)
    for(j=0;j<m;j++)
      scanf("%d",&a[i][j]);
 
  for(i=0;i<m;i++)
    for(j=0;j<l;j++)
      scanf("%d",&b[i][j]);
 
  for(i=0;i<n;i++)
    for(j=0;j<l;j++){
      s = 0;
      for(k=0;k<m;k++)
        s += a[i][k] * b[k][j] ;
      printf("%ld", s);
      if(j+1 == l)
        printf("\n");
      else
        printf(" ");
    }
 
  return 0;
}


Measured memory_bytes: 2792
#include <bits/stdc++.h>
using namespace std;
 
string rR(string s) {
  swap(s[0],s[2]);
  swap(s[0],s[6]);
  swap(s[6],s[8]);
  swap(s[1],s[5]);
  swap(s[1],s[3]);
  swap(s[3],s[7]);
  return s;
}
string rL(string s) {
  swap(s[0],s[2]);
  swap(s[2],s[8]);
  swap(s[6],s[8]);
  swap(s[1],s[5]);
  swap(s[5],s[7]);
  swap(s[3],s[7]);
  return s;
}
 
vector<string> U(vector<string> s) {
  swap(s[0],s[4]);
  swap(s[0],s[5]);
  swap(s[2],s[5]);
  for(int i=0; i<4; i++) swap(s[2][i],s[2][8-i]);
  for(int i=0; i<4; i++) swap(s[5][i],s[5][8-i]);
  s[1]=rR(s[1]);
  s[3]=rL(s[3]);
  return s;
}
vector<string> D(vector<string> s) {
  swap(s[0],s[5]);
  swap(s[0],s[4]);
  swap(s[2],s[4]);
  for(int i=0; i<4; i++) swap(s[2][i],s[2][8-i]);
  for(int i=0; i<4; i++) swap(s[4][i],s[4][8-i]);
  s[1]=rL(s[1]);
  s[3]=rR(s[3]);
  return s;
}
vector<string> R(vector<string> s) {
  swap(s[1],s[4]);
  swap(s[3],s[4]);
  swap(s[3],s[5]);
  s[0]=rR(s[0]);
  s[1]=rR(s[1]);
  s[2]=rL(s[2]);
  s[3]=rR(s[3]);
  s[4]=rR(s[4]);
  s[5]=rR(s[5]);
  return s;
}
vector<string> L(vector<string> s) {
  swap(s[1],s[5]);
  swap(s[3],s[5]);
  swap(s[3],s[4]);
  s[0]=rL(s[0]);
  s[1]=rL(s[1]);
  s[2]=rR(s[2]);
  s[3]=rL(s[3]);
  s[4]=rL(s[4]);
  s[5]=rL(s[5]);
  return s;
}
 
 
int main() {
  string t;
  while(cin >> t&&t!="#") {
    vector<string> s;
    map<vector<string>, int> m;
    string r=t;
    for(int j=1; j<3; j++) {
      cin >> t;
      r+=t;
    }
    s.push_back(r);
    for(int i=1; i<6; i++) {
      r="";
      for(int j=0; j<3; j++) {
        cin >> t;
        r+=t;
      }
      s.push_back(r);
    }
    m[s]=0;
    queue<vector<string> > que;
    que.push(s);
    while(!que.empty()) {
      s=que.front();que.pop();
      bool f1=0,f2=0;
      for(int i=0; i<3; i++) {
        if(s[0][i+6]=='*') f1|=1;
        if(s[2][i+6]=='*') f2|=1;
      }
      int c=m[s];
      if(f1&&f2) {
        cout << c << endl;
        break;
      }
      vector<string> t=U(s);
      if(!m.count(t)) {
        m[t]=c+1;
        que.push(t);
      }
      t=D(s);
      if(!m.count(t)) {
        m[t]=c+1;
        que.push(t);
      }
      t=R(s);
      if(!m.count(t)) {
        m[t]=c+1;
        que.push(t);
      }
      t=L(s);
      if(!m.count(t)) {
        m[t]=c+1;
        que.push(t);
      }
    }
  }
  return 0;
}


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


#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

ll mod = 1e9 + 7ll;
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; }
const ll inf = 1ll << 60;

int n, m;
int k, a;
int t = 0;
vector<int> bitlist(20);
vector<int> p(20);
int ans = 0;

int gcc(int n, int m) {
    int a = max({n, m});
    int b = min({n, m});
    if(b == 0) return a;
    int c;
    while(a % b != 0){
        c = a % b;
        a = b;
        b = c;
    }
    return b;
}

int main() {   
    scanf("%d%d", &n, &m);
    rp(i, 0, m){
        scanf("%d", &k);
        t = 0;
        rp(j, 0, k){
            scanf("%d", &a);
            t += 1 << a-1;
        }
        bitlist.at(i) = t;
    }
    rp(i, 0, m){
        scanf("%d", &p.at(i));
    }
    bool flag;
    rp(bit, 0, 1<<n){
        flag = true;
        rp(i, 0, m){
            if(__builtin_popcount(bit & bitlist.at(i)) % 2 != p.at(i)) flag = false;
        }
        if(flag) ans++;
    }
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int N;
  int A[100];
  int i;
  int flag=1;
  int temp;
  int count=0;

  scanf("%d",&N);
  for(i=0;i<N;i++)
  {
    scanf("%d",&A[i]);
  }

  while(flag)
  {
    flag=0;
    for(i=N-1;i>=1;i--)
    {
      if(A[i]<A[i-1])
      {
        temp = A[i];
        A[i] = A[i-1];
        A[i-1] = temp;
        flag=1;
        count++;
      }
    }
  }

  for(i=0;i<N-1;i++)
  {
    printf("%d ",A[i]);
  }
  printf("%d\n",A[N-1]);
  printf("%d\n",count);

  return 0;
}

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

int main(){
  int N;
  cin >> N;
  int c[4] ={};
  string S;
  for(int i=0; i<N; i++){
    cin >> S;
    if(S =="AC")        c[0]++;
    else if(S =="WA")   c[1]++;
    else if(S =="TLE")  c[2]++;
    else if(S =="RE")   c[3]++;
  } 
  cout << "AC x " << c[0] << endl;
  cout << "WA x " << c[1] << endl;
  cout << "TLE x " << c[2] << endl;
  cout << "RE x " << c[3] << endl;
  return 0;
} 

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

using namespace std;

int n, q;
vector<vector<int>> g;
int ans[201010];

void dfs(int v, int pv) {
  for (auto &nv : g[v]) {
    if (nv == pv) continue;
    ans[nv] += ans[v];
    dfs(nv, v);
  }
}

int main() {
  cin >> n >> q;
  g.assign(n, vector<int>());
  for (int i = 0; i + 1 < n; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }
  for (int i = 0; i < q; i++) {
    int p, x;
    cin >> p >> x;
    p--;
    ans[p] += x;
  }

  dfs(0, -1);
  for (int i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;

  return 0;
}

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

void roll_dice(char c, int d[])
{
    int buf;
    switch(c)
    {
        case 'N':
            buf = d[6];
            d[6] = d[5];
            d[5] = d[1];
            d[1] = d[2];
            d[2] = buf;
            break;
        case 'E':
            buf = d[6];
            d[6] = d[3];
            d[3] = d[1];
            d[1] = d[4];
            d[4] = buf;
            break;
        case 'S':
            buf = d[6];
            d[6] = d[2];
            d[2] = d[1];
            d[1] = d[5];
            d[5] = buf;
            break;
        case 'W':
            buf = d[6];
            d[6] = d[4];
            d[4] = d[1];
            d[1] = d[3];
            d[3] = buf;
    }
}


int main()
{
    int d[7];
    for(int i=1;i<7;i++)
    {
        cin >> d[i];
    }
    string c;
    cin >> c;
    
    for(int i=0;i<c.size();i++)
    {
        roll_dice(c[i], d);
    }
    cout << d[1] << endl;
    
    return 0;
}



Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  long a, b, c=0, d=0, e, f, g, h, n;
  cin >> a >> b >> n;
  if(a>n){
    co(a-n);
    co(b);
  }
  else if(a==n){
    co(0);
    co(b);
  }
  else if(b>=n-a){
    co(0);
    co(a+b-n);
  }
  else{
    co(0);
    co(0);
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
using namespace std;

int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int dis[2]={ty-sy, tx-sx};
    string d="URDL";
    for(int i=0; i<4; i++){
        for(int j=0; j<dis[i%2]; j++){
            cout << d[i];
        }
    }
    cout << 'L';
    for(int i=0; i<2; i++){
        for(int j=0; j<dis[i%2]+1; j++){
            cout << d[i];
        }
    }
    cout << "DR";
    for(int i=0; i<2; i++){
        for(int j=0; j<dis[i%2]+1; j++){
            cout << d[i+2];
        }
    }
    cout <<"U";
    return 0;
}

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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
// constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

int main(){
  int N, C;
  cin >> N >> C;
  vector<vector<int>> D(C, vector<int> (C)), cnt(3, vector<int>(C, 0));
  REP(i, C){
    REP(j, C){
      cin >> D[i][j];
    }
  }
  REP(i, N){
    REP(j, N){
      int c;
      cin >> c;
      c--;
      cnt[(i+j)%3][c]++;
    }
  }
  int ans = INF;
  REP(i, C){
    REP(j, C){
      if(i==j) continue;
      REP(k, C){
        if(i==k || j==k) continue;
        int cost = 0;
        REP(l, C){
          cost += D[l][i] * cnt[0][l];
          cost += D[l][j] * cnt[1][l];
          cost += D[l][k] * cnt[2][l];
        }
        ans = min(ans, cost);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int arr[20];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    while(true) {
        int N;
        cin >> N;
        if(!N) break;

        for(int i = 0; i < N; ++i) {
            cin >> arr[i];
        }
        int ans = 100000000;
        for(int pat = 0; pat < (1<<N); ++pat) {
            int suma = 0, sumb = 0;
            for(int i = 0; i < N; ++i) {
                if(pat & (1<<i)) suma += arr[i];
                else sumb += arr[i];
            }
            ans = min(ans, abs(suma-sumb));
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1188
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	long[] num = new long[4];
      	for(int i=0;i<4;i++){
          num[i] = sc.nextLong();
        }
      	long max = num[0] * num[2];
      	for(int i=0;i<2;i++){
          for(int j=2;j<4;j++){
            if( num[i] * num[j] > max ){
              max = num[i] * num[j];
            }
          }
        }
      	System.out.println(max);
      
	}
}

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

ll INF = 1LL << 60;
using G = vector<map<int, int>>;

int 
main() {
  int N; cin >> N;
  map<int, int> num;
  ll acum = 0;
  rep(i, 0, N){
    ll tmp; cin >> tmp;
    num[tmp]++;
    acum += tmp;
  }

  int Q; cin >> Q;
  vector<pair<int, int>> q(Q);
  rep(i, 0, Q) cin >> q[i].first >> q[i].second;

  rep(i, 0, Q){
    int B = q[i].first;
    int C = q[i].second;
    num[C] += num[B];
    acum = acum + (num[B] * (C - B));
    num[B] = 0;
    cout << acum << endl;
  }

}

Measured memory_bytes: 8412
#include <stdio.h>

int main(void)
{
	double h,M,m,a;
	scanf("%lf",&a);
	M=m=a;
	
	while(scanf("%lf",&a) != EOF){
		if(M<a){
			M=a;
		}
		else if(m>a){
			m=a;
		}
	}
	
	printf("%lf\n",M-m);

	return 0;
}

Measured memory_bytes: 648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1000 + 5;
int dp[N][N];
char grid[N][N];
int h, w;
const ll mod = 1e9 + 7;

void self_add(int &a, int b) {
    a += b;
    if (a >= mod)
        a -= mod;
}

int solve(int i, int j) {
    if (i == h - 1 && j == w - 1)
        return 1;
    if (i > h - 1 || j > w - 1)
        return 0;
    if (grid[i][j] == '#')
        return 0;
    if (dp[i][j] != -1)
        return dp[i][j];
    int res = 0;
    self_add(res, solve(i + 1, j));
    self_add(res, solve(i, j + 1));
    return dp[i][j] = res % mod;
}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> h >> w;
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
            cin >> grid[i][j];
    memset(dp, -1, sizeof dp);
    cout << solve(0, 0);
    return 0;
}


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

int main(void){
	int cnt = 0;
  	char s[10];
	
  	rewind(stdin);
	scanf("%s",s);
  
  if(s[0]==s[1]){
  	cnt++;
  }
    if(s[0]==s[2]){
  	cnt++;
  }
    if(s[0]==s[3]){
  	cnt++;
  }
    if(s[1]==s[2]){
  	cnt++;
  }
    if(s[1]==s[3]){
  	cnt++;
  }
    if(s[2]==s[3]){
  	cnt++;
  }
  
  if(cnt == 2){
   printf("Yes");
  }else{
   printf("No");
  }
  
  return 0;

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef pair<int,int> tA;
typedef pair<int,int> tB; // or null_type if you want a set
typedef tree<tA, null_type, less<tA>, rb_tree_tag, tree_order_statistics_node_update> ord_set;
int v[200005];
int main()
{
	ord_set s;
	int n;
	scanf("%d",&n);
	for(int i = 0 ; i < n ; i++)
	{
		int a;
		scanf("%d",&a);
		v[i] = a;
		s.insert({a,i});
	}
	int idx = n/2-1;
	for(int i = 0 ; i < n ; i++)
	{
	 	auto it = s.lower_bound({v[i],i});
		int val = it->first;
//		cout << "tirando: " << it->first << ' ' << it->second << endl;
		s.erase(it);
		it = s.find_by_order(idx);
		cout << it->first << endl;
		s.insert({val,i});	
	}
	return 0;
}


Measured memory_bytes: 15488
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 2019
int main()
{
    int k;
    string s;
    cin>>k>>s;
    int sz=s.size();
    if(sz<=k)
        cout<<s<<'\n';
    else
    {
        string s1=s.substr(0,k);
        cout<<s1<<"..."<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3576
MAX_X = 2000
MAX_Y = 2000
s = [ [0 for i in range(MAX_X)] for j in range(MAX_Y) ]
for _ in range (2) :
    x,y,w,h = map(int,input().split())
    for i in range(x,x+w) :
        for j in range(y,y+h) :
            s[i][j] += 1
c = 0
for i in range(0,MAX_X) :
    for j in range(0,MAX_Y) :
        if s[i][j] == 1 : c += 1
print(c)



Measured memory_bytes: 38012
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000000000000;
const int mod = 1000000007;
int test[345678];
signed main() {
	int n, m, k, a, cnt = 0; string s; cin >> n;
	if (n / 100 == 7 || n % 100 / 10 == 7 || n % 10 == 7) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
  int d,n;
  cin >> d  >>n;
  if(d==0 && n!=100){
    cout << n;
  }
  if(d==0 && n==100){
    cout << 101;
  }
  if(d==1 && n!=100){
    cout << n*100;
  }
  if(d==1 && n==100){
    cout << 10100;
  }
  
  if(d==2 && n!=100){
    cout << n*10000;
  }
  if(d==2 && n==100){
    cout << 1010000;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,k;
  int all[300005];
  int max=0,temp=0;
  int left=0;
  int L=0,R;
  double ans=0.0;
  cin >> n>>k;
  int right = k-1;
  R=right;
  for(int i = 0;i<n;i++)
    cin>>all[i];
for(int i =right+1;i<n;i++)
{
  temp+=all[i];
  temp-=all[left];
  if(temp>max)
  {
    max=temp;
    L=left+1;
    R=right+1;
  }
  left++;
  right++;
  
  
}
  for(int i =L;i<=R;i++)
  {
    ans+=((all[i]+1)*(double)all[i]/2)*(1/(double)all[i]);
  }
  
  cout<<setprecision(12)<<ans<<endl;
  return 0;
}


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

int main(void) {
    int N;
    int cnt;
    string S;
    cin >> N >> S;
    
    bitset<1000> check("0");

    int checkpos,spos;
    int d[3];
    for(d[0]=0;d[0]<10;d[0]++) {
    for(d[1]=0;d[1]<10;d[1]++) {
    for(d[2]=0;d[2]<10;d[2]++) {
        checkpos = 0;
        spos = 0;
        while((checkpos < 3) && (spos < S.size())) {
            if(d[checkpos] == (S[spos]-'0')) {
                checkpos++;
            }
            spos++;
        }
//printf("%d%d%d: %d\n", d[0],d[1],d[2],checkpos);
        if(checkpos == 3) {
            check[d[0] * 100 + d[1] * 10 + d[2]] = 1;
        }
    }
    }
    }
    
    cout << check.count() << "\n";


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1e9+7;
struct M {
  int n,m;
  vector<vector<int>> a;
  M(int _n,int _m) : n(_n),m(_m) {
    a.resize(n,vector<int>(m));
  }
  M operator*(const M& b) {
    auto c = M(n,b.m);
    for(int i=0;i<n;i++)
    for(int j=0;j<b.m;j++)
    for(int k=0;k<m;k++) {
      c.a[i][j] += a[i][k]*b.a[k][j];
      c.a[i][j] %= mod;
    }
    return c;
  }
};
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int n,k;
  cin >> n >> k;
  M a(n,n);
  for(int i=0;i<n;i++) {
    for(int j=0;j<n;j++) {
      cin >> a.a[j][i];
    }
  }
  auto res = M(n,n);
  for(int i=0;i<n;i++) res.a[i][i] = 1;
  while(k) {
    if (k%2) {
      res = res * a;
    }
    a = a * a;
    k /= 2;
  }
  auto unitM = M(n,1);
  for(int i=0;i<n;i++) unitM.a[i][0] = 1;
  auto ans = res * unitM;
  int fans = 0;
  for(int i=0;i<n;i++) fans = (fans + ans.a[i][0])%mod;
  cout << fans << '\n';
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>

using namespace std;

int64_t mod = 1e9+7;

int main(int argc, char** argv) {
    int n,k,x,y, ans{0};
    cin >> n >> k >> x >> y;
    if (n >= k) {
        ans += k*x;
        n -= k;
    } else {
        ans += n*x;
        n = 0;
    }
    ans += n*y;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        ReadLine();
        var a = ReadLine().Split().Select(x => long.Parse(x));

        if (a.Contains(0)) {
            WriteLine(0);
            return;
        }

        long ans = 1;
        long m = 1000000000000000000;
        foreach (var ai in a) {
            if (ans > m / ai) {
                WriteLine(-1);
                return;
            }
            ans *= ai;
        }
        WriteLine(ans);
    }
}

Measured memory_bytes: 40868
#include <bits/stdc++.h>
using namespace std;
const int MOD=1000000007;
long long mod_pow(int x,int y){//x^yを返す//計算量は0(log(y))
  long long tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
int main(){
    string L;
    cin>>L;
    long long ans=0;
    int a=L.size(),count=0;
    for(int i=0;i<a;i++){
        if(i==0){
            ans=mod_pow(3,a-i-1);
            count++;
        }
        else if(L.at(i)=='1'){
            ans+=mod_pow(2,count)*mod_pow(3,a-i-1);
            ans%=MOD;
            count++;
        }
    }
    ans+=mod_pow(2,count);
    cout<<ans%MOD<<endl;
}

Measured memory_bytes: 3764
n, k, q = map(int, input().split())
def judge():
    val = {}
    for _ in range(q):
        a = int(input())
        val[a-1] = val.get(a-1,0) + 1
    #print(val)
    for i in range(n):
        if val.get(i,k-q) + (k - q) > 0:
            print('Yes')
        else:
            print('No')
if k > q:
    print(*['Yes' for _ in range(n)])
else:
    ans = judge()


Measured memory_bytes: 9052
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    long double sum=0;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        sum+=(long double)1/x;
    }
    cout<<(long double)1/sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
const int N=210,p=998244353;
struct P{
	int x,y;
	P(int x=0,int y=0):x(x),y(y){}
};
inline P operator-(P u,P v){return P(u.x-v.x,u.y-v.y);}
inline int cross(P u,P v){return u.x*v.y-u.y*v.x;}

P o[N];
int n,fac[N],inv[N];
inline void D(int &x,int y){x-=y;if (x<0) x+=p;}
inline void A(int &x,int y){x+=y;if (x>=p) x-=p;}
inline int C(int x,int y){
	return 1ll*fac[x]*inv[y]%p*inv[x-y]%p;
}
inline int qmi(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=1ll*x*x%p) if (y&1) ans=1ll*ans*x%p;
	return ans;
}
inline int get_inv(int x){
	return qmi(x,p-2);
}
inline int calc(int n){
	return (qmi(2,n)-(1+C(n,1)+C(n,2))%p+p)%p;
}
int main(){
	scanf("%d",&n);
	if (n==1) return puts("0"),0;
	fac[0]=1;for (int i=1;i<=n;++i) fac[i]=1ll*fac[i-1]*i%p;
	inv[0]=inv[1]=1;for (int i=2;i<=n;++i) inv[i]=1ll*inv[p%i]*(p-p/i)%p;
	for (int i=2;i<=n;++i) inv[i]=1ll*inv[i]*inv[i-1]%p;
	for (int i=1;i<=n;++i) scanf("%d%d",&o[i].x,&o[i].y);
	int ans=calc(n);
	for (int i=1;i<=n;++i)
		for (int j=1;j<=n;++j)if (i!=j){
			int tot=2;
			for (int k=1;k<=n;++k) if (k!=i&&k!=j) tot+=(cross(o[k]-o[i],o[j]-o[i])==0);
			D(ans,1ll*calc(tot)*get_inv(tot*tot-tot)%p);
		}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include<vector>

std::vector<bool> Eratosthenes(int n) {
    std::vector<bool> is_prime(n + 1, true);
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; is_prime[i] && i * i <= n; ++i)
        for(int j = i << 1; j <= n; j += i)
            is_prime[j] = false;
    return is_prime;
}

int mod_power(long long int m, long long int n, int mod) {
    if(!n) return 1;
    if(n & 1) return mod_power(m, n - 1, mod) * m % mod;
    return mod_power(m * m % mod, n >> 1, mod) % mod;
}

int gcd(int m, int n) {
    if(n == 0) return m;
    return gcd(n, m % n);
}

int lcm(long long int m, long long int n) {
    return m * n / gcd(m, n);
}

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

#include<iostream>
using namespace std;

int main() {
    int n;
    int answer = 1;
    for(cin >> n; n > 0; --n) {
        int a;
        cin >> a;
        answer = lcm(answer, a);
    }
    cout << answer << endl;
}

Measured memory_bytes: 1160
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

func check(n int) bool {
	s := strconv.Itoa(n)
	for l := 0; l < len(s)-1; l++ {
		if s[l] != s[l+1] {
			return false
		}
	}
	return true
}

func main() {
	log.SetFlags(log.Lshortfile)
	n := nextInt()
	for {
		if check(n) {
			break
		}
		n++
	}

	out := bufio.NewWriter(os.Stdout)
	fmt.Fprintf(out, "%d", n)
	fmt.Fprintf(out, "\n")
	out.Flush()
}
func Max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func Min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func Sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func Abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	return p[i].b < p[j].b
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

    rep(i, n)
    {
        int a;
        cin >> a;
        x[i].resize(a);
        y[i].resize(a);
        rep(j, a) cin >> x[i][j] >> y[i][j];
    }

    int ans = 0;
    for (int bit = 0; bit < (1 << n); bit++)
    {
        bool ck = true;
        int cnt = 0;
        rep(i, n)
        {
            if (bit & (1 << i))
            {
                rep(j, x[i].size())
                {
                    if (y[i][j])
                    {
                        if (!(bit & (1 << x[i][j] - 1)))
                        {
                            ck = false;
                        }
                    }
                    else
                    {
                        if (bit & (1 << x[i][j] - 1))
                        {
                            ck = false;
                        }
                    }
                }
            }
        }
        if (ck)
        {
            ans = max(ans, __builtin_popcount(bit));
        }
    }

    cout << ans << '\n';
    return 0;
}


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

int main(){
  int N,c;
  cin>>N>>c;
  int d[c][c];
  int i,j,k,x;
  for(i=0;i<c;i++){
	for(j=0;j<c;j++){
	cin>>x;
	d[i][j]=x;
	}
  }
  int su[3][c];
  for(i=0;i<3;i++){
	for(j=0;j<c;j++){
	su[i][j]=0;
	}
  }
  for(i=1;i<=N;i++){
	for(j=1;j<=N;j++){
	cin>>k;
	su[(i+j)%3][k-1]+=1;
	}
  }
  
  ll ans=100000000000000;
  for(i=0;i<c;i++){
	for(j=0;j<c;j++){
		for(k=0;k<c;k++){
		ll temp=0;
		if(i==j||j==k||k==i) continue;
		for(int l=0;l<c;l++) temp+=su[0][l]*d[l][i];
		for(int l=0;l<c;l++) temp+=su[1][l]*d[l][j];
		for(int l=0;l<c;l++) temp+=su[2][l]*d[l][k];
		ans=min(ans,temp);
		}
	}
  }
cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
mod = 10**9+7

ans = 1
p = 0
m = 0
for si in s:
    if((p-m)%2==0):
        if(si=='B'):
            p += 1
        else:
            ans *= (p-m)
            ans %= mod
            m += 1
    else:
        if(si=='W'):
            p += 1
        else:
            ans *= (p-m)
            ans %= mod
            m += 1

if(p!=m):
    ans = 0

for i in range(1,n+1):
    ans *= i
    ans %= mod

print(ans)

Measured memory_bytes: 73032
n = int(input())
s = input()
cnt = 1

if n != 1:
    cnt = sum(s[i] != s[i + 1] for i in range(n - 1)) + 1
    # for i in range(n - 1):
    #     if s[i] != s[i + 1]:
    #         cnt += 1

print(cnt)


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

int main(void){
    int W,H,N;
    cin >> W >> H >> N;
    int x[N],y[N],a[N];
    for(int i = 0 ; i < N ; i++){
        cin >> x[i] >> y[i] >> a[i];
    }
    
    bool judge[H][W];
    for(int i = 0 ; i < H ; i++){
        for(int j = 0 ; j < W ; j++){
            judge[i][j] = true;
        }
    }
    
    for(int k = 0 ; k < N ; k++){
        if(a[k] == 1){
            for(int i = 0 ; i < H ; i++){
                for(int j = 0 ; j < x[k] ; j++){
                    judge[i][j] = false;
                }
            }
        }else if(a[k] == 2){
            for(int i = 0 ; i < H ; i++){
                for(int j = x[k] ; j < W ; j++){
                    judge[i][j] = false;
                }
            }
        }else if(a[k] == 3){
            for(int i = 0 ; i < y[k] ; i++){
                for(int j = 0 ; j < W ; j++){
                    judge[i][j] = false;
                }
            }
        }else if(a[k] == 4){
            for(int i = y[k] ; i < H ; i++){
                for(int j = 0 ; j < W ; j++){
                    judge[i][j] = false;
                }
            }
        }
    }
    
    int counter = 0;
    for(int i = 0 ; i < H ; i++){
        for(int j = 0 ; j < W ; j++){
            if(judge[i][j] == true){
                counter++;
            }
        }
    }
    cout << counter << endl;
    return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<pair<int, int>> Tasks(N);
	for (int i = 0; i < N; i++) cin >> Tasks[i].second >> Tasks[i].first;
	sort(Tasks.begin(), Tasks.end());
	int now = 0;
	bool ans = true;
	for (const auto task : Tasks) {
		now += task.second;
		if (now > task.first) {
			ans = false;
			break;
		}
	}
	cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 1792
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
const double PI = 3.14159265358979323846;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

int main() {
	long long A, B, N;
	cin >> A >> B >> N;

	long long ans = 0;
	long long x = min(N, B - 1);
	ans = floor((A * x) / B);

	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int n; cin>>n;
    if(n==7||n==5||n==3) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


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

int N;
int* a;
int* b;

int* c; //a>b
int* d; //b>a

long long csum = 0;
long long dsum = 0;

int main() {
	cin >> N;
	a = new int[N];
	b = new int[N];
	c = new int[N];
	d = new int[N];

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

		if (a[i] - b[i] > 0) {
			c[i] = a[i] - b[i];
			csum += c[i];
		}
		else {
			d[i] = b[i] - a[i];
			dsum += d[i] / 2;
		}
	}

	if (csum <= dsum) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;
}

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

using ll = long long;

const ll INF = (1LL << 50);

int main() {
    int N, M;
    cin >> N >> M;

    const int MAX_N = 2000;
    const int MAX_M = 3000;

    int a[MAX_M], b[MAX_M];
    ll  c[MAX_M];

    for (int i = 0; i < M; i++) {
        cin >> a[i] >> b[i] >> c[i];

        a[i]--;
        b[i]--;
        c[i] = -c[i];
    }

    ll dist[MAX_N];
    for (int i = 0; i < N; i++) dist[i] = INF;
    
    dist[0] = 0;
    for (int loop = 0; loop < N - 1; loop++) {
        for (int i = 0; i < M; i++) {
            if (dist[a[i]] == INF) continue;

            if (dist[b[i]] > dist[a[i]] + c[i]) {
                dist[b[i]] = dist[a[i]] + c[i];
            }
        }
    }

    ll ans = -dist[N - 1];

    bool negative[N];
    for (int i = 0; i < N; i++) negative[i] = false;

    for (int loop = 0; loop < N; loop++) {
        for (int i = 0; i < M; i++) {
            if (dist[a[i]] == INF) continue;

            if (dist[b[i]] > dist[a[i]] + c[i]) {
                dist[b[i]] = dist[a[i]] + c[i];
                negative[b[i]] = true;
            }

            if (negative[a[i]]) negative[b[i]] = true;
        }
    }

    if (negative[N - 1]) cout << "inf" << endl;
    else cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(50) << setiosflags(ios::fixed);

  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  string u;
  cin >> u;
  if (s == u)
    a--;
  else
    b--;
  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
if n == 1 and m == 1:
  print(1)
elif n == 1 or m == 1:
  print(max(n, m) -2)
elif n == 2 or m == 2:
  print(0)
else:
  print((n-2) * (m-2))
  

Measured memory_bytes: 2940
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let a: u64 = itr.next().unwrap().parse().unwrap();
    let b: u64 = itr.next().unwrap().parse().unwrap();
    println!("{}", a * b);
}


Measured memory_bytes: 2112
from collections import defaultdict
def solve():
    N = int(input())
    d = defaultdict(int)
    for _ in range(N):
        A = int(input())
        d[A] += 1
    
    cnt = 0
    for key, val in d.items():
        if val % 2 != 0:
            cnt += 1
    
    print(cnt)

if __name__ == '__main__':
    solve()

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

typedef long long ll;
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);

void solveA() {
	int a[3];
	for(int i = 0; i < 3; i++) 
		cin >> a[i];
	int ans = 10000000;
	do {
		int here = 0;
		for(int i = 1; i < 3; i++)
			here += abs(a[i] - a[i-1]);
		ans = min(here, ans);
	} while(next_permutation(a,a+3));
	cout << ans << endl;
}
void solveB() {
	FAST;
	string s, t;
	cin >> s >> t;
	int n = s.size();
	for(int i = 0; i < n; i++) {
		string tmp = "";
		for(int j = i; j < n; j++)
			tmp += s[j];
		for(int j = 0; j < i; j++)
			tmp += s[j];
		if(tmp == t) { cout << "Yes\n"; return; }
	} cout << "No\n";
	return;
}
void solveC() {

}
void solveD() {

}

int main() {
	//solveA();
	solveB();
	//solveC();
	//solveD();
	return 0;
}

Measured memory_bytes: 256
import copy


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    if K == 0:
        print(calc(0, A))
        return
    count = 0
    while True:
        if K < 2 ** (count + 1):
            break
        count += 1
    ans = 0
    A_copy = copy.copy(A)
    while count != -1:
        if (K - ans) < 2 ** count:
            count -= 1
            continue
        zero_count = 0
        one_count = 0
        for a in A_copy:
            if (a >> count) & 1 == 0:
                zero_count += 1
            else:
                one_count += 1
        if one_count < zero_count:
            ans += 2 ** count
        count -= 1
    print(calc(ans, A))


def calc(X, A):
    ans = 0
    for a in A:
        ans += X ^ a
    return ans


if __name__ == "__main__":
    main()


Measured memory_bytes: 15368