akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <queue>
#include <utility>
#include <math.h>
using namespace std;

int main(void){
  int i;
  cin >> i;
  string s;
  cin >> s;
  if(i>=3200){
    cout << s <<endl;
  }else{
    s = "red";
    cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i,s;
cin>>n;
long long ar[n+1];
for(i=1;i<=n;i++){
        cin>>s;
     ar[s-1]=i;

}
for(i=0;i<n;i++){
    cout<<ar[i]<<' ';
}
}


Measured memory_bytes: 1536
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {
    string s; cin >> s;
    for (int i = 0; i < s.size(); i++) cout << 'x';
    cout << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
public static void main(String[]args){
Scanner scan=new Scanner(System.in);
int a=scan.nextInt();
int b[][][]=new int[4][3][10];
int c[][]=new int[a][4];
for(int i=0;i!=a;i++) {
	c[i][0]=scan.nextInt();
	c[i][1]=scan.nextInt();
	c[i][2]=scan.nextInt();
	c[i][3]=scan.nextInt();
}
for(int i=0;i!=a;i++) {
	b[c[i][0]-1][c[i][1]-1][c[i][2]-1]=b[c[i][0]-1][c[i][1]-1][c[i][2]-1]+c[i][3];
}
for(int i=0;i!=4;i++) {
	for(int j=0;j!=3;j++) {
		for(int k=0;k!=10;k++) {
			System.out.print(" "+b[i][j][k]);
		}	
		System.out.println();
	}
	if(i!=3) {
	System.out.println("####################");
}
	}

}
}


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

using namespace std;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using pii = pair<int, int>;

/* [💭] [💡] [🎈] */

int window[1000001];

int calc(const string &s, int l, int r) {
    bool flag = !(window[l]);
    int x = abs(s[r - 1] - s[l]);
    if (x == 2) {
        return flag * 2;
    } else {
        return x;
    }
}

string naive(const string &s) {
    int n = s.length();
    vector<vector<int>> v = vector<vector<int>>(n, vector<int>(n));
    for (int i = 0; i < n; i++) v[0][i] = s[i];
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < n - i; j++) {
            v[i][j] = abs(v[i - 1][j] - v[i - 1][j + 1]);
        }
    }

    string x;
    x += ('0' + (char) v[n - 1][0]);
    return x;
}

string reduce(const string &s) {
    string x;
    int n = s.length();
    if (n <= 100) return naive(s);
    int m = 1;
    while (m + 1 <= n) m <<= 1;
    m /= 2;
    m++;
    window[0] = 0;
    for (int i = 0; i < m; i++) window[0] += (s[i] == '1');
    for (int i = m; i < n; i++) {
        window[i - m + 1] = window[i - m] - (s[i - m] == '1') + (s[i] == '1');
    }
    for (int i = 0; i <= n - m; i++) {
        int j = i + m;
        x += '0' + (calc(s, i, j));
    }
    return x;
}

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

    int n;
    string s;
    cin >> n >> s;

    for (char &c : s) c--;
    while (s.length() > 1) s = reduce(s);
    cout << s << endl;

    return 0;
}

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

int main(void){
    int H, W, count = 0;
    cin >> H >> W;
    
    string S[51];
    for(int i = 0; i < H; i++) cin >> S[i];

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(S[i][j] == '.'){
                for(int k = i-1; k < i+2; k++){
                    for(int l = j-1; l < j+2; l++){
                        if((k < 0) || (l < 0) || (k > H) || (l > W)) continue;
                        if(S[k][l] == '#') count++;
                    }
                }
                S[i][j] = (char)(count + '0');
                count = 0;
            }
        }
    }

    for(int i = 0; i < H; i++) cout << S[i] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
typedef long long ll;

using namespace std;

int main() {
    int a;
    cin >> a;
    
    cout << 3 * a * a << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
int main(){
    string s,t;cin>>s>>t;
    int cnt[26];fill(cnt,cnt+26,0);
    vector<ll> v[26];
    rep(i,0,s.size()){
        cnt[s[i]-'a']++;
        v[s[i]-'a'].push_back(i);
    }
    rep(i,0,t.size()){
        if(cnt[t[i]-'a']==0){
            cout<<-1<<endl;
            return 0;
        }
    }
    ll moji=0;
    ll now=-1;
    ll kai=0;
    for(;;){
        int y=t[moji]-'a';
        int r=upper_bound(v[y].begin(),v[y].end(),now)-v[y].begin();
        if(r==v[y].size()){
            kai++;
            now=v[y][0];
            
        }
        else{
            now=v[y][r];
        }
        moji++;
        if(moji==t.size())break;
    }
    cout<<kai*s.size()+now+1<<endl;
}


Measured memory_bytes: 1724
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	if n == 1 {
		fmt.Fprintln(writer, 0)
		return
	}
	var ans, a, b mint
	ans = 1
	a = 1
	b = 1
	for i := 0; i < n; i++ {
		ans.MulAs(10)
		a.MulAs(9)
		b.MulAs(8)
	}
	fmt.Fprintln(writer, ans.Sub(a).Sub(a).Add(b))
}

