akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

char str[2005][2005];

int sa[2005][2005];
int ssa[2005][2005];
int sb[2005][2005];
int ssb[2005][2005];
int sc[2005][2005];
int ssc[2005][2005];

void solve()
{
    int n, m, Q;
    scanf("%d%d%d", &n, &m, &Q);
    int i, j;
    for (i = 0; i < n; i++) {
        scanf("%s", str[i]);
        for (j = 0; j < m; j++) {
            int add0 = 0;
            if (str[i][j] == '1') {
                add0 = 1;
            }
            sa[i][j+1]=sa[i][j] + add0;

            int add1 = 0;
            if (j < m - 1 && str[i][j] == '1' && str[i][j + 1] == '1') {
                add1 = 1;
            }
            sb[i][j+1]=sb[i][j] + add1;
        }        
    }
    for (j = 0; j <= m; j++) {
        for (i = 0; i < n; i++) {
            ssa[i+1][j] = ssa[i][j]+sa[i][j];
            ssb[i+1][j] = ssb[i][j]+sb[i][j];
        }
    }

    for (i = 1; i < n; i++) {
        for (j = 0; j < m; j++) {
            int add = 0;
            if (str[i - 1][j] == '1' && str[i][j] == '1') {
                add = 1;
            }
            sc[i - 1][j + 1] = sc[i - 1][j] + add;
        }
        
    }
    for (j = 0; j <= m; j++) {
        for (i = 0; i < n-1; i++) {
            ssc[i+1][j] = ssc[i][j]+sc[i][j];
        }
    }

    for (i = 0; i < Q; i++) {
        int x0, y0, x1, y1;
        scanf("%d%d%d%d", &x0, &y0, &x1, &y1); x0--; y0--; x1--; y1--;

        int ans0 = ssa[x1 + 1][y1 + 1] - ssa[x0][y1 + 1] - ssa[x1 + 1][y0] + ssa[x0][y0];
        int ans1 = ssb[x1 + 1][y1] - ssb[x0][y1] - ssb[x1 + 1][y0] + ssb[x0][y0];
        int ans2 = ssc[x1][y1 + 1] - ssc[x0][y1 + 1] - ssc[x1][y0] + ssc[x0][y0];
        printf("%d\n", ans0-ans1-ans2);
    }


    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 99944
#include<stdio.h>
#include<math.h>

int main(void) {
    // FIX1: カウンタ変数はなるべく使わない（グローバルにしない）ように組む
    //     : ほとんどの場合は頑張れば使わなくても同じことができる（たぶん）
    // int i;

    int mod26[16];
    char name[16];
    int count = 0;
    long long N;

    scanf("%lld", &N);

    for (int i = 0; i < 16; i++) {
        mod26[i] = N % 26;
        count = i; // FIX2: FIX1に関連して．ここと

        // FIX3: modが0の場合は"z"を出力したいから
        //     : 0 -> 26
        if (mod26[i] == 0) {
            mod26[i] = 26;
            N--;
        }

        // FIX4: N = N / 26; とおなじ
        //     : どう書くかは好みの問題だとは思う
        N /= 26;

        if (N == 0) {
            break;
        }
    }
    count++; // FIX2: ここでほぼ「count = i + 1;」

    // FIX5: if -> while
    //     : そんなに変わらんけどなんとなくwhileでやると安全な気がする
    while (mod26[count - 1] == 0) {
        count--;
    }

    for (int i = 0; i < count; i++) {
        name[i] = 'a' + mod26[count - 1 - i] - 1;
        printf("%c", name[i]);
    }

    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
string a,b;
  cin>>a>>b;
  string S =a+b;
  int x=0;
for (int i = 0; i < S.length(); i++) {
 x= x*10 + (S[i] - '0');
}
for (int i = 0; i < 1000; i++) {
 if(x==i*i){
   cout<<"Yes"<<endl;
   return 0;
}
}
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int N;
  cin >> N;
  vector<int> a(3*N);
  for(int i=0;i<3*N;++i) cin >> a.at(i);
  sort(a.begin(),a.end());
  ll ans=0;
  for(int i=0;i<N;++i) ans+=a.at(N+2*i);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4584
/*
***************************************************************************
 name  : ITP1_03_B.cpp
 title : Print Test Cases
 make  : 2018/08/08 tanabe
***************************************************************************
*/

// Library
#include <iostream> // standard input output object

main(void){
  int x; // integer
  int i; // index

  std::cin >> x; // input "x"

  // initialized i = 1
  // continue x != 0
  // increment i and input "x" at loop update
  for(i = 1;x;i++,std::cin >> x){
    std::cout << "Case " << i << ": " << x << std::endl; // output "Case i: x"
  }

}



Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,m,k;
    cin>>n>>m>>k;
    vector<ll> a(n),b(m),sum1(n+1,0),sum2(m+1,0);
    rep(i,n){
        cin>>a[i];
        sum1[i+1]=sum1[i]+a[i];
    }
    rep(i,m){
        cin>>b[i];
        sum2[i+1]=sum2[i]+b[i];
    }
    ll ans=0;
    ll now=0;
    ll ret=k;
    auto itr=upper_bound(begin(sum2),end(sum2),ret);
    itr--;
    now+=itr-begin(sum2);
    chmax(ans,now);
    rep(i,n){
        ll now=i+1;
        ll ret=k-sum1[i+1];//0以以上
        if(ret<0){
            now=0;
            ret=0;
        }
        auto itr=upper_bound(begin(sum2),end(sum2),ret);
        itr--;
        now+=itr-begin(sum2);
        chmax(ans,now);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 9488
#include<stdio.h>

int main(){

	unsigned long long a,b,x = 0;
	unsigned long long count = 0;

	scanf("%llu %llu %llu",&a,&b,&x);

	if(a == 0){
		count = b/x+1;
	}else{
		count = b/x+1 - ((a-1)/x + 1);
	}
	
	printf("%llu",count);

	return 0;

}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;	
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

const ll INF = 1LL << 61;

#include <bits/stdc++.h>
using namespace std;

const ll mod = 1000000007;


ll solve(ll a, ll b, ll x) {
	ll a1 = (a * x) / b;;
	ll a2 = a * (x/b);
	return a1 - a2;
}

int main() {

	ll a, b, n;
	cin >> a >> b >> n;
	if (n >= b) {
		auto r = solve(a, b, b - 1);
		cout << r << endl;
	}
	else {
		auto r = solve(a, b, n);
		cout << r << endl;
	}
	return 0;
}

Measured memory_bytes: 3592
def subpow(x, p):
    return (x - p) ** 2

n = int(input())
x = sorted(map(int, input().split()))
mini = 10000000000000
for p in range(x[-1] + 1):
    sum = 0
    for i in range(n):
        sum += subpow(x[i], p)
    mini = min(sum, mini)
print(mini)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL;
 
#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
 
const int maxn = 2e5 + 20;
int a[maxn];
bool book[maxn];
void work() {
    int n, x;
    scanf("%d%d", &n, &x);
    if (x == 1 || x == 2 * n - 1) {
        printf("No\n");
        return;
    }
    int t = 2 * n - 1;
    a[t / 2 + 1] = x;
    a[t / 2] = x - 1;
    a[t / 2 + 2] = x + 1;
    book[x] = book[x - 1] = book[x + 1] = 1;
    if (t / 2 - 1 > 0 && x + 2 <= t) {
        a[t / 2 - 1] = x + 2;
        book[x + 2] = 1;
    }
    if (t / 2 + 3 <= t && x - 2 >= 1) {
        a[t / 2 + 3] = x - 2;
        book[x - 2] = 1;
    }
    int to = 1;
    for (int i = 1; i <= t; ++i) {
        if (a[i] != 0) continue;
        while (book[to] != 0) to++;
        a[i] = to;
        book[to] = 1;
    }
    printf("Yes\n");
    for (int i = 1; i <= t; ++i) {
        printf("%d\n", a[i]);
    }
}
 
int main() {
#ifdef local
    freopen("data.txt","r",stdin);
#endif
    work();
    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define ff(i, n) for (int i = 1; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;



void solve(){
    int n, k, q;
    cin>>n>>k>>q;
    int a[n+4];
    ff(i,n)a[i] = k;
    f(i,q){
        int k;
        cin>>k;
        a[k]++;
    }
    ff(i,n){
        a[i] -= q;
        if(a[i] > 0)cout<<"Yes\n";
        else cout<<"No\n";
    }
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}

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

int h,w,ch,cw,dh,dw;
string s[1001];

bool legal(int r,int c)
{
    if(r>=0 && r<h && c>=0 && c<w && s[r][c]=='.')
    return 1;
    else
    return 0;
}

int main() 
{
	cin>>h>>w>>ch>>cw>>dh>>dw;
	ch--,cw--,dh--,dw--;
	for(int i=0;i<h;i++)
	{
	    cin>>s[i];
	}
	deque<pair<int,int>> q;
	q.push_front({ch,cw});
	long int vis[h][w];
	for(int i=0;i<h;i++)
	{
	    for(int j=0;j<w;j++)
	    {
	        vis[i][j]=1e6;
	    }
	}
	vis[ch][cw]=0;
	while(!q.empty())
	{
	    pair<int,int>v=q.front();
	    q.pop_front();
	    for(int i=-1;i<=1;i++)
	    {
	        for(int j=-1;j<=1;j++)
	        {
	            if(abs(i+j)==1 && legal(v.first + i , v.second + j))
	            {
	                if(vis[v.first + i][v.second + j]>vis[v.first][v.second])
	                {
	                    vis[v.first + i][v.second + j]=vis[v.first][v.second];
	                    q.push_front({v.first + i , v.second + j});
	                }
	            }
	        }
	    }
	    for(int i=-2;i<=2;i++)
	    {
	        for(int j=-2;j<=2;j++)
	        {
	            if(legal(v.first + i , v.second + j))
	            {
	                if(vis[v.first + i][v.second + j]>vis[v.first][v.second]+1)
	                {
	                    vis[v.first + i][v.second + j]=vis[v.first][v.second]+1;
	                    q.push_back({v.first + i , v.second + j});
	                }
	            }
	        }
	    }
	}
	if(vis[dh][dw]==1e6)
	cout<<"-1";
	else
	cout<<vis[dh][dw];
	return 0;
}

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

using namespace std;

int main(){
    string S;
    cin >> S;
    if(S == "abc" || S == "acb" || S == "bac" || S == "bca" || S == "cab" || S == "cba") cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define all(x) x.begin(),x.end()
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define sll set<ll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define endl "\n"
const ll maxn = 2e5+2;

int main()
{
    fastio;
    ll i, j, k, n, l, r, d;
    vll a;

    cin>>l>>r>>d;
    ll ans=0;
    for ( i = l; i <= r; i++)
    {
        if(i%d==0)
        ans++;
    }
    
    cout<<ans<<endl;

        
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int H, W;
    cin >> H >> W;
    unsigned char S[H][W],A[H][W];
    int count;
  
  for(int i=0; i<H; i++)
    for(int j=0; j<W; j++)
      cin>> S[i][j];
  
    
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      count = 0;
      if(S[i][j] == '#'){//#だった場合
        cout << '#';
      }else{               //.だったとき
        for(int k=i-1; k<i+2; k++){  //周りの#をcountして代入
        	for(int l=j-1; l<j+2; l++){
              if(k >=0 && k<H && l >=0 && l<W)
            	if(S[k][l] == '#')
                  count++;
            }
        }
        cout << count;
      }    
    }
 cout << endl;
}
            
  }

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;

	vector<int> A(N);
	for(int i=0;i<N;i++){
		cin >> A.at(i);
	}

	sort(A.begin(),A.end());
	reverse(A.begin(),A.end());

	int math = A.at(0);
	for(int i=1;i<N;i++){
		if(i % 2 == 0){
			math += A.at(i);
		}else{
			math -= A.at(i);
		}
	}

	cout << math << endl;
}

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

signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  long long I, O, T, J, L, S, Z; cin >> I >> O >> T >> J >> L >> S >> Z;
  long long res = O + I / 2 * 2 + J / 2 * 2 + L / 2 * 2;
  int t = I % 2 + J % 2 + L % 2;
  if (t == 3) res += 3;
  if (t == 2 and I > 0 and J > 0 and L > 0) res += 1; 
  cout << res << "\n";
  return 0;
}

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

using ll = long long;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)

int main(){
	int a,b,t;
	cin >> a >> b >> t;
	cout << t / a * b << endl;
	return 0; 
}

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

int main(){
  int n[101]={0},a,max;
  queue<int> q;
  while(cin>>a)n[a]++;
  max=1;
  while(q.size())q.pop();
  for(int i=1;i<=100;i++){
    if(n[i]>max){
      while(q.size())q.pop();
      q.push(i);
      max=n[i];
    }else if(n[i]==max){
      q.push(i);
    }
  }
  while(q.size()){
    cout<<q.front()<<endl;
    q.pop();
  }
  return 0;
}

Measured memory_bytes: 3056
import java.util.*;


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

		// 入力値取得
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		double po = Math.pow(r, 2);
		int d = 3 * (int)po;
		System.out.println(d);
	}
}


