akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

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

using namespace std;

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

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

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

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


/*FUNCs=================================================*/
bool is_ok(string &s) {
    bool ret = 1;
    for(i32 i = 0, j = s.size()-1; i <= j; ++i, --j) if(s[i] != s[j]) ret = 0;
    return ret;
}

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

    i32 a,b, ans = 0; cin >> a >> b;

    for(i32 x = a; x <= b; ++x) {
        string s = to_string(x);
        bool ok = is_ok(s);
        s.clear();
        ans += (ok? 1 : 0);
    }

    cout << ans << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 3812
/*"Everything in the universe is balanced. Every disappointment
   you face in life will be balanced by something good for you!
                Keep going, never give up."            */

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

#define ll long long
const ll N=1e6+9;
const ll mod=1e9+7;

ll a[N],n,m;
int dp[10005][101][2];
     string s;

 int add(int x, int y){
 	ll p = x+y;
 	return p%mod;
 }

int go(int index, int mode, int flag){
	if(index==n)
		return mode==0;
	int &ans  = dp[index][mode][flag];
	if(ans!=-1)return ans;

	ans = 0 ;
	int maxm = s[index]-'0';

	if(flag) {
		for(int i=0; i<=9; i++){
			ans  = add(ans,go(index+1, (mode+i)%m, flag )) ;
		}
	}
	else{
		for(int i=0; i<maxm; i++){
			ans  = add(ans,go(index+1, (mode+i)%m, 1 )) ;
		}
		ans = add(ans , go(index+1, (mode+maxm)%m, 0 )) ;
	}
	//cout<<index<<mode<<flag<<maxm<<" "<<ans<<"\n";
	return ans;
}

void solve()
{    
    cin>>s>>m;
    memset(dp,-1,sizeof dp);
    n = s.size();
    cout<<(go(0,0,0)-1+mod)%mod;

}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t=1;
    //pre();
    //cin>>t;
    while(t--)
    {
      solve();
    }  
}


// Xoraware

Measured memory_bytes: 12348
a,b,c,d = gets.chomp.split(' ').map(&:to_i)
ab = [a,b].sort
cd = [c,d].sort
ans = []
ans << ab[0]*cd[0]
ans << ab[0]*cd[1]
ans << ab[1]*cd[0]
ans << ab[1]*cd[1]
ans = ans.sort
p ans [-1]

Measured memory_bytes: 14368
#include <bits/stdc++.h>
using namespace std;
#define Maxn 10007
int m,a[Maxn],b[Maxn],c[Maxn];
int n;
int main()
{
    scanf("%d",&n);
    if (n%2==0)
    {
        for (int i=1;i<=n/2;i++)
            c[i]=i,c[n+1-i]=i;
    } else
    {
        for (int i=1;i<=n/2;i++)
            c[i]=i,c[n-i]=i;
        c[n]=n;
    }
    for (int i=1;i<=n;i++)
        for (int j=i+1;j<=n;j++)
            if (c[i]!=c[j])
            {
                ++m;
                a[m]=i;
                b[m]=j;
            }
    printf("%d\n",m);
    for (int i=1;i<=m;i++)
        printf("%d %d\n",a[i],b[i]);
    return 0;
}

Measured memory_bytes: 3848
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;


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

    int N;
    cin >> N;
    int a[N];
    rep(i,N) cin >> a[i];

    int ans=0;
    rep(i,N) ans+=a[i]-1;
    cout << ans << endl;


}


Measured memory_bytes: 256
import math

mod = 1000000007

def add(a, b):
    return (a + b) % mod
def sub(a, b):
    return (a + mod - b) % mod
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod
def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y/2)**2 % mod
    else            : return power(x, y/2)**2 * x % mod

def div(a, b):
    return mul(a, power(b, mod-2))
#N = map(int,input().split())
#AB=[]
N = int(input())
#C = input()
#D, T, S=map(int,input().split())
#C = []
#for i in range(N):
#    C.append(list(map(int,input().split())))
c = 1
d = 1
e = 1
for i in range(N):
    c = mul(c,10)
for i in range(N):
    e = mul(e,9)
for i in range(N):
    d = mul(d,8)

print(sub(sub(c,mul(sub(e,d),2)),d))

Measured memory_bytes: 9220
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int sum=0;
  int t[n];for(int i=0;i<n;i++){
    cin>>t[i];
    sum+=t[i];
  }
  int m;cin>>m;
  int p[m],x[m];
  for(int i=0;i<m;i++)cin>>p[i]>>x[i];
  int ans[m];
  for(int i=0;i<m;i++){
    cout<<sum-t[p[i]-1]+x[i]<<endl;
  }
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <string,string> P;

