akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define lint long long int
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define MAXN 100001
#define len length()
#define testcase(t) for(int i=0;i<t;i++)
lint dp[100001];

void solve()
{
	//lint t;
	//cin>>t;
	//testcase(t)
	//{
		lint n,k,q;
		string s;
		char c;
		cin>>n;
		lint a[n+1];
		for(int i=1;i<n+1;i++)
			cin>>a[i];
		//dp[1]=0;
		dp[0]=mod;
		//dp[1]
		for(int i=1;i<n+1;i++)
		{
			if(i==1)
				dp[i]=0;
			else
				dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
		}
		cout<<dp[n]<<endl;

	//}
}
int main()
{

	solve();
}

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

int main(){
  long long int n, m;
  cin >> n >> m;
  vector<tuple<long long int, long long int>> x;
  rep(i,n,0){
    long long int a, b;
    cin >> a >> b;
    x.push_back(tie(a, b));
  }
  sort(x.begin(), x.end());
  
  long long int ans = 0;
  rep(i,n,0){
    long long int cost, hon;
    tie(cost, hon) = x[i];
    ans += (cost * min(hon,m));
    m -= min(hon,m);
    if(m == 0) break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3444
#include<stdio.h>
int main(void)
{
	char s[10];
	int i;
	scanf("%s", s);
	if (s[0] == 'R') {
		if (s[1] == 'R') {
			if (s[2] == 'R') {
				i = 3;
			}
			else {
				i = 2;
			}
		}
		else {
			i = 1;
		}
	}
	else {
		if (s[1] == 'R') {
			if (s[2] == 'R') {
				i = 2;
			}
			else {
				i = 1;
			}
		}
		else {
			if (s[2] == 'R') {
				i = 1;
			}
			else {
				i = 0;
			}
		}
		}
	printf("%d",i);
	return 0;
}

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

typedef long long ll;

int main() {
      ios::sync_with_stdio(0);
      srand(time(NULL));
    
      ll a, b, c, x, y;
      cin >> a >> b >> c >> x >> y;
      
      ll ans1 = max(x, y)*c*2;
      ll ans2 = min(x, y)*c*2;
      if (x > y) {
            ans2 += (x - y)*a;
      } else {
            ans2 += (y - x)*b;
      }
      ll ans3 = a*x + b*y;
      cout << min(ans1, min(ans3, ans2));
    
      return 0;
}

Measured memory_bytes: 256
H,W = map(int, input().split())
c, A = [], []
num = [0] * 10
for _ in range(10):
    ci = list(map(int, input().split()))
    ci[0], ci[1] = ci[1], ci[0]
    c.append(ci)
for _ in range(H):
    A += list(map(int, input().split()))
for i in [0] + list(range(2, 10)):
    num[i] += A.count(i)

c = [[0]] + c[:1] + c[2:]
num[0], num[1] = num[1], num[0]

dp = [[c[i][0] for i in range(10)]] + [[10000 for i in range(10)] for j in range(9)]
for i in range(1, 10):
    for j in range(1, 10):
            dp[i][j] = min(c[j][k] + dp[i-1][k] for k in range(1, 10))

print(sum(dp[9][i] * num[i] for i in range(1,10)))

Measured memory_bytes: 3508
#include<bits/stdc++.h>
  using namespace std;
   
  void __print(int x) {cout << x;}
  void __print(long x) {cout << x;}
  void __print(long long x) {cout << x;}
  void __print(unsigned x) {cout << x;}
  void __print(unsigned long x) {cout << x;}
  void __print(unsigned long long x) {cout << x;}
  void __print(float x) {cout << x;}
  void __print(double x) {cout << x;}
  void __print(long double x) {cout << x;}
  void __print(char x) {cout << '\'' << x << '\'';}
  void __print(const char *x) {cout << '\"' << x << '\"';}
  void __print(const string &x) {cout << '\"' << x << '\"';}
  void __print(bool x) {cout << (x ? "true" : "false");}
   
  template<typename T, typename V>
  void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
  template<typename T>
  void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
  void _print() {cout << "]\n";}
  template <typename T, typename... V>
  void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
  #ifndef ONLINE_JUDGE
  #define debug(x...) cout << "[" << #x << "] = ["; _print(x)
  #else
  #define debug(x...)
  #endif
  #define int long long int 
  #define fi first
  #define se second
  #define FIO {ios::sycnt2_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
  #define pb push_back
  #define all(x) (x).begin(), (x).end()
  #define rall(x) (x).rbegin(), (x).rend()
  #define forn(i, n) for (int i = 0; i < (int)(n); ++i)
  #define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
  #define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
  #define all(x) (x).begin(), (x).end()
  #define pow10(n) stoll("1"+string(n,'0'))
  //fill(all(arr),1)
  //if(map.count(key)){}
  //bitset<20>(n);
  //int mini=min({a,b,c,d,e});
   
  typedef pair<int, int> pii;
  typedef vector<int> vi;
  typedef vector<pii> vpi;
  typedef vector<vi> vvi;
  typedef long long ll;
  typedef vector<ll> vll;
  typedef vector<vll> vvll;
  typedef long double ld;
  int32_t main()
  {
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a;  
  }

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

string s;
deque<char>d;
char c;
int f, t, q;

int32_t main()
{
	cin >> s >> q;
	int cont = 0;
	
	for(int i=0; i<s.size(); i++)
		d.push_back(s[i]);
	
	while(q--)
	{
		scanf("%lld", &t);
		if(t == 1)
			cont++;
		else
		{
			scanf("%lld %c", &f, &c);
			if((f == 1 and cont%2==0) or (f == 2 and cont%2==1))
				d.push_front(c);
			else if((f == 1 and cont%2==1) or (f == 2 and cont%2==0))
				d.push_back(c);
		}
	}
	
	if(cont%2==0)
		for(int i=0; i<d.size(); i++)
			cout << d[i];
	else
		for(int i=d.size()-1; i>=0; i--)
			cout << d[i];
	
	cout << '\n';
}

Measured memory_bytes: 896
import java.util.Scanner;

/**
 *
 * @author k16075kk
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] line = scanner.nextLine().split(" ");
        int a1 = Integer.parseInt(line[0]);
        int a2 = Integer.parseInt(line[1]);
        int a3 = Integer.parseInt(line[2]);
        int a4 = Integer.parseInt(line[3]);
        int a5 = Integer.parseInt(line[4]);
        int a6 = Integer.parseInt(line[5]);

        int b = Integer.parseInt(scanner.nextLine());
        for (int i = 0; i < b; i++) {
            int c = scanner.nextInt();
            int d = scanner.nextInt();
            int result = 0;
            if (c == a1 || c == a6) {
                if (d == a2) {
                    result = 3;
                } else if (d == a3) {
                    result = 5;
                } else if (d == a4) {
                    result = 2;
                } else {
                    result = 4;
                }
            } else if (c == a2 || c == a5) {
                if (d == a1) {
                    result = 4;
                } else if (d == a3) {
                    result = 1;
                } else if (d == a4) {
                    result = 6;
                } else {
                    result = 3;
                }
            } else {
                if (d == a1) {
                    result = 2;
                } else if (d == a2) {
                    result = 6;
                } else if (d == a5) {
                    result = 1;
                } else {
                    result = 5;
                }
            }
            if (c == a4 || c == a5 || c == a6) {
                result = 7 - result;
            }
            System.out.println(line[result - 1]);
        }
    }

}



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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

ll H, W, N;
ll a, b;
string A, B;

bool is(ll h, ll w)
{
	return (0 <= h && h < H) && (0 <= w && w < W);
}

int main(int argc, char **argv)
{
	cin >> H >> W >> N >> a >> b >> A >> B;
	--a, --b;

	bool ok{true};
	ll w{b};

	// right
	REP(i, N)
	{
		if (A[i] == 'R')
			++w;
		if (!is(a, w)) ok = false;

		if (B[i] == 'L' && w != 0)
			--w;
	}

	w = b;
	// left
	REP(i, N)
	{
		if (A[i] == 'L')
			--w;
		if (!is(a, w)) ok = false;
		if (B[i] == 'R' && w != W-1)
			++w;
	}

	ll h{a};
	// top
	REP(i, N)
	{
		if (A[i] == 'U') --h;
		if (!is(h, b)) ok = false;
		if (B[i] == 'D' && h != H-1)
			++h;
	}

	h = a;
	REP(i, N)
	{
		if (A[i] == 'D') ++h;
		if (!is(h, b)) ok = false;
		if (B[i] == 'U' && h != 0)
			--h;
	}

	std::cout << (ok ? "YES" : "NO") << std::endl;
}


Measured memory_bytes: 776
#include<bits/stdc++.h>
#define pb push_back
#define li long long int
#define mp make_pair
using namespace std;
 int main(){
 int n;
 cin>>n;
 vector<int>a(n),b(n);
 for(int i = 0 ; i < n ; i++){
    cin>>a[i];
    b[i]=a[i];
 }
 sort(a.begin(),a.end());
 li count=0;
 for(int i = 0 ; i < n; i++){
    if(a[i]!=b[i])
        count++;
 }
 if(count<=2)
    cout<<"YES"<<endl;
 else
    cout<<"NO"<<endl;

 }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
using namespace std;

int main()
{
	string a;
	cin >> a;
	int ans = 0;
	stack<char>stk;
	for (int i = 0; i < a.length(); i++) {
		if (stk.empty())stk.push(a[i]);
		else {
			if (stk.top() == a[i])stk.push(a[i]);
			else {
				ans += 2;
				stk.pop();
			}
		}
	}
	cout << ans;
	return 0;
}

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

using namespace std;

int solve(const vector<int>& A, const vector<int>& B){
    vector<int> spare;
    long long lack = 0;
    long long res = 0;
    for(int i=0;i<A.size();i++){
        if(A[i] < B[i]){ lack += B[i] - A[i]; res++; }
        else { spare.emplace_back(A[i]-B[i]); }
    }
    if(lack == 0) return res;
    sort(spare.rbegin(), spare.rend());
    for(auto& s : spare){
        lack -= s;
        ++res;
        if(lack <= 0) return res;
    }
    return -1;
}

int main(){
    int N;
    while(cin >> N){
        vector<int> A(N), B(N);
        for(auto& t : A) cin >> t;
        for(auto& t : B) cin >> t;
        cout << solve(A, B) << endl;
    }
}

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

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

int main()
{
  long long int x, y;
  while (cin >> x >> y, x + y){
    int cnt = 0;
    if (x < y) swap(x, y);
    while (y != 0){
      x = x % y;
      swap(x, y);
      cnt++;
    }
    cout << x << " " << cnt << endl;
  }
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
struct edge{int to,cap,rev;};
int m,n;
vector<edge> G[1500];
int v[1500];
bool used[1500];

void add_edge(int from,int to,int cap){
  G[from].push_back((edge){to,cap,int(G[to].size())});
  G[to].push_back((edge){from,0,int(G[from].size()-1)});
}

int dfs(int v,int t,int f){
  if(v==t) return f;
  used[v]=1;
  for(int i=0;i<G[v].size();++i){
    edge &e = G[v][i];
    if(used[e.to] || e.cap<=0) continue;
    int d = dfs(e.to,t,min(f,e.cap));
    if(d>0){
      e.cap-=d;
      G[e.to][e.rev].cap+=d;
      return d;
    }
  }
  return 0;
}

int ford_fulkerson(int s,int t){
  int flow = 0,f;
  while(true){
    memset(used,0,sizeof(used));
    f=dfs(s,t,1<<28);
    if(f==0) break;
    flow+=f;
  }
  return flow;
}

int main(){
  while(cin>>m>>n,m||n){
    for(int i=0;i<=m+n+1;++i) G[i].clear();
    for(int i=1;i<=m;++i) cin>>v[i];
    for(int i=m+1;i<=m+n;++i) cin>>v[i];
    for(int i=1;i<=m;++i) add_edge(0,i,1);
    for(int j=m+1;j<=m+n;++j) add_edge(j,m+n+1,1);
    for(int i=1;i<=m;++i)
      for(int j=m+1;j<=m+n;++j)
	if(__gcd(v[i],v[j])>1)
	  add_edge(i,j,1);

    cout << ford_fulkerson(0,m+n+1) << endl;
  }  
  return 0;
}

Measured memory_bytes: 7604
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int Q = sc.nextInt();
        for (int tc = 0; tc < Q; ++tc) {
            int A = sc.nextInt();
            int B = sc.nextInt();

            System.out.println(solve(A, B));
        }

        sc.close();
    }

    static int solve(int A, int B) {
        if (A > B) {
            return solve(B, A);
        }

        int result = -1;
        int lower = 0;
        int upper = A + B - 2;
        while (lower <= upper) {
            int middle = lower + (upper - lower) / 2;
            if (check(A, B, middle)) {
                result = middle;
                lower = middle + 1;
            } else {
                upper = middle - 1;
            }
        }

        return result;
    }

    static boolean check(int A, int B, int x) {
        long productLimit = (long) A * B;

        if (x < A) {
            return checkPiece(productLimit, 1, x, x, 1);
        } else if (x < B) {
            return checkPiece(productLimit, 1, A - 1, x, x - A + 2)
                    && checkPiece(productLimit, A + 1, x + 1, x - A + 1, 1);
        } else {
            if (A + B == x + 2) {
                return checkPiece(productLimit, 1, A - 1, x + 1, B + 1)
                        && checkPiece(productLimit, A + 1, x + 1, B - 1, 1);
            } else {
                return checkPiece(productLimit, 1, x - B + 1, x + 1, B + 1)
                        && checkPiece(productLimit, x - B + 2, A - 1, B - 1, x - A + 2)
                        && checkPiece(productLimit, A + 1, x + 1, x - A + 1, 1);
            }
        }
    }

    static boolean checkPiece(long productLimit, int beginA, int endA, int beginB, int endB) {
        int middleA = (beginA + beginB) / 2;
        int middleB = beginA + beginB - middleA;

        return checkPoint(productLimit, beginA, beginB) && checkPoint(productLimit, endA, endB)
                && (!(middleA >= beginA && middleA <= endA && middleB <= beginB && middleB >= endB)
                        || checkPoint(productLimit, middleA, middleB));
    }

    static boolean checkPoint(long productLimit, int a, int b) {
        return (long) a * b < productLimit;
    }
}

Measured memory_bytes: 21972
import sys
from operator import itemgetter
 
inf = 1 << 30
 
def solve():
    n = int(sys.stdin.readline())
 
    # r_max = MAX, b_min = MIN にしたとき
 
    r_max = b_max = 0
    r_min = b_min = inf

    p = []
 
    for i in range(n):
        xi, yi = map(int, sys.stdin.readline().split())

        if xi > yi:
            xi, yi = yi, xi

        p.append((xi, yi))

        r_max = max(r_max, yi)
        r_min = min(r_min, yi)
        b_max = max(b_max, xi)
        b_min = min(b_min, xi)
 
    ans1 = (r_max - r_min) * (b_max - b_min)
 
    # r_max = MAX, r_min = MIN にしたとき
 
    ans2 = (r_max - b_min)

    p.sort(key=itemgetter(0))

    b_min = p[0][0]
    b_max = p[-1][0]

    y_min = inf

    dif_b = b_max - b_min
 
    for i in range(n - 1):
        if p[i][1] == r_max:
            break

        y_min = min(y_min, p[i][1])

        b_min = min(p[i + 1][0], y_min)
        b_max = max(b_max, p[i][1])

        dif_b = min(dif_b, b_max - b_min)

        if p[i][1] < p[i + 1][0]:
            break
 
    ans2 *= dif_b
 
    ans = min(ans1, ans2)
 
    print(ans)
 
if __name__ == '__main__':
    solve()

Measured memory_bytes: 33904
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
constexpr long long LINF = 1000100010001000100LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


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

    ll T, A;
    rep(i, n){
        ll t, a; cin >> t >> a; 
        if(i==0 or t>=T and a>=A) T = t, A = a;
        else if(t < a) {
            ll num = T/t;if(T%t!=0)num++;
            ll t1 = num*t, a1 = num*a;
            if(a1 >= A) T = t1, A = a1;
            else{
                num = A/a;if(A%a!=0)num++;
                T = num*t, A = num*a;
            }
        }else if(t > a){
            ll num = A/a; if(A%a!=0)num++;
            ll aa = num*a, tt = num*t;
            if(tt >= T) T = tt, A = aa;
            else{
                num = T/t; if(T%t!=0)num++;
                T = num*t, A = num*a;
            }
        }else{
            if(T > A) A = T;
            else T = A;
        }
        //cout << "T:" << T << " A:" << A << ln;
    }

    cout << T + A << ln;
}

Measured memory_bytes: 256
import sys

turn = -1
for line in sys.stdin:
    turn += 1
    if turn%2 == 0:
        A = map(int, line.rstrip().split())
        continue
    else:
        B = map(int, line.rstrip().split())

    hit, blow = 0, 0
    for i, b in enumerate(B):
        if A[i] == b:
            hit += 1
        elif b in A:
            blow += 1
    print hit, blow

Measured memory_bytes: 6360
n = int(input())
h = list(map(int, input().split()))

dp = [0, abs(h[1]-h[0])]
if n >2:
    for i in range(2,n):
        dp.append(min(abs(h[i]-h[i-2])+dp[-2], abs(h[i]-h[i-1])+dp[-1]))
else:
    print(dp[-1])
    exit()

print(dp[-1])


Measured memory_bytes: 13928
N,A,B,C=map(int,input().split())
S=[]
d={'A':A, 'B':B, 'C':C}
for i in range(N):
    S.append(input())
out=[]

for i in range(N):
    s=S[i]
    s0=s[0]
    s1=s[1]

    if d[s0]==d[s1]==0:
        print('No')
        break
    elif d[s0]==0:
        d[s0]+=1
        d[s1]-=1
        out.append(s0)
    elif d[s1]==0:
        d[s0]-=1
        d[s1]+=1
        out.append(s1)
    elif i == N-1:
        out.append(s0)
    elif s0 in S[i+1]:
        d[s0]+=1
        d[s1]-=1
        out.append(s0)
    else:
        d[s0]-=1
        d[s1]+=1
        out.append(s1)
else:
    print('Yes')
    for o in out:
        print(o)

Measured memory_bytes: 16860
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i = n;i >= 0;--i)
#define FOR(i,m,n) for(int i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
int main(void)
{
    int n;
    cin >> n;
    vector<int> a(n + 1);
    a[0] = 0;
    FOR(i,1,n+1)
    {
        cin >> a[i];
    }
 
    vector<int> L(n + 2,0);
    vector<int> R(n + 2,0);
 
    for (int i = 0; i < L.size() - 1;i++){
        L[i + 1] = gcd(L[i], a[i]);
    }
 
    for (int i = n; i >= 1;i--){
        R[i] = gcd(R[i + 1], a[i]);
    }
 
    vector<int> M(n);
    for (int i = 1; i <= n;i++){
        M[i - 1] = gcd(L[i], R[i + 1]);
    }
 
    int ans = *max_element(all(M));
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;

namespace MyProgram{
    class AtCoder{
        static void Main(){
            int N = int.Parse(Console.ReadLine());
            long[] A = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
            var dic = new SortedDictionary<long,long>();
            for(var i=0;i<N;i++){
                if(!dic.ContainsKey(A[i]))dic[A[i]]=1;
                else dic[A[i]]++;
            }
            long a,b;
            long max=0;
            foreach(var key in dic.Keys){
                if(dic[key]>=2){
                    max = Math.Max(max,key);
                }
            }
            if(max!=0){
                dic[max] -= 2;
            }
            a = max;
            max = 0;
            foreach(var key in dic.Keys){
                if(dic[key]>=2){
                    max = Math.Max(max,key);
                }
            }
            b = max;
            Console.WriteLine(a*b);
        }
    } 
}

Measured memory_bytes: 29660
#include <iostream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>

using namespace std;

struct dice{
  int surface[6];

  void numReplace(int num[6], int n0, int n1, int n2, int n3, int n4, int n5){
    num[0] = n0;
    num[1] = n1;
    num[2] = n2;
    num[3] = n3;
    num[4] = n4;
    num[5] = n5;
  }
  
  void rotation(struct dice *self, char c){
    int num[6];
    for(int i = 0; i < 6; i++){
      num[i] = self->surface[i];
    }

    if(c == 'N'){
      numReplace(self->surface, num[1], num[5], num[2], num[3], num[0], num[4]);
    }
    else if(c == 'E'){
      numReplace(self->surface, num[3], num[1], num[0], num[5], num[4], num[2]);
    }
    else if(c == 'S'){
      numReplace(self->surface, num[4], num[0], num[2], num[3], num[5], num[1]);
    }
    else if(c == 'W'){
      numReplace(self->surface, num[2], num[1], num[5], num[0], num[4], num[3]);
    }
  }

  void spin(struct dice *self, string s){
    int num[6];
    for(int i = 0; i < 6; i++){
      num[i] = self->surface[i];
    }

    if(s == "CW"){
      numReplace(self->surface, num[0], num[2], num[4], num[1], num[3], num[5]);
    }
    else if(s == "CCW"){
      numReplace(self->surface, num[0], num[3], num[1], num[4], num[2], num[5]);
    }
  }
};

bool checkDiceSurface(struct dice *d1, struct dice *d2){
  for(int i = 0; i < 6; i++){
    if(d1->surface[i] != d2->surface[i]){
      return false;
    }
    else if(i == 5 && d1->surface[i] == d2->surface[i]){
      return true;
    }
    else{
      continue;
    }
  }
}

int main(){
  struct dice d[100] = {{0}};
  bool check = false;
  bool result = true;
  int n;
  
  cin >> n;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 6; j++){
      cin >> d[i].surface[j];
    }
  }

  for(int i = 0; i < n-1; i++){
    for(int j = i+1; j < n; j++){
      for(int k = 0; k < 6; k++){
	for(int l = 0; l < 4; l++){
	  if(checkDiceSurface(&d[i], &d[j])){
	    check = true;
	    break;
	  }
	  d[i].spin(&d[i], "CW");
	}
	if(check){ break; }

	if(k%2){ d[i].rotation(&d[i], 'E'); }
	else{ d[i].rotation(&d[i], 'S'); }
      }
      
      if(check){
	result = false;
	break;
      }
      else{
	check = false;
	continue;
      }
    }
    if(!result){ break; }
  }

  if(result){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3228
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
int X,Y,Z;
int main() {
	cin>>X>>Y>>Z;
	int A,B;
	A=Z;
	for(int i=1;;i++){
		A+=Y+Z;
		if(A<=X)B=i;
		else break;
	}

	cout<<B<<endl;
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  string s; cin >> s;
  reverse(ALL(s));
  int n = s.length();
  vector<vector<ll> > dp(n + 1, vector<ll>(2, LINF));
  dp[0][false] = 0;
  REP(i, n) {
    int val = s[i] - '0';
    chmin(dp[i + 1][false], dp[i][false] + val);
    if (val == 9) {
      chmin(dp[i + 1][true], dp[i][true]);
    } else {
      chmin(dp[i + 1][false], dp[i][true] + val + 1);
    }
    if (val == 0) {
      chmin(dp[i + 1][false], dp[i][false]);
    } else {
      chmin(dp[i + 1][true], dp[i][false] + 10 - val);
    }
    chmin(dp[i + 1][true], dp[i][true] + 9 - val);
  }
  cout << min(dp[n][false], dp[n][true] + 1) << '\n';
  return 0;
}


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

using namespace std;

int main()
{
    long long n, ans;
    cin>>n;

    int d = sqrt(n);

    for(int i=d; i>=1; --i)
    {
        if(n%i==0)
        {
            ans = n/i + i - 2;
            //cout<<n/i<<" "<<i<<endl;
            cout<<ans;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

ll high_pw(ll base, ll n, ll mod) {
    if (n == 1)
        return base % mod;
    else {
        ll tmp = high_pw(base, n/2, mod) % mod;
        ll sq = (tmp * tmp) % mod;
        if (n % 2 == 1)
            return (sq*base) % mod;
        return sq % mod;
    }
    return 1;
}
ll nCr(ll n, ll m) {
    ll mod = 1e9 + 7;
    m = min(m, n-m);
    if (m == 0) return 1;
    ll num = 1, dem = 1;
    for(ll i = 1; i <= m; i++) {
        num *= (n+1-i);
        num %= mod;
        dem *= i;
        dem %= mod;
    }
    dem = high_pw(dem, mod-2, mod) % mod;
    return (num * dem) % mod;
}
int main() {
    int N, K;
    ll mod = 1e9 + 7;
    cin >> N >> K;
    int red = N - K;
    //  0 1 2 3 4 bin
    //0 X 1 1 1 1
    //1 X 1 2 3 4
    //2 X 1 3 6 10
    //ball
    vector<vector<ll>> dp(red+1, vector<ll>(K+2, 0));
    for(int bin = 1; bin <= K+1; bin++)
        dp[0][bin] = 1;
    for(int ball = 0; ball <= red; ball++)
        dp[ball][1] = 1;
    for(int ball = 1; ball <= red; ball++) {
        for(int bin = 2; bin <= K+1; bin++) {
            dp[ball][bin] = (dp[ball][bin-1] + dp[ball-1][bin]) % mod;
        }
    }
    /*
    for(int i = 0; i <= red; i++) {
        for(int num: dp[i])
            cout << num << " ";
        cout << endl;
    }*/
    /*
    for(int i = 0; i < K; i++) { // i: use how many red balls
        if (red < i) {
            cout << 0 << endl;
            continue;
        }
        ll pre = nCr(K-1, i);

        ll post = dp[red-i][i+2];
        // cout << pre << " - " << post << endl;
        cout << (pre * post) % mod << endl;
    }*/
    for(int i = 1; i <= K; i++) {
        if (red < i-1) {
            cout << 0 << endl;
            continue;
        }
        ll pre = nCr(red+1, i) % mod;
        ll post = nCr(K-1, i-1) % mod;
        cout << (pre * post) % mod << endl;;
    }
    return 0;
}



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


int main(){

  ll a;
  cin>>a;
  cout<<3*a*a<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define mes(a,b) memset((a),(b),sizeof((a)))
#define syio std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0);
#define lson l, mid, rt << 1
#define rson mid+1, r, rt << 1 | 1
typedef long long ll;
typedef long double real;
typedef pair<int, int> pii;

const int oo = ~0u >> 2;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mxn = 1000003;
inline int read(){
    int x = 0,f = 1;char c = getchar();
    while(!isdigit(c))f = c == '-' ? -1 : 1,c = getchar();
    while(isdigit(c))x = x * 10 + c - '0',c = getchar();
    return x * f;
}
int n, a[mxn], cnt[mxn];
int main()
{
    syio;
    cin>>n;
    int mx = 0;
    for (int i = 1; i <= n; ++ i)
    {
        cin>>a[i];
        cnt[a[i]] ++;
        mx = max(mx, a[i]);
    } 
    int f1 = 0, f2 = 0;
    for (int i = 2; i <= mx; ++ i)
    {
        int num = 0;
        for (int j = 1; i*j <= mx; ++ j)
        {
            num += cnt[i*j];
        }
        if (num > 1) {f1 = 1; break;}
    }
    int gd = 0;
    for (int i = 1; i <= n; ++ i) 
    gd = __gcd(gd, a[i]);
    if (gd == 1) f2 = 1;
    if (!f1) cout<<"pairwise coprime"<<endl;
    else if (f2) cout<<"setwise coprime"<<endl;
    else cout<<"not coprime"<<endl;
    return 0;
}

Measured memory_bytes: 11348
#%%

N = int(input())
A = sorted([int(i) for i in input().split()])
B = sorted([int(i) for i in input().split()])
C = sorted([int(i) for i in input().split()])

#%%

def isok_A(index, key, arr):
    if arr[index] >= key:
        return True
    else:
        return False
 
def Binary_search_A(key, arr):
    
    ng = -1
    ok = len(arr)
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if isok_A(mid, key, arr) is True:
            ok = mid
        else:
            ng = mid
    
    return ng, ok

def isok_B(index, key, arr):
    if arr[index] > key:
        return True
    else:
        return False

def Binary_search_B(key, arr):
    
    ng = -1
    ok = len(arr)
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if isok_B(mid, key, arr) is True:
            ok = mid
        else:
            ng = mid
    
    return ng, ok

cnt = 0
for i in B:
    ng_a, ok_b = Binary_search_A(i, A)
    ng_c, ok_c = Binary_search_B(i, C)
    cnt += (ng_a + 1) * (N - ok_c)
print(cnt)


Measured memory_bytes: 28796
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,x,ans=0;
  cin >> a >> b >> x;
  ans+=b/x;
  ans-=a/x;
  if(a%x==0){
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
s = list(str(input()))
k = int(input())
t = s[k-1]
for i in range(n):
  if s[i] == t:
    s[i] = s[i]
  else:
    s[i] = "*"
answer = ""
for i in range(n):
  answer = answer + s[i]
print(answer)

Measured memory_bytes: 3064
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    int c = a * b;
    if(c % 2 == 1){
      System.out.println("Odd");
    }else{
      System.out.println("Even");
    }
  }
}

Measured memory_bytes: 21844
#include <stdio.h>
int main() {
	int x, y;
	for (int i = 1;; i++) {
		scanf("%d", &x);
		scanf("%d", &y);
		if (x == 0 && y == 0) {
			break;
		} if (x <= y) {
			printf("%d %d\n", x, y);
		}
		else {
			printf("%d %d\n", y, x);
		}
	} 
	return 0;
}


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

int n;
ll ans;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n;
    vector<ll> a(n);
    for (auto& i : a) cin >> i;

    for (int l = 0, r = 0, cur = 0, lr = 0; r < n; ++r) {
        while (l < r && (cur & a[r]) != 0) {
            cur ^= a[l];
            ++l;
        }

        bool moved = false;
        while (r < n && (cur & a[r]) == 0) {
            cur ^= a[r];
            ++r;
            moved = true;
        }

        ll sz = r - l;
        // cout << l << ' ' << r << '\n';
        ll rep = max(0, lr - l);
        ans -= rep * (rep - 1) / 2;
        ans += sz * (sz - 1) / 2;
        lr = r;
        if (moved) --r;
    }
    
    ans += n;
    cout << ans;
}