Measured memory_bytes: 21844
s=input()
q=int(input())
f=""
b=""
r=0
for i in range(q):
  query=input().split()
  if int(query[0])==1:
    r=1-r
  else:
    if (r^(int(query[1])-1))==0:
      f+=query[2]
    else:
      b+=query[2]
ret=f[::-1]+s+b
if r:
  ret=ret[::-1]
print(ret)

Measured memory_bytes: 9988
#include <iostream>
#include <vector>
#include <string.h>
#include <climits>
#include <algorithm>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;

int a, b;

signed main()
{
    cin >> a >> b;

    if (a <= 0 && 0 <= b) {
        cout << "Zero" << endl;
    } else {
        if (0 < a) {
            cout << "Positive" << endl;
        } else {
            if (b < 0) {
                if ((b - a) % 2 == 0) {
                    cout << "Negative" << endl;
                } else {
                    cout << "Positive" << endl;
                }
            } else {
                if ((-a) % 2 == 0) {
                    cout << "Positive" << endl;
                } else {
                    cout << "Negative" << endl;
                }
            }
        }
    }
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = line[0], K = line[1];
            var array = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var sol = new Solve(N, K, array);
            Console.WriteLine(sol.Execute());
        }
    }

    class Solve
    {
        public int N { get; set; }
        public int K { get; set; }
        public int[] array { get; set; }
        public int[] dp { get; set; }

        public Solve(int N, int K, int[] array)
        {
            this.N = N; this.K = K; this.array = array;
            dp = new int[N + 10];
        }

        public int Execute()
        {
            for (var i = 1; i < N; i++)
            {
                var min = int.MaxValue;
                for (var j = 1; j <= K && i-j >=0; j++)
                {
                    min = Math.Min(dp[i-j] + Math.Abs(array[i] - array[i - j]), min);
                }
                dp[i] = min;
            }
            return dp[N-1];
        }
    }
}

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