int n;
string s;
map<P,ll> a,b;

int main(){
  cin >> n >> s;
  rep(U,0,1<<n){
    string t,w;
    rep(i,0,n){
      if(U>>i & 1) t.push_back(s[i]);
      else w.push_back(s[i]);
    }
    a[P(t,w)]++;
  }
  rep(U,0,1<<n){
    string t,w;
    rep(i,0,n){
      if(U>>i & 1) t.push_back(s[n*2-i-1]);
      else w.push_back(s[n*2-i-1]);
    }
    b[P(t,w)]++;
  }
  ll ans = 0;
  for(auto i : a){
    ans += i.second * b[i.first];
  }
  cout << ans << endl;
  return 0;
}


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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int res = 0;
  int tmp = 0;
  rep(i, n) {
    char c = s[i];
    if (c == 'I') {
      tmp++;
    } else if (c == 'D') {
      tmp--;
    }
    res = max(res, tmp);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3620
import java.text.*;
import java.math.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		DecimalFormat df = new DecimalFormat();
		df.applyPattern("0");
		df.setMaximumFractionDigits(8);
		df.setMinimumFractionDigits(8);

		int kaisu = 2;
		long[] num = new long[kaisu];

		for(int i = 0; i < kaisu; i++) {
			num[i] = scan.nextInt();
		}

		long d = num[0] / num[1];
		long r = num[0] % num[1];
		double nf = num[0] / (double)num[1];
		Double objf = new Double(nf);
		String f = df.format(objf);
		System.out.println(d + " " + r + " " + f);
	}
}

Measured memory_bytes: 17408
#include<bits/stdc++.h>
using namespace std;
typedef struct{int a,b;}dat;
main(){
  int n;
  cin>>n;
  vector<dat> v(n);
  for(auto& p:v)cin>>p.a>>p.b;
  sort(v.begin(),v.end(),[](dat p,dat q){return (p.b-q.b)?p.b<q.b:p.a<q.a;});
  for(int i=0,s=0;i<n;++i)if((s+=v[i].a)>v[i].b){cout<<"No";return 0;}
  cout<<"Yes";
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int i=a,inc=(b-a)/abs(b-a); i!=b ; i+=inc)
#define deb(x) cout<<#x<<"->"<<x<<endl;
#define print(arr,a,b) for(int i=a;i!=b;i++){cout<<arr[i]<<" ";}cout<<endl;
using ll=long long int;
int arr_min(int arr[],int a,int b){ int min=arr[0]; for(int i=a;i!=b;i++){if(min>arr[i]) min=arr[i];}return min;}
int arr_max(int arr[],int a,int b){ int max=arr[0]; for(int i=a;i!=b;i++){if(max<arr[i]) max=arr[i];}return max;}

signed main()
{
	ios_base::sync_with_stdio(false);   
    cin.tie(NULL);

	#ifndef ONLINE_JUDGE
      	freopen("input.txt", "r", stdin);
      	freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t-->0){
    	ll n;
    	cin>>n;
    	ll sum=0;
    	for(ll i=1;i<=n;i++)
    	{
            if(i%3==0 || i%5==0 || (i%3==0 && i%5==0))
            {
            	continue;
            }
            else
            	sum=sum+i;

    	}
    	cout<<sum;
    	
    	
    }
    return 0;
}

