akhauriyash/Code-Regression huggingface dataset:
import java.util.*

fun main(args: Array<String?>) {
    val scanner = Scanner(System.`in`)

    val n = scanner.nextInt()
    val m = scanner.nextInt()
    val flags = IntArray(m)
    for (i in 0 until m) {
        val k = scanner.nextInt()
        var flag = 0;
        for (j in 0 until k) {
            val s = scanner.nextInt()
            flag = flag or (1 shl s - 1)
        }
        flags[i] = flag
    }
    val ps = IntArray(m)
    for (i in 0 until m) {
        ps[i] = scanner.nextInt()
    }
    val end = 1 shl n
    var count = 0
    for (i in 0 until end) {
        var ok = true
        for (j in 0 until m) {
            if (Integer.bitCount(i and flags[j]) % 2 != ps[j]) {
                ok = false
                break
            }
        }
        if (ok) {
            ++count
        }
    }
    println(count)
}


Measured memory_bytes: 31396
# include <cstdio>
# include <iostream>
# include <cstring>
# include <string>
# include <algorithm>
# include <cmath>
# define R register int
# define ll long long

using namespace std;

const int maxn=100005;
int n,m;
struct cit
{
	int p,y,id,cnt;
}c[maxn];

bool cmp (cit a,cit b)
{
	if(a.p!=b.p) return a.p<b.p;
	return a.y<b.y;
}

bool cmp2 (cit a,cit b)
{
	return a.id<b.id;
}

int main()
{
	scanf("%d%d",&m,&n);
	for (R i=1;i<=n;++i)
		scanf("%d%d",&c[i].p,&c[i].y),c[i].id=i;
	sort(c+1,c+1+n,cmp);
	int cnt=0;
	for (R i=1;i<=n;++i)
	{
		if(c[i].p==c[i-1].p) cnt++;
		else cnt=1;
		c[i].cnt=cnt;
	}
	sort(c+1,c+1+n,cmp2);
	for (R i=1;i<=n;++i)
		printf("%06d%06d\n",c[i].p,c[i].cnt);
	return 0;
}

Measured memory_bytes: 3072
// AC

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

#define INF 100001

int main()
{
  // INPUT
  int n; cin >> n;
  int arr[n][3];
  for(int i=0;  i<n; i++)
  {
    for(int k=0; k<3; k++) cin >> arr[i][k];
  }


  // INIT
  int dp[n][3]={};

  // Base case
  dp[0][0]=arr[0][0];
  dp[0][1]=arr[0][1];
  dp[0][2]=arr[0][2];


  for(int i=1;i<n;i++)
  {
    for(int k=0;k<3;k++)
    {
      // dp[i][k] is the score when 
      int a = dp[i-1][(k+1)%3];
      int b = dp[i-1][(k+2)%3];
      dp[i][k]=arr[i][k] + max(a,b);
    }
  }

  // OUTPUT
  int ans = *max_element(dp[n-1],dp[n-1]+3);
  cout << ans << endl;
}


Measured memory_bytes: 5944
import fractions
A,B,C,D = map(int,input().split())
def pdw(n):
    i=2
    t=[]
    ta = t.append
    while i*i<=n:
        while n%i==0:
            n//=i
            ta(i)
        i+=1
    if n>1:ta(n)
    return t