type mint int64

func (mt mint) Mod() mint {
	m := mint(1e9 + 7)
	mt %= m
	if mt < 0 {
		return mt + m
	}
	return mt
}
func (mt mint) Inv() mint {
	return mt.Pow(mint(0).Sub(2))
}
func (mt mint) Pow(n mint) mint {
	p := mint(1)
	for n > 0 {
		if n&1 == 1 {
			p.MulAs(mt)
		}
		mt.MulAs(mt)
		n >>= 1
	}
	return p
}
func (mt mint) Add(x mint) mint {
	return (mt + x).Mod()
}
func (mt mint) Sub(x mint) mint {
	return (mt - x).Mod()
}
func (mt mint) Mul(x mint) mint {
	return (mt * x).Mod()
}
func (mt mint) Div(x mint) mint {
	return mt.Mul(x.Inv())
}
func (mt *mint) AddAs(x mint) *mint {
	*mt = mt.Add(x)
	return mt
}
func (mt *mint) SubAs(x mint) *mint {
	*mt = mt.Sub(x)
	return mt
}
func (mt *mint) MulAs(x mint) *mint {
	*mt = mt.Mul(x)
	return mt
}
func (mt *mint) DivAs(x mint) *mint {
	*mt = mt.Div(x)
	return mt
}


Measured memory_bytes: 1836
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
h = {'s': 'r', 'p': 's', 'r': 'p'}
t = {'r': R, 's': S, 'p': P}

a = [0] * N
ans = 0
for i in range(K):
    a[i] = h[T[i]]
    ans += t[a[i]]

for i in range(K, N):
    if h[T[i]] != a[i - K]:
        a[i] = h[T[i]]
        ans += t[a[i]]
    else:
        if i + K < N:
            a[i] = T[i+K]
        else:
            a[i] = T[i]
print(ans)


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

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

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

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
}

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

int main(){
  int N;
  int A;
  cin >> N >> A;
  
  int residue = N % 500;
  
  if(residue <= A){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
   
}

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

int main(){

    int N;
    cin >> N;
    int A[N];

    for (size_t i = 0; i < N; i++)
    {
        cin >> A[i];
        if(A[i]%2==0){
            if(A[i]%3!=0 && A[i]%5!=0){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    
    cout << "APPROVED" <<endl;

    return 0;
}

Measured memory_bytes: 256
n = input(); n = int(n)
A = list(map(int,input().split()))

if A[0] != 0 :
  print(0)
  exit()

MOD = 998244353
L = [0]*(n+1)

for a in A : L[a] += 1
#print(L)

if L[0] != 1 :
  print(0)
  exit()

zerofirst = L.index(0)
for i in range(n-1,-1,-1) :
  if L[i] != 0 :
    nonzerolast = i
    break

if zerofirst < nonzerolast :
  print(0)
  exit()

ans = 1
for i in range(1,nonzerolast+1) :
  ans *= (L[i-1]) ** (L[i])
  ans %= MOD

print(ans)

#print(zerofirst, nonzerolast)



Measured memory_bytes: 14396
#include <stdio.h>
void swap(int *,int *);
void bubbleSort(int [],int);

int count=0;

int main(){
  int i,n,A[100];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    }
    bubbleSort(A,n);
    for(i=0;i<n;i++){
      if(i)printf(" ");
      printf("%d",A[i]);
    }
    printf("\n");
    printf("%d\n",count);
    return 0;
  }

void swap(int *a,int *b){
  int v;
  v=*a;
  *a=*b;
  *b=v;
}


void bubbleSort(int A[],int N){
  int i,j,flag;
  int h;
  flag=1;
  i=0;

for(h=0;h<=N-1;h++){
    for(j=N-1;j>=i+1;j--){
      if(A[j]<A[j-1]){
        swap(&A[j],&A[j-1]);
        count++;
        flag=1;
      }
    }
  i++;
  }
 }

Measured memory_bytes: 604
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	int n;
	cin >> n;
	map<int, int> o, e;
	REP(i, n){
		cin >> tmp;
		if(i %2 == 0) e[tmp] ++;
		else o[tmp]++;
	}
	vector< pair <int, int >> od , ev;
	for(auto it = e.begin(); it != e.end(); it++){
		ev.push_back(make_pair(it->second, it->first));
	}
	for(auto it = o.begin(); it != o.end(); it++){
		od.push_back(make_pair(it->second, it->first));
	}
	ev.push_back(make_pair(0, -1));
	od.push_back(make_pair(0, -1));
	sort(ev.begin(), ev.end(), greater<pair<int, int>>());
	sort(od.begin(), od.end(), greater<pair<int, int>>());
	if(ev[0].second != od[0].second){
		cout << n - ev[0].first - od[0].first;
	}
	else{
		cout << min(n - ev[1].first - od[0].first, n - ev[0].first - od[1].first);
	}
	//cout << ans << endl;
}

Measured memory_bytes: 6136
import itertools

N, M = map(int, input().split())
ab = []
for _ in range(M):
    a, b = map(int, input().split())
    ab.append({a-1, b-1})

ans = 0
for v in itertools.permutations(range(1, N)):
    ok = True
    a = 0
    for b in v:
        if {a, b} not in ab:
            ok = False
            break
        a = b
    if ok:
        ans += 1

print(ans)


Measured memory_bytes: 9132
#include <iostream>

using namespace std;

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

    int ans = 0;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                int sum = 500 * i + 100 * j + 50 * k;
                if (sum == x) ans++;
            }
        }
    }

    cout << ans << endl;
}


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