Measured memory_bytes: 3652
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    vector<pair<ll, ll>> A(N);
    REP(i, N) {
        cin >> A[i].first >> A[i].second;
    }
    SORT(A);
    ll res = 0, cnt = 0;
    REP(i, N) {
        if (cnt == M) {
            break;
        } else if (cnt + A[i].second <= M) {
            res += A[i].first * A[i].second;
            cnt += A[i].second;
        } else if (cnt + A[i].second > M) {
            res += A[i].first * (M - cnt);
            cnt = M;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1792
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe

readInts :: IO [Integer]
readInts = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readStrings :: IO [BS.ByteString]
readStrings = BS.words <$> BS.getLine

main :: IO ()
main = do
  (n:_) <- readInts
  p <- readInts
  q <- readInts
  print $ solve (sort $ permutations [1 .. n]) p q

solve n p q = abs $ fromJust (elemIndex p n) - fromJust (elemIndex q n)

Measured memory_bytes: 21116
#include <bits/stdc++.h>
using namespace std;
//debug
#ifdef grief
#define debug(...) do{\
	fprintf(stderr , "%s - %d : (%s) = " , __PRETTY_FUNCTION__ , __LINE__ , #__VA_ARGS__ );\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){
	cerr<<x<<endl;
}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){
	cerr<<x<<" , ";
	_DO(tail...);
}
#else
#define debug(...)
#endif
//type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef priority_queue<pll,vector<pll>,greater<pll> > heap;
//macro
#define SZ(x) ((ll)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define F first
#define S second
#define mkp make_pair
#define pb push_back
#define IOS do{ios_base::sync_with_stdio(0); cin.tie(0);}while(0)
const ll INF=4e18;
const ll MAX=1e5+5;
const ll MOD=1e9+7;
//}}}
ll dis[210][210];
ll R[10];
int main(){
	IOS;
	ll n,m,r;
	cin>>n>>m>>r;
	for(int i=0;i<r;i++){
		cin>>R[i];
		R[i]--;
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++)
			dis[i][j]=INF;
	}
	for(int i=0;i<m;i++){
		int a,b,c;
		cin>>a>>b>>c;
		a--; b--;
		dis[a][b]=dis[b][a]=c;
	}
	for(int k=0;k<n;k++){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
			}
		}
	}
	sort(R,R+r);
	ll ans=INF;
	do{
		ll now=0;
		for(int i=1;i<r;i++){
			now+=dis[R[i]][R[i-1]];
		}
		ans=min(ans,now);
	}while(next_permutation(R,R+r));
	cout<<ans<< '\n';
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
char rev(char c){
  if(c=='H'){
    return 'D';
  }else{
    return 'H';
  }
}