#print(pdw(D))
#print(pdw(C))
bc = fractions.gcd(C,D)
lbc = C*D//bc
#print(lbc)
t = B - (B//C+B//D-B//lbc)
if A == 1:
    print(t)
else:
    p = A-1
    u = p - (p//C+p//D-p//lbc)
    print(t-u)

Measured memory_bytes: 5180
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()

signed main() {
	std::string s,t;
	std::cin >> s >> t;
	std::map<char,std::vector<int> > map;
	rep(i,s.size()) map[s[i]].emplace_back(i);
	int necessary = -1;
	int cycles = 0;
	for(auto c:t) {
		if(map[c].empty()) {
			print(-1);
			return 0;
		}
		if((map[c][0]+cycles*(int)s.size()) - necessary > 0) {
			necessary = map[c][0] + cycles*s.size();
			continue;
		} else {
			auto it = std::upper_bound(all(map[c]),necessary-cycles*s.size());
			if(it!=map[c].end()) {
				necessary = *it + cycles*s.size();
			} else {
				cycles++;
				necessary = map[c][0] + cycles*s.size();
			}
		}
	}

	print(necessary+1);
	return 0;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    string s;
    cin >> s;
    int slen = s.size();
    if(s[slen-1]=='s'){
        cout << s << "es" << endl;
    }else{
        cout << s << "s" << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int n;
  string s,t1="",t2="";
  cin >> n;
  cin >> s;
  for(int i=0;i<n/2;i++) t1 += s.at(i);
  for(int i=n/2;i<n;i++) t2 += s.at(i);
  if(t1 == t2) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
S = input()

# 理想の配置を定義
I = ''
J = ''
for i in range(len(S)):
    if i % 2 == 0:
        I += '0'
        J += '1'
    else:
        I += '1'
        J += '0'

i_c = 0
j_c = 0
for s, i, j in zip(S, I, J):
    if s != i:
        i_c += 1
    if s != j:
        j_c += 1

print(min(i_c, j_c))


Measured memory_bytes: 3316
# 2020/05/02
# AtCoder Grand Contest 029 - A

# Input
s = input()

sidx = len(s) - 1
bidx = -1
ans = 0
leftflg = True
while(sidx >= 0):
    # Set Init position of B
    if leftflg and s[sidx] == 'W':
        leftflg = False
        bidx = sidx
    # Put B
    elif s[sidx] == 'B':
        ans = ans + max(0, bidx - sidx) 
        bidx = bidx - 1
        
    sidx = sidx - 1

# Output
print(ans)


Measured memory_bytes: 3500
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<ctime>

using namespace std;

template <typename T>

inline T read()
{
	T x=0,f=1;char c=getchar();
	while(!isdigit(c))
	{if(c=='-') f=-f;c=getchar();}
	while(isdigit(c))
	{x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint

const int inf=1e9+1e7;
const double PI=3.1415926;

int main(void)
{

	// freopen("testdata.in","r",stdin);
	// freopen("testdata.out","w",stdout);

	double n;

	cin>>n;

	printf("%.2lf",2*n*PI);

	return 0;

}


Measured memory_bytes: 3788
public class Main {
  private static void solve() {
    int k = ni();
    int x = ni();
    if (k * 500 >= x) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
int n,m;
int u,v,s,t;
bool vis[100100];
vector<int> ga[100100];
queue<int> q;
int dist[100100];
void dfs(int u){
	vis[u]=1;
	for(int i=0;i<ga[u].size();i++){
		if(!vis[ga[u][i]])
			dfs(ga[u][i]);
	}
}
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>u>>v;
		ga[u].push_back(v);
	}
	cin>>s>>t;
	memset(dist,63,sizeof(dist));
	dfs(s);
	if(!vis[t]){
		cout<<-1<<endl;
		return 0;
	}
	q.push(s);
	dist[s]=0;
	while(q.size()){
		int u=q.front();
		q.pop();
		for(int i=0;i<ga[u].size();i++){
			int v=ga[u][i];
			for(int j=0;j<ga[v].size();j++){
				int w=ga[v][j];
				for(int k=0;k<ga[w].size();k++){
					int x=ga[w][k];
					if(dist[x]>=1e9){
						if(x==t){
							cout<<dist[u]+1<<endl;
							return 0;
						}
						dist[x]=dist[u]+1;
						q.push(x);
					}
				}
			}
		}
	}
	cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 9344
#include <bits/stdc++.h>
#define int             long long
#define ld              long double
#define rep0(i,n)       for(int i=0;i<n;i++)
#define rep1(i,n)       for(int i=1;i<=n;i++)
#define rep(i,x,y)      for(int i=x;i<=y;i++)
#define reprev1(i,n)    for(int i=n;i>0;i--)
#define reprev0(i,n)    for(int i=n-1;i>=0;i--)
#define reprev(i,x,y)   for(int i=x;i>=y;i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x,y)         fixed<<setprecision(y)<<x
#define setbits(x)      __builtin_popcount(x)
#define zerobits(x)     __builtin_ctz(x)
#define in(a,n)         vi a(n);rep0(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define endl            '\n'
#define mod             1000000007
#define Max             (int)1e6+6
#define inf             1e18
using namespace std;

int n,m,k,x,y,z,a1,b,c,d,i,j;





void sol()
{   
    cin>>n;
    int a[n+1];
    rep1(i,n)cin>>a[i];
    int dp[n+1]={};
    dp[2]=abs(a[2]-a[1]);
    for(int i=3;i<=n;i++)
    {
        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;
}





int32_t main(){

    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    // w(t)
    sol();
    return 0;
}



Measured memory_bytes: 1792
import java.util.Scanner;

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


		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		if (s.contains("RRR")){
			System.out.println(3);
		} else if (s.contains("RR")){
			System.out.println(2);
		} else if (s.contains("R")){
			System.out.println(1);
		} else {
			System.out.println(0);
		}

	}


}

Measured memory_bytes: 35572
import java.util.Scanner;

public class Main {

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

		    int n = sc.nextInt();
		    if(n == 1) {
		    	System.out.println("Hello World");
		    }
		    else {
		    	int a = sc.nextInt();
		    	int b = sc.nextInt();
		    	System.out.println(a + b);
		    }
		    sc.close(); }
}

Measured memory_bytes: 21716
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;

#define MAX_N 100000
int P[MAX_N];
int Q[MAX_N];

int main() {

  // -----------------------------
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  // input

  int N;
  cin >> N;

  ll p = 0;
  ll q = 0;
  
  for (int i = 0; i < N; i++) {
    cin >> P[i];
    p = p + P[i] * pow(10, N-i-1);
  }

  for (int i = 0; i < N; i++) {
    cin >> Q[i];
    q = q + Q[i] * pow(10, N-i-1);
  }
  
  // -----------------------------

  int array[N];
  for (int i = 0; i < N; i++) {
    array[i] = i+1;
  }

  int ind_p, ind_q;
  int cnt = 0;
  
  do {

    int num = 0;
    for (int i = 0; i < N; i++) {
      num = num + array[i] * pow(10, N-i-1);
    }

    if ( num == p ) ind_p = cnt;
    if ( num == q ) ind_q = cnt;

    cnt++;
    
  } while ( next_permutation(array, array + N) );

  cout << abs(ind_p - ind_q) << endl;
  
  return 0;
  
}


Measured memory_bytes: 512
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7
import math

n, x, t = LI()

# n個のたこ焼きを作るために必要な時間の最小値を整数で
# 一度にX個、作る個数によらずT分

ans = math.ceil(n / x) * t
print(ans)

Measured memory_bytes: 9284
import collections
N = int(input())
A = sorted(collections.Counter(int(T) for T in input().split()).most_common(),reverse=True)
Flag = False
LS = 0
SS = 0
for T in range(0,len(A)):
    if LS==0 and A[T][1]>=4:
        Sq = A[T][0]**2
        Flag = True
        break
    if A[T][1]>=2:
        if LS==0:
            LS = A[T][0]
        else:
            SS = A[T][0]
            Sq = LS*SS
            Flag = True
            break
if Flag:
    print(Sq)
else:
    print(0)

Measured memory_bytes: 28036
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
const ll mo=1000000007;
ll ans=0;
ll dp[0][0];

int main()
{
ll a[5];
rep(i,5){
cin >> a[i];
}
vector<ll> v;



int sum=0;
rep(i,5){
    if(a[i]%10==0){
        sum+=a[i]/10;
    }
    else{
        v.push_back(a[i]%10);
        sum+=a[i]/10;
        sum++;
    }
}
if(v.size()!=0){
    sort(v.begin(), v.end());
    ans+=v[0];
}

ans+=sum*10;
if(v.size()!=0){
    ans=ans-10;
}
cout << ans << endl;
return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define full(x,a) memset(x,a,sizeof(x))

main(){
    string s;
    cin>>s;
    if(s.size()%2!=0)
        cout<<"No"<<endl;
    else{
        int x=s.size()/2;
        string s1="";
        for(int i=0;i<x;i++)
            s1+="hi";
        if(s1==s)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
}

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

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int r, c; cin >> r >> c;
	vvi table(r, vi(c));
	REP(i, r) REP(j, c) cin >> table[i][j];
	vi col_sum(c, 0);
	REP(i, r) {
		int sum = 0;
		REP(j, c) {
			cout << table[i][j] << " ";
			sum += table[i][j];
			col_sum[j] += table[i][j];
		}
		cout << sum << endl;
	}
	int col_sum_sum = 0;
	REP(j, c) {
		cout << col_sum[j] << " ";
		col_sum_sum += col_sum[j];
	}
	cout << col_sum_sum << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}



Measured memory_bytes: 3164
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
a, b  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

print(a * b)


Measured memory_bytes: 9464
//#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<set>
//#include<unordered_map>
using namespace std;
#define int long long
#define ll long long
#define str string
#define db double
#define ac() cout<<"Yes"<<endl
#define wa()  cout<<"No"<<endl
#define ddd cout<<"---debug---"<<endl;
#define ff(a,b) for(signed long long (a)=1;(a)<=(b);(a)++)
#define fff(a,b) for(signed long long (a)=0;(a)<(b);(a)++)
#define re readdd()
#define pr(a) printtt(a)
#define pee puts("");
#define eee putchar(' ');
#define pss(a) push_back(a)
#define ps(a) push(a)
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}//
int ppow(int a,int b,int mod){a%=mod;//
int ans=1%mod;while(b){if(b&1)ans=(long long)ans*a%mod;
a=(long long)a*a%mod;b>>=1;}return ans;}
int readdd(){int x=0,f=1;char c=getchar();//
while(!isdigit(c)&&c!='-')c=getchar();
if(c=='-')f=-1,c=getchar();
while(isdigit(c))x=x*10+c-'0',c=getchar();
return f*x;}
void printtt(int x){if(x<0)putchar('-'),x=-x;
if(x>=10)printtt(x/10);putchar(x%10+'0');}
bool addd(int a,int b){return a>b;};
//
const int maxm=2e5+5;
map<int,int>mark;
signed main(){
    int x=re,k=re;
    int ans=x;
    int t=x/k;
    ans=min(ans,x-t*k);
    ans=min(ans,abs(x-(t+1)*k));
    pr(ans);pee;
    return 0;
}


Measured memory_bytes: 256
[N,K] = [int(s) for s in input().rstrip().split(' ')]
L = [0]*N
for i in range(K):
    d_i = int(input())
    A_i = [int(s) for s in input().rstrip().split(' ')]
    for a_i in A_i:
        L[a_i-1] += 1
print(L.count(0))

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a[3],i;
  for(i=0;i<3;i++)
  {
    cin>>a[i];
  }
  sort(a,a+3);
  int c=a[0]+a[1];
  int d=a[2];
  if(c==d)
  {
    cout<<"Yes";
  }
  else
  {
    cout<<"No";
  }
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  string s; 
  cin >> s;

  int N = s.size();

  bool ans = true;
  for(int i = 0; i < N/2; i++){
    if(s[i] != s[N-i-1]) ans = false;
  }
  for(int i = 0; i < (N-1)/2; i++){
    if(s[i] != s[(N-1)/2-1-i]) ans = false;
  }
  for(int i = (N+3)/2; i < N; i++){
    if(s[i] != s[N-1-i]) ans = false;
  }

  ans? Yes: No;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		
		System.out.println((a * b) + " " + (a + b) * 2);
	}	
}

Measured memory_bytes: 26404
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
const int MaxN = 1e3 + 5;

int main() {
	LL a, b, c;
	scanf("%lld %lld %lld", &a, &b, &c);
	if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0) printf("0\n");
	else if(a >= b && a >= c) printf("%lld\n", b * c);
	else if(b >= a && b >= c) printf("%lld\n", a * c);
	else if(c >= a && c >= b) printf("%lld\n", a * b);
	return 0;
}

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

using namespace std;

#define int long long

int ans;

void oks(int x, int n) {
    if (x == 1) {
        n--;
        for (int s = 1; s * s <= n; ++s) {
            if (n % s == 0) {
                if (s != 1) ans++;
                if (s * s != n) ans++;
            }        
        }
        return;
    }
    while (n % x == 0) n /= x;
    ans += ((n - 1) % x == 0);
}

main() {
    int n;
    cin >> n;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            oks(i, n);
            if (i * i != n) oks(n / i, n);
        }
    }
    cout << ans << '\n';
}

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