int main(void) {
    int n;
    std::cin >> n;
    std::vector<int> vec = std::vector<int>(n + 1, 0);
    for(int i = 0; i < n - 1; ++i) {
        int input;
        std::cin >> input;
        vec[input]++;
    }
    for(int i = 1; i <= n; ++i) {
        std::cout << vec[i] << std::endl;
    }
}

Measured memory_bytes: 4048
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 2005
using namespace std;
int n,m;
int r[M][M], d[M][M], l[M][M], u[M][M];
char in[M][M];
int main()
{
    while (~scanf("%d %d", &n, &m)) {
        MSET(r, 0);
        MSET(d, 0);
        MSET(l, 0);
        MSET(u, 0);
        REP(i,1,n) scanf("%s", in[i]+1);

        auto isb = [&](int x,int y) {
            if (x>n || x<1) return true;
            if (y>m || y<1) return true;
            return in[x][y] == '#';
        };

        for (int i=n; i>=1; i--) for (int j=m; j>=1; j--) if (in[i][j]=='.') {
            if (isb(i+1, j)) d[i][j] = i;
            else d[i][j] = d[i+1][j];

            if (isb(i,j+1)) r[i][j] = j;
            else r[i][j] = r[i][j+1];
        }

        REP(i,1,n) REP(j,1,m) if(in[i][j] == '.') {
            if (isb(i-1, j)) u[i][j] = i;
            else u[i][j] = u[i-1][j];

            if (isb(i,j-1)) l[i][j] = j;
            else l[i][j] = l[i][j-1];
        }

        int ans = 0;
        REP(i,1,n)REP(j,1,m) if(in[i][j]=='.')
            ans = max(ans, d[i][j]-u[i][j] + r[i][j]-l[i][j] + 1);
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 66944
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,k;
  long long p[2000001],ans=0,c[2000001]={};
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>p[i];
    p[i]=(p[i]+1)*5000000;
    if(i>=k-1)
    c[i]=p[i]+c[i-1]-p[i-k];
    else
      c[i]+=p[i]+c[i-1];
    if(ans<c[i])
      ans=c[i];
  }
  cout<<ans/10000000<<"."<<ans%10000000<<endl;
  return(0);
}

Measured memory_bytes: 21248
def main():
    N, M = map(int, input().split())
    H = [int(i) for i in input().split()]

    X = [True] * N
    s = set()
    for i in range(M):
        a, b = map(int, input().split())
        s.add(a)
        s.add(b)
        if  H[a - 1] == H[b - 1]:
            X[a - 1] = False
            X[b - 1] = False
        elif H[a - 1] > H[b - 1]:
            X[b - 1] = False
        else:
            X[a - 1] = False


    print(X.count(True))



if __name__ == '__main__':
    main()

Measured memory_bytes: 89868
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		ArrayList<Integer> A = new ArrayList<Integer>();
		for (int i = 0; i < N; i++)
			A.add(sc.nextInt());
		ArrayList<Integer> output = new ArrayList<Integer>();
		for (int i = 0; i < N; i++)
			output.add(0);

		
		for (int i = 0; i < N; i++) {
			int AIndex = A.get(i) - 1;
			output.set(AIndex, i+1);
		}
		for(int i = 0;i<N;i++) {
			System.out.print(output.get(i)+" ");
		}
		
	}

}


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