#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

const int maxn=(int)3005;


int a[maxn],b[maxn];

int dp[maxn][maxn+maxn];

bool cmp(pii &a,pii& b)
{
    return a.first<b.first;
}

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

    vector< pii > v;

    v.pb({-1,-1});

    for(int i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i];

        v.pb({a[i],b[i]});
    }

    sort(v.begin(),v.end(),cmp);

    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<maxn+maxn;j++)
        {
            dp[i][j]=dp[i-1][j];
        }

        for(int j=v[i].first;j<maxn+maxn;j++)
        {
            if(j-v[i].first<t)
            {
                dp[i][j]=max(dp[i][j],dp[i-1][j-v[i].first]+v[i].second);
            }
        }
    }

    int res=0;

    for(int j=0;j<maxn+maxn;j++)
    {
        res=max(res,dp[n][j]);
    }

    cout<<res<<endl;

    return 0;

}

Measured memory_bytes: 70784
#include<stdio.h>

#define MAX 100
#define MIN 1 

int main(){
  int i, j;
  int n, u, k, v;
  int Adj[MAX][MAX];
  
  scanf("%d", &n);
  if(n<=MAX && n>=MIN){
    for(i=0;i<n;i++)
      for(j=0;j<n;j++)
	Adj[i][j]=0;
    
    for(i=0;i<n;i++){
      scanf("%d%d", &u, &k);
      for(j=0;j<k;j++){
	scanf("%d", &v);
	Adj[u-1][v-1]=1;
      }
    }
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	 if(j>0)printf(" ");
	printf("%d", Adj[i][j]);
      } printf("\n");
    }
  }  
  return 0;
}


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