int main(){
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> ra(a), ga(b), wa(c);
  for(int i=0; i<a; ++i) cin >> ra[i];
  for(int i=0; i<b; ++i) cin >> ga[i];
  for(int i=0; i<c; ++i) cin >> wa[i];
  sort(ra.begin(),ra.end());
  reverse(ra.begin(),ra.end());
  sort(ga.begin(),ga.end());
  reverse(ga.begin(),ga.end());
  for(int i=0; i<x; ++i) wa.push_back(ra[i]);
  for(int i=0; i<y; ++i) wa.push_back(ga[i]);
  sort(wa.begin(),wa.end());
  reverse(wa.begin(),wa.end());
  long long ans = 0;
  for(int i=0; i<x+y; ++i) ans += wa[i];
  cout << ans << endl;
}

Measured memory_bytes: 2552
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String[] s = a.split("");
    int[] ary = new int[4];
    for(int count = 0;count<4;count++){
      ary[count] = Integer.parseInt(s[count]);
      if(count>0&&ary[count]==ary[count-1]){
        System.out.println("Bad");
        break;
      }else if(count==3){
          System.out.println("Good");
      }
    }
  } 
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let n = read::<f64>();
    let (t,a) = {
        let s = read_vec::<f64>();
        (s[0],s[1])
    };
    let hn = read_vec::<f64>();
    let sub:Vec<f64> = hn.into_iter().map(|x| t - x*0.006 )
    .map(|x| (x - a).abs())
    .collect();
    let enu:Vec<_> = sub.into_iter().enumerate().collect();
    let mut ans = (0, 1e10 as f64);
    for (k,v) in enu {
        if  v < ans.1  {
            ans = (k,v);
        }
    } 
    println!("{}",ans.0 + 1);
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 45;
const int mod = 1000000007;
//const int mod = 998244353;


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

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  ll n, a, b;
  cin >> n >> a >> b;
  cout << max(0ll, (b-a)*(n-2)+1) << endl;
}


