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

public class Main {
    
    static int[] a;
    static int h;

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        a = new int[2000000];
        h = 0;
        StringBuilder sb = new StringBuilder();
        while(true){
            String s = sc.next();
            if(s.equals("insert")){
                insert(Integer.parseInt(sc.next()));
            }else if(s.equals("extract")){
                sb.append(heapExtractMax()).append(System.lineSeparator());
            }else if(s.equals("end")){
                break;
            }
        }
        
        System.out.print(sb);
    }
    
    static void insert(int key){
        
        h++;
        a[h] = Integer.MIN_VALUE;
        heapIncreaseKey(h, key);
    }
    
    static void heapIncreaseKey(int i, int key){
        
        if(key < a[i]) return;
        a[i] = key;
        while(i > 1 && a[i/2] < a[i]){
            int tmp = a[i/2];
            a[i/2] = a[i];
            a[i] = tmp;
            i = i/2;
        }
    }
    
    static int heapExtractMax(){
        
        if(h < 1) return Integer.MIN_VALUE;
        int max = a[1];
        a[1] = a[h];
        h--;
        maxHeapify(1);
        
        return max;
    }
    
    static void maxHeapify(int i){
        
        int l = i*2;
        int r = i*2+1;
        int largest;
        
        if(l <= h && a[l] > a[i]){
            largest = l;
        }else{
            largest = i;
        }
        if(r <= h && a[r] > a[largest]){
            largest = r;
        }
        
        if(largest != i){
            int tmp = a[i];
            a[i] = a[largest];
            a[largest] = tmp;
            maxHeapify(largest);
        }
    }
}


Measured memory_bytes: 309176
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		String[] str1 = sc.nextLine().split("");
		String[] str2 = sc.nextLine().split("");

		List list = Arrays.asList(str2);
		Collections.reverse(list);
		str2 = (String[]) list.toArray(new String[3]);

		if (String.join("", str1).equals(String.join("", str2))) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

	}

}


Measured memory_bytes: 23124
def partition(A, p, r):
    x=A[r]
    i=p-1
    for j in range(p,r):
        if A[j] <= x:
            i += 1
            A[i],A[j] = A[j],A[i]
    A[i+1],A[r] = A[r],A[i+1]
    return i+1

if __name__ == "__main__":
    n=int(input())
    A=list(map(int,input().split()))
    j=partition(A,0,n-1)
    for i in range(n):
        if i == n-1:
            print(A[i])
        elif i==j:
            print("[{}]".format(A[i]),end=" ")
        else:
            print(A[i],end=" ")



Measured memory_bytes: 16388
import math
A,B,H,M = map(int,input().split())
zisin = 360/12 * H + 30/60 * M
hunsin = 360/60 * M 
kakusa = min(abs(zisin - hunsin),abs(360-zisin+hunsin))*math.pi/180
ans_2 = A**2 + B**2 - 2*A*B*math.cos(kakusa)
print(ans_2**0.5)

Measured memory_bytes: 9512
#include<iostream>
#include<vector>
#include<numeric>
#include<algorithm>
using namespace std;
typedef long double ld;
int n;
vector<ld> data;
int inp(){
  cin>>n;
  if(!n)return 0;
  data=vector<ld>(n);
  for(int i=0;i<n;i++)
    cin>>data[i];
  return n;
}
void proc(){
  ld avg=accumulate(data.begin(),data.end(),0.0)/n;
  transform(data.begin(),data.end(),data.begin(),[avg](ld x)->ld{return (x-avg)*(x-avg);});
  ld result=sqrt(accumulate(data.begin(),data.end(),0.0)/n);
  printf("%Lf\n",result);
}
int main(){
  while(inp())proc();
  return 0;
}

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

using namespace std;

using lint = long long;

int main(void)
{
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for(auto &x: h){
        cin >> x;
    }

    int ans = 0;
    for(int i = 0; i <  N; i++){
        if(h[i] >= K){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;



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

	vector< vector< long long >  > A = vector< vector< long long >  >(N,vector< long long >(3));
	
	for(int i = 0; i < N; i++)
	{
		
		for(int j = 0; j < 3; j++)
		{
			cin >> A[i][j];
		}
		
	}

	long long max_v = -(1LL << 60);
	for(int i = 0; i < 8; i++)
	{
		vector< long long > v;
		
		for(int j = 0; j < N; j++)
		{
			long long S =0;
			
			for(int k = 0; k < 3; k++)
			{
				if((i/(1<<k) %2 == 0)){
					S += A[j][k];
				}else{
					S -= A[j][k];
				}
			}
			v.push_back(S);
		}
		sort(v.begin(), v.end());
		reverse(v.begin(), v.end());
		long long ans = 0;
		
		for(int j = 0; j < M; j++)
		{
			ans += v[j];
		}
		
		max_v	= max(max_v	, ans);
	}
	
	cout << max_v << endl;

	return 0;
}



Measured memory_bytes: 256
s = input()
s = "".join([ i for i in reversed(s)]) + "0"
 
INF = 10 ** 32
n = len(s)
dp = [ [INF]*2 for _ in range(n)]
 
dp[0][0] = 0
 
for i in range(n-1):
    x = int(s[i])
    dp[i+1][0] = min( dp[i][0]+x, dp[i][1]+x )
    dp[i+1][1] = min( dp[i][0]+1+(10-x), dp[i][1]+(9-x) )
 
print(min(dp[n-1][0], dp[n-1][1]))

Measured memory_bytes: 166572
#include <iostream>
#include <string>
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define SIZE(x) ll(x.size())

typedef long long ll;

using namespace std;
int main() {
  string S, T;
  cin >> S >> T;
  int num = SIZE(S);
  REP(i, num) {
    if (S == T) {
      cout << "Yes";
      return 0;

    } else {
      T = T[num - 1] + T.substr(0, num - 1);
    }
  }
  cout << "No";
  return 0;
}

Measured memory_bytes: 3572
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        string[] n = Console.ReadLine().Split(' ');
        int a = int.Parse(n[0]);
        int b = int.Parse(n[1]);
        string u = Console.ReadLine();
        if (s[0] == u)
        {
            a -= 1;
        } else
        {
            b -= 1;
        }
        Console.WriteLine(a + " " + b);
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)(x).size())
#define mset(a,v) memset(a,v,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
using namespace std;
typedef long long ll;