int main() {
  char a, b;
  std::cin >> a >> b;

  if(a=='H'){
    std::cout << b;
  }else{
    std::cout << rev(b);
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
int a,b;
scanf("%5d",&a);
scanf("%5d",&b);
 if(a>b){
   printf("a > b\n",a,b);
 }
 if(a<b){
   printf("a < b\n",a,b);
 }
 if(a==b){
   printf("a == b\n",a,b);
 }
}


Measured memory_bytes: 2712
N = gets.to_i
W = gets.split.map(&:to_i)

ans = 10000
(N-1).times do |i|
    t = i+1
    s_1 = W[0,t].inject(:+)
    s_2 = W[t..-1].inject(:+)
    s_abs = (s_1 - s_2).abs
    if s_abs == 0 then
        ans = 0
        break
    elsif s_abs < ans then
        ans = s_abs
    end
end

p ans

Measured memory_bytes: 1788
def get_divisor(n):
    if n==1:return [1]
    a = [1]
    b = [n]
    for i in range(2,int(n**0.5)+1):
        if n%i==0:
            a.append(i)
            b.append(n//i)
    if a[-1]==b[-1]:b.pop()
    a.extend(b[::-1])
    return a

N = int(input())
*A, = map(int,input().split())
D = [0]*(N+1)
ans = []
for i in range(N,0,-1):
    if D[i]%2 != A[i-1]:
        ans.append(i)
        for j in get_divisor(i):
            D[j]+=1
print(len(ans))
print(*ans)

Measured memory_bytes: 73832
/**
 *    GOOGLE CODEJAM 2020
 *    Author:  dominix
 **/
#include "bits/stdc++.h"
using namespace std;
#define READ 		freopen("in.txt", "r", stdin)
#define WRITE  		freopen("out.txt", "w", stdout)
#define BOOST		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define shandom_ruffle random_shuffle
#define debug(x) cout << "hi" << x
#define pb push_back
#define nl cout << '\n'
#define br break
#define fi first
#define se second
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vll = vector<ll>;
using vlll = vector<vll>;
using vpii = vector<pii>;
using mpii = map<int, int>;
using mpll = map<ll, ll>;
using stch = stack<char>;
using stvll = stack<vll>;
const ll nax = 1000*1007;
const ll mno = 1007;
const ll mod = 1e9 + 7;
const ll mxN = 1e5 + 5;
const ll inF = 1e18;
const ll rc = 64;
const ll MOD = 998244353; 

#define popcountL   __builtin_popcountll
#define popcount    __builtin_popcount
inline bool checkBit(int N,int pos){return (bool)(N & (1<<pos));} // check bit
inline int setBit(int N,int pos){	return N=N | (1<<pos);}// set bit
inline int unsetBit(int N,int pos){	return N=( N & ( ~( 1<<pos ) ) );}// unset bit
inline int toggleBit(int N,int pos){ return N = ( N ^(1<<pos) ); }// toggle bit

inline ll modMul(ll a, ll b,ll mod){
    ll ans = 0;
    a = a % mod;
    while (b > 0){
        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;
        a = (a%mod * 2%mod) % mod;
        b /= 2;
    }
    return ans % mod;
}
inline ll powerMod(ll a,ll b,ll mod){
	if(b==0)return 1LL%mod;
	ll x=powerMod(a,b/2,mod);
	x = (x%mod*x%mod)%mod;
	if(b%2==1)x = (x%mod*a%mod)%mod;
	return x%mod;
}

inline ll lcm( ll a,ll b ){
	ll g = __gcd(a,b);
	return ((a/g) * b);
}
#define PI 3.14159265358979323846
int n, m, k, t;
// char ch;
string s;
// int x[mxN], y[mxN];
int main() {
    BOOST;
    // READ;
    // WRITE;
 	// cin >> t;
	// for(int tt = 1; tt <= t; ++tt) {
        // cout << "Case #" << tt << ": ";
        double r;
        cin >> r;
        cout << fixed << setprecision(2) << 2 * PI * r;
        // nl;
    // }
  return 0;
}

Measured memory_bytes: 3812
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

import java.util.*;

public class Main{
  public static void main(String[] args){
    FastScanner sc = new FastScanner();

    String s = sc.next();
    String[] as = s.split("/");
    String ans = "2018/" + as[1] + "/" + as[2];

    System.out.println(ans);
  }
}

class FastScanner {
  private static final InputStream in = System.in;
  private static final PrintWriter out = new PrintWriter(System.out);
  private final byte[] buffer = new byte[2048];
  private int p = 0;
  private int buflen = 0;

  public FastScanner(){
  }

  private boolean hasNextByte() {
    if(p < buflen){
      return true;
    }
    p = 0;
    try{
      buflen = in.read(buffer);
    }catch (IOException e) {
      e.printStackTrace();
    }
    if(buflen <= 0){
      return false;
    }
    return true;
  }

  public boolean hasNext() {
    while(hasNextByte() && !isPrint(buffer[p])){
      p++;
    }
    return hasNextByte();
  }

  private boolean isPrint(int ch) {
    if(ch >= '!' && ch <= '~'){
      return true;
    }
    return false;
  }

  private int nextByte() {
    if(!hasNextByte()){
      return -1;
    }
    return buffer[p++];
  }

  public String next() {
    if(!hasNext()){
      throw new NoSuchElementException();
    }
    StringBuilder sb = new StringBuilder();
    int b = -1;
    while(isPrint((b = nextByte()))){
      sb.appendCodePoint(b);
    }
    return sb.toString();
  }

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

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

  public double nextDouble() {
    return Double.parseDouble(next());
  }
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int is_kaibun(string str){
    int m = str.size();
    int res = 1;
    for(int i = 0; i < m / 2; i++){
        if(str[i] != str[m-1-i]){
            res = 0;
            break;
        }
    }
    return res;
}

int main() {
    string s;
    cin >> s;
    int n = s.size();
    string t;
    rep(i,(n-1)/2)t += s[i];
    string u;
    srep(i,(n+3)/2-1,n)u += s[i];
    if(is_kaibun(s) && is_kaibun(t) && is_kaibun(u))yn;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, b, n) for (int i = b; i < n; ++i)

using namespace std;

void solve(int N, int M, vector<int> s, vector<int> c) {
  auto thisIsIt =[&](const int X) {
    string Xstr = to_string(X);
    REP(i, M)
    if (Xstr[s[i] - 1] - '0' != c[i])
	return false;
    return true;
  };

  FOR(X, N == 1 ? 0 : pow(10, (N - 1)), pow(10, N))
    if (thisIsIt(X)) {
      cout << X << endl;
      return;
    }
  cout << -1 << endl;
}

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

  int N, M;
  cin >> N >> M;
  vector<int> s(M);
  vector<int> c(M);
  REP(i, M)
    cin >> s[i] >> c[i];

  solve(N, M, move(s), move(c));

  return 0;
}


Measured memory_bytes: 4124
package main

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

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func main() {
	sc.Split(bufio.ScanWords)
	n, _ := getInt(), getInt()

	a := make(map[int]int, n)

	for i := 0; i < n; i++ {
		k := getInt()
		for j := 0; j < k; j++ {
			t := getInt()
			a[t]++
		}
	}

	ans := 0
	for _, v := range a {
		if v == n {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 998244353; constexpr int MAX = 2000020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;



int calc(int n, int k) {
	if (n < k)return 0;
	if (n%k == 0)return n / k;
	else {
		int ok = 1, ng = 1e9;
		int cnt = n / k;
		while (abs(ok - ng) > 1) {
			int mid = (ok + ng) / 2;
			int tmp = n - mid * (n / k + 1);
			int c = tmp / k;
			if (c == cnt)ok = mid;
			else ng = mid;
		}
		n = n - ok * (n / k + 1);
		return calc(n, k);
	}
}

void solve() {
	int N; cin >> N;
	int g = 0;
	REP(i, N) {
		int A, K; cin >> A >> K;
		g ^= calc(A, K);
	}
	cout << (g == 0 ? "Aoki" : "Takahashi") << endl;

}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
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 nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    vector<vector<int>> a(3, vector<int>(3));

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

    vector<vector<int>> bingo(3, vector<int>(3, 0));

    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        int b;
        cin >> b;
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(a[j][k] == b){
                    bingo[j][k] = 1;
                }
            }
        }
    }
    bool ans = false;
    for(int i = 0; i < 3; i++){
        bool tmp = true;
        for(int j = 0; j < 3; j++){
            if(!bingo[i][j]){
                tmp = false;
                break;
            }
        }
        if(tmp){
            ans = true;
        }
    }

    for(int i = 0; i < 3; i++){
        bool tmp = true;
        for(int j = 0; j < 3; j++){
            if(!bingo[j][i]){
                tmp = false;
                break;
            }
        }
        if(tmp){
            ans = true;
        }
    }
    bool tmp = true;
    for(int i = 0; i < 3; i++){
        if(!bingo[i][i]){
            tmp = false;
            break;
        }
    }
    if(tmp) ans = true;
    tmp = true;
    for(int i = 0; i < 3; i++){
        if(!bingo[i][2 - i]){
            tmp = false;
            break;
        }
    }
    if(tmp) ans = true;

    if(ans){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}   

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

int main() {
    int X, A, B;
    cin >> X >> A >> B;
    if(A >= B) cout << "delicious" << endl;
    else if(B - A <= X) cout << "safe" << endl;
    else cout << "dangerous" << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n;
    while(cin>>n,n){
        int temp;
        int hoge = 0;
        vi v; rep(i,n){
            cin>>temp;
            if(!temp)continue;
            v.push_back(temp);
            cmax(hoge,temp);
        }
        if(hoge<2){cout<<"NA"<<endl;}
        else if(v.size()==1)cout<<"2"<<endl;
        else cout<<v.size()+1<<endl;
    }
}

Measured memory_bytes: 3244
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    
    ll n;
    cin >> n;
    if (n & 1 || n == 0) { cout << 0 << endl; return 0; }
    
    ll ans = 0;
    ll five = 10; // 偶数だから5 * 2
    while (1) {
        ans += n / five;
        five *= 5;
        if (n / five == 0) break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<int, int>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin, s;
    if (s == string(3, 'A') || s == string(3, 'B')) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
L={}
for i in range(N):
    if i>0:
        prev = t[-1]
    t = input()
    if t in L:
        print("No")
        break
    L[t] = 1
    if i>0:
        if t[0] != prev:
            print ("No")
            break
            
else:
    print ("Yes")

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

#define MEM(a, b) memset(a, b, sizeof a);
#define REP(i, k) for(int i = (0); i < int(k); i++ )
#define FOR(i, a, b) for(int i = (a); i <= int(b); i++)
#define TRAV(a, e) for(auto x : e)

#define ALL(cont) cont.begin(), cont.end()
#define RALL(cont) cont.begin(), cont.end()
#define FOREACH(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define INF (int)INT_MAX
#define EPS (int)1e-9
#define PI acos(-1)
#define MOD 1000000007

#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long L;
typedef unsigned long UL;
typedef long long LL;
typedef unsigned long long ULL;

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

void solve(__attribute__((unused)) int tc = 0) {
    int n, x;
    cin >> n >> x;
    vector<int> v;
    v.pb(0);
    REP(i, n) {
        int a;
        cin >> a;
        v.pb(v.back() + a);
    }
    debug(v);
    cout << (upper_bound(v.begin(), v.end(), x) - v.begin())<< endl;
    return;
}

int main() {
#ifdef FILE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin.tie(0);
    ios_base::sync_with_stdio(false);

    /*int TC;
      cin >> TC;
      REP(tc, TC) {
      solve(tc);
      }*/
    solve();
#ifdef TIME
    cout << "Execution time(second) : " << int(clock() * 1000.0 / CLOCKS_PER_SEC) << " ms" << endl;
#endif
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e15;

//累乗(nのk乗）
long long ruijou(int n, int k){
    if(k==0) return 1;
    int x=k/2;
    long long t=ruijou(n,x);
    
    if(k%2==1) return n*t*t;
    else return t*t;
}

ll dp[4096];
int rui[13];
int main(){
    int N,M;cin>>N>>M;
    for(int i=0;i<4096;i++) dp[i]=BIG;
    for(int i=0;i<13;i++) rui[i]=ruijou(2,i);
    int NN=rui[N];
    //cout<<NN-1<<endl;
    dp[0]=0;
    for(int i=0;i<M;i++){
        ll a; cin>>a;
        int b; cin>>b;
        vector<int> x(b);
        for(int j=0;j<b;j++) cin>>x.at(j);
        //cout<<x.size()<<endl;
        for(int k=0;k<NN;k++){
            int Saki=k;
            for(int t=0;t<b;t++) {
                int p=rui[x.at(t)-1];
                if(k%(2*p)<p) Saki+=p;
            }
            dp[Saki]=min(dp[Saki],dp[k]+a);
        }
    }
    if(dp[NN-1]==BIG) cout<<-1<<endl;
    else cout<<dp[NN-1]<<endl;
    

}

Measured memory_bytes: 256
a,b,c = map(int,input().split())
K = int(input())
ans = "No"
for i in range(K+1):
    for j in range(K+1-i):
        for k in range(K+1-i-j):
            if a*2**i < b*2**j < c*2**k:
                ans = "Yes"
                break
print(ans)

Measured memory_bytes: 9176
import Data.Array.Unboxed
import Data.Bool
import qualified Data.ByteString.Char8  as C
import Data.List
import Data.Maybe

main = sol <$> getn <*> gets >>= put

getn = fst . fromJust . C.readInt <$> C.getLine

gets = C.filter ((||) <$> ('o' ==) <*> ('x' ==)) <$> C.getLine

put = putStrLn . (flip bool "-1" . head <*> null)

sol n s = mapMaybe f $ (,) <$> "SW" <*> "SW"
  where
  a = listArray (0,n) $ (=='o') <$> C.last s:C.unpack s :: UArray Int Bool
  f p = (\(s,Just r) -> bool Nothing (Just (C.unpack s)) (p==fst r)) $ C.unfoldrN n step (p,1)
  step (('S','S'),i) = Just ('S', (('S',bool 'W' 'S' (a!i)),i+1)) 
  step (('S','W'),i) = Just ('W', (('W',bool 'S' 'W' (a!i)),i+1)) 
  step (('W','S'),i) = Just ('S', (('S',bool 'S' 'W' (a!i)),i+1)) 
  step (('W','W'),i) = Just ('W', (('W',bool 'W' 'S' (a!i)),i+1)) 


Measured memory_bytes: 2300
function E166(_input) {
    var lines = _input.split("\n");
    var num = lines.shift()*1;
    var heights = lines.shift().split(' ').map(item => item*1);
    var map = {};
    var count = 0;

    for (let i = 1; i<=num;i++) {
        var pk = i - heights[i-1];
        count += map[pk] ? map[pk] : 0;
        var nk = i + heights[i-1];
        map[nk] = map[nk] ? (map[nk]+1) : 1;
    }
    console.log(count);
}
E166(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(){
  string n;
  cin >> n;
  for(int i = 0; i < n.size(); i++){
    if(n[i] == '7'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

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

int main() {
  int N, Sum=0;
  cin >> N;
  vector<int> A(N);
  rep(i, N)cin >> A.at(i);
  for(int i=0; i<N-1; i++){
    for(int j=i+1; j<N; j++){
      Sum=Sum+A.at(i)*A.at(j);
    }
  }
  cout << Sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
    int n;
    string s,t;
    cin >> n >> s >> t;
    if(s == t){
        cout << n << endl;
        return 0;
    }else {
        for(int i = 1;i<n;i++){
            if(s.substr(i) == t.substr(0,n-i)){
                cout << n + i << endl;
                return 0;
            }
        }
    }
    cout << s.length() + t.length() << endl;
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    char b;
    cin >> b;
    if(b=='A')
        cout << 'T';
    else
        if (b=='T')
        cout << 'A';
    else
        if (b=='G')
        cout << 'C';
        else
        if (b=='C')
        cout << 'G';




    return 0;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll x,y,z;
  cin >> x >> y >> z;

  ll ans = 1;
  x -= y+2*z;
  while(x>=y+z){
    x -= y+z;
    ans++;
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
n=int(input())
a=[0]+list(map(int,input().split()))
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    if dp[a[i]-1]:
        dp[a[i]]=1+dp[a[i]-1]
maxi=max(dp)-1
print(n-maxi) if dp[1] else print(-1)


Measured memory_bytes: 24744
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    string s;
    cin>>s;
    map<char,int> mp;
    rep(i,0,s.size()){
        mp[s[i]]++;
    }
    
    string ans="Yes";
    if(mp['N']==0&&mp['S']!=0) ans="No";
    if(mp['N']!=0&&mp['S']==0) ans="No";
    if(mp['W']==0&&mp['E']!=0) ans="No";
    if(mp['W']!=0&&mp['E']==0) ans="No";
    cout<<ans<<endl;
}


Measured memory_bytes: 256
def main():
  import sys
  import math
  import collections
  n=int(input())
  word=["".join(sorted(str(sys.stdin.readline().rstrip()))) for _ in range(n) ]
  dic=collections.Counter(word)
  ans=0
  for k in dic.values():
    if k>1:
      ans+=math.factorial(k)//math.factorial(k-2)//2
  print(ans)
  
if __name__=="__main__":
  main()
  

Measured memory_bytes: 19760
class Dice
  attr_accessor :status
  def initialize(status)
    @status = status
  end

  def compareSpec(dice)
    @d2 = dice.status
    d1 = matchDirect(@d2)
    return (d1 == @d2) ? true : false
  end

  def matchDirect(d2)
    dt = Array.new(6)
    2.times do |i|
      idx = detectIndex(i)
      dt[i] = @status[idx]
      dt[5-i] = @status[5-idx]
    end
    top = @status.index(dt[0]) + 1
    front = @status.index(dt[1]) + 1
    idx = detectSideIndex(top,front)
    dt[2] = @status[idx]
    dt[3] = @status[5-idx]
    return dt
  end

  def detectIndex(i)
    idx = 0
    @status.each_with_index do |dir,j|
      if ((dir == @d2[i]) && (@status[5-j] == @d2[5-i]))
        idx = j
        break
      end
    end
    return idx
  end

  def detectSideIndex(top,front)
    idx = 0
    case top
    when 1,6
      s = [2,3,5,4]
      while (s.include?(front))&&(s[0] != front) do
        s.unshift(s.pop)
      end
      idx = (top == 1) ? s[1] - 1 : s[-1] - 1
    when 2,5
      s = [1,4,6,3]
      while (s.include?(front))&&(s[0] != front) do
        s.unshift(s.pop)
      end
      idx = (top == 2) ? s[1] - 1 : s[-1] - 1
    when 3,4
      s = [1,2,6,5]
      while (s.include?(front))&&(s[0] != front) do
        s.unshift(s.pop)
      end
      idx = (top == 3) ? s[1] - 1 : s[-1] - 1
    end
    return idx
  end
end

d1 = Dice.new(gets.split.map(&:to_i))
d2 = Dice.new(gets.split.map(&:to_i))
result = d1.compareSpec(d2)
puts (result == true) ? "Yes" : "No"

Measured memory_bytes: 8620
import math

a, b, x = map(int, input().split())

s = x/a

u = 2*s/a-b

if u >= 0:
	d = math.degrees(math.atan((b-u)/a))
else:
	u = s*2/b
	d = math.degrees(math.atan(b/u))

print(d)

Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<stdio.h>

void f( int n, std::vector<int> m )
{
 	if( n <= 0 ){
		for( int i = 0; i < m.size(); i++ ){
			printf( "%d%c", m[i], ( i != m.size() - 1 ? ' ' : '\n' ) );
		}
		
		return;
	}
	
	for( int i = 0; i < n; i++ ){
		if( m.empty() || ( !m.empty() && n - i <= m[m.size()-1] ) ){
			m.push_back( n - i );
			f( i, m );
			m.pop_back();
		}
	}
	
	return;
}

int main()
{
	int n;
	std::vector<int> m;
	
	while( std::cin >> n, n ){
		f( n, m );
	}

 	return 0;
}

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

#define endl "\n"

typedef long long ll;
typedef pair <ll, ll> pii;
typedef long double ld;

const ll DIM = 100007;
const ll INF = 1000000007;
ll n,m,k;
ll a,b,c;
ll v[DIM][5],ans[DIM][5];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin>>n;
    for(ll i=1;i<=n;i++)
      {

cin>>v[i][1]>>v[i][2]>>v[i][3];
        ans[i][1]=max(ans[i-1][2],ans[i-1][3])+v[i][1];
        ans[i][2]=max(ans[i-1][1],ans[i-1][3])+v[i][2];
        ans[i][3]=max(ans[i-1][2],ans[i-1][1])+v[i][3];

      }

      cout<<max(ans[n][1],max(ans[n][2],ans[n][3]));
    return 0;
}


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

using namespace std;

const int maxn = 5e5+10;

int n, bit[30][maxn];

void upd(int v, int pos, int val){
    while(pos <= n){
        bit[v][pos] += val;
        pos += (pos &- pos);
    }
}

int sum(int v, int pos){
    int s = 0;
    while(pos > 0){
        s += bit[v][pos];
        pos -= (pos &- pos);
    }
    return s;
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    cin >> n;

    string s;

    cin >> s;

    for(int i=0; i<n; i++){
        upd(s[i]-'a', i+1, 1);
    }

    int q;

    cin >> q;

    while(q--){
        int op;

        cin >> op;

        if(op == 1){
            int id;

            char c;

            cin >> id >> c;

            upd(s[id-1]-'a', id, -1);

            s[id-1] = c;

            upd(s[id-1]-'a', id, 1);
        }
        else{
            int l, r, ans = 0;

            cin >> l >> r;

            for(int j=0; j<26; j++){
                if(sum(j, r) - sum(j, l-1) >= 1) ans++;
            }

            cout << ans << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 52124
// D - 3N Numbers
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VL = vector<ll>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define pq priority_queue

void v_print(VL v,int N){rp(i,0,N) printf("%d,",v[i]);puts("");}//

#define NMAX 100000
int N;
VL A(3*NMAX);

void f(VL &V, ll sign){
	pq<int> que;
	rp(i, 0, N){
		que.push(sign*A[i]);
		V[0] += A[i];
	}
	int j=0;
	rp(v, 0, N){
		int a = N + v;
		que.push(sign*A[a]);
		V[v+1] += V[v] + A[a] - sign*que.top();
		que.pop();
	}
}

int main(){
	cin>>N;
	int N3 = N*3;
	rp(i, 0, N3) cin>>A[i];

	VL F(N+1), B(N+1);
	f(F, -1L);
	reverse(A.begin(), A.begin()+N3);
	f(B, 1L);

	ll maxfb = LLONG_MIN;
	rp(f, 0, N+1){
		int b = N - f;
		maxfb = max(maxfb, F[f]-B[b]);
	}
	cout<< maxfb <<endl;
}

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

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let h: usize = it.next().unwrap().parse().unwrap();
    let n: usize = it.next().unwrap().parse().unwrap();
    let w = h + 10000;
    let mut dp = vec![1000000000000; w + 1];
    dp[0] = 0;
    for _ in 0..n {
        let a: usize = it.next().unwrap().parse().unwrap();
        let b: usize = it.next().unwrap().parse().unwrap();
        for i in a..(w + 1) {
            dp[i] = std::cmp::min(dp[i], dp[i - a] + b);
        }
    }
    let ans = *dp[h..].iter().min().unwrap();
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ

int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	int ret=0;
	while(c>0){
		ret++;
		if(a<b){
			c-=b;
			a--;
		}else{
			c-=a;
			b--;
		}
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int dig[31][200002];

int main()
{
    int n;
    cin >> n;
    int a[200002], b[200002];
    ll ca[31], cb[31];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        int p = 1;
        for(int j = 0; j < 31; j++){
            if(a[i] & p) ca[j]++;
            p *= 2;
        }
    }
    for(int i = 0; i < n; i++){
        cin >> b[i];
        int p = 1;
        for(int j = 0; j < 31; j++){
            if(b[i] & p) cb[j]++;
            dig[j][i] = b[i] % p;
            p *= 2;
        }
    }
    int p = 1;
    int ans = 0;
    for(int j = 0; j < 31; j++){
        sort(dig[j], dig[j] + n);
        ll carry = ((ca[j] + cb[j]) * n - ca[j] * cb[j] * 2) % 2;
        for(int i = 0; i < n; i++){
            carry = (carry + n - (lower_bound(dig[j], dig[j] + n, p - a[i] % p) - dig[j])) % 2;
        }
        ans += carry * p;
        p *= 2;
    }
    cout << ans << endl;
}

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

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

using ll = long long int;
const ll MOD = 1e9 + 7;

int main() {
  int N, K, C;
  std::string S;
  std::cin >> N >> K >> C >> S;

  std::vector<int> L(K), R(K);
  int day = 1;
  rep(i, K) {
    while(S[day - 1] == 'x') {
      ++day;
    }
    L[i] = day;
    day += C + 1;
  }

  day = N;
  rep(i, K) {
    while(S[day - 1] == 'x') {
      --day;
    }
    R[K - i - 1] = day;
    day -= C + 1;
  }

  rep(i, K) {
    if(L[i] == R[i]) {
      std::cout << L[i] << '\n';
    }
  }
}


Measured memory_bytes: 3332