int main(){
	string ref;
	int in;
	priority_queue<int> prq;
	while(1){
		cin >> ref;
		if(ref=="insert"){
			cin >> in;
			prq.push(in);
		}else if(ref=="extract"){
			in=prq.top();
			prq.pop();
			cout << in << endl;
		}else if(ref=="end"){
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 6984
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=nxt(),m=nxt();
    ll test=1;
    ll mod=1e9+7;
    if(abs(n-m)>1){
        cout<<"0\n";
        return 0;
    }
    if(m>n)
        swap(n,m);
    if(n==m)
    {
        for(int i=1;i<=n;i++)
            (((test*=i)%=mod)*=i)%=mod;
        (test*=2)%=mod;
    }
    else
    {
        for(int i=1;i<=n;i++)
            (test*=i)%=mod;
        for(int i=1;i<=m;i++)
            (test*=i)%=mod;

    }
    cout<<test<<endl;
    
    
    return 0;   
}




 
 


Measured memory_bytes: 256
x, y, aa, bb, cc, = map(int, input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort(reverse=True)
b.sort(reverse=True)

ary = a[:x] + b[:y] + c
ary.sort(reverse=True)
print (sum(ary[:x+y]))

Measured memory_bytes: 22720
#include<stdio.h>
int main(void){
    int a;
    while((a=getchar())!=EOF){
        if(a>='a' && a<='z'){
            putchar(a-'a'+'A');
        }else{
            putchar(a);
        }
    }
    //printf ("\n");
    return 0;
}

Measured memory_bytes: 524
v, e, r = map(int, input().split())
edges = []
for _ in range(e):
    s, t, d = map(int, input().split())
    edges.append((s, t, d))

def shortest_path(v, s, edges, inf):
    d = [inf] * v
    d[s] = 0
    cnt = 0
    while True:
        cnt += 1
        update = False
        for frm, to, cost in edges:
            if d[frm] != inf and d[to] > d[frm] + cost:
                d[to] = d[frm] + cost
                update = True
        if cnt == v and update:
            return False
        elif not update:
            break
    return d

inf = 10 ** 9
d = shortest_path(v, r, edges, inf)
if d == False:
    print('NEGATIVE CYCLE')
else:
    for i in range(v):
        if d[i] == inf:
            print('INF')
        else:
            print(d[i])


Measured memory_bytes: 6120
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
 */
//入力終了→Ctrl+D
import java.util.*;
import java.awt.*;
import java.awt.Graphics.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int[] a = new int[6];
        for (int i = 0; i < 6; i++) {
            a[i] = sc.nextInt();
        }
        String s="";
        for (int i = 0; i < 4; i++) {
            s+="N";
        }
        for (int i = 0; i < 4; i++) {
            s+="E";
        }
        int q = sc.nextInt();
        for (int i = 0; i < q; i++) {
            int ue=sc.nextInt(),temae=sc.nextInt();
            dice1.init(a);
            int c=0;
            for (int k=0;k<s.length();k++) {
                for (int j = 0; j < 4; j++) {
                    if (dice1.men[0] == ue && dice1.men[1] == temae && c == 0) {
                        out.println(dice1.men[2]);
                        c=1;
                        break;
                    }
                    dice1.roll('L');
                }
                dice1.roll(s.charAt(k));
            }
        }
    }

    static class dice1 {
        static int[] men = new int[6];
        static void init(int[] a) {
            men=a.clone();
        }
        static void roll(char c) {
            int t = men[0];
            switch (c) {
                case 'S':
                    men[0] = men[4];
                    men[4] = men[5];
                    men[5] = men[1];
                    men[1] = t;
                    break;
                case 'E':
                    men[0] = men[3];
                    men[3] = men[5];
                    men[5] = men[2];
                    men[2] = t;
                    break;
                case 'W':
                    men[0] = men[2];
                    men[2] = men[5];
                    men[5] = men[3];
                    men[3] = t;
                    break;
                case 'N':
                    men[0] = men[1];
                    men[1] = men[5];
                    men[5] = men[4];
                    men[4] = t;
                    break;
                case 'L':
                    t=men[1];
                    men[1]=men[3];
                    men[3]=men[4];
                    men[4]=men[2];
                    men[2]=t;
                    break;
                default:
                    break;
            }
        }
    }
}


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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    for (int i = 1; i < 2000; ++i) {
        int ai = i * 0.08;
        int bi = i * 0.1;
        if (ai == a && bi == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
def test(n,hlist)
  max = hlist[0]
  (0..n-2).all?{|i|
    a = hlist[i]
    b = hlist[i+1]
    ret = a<=b || (a-1<=b && max<=a-1)
    max = [a-1,max].max
    ret
  }
end
puts test(gets.to_i,gets.split(' ').map(&:to_i)) ? 'Yes' : 'No'


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

int main(void) {

  int N, m;
  cin >> N >> m;
  int sum = 0;

  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    sum += a;
  }

  cout << max(N - sum, -1) << endl;
  return 0;
}


Measured memory_bytes: 3644
def main():
    s = 0
    n = int(input())
    gd1s = []
    combs = {}
    '''
    for i in range(1, n+1):
        for j in range(1, n+1):
            try:
                gd1 = combs[(i, j)]
                combs[(j, i)] = gd1
                gd1s.append(gd1)
            except:
                gd1 = gcd(i, j)
                gd1s.append(gd1)
                combs[(i, j)] = gd1

    for k in range(1, n+1):
        for g in gd1s:
            s += combs[(g,k)]
    print(s)
    '''
    for i in range(1, n+1):
        for j in range(1, n+1):
            gcd_tmp = gcd(i, j)
            for k in range(1, n+1):
                s += gcd(gcd_tmp, k)
    print(s)

                

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

if __name__ == "__main__":
    main()

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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define RREP(i,a) for(int i = a;i >= 0;i--)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = 0x3f3f3f3f;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    VI as, bs, cs, ds;
    rep (i, N) {
        int a, b;
        cin >> a >> b;
        as.pb(a);
        bs.pb(b);
    }
    rep (i, M) {
        int c, d;
        cin >> c >> d;
        cs.pb(c);
        ds.pb(d);
    }
    VI ans;
    rep (i, N) {
        int min_dist = INF;
        int point = -1;
        rep (j, M) {
            int x = max(as[i], cs[j]) - min(as[i], cs[j]);
            int y = max(bs[i], ds[j]) - min(bs[i], ds[j]);
            int dist = x + y;
            if (min_dist > dist) {
                min_dist = dist;
                point = j;
            }
        }
        ans.pb(point + 1);
    }
    for (auto &a : ans) {
        cout << a << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int n,c[500],s[500],f[500],a[500],i,j,ti;
	scanf("%d",&n);
	for(i=1;i<n;i++)	{
		scanf("%d %d %d",&c[i],&s[i],&f[i]);
	}
	for(i=1;i<=n;i++)	{
		a[i]=0;
		for(j=i;j<n;j++)	{
			if(a[i]<s[j])	a[i]=s[j];
			else {
				if(a[i]%f[j]!=0){
					a[i]=(a[i]+f[j])-(a[i]+f[j])%f[j];
				}
			}
			a[i]+=c[j];
		}
	}
	for(i=1;i<=n;i++)	printf("%d\n",a[i]);
	return 0;
}


Measured memory_bytes: 128
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

mod = 10 ** 9 + 7
N = int(input())

P = primes(N)

ans = 1

for p in P:
    cnt = 1
    tmp = p
    while tmp <= N:
        cnt += N // tmp
        tmp *= p
    ans *= cnt
    ans %= mod

print(ans)

Measured memory_bytes: 9368
#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()
/* libraries */

int powl(int v,int k){ int r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }


signed main() {
	int m,k;
	std::cin >> m >> k;
	if(k>=powl(2,m) || (m==1&&k==1)) {
		print(-1);
		return 0;
	}
	if(m==1&&k==0) {
		print("0 0 1 1");
		return 0;
	}
		
	int n = powl(2,m);
	rep(i,n) {
		if(i==k) continue;
		std::cout << i << ' ';
	}
	std::cout << k << ' ';
	for(int i=n-1;i>=0;i--) {
		if(i==k) continue;
		std::cout << i << ' ';
	}
	std::cout << k << ' ';
	std::cout << ENDL;

	return 0;
}


Measured memory_bytes: 1792
n = int(input())
alist = []
xy = [[] for i in range(n)]
ans = 0
for i in range(n):
    xy[i] =  []
for i in range(n):
    alist.append(int(input()))
    for j in range(alist[i]):
        a,b=input().split()
        xy[i].append([int(a), int(b)])
g = [[] for i in range(2**n-1)]
for i in range(1,2**n):
    for j in range(n):
        if list(format(i,'0b').zfill(n))[j] == '1':
            g[i-1].append(xy[j])
def lie(xy,p):
    z = list(format(p,'0b').zfill(n)) 
    for i in range(len(xy)):
        for j in range(len(xy[i])):
            if str(xy[i][j][1]) == z[xy[i][j][0]-1]:
                continue
            else:
                return 'No'
                break
    return 'Yes'
for k in range(2**n-1):
    if lie(g[k],k+1) == 'Yes':
        ans = max(ans,list(str(format(k+1,'0b'))).count('1'))
print(ans)

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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
// #define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

long calc(long s1, long s2, long s3) {
   long xs[3] = {s1, s2, s3};
   std::sort(xs, xs + 3);
   return xs[2] - xs[0];
}

long dfs2(long h1, long w1, long h, long w) {
   long res = (1LL << 60);
   for(long h2 : {h / 2}) {
      if( h == 1 ) continue;
      long h3 = h - h2;
      long w2 = w, w3 = w;
      res = std::min(res, calc(h1 * w1, h2 * w2, h3 * w3));
   }
   for(long w2 : {w / 2}) {
      if( w == 1 ) continue;
      long w3 = w - w2;
      long h2 = h, h3 = h;
      res = std::min(res, calc(h1 * w1, h2 * w2, h3 * w3));
   }
   return res;
}

long dfs1(long h, long w) {
   long res = (1LL << 60);
   for(long h1 = 1; h1 <= h - 1; ++h1) {
      res = std::min(res, dfs2(h1, w, h - h1, w));
   }
   for(long w1 = 1; w1 <= w - 1; ++w1) {
      res = std::min(res, dfs2(h, w1, h, w - w1));
   }
   return res;
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long h, w;
      scan(h, w);
      printf("%ld\n", dfs1(h, w));
   }
};

int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
}