#define MOD 1000000007

int f[100005][2];
vector<int> g[100005];
int n;

void dfs(int x, int p){
	for(int y:g[x])if(y!=p)dfs(y,x);
	f[x][0]=1;
	for(int y:g[x])if(y!=p)f[x][0]=1LL*f[x][0]*f[y][1]%MOD;
	f[x][1]=1;
	for(int y:g[x])if(y!=p)f[x][1]=1LL*f[x][1]*f[y][0]%MOD;
	f[x][1]=(f[x][0]+f[x][1])%MOD;
}

int main(){
	scanf("%d",&n);
	fore(_,1,n){
		int x,y;
		scanf("%d%d",&x,&y);x--;y--;
		g[x].pb(y);g[y].pb(x);
	}
	mset(f,-1);
	dfs(0,-1);
	printf("%d\n",f[0][1]);
	return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
  int H, W;
  int c[10][10];
  int A[200][200];

  cin >> H >> W;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> c[i][j];
    }
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> A[i][j];
    }
  }

  for (int k = 0; k < 10; k++) {
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
      }
    }
  }

  ll ans = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (A[i][j] < 0) {
        continue;
      }
      ans += c[A[i][j]][1];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int N,A,B,i,AB,kaigai=0,kakutei=0;
    char *s;
    // 整数の入力
    scanf("%d %d %d\n",&N,&A,&B);
    s = malloc(N+1);
    *s = '\0';
    fgets(s,N+1,stdin);


    AB = A + B;



    for(i=0;i<N;i++){



        if(s[i] == 'c'){
            printf("No\n");

        }else if(s[i] == 'a'){
            if(kakutei < AB) printf("Yes\n"),kakutei++;
            else printf("No\n");

        }else if(s[i] == 'b'){
            kaigai++;


            if(kakutei < AB && kaigai <= B) printf("Yes\n"),kakutei++;
            else printf("No\n");
        }








    }





    // 出力

    free(s);

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL = 1LL<<40;
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


int main() {

    ll n, p;cin>>n>>p;
    ll ans = 1;
    
    if (n == 1) {cout<<p<<endl;return 0;}
    
    repsg(i,2,1000005){
        while(p%(ll)pow(i,n) == 0){
            p /= (ll)pow(i,n);
            ans *= i;
        }
    }
    
    
    
    cout<<ans<<endl;
    
    return 0;
}












Measured memory_bytes: 384
n=gets.to_i
n.times{
	point=gets.split(" ").map{|f| f.to_f}
	if(point[2]==point[0]||point[6]==point[4]) then
		if(point[2]==point[0]&&point[6]==point[4]) then
			puts "YES"
		else puts "NO"
		end
	elsif(((point[3]-point[1])/(point[2]-point[0])-(point[7]-point[5])/(point[6]-point[4])).abs<1e-11) then
		puts "YES"
	else puts "NO"
	end
}


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

const int MAXN = 5010;

int N, K;
int A[MAXN];

bool dppref[MAXN][MAXN], dpsuff[MAXN][MAXN];
int sum[MAXN];

int main() {
	scanf("%d %d", &N, &K);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}

	dppref[0][0] = true;
	for (int i = 0; i < N; i++) {
		copy(dppref[i], dppref[i] + K + 1, dppref[i+1]);
		for (int j = 0; j <= K-A[i]; j++) {
			dppref[i+1][j+A[i]] |= dppref[i][j];
		}
	}

	dpsuff[N][0] = true;
	for (int i = N-1; i >= 0; i--) {
		copy(dpsuff[i+1], dpsuff[i+1] + K + 1, dpsuff[i]);
		for (int j = 0; j <= K-A[i]; j++) {
			dpsuff[i][j+A[i]] |= dpsuff[i+1][j];
		}
	}

	// A card is NOT unnecessary <-> a sum in [K-a(i), K-1] can be formed
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int low = K - A[i];
		int high = K - 1;
		for (int j = 0; j <= K; j++) {
			sum[j] = dpsuff[i+1][j];
			if (j > 0) sum[j] += sum[j-1];
		}

		bool found = false;
		for (int j = 0; j <= high; j++) {
			if (!dppref[i][j]) continue;
			int cntOne = sum[high-j];
			if (low-j >= 1) {
				cntOne -= sum[low-j-1];
			}
			found |= bool(cntOne);
		}

		ans += 1 - int(found);
	}

	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 49280
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
using namespace std;
ll dp[3001][3001];
int main()
{
    ll n, m;
    cin >> n >> m;
    char a[n + 1][m + 1];
    ll dp[n + 1][m + 1];
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            dp[i][j] = 0;
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (a[i][0] == '#')
        {
            break;
        }
        dp[i][0] = 1;
    }
    for (int i = 0; i < m; i++)
    {
        if (a[0][i] == '#')
        {
            break;
        }
        dp[0][i] = 1;
    }
    for (int i = 1; i < n; i++)
    {
        for (int j = 1; j < m; j++)
        {
            if (a[i][j] == '#')
            {
                continue;
            }
            else
            {
                dp[i][j] = (dp[i][j - 1] + dp[i - 1][j]) % MOD;
            }
        }
    }
    cout << dp[n - 1][m - 1] % MOD;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b;