Measured memory_bytes: 4748
n = int(input())
a = list(map(int, input().split()))
INF = 1001001001001001
c = n//2
dp = [[-INF]*3 for _ in range(c+1)]
dp[0][0] = 0
for i in range(c+1):
    for j in range(3):
        for k in range(3):
            if i+1<=c and j+k<3 and 2*i+j+k<n:
                dp[i+1][j+k] = max(dp[i+1][j+k], dp[i][j]+a[2*i+j+k])

ans = -INF

for i in range(3):
    ans = max(ans,dp[c][i])

print(ans)

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

int main(){
  int N, min, x, p;
  cin >> N;
  min = 1000;

  for(int i = 0; i < N; i++){
    cin >> x;
    p = 0;
    while(x % 2 == 0 && x != 0){
      p++;
      x /= 2;
    }
    if(p < min){
      min = p;
    }
    
  }
  cout << min << endl;
}
       
           

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    ll a,b;
    cin >> a >> b;
    ll ans = a+b;
    if(ans%2 == 1) cout << "IMPOSSIBLE" << endl;
    else cout << ans/2 << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >>d;

    if((a + d - 1) / d >= (b + c - 1) / b)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3628
N = int(input())
A = list(map(int, input().split()))
cumsum = [0]
for i in range(N):
    cumsum.append(cumsum[-1] + A[i])