int main(){
       int a,b;
       char op;

       while(op != '?'){

       cin>>a>>op>>b;
       
       if(op == '+'){
	      cout<<a+b<<endl;
       }else if(op == '-'){
	      cout<<a-b<<endl;
       }else if(op == '*'){
	      cout<<a*b<<endl;
       }else if(op == '/'){
	      if(b == 0) break;
	      cout<<a/b<<endl;
       }
       }

       return 0;
}
 

Measured memory_bytes: 3072
n, m = gets.to_s.split.map{|i| i.to_i }

# bits = Array.new(n){|i| 2**i }
# p bits = Array.new(12){|i| 2**i } #=> [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]
shops = Array.new(m) do
  a = gets.to_s.to_i
  c = gets.to_s.split.map{|i| i.to_i - 1 }
  [c.reduce(0){|s,t| s + (1 << t) }, a]
end

inf = 10 ** 10
state_size = 2 ** n
d = Array.new(state_size, inf)
d[0] = 0

state_max = 0
shops.each do |(bit, a)|
  state_max |= bit
  state_max.times do |k|
    new = k | bit
    d[new] = d[k] + a if d[new] > d[k] + a
  end
  
end

puts d[-1] == inf ?  -1 : d[-1]

Measured memory_bytes: 3964
#coding: UTF-8
import copy
 
N,K = map(int, input().split())
A = list(map(int, input().split()))


for i in range(N-K):
  #i=0 = i+K学期判定
  scr1 = 1
  scr2 = 1
  #手前
  scr1 *= A[i]
  #print(scr1)
  scr2 *= A[i+K]
  #print(scr2)
  if scr1<scr2:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 31936
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main(int argc , char **argv)
{
	(void)argc;
	(void)argv;

	int A,B;
	cin >> A >> B;
	int c=A+B;
	if(10<=c){printf("error\n");}else{printf("%d\n",c);}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){

  int N, M, Q; cin >> N >> M >> Q;

  int table[N][N];
  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      table[i][j] = 0;
    }
  }

  for (int i = 0; i < M; i++){
    int L, R; cin >> L >> R;
    L--; R--;
    table[L][R]++;
  }


  int C[N][N + 1];
  for (int i = 0; i < N; i++){
    for (int j = 0; j < N + 1; j++){
      if (j == 0) C[i][j] = 0;
      else C[i][j] = C[i][j - 1] + table[i][j - 1];
    }
  }
  

  vector < pair<int, int> > PQ(Q);
  for (int i = 0; i < Q; i++){
    int p, q; cin >> p >> q;
    p--; q--;
    PQ[i] = make_pair(p, q);
  }
  
  for (int i = 0; i < Q; i++){
    int p = PQ[i].first, q = PQ[i].second;

    int ans = 0;
    for (int i = p; i <= q; i++){
      ans += C[i][q + 1] - C[i][p];
    }
    cout << ans << endl;
  }

  return 0;
}


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

class Main {
    static Scanner scanner = new Scanner();
    static long mod = 1000000007;

    public static void main(String[]$) {
        int n = scanner.nextInt();
        System.out.println((n + 1) / 2 / (double)n);
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


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

using ll=long long;
using namespace std;

#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}

const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

char BigAlphaToSmall(char a){
    if (a >= 65 && a <= 90){
        return a + 32;
    }
    return a;
}

char SmallAlphaToBig(char a){
    if (a >= 97 && a <= 122){
        return a - 32;
    }
    return a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    vector<int> hoge;
    int n; cin >> n;
    int a, b;
    for (int i = 0; i < n; i++){
        cin >> a;
        if(a == 0){
            cin >> b;
            hoge.push_back(b);
            continue;
        }

        if(a == 1){
            cin >> b;
            say(hoge[b]);
            continue;
        }

        if(a == 2){
            hoge.pop_back();
        }
    }
}


Measured memory_bytes: 3856
import sys
sys.setrecursionlimit(10**8)
N = int(input())
AB = [tuple(map(int,input().split())) for i in range(N-1)]
es = [[] for i in range(N)]
for i,(a,b) in enumerate(AB):
    a,b = a-1,b-1
    es[a].append((b,i))
    es[b].append((a,i))
ans=[0]*(N-1)
g=[0]*N
def dfs(v,h=-1):
  res=1
  for i,j in es[v]:
      if g[i]:
            continue
      g[v]=1
      if h==res:
            res+=1
      ans[j]=res
      dfs(i,res)
      res+=1

dfs(0)
print(max(ans))
for i in ans:
      print(i)


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

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

    int x;
    cin >> x;
    if(x==1) puts("0");
    if(x==0) puts("1");

    return 0;
}

Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	void solve() throws IOException {
		solve(ni());
	}