ll xxor(ll x){
	ll ret=0;
	while(x%4!=3&&x>=0){
		ret^=x;
		x--;
	}
	return ret;
} 
int main(){
	cin>>a>>b;
	cout<<(xxor(a-1)^xxor(b)) <<endl;
	return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn._
object Main extends App {
  val Array(s, t) = readLine.split(" ")
  val Array(a, b) = readLine.split(" ").map(_.toInt)
  readLine match {
    case u if u == s => println(s"${a - 1} $b")
    case _ => println(s"$a ${b - 1}")
  }

}

Measured memory_bytes: 27332
s = int(input())

def f(n):
	if n % 2 == 0:
		return n / 2
	else:
		return 3 * n + 1

i = 1
tmp = {s}
while True:
	res = f(s)
	if res not in tmp:
		tmp.add(res)
		s = res
	else:
		print(i+1)
		break
	i += 1



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

int main(){
	int x,y;
    cin >> x >> y;
    if(x%y==0)
      cout << -1 << endl;
    else{
      int i=1;
      while(x*i%y==0)
        i++;
      cout << x*i << endl;
    }  
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <map>
#define in(N) cin >> N
#define in2(N,M) in(N) >> M
#define in3(N,M,K) in2(N,M) >> K
#define out(ans) cout << ans << endl
#define outf(ans) cout << fixed << setprecision(6) << ans << endl
#define rep(i,n) for(int i=0; i<n; i++)
#define inv(A,N) rep(i,N) in(A[i])
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;

int main(){
	ll N;
	in(N);
	vector<string> S(N);
	map<string,int> keihin;
	rep(i,N){
		in(S[i]);
		keihin[S[i]]++;
	}
	out(keihin.size());
	return 0;
}

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

int main()
{
    int ant[5];
    int far;
    
    for(int i = 0; i < 5; i++){
        cin >> ant[i];
    }
    
    cin >> far;
    
    for(int j = 4; j >= 1; j--){
        for(int k = j -1; k >= 0; k--){

            if((ant[j] - ant[k]) > far){
                cout << ":(" << endl;
                return 0;
            }        
        }
    }
    cout << "Yay!" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// Copy Korte ascho tai nah //
#define CASE(t)                 printf("Case %d: ",t)
#define gcd(a,b)                __gcd(a,b)
#define lcm(a,b)                ((a)*(b))/gcd(a,b)
#define PI                      2*acos(0.0)
#define ll                      long long int
//MD.JAHIR RAYHAN  , 11th batch CSE ,ID : 11908028 , Comilla University (2018-2019) :
//Email : rayhanlabib7@gmail.com, Phone : 01637809651.
using namespace std;
int main()
{
    int i,z=0,m=0;
   string s;

cin>>s;
for(i=0;i<s.size();i++)
{
    if(i%2==0)
    {
        if(s[i]=='L')
        {
            z++;
        }
    }
     else
    {
        if(s[i]=='R')
        {
            m++;
        }

    }
}
if(z>0 || m>0){
    cout<<"No"<<endl;
}
else
    cout<<"Yes"<<endl;

return 0;
}




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

int main(){
	long long int x;
	scanf("%lld",&x);
	long long int six;
	long long int five;
	six = x%11;
	if (six == 0)
	{
		printf("%lld\n", 2*x/11);
	}
	else if (six <= 6)
	{
		printf("%lld\n", (2*(x/11))+1);
	}
	else{
		printf("%lld\n", (2*(x/11))+2);
	}
	// printf("%lld\n", six);
	// printf("%lld\n", 2*x/11);
	return 0;
}

Measured memory_bytes: 256
n,x = map(int, input().split())

L = list(map(int, input().split()))

K = [0]
for i in range(len(L)):
  K.append(K[i] + L[i])
ans = 0
for i in range(len(K)):
  if K[i] <= x:
    ans += 1
print(ans)

Measured memory_bytes: 3064
while True:
    a, op, b = input().split()   
    a =int(a)                   
    b = int(b)                  

    if op=="?": # opが"?"の時は終了
        break
    else:    #opが"?"以外の時
        if op=="+":
            print(a+b)
        elif op=="-":
            print(a-b)
        elif op=="*":
            print(a*b)
        elif op=="/":
            print(a//b)


Measured memory_bytes: 5592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <utility>
using namespace std;
#define fol(i,n) for (int i=0;i<n;i++)

int main(){
    int a,c;
    char b;
    cin >>a>>b>>c;
    if (b=='+')cout << a+c<<endl;
    else cout << a-c<<endl;
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(dead_code)]
#![macro_use]
use std::io::prelude::*;
use std::cmp::{max, min};
use std::collections::BinaryHeap;

const MOD: i64 = 1e9 as i64 + 7;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn gcd(x: usize, y: usize)->usize{
    if y == 0{
        return x
    }
    gcd(y, x % y)
}

fn main() {
    input! {
        w: chars,
    }
    let mut c = vec![0; 26];
    for i in w{
        c[i as usize - 'a' as usize] += 1;
    }
    let ans = c.iter().all(|&x| (x % 2) == 0);
    println!("{}", if ans {"Yes"} else {"No"});
}


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

void solve()
{
    int a, b, k;
    cin >> a >> b >> k;
    set<int> st;
    for (int i = a; i <= min(b, a + k - 1); i++)
        st.insert(i);
    for (int i = b; i >= max(a, b - k + 1); i--)
        st.insert(i);
    for (auto i : st)
        cout << i << endl;
}

int main()
{
    solve();
    return 0;
}

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

int main()
{
	while(1){
		int n, m, masu[1001] = {0}, sugoroku[1001];
		cin >> n >> m;
		if(n == 0 && m == 0)break;

		for(int i = 1; i <= n; i++)
			cin >> masu[i];
		for(int i = 1; i <= m; i++)
			cin >> sugoroku[i];
	
		int now = 1, ans = 0;
	
		for(int i = 1; i <= m; i++){
			(now + sugoroku[i] >= n) ? ans = i : now += sugoroku[i];
			if(ans > 0)
				break;

			(now + masu[now] >= n) ? ans = i : (now + masu[now] >= 1) ? now += masu[now]  : now = 1; 
			if(ans > 0)
				break;
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1168
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>

using namespace std;

int main()
{
    const int none = -1;
    int A, B, C;
    if (scanf("%d%d%d", &A, &B, &C) < 3) return 0;

    int cnt = 0;
    if (A % 2 == 1
        || B % 2 == 1
        || C % 2 == 1)
    {
        printf("%d\n", cnt);
    }
    else if (A == B && B == C
        && A % 2 == 0
        && B % 2 == 0
        && C % 2 == 0)
    {
        printf("%d\n", none);
    }
    else
    {
        cnt++;
        while(true)
        {
            int bkA1 = A / 2;
            int bkA2 = A - bkA1;

            int bkB1 = B / 2;
            int bkB2 = B - bkB1;

            int bkC1 = C / 2;
            int bkC2 = C - bkC1;

            A = bkB1 + bkC1;
            B = bkA1 + bkC2;
            C = bkA2 + bkB2;

            if (A % 2 == 1
                || B % 2 == 1
                || C % 2 == 1)
            {
                printf("%d\n", cnt);
                break;
            }
            else if (A == B && B == C
                && A % 2 == 0
                && B % 2 == 0
                && C % 2 == 0)
            {
                printf("%d\n", none);
            }

            cnt++;
        }
    }

    return 0;
}


Measured memory_bytes: 128
n=int(input())
l=[]
for i in range(n-1):
  l.append(list(map(int,input().split())))
for i in range(n-1):
  t=l[i][0]+l[i][1]
  for j in range(i+1,n-1):
    if t<l[j][1]:
      t=l[j][0]+l[j][1]
    else:
      m=t%l[j][2]
      t+=l[j][0]+(l[j][2]-m)*(m!=0)
  print(t)
print(0)

Measured memory_bytes: 3188
import sys
input = sys.stdin.readline

N=int(input())
P=list(map(int,input().split()))

Q=sorted(P)

import copy

for i in range(N):
    for j in range(i,N):
        R=copy.deepcopy(P)

        R[i],R[j]=R[j],R[i]

        if Q==R:
            print("YES")
            sys.exit()

print("NO")

Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#define inf 10e8
#define rep(i,n) for(long i=0;i<n;i++)
using namespace std;

int main(){
    double n;
    cin >> n;
    int d=n/1;
  string a="0.5000000000";
    if(d%2==0) cout << a << endl;
    else printf("%.12f\n",(n+1)/(2*n));
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int[]d = new int[n];
		int ans = 0;
		for(int i=0;i<n;i++) {
			int nyu = sc.nextInt();
			int status = 0;
			for(int j=0;j<n;j++) {
				if(d[j]==nyu) {
					status = 1;
				}
			}
			if(status == 0) {
				ans ++;
			}
			d[i] = nyu;
		}
		// 文字列の入力
		//String s = sc.next();
		// 出力
		//for(int i=0;i<n;i++) {
		//	System.out.println(d[i]);
		//}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22228
#include <stdio.h>
int main(void){
	struct tag{
		int custo;
		int tempo;
		int valido;
	};
	int limite,n,min=10000,caminho;
	scanf("%d %d", &n,&limite);
	struct tag arr[n];
	for(int i=0;i<n;i++){
		scanf("%d %d", &arr[i].custo, &arr[i].tempo);
		if (arr[i].tempo>limite)arr[i].valido=0;
		else arr[i].valido=1;
	}
	for(int w=0;w<n;w++){
		if(arr[w].valido==1){
			if(arr[w].custo<min)min=arr[w].custo;
		}
	}
	if(min==10000)printf("TLE\n");
	else printf("%d\n", min);
	return 0;
}

			

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

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

    int r = a[0][0];
    for (int j = 0; j < n; j++) {
        r += a[1][j];
    }

    int t = r;
    for (int j = 1; j < n; j++) {
        t += a[0][j] - a[1][j - 1];
        r = max(r, t);
    }

    cout << r << endl;

    return 0;
}

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

ll N, M;
vector<ll> X;
vector<ll> b;
ll ret = 0;

void input(){
    ll temp;
    cin >> N >> M;
    for(ll i=0;i<M;i++){
        cin >> temp;
        X.push_back(temp);
    }
}

void solve(){
    sort(X.begin(), X.end());
    for(ll i=0;i<M-1;i++){
        b.push_back(X[i+1] - X[i]);
    }
    sort(b.begin(), b.end());
    for(ll i=0;i<M-1-(N-1);i++){
        ret += b[i];
    }
}

int main(void){
    // Your code here!
    input();
    solve();
    cout << ret << endl;
}


Measured memory_bytes: 2548
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i,a,b) for(register int i=a;i<=b;++i)
#define repd(i,a,b) for(register int i=a;i>=b;--i)
#define reps(s) for(int i=head[s];i;i=e[i].nxt)
#define ce(i,r) i==r?'\n':' '
#define pb push_back 
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef long long ll;
int main()
{
	int n,m; si(n),si(m);
	int sum=0;
	repi(i,1,m){
		int x; si(x);
		sum+=x;
	}
	if(sum<=n) printf("%d\n",n-sum);
	else puts("-1");
	return 0;
}


Measured memory_bytes: 3828
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

int sum[200100];

int main(){
  int n, k;
  cin >> n >> k;
  for(int i = 0; i < n; ++i){
  	int p;
  	cin >> p;
  	sum[i + 1] = sum[i] + p;
  }

  int mx = 0;
  for(int i = 0; i < n - k + 1; ++i){
  	mx = max(mx, sum[i + k] - sum[i]);
  }

  double ans = ((double)k + (double)mx) / 2.0;
  printf("%.12lf", ans);
  return 0;
}


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

int main() {
    string s;
    cin >> s;
    int ans = 0, cnt = 0;
    
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G') {
            cnt++;
            ans = max(ans, cnt);
        }
        else {
            cnt = 0;
        }
    }
    ans = max(ans, cnt);

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(false) , cin.tie(0) ;
#define w(x) cout << (#x) << " is " << x << "\n" ;

int main()
{
    fast ;
//#ifndef ONLINE_JUDGE
//    freopen("input.txt","r",stdin);
//#endif
    ll n,g,x;
    cin >> n ;
    cin >> x ;
    n--;
    while(n--)
    {
        cin >> g ;
        x=__gcd(x,g);
    }
    cout << x << "\n";
    return 0;
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)

void solve() 
{
    string s;cin>>s;
    bool flag1=0,flag2=0;
    REP(i,s.size()){
        if(flag1==0){
            if(s[i]=='C')flag1=1;
        }else if(flag2==0){
            if(s[i]=='F')flag2=1;
        }else{
            break;
        }
    }cout<<(flag2?"Yes":"No")<<endl;
}

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

Measured memory_bytes: 256
a=int(input())
b=[]
for _ in range(a):
    b.append(list(map(str,input().split())))
ans=0
for i in range(a):
    if b[i][1]=='JPY':
        ans+=int(b[i][0])
    else:
        ans+=float((b[i][0]))* 380000
print(ans)

Measured memory_bytes: 9056
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::{i32, i64, u32, u64, usize, f64};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet};
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::mem::{swap};

fn main() {
    input! {
        h: usize,
        w: usize,
        grid: [String; h],
    }
    let grid: Vec<_> = grid.iter().map(|r| r.chars().collect::<Vec<char>>()).collect();
    for i in 0..h {
        for j in 0..w {
            if grid[i][j] == '#' {
                for (m, &(di, dj)) in [(1, 0), (0, 1), (!0, 0), (0, !0)].iter().enumerate() {
                    let (k, l) = (i.wrapping_add(di), j.wrapping_add(dj));
                    if k < h && l < w && grid[k][l] == '#' { break; }
                    if m == 3 {
                        println!("No");
                        return;
                    }
                }
            }
        }
    }
    println!("Yes")
}


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

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

using namespace std;

int n, m;

int main(){
  scanf("%d%d", &n, &m);
  int s = 0, M = 0;
  rep(i, m){
    int a, b;
    scanf("%d%d", &a, &b);
    int v = max(n - a, 0);
    s += v;
    M = max(v, M);
  }
  printf("%d\n", s - M);
  return 0;
}

Measured memory_bytes: 2692
#include <stdio.h>
#include <string.h>

int con[2000], len[2000];

int main(void)
{
	char str[2000][100];
	int i, j, k = 0, max_len, max_app;
	
	while (scanf("%s", str[k]) != EOF)k++;
	
	for (i = 0; i < k - 1; i++){
		if (con[i] == -1)continue;
		for (j = i + 1; j < k; j++){
			if (strcmp(str[i], str[j]) == 0){
				con[i]++;
				con[j] = -1;
			}
		}
	}
	
	for (i = 0; i < k; i++){
		len[i] = strlen(str[i]);
		if (i == 0)max_len = i;
		else if (len[max_len] < len[i])max_len = i;
	}
	
	for (i = 0; i < k - 1; i++){
		if (i == 0)max_app = i;
		else if (con[max_app] < con[i])max_app = i;
	}
	
	printf("%s %s\n", str[max_app], str[max_len]);
	
	
	return (0);
}

Measured memory_bytes: 576
h, w = list(map(int, input().split()))
s = [input() for i in range(h)]
cel = [[[""]for i in range(w)] for j in range(h)]
dir = [[-1, -1], [-1, 0], [-1, 1], [0, -1], [0, 1], [1, -1], [1, 0], [1, 1]]
for y in range(h):
    for x in range(w):
        if s[y][x] == "#":
            cel[y][x] = "#"
for y in range(h):
    for x in range(w):
        if cel[y][x] == "#":
            continue
        bomb = 0
        for dx, dy in dir:
            cx = x+dx
            cy = y+dy
            if cx >= 0 and cx < w and cy >= 0 and cy < h:
                if cel[cy][cx] == "#":
                    bomb += 1
        cel[y][x] = bomb
for y in range(h):
    output = ""
    for x in range(w):
        output += str(cel[y][x])
    print(output)

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
const int INF=1e9;

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

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

const int INF = 1001001001;

int main() {
    int n, k;
    while (cin >> n >> k) {
        if (n == 0) break;
        vector<ll> a(n);
        rep(i, n) cin >> a[i];
    
        vector<ll> s(n+1);
        rep(i, n) s[1+i] += s[i] + a[i];
        
        ll ans = -INF;
        for(int i = 0; i <= n-k; i++) {
            ll val = s[k+i] -s[i];
            if (ans < val) ans = val;
        }
        cout << ans << endl;
    }
    return 0;
}


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

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

int main() {
	int k;
	cin >> k;
	vector<ll> ans;
	queue<ll> que;
	REP(i, 9) {
		ans.push_back(i);
		que.push(i);
	}
	
	while (1) {
		if (ans.size() >= k) break;
		ll p = que.front();
		que.pop();
		if (p % 10 == 0) {
			que.push(10 * p);
			que.push(10 * p + 1);
			ans.push_back(10 * p);
			ans.push_back(10 * p + 1);
		} else if (p % 10 == 9) {
			que.push(10 * p + 8);
			que.push(10 * p + 9);
			ans.push_back(10 * p + 8);
			ans.push_back(10 * p + 9);
		} else {
			ll t = p % 10;
			que.push(10 * p + (t - 1));
			que.push(10 * p + t);
			que.push(10 * p + t + 1);
			ans.push_back(10 * p + t - 1);
			ans.push_back(10 * p + t);
			ans.push_back(10 * p + t + 1);
		}
	}
	cout << ans[k-1] << endl;
	return 0;
}



Measured memory_bytes: 1620
#include <iostream>
using namespace std;
int N,M;
string S[55];
string ans[55];
int d[]={-1,0,1};
int main()
{
    cin>>N>>M;
    for(int i=1;i<=N;i++)
    {
        cin>>S[i];
        S[i]=" "+S[i];
        ans[i].resize(M+1);
    }
    for(int i=1;i<=N;i++)
    {
        for(int j=1;j<=M;j++)
        {
            if(S[i][j]=='#')
            {
                ans[i][j]='#';
            }
            else
            {
                ans[i][j]='0';
                for(int k=0;k<3;k++)
                {
                    for(int l=0;l<3;l++)
                    {
                        int x=i+d[k];
                        int y=j+d[l];
                        if(x&&y&&x<=N&&y<=M)
                        {
                            ans[i][j]+=(S[x][y]=='#');
                        }
                    }
                }
            }
        }
        cout<<ans[i].substr(1)<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline




def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())

directions=np.array([[1,0],[0,1],[-1,0],[0,-1]])
directions = list(map(np.array, directions))

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact



def serch(x, count):
    #print("top", x, count)
            

    for d in directions:
        nx = d+x
        #print(nx)
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1 
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)  
                continue
            if field[nx[0]][nx[1]] == "#":
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)    
                 
    return count

N,M=acinput()

l=[acinput() for i in range(N)]

res=-1
for k in range(2**3):
    b=list(bin(k)[2:].zfill(3))
    #print(b)
    b = [1 if sb == '0' else -1 for sb in b]

    #print(b)
    tmp=sorted([np.dot(b,x) for x in l],reverse=True)
    #print(tmp)
    res=max(res,sum(tmp[:M]))
    
    
print(res)
    
        


Measured memory_bytes: 14640
def suit2num(suit):
    if suit == 'S':
        return 0
    elif suit == 'H':
        return 1
    elif suit == 'C':
        return 2
    elif suit == 'D':
        return 3

def num2suit(num):
    if num == 0:
        return 'S'
    elif num == 1:
        return 'H'
    elif num == 2:
        return 'C'
    elif num == 3:
        return 'D'

num = int(input())
card = [[0 for i in range(13)] for j in range(4)]

while num > 0:
    list = input().split()
    a = suit2num(list[0])
    b = int(list[1]) - 1
    card[a][b] = 1
    num -= 1

for i in range(4):
    for j in range(13):
        if card[i][j] == 0:
            print(num2suit(i), j + 1)



Measured memory_bytes: 5608
from sys import stdin
import fractions

N = str(stdin.readline().rstrip())
# A = [int(x) for x in stdin.readline().rstrip().split()]
# print(N)
# print(A)

ans = 0 # change_count

n_list = list(N)
back = len(n_list) - 1

for i in range(0, len(n_list)//2):
    if not n_list[i] == n_list[back]:
        ans += 1
    back -= 1

print(ans)


Measured memory_bytes: 5344
#include<iostream>
#include<string.h>
#include<math.h>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a <= 5) {
		cout << 0 << endl;
	}
	else if (a <= 12) {
		cout << b / 2 << endl;
	}
	else {
		cout << b << endl;
	}
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll ans = 0;
    for(ll i = 0; i < N - 2; i++){
        if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C'){
            ans++;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  int n,l;cin>>n>>l;
  vector<int> vec(n);
  int cnt=0,a=1e9;
  rep(i,n){
    vec[i]=i+l;
    cnt+=vec[i];
    a=min(a,abs(vec[i]));
  }
  if(cnt>0)cout<<cnt-a<<endl;
  else cout<<cnt+a<<endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

void solve() {
    unsigned int N;
    cin >> N;
    vector<int> A(N);
    REP(i,N) cin >> A[i];
    set<int> st;
    for(int bit = 0; bit < (1u << N); bit++) {
        int cnt  = 0;
        REP(i,N) if ((1u << i) & bit) cnt += A[i];
        st.insert(cnt);
    }
    int q;
    cin >> q;
    REP(_,q) {
        int m;
        cin >> m;
        if(st.count(m)) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d,e;
cin>>a>>b;
c=a+b;
d=a-b;
e=a*b;
int ans=0;
ans=max(c,d);
ans=max(ans,e);
cout<<ans;
}

Measured memory_bytes: 3620
mod=10**9+7

def modpow(a,n):
    if n==0:
        return 1
    elif n==1:
        return a%mod
    elif n%2==0:
        return (modpow(a,n/2)**2)%mod
    else:
        return (a*modpow(a,n-1))%mod

def modfact(l,r):
    fact=1
    for i in range(l-r+1):
        fact=fact*(r+i)%mod
    return fact

def comb(n,x):
    S=modfact(n,n-x+1)
    fact=modfact(x,1)
    T=modpow(fact,mod-2)
    return S*T%mod

n,a,b=map(int,input().split())
fact=modpow(2,n)
ans=fact-1-comb(n,a)-comb(n,b)
while ans<0:
    ans+=mod
print(ans)

Measured memory_bytes: 3188
#include "stdio.h"

int main(){
  int height[10];
  int i,numb,num,a;
  for(i = 0; i < 10; i++){
    scanf(" %d", &height[i]);
  }
  for(numb = 0; numb < 9; numb++){
        for(num = 0; num < 9-numb; num++){
            if(height[num] < height[num+1]){
                int stock = height[num];
                height[num] = height[num+1];
                height[num+1] = stock;
            }
        }
    }
  for(a = 0; a < 3; a++){
    printf("%d\n", height[a]); 
  }
  return 0;
}

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

typedef long long LL;

const int N = 1000005;
const int MOD = 1000000007;

int n, inv[N * 2], fac[N * 2], m;
char str[N];

int ksm(int x, int y)
{
	int ans = 1;
	while (y)
	{
		if (y & 1) ans = (LL)ans * x % MOD;
		x = (LL)x * x % MOD; y >>= 1;
	}
	return ans;
}

int C(int n, int m)
{
	return (LL)fac[n] * inv[m] % MOD * inv[n - m] % MOD;
}

int main()
{
	scanf("%d", &n);
	scanf("%s", str + 1);
	m = strlen(str + 1);
	fac[0] = fac[1] = inv[0] = inv[1] = 1;
	for (int i = 2; i <= n + m; i++) fac[i] = (LL)fac[i - 1] * i % MOD, inv[i] = (LL)(MOD - MOD / i) * inv[MOD % i] % MOD;
	for (int i = 2; i <= n + m; i++) inv[i] = (LL)inv[i - 1] * inv[i] % MOD;
	int ans = 0;
	for (int i = 0; i <= n; i++)
		(ans += (LL)ksm(26, i) * C(n + m - i - 1, m - 1) % MOD * ksm(25, n - i) % MOD) %= MOD;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 20388
#include <iostream>
using namespace std;
 
int n, r, p, c;
int cards[64];
 
void init() {
    for(int i = 0; i < n; i++)
        cards[i] = n - i;
}
 
bool input() {
    cin >> n >> r;
    if(!n && !r)
        return false;
    return true;
}
 
void shuffle() {
    int tmp[64];
    
    // c 個分の要素をtmpに格納
    for(int i = 0; i < c; i++)
        tmp[i] = cards[p - 1 + i];
    // p-1 個分の要素を c 個分ずらす
    for(int i = 0; i < p - 1; i++)
        cards[p - 2 - i + c] = cards[p - 2 - i];
    // 先頭に c 個分の要素をつめる
    for(int i = 0; i < c; i++)
        cards[i] = tmp[i];
}
 
int solve() {
    for(int i = 0; i < r; i++) {
        cin >> p >> c;
        shuffle();
    }
    return cards[0];
}
 
int main() {
    while(input()) {
        init();
        cout << solve() << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;

ll A,B,Q;

int main(){
    cin >> A >> B >> Q;
    vector<ll> s(A);
    vector<ll> t(B);
    vector<ll> x(Q);
    for(int i=0;i<A;i++) cin >> s[i];
    for(int i=0;i<B;i++) cin >> t[i];
    for(int i=0;i<Q;i++) cin >> x[i];
    for(int i=0;i<Q;i++){
        vector<ll> v;
        auto s_itr = lower_bound(s.begin(),s.end(),x[i]);
        int s_index = (int)(s_itr -  s.begin());
        if(s_index != A){
            ll l = abs(s[s_index]-x[i]);
            auto t_itr = lower_bound(t.begin(),t.end(),s[s_index]);
            int t_index = (int)(t_itr -  t.begin());
            if(t_index != B){
                v.push_back(l + abs(s[s_index]-t[t_index]));
            }
            if(t_index != 0){
                v.push_back(l + abs(s[s_index]-t[t_index-1]));
            }
        }
        if(s_index != 0){
            s_index--;
            ll l = abs(s[s_index]-x[i]);
            auto t_itr = lower_bound(t.begin(),t.end(),s[s_index]);
            int t_index = (int)(t_itr -  t.begin());
            if(t_index != B){
                v.push_back(l + abs(s[s_index]-t[t_index]));
            }
            if(t_index != 0){
                v.push_back(l + abs(s[s_index]-t[t_index-1]));
            }
        }

        auto t_itr = lower_bound(t.begin(),t.end(),x[i]);
        int t_index = (int)(t_itr -  t.begin());
        if(t_index != B){
            ll l = abs(t[t_index]-x[i]);
            s_itr = lower_bound(s.begin(),s.end(),t[t_index]);
            s_index = (int)(s_itr -  s.begin());
            if(s_index != A){
                v.push_back(l + abs(s[s_index]-t[t_index]));
            }
            if(s_index != 0){
                v.push_back(l + abs(s[s_index-1]-t[t_index]));
            }
        }
        if(t_index != 0){
            t_index--;
            ll l = abs(t[t_index]-x[i]);
            s_itr = lower_bound(s.begin(),s.end(),t[t_index]);
            s_index = (int)(s_itr -  s.begin());
            if(s_index != A){
                v.push_back(l + abs(s[s_index]-t[t_index]));
            }
            if(s_index != 0){
                v.push_back(l + abs(s[s_index-1]-t[t_index]));
            }
        }

        sort(v.begin(),v.end());
        cout << v[0] << endl;
    }
    return 0;
}

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

int main() {
 string S;
 cin >> S;
 bool ans = true;
 int N = (int)S.size();
 vector<char> A(N);
 for(int i = 0; i < N; i++){
   A.at(i) = S.at(i);
 }
 for(int i = 0; i < (N-1)/2; i++){
   if(A.at(i) != A.at(N-i-1)){
     ans = false;
     break;
   }
 }
 for(int i = 0; i < (N-1)/4; i++){
   if(A.at(i) != A.at((N-1)/2-i-1)){
     ans = false;
     break;
   }
 }
 for(int i = (N+3)/2-1; i < N; i++){
   if(A.at(i) != A.at(N-i-1)){
     ans = false;
     break;
   }
 }
 if(ans) cout << "Yes" << endl;
 else cout << "No" << endl;
 
 return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  vector<int> a(n);

  REP(i, n) cin >> a[i];

  int x = 0;
  REP(i, n) {
    if(i % 2 == 0) x += a[i];
    else x -= a[i];
  }

  vector<int> ans(n);
  ans[0] = x;

  int t = x / 2;
  REP(i, n - 1) {
    t = a[i] - t;
    ans[i + 1] = t * 2;
  }

  REP(i, n) cout << ans[i] << endl;
}


Measured memory_bytes: 3976
#include<bits/stdc++.h>
using namespace std;
string st;
int l,x;
int main()
{
	cin>>st;
	l=st.size();
	st=" "+st;
	if(!(st[1]-'0'))
	{
		puts("-1");
		return 0;
	}
	if(st[l]-'0')
	{
		puts("-1");
		return 0;
	}
	for(int i=1;i<l;i++)
	if(st[i]!=st[l-i])
	{
		puts("-1");
		return 0;
	}
	x=1;
	for(int i=1;i<l;i++)
	{
		printf("%d %d\n",i+1,x);
		if(st[i]-'0')x=i+1;
	}
	return 0;
}

Measured memory_bytes: 3920
#include<cstdio>
using namespace std;
const int maxn=20;
int n,m,cnt;
char mp[maxn][maxn];bool vis[maxn][maxn];
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%s",mp[i]+1);
	for (int i=1;i<=n;i++)
	for (int j=1;j<=m;j++) if(mp[i][j]=='#') cnt++;
	if(cnt!=n+m-1){puts("Impossible");return 0;}
	vis[0][1]=1;
	for (int i=1;i<=n;i++)
	for (int j=1;j<=m;j++)
	vis[i][j]=mp[i][j]=='#'&&(vis[i][j-1]||vis[i-1][j]);
	puts(vis[n][m]?"Possible":"Impossible");
	return 0;
}

Measured memory_bytes: 128