mod = 10**9 + 7
ans = 0

for i in range(N - 1):
    tmp = (A[i] % mod) * (cumsum[-1] - cumsum[i + 1])
    ans += (tmp % mod)

print(ans % mod)


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

#include <string>
#include <vector>
int main(){
    int n,k; cin >> n >> k;
    int d,a;
    vector<int> nusuke(n);
    while(k--){
        cin >> d;
        while(d--){
            cin >> a;
            nusuke[a-1]++;
        }
    }
    int ans=0;
    for(int &i:nusuke) if(i==0) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
int n,m;
int x[111111];
int d[111111];
int main(){
  cin>>n>>m;
  rep(i,m)cin>>x[i];
  sort(x,x+m);
  if(n>=m){
    cout<<0<<endl;
    return 0;
  }
  int ans=0;
  rep(i,m-1)ans+=x[i+1]-x[i];
  int c=0;
  rep(i,m-1)d[c++]=x[i+1]-x[i];
  sort(d,d+m-1);
  for(int i=m-1;i>=m-1-(n-1);i--)ans-=d[i];
  cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define debug(x) cout << x << endl;
const ll INF = 1e18;
const ll mod = 1e9 + 7;
const ll N = 1010;
bool isPal(string str){
        size_t len = str.length();

    for(int i = 0; i < len/2; i++){
        if(str[i] != str[len-1-i]){
            return false;
        }
    }
    return true;

}
ll a[200005];
ll arr[200005];
int main()
{

ll n;
cin>>n;

for(int i=0;i<n;i++)
{
ll x;
cin>>x;
a[x]++;
arr[i]=x;

}

ll sum=0;

for(int i=1;i<=n;i++)
{
    if(a[i]!=0)
     sum+=(a[i]*(a[i]-1)/2);
}
   for(int i=0;i<n;i++)
   {
if(a[arr[i]]!=1)
{
ll sum1=sum;
sum1-=(a[arr[i]]*(a[arr[i]]-1)/2);
sum1+=((a[arr[i]]-1)*(a[arr[i]]-2)/2);
cout<<sum1<<endl;
}
else
{
 cout<<sum<<endl;

}



   }
   


}

Measured memory_bytes: 4736
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split(" ");
			int a = Integer.parseInt(chr[0]);
			int b = Integer.parseInt(chr[1]);
			int c = Integer.parseInt(chr[2]);
			System.out.println(b-a==c-b?"YES":"NO");

		}
	}
}