	int[][] max;
	int[] a;

	private void solve(int n) throws IOException {
		int N = 1 << n;

		a = new int[N];
		max = new int[N][2];
		for (int i = 0; i < N; i++) {
			a[i] = ni();
			Arrays.fill(max[i], -1);
		}

		for (int i = 0; i < N; i++) {
//			Helper.tr("->", i);
			merge(i, i);
			for (int bit = 0; bit < n; bit++) {
				if ((i & (1 << bit)) == 0) {
					merge(i ^ (1 << bit), max[i][1]);
					merge(i ^ (1 << bit), max[i][0]);
				}
			}
		}
//		Helper.tr(a);
//		Helper.tr(max);
		int ans = 0;
		for (int i = 1; i < max.length; i++) {
			ans = Math.max(ans, a[max[i][0]] + a[max[i][1]]);
			out.println(ans);
		}
	}

	private void merge(int i, int j) {
		if (j < 0)
			return;
//		Helper.tr(i, j, max[i][1], max[i][0], a[j]);
		if (j == max[i][1] || j == max[i][0])
			return;
		if (max[i][1] < 0 || a[max[i][1]] < a[j]) {
			max[i][0] = max[i][1];
			max[i][1] = j;
		} else if (max[i][0] < 0 || a[max[i][0]] < a[j]) {
			max[i][0] = j;
		}
	}

	String ns() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine(), " ");
		}
		return tok.nextToken();
	}

	int ni() throws IOException {
		return Integer.parseInt(ns());
	}

	long nl() throws IOException {
		return Long.parseLong(ns());
	}

	double nd() throws IOException {
		return Double.parseDouble(ns());
	}

	String[] nsa(int n) throws IOException {
		String[] res = new String[n];
		for (int i = 0; i < n; i++) {
			res[i] = ns();
		}
		return res;
	}

	int[] nia(int n) throws IOException {
		int[] res = new int[n];
		for (int i = 0; i < n; i++) {
			res[i] = ni();
		}
		return res;
	}

	long[] nla(int n) throws IOException {
		long[] res = new long[n];
		for (int i = 0; i < n; i++) {
			res[i] = nl();
		}
		return res;
	}

	public static void main(String[] args) throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		tok = new StringTokenizer("");
		Main main = new Main();
		main.solve();
		out.close();
	}
}

Measured memory_bytes: 84320
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String args[]){

		Scanner cin = new Scanner(System.in);
		String tmp = cin.next();
		String result = "yes";
		
		HashMap <Character,Integer> check = new HashMap<Character,Integer>();
		for(int i=0;i<tmp.length();i++){
			if(check.containsKey(tmp.charAt(i))){
				result = "no";
				break;
			}else{
				check.put(tmp.charAt(i), 1);
			}
		}
		System.out.println(result);
	}
}


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