Measured memory_bytes: 256
from itertools import product
N, M = map(int, input().split())
Cake = [list(map(int, input().split())) for i in range(N)]


ans = 0
for a, b, c in product([-1, 1], repeat=3):
    score = []
    for x, y, z in Cake:
        score.append(a * x + b * y + c * z)
    score.sort(reverse=True)
    ans = max(ans, sum(score[:M]))

print(ans)


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

string S;

// 0:a 1:b 2:c 3:?
ll d[MAX_N][4];

ll power(ll p, ll q) {
  ll res = 1ll;
  while (q > 0) {
    if ((q & 1) == 1) {
      (res *= p) %= MOD;
    }
    (p *= p) %= MOD;
    q >>= 1;
  }
  return res % MOD;
}

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

  
  cin >> S;
  REP(si, S.size()) {
    switch(S[si]) {
    case 'A':
      d[si][0]++;
      break;
    case 'B':
      d[si][1]++;
      break;
    case 'C':
      d[si][2]++;
      break;
    case '?':
      d[si][3]++;
      break;
    }
  }

  REP(si, S.size()) {
    REP(i, 4) {
      d[si + 1][i] += d[si][i];
    }
  }

  ll ans = 0ll;
  FOR(si, 1, S.size() - 1) {
    // 左のA
    ll la = d[si - 1][0];
    // 左の?
    ll lq = d[si - 1][3];
    // 右のC
    ll rc = d[S.size()][2] - d[si][2];
    // 右の?
    ll rq = d[S.size()][3] - d[si][3];
    // debug(la);
    // debug(lq);
    // debug(rc);
    // debug(rq);
    if (S[si] == 'B' || S[si] == '?') {
      // ABC
      (ans += la * rc * power(3ll, (lq + rq))) %= MOD;
      // AB?
      // powerの-1は,rqで?を一つ使っているから
      (ans += la * rq * power(3ll, (lq + rq - 1))) %= MOD; 
      // ?BC(同上)
      (ans += lq * rc * power(3ll, (lq + rq - 1))) %= MOD;
      // ?B?(同上)
      (ans += lq * rq * power(3ll, (lq + rq - 2))) %= MOD;
    }
    ans %= MOD;
    // debug(si);
    // debug(ans);
  }

  cout << ans << endl;

  

  return 0;
}