Measured memory_bytes: 25364
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

int main()
{
    int n;
    ll k;
    cin >> n >> k;
    VI v(n);
    rep(i, n)
    {
        cin >> v[i];
        v[i]--;
    }
    int cur = 0;
    int warpnum = 0;
    map<int, bool> visited;
    visited[cur] = true;
    VI log = {0};
    while (k > 0)
    {

        cur = v[cur];
        warpnum++;
        k--;
        if (visited[cur] == true)
        {
            int ind = 0;
            rep(i, log.size())
            {
                if (log[i] == cur)
                {
                    ind = i;
                    break;
                }
            }
            k %= (warpnum - ind);
        }
        visited[cur] = true;
        log.push_back(cur);
    }
    rep(i, k)
    {
        cur = v[cur];
    }
    cout << cur + 1 << endl;
    return 0;
}

Measured memory_bytes: 12088
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

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

    ll A, B, C;
    cin >> A >> B >> C;

    if(A > B) swap(A, B);
    if(A <= C && C <= B) cout << "Yes" << endl;
    else cout << "No" << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// url: http://tenka1-2017-beginner.contest.atcoder.jp/tasks/tenka1_2017_a

import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto rd1 = readln.split, n = rd1[0].to!size_t, k = rd1[1].to!long;

  struct AB { long a, b; }
  auto ab = new AB[](n);

  foreach (i; 0..n) {
    auto rd2 = readln.splitter;
    auto a = rd2.front.to!long; rd2.popFront();
    auto b = rd2.front.to!long;
    ab[i] = AB(a, b);
  }
  ab = ab.filter!(abi => abi.a <= k).array;

  long calc(ptrdiff_t b, AB[] c)
  {
    if (b == -1) return c.map!"a.b".sum;

    if (k.bitTest(b)) {
      auto r1 = calc(b-1, c);
      auto r2 = c.filter!(ci => !ci.a.bitTest(b)).map!"a.b".sum;
      return max(r1, r2);
    } else {
      return calc(b-1, c.filter!(ci => !ci.a.bitTest(b)).array);
    }
  }

  if (k == 0)
    writeln(ab.filter!(abi => abi.a == 0).map!"a.b".sum);
  else
    writeln(calc(k.bsr, ab));
}