int main(){
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << x2 + y1 - y2 << ' ' << y2 - x1 + x2 << ' ' << x1 + y1 - y2 << ' ' << y1 - x1 + x2;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
using namespace std;
int a = 0, b = 0, c = 0, d = 0, e[17] = {}, f[100010] , counto = 0, counto1 = 1145148;
double syo = 0, su = 0;
bool mazi = false, gi[110] = { false };
pair<int, int>n[110];
vector<int> r;
int main() 
{
	cin >> a;
	for (int i = 0; i < a; i++) {
		cin >> e[i];
	}
	sort(e, e + a);
	for (int i = 0; i < a-1; i++) {
		counto += e[i];
	}
	if (counto > e[a - 1]) {
		cout << "Yes" << endl;
	}
	else { cout << "No" << endl; }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<int, int>p;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
const ull INF3 = 18446744073709551600LL;
bool flag = true;
bool fl = true;
bool used[210];
bool graph[100][100];
bool visited[8];
int abc[26] = { 0 };


int main() {
	ull n, k, w[100000], d[100000];
	std::cin >> n >> k;
	for (int i = 0;i < n;i++) {
		std::cin >> w[i] >> d[i];
	}
	ull l = 0, r = INF3;
	while (r - l > 1) {
			ull sum = 0;
			ull mid = (l + r) / 2;
			for (int i = 0;i < n;i++) {
				if (mid < w[i])continue;
				else {
					sum += (mid - w[i]) / d[i] + 1;
				}
				if (sum > k)break;
			}
			if (sum >= k) {
				r = mid;
			}
			else if (sum < k) {
				l = mid;
			}
		}
		std::cout << r << std::endl;
}

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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int H, W;
vector<string> a;
bool went[8][8];
int num;
bool judge;

void dfs(int h, int w) {
    num--;
    if(num == 0) {
        judge = true;
        return;
    }
    if(h < H - 1 && a[h + 1][w] == '#') {
        dfs(h + 1, w);
        num++;
    }
    if(w < W - 1 && a[h][w + 1] == '#') {
        dfs(h, w + 1);
        num++;
    }
}

int main() {
    cin >> H >> W;
    a.resize(H);
    REP(i, H) cin >> a[i];
    REP(i, H) REP(j, W) if(a[i][j] == '#') num++;
    dfs(0, 0);
    cout << (judge ? "Possible" : "Impossible") << "\n";
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();

		if(a == b)
			System.out.println("a == b");
		else if(a < b)
			System.out.println("a < b");
		else
			System.out.println("a > b");
	}

}


Measured memory_bytes: 26152
#include<bits/stdc++.h>
using namespace std;
long long s;
long long x[3];
long long y[3];
long long inf=1e9;
int main() {
    scanf("%lld",&s);
    if(s==inf*inf) {
        printf("%lld %lld\n",0,0);
        printf("%lld %lld\n",inf,0);
        printf("%lld %lld\n",0,inf);
        return 0;
    }
    long long a,b,c,d;
    b=(s/inf);
    s=s-b*inf;
    c=s;
    a=1;
    d=inf-c;
    printf("%lld %lld\n",0,0);
    printf("%lld %lld\n",c+d,a);
    printf("%lld %lld\n",d,a+b);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> x(n),y(n),h(n);
	for(int i=0;i<n;i++)
		cin >> x[i] >> y[i] >> h[i];
	
	int hig=-1;
	for(int cx=0;cx<=100;cx++)
	{
		for(int cy=0;cy<=100;cy++)
		{
			hig=abs(cx-x[0])+abs(cy-y[0])+h[0];
			bool zero=false;
			if(h[0]==0)
				zero=true;
			bool can=true;
			for(int i=1;i<n;i++)
			{
				int now=abs(cx-x[i])+abs(cy-y[i])+h[i];
				if(h[i]==0)
				{
					if(zero==true)
						hig=min(hig,now);
					else
					{
						if(hig>now)
							can=false;
					}
				}
				else
				{
					if(zero==true)
					{
						if(hig<now)can=false;
						hig=now;
						zero=false;
					}
					else if(hig != now)
						can=false;
				}
			}
			if(hig<1)can=false;
			if(can)
			{
				cout << cx << " " << cy << " " << hig << endl;
				return 0;
			}
		}
	}
	
	cout << -1 << endl;
}



Measured memory_bytes: 256
N, T = map(int, input().split())
a = [int(i) for i in input().split()]
b = [a[0]]
m = b[0]
for i in range(1,N):
	if m > a[i]:
		m = a[i]
	b.append(m)
c = [a[i] - b[i] for i in range(N)]
print(c.count(max(c)))

Measured memory_bytes: 14252
using System;

namespace Math_Functions
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] x = Console.ReadLine().Split(' ');
            double a = int.Parse(x[0]);
            double b = int.Parse(x[1]);
            double c = int.Parse(x[2]);

            double t = (c * Math.PI) / 180;

            Console.Write("{0:F4}\n{1:F4}\n{2:F4}\n",
                          0.5 * a * b * Math.Sin(t),
                          a + b + Math.Sqrt(a * a + b * b - 2 * a * b * Math.Cos(t)),
                          b * Math.Sin(t));
        }
    }
}

Measured memory_bytes: 9144
#include <bits/stdc++.h>
#define N 100010
int main()
{
    using namespace std;
    int n, m, h[N], ma[N];
    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
    {
        cin >> h[i];
        ma[i] = 0;
    }
    for (int i = 0; i < m; ++i)
    {
        int a, b;
        cin >> a >> b;
        ma[a] = max(ma[a], h[b]);
        ma[b] = max(ma[b], h[a]);
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i)
        ans += h[i] > ma[i];
    cout << ans << endl;
}

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

int main(){
  ll n, a, b, c;
  cin >> n >> a >> b;
  c = a - b;
  ll h[n];
  rep(i, n) cin >> h[i];
  ll lb = 0, ub = MAX_N;
  while(ub - lb > 1){
    ll mid = (ub + lb)/2;
    ll k = 0;
    rep(i, n){
      ll m = h[i] - b*mid;
      if(m > 0) k += (m + c - 1)/c;
    }
    if(k > mid) lb = mid;
    else ub = mid;
  }
  cout << ub << endl;
  return 0;
}


Measured memory_bytes: 1024
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    let n: usize = iter.next().unwrap().parse().unwrap();

    let mut difficulties: Vec<i32> = (0..n).map(|_| iter.next().unwrap().parse().unwrap() ).collect();
    difficulties.sort();

    if difficulties[n/2 - 1] == difficulties[n/2] {
        println!("0");
    } else {
        println!("{}", difficulties[n/2] - difficulties[n/2 - 1])
    }
}

Measured memory_bytes: 6396
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
typedef long double ld;
int main()
{
  int t; cin >> t;
  vector<ll> n(t), a(t), b(t), c(t), d(t);
  rep(i,t) {
    cin >> n[i] >> a[i] >> b[i] >> c[i] >> d[i];
  }
  ll inf = (1LL << 60);
 
  rep(i,t) {
    map<ll,ll> dp;
    dp[0] = 0;
    dp[1] = d[i];
    auto rec = [&](auto f, ll nn)-> ll{
		 if(dp.find(nn) != dp.end()) return dp[nn];
		 ll res = inf;
		 if(((ld)nn * (ld)d[i]) < inf) {
		   res = nn * d[i];
		 }
		 if(nn % 2 == 0) chmin(res, f(f, nn/2) + a[i]);
		 else {
		   chmin(res, f(f, (nn+1)/2) + a[i] + d[i]);
		   chmin(res, f(f, (nn-1)/2) + a[i] + d[i]);		   
		 }
		 if(nn % 3 == 0) chmin(res, f(f, nn/3) + b[i]);
		 else {
		   chmin(res, f(f, nn/3) + b[i] + d[i]*(nn % 3));
		   chmin(res, f(f, nn/3 + 1) + b[i] + d[i]*(3 - nn%3));		   		   
		 }
		 if(nn % 5 == 0) chmin(res, f(f, nn/5) + c[i]);
		 else {
		   chmin(res, f(f, nn/5) + c[i] + d[i]*(nn % 5));
		   chmin(res, f(f, nn/5 + 1) + c[i] + d[i]*(5 - nn%5));		   		   
		 }
		 return dp[nn] = res;
	       };
    cout << rec(rec, n[i]) << "\n";
  }
  
  return 0;
}