Measured memory_bytes: 3664
#include<iostream>
#include<algorithm>
using namespace std;
int n,m,a[10010],b[10010],cost[10010];
int parent[101];
pair<int,int> bridge[10010];
void init(int N){
	for(int i=0;i<N;i++)parent[i]=i;
}
int root(int a){
	if(parent[a]==a)return a;
	return (parent[a]=root(parent[a]));
}
bool is_same_set(int a,int b){
	return (root(a)==root(b));
}
void unite(int a,int b){
	parent[root(a)]=root(b);
}

int main(){
	while(cin>>n>>m&&n>0){
		for(int i=0;i<m;i++){
			cin>>a[i]>>b[i]>>cost[i];
			bridge[i].first=cost[i];
			bridge[i].second=i;
		}
		sort(bridge, bridge+m);
		init(n);
		int ans=0;
		for(int i=0;i<m;i++){
			if(is_same_set(a[bridge[i].second],b[bridge[i].second]))continue;
			unite(a[bridge[i].second],b[bridge[i].second]);
			ans+=bridge[i].first;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1260
#include<bits/stdc++.h>
using namespace std;
vector<set<int> > s(30);
int main()
{
    int n,q;
    string a;
    cin>>n>>a>>q;
    for(int i=0;i<n;i++)
    {
        s[a[i]-'a'].insert(i);//记录每一个字母出现的下标
    }
    while(q--)
    {
        int type;
        cin>>type;
        if(type==1){
            int i;
            char c;
            cin>>i>>c;
            i--;
            s[a[i]-'a'].erase(i);//抹去原来在i位置的元素
            a[i]=c;
            s[a[i]-'a'].insert(i);//在i位置上加上新元素
        }
        else{
            set<int>::iterator it;
            int l,r;
            cin>>l>>r;
            l--;
            r--;
            int ans=0;
            for(int i=0;i<26;i++){
                it=s[i].lower_bound(l);
                if(it!=s[i].end()&& *it<=r) ans++;
            }
            cout<<ans<<endl;
        }
    }
    return 0;
}
/*
        7
        abcdbbd
        6
        2 3 6
        1 5 z
        2 1 1
        1 4 a
        1 7 d
        2 1 7

一开始的初始化：
        a  0
        b  1  4  5
        c  2
        d  3  6
举例第一个查询操作：查第三个元素到第六个元素，即查下标【2,5】之内的；
接着是for循环遍历a~z;
查找大于2的最小的下标，且这个最小的下标还需要小于等于5，符合条件的话就记录下来；
举例第一个更改操作：1 5 z
即将下标为0的元素更改为z;
首先需要抹去未更改前记录元素a下标为0的情况,接着再把新元素z添加到下标为0的位置上；并在记录元素z的下标集合中加入0这个元素
更改后：
        b 1 4 5
        c 2
        d 3 6
        z 0
*/


Measured memory_bytes: 26244
#include<iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include<unordered_map>
using namespace std;
const long long int mod1=1000000007;
const long long int mod2 = -1;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pp pop_back                                       
#define ff first
#define ss second
#define ll long long int
#define ull unsigned long long int
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define ordered1 tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define inf mod1
#define all(x) x.begin(),x.end()
ll gcd(ll a, ll b){
    ll c;
     while(b){
        c = b;
        b = a % b;
        a = c;
     }
     return a;
}
ll power1(ll a, ll b){
     if(b == 0) return 1;
     else if(b % 2) return a * power1(a, b - 1);
     else {
        ll temp = power1(a, b / 2);
        return temp * temp;
     }
}
ll power2(ll a, ll b, ll m){
     a %= m;
     if(b == 0) return 1;
     else if(b % 2) return (a * power2(a, b - 1, m)) % m;
     else{
        ll temp = power2(a, b / 2, m);
        return (temp * temp) % m;
     }
}
ll mod(ll x, ll p){
return (x % p + p) % p;
}
ll lcm(ll x, ll y){
return (x * y)/gcd(x, y);
}
int main(){
    fast;
    ll tt = 1;
    //cin >> tt;
    while(tt--){
      string s;
      cin >> s;
      if(s == "ABC"){
        cout << "ARC";
      }  
      else{
        cout << "ABC" ;
      }
    }
}

Measured memory_bytes: 3612
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n + 1, 0);
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    if(n & 1){
        for(int i = n; i >= 1; i -= 2){
            cout << a[i] << ' ';
        }
        for(int i = 2; i <= n; i += 2){
            cout << a[i] << ' ';
        }
    }else{
        for(int i = n; i >= 1; i -= 2){
            cout << a[i] << ' ';
        }
        for(int i = 1; i <= n; i += 2){
            cout << a[i] << ' ';
        }
    }
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e18;
using Graph = vector<vector<int>>;

//UnionFind
struct UnionFind{
  vector<int> Par;

  //N個の独立した根として初期化
  UnionFind(int N) : Par(N) {
    for(int i = 0; i < N; i++) Par[i] = i;
  }

  //どこの根に属するか得る再帰関数
  int root(int X){
    if( Par.at(X) == X ) return X;
    else return Par.at(X) = root(Par.at(X));
  }

  //XとYが同じ根に属するか判定
  bool same(int X, int Y){
    return root(X) == root(Y);
  }

  //XとYの木を合体
  void unite(int X, int Y){
    X = root(X);
    Y = root(Y);
    if( X == Y ) return;
    Par.at(X) = Y;
  }
};


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

  UnionFind UF(N);
  Graph G(N);
  for( int i = 0; i < M; i++ ){
    int X, Y, Z;
    cin >> X >> Y >> Z;
    X--;
    Y--;
    UF.unite(X, Y);
  }

  set<int> num;
  for( int i = 0; i < N; i++ ){
    int R = UF.root(i);
    if( num.count(R) ) continue;
    num.insert(R);
  }
  cout << num.size() << endl;

 }


Measured memory_bytes: 11116
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int x = sc.nextInt();
        
        int[] m = new int[n];
        
        for(int i = 0; i < n; i++) { 
            m[i] = sc.nextInt();
            x-=m[i];
            
        }
        
        int res = n;
        
        Arrays.sort(m);
        
        res+=x/m[0];
        
        System.out.println(res);
        
    }
}


