akhauriyash/Code-Regression huggingface dataset:
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
--import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Fixed
import Data.Tuple
--import Data.Array
import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Text.Printf
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
whenM :: Monad m => m Bool -> m () -> m ()
whenM c a = c >>= flip when a
unconsU :: [a] -> (a, [a])
unconsU (x:xs) = (x, xs)
-- templete

it [] _ = []
it _ [] = []
it xa@(x:xs) ya@(y:ys)
  | x<y = it xs ya
  | x>y = it xa ys
  | otherwise = x : it xs ys


main = do
    n <- getInt
    unless (n==0) $ do
        ds <- replicateM n getInts
        let lefts = sort $ map minimum ds
        let rights = sort $ map maximum $ transpose ds
        let r = it lefts rights
        print $ cond 0 (head r) $ null r
        main


Measured memory_bytes: 4100
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n, m;
const int maxP = 1040;
int a[maxP][maxP];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n >> m;
    int x = (1 << n);
    int b = (1 << m);
    if (n <= m) {
        for (int i = 0; i < x; i++) {
            for (int j = 0; j < b; j++) {
                int p = (j >> (m - n));
                ::a[i][j] = __builtin_popcount((i & p)) & 1;
            }
        }
    }
    else {
        for (int i = 0; i < x; i++) {
            for (int j = 0; j < b; j++) {
                int p = (i >> (n - m));
                ::a[i][j] = (__builtin_popcount((j & p))) & 1;
            }
        }
    }



    for (int i = 1; i < (1 << n); i++) {
        if (a[i][0] == 1) {
            for (int j = 0; j < (1 << m); j++) {
                a[i][j] ^= 1;
            }
        }
    }
    for (int i = 1; i < (1 << m); i++) {
        if (a[0][i] == 1) {
            for (int j = 0; j < (1 << n); j++) {
                a[j][i] ^= 1;
            }
        }
    }
//    for (int bit1 = 0; bit1 < (1 << n); bit1++) {
//        for (int bit2 = bit1 + 1; bit2 < (1 << n); bit2++) {
//            int cnt0 = 0;
//            int cnt1 = 0;
//            for (int j = 0; j < (1 << m); j++) {
//                int p = a[bit1][j] ^ a[bit2][j];
//                if (p == 0) cnt0++;
//                else cnt1++;
//            }
//            assert(cnt0 == cnt1);
//        }
//    }
    for (int i = 1; i < (1 << n); i++) {
        for (int j = 1; j < (1 << m); j++) {
            cout << (a[i][j] ^ a[i - 1][j] ^ a[i][j - 1] ^ a[i - 1][j - 1]);
        }
        cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 5504
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        String s = sc.nextLine();
        String result = "";
        char cArray[] = s.toCharArray();
        for(int i = 0; i < cArray.length; i++) {
            int tempInt = (int)cArray[i] + n;
            if (tempInt > 90) {
                tempInt = tempInt - 26;
            }
            result = result + (char)tempInt;

        }
        System.out.println(result);
    }
}

Measured memory_bytes: 56572
k, n = map(int, input().split())
a = [int(n) for n in input().split()]

max_sub = a[0]-a[n-1]+k

for i in range(n-1):
  if(a[i+1]-a[i] > max_sub):
    max_sub = a[i+1]-a[i]

print('{}'.format(k-max_sub))
        

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

using namespace std;
using ll = long long;

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