Measured memory_bytes: 4392
n = int(input())
Ps = list(map(int, input().split()))
ans = 0

for i in range(1, n-1):
    As = [Ps[i-1], Ps[i], Ps[i+1]]    
    if Ps[i] == sum(As) - max(As) - min(As):
        ans += 1


print(ans)

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

class Cube{
    public:
    int f[6];
    Cube(){}
    void roll_x(){roll(0,1,5,4);} // to E
    void roll_y(){roll(0,2,5,3);} // to N
    void roll_z(){roll(1,2,4,3);} // 上から見て時計回り
    void roll(int i,int j,int k,int l){
        int t=f[i]; f[i]=f[j]; f[j]=f[k]; f[k]=f[l]; f[l]=t;
    }
};

bool eq(Cube c1,Cube c2){
    for(int i=0;i<6;i++){
        if(c1.f[i]!=c2.f[i]) return false;
    }
    return true;
}

bool equal(Cube c1,Cube c2){
    for(int i=0;i<6;i++){
        for(int j=0;j<4;j++){
            if(eq(c1,c2)) return true;
            c1.roll_z();
        }
        if(i%2==0) c1.roll_y();
        else c1.roll_x();
    }
    return false;
}

int main(){
    Cube c1,c2;
    
    for(int i=0;i<6;i++) cin >> c1.f[i];
    for(int i=0;i<6;i++) cin >> c2.f[i];

    if(equal(c1,c2)) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


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

int main()
{
	bool flag=false;
	string s;
	cin >> s;
	
	for (int i = 0; i < s.length(); ++i)
	{		
		if (i%2 == 0)
		{
			if (s[i] == 'R' || s[i] == 'U' || s[i] == 'D')
			{
				flag = true;
			}
			else
			{
				flag = false;
				break;
			}
		}
		else
		{
			if (s[i] == 'L' || s[i] == 'U' || s[i] == 'D')
			{
				flag = true;
			}
			else
			{
				flag = false;
				break;
			}
		}
	}
	
	if (flag == true)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	cin >> N;
	lint countM = 0;
	lint countA = 0;
	lint countR = 0;
	lint countC = 0;
	lint countH = 0;

	for (int i = 0; i < N; i++)
	{
		string tmp;
		cin >> tmp;
		switch (tmp[0])
		{
		case 'M':
			countM++;
			break;
		case 'A':
			countA++;
			break;
		case 'R':
			countR++;
			break;
		case 'C':
			countC++;
			break;
		case 'H':
			countH++;
			break;
		default:
			break;
		}
	}
	lint ans = 0;
	ans += countM * countA * countR;
	ans += countM * countA * countC;
	ans += countM * countA * countH;
	ans += countM * countR * countC;
	ans += countM * countR * countH;
	ans += countM * countC * countH;
	ans += countA * countR * countC;
	ans += countA * countR * countH;
	ans += countA * countC * countH;
	ans += countR * countC * countH;

	cout << ans << endl;

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MAXN 100009
#define MOD 1000000007
#define LL long long

int main(){
	LL n,m;
	cin>>n>>m;
	LL x[MAXN],y[MAXN];
	for(LL i=0;i<n;i++){
		cin>>x[i];
	}
	for(LL i=0;i<m;i++){
		cin>>y[i];
	}
	sort(x,x+n,greater<LL>());
	sort(y,y+m,greater<LL>());
	LL mul=(n-1);
	LL sumx=0;
	for(LL i=0;i<n;i++){
		sumx+=(mul*x[i])%MOD;
		mul-=2;
		sumx%=MOD;
		if(sumx<0){
			sumx+=MOD;
		}
	}
	mul=(m-1);
	LL sumy=0;
	for(LL i=0;i<m;i++){
		sumy+=(mul*y[i])%MOD;
		mul-=2;
		sumy%=MOD;
		if(sumy<0){
			sumy+=MOD;
		}
	}
	LL res = sumx*sumy%MOD;
	cout<<res;
	return 0;
}

Measured memory_bytes: 1792
news = "NEWS"
adds = [[1, 0], [0, 1], [0, -1], [-1, 0]]

while true
    n = gets.to_i
    break if n == 0
    gems = Array.new(21){"." * 21}
    n.times{
        x, y = gets.chomp.split.map(&:to_i)
        gems[y][x] = "#"
    }
    gems[10][10] = "-"

    m = gets.to_i
    y, x = 10, 10
    m.times{
        direction, distance = gets.chomp.split
        add = adds[news.index(direction)]
        distance.to_i.times{|i|
            y, x = y + add[0], x + add[1]
            gems[y][x] = "-"
        }
    }
    puts gems.all?{|line| !line.include?("#")} ? "Yes" : "No"
end


Measured memory_bytes: 6880
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

typedef struct dice{
    int face[6];
}dice;

void rotate(dice *d, char dir)
{
    int temp;
    switch(dir) {
    case 'N':
        temp=d->face[0];
        d->face[0]=d->face[1];
        d->face[1]=d->face[5];
        d->face[5]=d->face[4];
        d->face[4]=temp;
        break;
    case 'E':
        temp=d->face[0];
        d->face[0]=d->face[3];
        d->face[3]=d->face[5];
        d->face[5]=d->face[2];
        d->face[2]=temp;
        break;
    case 'W':
        temp=d->face[0];
        d->face[0]=d->face[2];
        d->face[2]=d->face[5];
        d->face[5]=d->face[3];
        d->face[3]=temp;
        break;
    case 'S':
        temp=d->face[0];
        d->face[0]=d->face[4];
        d->face[4]=d->face[5];
        d->face[5]=d->face[1];
        d->face[1]=temp;
        break;
    }
}

int isSame(dice d1, dice d2)
{
    static const char dir[]="NNNESSSWNNNESSSWNNNESSSW";
    int i, j;
    for(i=0; i<24; i++) {
        for(j=0; j<6 && d1.face[j]==d2.face[j]; j++);
        if(j==6) return 1;
        rotate(&d2, dir[i]);
    }
    return 0;
}

int main()
{
    dice d[100];
    int i, j, n;
    scanf("%d", &n);
    for(i=0; i<n; i++) {
        for(j=0; j<6; j++) {
            scanf("%d", &d[i].face[j]);
        }
        for(j=0; j<i; j++) {
            if(isSame(d[i], d[j])) {
                puts("No");
                return 0;
            }
        }
    }
    puts("Yes");
    return 0;
}



Measured memory_bytes: 2112
#include <iostream>
#include <algorithm>
#include <vector>

typedef std::pair<int, int> P;

int n, sum;
P x[2001];
std::vector<int> book[11];
int cnt[11];
int dp[11][2001];

int main(){
	std::cin >> n >> sum;
	for(int i = 0; i < n; ++i){
		int a, b;
		std::cin >> a >> b;
		book[b - 1].push_back(a);
	}
	
	for(int i = 0; i < 10; ++i){
		std::sort(book[i].begin(), book[i].end(), std::greater<int>());
		for(int j = 1; j < book[i].size(); ++j){
			book[i][j] += book[i][j - 1];
		}
		for(int j = 1; j < book[i].size(); ++j){
			book[i][j] += j * (j + 1);
		}
		book[i].insert(book[i].begin(), 0);
	}
	
	for(int i = 0; i < 11; ++i){
		for(int j = 0; j < 2001; ++j)dp[i][j] = -1;
	}
	
	dp[0][0] = 0;
	for(int i = 0; i < 10; ++i){
		for(int j = 0; j <= sum; ++j){
			if(dp[i][j] == -1)continue;
			
			for(int k = 0; k < book[i].size(); ++k){
				if(j + k <= sum)dp[i + 1][j + k] = std::max(dp[i + 1][j + k], dp[i][j] + book[i][k]);
			}
		}
	}
	
	std::cout << dp[10][sum] << std::endl;
	
	return 0;
}

Measured memory_bytes: 1340
#include <iostream>
#include <cstdio>
using namespace std;
const int MAX = 10005;
int c[MAX];
int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    int *a, *b;
    cin >> n;
    a = new int[n + 1];
    b = new int[n + 1];
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        ++c[a[i]];
    }
    int i;
    for (i = 0; i <= MAX; ++i)
    {
        if (c[i])
        {
            --c[i];
            cout << i;
            break;
        }
    }
    for (;i <= MAX; ++i)
    {
        while (c[i])
        {
            --c[i];
            cout << ' ' << i;
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 11068
using System;
 
class Program
{
    static void Main(string[] args)
    {
        var inputValues = Console.ReadLine().Split(' ');
        var a = int.Parse(inputValues[0]);
        var b = int.Parse(inputValues[1]);
        var t = int.Parse(inputValues[2]);
 
        int biscuitCreateTiming = (int)(t + 0.5) / a;
        int biscuitSum = biscuitCreateTiming * b;
 
        Console.WriteLine(biscuitSum);
    }
}

Measured memory_bytes: 13140
use std::vec::Vec;
use std::cmp::min;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
    let v = read_vec::<T>();
    assert_eq!(v.len(), 2);
    (v[0], v[1])
}

fn main() {
    let (n, k) = read_touple::<usize>();
    let a: Vec<usize> = read_vec();
    let first = "First";
    let second = "Second";
    let mut ans = first;
    let mut dp = vec![vec![false; 2]; k+1];

    // init
    dp[0][0] = false;
    dp[0][1] = false;

    for i in 0..k+1 {
        for &e in &a {
            if i + e > k {
               continue
            }
            dp[i+e][0] = !dp[i][1] || dp[i+e][0];
            dp[i+e][1] = !dp[i][0] || dp[i+e][1];
        }
    }

    if !dp[k][0] {
       ans = second;
    }

    println!("{}", ans);
}


Measured memory_bytes: 8444