Measured memory_bytes: 23892
#include <iostream>
#include "bits/stdc++.h"
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define lpe(i, n) for (int i = 1; i <= (int)(n); ++i)
#define lpd(i, n) for (int i = (int)(n); i >= 1; --i)
#define ll long long
using namespace std;
typedef pair<ll, ll> pl;
typedef vector<ll> vl;
typedef map<ll, ll> ml;
int a[1000000];
int main()
{
ll k,x;
    cin>>k>>x;
    ll v[x];
    for (int i=0; i<x; i++)
        cin>>v[i];
    ll sum=v[x-1]-v[0];
    for(int i=1; i<x; i++)
    {
        sum=min(k-v[i]+v[i-1],sum);
    }
    cout<<sum<<endl;
}


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

using namespace std;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
const int maxn=400005;

struct {
	ll sum,lazy;	
} S[maxn];
int n,q;

void update(int id,int ql,int qr,int v,int l,int r) {
	if (ql==l && qr==r) {
		S[id].lazy+=v;
		return;
	}
	int m=l+r>>1;
	if (qr<=m) update(id<<1,ql,qr,v,l,m);
	else if (ql>m) update(id<<1|1,ql,qr,v,m+1,r);
	else update(id<<1,ql,m,v,l,m), update(id<<1|1,m+1,qr,v,m+1,r);
	S[id].sum=S[id<<1].sum+S[id<<1|1].sum+S[id<<1].lazy*(m-l+1)+S[id<<1|1].lazy*(r-m);
}