pragma(inline) {
  pure bool bitTest(T)(T n, size_t i) { return (n & (T(1) << i)) != 0; }
  pure T bitSet(T)(T n, size_t i) { return n | (T(1) << i); }
  pure T bitReset(T)(T n, size_t i) { return n & ~(T(1) << i); }
  pure T bitComp(T)(T n, size_t i) { return n ^ (T(1) << i); }

  import core.bitop;
  pure int bsf(T)(T n) { return core.bitop.bsf(ulong(n)); }
  pure int bsr(T)(T n) { return core.bitop.bsr(ulong(n)); }
  pure int popcnt(T)(T n) { return core.bitop.popcnt(ulong(n)); }
}


Measured memory_bytes: 34556
#include <stdio.h>
int main(void){
  int n,x,i,c=1,d=0;
  scanf("%d%d",&n,&x);
  int l[n+1];
  for(i=0;i<n;i++){
    scanf("%d",&l[i]);
    d+=l[i];
    if(d<=x) c++;
  }
  printf("%d",c);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
 
using namespace std;
 
int main() {
  string S, T;
  cin >> S >> T;
  
  for (int i = 0; i < S.size(); i++) {
    if (S == T) {
      cout << "Yes" << endl;
      return 0;
    }
    S = S.substr(1) + S[0];
  }
  
  cout << "No" << endl;
}

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

int main()
{
    int n,l;
    std::cin>>n>>l;
    int max = 10000000,res;
    for(int i=0;i<n;i++){
        int cur = i + l;
        if(max>std::abs(0-cur)){
            res = cur - 0;
            max = std::abs(0-cur);
        }
    }
    int sum = l*n + (0 + (n-1)) * n / 2;
    std::cout<<sum-res<<std::endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int x,y;
    scanf("%d%d",&x,&y);
    if(x==2||y==2){
        printf("No");
        return 0;
    }
    if((x==1||x==3||x==5||x==7||x==8||x==10||x==12)&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12)){
        printf("Yes");
        return 0;
    }
    if((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11)){
        printf("Yes");
        return 0;
    }
    printf("No");
    return 0;
}