Measured memory_bytes: 256
while True:
    h,w=map(int,raw_input().split())
    if h==0 and w==0:
        break
    for a in range(1,h+1):
        if a%2==1:
            if w%2==0:
                print("#."*(w/2))
            else:
                print("#."*(w/2)+"#")
        else:
            if w%2==0:
                print(".#"*(w/2))
            else:
                print(".#"*(w/2)+".")
    print


Measured memory_bytes: 4648
#include <cstdio>
#include <algorithm>

int main()
{
	char s[15];
	char t[15];
	scanf("%s%s", s, t);
	for (int i = 0; s[i]; ++i)
	{
		if (s[i] != t[i])
		{
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 1644
#include<stdio.h>

int main(void){
	int r, c, i, j, table[101][101] = {};
	scanf("%d %d", &r, &c);
	for (i = 0; i < r; i++) {
		for (j = 0; j < c; j++) {
			scanf("%d", &table[i][j]);
			table[i][c] += table[i][j];
			table[r][j] += table[i][j];
			table[r][c] += table[i][j];
		}
	}
	for (i = 0; i <= r; i++) {
		for (j = 0; j <= c; j++) {
			if(j) printf(" ");
			printf("%d", table[i][j]);
		}
		printf("\n");
	}


    return 0;
}


Measured memory_bytes: 2080
#include <iostream>
#include <string>

typedef long long ll;

#define F first
#define S second

using namespace std;

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

    string s;

    cin >> s;

    if (s.length() == 2) {
    	cout << s << endl;
    } else {
    	cout << s[2] << s[1] << s[0] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	int n,d,x[10][10],xx,i,j,k,cnt,flg;
	scanf("%d %d",&n,&d);
	for(i=0;i<n;i++)	{
		for(j=0;j<d;j++)	{
			scanf("%d",&x[i][j]);
		}
	}
	cnt=0;
	for(i=0;i<n-1;i++)	{
		for(j=i+1;j<n;j++)	{
			xx=0;
			for(k=0;k<d;k++)	{
				xx+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
			}
			flg=0;
			k=1;
			while(k*k<=xx)	{
				if(k*k==xx)	{
					flg=1;
					break;
				}
				k++;
			}
			cnt+=flg;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
    int k,head=1,tail=10;
    scanf("%d",&k);
    long long int x, queue[100005];
    for(int i = 0; i < 10; i++)
        queue[i] = i;
    while(tail <= k){
        x = queue[head++];
        if(x % 10 != 0)
            queue[tail++] = x*10+x%10-1;
        queue[tail++] = x*10+x%10;
        if(x % 10 != 9)
            queue[tail++]= x*10+x%10+1;
    }
    printf("%lld\n",queue[k]);
    return 0;
}

Measured memory_bytes: 896
#include <stdio.h>
#include <stdlib.h> 
int main() {
	int h; int w;
	scanf("%d %d", &h,&w);
	while (h!=0&&w!=0){
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(!i||!j||i==h-1||j==w-1){
					printf("#");
				}else{
					printf(".");
				}
			}
			puts("");
		}
		puts("");
		scanf("%d %d", &h,&w);
	}
	return 0;
}
 


Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define N 200005
#define debug(x) cout<<#x<<":"<<x<<endl;
using namespace std;
int n,m;
bool res;
bool A[N],B[N];
int ans[N];
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&A[i]);
	}
	for(int i=n;i;i--){
		bool res=0;
		for(int j=i+i;j<=n;j+=i)if(B[j])res^=1;
		if(res^A[i])ans[++m]=i,B[i]=1;
	}
	printf("%d\n",m);
	for(int i=m;i;i--)printf("%d ",ans[i]);
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  
  int count = 0;
  for(int i = 1; i < s.size()-1; i++){
    count++;
  }
 
  cout << s[0];
  cout << count;
  cout << s[s.size()-1];
  
  return 0;
}


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