ll query(int id,int ql,int qr,int l,int r) {
	int m=l+r>>1;
	ll lz=S[id].lazy*(qr-ql+1);
	if (ql==l && qr==r) return lz+S[id].sum;
	if (qr<=m) return lz+query(id<<1,ql,qr,l,m);
	else if (ql>m) return lz+query(id<<1|1,ql,qr,m+1,r);
	else return lz+query(id<<1,ql,m,l,m)+query(id<<1|1,m+1,qr,m+1,r);
}

int main() {
	cin>>n>>q;
	for (int i=0;i<q;i++) {
		bool op; cin>>op;
		int s,t,x;
		if (op) {
			cin>>s>>t;
			cout<<query(1,s,t,1,n)<<'\n';
		}
		else {
			cin>>s>>t>>x;
			update(1,s,t,x,1,n);
		}
	}
}


Measured memory_bytes: 7212
#n = int(input())
import math
n, k = map(int, input().split())
#al = list(map(int, input().split()))
#al=[list(input()) for i in range(h)]

ans = 0

for i in range(1, n+1):
    if i>=k:
        heads_num=0
    else:
        heads_num = math.ceil(math.log2(k/i))
    add = (1/n)*((0.5)**heads_num)
    ans += add
    #ans += (1/n)*((0.5)**heads_num)

print('{:.12f}'.format(ans))


Measured memory_bytes: 9276
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

ll extgcd(ll a, ll b, ll &x, ll &y){
    ll d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x=1;
        y=0;
    }
    return d;
}

int main() {
    cin>>N>>A;
    vec x(N + 1);
    rep(i,N) cin>>x[i];
    x[N] = A;
    sort(x.begin(), x.end());
    ll gcd = x[1] - x[0];
    ll a,b;
    reps(i,2,N + 1) gcd = extgcd(max(gcd,x[i] - x[i-1]), min(gcd,x[i] - x[i-1]),a,b);
    cout<<gcd<<endl;
}


Measured memory_bytes: 1024
def main():
    x, y = input().split()

    x_ord, y_ord = ord(x), ord(y)
    if x_ord < y_ord:
        ans = "<"
    elif x_ord > y_ord:
        ans = '>'
    else:
        ans = '='
    print(ans)