Measured memory_bytes: 128
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=1e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
int main()
{
    char ch;
    while(cin>>ch)
    {
        if(ch=='z')cout<<"a"<<endl;
        else printf("%c\n",ch+1);
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define LINE_BUF_SIZE 512

int power(int a, int b) {
        int ret = 1;
        while (b-- > 0) {
                ret *= a;
        }
        return ret;
}

int main() {
  char line[LINE_BUF_SIZE];
  int a, b;
  while (fgets(line, sizeof(line), stdin) != NULL) {
        if (sscanf(line, "%d %d", &a, &b) == 2) {
                        if (b == 100) b++;
                        printf("%d", b * power(100, a));
                }
        }
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include<cmath>
using namespace std;
//typedef __int64 LL;
typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef pair<int,int> P;
//typedef pair<LL,LL> PL;

const int MOD=1000000007;
LL INF=1001001001001001;

LL h[310];
LL dp[310][310];
int main(){
	LL n,k;cin>>n>>k;
	for(LL i=1;i<=n;i++)cin>>h[i];
	h[0]=0,h[n+1]=0;
	for(int i=1;i<=n+1;i++)
	{
		for(int j=0;j<=k;j++)
		{
			LL po=INF;
			for(int k=0;k<=j;k++)
			{
				if(i-1-k<0)continue;
				po=min(po,dp[i-1-k][j-k]+abs(h[i-1-k]-h[i]));	
			}
			dp[i][j]=po;
		}
	}
	cout<<dp[n+1][k]/2<<"\n";	
	return 0;
}

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

int main() {
    string s="000";
    char a,b,c;
    cin>>a>>b>>c;

    s[0]=a;s[1]=b;s[2]=c;

    sort(s.begin(),s.end());

    if(s[0]=='5'&&s[1]=='5'&&s[2]=='7'){
        cout<<"YES"<<endl;
    }
    else {
        cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <set>
#include <list>
#include <deque>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <iterator>
#define ll long long
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define powr(x,n,p) for(int axy=0 ; axy<p ; axy++){x=x*n;}
#define YES printf("YES\n")
#define Yes printf("Yes\n")
#define yes printf("yes\n")
#define NO printf("NO\n")
#define No printf("No\n")
#define no printf("no\n")
#define nl printf("\n")
#define fr0(n,q) for(q=0 ; q<n ; q++)
#define fr1(n,q) for(q=1 ; q<=n ; q++)
#define mp make_pair
#define scl(x) scanf("%lld",&x)
#define sci(x) scanf("%d",&x)
#define lst(x) x[x.size()-1]
#define llst(x) x[x.size()-2]
#define md 1000000007
#define check(x,y) (x&(1<<y))
#define set(x,y) x=x|(1<<y)
using namespace std;
int dp[100005];
int arr[100005];
int n;
int solve(int x){
	if(x>=n) return 0;
	if(dp[x]!=-1) return dp[x];
	int ret;
	if(x==n-1) ret=abs(arr[x+1]-arr[x])+solve(x+1);
	else ret=min(abs(arr[x+1]-arr[x])+solve(x+1),abs(arr[x+2]-arr[x])+solve(x+2));
	return dp[x]=ret;
}
int main()
{
	int i;
	cin>>n;
	for(i=0 ; i<100005 ; i++) dp[i]=-1;
	for(i=1 ; i<=n ; i++) cin>>arr[i];
	cout<<solve(1);
	nl;
	return 0;
}


Measured memory_bytes: 7516
MAX = 1000010
finv = [0] * MAX
inv = [0] * MAX
def COMinit():
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX):
        inv[i] = MOD - inv[MOD%i] * (MOD//i) % MOD
        finv[i] = finv[i-1] * inv[i] % MOD

def COM(n, k):
    res = 1
    for i in range(k):
        res = res * (n-i) % MOD
    return res * finv[k] % MOD

MOD = 10**9+7
x, y = map(int, input().split())
s, t = (-x+2*y)/3, (2*x-y)/3

if s < 0 or t < 0:
    ans = 0
elif not (s.is_integer() and t.is_integer()):
    ans = 0
else:
    s, t = int(s), int(t)
    COMinit()
    ans = COM((s+t), s)

print(ans)

Measured memory_bytes: 87900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const ll INF = 1e9+10;
const ll mod = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 

vector<pair<ll, ll> > pairs;

int main()
{
    ll H, N, sum = 0;
    cin >> H >> N;
    vector<int> A(N);
    
    rep(i, N){
        cin >> A[i];
        sum += A[i];
    }
    if (sum >= H){
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;    
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
	int a;
	int b;
	int c;
	int d;
	scanf("%d %d",&a ,&b);
	
	 c= a * b;
	 d= (a + b) * 2;
	printf("%d %d\n",c,d);
	
	// your code goes here
	return 0;
}

Measured memory_bytes: 596
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    a, b = iim()

    if a < b:
        s = "<"
    elif a > b:
        s = ">"
    else:
        s = "=="

    print(f"a {s} b")

if __name__ == "__main__":
    resolve()



Measured memory_bytes: 5608
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		int rect=0;
		int rhombus=0;
		String s="";
		while(!String.IsNullOrEmpty(s=rs())){
			var d=s.Split(',').Select(long.Parse).ToArray();
			if(d[0]*d[0]+d[1]*d[1]==d[2]*d[2])rect++;
			if(d[0]==d[1])rhombus++;
		}
		Console.WriteLine(rect);
		Console.WriteLine(rhombus);
	}

	public Sol(){
	}




	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}

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

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

  int a, b, c, d;
  cin >> a >> b >> c >> d;

  cout << max(0, min(b, d) - max(a, c)) << '\n';
  return 0;

}

Measured memory_bytes: 256
<?php
    fscanf(STDIN,"%d%d%d",$N,$A,$B);
    
    $rb_pair = intval(floor($N/($A+$B)));
    
    $amari = $N%($A+$B);
    
    $ans = $A*$rb_pair;
    
    if($amari<$A){
        $ans+=$amari;
    }else{
        $ans+=$A;
    }
    
    echo $ans;
    
    
?>

Measured memory_bytes: 16176