int main()
{
    int n, m;
    cin >> n >> m;
    priority_queue<int> a;
    for(int i = 0; i < n; i++){
        int s;
        cin >> s;
        a.push(s);
    }
    for(int i = 0; i< m; i++){
        int tmp = a.top();
        a.pop();
        tmp /= 2;
        a.push(tmp);
    }
    ll ans = 0;
    for(int i = 0; i< n; i++){
        ans += a.top();
        a.pop();
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    ll n, m;
    cin >> n >> m;
    vector<tuple<ll, ll>> c(n);
    rep(i, n)
    {
        ll a, b;
        cin >> a >> b;
        c[i] = make_tuple(a, b);
    }
    sort(all(c));
    ll ans = 0;
    rep(i, n)
    {
        if (m >= get<1>(c[i]))
        {
            m -= get<1>(c[i]);
            ans += get<0>(c[i]) * get<1>(c[i]);
        }
        else
        {
            ans += get<0>(c[i]) * m;
            break;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
sx, sy, tx, ty = map(int, input().split())

def go(start, goal):
    x = goal[0] - start[0]
    y = goal[1] - start[1]
    if x < 0:
        st = "L" * abs(x)
    else:
        st = "R" * x

    if y < 0:
        st += "D" * abs(y)
    else:
        st += "U" * y

    return st

def go2(start, goal):
    x = goal[0] - start[0]
    y = goal[1] - start[1]

    if y < 0:
        st = "D" * abs(y)
    else:
        st = "U" * y

    if x < 0:
        st += "L" * abs(x)
    else:
        st += "R" * x

    return st

ans = go([sx, sy], [tx, ty])
ans += go([tx, ty], [sx, sy])
ans += go([sx, sy], [sx - 1, sy])
ans += go2([sx - 1, sy], [tx, ty + 1])
ans += go2([tx, ty + 1], [tx, ty])
ans += go2([tx, ty], [tx + 1, ty])
ans += go2([tx + 1, ty], [sx, sy - 1])
ans += go2([sx, sy - 1], [sx, sy])
print(ans)


Measured memory_bytes: 3064
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt(), t = sc.nextInt();
		int a[] = new int[n];
		for(int i=0;i<n;i++){
			a[i] = sc.nextInt();
		}
		int maxd = 0;
		int cnt = 1;
		int sufmax[] = new int[n];
		sufmax[n-1] = a[n-1];
		for(int i=n-2;i>=0;i--){
			sufmax[i] = Math.max(a[i], sufmax[i+1]);
		}
		
		for(int i=0;i<n-1;i++){
			if(sufmax[i+1] - a[i] > maxd){
				maxd = sufmax[i+1] - a[i];
				cnt = 1;
			}
			else if(sufmax[i+1] - a[i] == maxd){
				cnt++;
			}
		}
		
		System.out.println(cnt);
		
	}

}


Measured memory_bytes: 50320
#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define int long long
#define gcd __gcd
const int inf = 0x3f3f3f3f;
const int maxn = 201110;
const int M = 1e9+7;
int n,m;

map<string,int> mp;

signed main()
{
    string s1;
    cin>>s1;
    int len = s1.size();
    for(int i = 1; i <= len; i++) 
    {
        putchar('x');
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=105;
char a[MAXN],b[MAXN],c[MAXN];
int la,lb,lc,sa,sb,sc,l=1;
char ans;
int check(char t){
	if(t=='a')return 1;
	if(t=='b')return 2;
	if(t=='c')return 3;
	return 0;
}
int main(){
	scanf("%s%s%s",a+1,b+1,c+1);
	la=strlen(a+1);
	lb=strlen(b+1);
	lc=strlen(c+1);
	while(sa<=la&&sb<=lb&&sc<=lc){
		if(l==1)l=check(a[++sa]);
		if(l==2)l=check(b[++sb]);
		if(l==3)l=check(c[++sc]);
	}
	if(sa>la)ans='A';
	if(sb>lb)ans='B';
	if(sc>lc)ans='C';
	printf("%c\n",ans);
}

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

using namespace std;

typedef long long ll;
typedef double dd;

ll arr[3][3];

bool check(ll sum) {
  for (ll r = 0; r < 3; ++r)
    if (arr[r][0] + arr[r][1] + arr[r][2] != sum || arr[0][r] + arr[1][r] + arr[2][r] != sum)
      return false;
  if (arr[0][0] + arr[1][1] + arr[2][2] != sum)
    return false;
  if (arr[2][0] + arr[1][1] + arr[0][2] != sum)
    return false;
  return true;
}

void solve(ll test_num) {
  (void) test_num;
  ll A, B, C;
  cin >> A >> B >> C;
  arr[0][0] = A;
  arr[0][1] = B;
  arr[1][1] = C;
  for (ll sum = -300; sum <= 300; ++sum) {
    arr[0][2] = sum - A - B;
    arr[2][1] = sum - B - C;
    arr[2][2] = sum - A - C;
    arr[1][2] = sum - arr[0][2] - arr[2][2];
    arr[1][0] = sum - arr[1][2] - arr[1][1];
    arr[2][0] = sum - arr[2][2] - arr[2][1];
    if (check(sum)) {
      for (int r = 0; r < 3; ++r, cout << endl)
        for (int c = 0; c < 3; ++c)
          cout << arr[r][c] << ' ';
      return;
    }
  }
}

void init() {

}

int main() {
#ifdef AZN
  const auto start_time = chrono::system_clock::now();
  freopen("/home/azneye/Documents/Stuff/input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  init();
  ll tests = 1;
  //cin >> tests;
  for (ll test = 1; test <= tests; ++test) {
    solve(test);
  }
#ifdef AZN
  cerr << "Took: " << ((chrono::system_clock::now() - start_time).count() / 1e9) << " s" << endl;
#endif
  return 0;
}

Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;

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

        char[] cs = s.toCharArray();
        char[] ct = t.toCharArray();

        Arrays.sort(cs);
        Arrays.sort(ct);

        for (int l = 0, r = ct.length - 1; l < r; l++, r--) {
            char tmp = ct[l];
            ct[l] = ct[r];
            ct[r] = tmp;
        }

        if (new String(cs).compareTo(new String(ct)) < 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

int main() {
  int N,b,c,d;
  b=1;
  c=0;
  d=0;
  cin >>N;
  vector<int> vec(N);
  
  for(int i=0;i<N; i++){
    cin >> vec.at(i);
  }
  for(int j=0; j<N; j++){
    if(vec.at(b-1)==2){
      d =d+1;
      break;
    }
    else{
      b = vec.at(b-1);
      d =d+1;
    }
  }
  if(vec.at(b-1)==2){
    cout <<d <<endl;
  }
  else{
    cout <<-1 <<endl;
  }
  
  
}


Measured memory_bytes: 640
n = int(input())
d = {"AC":0, "WA":0, "TLE":0, "RE":0}
for _ in range(n):
    s = input()
    d[s] += 1

for s in ['AC', 'WA', 'TLE', 'RE']:
    print("{} x {}".format(s, d[s]))


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD ((ll)1e9+7)
ll N,K;
ll F[202020];
ll i,j,ans;

ll moddiv(ll a,ll b){
    a %= MOD;
    b %= MOD;
    ll m = MOD - 2;
    while(m){
        if(m&1){
            a = (a * b) % MOD;
        }
        b = b * b%MOD;
        m /= 2;
    }
    return a;
}

int main(){
    scanf("%lld%lld", &N,&K);
    F[0] = 1;
    fornum(i,0,N){
        F[i + 1] = (F[i] * (i + 1)) % MOD;
        
    }
    fornum(i,1,K+1){
        if(N-K+1>=i)
            printf("%lld\n", moddiv(F[N-K+1],F[i]*F[N-K-i+1])*moddiv(F[K-1],F[i-1]*F[K-i]) % MOD);
        else
            printf("0\n");
    }
    
    return 0;
}

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

int stack[100],top = 0;

int isempty();
int isfull();
void push(int);
int pop();

int main(){
  int x,y;
  char s[8];

  while(scanf("%s",s) != EOF){
    if(s[0] == '+'){
      x = pop() + pop();
      push(x);
    }

    else if(s[0] == '-'){
      x = pop();
      y = pop();
      x = y - x;
      push(x);
    }

    else if(s[0] == '*'){
      x = pop() * pop();
      push(x);
    }

    else{
      x = atoi(s);
      push(x);
    }
  }

  printf("%d\n",pop());
  
  return 0;
}

int isempty(){
  if(top <= 0) return 0;
  return 1;
}

int isfull(){
  if(top == 100) return 0;
  return 1;
}

void push(int x){
  if(isfull() == 0) exit(1);
  stack[top++] = x;
}

int pop(){
  if(isempty() == 0) exit(2);
  return stack[--top];
}



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

using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ldouble = long double;
 
const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;

string res;
ll sum = 0;

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

    for (ll i = 0; i < n; i++)
    {
        ll a, b;
        cin >> a >> b;

        sum += (b - a) + 1;
    }
    println(sum);
}

Measured memory_bytes: 3560
#include<cstdio>

#include<cstring>

#include<iostream>

#include<algorithm>

using namespace std;

typedef long long ll;

const int N=1e6+10;

int n,m,a[4][N];

ll ans,cnt[N];

 

 

int main()

{

//	freopen("in.in","r",stdin);

//	freopen("out.out","w",stdout);

	scanf("%d",&n);

	for(int i=1;i<=3;i++)

		for(int j=1;j<=n;j++)

		scanf("%d",&a[i][j]);

	for(int i=1;i<=3;i++)

		sort(a[i]+1,a[i]+n+1);

	for(int i=1,j=1;j<=n;j++)

	{

		while(a[1][i]<a[2][j]&&i<=n) i++;

		cnt[j]=i-1;

	}

//	for(int i=1;i<=n;i++)

//		printf("cnt=%d\n",cnt[i]);

//改用前缀和（dp思想） 

	for(int i=1;i<=n-1;i++) cnt[i+1]=cnt[i]+cnt[i+1]; 

	for(int i=1,j=1;j<=n;j++)

	{

		while(a[2][i]<a[3][j]&&i<=n) i++;

//		for(int m=1;m<=i-1;m++)

//			ans+=cnt[m] ;

		ans+=cnt[i-1];

	 	

	 } 

 

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

	return 0;

}


Measured memory_bytes: 14720
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define reverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vc = vector<char>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
const ll MOD = 1e9+7;
vi alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z'};


int main(void){
    int N,M;
    cin>>N>>M;
    vvi ab(M,vi(2));
    rep(i,M){
        cin>>ab[i][1];
        cin>>ab[i][0];
        ab[i][0]--;
        ab[i][1]--;
    }
    sort(ab);
    ll count=0;
    ll x=-1;
    rep(i,M){
        if(x>=ab[i][1])continue;
        else{
            x=ab[i][0]-1;
            count++;
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
using pir=pair<int,int>;
int N;  
vector<vector<pir>> v;

bool check(int bit){
  for(int i=0;i<N;i++){
    if(!(bit&(1<<i)))continue;//不親切な人の証言は無視しておけ
    for(pir xy:v[i]){//正直者の証言
      int x=xy.first;
      int y=xy.second;//y=1が正直者、y=0が不親
      if(y==1&&!(bit&(1<<x)))return false;
      if(y==0&&(bit&(1<<x)))return false;
    }
  }
  return true;
}

int main(){
  cin>>N;
  v.resize(N);
  for(int i=0;i<N;i++){
    int A;cin>>A;
    v[i].resize(A);
    for(int j=0;j<A;j++){
      cin>>v[i][j].first>>v[i][j].second;
      v[i][j].first--;//0_indexed;
    }
  }
  int ans=0;
  for(int bit=0;bit<(1<<N);bit++){
    if(check(bit)){
      int cnt=0;
      for(int i=0;i<N;i++){
        if(bit&(1<<i))cnt++;
      }
      ans=max(ans,cnt);
    }
  }
  cout<<ans<<endl;
}

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

int main()
{
    long long n,k,sum=0,ans=0;
    cin>>n>>k;
    
    long long a[n];
    
    for(long long i=0;i<n;i++)
    {
        cin>>a[i];
    }
    
    if(k>n)
    {
        sum=0;
    }
    else
    {
        sort(a,a+n);
        for(long long i=0;i<n-k;i++) 
        {
            sum+=a[i];
        }
    }
    
    cout<<sum<<endl;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)

// Based on official editorial
vector <ll> factorials, inv_factorials;
ll mod=1e9+7;
ll modExp(ll x, ll n)
{
    if (n==0) return 1;
    if (n==1) return x%mod;
    ll ans = modExp(x,n/2);
    ans = (ans*ans)%mod;
    if (n%2) ans*=x;
    return ans%mod;
}

ll modInv(ll a)
{
    return modExp(a, mod-2);
}

void calculate(ll N)
{
    factorials.resize(N+1);
    inv_factorials.resize(N+1);
    factorials[0]=1;
    for (int i=1; i<=N; ++i) factorials[i]=(factorials[i-1]*i)%mod;
    inv_factorials[N]=modInv(factorials[N]);
    for (int i=N-1; i>=0; --i) inv_factorials[i]=((i+1)*inv_factorials[i+1])%mod;
}

ll choose(ll N, ll K)
{
    if (N<0 || K<0) return 0;
    if (K>N) return 0;
    return (((factorials[N]*inv_factorials[N-K])%mod)*inv_factorials[K])%mod;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll K; cin >> K;
    string S; cin >> S;
    ll N=S.length();
    calculate(N+K);
    ll total=S.length()+K;
    /*
    * Total length of resulting string = total
    * N = S.length()
    * S = S_1...S_N (S_i = character at ith position)
    * resulting string T looks like <S_1*>S_1<S_2*>S_2...<S_N*>S_N<*>
    * here <S_i*> denotes inserted characters between S_{i-1} (or start of string) and S_i
    * Length of <S_1*>+...+<S_N*>+<*> = K
    * To count distinct string, let us count number of strings such that S_i is first occurence of 
    * (whichever character is there at S_i) after S_{i-1}.
    * This means <S_i*> cannot contain the character S_i.
    * But <*> at the end of T, can have any character. 
    * This leads to the formula in the editorial
    * Ans for a particular arrangement = 25^( Sum i=1 to N (|<S_i*>|) ) * 26^(K - (Sum i=1 to N (|<S_i*>|)) )
    * Now let's iterate over all possible values for Sum i=1 to N (|<S_i*>|)
    */
    ll ans=0;
    vector <ll> power25(K+1, 1), power26(K+1,1);
    for (int i=1; i<=K; ++i) {
        power25[i]=(power25[i-1]*25)%mod;
        power26[i]=(power26[i-1]*26)%mod;
    }
    for (int i=0; i<=K; ++i) // i = len(<*>) = number of characters after S_N
    {
        // Since i is fixed, since means position of S_N must be already fixed as well.
        // Only the places for rest N-1 characters can be chosen.
        ll waysToSelectPlacesForStringS= choose(N+K-(i+1), N-1);
        ll waysToSelectCharactersInRemainingPlaces = (power25[K-i]*power26[i])%mod;
        ans=(ans+(waysToSelectPlacesForStringS*waysToSelectCharactersInRemainingPlaces)%mod)%mod;
    }
    cout << ans << "\n";
    return 0;
}

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

using namespace std;

using ll = long long;

const string col[2] = {"RB", "GY"};

int H, W, d;
char hoge[1005][1005];
char ans[505][505];

void solve1() {
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (i % 2 == 0 && j % 2 == 0) ans[i][j] = 'R';
            else if (i % 2 == 1 && j % 2 == 0) ans[i][j] = 'G';
            else if (i % 2 == 0 && j % 2 == 1) ans[i][j] = 'Y';
            else ans[i][j] = 'R';
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W >> d;
    int n = H + W - 1;
    for (int i = 0; i < n; i += d) {
        for (int j = 0; j < n; j += d) {
            for (int k = 0; k < d; k++) {
                for (int l = 0; l < d; l++) {
                    if (i + k >= n || j + l >= n) continue;
                    hoge[i + k][j + l] = col[i / d % 2][j / d % 2];
                }
            }
        }
    }

    int geta = W - 1;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            ans[i][j] = hoge[i + j][i - j + geta];
            cout << ans[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define optimize ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long
#define ld long double
#define vi vector<int>
#define si set<int>
#define vc vector<char>
#define vs vector<string>
#define vb vector<bool>
#define vll vector<ll>
#define vd vector<double>
#define lb(v,x) lower_bound(v.begin(), v.end(), x) - v.begin()
#define up(v,x) upper_bound(v.begin(), v.end(), x) - v.begin() - 1
#define pb push_back
#define lp(i,a,b) for(int i = a ; i <= b ; i ++)
#define rlp(i,a,b) for(int i = b ; i >= a ; i --)
#define a_sort(v) sort(v.begin(), v.end())
#define d_sort(v) sort(v.rbegin(), v.rend())
#define vin(v) for(auto &x : v) cin >> x
#define vout(v) for(auto x : v) cout << x << ' ' ; cout << endl
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define pi 3.14159265358979323846264338327950
using namespace std ;
// #define debug

const int MOD = 1E9 + 7 ;
const int N = 1E5 ;

int main() {
    #ifdef debug
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif // debug
    optimize

    int n ; cin >> n ;
    if(n % 1000 == 0) cout << 0 << endl ;
    else cout << ((n / 1000) + 1) * 1000 - n << endl ;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define fastio     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x)     (x).begin() , (x).end()
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
typedef long long int ll;
using namespace std;

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

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


const ll mod = 1e9+7;
const double eps = 1e-9;



void solve(){
    string a,b;
    cin>>a>>b;
    int cnt=0;
    for(int i=0;i<(int)a.size();++i)cnt+=a[i]!=b[i];
    cout<<cnt;
}





int main(){
    fastio
    int test=1;
    while(test--)
        solve();
    return 0;
}


Measured memory_bytes: 3784
#define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

ll X;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> X;
    solve();
}

// 1 <= X <= 10^9
// X は整数である。
// 条件を満たす整数の組 (A,B) が存在する。

// ll X
// A と B を空白区切りで出力せよ。条件を満たす整数の組 (A,B) が複数存在する場合、どれを出力してもかまわない。
void solve(){
    rep(i,200)rep(j,200){
        if(j*j*j*j*j-i*i*i*i*i==X){
            cout<<j<<' '<<i<<endl;
            return;
        }
        if(j*j*j*j*j+i*i*i*i*i==X){
            cout<<j<<' '<<-i<<endl;
            return;
        }
    }
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}


//cout<<""<<endl;
int main(){
  int N,K;cin>>N>>K;
  int ke=0;
  while(N>0){
    N/=K;
    ke++;
  }
  cout<<ke<<endl;
}


Measured memory_bytes: 256
tenboudai,roads_num=map(int,input().split())
t_heights=list(map(int,input().split()))
t_points=list(range(tenboudai))
for i in range(roads_num):
    ai,bi=map(int,input().split())
    ai-=1
    bi-=1
    if t_heights[ai]>t_heights[bi]:
        t_points[bi]=t_points[ai]
    elif   t_heights[bi]>t_heights[ai]:
        t_points[ai]=t_points[bi]
    else:
        t_points[ai]=-1
        t_points[bi]=-1
counter=0
for i in range(tenboudai):
    if t_points[i]==i:
        counter+=1
print(counter)


Measured memory_bytes: 20072
#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using arr = vector<ll>;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;

ll n, h[100100];

int main()
{
  cin >> n;
  REP(i, n) cin >> h[i];

  arr dp(100010, INF);
  dp[0] = 0;
  REP(i, n - 1) {
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
    dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
  }

  cout << dp[n - 1];
  return 0;
}

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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vst = V<str>;
using vch = V<char>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define ci(a) cin>>a
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define cfs(a) cout<<fixed<<setprecision(a)
#define INF 1e16
#define mod 1e9+7


int main() {
  vll v(3);
  FOR(i,0,3){
    cin>>v[i];
  }
  SORT(v);
  ll ans=0;
  ans+=v[0]+v[1];
  co(ans);
}
  

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

int main() {
  
  string N;
  cin >> N;
  
  if (N.at(0) == N.at(1) && N.at(1) == N.at(2)){
    cout << "Yes" << endl;
  } 
  else if (N.at(1) == N.at(2) && N.at(2) == N.at(3)){
	cout << "Yes" << endl;
  }
  else{
	cout << "No" << endl;
  }

 }

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 1000005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9+7;
vector<pair<int,int>>v;
ll dp[2005][2005];
ll solve(int l, int r) {
    if (~dp[l][r])return dp[l][r];
    if (l > r)return dp[l][r] = 0;
    int idx = v.size() - 1 - (r - l);
    pair<int,int>now = v[idx];
    return dp[l][r] =  max(solve(l+1,r) + (ll)abs(now.S-l) * now.F, solve(l,r-1) +(ll)abs(now.S-r) * now.F);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    v.resize(n);
    f(n) {
        cin >> v[i].F;
        v[i].S = i;
    }
    sort(all(v));
    reverse(all(v));
    memset(dp,-1,sizeof(dp));
    cout << solve(0,n-1) << '\n';;
}


Measured memory_bytes: 35128
#include <stdio.h>
#include <string.h>
int main(void){

  char S[20];
  int count=0;
  int max=0;
  int len=0;
  
  scanf("%s",S);
  len=strlen(S);
  
  for(int i=0;i<len;i++){
  	 if(S[i]=='A' || S[i]=='C' || S[i]=='G' || S[i]=='T'){
  		count++;
        if(count>max){
        	max=count;
        }
     }else{
        	count=0;
        }
  }

  printf("%d",max);
  
 return 0;
}

Measured memory_bytes: 128
/*
Author-> Codie_1(Akash)
*/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(n) for(int i=0;i<n;i++)
#define repi(n) for(int i=0;i<n;i++)
#define repj(n) for(int j=0;j<n;j++)
#define repp(n) for(int i=0;i<=n;i++)
#define repab(a,b) for(int i=a;i<b;i++)
#define w(t) int t; cin>>t; while(t--)
#define endl '\n'
#define pi pair<int, int> p
#define pis pair<int, string> p
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vi vector<int> v
#define vl vector<long long> v;
typedef long long ll;

 

int main()
{
	//fast
	int n,k;
	cin>>n>>k;
	int arr[n];
	for(int i=0;i<n;i++) // rep(n) cin>>arr[i];
		cin>>arr[i];
	sort(arr,arr+n);
	int sum=0;
	rep(k) sum+=arr[i];
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> ac(n, 0), pena(n, 0);

    int p_no;
    string judge;
    for(int i = 0; i < m; i++){
        cin >> p_no >> judge;
        p_no--;
        if (ac[p_no]) continue;
        if (judge == "AC"){
            ac[p_no] = 1;
        }
        else{
            pena[p_no]++;
        }
    }
    int AC = 0, PENA = 0;
    for (int i = 0; i < n; i++){
        AC += ac[i];
        if (ac[i]) PENA += pena[i];
    }
    cout << AC << " " << PENA << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <set>
#include <bitset>
typedef long long ll;
typedef long double ld;

#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
vector<ll> par;


int main() {
	string S;
	cin >> S;
	if (S == "AAA" || S == "BBB") {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define mk make_pair
#define pi pair<int, int>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
using namespace std;
int dt[][2]= {{1,0},{-1,0},{0,1},{0,-1},{0,0}};
//typedef pair<int, int> P;
//priority_queue<int, vector<int>, greater<int> > q;
int main()
{
   //IOS;
   bool vis[110];
   int n,k;
   cin >> n >> k;
   MEM(vis,0);
   while(k--){
       int x;
       cin >> x;
       while(x--){
           int bb;
           cin >> bb;
           vis[bb]=1;
       }
   }
   int ans=0;
   rep(i,1,n){
       if(vis[i]==0) ++ans;
   }
   cout<<ans;
}


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

char a[25], buf[100];

int main() {
    int i, cnt = 0;
    int j, k, l, L, M, N;
    scanf("%d", &N);
    scanf("%s", a);
    L = strlen(a);
next:
    while (i++<N) {
        scanf("%s", buf);
        M = strlen(buf);
        for (j=0; j<M; j++)
            for (k=1; j+k*(L-1)<M; k++) {
                for (l=0; l<L && a[l]==buf[j+k*l]; l++);
                if (l>=L) {
                    cnt++;
                    goto next;
                }
            }
    }
    printf("%d\n", cnt);
}



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

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

  int n[3]; cin >> n[0] >> n[1] >> n[2];
  sort(n, n + 3);
  int cnt = 0;
  for(int i = 0; i < 1100000; i++) {
  	if(n[1] == n[2]) {
  		break;
  	}
  	n[0]++;
  	n[1]++;
  	cnt++;
  }
  int dif = n[2] - n[0];
  if(dif % 2 == 0) {
  	cnt += dif / 2;
  }
  else {
  	cnt += (dif + 1) / 2;
  	cnt++;
  }
  cout << cnt << '\n';
	return 0;
}	


Measured memory_bytes: 256
# -*- coding:utf-8 -*-
import numpy as np

n,m = map(int,raw_input().split())

ks_list = []

for i in xrange(m):
	ks_list.append(map(int,raw_input().split()))

#print ('ks_list',ks_list)

p_list = (map(int,raw_input().split()))

cordStates = [[0 for i in range(m)] for j in range(n)]

for i in xrange(m):
    for j in xrange(ks_list[i][0]):
        tmp =  ks_list[i][j+1]-1
        cordStates[tmp][i] = 1

#print ('cordStates', cordStates)

SwStates = [[0 for i in range(n)] for j in range(2**n)]

for i in xrange(2**n):
    SwBin = format(np.left_shift(i, 0), '0'+str(n)+'b')
    SwStates[i]=list(SwBin)
    SwStates[i] = list(map(int, SwStates[i]))  

#print ('SwStates',SwStates)

LightStates = [[0 for i in range(m)]for j in range(2**n)]

#i:len(SwState) j:Swcount k:Lightcount
for i in xrange(1,(2**n)):
    nowStates = [0 for c in range(m)]
    #Ls = [0 for c in range(m)]
    #print('i: %d' % i)
    for j in xrange(n):
        #print('j: %d' % j)
        #print ('SwStates[i][j]:',SwStates[i][j])
        if SwStates[i][j]==1:
            #print ('SwStates[i][j]!=0')
            for k in xrange(m):
                #print('k: %d' % k)
                #print('i',i,'j',j,'k',k)
                #print ('nowStates[k]',nowStates[k])
                #print ('cordStates[j][k]',cordStates[j][k])
                if (nowStates[k]^cordStates[j][k])==1:
                    #Ls[k] = 1
                    nowStates[k] = 1
                else:
                    #Ls[k] = 0
                    nowStates[k] = 0

                #print ('Ls',Ls)

        #nowStates = Ls
    #print ('i',i,'j',j,'nowStates',nowStates)
    LightStates[i] = nowStates

ans = 0
for i in xrange(len(LightStates)):
    if(LightStates[i]==p_list):
        ans+=1;


print ans

Measured memory_bytes: 10672
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int a,b,c,d;

        cin >> a >> b >> c >> d;
        cout << (a - c) * (b - d) << endl;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define pai 3.141592653589793238462643383279

int main(){
  ll K; cin >> K; 
  if(7%K==0){
    cout << 1 << endl; return 0;
  }
  ll now = 7; int cnt = 1; bool can=false;
  rep(i, K){
    now*=10; now%=K; now+=7; now%=K;
    cnt++;
    if(now==0){
       can = true; break;
    }
  }
  if(can) cout << cnt << endl;
  else cout << -1 << endl;
}



Measured memory_bytes: 3632
import java.util.Scanner;

//Matrix-like Computation
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int[][] a = new int[n+1][n+1];
			for(int i=0;i<n;i++)for(int j=0;j<n;j++)a[i][j]=sc.nextInt();
			for(int i=0;i<n;i++)for(int j=0;j<n;j++){a[i][n]+=a[i][j];a[n][i]+=a[j][i];}
			for(int i=0;i<n;i++)a[n][n]+=a[i][n];
			for(int i=0;i<=n;i++){
				for(int j=0;j<=n;j++)System.out.printf("%5d",a[i][j]);
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 0
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

n,m = map(int, input().split())
p = [list(map(str,input().split())) for i in range(m)]

#コンテスト毎に["AC","WA","AC"]を格納する
d = {}

for i in range(m):
    key = p[i][0]
    val = p[i][1]
    if key in d:
        d[key].append(val)
    else:
        d[key] = [val]

# AC数を求める
acNum = 0

for v in d.values():
    if "AC" in v:
        acNum += 1

# WA数求める
waNum = 0

for v in d.values():
    if "AC" in v:
        for i in range(len(v)):
            if v[i] == "AC":
                break
            else:
                waNum += 1
print(acNum, waNum)



Measured memory_bytes: 48020
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <functional>
#include <string>
#include <queue>
#include <iomanip>
using namespace std;

#define rep(i,a,b) for(long long int i=a; i<b; i++ )
#define REP(i,n) rep(i,0,n)


int main()
{
  int N, K; cin >> K >> N;
  vector<int> a(N);
  REP(i, N){ cin >> a[i]; }
  sort( a.begin(), a.end() );

  vector<int> dist(N);
  REP(i, N-1){
    dist[i] = a[i+1] - a[i];
  }
  dist[N-1] = (K-a[N-1]) + a[0];

  int max = *std::max_element(dist.begin(), dist.end());
  cout << K - max << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int r, d, x;
  cin>>r>>d>>x;
  for(int i=0;i<10;++i) {
    x = r*x-d;
    cout<<x<<endl;
  }
}



Measured memory_bytes: 3516
N ,M = map(int,input().split())
cnt = [0]*N
C = [0]*N
C[0] = 1
for i in range(M):
    s, c = map(int,input().split())
    if cnt == 1 and C[s-1] != c:
        cnt[s-1] += 1
    elif cnt[s-1] == 1 and C[s-1] == c:
        pass
    else:
        cnt[s-1] += 1
        C[s-1] = c
if N ==1 and C[0] == 0:
    print(0)
elif N ==1 and M == 0:
    print(0)
elif max(cnt)>=2 or C[0] == 0 :
    print(-1)
else:
    print("".join(map(str,C)))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define rusha scanf("%d",&n);rep(i,1,n)scanf("%d",&a[i]);
#define rushb scanf("%d",&t);while(t--)
#define debug(x) cout<<"LBWNB    "<<x<<"---\n"
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define p() puts("")
#define mem(a,b) memset(a,b,sizeof a)
#define all(x) (x.begin(),x.end())
#define judgef printf("%s\n",f?"Yes":"No")
#define Judgef printf("%s\n",f?"YES":"NO")

using namespace std;
typedef long long ll;
const int mod=998244353;
const int inf=1e9+7;
const int maxn=2e5+10;
char a[maxn];
int main(){
    ll s;
    scanf("%lld",&s);
    printf("%lld\n",s/500*1000+(s%500/5*5));
    return 0;
}

Measured memory_bytes: 256
using System;

namespace oasobi
{
    static class MainClass
    {
        public static void Main()
        {
            string s = Console.ReadLine();
            int counter = 0;
            for(int r = 0; r <= 2; r++)
            {
                if (s[r] == '1')
                {
                    ++counter;
                }
            }

            Console.WriteLine(counter);
        }
    }
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

#define cMOD 1000000007ULL
#define cINF ((1ull<<62)-1)
#define cINFINT ((1<<30)-1)


int main()
{
	int n,m;cin>>n>>m;
	int l = 1; int r = n + 1;
	REP(i,n)
	{
		int a,b;cin>>a>>b;
		++b;
		l = max(l,a);
		r = min(r,b);
	}
	int ans = max( 0, r-l );
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());

		HashSet<Integer> aSet = new HashSet<>();
		HashSet<Integer> bSet = new HashSet<>();

		for (int i = 0; i < m; i++) {

			int a = Integer.parseInt(sc.next());
			int b = Integer.parseInt(sc.next());

			if (b == n){
				aSet.add(a);
			}

			if (a == 1){
				bSet.add(b);
			}
		}

		aSet.retainAll(bSet);

		if (aSet.size() != 0){
			System.out.println("POSSIBLE");
		}else {
			System.out.println("IMPOSSIBLE");
		}
	}
}


Measured memory_bytes: 80204
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>

using namespace std;

inline void InitRand(){
    srand((unsigned int)time(NULL));
}

int main(){
    vector<string> v;

    string output = "abc";
    for(int i=0; i < 100; i++){
        string input;
        input += output[output.size()-1];
        int s = rand()%7+1;
        for(int j=0; j < s; j++) input += 'a'+rand()%26;
        input += output[0];
        cout << "?"+input << endl; fflush(stdout);
        cin >> output;

        v.push_back(input);
        bool is = false;
        for(int j=0; j < v.size(); j++) if(v[j] == output) is = true;
        if(input[input.size()-1] != output[0]) is = true;

        if(is){cout << "!OUT" << endl; fflush(stdout); break;}
        else v.push_back(output);
    }
}

Measured memory_bytes: 1256
#include <iostream>
using namespace std;
int main()
{
    long long int i,n,s=0;
     cin>>n;
    long long int a[n+10],b[n+10],c[n+10],A[n+10],B[n+10],C[n+10];
     for (i=1;i<=n;i++)
        cin>>a[i]>>b[i]>>c[i];
        for (i=1;i<=n;i++) {A[i]=0;
        B[i]=0;
        C[i]=0;
		}
        A[1]=a[1];
        B[1]=b[1];
        C[1]=c[1];
      for (i=2;i<=n;i++)
      {
      	A[i]=max(B[i-1],C[i-1])+a[i];
      	B[i]=max(A[i-1],C[i-1])+b[i];
      	C[i]=max(B[i-1],A[i-1])+c[i];
	  }
	  cout<<max(max(A[n],B[n]),C[n]);
}


Measured memory_bytes: 4992
#pragma warning(disable: 4996)
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <sstream>
#include <fstream>
#include <math.h>
#include <algorithm>
#include <map>

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

int main() {
    int n;
    cin >> n;
    map<string,int> mp;//各文字列に対して数字を持つリストを作れる(一個目の要素をキーにしてそこに二個目のデータの方を入れる)
    //unordered_mapにすれば順番通りにキーが並んでいるとは限らないが、計算が早くなる
    rep(i, n) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());//ソートはこうやってできる
        mp[s]++;
    }
    ll ans = 0;
    for (auto p : mp) {//autoは型を指定する必要はない？vectorとかmapで使える？
        int cnt = p.second;
        ans += (ll)cnt * (cnt - 1) / 2;//(ll)を計算のところに付ければ掛け算でのオーバーフローを防げる。
    }
    cout << ans << endl;
   
    return 0;
}

Measured memory_bytes: 10912