using namespace std;

main(){
    int a , b , ans = 0;
    scanf("%d %d" , &a , &b);
    for(int i = a ; i <= b ; i ++){
            string s = to_string(i);
            string s2 = s;
            reverse(s2.begin() , s2.end());
            if(s == s2)ans ++;
    }
    printf("%d\n" , ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

int main()
{
    int N, X, T;
	cin >> N >> X >> T;
	
	int time = N / X;
	int cur = N % X;
	if(cur != 0) time++;
	
	printf("%d\n", time * T);
	
		
    return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define pb(a) push_back(a)
#define mp make_pair

#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"
int main()
{
	int n, l = 0;
	cin >> n >> l;
	int ans = 0;
	int ct = l;
	int num = INF;
	bool found = false;
	REP(i, n)
	{
		if (ct == 0)
		{
			found = true;
		}
		ans += ct;
		if (abs(ct) < abs(num))
		{
			num = ct;
		}
		else
		{
			num = num;
		}
		ct++;
	}

	if (found)
	{
		COUT(ans);
		return 0;
	}
	else
	{
		if (num < 0)
		{
			COUT(ans + abs(num));
			return 0;
		}
		else
		{
			COUT(ans - abs(num));
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long N,M, ans = 0;
    cin >> N >> M;
    if(M >= 2*N){
        ans += N;
        M -= 2*N;
        ans += M/4;
    }
    else{
        ans = M/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
using System;

class Program
{
    static void Main(string[] args)
    {
        var scaner = new Scanner();
        var a = scaner.ReadInt();
        var b = scaner.ReadInt();
        var c = scaner.ReadInt();

        var x = a - b;
        var ans = Math.Max(c - x, 0);

        Console.WriteLine(ans);
    }
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];

        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);

        if (this.S.Length == 0) return this.Next();

        this.Index = 0;
        return this.S[this.Index++];
    }

    public int ReadInt()
    {
        return int.Parse(this.Next());
    }

    public long ReadLong()
    {
        return long.Parse(this.Next());
    }

    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }

    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
}

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

int main(){
    string s;
    cin >> s;
    map<char,int> m;

    for(int i = 0; i < 4; i++){
        m[s[i]]++;
    }
    
    cout << (m.size() == 2 ? "Yes" : "No") << endl;
}

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

int main(){
  int a,b,n,c=0; cin>>a>>b>>n;
  for(int i=100;i>0;i--){
    if(a%i==0 && b%i==0) c++;
    if(c==n){
      cout<<i<<endl;
      return 0;
    }
  }
}
  

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~i))
const int neko=200010,inf=0x3f3f3f3f;
char s[neko];
int ans=inf;
int cmin(int x,int y){return x<y?x:y;}
int cmax(int x,int y){return x>y?x:y;}
int main()
{
	scanf("%s",s+1);
	int len=strlen(s+1);
	f(i,1,len-1)if(s[i]^s[i+1])ans=cmin(ans,cmax(i,len-i));
	return printf("%d\n",ans^inf?ans:len),0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define I(x) cin >> x;
#define D(x) cerr << (x) << " ";
#define BR cerr << "\n";
#define P(x) cout << (x) << endl;
#define FIX cout << fixed << setprecision(10);

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;

int main(void){
  ll A, B, C, K;
  I(A);
  I(B);
  I(C);
  I(K);
  if (A <= K) {
    ret += A;
    K -= A;
    if (B <= K) {
      K -= B;
      ret -= K;
    }
  } else {
    ret += K;
  }

  P(ret);

}


Measured memory_bytes: 3632
A = str(input())
S = []
for s in A:
    S.append(s)
ACGT = ["A","C","G","T"]
X = []
cnt = 0
ans = []
for i in range(len(S)):
    if S[i] in ACGT:
        cnt += 1
        continue
    else:
        ans.append(cnt)
        cnt = 0
ans.append(cnt)
print(max(ans))

    


Measured memory_bytes: 3060
#include<stdio.h>

#define MAX 200010

int main()
{
	int N;
	int i, j;
	int count = 0;

	char str[MAX];

	scanf("%d", &N);
	scanf("%s", str);

	j = N-1;

	for (i = 0 ; i < N ; i++)
	{
		if (str[i] == 'W')
		{
			while(str[j] != 'R')
			{
				j--;
				if (j <= i)
				{
					goto out;
				}
			}
			str[i] = 'R';
			str[j] = 'W';
			count++;
		}
	}

out:
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 1908
from itertools import permutations
n, m = map(int, input().split())
G = [[0]*n for _ in range(n)]
for _ in range(m):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  G[a][b] = 1
  G[b][a] = 1
ans = 0
for l in permutations(range(n)):
  if l[0] != 0:
    continue
  for i in range(n-1):
    if not G[l[i]][l[i+1]]:
      break
  else:
    ans += 1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << x2 + y1 - y2 << " " << x2 + y2 - x1 << " " << y1 - y2 + x1 << " " << x2 - x1 + y1 << endl;
}

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

using namespace std;
typedef long long ll;
ll l, n , k , x , a, b, c ,d,sum;
vector<int>v;
const ll MOD = 1e9 + 7;
const ll N = 2000;
const ll K = 2000;
ll C[N+2][K+2];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    memset(C, 0 , sizeof C);
    C[0][0]=1;
    C[1][0]=1;
    for(int i = 0 ; i <=N ;i++)
    {
        C[i][0]=1;
    }
    for(int i = 1 ; i <= N ;i++)
    {
        for(int j = 1 ; j<=K ;j++)
        {
            C[i][j]=(C[i-1][j-1]+ C[i-1][j])%MOD;

        }
    }
    cin >> n >> k;
    a=n-k+1;
    for(int i = 1 ; i <=k ; i++)
    {
       b= C[a][i]%MOD;
       c=C[k-1][i-1]%MOD;
       if(i==1)
       {
           c=1;
       }
       cout << (b*c)%MOD << "\n";
    }
    return 0;
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, int> pli;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    int n;
    scanf("%d", &n);
    printf("%d\n", div_ceil(n, 2));
}

Measured memory_bytes: 256
def main():
    S = input()
    keyence = 'keyence'

    i = 0
    while True:
        if S[i] != keyence[i]:
            break

        if i == len(keyence) - 1:
            print("YES")
            return

        i += 1

    res = len(keyence) - i

    i = -res
    while True:
        if S[i] != keyence[i]:
            print("NO")
            return

        if i == -1:
            print("YES")
            return

        i += 1

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace ConsoleApplication52
{
    class Program
    {
        static void Main(string[] args)
        {
            int ab = int.Parse(Console.ReadLine());
            int[] a = new int[ab];
            for (int ki = 0; ki < ab; ki++)
                a[ki] = ki + 1;
            int c = int.Parse(Console.ReadLine());
            for (int u = 0; u < c; u++)
            {
                int[] b = Console.ReadLine().Split(',').Select(int.Parse).ToArray();
                int d = a[b[0]-1];
                a[b[0] - 1] = a[b[1] - 1];
                a[b[1] - 1] = d;
            }
            for (int y = 0; y < ab; y++)
                Console.WriteLine(a[y]);
        }
    }
}

Measured memory_bytes: 9460
p = 1000000007

main :: IO ()
main = do
  [n, m] <- (map read . words) <$> getLine :: IO [Int]
  print $ solve n m

factorial 0 f = f
factorial n f = factorial (n - 1) (f * n `mod` p)

solve n m
  | abs(n - m) > 1  = 0
  | abs(n - m) == 1 = (factorial n 1) * (factorial m 1) `mod` p
  | otherwise = 2 * (factorial n 1) * (factorial m 1) `mod` p


Measured memory_bytes: 508
#include <cmath>
#include <iostream>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <algorithm>

using namespace std;

template <class T>
T even(T n)
{
	return !(n % 2);
}
template <class T>
T div_three(T n)
{
	return !(n % 3);
}
template <class T>
T div_five(T n)
{
	return !(n % 5);
}

int main() {
	int n, tmp;
	bool f = false;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		if (even(tmp)) {
			f = (div_three(tmp) || div_five(tmp));
			if (!f) {
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}
	cout << "APPROVED" << endl;
    return 0;
}


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

using namespace std;

int main(){
  int N;
  long long K;
  cin >> N >> K;
  
  vector<int> P(N);
  vector<long long> C(N);
  
  for(int i = 0; i < N; i++){
    cin >> P[i];
    --P[i];
  }
  
  for(int i = 0; i < N; i++){
    cin >> C[i];
  }
  
  long long max_score = 0;
  
  for(int i = 0; i < N; i++){
    int cur = i;
    long long s = 0;
    long long ms = 0;
    int cyc = 0;
    for(int k = 0; k == 0 || (k < (int)K && cur != i); k++){
      ++cyc;
      cur = P[cur];
      s += C[cur];
      ms = max(s, ms);
    }
    
    if(s > 0){
      long long st = 0, stm = 0;
      for(int k = 0; k < (int)K % cyc; k++){
        cur = P[cur];
        st += C[cur];
        stm = max(st, stm);
      }
      
      ms = max(s * (K / cyc - 1) + ms, ms);
      ms = max(s * (K / cyc) + stm, ms);
    }
    
    max_score = max(ms, max_score);
  }
  
  bool all_neg = true;
  long long max_neg = -1e9 - 2;
  for(int i = 0; i < N; i++){
    max_neg = max(C[i], max_neg);
    if(C[i] >= 0ll){
      all_neg = false;
      break;
    }
  }
  
  if(all_neg){
    cout << max_neg << endl;
  }else{
    cout << max_score << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3672