if __name__ == "__main__":
    main()


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, 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; }

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

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  string s; cin>>s;
  ll n=s.size();
  ll ans=0;
  for(ll bit=0; bit<(1<<(n-1)); bit++){
    ll tmp=0;
    ll pos=0;
    rep(i,n){
      if(bit&(1<<i) || i==n-1){
        tmp+=stol(s.substr(pos,i+1-pos));
        pos=i+1;
      }
    }
    ans+=tmp;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
/*|In The Name of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 7e3+5;

int a , b;

int main(){
    cin >> a >> b;
    cout << max(a + a - 1 , max(b + b - 1 , a + b)) << endl;
    return 0;
}



Measured memory_bytes: 256
//https://onlinejudge.u-aizu.ac.jp/problems/ALDS1_6_D
//p187.cpp

#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 1000;
static const int VMAX = 10000;

int n , A[MAX] , s ;
int B[MAX] , T[VMAX + 1];

int solve(){
	int ans = 0;

	bool V[MAX];
	for(int i = 0; i < n; i++){
		B[i] = A[i];
		V[i] = false;
	}
	sort(B,B+n);
	for(int i = 0; i < n ; i++) T[B[i]] = i;
	for (int i = 0; i < n; i++) {
		if (V[i])continue;
		int cur = i;
		int S = 0;
		int m = VMAX;
		int an = 0;
		while (1) {
			V[cur] = true;
			an++;
			int v = A[cur];
			m = min(m, v);
			S += v;
			cur = T[v];
			if (V[cur])break;
		}
		ans += min(S + (an - 2) * m, m + S + (an + 1) * s);
	}
	return ans;
}

int main(){
	cin >> n;
	s = VMAX;
	for( int i = 0 ; i < n ; i++ ){
		cin >> A[i];
		s = min( s , A[i]);
	}
	int ans = solve();
	cout << ans << endl;

	return 0;
}




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

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

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

const ll INF = 1LL << 60;

int dp[110][100100]; //dp[i+1][v]:i番目の品物まで調べたときのvalueがvを超える条件下の重さの最小値(商品は0-index:0,1,2,...,n-1)

int main(){
  int n,W; cin >> n >> W;
  int weight[110], value[110];
  rep(i, n) cin >> weight[i] >> value[i];
  rep(i, 110) rep(j, 100100) dp[i][j] = 1001001000;

  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int v = 0; v <100100 ; v++) {
      //とりあえずi番目の品物を選ばない場合の重さの最小値を入れておく
      dp[i+1][v] = dp[i][v];

      // if(i番目の品物を選んでvalueをv以上にできるようなテーブルがある),
      if (v-value[i] >= 0) chmin(dp[i+1][v],dp[i][v-value[i]] + weight[i]);
      // その場合の重さと比較
      //printf("dp[%d][%d] = %d \n",i,v,dp[i][v] );
    }
  }
  int ans = 0;
  for (int v = 0; v < 100100; v++) {
    if(dp[n][v] <= W) ans = v;
  }
  std::cout << ans << '\n';
}


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

int main()
{
	ll n;
	cin >> n;
	map<char, ll> name_cnt;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		switch (s[0]) {
		case 'M': name_cnt[s[0]]++;
			break;
		case 'A': name_cnt[s[0]]++;
			break;
		case 'R': name_cnt[s[0]]++;
			break;
		case 'C': name_cnt[s[0]]++;
			break;
		case 'H': name_cnt[s[0]]++;
			break;
		default:
			break;
		}
	}

	vector<ll> d = { name_cnt['M'],name_cnt['A'], name_cnt['R'], name_cnt['C'], name_cnt['H'] };
	vector<ll> p = { 0,0,0,0,0,0,1,1,1,2 };
	vector<ll> q = { 1,1,1,2,2,3,2,2,3,3 };
	vector<ll> r = { 2,3,4,3,4,4,3,4,4,4 };

	ll res = 0;
	for (int i = 0; i < 10; i++) res += d[p[i]] * d[q[i]] * d[r[i]];
	cout << res << endl;
}


Measured memory_bytes: 256
def run():
    n = int(input())
    li = [int(x) for x in input().split()]
    assert(len(li) == n)

    q = int(input())
    for _ in range(q):
        b, e, k = [int(x) for x in input().split()]
        print(li[b:e].count(k))


if __name__ == '__main__':
    run()



Measured memory_bytes: 5716
#include<bits/stdc++.h>
#define FOR(i,a,b) for (register int i=(a);i<=(b);i++)
#define For(i,a,b) for (register int i=(a);i>=(b);i--)
#define mem(i,j) memset(i,j,sizeof(i))
#define pb push_back
using namespace std;
typedef long long ll;
const int N=1e5+5;
int n,ans=1,a[N];
int read()
{
	int x=0,f=1;
	char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') {x=(x<<1)+(x<<3)+c-'0';c=getchar();}
	return f*x;
}
int main()
{
	n=read();
	FOR(i,1,n) a[i]=read();
	FOR(i,2,n)
	{
		if (a[i]-1>=a[i-1]) a[i]--;
		if (a[i]<a[i-1]) ans=0;
	}
	if (ans) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 640
class Point
  attr_reader :x, :y
  def initialize(x, y)
    @x = x
    @y = y
  end

  def get_distance(p)
    return ((@x-p.x)**2 + (@y-p.y)**2)**0.5
  end
end

def heron(a, b, c)
  s = (a+b+c) / 2.0
  return (s*(s-a)*(s-b)*(s-c))**0.5
end

$<.each_line do |line|
  x1, y1, x2, y2, x3, y3, xp, yp = line.split.map(&:to_f)

  p1 = Point.new(x1, y1)
  p2 = Point.new(x2, y2)
  p3 = Point.new(x3, y3)
  pc = Point.new(xp, yp)

  triangle_size = heron(
    p1.get_distance(p2),
    p2.get_distance(p3),
    p3.get_distance(p1),
  )

  part_size = 0.0
  part_size += heron(
    p1.get_distance(pc),
    p2.get_distance(p1),
    pc.get_distance(p2),
  )
  part_size += heron(
    p2.get_distance(pc),
    p3.get_distance(p2),
    pc.get_distance(p3),
  )
  part_size += heron(
    p3.get_distance(pc),
    p1.get_distance(p3),
    pc.get_distance(p1),
  )

  puts ((triangle_size - part_size).abs < 0.000001) ? "YES" : "NO"
end

Measured memory_bytes: 8884
#include<bits/stdc++.h>
using namespace std;
#define int           long long
#define	pb            push_back
#define all(a)        (a).begin(),(a).end()
#define sz(x)         (int)x.size()
#define F             first
#define S             second
#define endl          "\n"
#define inf           1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
#define bigboi        1e18
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
#define SHUF(v) shuffle(aint(v), RNG);
// Use mt19937_64 for 64 bit random numbers. 

long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
int ceil(int a, int b){
	return (a+b-1)/b;
}

void solve(){
	int a;
	cin>>a;
	cout<<a+a*a+a*(a*a)<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);     
    int t=1;
    //cin>>t;
    FOR(i, 1, t+1){ 
        //cout<<"Case #"<<i<<": ";
        solve();
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
 
}



Measured memory_bytes: 3608