akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#define mm(a,x) memset(a,x,sizeof(a))
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0)
#define ll long long
using namespace std;
int main(void)
{
    sync;
    ll x,k,d;
    cin>>x>>k>>d;
    ll c=x/d;
    if(k<=abs(c))
    {
        cout<<(x>0?abs(x-k*d):abs(x+k*d))<<endl;
        return 0;
    }
    k-=abs(c);
    x-=c*d;
    if(k&1)
        cout<<(x>0?abs(x-d):abs(x+d))<<endl;
    else
        cout<<abs(x)<<endl;
    return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
   int a, b, c;
   cin >> a >> b >> c ;
   if (a != b && a != c ){
        cout << a << endl ;
   }else if (b != c && b != a ){
        cout << b << endl;
   }else if (b != c && c != a ){
        cout << c << endl ;
   }

   return 0;

}


Measured memory_bytes: 256
/*
[dp] Q - Flowers
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 2e5;
const ll INF = 1e18;

template <typename T>
class RMQ {
public:
    int n;
    vector<T> dat;
    void init(int _n);
    void update(int k, T a);
    T query(int a, int b);

private:
    T query(int a, int b, int k, int l, int r);
};

template <typename T>
void RMQ<T>::init(int _n) {
    n = 1;
    while (n < _n) {
        n <<= 1;
    }
    dat.reserve(2 * n - 1);
    for (int i = 0; i < 2 * n - 1; i++) {
        dat[i] = INF;
    }
    return;
}

template <typename T>
void RMQ<T>::update(int k, T a) {
    k += n - 1;
    dat[k] = a;
    while (k > 0) {
        k = (k - 1) / 2;
        dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
    return;
}

template <typename T>
T RMQ<T>::query(int a, int b) {
    return query(a, b, 0, 0, n);
}

// [a, b), [l, r)
template <typename T>
T RMQ<T>::query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) {
        return INF;
    }
    if (a <= l && r <= b) {
        return dat[k];
    }
    return min(query(a, b, k * 2 + 1, l, (l + r) / 2),
               query(a, b, k * 2 + 2, (l + r) / 2, r));
}

int N;
int h[MAX_N], a[MAX_N];
RMQ<ll> t;

ll solve() {
    t.init(N + 1);
    t.update(0, 0);

    for (int i = 0; i < N; i++) {
        ll m = t.query(0, h[i]);
        t.update(h[i], m - a[i]);
    }

    return -t.query(0, N + 1);
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF (2147483647)
#define MOD (int)(998244353) 

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << ' ' << y << ' ' << z << '\n';
    return 0;
}

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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

ll a, b, c, d;
unordered_map<ll, ll> mm;
ll dfs(ll n){
    if(n==0) return 0;
    if(n==1) return d;
    if(mm[n]) return mm[n];
    ll ret=LLONG_MAX;

    if(log10(n)+log10(d)<18) ret=min(ret, n*d);

    ret=min(ret, d*(n-n/2*2)+a+dfs(n/2));
    if(n%2!=0) ret=min(ret, d*((n/2+1)*2-n)+a+dfs(n/2+1));

    ret=min(ret, d*(n-n/3*3)+b+dfs(n/3));
    if(n%3!=0) ret=min(ret, d*((n/3+1)*3-n)+b+dfs(n/3+1));

    ret=min(ret, d*(n-n/5*5)+c+dfs(n/5));
    if(n%5!=0) ret=min(ret, d*((n/5+1)*5-n)+c+dfs(n/5+1));

    mm[n]=ret;
    return ret;
}

int main(){
    int t;
    cin>>t;
    rep(k, t){
        ll n;
        cin>>n>>a>>b>>c>>d;
        mm.clear();
        cout<<dfs(n)<<endl;
    }
    return 0;
}


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


class Program {

	const long mod = 1000000007;
	//public static int[] max;

	static void Main(string[] args) {

		char[] cs = new char[] { ' ', ',' };
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//int val = int.Parse(Console.ReadLine());
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//int n = vals[0];
		//string res="";

		//int y = vals[0];
		//int x = vals[1];

		int val = int.Parse(Console.ReadLine());

		int[] res = new int[26];

		int A = 'a';

		string str = Console.ReadLine();
		for (int i = 0; i < str.Length; i++) {
			res[str[i] - A]++;
		}

		for (int k = 1; k < val; k++) {
		int[] mo = new int[26];
			str = Console.ReadLine();

			for (int i = 0; i < str.Length; i++) {
				mo[str[i] - A]++;
			}

			for (int i = 0; i < 26; i++) {
				res[i] = Math.Min(res[i], mo[i]);
			}


		}


		string r = "";
		for (int i = 0; i < 26; i++) {
			while (res[i] > 0) {
				r += "" + (char)( i + A );
				res[i]--;
			}
			
		}


		Console.WriteLine(r);


		return;
	}



	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryl(string[] str) {
		long[] nums = new long[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}



	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for (int i = 0; i < str.Length; i++) { re[i] = str[i].ToString(); }
		return re;
	}

}

Measured memory_bytes: 13140
#include <iostream>

using namespace std;
#define ll long long
#define N  1000000007
int main() 
{
 
	ll int r,c;
	cin>>r>>c;
	char input[r][c];
	for(int i=0;i<r;i++)
	{
	    for(int j=0;j<c;j++)
	    {
	        cin>>input[i][j];
	    }
	}
 
   ll int path[r][c];
   path[0][0]=1;
   for(int i=1;i<r;i++)
   {
       path[i][0]=0;
       if(input[i][0]=='.'&&path[i-1][0])
       {
           path[i][0]=1;
       }
   }
    for(int i=1;i<c;i++)
   {
       path[0][i]=0;
       if(input[0][i]=='.'&&path[0][i-1])
       {
           path[0][i]=1;
       }
   }
   for(int i=1;i<r;i++)
   {
       for(int j=1;j<c;j++)
       {   
           if(input[i][j]=='.')
           path[i][j]=(path[i][j-1]%N+path[i-1][j]%N)%N;
           else
           path[i][j]=0;
       }
   }
   	 
  cout<<path[r-1][c-1];
}


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

using namespace std;

typedef long long ll;

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

  vector<ll> A(N);
  for(ll i=0; i<N; i++) cin >> A[i];

  ll stock = 0;
  ll money = 1000;
  for(ll i=0; i<N; i++){
    if (i == N-1){
      money += A[i] * stock;
      break;
    }  

    if(A[i+1] > A[i] && stock == 0){
      stock += money / A[i];
      money -= stock * A[i];
    }
    if(A[i+1] < A[i] && stock != 0){
      money += A[i] * stock;
      stock = 0;
    }
  }

  cout << money << endl;
  return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(N, vector<int>(N));
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a][b] = G[b][a] = 1;
    }
    vector<int> v(N);
    for (int i = 0; i < N; i++)
        v[i] = i;

    int res = 0;
    do {
        if (v[0] != 0) break;
        bool flag = true;
        for (int i = 0; i < N - 1; i++) {
            if (G[v[i]][v[i + 1]] == 0) {
                flag = false;
                break;
            }
        }
        if (flag) res++;
    } while (next_permutation(v.begin(), v.end()));

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
using namespace std;
 
int main() {
    fast();
    // ll t;
    // cin>>t;
    // while(t--)			
    // {
               
    // }
    string s;
    cin>>s;
    string a="ABC",b="ARC";
    if(s==a)
    cout<<b;
    else
    cout<<a;
}


Measured memory_bytes: 3640
N, M = map(int, input().split())
AB = []
CD = []
IMF = 1001001001

for i in range(N):
    AB.append(list(map(int, input().split())))

for i in range(M):
    CD.append(list(map(int, input().split())))

ans = [0] * N
for i in range(N):
    a, b = AB[i]
    t = IMF
    for j in range(M):
        c, d = CD[j]
        s = abs(a-c) + abs(b-d)
        if s < t:
            t = s
            ans[i] = j+1

print(*ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		if(b%a == 0) System.out.println(a+b);
		else System.out.println(b - a);
	}
}

Measured memory_bytes: 21716
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BPapersPlease solver = new BPapersPlease();
        solver.solve(1, in, out);
        out.close();
    }

    static class BPapersPlease {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
                if (a[i] % 2 == 0 && !(a[i] % 3 == 0 || a[i] % 5 == 0)) {
                    out.println("DENIED");
                    return;
                }
            }
            out.println("APPROVED");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



Measured memory_bytes: 22868
N, M = list(map(int, input().split()))
p = [0]*M
S = [0]*M

for i in range(M):
    inp = input().split()
    p[i], S[i] = int(inp[0]), inp[1]

is_ac = [False]*N
wa_cnt = [0]*N

for i in range(M):
    if S[i] == 'AC':
        is_ac[p[i]-1] = True
    else:
        if not is_ac[p[i]-1]:
            wa_cnt[p[i]-1] += 1

ac_cnt = 0
penalty = 0

for j in range(N):
    if is_ac[j]:
        ac_cnt += 1
        penalty += wa_cnt[j]

print("{} {}".format(ac_cnt, penalty))

Measured memory_bytes: 21380
#include<bits/stdc++.h>
using namespace std;
#define N 1000003
#define LL long long
#define mod 998244353

int n,K,Q;
int g[N];
char s[10];

inline int read(){
	int X=0,w=0;
	char ch=0;
	while (ch<'0' || ch>'9')
	  w|=ch=='-',ch=getchar();
	while (ch>='0' && ch<='9')
	  X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
	return w ? -X : X;
}

int main(){
	n=read();K=read();Q=read();
	for (int i=1;i<=Q;i++){
		int u=read();
		g[u]++;
	}
	for (int i=1;i<=n;i++){
		if (K-Q+g[i]>0) puts("Yes");
		  else puts("No");
	}
	return 0;
}

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

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

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

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

ll base_count(ll n, ll base){
  ll r;
  ll count = 0;
  while(n != 0){
    r = n % base;
    count += r;
    n = (n - r) / base;
  }
  
  return count;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll n;
  cin >> n;
  
  ll min_count = 114514;
  REP(i, n+1){  
    min_count = min(min_count, \
      (base_count(i, 6) + base_count(n-i, 9)));
  }
  
  cout << min_count << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
const int MAX = 10005;
int c[MAX];
int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	int *a, *b;
	cin >> n;
	a = new int[n + 1];
	b = new int[n + 1];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		++c[a[i]];
	}
	int i;
	for (i = 0; i <= MAX; ++i)
	{
		if (c[i])
		{
			--c[i];
			cout << i;
			break;
		}
	}
	for (i = 0; i <= MAX; ++i)
	{
		while (c[i])
		{
			--c[i];
			cout << ' ' << i;
		}
	}
	cout << endl;
	return 0;
}

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

int main(int argc, const char * argv[]) {
    // insert code here...
    int N;
    cin >> N;
    
    int x = 0, y = 0;
    
    for (int i = 1; i <= N; i++) {
        x += 800;
        if (i % 15 == 0) y += 200;
    }
    
    cout << x - y << endl;
    
    return 0;
}


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

  int N , M ;
  cin >> N >> M ;
  int A = 1 ;
  int ans = 0 ;
  if( N == 1 ){	
    cout << M << endl ;
    return 0 ;
  }
  while(M > ( N - 1 )*A ){
	if( ( M + A - N*A )%A == 0 ) ans = A ;
    A++ ;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
// const ll INF = 1000000000000000000LL;

int main(){
	int n;
	cin >> n;
	vector<string> input(n);
	rep(i,n) cin >> input[i];
	int table[n][26];
	rep(i,n){
		rep(j,26){
			table[i][j]=0;
		}
	}
	rep(i,n){
		rep(j,input[i].size()){
			// cout << input[i][j]-97 << endl;
			table[i][input[i][j]-97]++;
		}
	}
	string ans = "";
	rep(i,26){
		int nin = INF;
		rep(j,n){
			nin = min(nin,table[j][i]);
		}
		rep(j,nin)
			ans+=char(i+97);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import math
a, b, x = map(int, input().split())

def fm(a, b, x):
    return (2*x / (a**2)) - b

def fn(a, b, x):
    return 2*x / (a*b)

if fm(a, b, x) >= 0:
    ans = math.degrees(math.atan((b - fm(a, b, x)) / a))
else:
    ans = math.degrees(math.atan(b / fn(a, b, x)))

print(ans)

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();
        StringBuilder sb = new StringBuilder();
        boolean same = false;
        for (int i = 0; i < s1.length(); i++) {
            sb.setLength(0);
            sb.append(s1.substring(i)).append(s1.substring(0, i));
            if (sb.toString().compareTo(s2) == 0) {
                same = true;
                break;
            }
        }
        if (same)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
        }
        for(int i=0; i<n; i++){
            b[i] = sc.nextInt();
        }
        long suma = 0, sumb = 0;
        for(int i=0; i<n; i++){
            if(a[i] > b[i]){
                sumb += a[i] - b[i];
            }else{
                suma += (b[i] - a[i]) / 2;
            }
        }
        if(suma >= sumb){
            System.out.println("Yes");        
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 44240
#include <bits/stdc++.h>
#define rep(i, n) for (long i = 0; i < (n); i++)
using namespace std;
int main()
{
    long n;
    cin >> n;
    vector<long> a(n);
    long all = 0;
    long ans[n]={0};
    rep(i, n){
        cin >> a[i];
        all += a[i];
        if (i % 2 != 0)
            ans[0] += a[i];
    }
    ans[0] = all - 2 * ans[0];
    cout << ans[0] <<' ';
    rep(i,n-1){
        ans[i + 1] = 2 * a[i] - ans[i];
        cout << ans[i + 1] << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 2816
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <limits>

using namespace std;

int N;
size_t MASK;
vector<vector<int>> v;
vector<int> dp;

size_t get_mask()
{ 
  size_t mask = 0;
  for (int i = 0; i < N; ++i)
  { 
    mask |= (1 << i);
  }
  return mask;
}

inline size_t add(size_t res, size_t delta)
{ 
  return (res + delta) % 1000000007;
}

size_t solution(int i, size_t mask = 0)
{ 
  size_t res = 0; 
  for (int j = 0; j < N; ++j)
  { 
    if (v[i][j] && !(mask & (1<<j)))
    { 
      const size_t new_mask = mask | (1<<j);
      if (new_mask == MASK)
      { 
        res = add(res, 1);
        break;
      }
      if (dp[new_mask] == -1)
      { 
        dp[new_mask] = solution(i+1, new_mask);
      }
      res = add(res, dp[new_mask]);
    }
  }
  return res;
}


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

  cin >> N;

  MASK = get_mask();

  v = vector<vector<int>>(N, vector<int>(N));
  dp = vector<int>(1<<N, -1);

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

  cout << solution(0);

  return 0;
}

Measured memory_bytes: 8448
#include<stdio.h>

int call(int n)
{
	int i,x;
	for (i = 1; i <= n; i++){
		x = i;
		while (1){
			if (x % 3 == 0){
				printf(" %d", i);
				break;
			}
			while (x >= 1){
				if (x % 10 == 3){
					printf(" %d", i);
					break;
				}
				else
					x /= 10;
			}
			break;
		}
	}
	printf("\n");
}

int main()
{
	int n;
	while (1){
		scanf("%d", &n);
		if (3 <= n&&n <= 10000)
			break;
	}
	call(n);
	return 0;
}

Measured memory_bytes: 600
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];
		for(int i = 0 ; i<n; i++){
			d[i] = sc.nextInt();
		}
		long res = 0;
		for(int i = 0 ; i<n-1; i++){
			for(int j = i+1; j<n; j++){
				res+=d[i]*d[j];
			}
		}
		System.out.println(res);
	}
}


Measured memory_bytes: 23764
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N,K=mi()
    P=list(mi())
    C=list(mi())

    ans = -INF
    for i in range(N):
        start = i + 1 
        stack = [start]
        score_his = [0]
        scores = 0
        depth = 1
        seen = {}
        while stack:
            if depth > K: break
            current = stack.pop()
            
            if current in seen:
                loop_start_depth = seen[current]
                loop_end_depth = depth - 1 
                loop_scores = score_his[-1] - score_his[loop_start_depth-1]
                loop_len = loop_end_depth - loop_start_depth + 1
                if loop_scores < 0: break

                # print(start,score_his)
                # print(loop_start_depth,loop_end_depth,loop_scores,loop_len)
                
                rest_count = K - depth + 1
                available_loop_count = rest_count // loop_len
                res1 = (available_loop_count-1) * loop_scores + scores

                # print("a",rest_count,available_loop_count,res1)
                
                res2 = res1
                rest_loop_len = rest_count % loop_len + loop_len

                # print("b",rest_loop_len)
                ress = [res1,res2]
                for j in range(rest_loop_len):
                    score = C[P[current-1]-1]
                    res2 += score
                    ress.append(res2)
                    current = P[current-1]

                # print("ress",ress)
                score_his.append(max(ress))

                break

            
            score = C[P[current-1]-1]
            scores += score
            score_his.append(scores)

            seen[current] = depth
            stack.append(P[current-1])

            depth += 1
        
        ans = max(ans,max(score_his[1:]))
    
    print(ans)





if __name__ == "__main__":
    main()

Measured memory_bytes: 220704
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double EPS = 1e-10;
const int INF = 2147483647;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int h, w;
int a[26];
int one = 0;
int two = 0;

int main()
{
	cin >> h >> w;

	if (h % 2 && w % 2) one = 1;

	if (h % 2) {
		two += (w / 2);
	}

	if (w % 2) {
		two += (h / 2);
	}


	for(int i=0;i<h;i++)
		for (int j = 0;j < w;j++) {
			char c;
			cin >> c;
			a[c - 'a']++;
		}

	for (int i = 0;i < 26;i++) {
		int t = a[i] % 4;
		if (t == 1) {
			one--;
		}
		if (t == 2) {
			two--;
		}
		if (t == 3) {
			one--;
			two--;
		}

	}

	if (one < 0 || two < 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 n, d;
    cin >> n >> d;

    int count = 0;
    long long x, y;
    for(int i = 0; i < n; i++) {
        cin >> x >> y;
        if(x*x + y*y <= d*d) count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <math.h>

int main(int argc, char **argv){
	int a,b;
	char op;

	for(;;){
		// Input
		scanf("%d %c %d",&a, &op, &b);
		// Finish Check
		if( op == '?' ){
			break;
		}
		// Output
		switch(op){
		case '+':
			printf("%d\n",a+b);
			break;
		case '-':
			printf("%d\n",a-b);
			break;
		case '*':
			printf("%d\n",a*b);
			break;
		case '/':
			printf("%d\n",a/b);
			break;
		default:
			// Unknown Case
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {

  int N,M;cin>>N>>M;
  
  if(N==M){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

int main()
{
	int a[1000];
	int i = 0;
	int x;
	cin>>x;
	while (i < x)
	{
		int k;
		cin>>k;
		a[i] = k;
		i++;
	}
	for (int j = i - 1; j>=0; j--)
		if (j != 0)
			cout << a[j] <<" ";
		else
			cout << a[j] ;
	cout<< endl;
	return 0;
}

Measured memory_bytes: 3096
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

vector< vector<int> > cnt(26);

int main(){
  int n,f,a,b,t;
  cin >> n;
  string s;
  cin >> s;
  for(int i = 0; i < s.length(); i++){
    cnt[s[i] - 'a'].push_back(i);
  }
  int ans = 0;
  for(int i = 0; i < 26; i++){
    f = cnt[i].size();
    for(int j = 0; j < f; j++){
      a = cnt[i][j];
      for(int k = f-1; k > j  && cnt[i][k]-a > ans; k--){
        b = cnt[i][k];
        if(n-b <= ans) continue;
        t = 0;
        for(int m = 0; a + m < b; m++){
          if(s[a+m] == s[b+m]) t++;
          else break;
        }
        if(t > ans) ans = t;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long int GCD(long long int x, long long int y) {
    if(x<y) {
        swap(x, y);
    }
    
    if(y==0) {
        return x;
    }
    
    return GCD(y, x%y);
}

int main() {
    int N;
    cin >> N;
    
    long long int ans=1;
    for(int n=0; n<N; n++) {
        long long int T;
        cin >> T;
        
        ans /= GCD(T, ans);
        ans *= T;
    }
    
    cout << ans << endl;


    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

int main(){
    int n;
    cin >> n;
    cout << ((n-1)/111+1)*111 << endl;
    return 0;
}

Measured memory_bytes: 256
#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++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=100005;
int n,q;
ll m;
int a[maxn],b[maxn],c[maxn];
bool bad[maxn],ok;
namespace Dsu{
	int f[maxn];
	void init(){
		rep(i,n)f[i]=i;
	}
	int find(int x){
		return f[x]==x?x:f[x]=find(f[x]);
	}
};

int main(){
	scanf("%d%lld%d",&n,&m,&q);
	Dsu::init();
	rep(i,q){
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
		if(c[i]==0){
			int u=Dsu::find(a[i]),v=Dsu::find(b[i]);
			Dsu::f[u]=v;
		}
	}
	ok=true;
	rep(i,q)if(c[i]==1){
		int u=Dsu::find(a[i]),v=Dsu::find(b[i]);
		if(u==v){
			puts("No");
			return 0;
		}
		bad[u]=bad[v]=true;
		ok=false;
	}
	int cnt=0,tot=0;
	rep(i,n)if(Dsu::find(i)==i){
		tot++;
		if(!bad[i])cnt++;
	}
	if(tot==2&&cnt==0){
		puts("No");
		return 0;
	}
	if(!ok&&m==n-1){
		puts("No");
		return 0;
	}
	if(m<=n-tot+1LL*tot*(tot-1)/2)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N;
string S;

int main() {
	cin >> N;
	cin >> S;
	
	map<char, char> mm;
	mm['B'] = 'W';
	mm['W'] = 'B';
	REP(i, S.size()) S[i] = mm[S[i]];
	
	ll ans;
	if (S[0] == 'B' || S[S.size() - 1] == 'B') ans = 0;
	else {
		ll cnt = 0;
		ans = 1;
		
		REP(i, S.size()) {
			if (S[i] == 'W') {
				if (cnt % 2 == 0) cnt++;
				else if (cnt == 0) ans = 0;
				else {
					ans = ans * cnt % MOD;
					cnt--;
				}
			}
			else {
				if (cnt % 2 == 1) cnt++;
				else if (cnt == 0) ans = 0;
				else {
					ans = ans * cnt % MOD;
					cnt--;
				}
			}
		}
		
		if (cnt != 0) ans = 0;
		
		// N!
		FOR(i, 1, N + 1) ans = ans * i % MOD;
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define all(a) a.begin(), a.end()
#define sz(a) a.size()
using namespace std;

ll n, a[200001];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("A.txt", "r", stdin);
    #endif
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a, a+n);
    int nn=n-2;
    ll ans = a[n-1];
    for(int i=n-2; i>=0; i--){
        if(nn--) ans += a[i];
        else break;
        if(nn--) ans += a[i];
        else break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5168
S=input()
l = len(S)

a=0
for i in range(l):
    if i%2 == 0:
        if S[i] == '1':
            a += 1
    else:
        if S[i] == '0':
            a += 1

b=0
for i in range(l):
    if i%2 == 0:
        if S[i] == '0':
            b += 1
    else:
        if S[i] == '1':
            b += 1

print(min(a,b))


Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <valarray>
#include <utility>

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP2(i,m,n) for(int i=m+1;i<=(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<=(int)(n);i++)
#define INF 2000000000
#define INFLL 9000000000000000000
#define MOD 1000000007

typedef long long int ll;

ll A = 0;
ll B = 0; //A*Bが解

int main() {
    int n, m;
    cin >> n >> m;
    ll x[n], y[m];

    rep(i, n) {
        cin >> x[i];
        while (x[i] < 0) {
            x[i] += MOD;
        }
    }

    rep(i, m) {
        cin >> y[i];
        while (y[i] < 0) {
            y[i] += MOD;
        }
    }

    for (ll k = 1; k <= n; ++k) {

        A += (2 * k - n - 1) * x[k - 1];

        if (A >= MOD) {
            A %= MOD;
        } else if (A < 0) {
            while (A < 0) {
                A += MOD;
            }
        }

    }

    for (ll k = 1; k <= m; ++k) {

        B += (2 * k - m - 1) * y[k - 1];

        if (B >= MOD) {
            B %= MOD;
        } else if (B < 0) {
            while (B < 0) {
                B += MOD;
            }
        }

    }

    ll P = A*B;
    if (P >= MOD) {
        P %= MOD;
    } else if (P < 0) {
        while (P < 0) {
            P += MOD;
        }
    }

    cout << P << endl;
    return 0;
}



Measured memory_bytes: 1792
n, m = map(int, input().split())
a = list(map(int, input().split()))
select = 0
a.sort(reverse=True)
for i in range(m):
    if a[i]/sum(a) >= 1/(4*m):
        select = 1
    else:
        select = 0

if select == 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9176
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define N 300005
#define vi vector<int>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int h,w;
   cin>>h>>w;
   if(h==1 || w==1)
   {
       cout<<1<<endl;
       return 0;
   }
   if(w & 1)
   {
       if(h & 1)
       {
           int ans=0;
           ans+=((h/2 + 1)* (w/2 + 1));
           ans+=((h/2) * (w/2));
           cout<<ans<<endl;
       }
       else
       {
           int ans=0;
           ans+=((h/2 )* (w/2 + 1));
           ans+=((h/2) * (w/2));
           cout<<ans<<endl;
       }
   }
   else
   {
       cout<<h*(w/2)<<endl;
   }

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#define sqr(a) ((a)*(a))
using namespace std;

int X, Y, mod = 1e9+7;
int64_t tmp, res;

int64_t pw(int a,int n)
{
    if (n == 1) return a;
    tmp = pw(a, n>>1);
    return n&1 ? tmp * tmp % mod * a % mod : tmp * tmp % mod;
}
int64_t C(int n, int k)
{
    res = 1;
    for(int i=0; i<k; ++i) res = res * (n-i) % mod * pw(i+1, mod-2) % mod;
    return res;
}
int main()
{

    cin >> X >> Y; int64_t ans = 0;
    for(int a=X&1; a<=X; a+=2) if (a+a + (X-a)/2 == Y)
        ans = (ans + C((a+X)/2, a)) % mod;
    cout << ans;
}


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

using namespace std;

template<typename T>
class LazySegTree {
public:
    explicit LazySegTree(int n, T init, T def) : N(calcN_(n)), def(def) {
        mVal.assign(2*N+1, init);
        mLazy.assign(2*N+1, 0);
        mDirty.assign(2*N+1, 0);
    }
    void update(int l, int r, T value){
        updateImpl_(l, r, value, 0, 0, N);
    }
    T get(int l, int r){
        return getImpl_(l, r, 0, 0, N);
    }
private:
    int calcN_(int n){
        int res = 1;
        while(res < n) res *= 2;
        return res;
    }
    void updateImpl_(int l, int r, T value, int idx, int rangeL, int rangeR){
        eval_(idx, rangeL, rangeR);
        if(r <= rangeL || rangeR <= l) return;
        if(l <= rangeL && rangeR <= r){
            setLazy_(idx, value);
            eval_(idx, rangeL, rangeR);
        } else {
            int rangeM = (rangeL+rangeR)/2;
            updateImpl_(l, r, value, 2*idx+1, rangeL, rangeM);
            updateImpl_(l, r, value, 2*idx+2, rangeM, rangeR);
            mVal[idx] = operate_(mVal[2*idx+1], mVal[2*idx+2]);
        }
    }
    void setLazy_(int idx, T value){
        mLazy[idx] += value;
        mDirty[idx] = 1;
    }
    T getImpl_(int l, int r, int idx, int rangeL, int rangeR){
        if(r <= rangeL || rangeR <= l) return def;
        eval_(idx, rangeL, rangeR);
        if(l <= rangeL && rangeR <= r) return mVal[idx];
        int rangeM = (rangeL+rangeR)/2;
        T a = getImpl_(l, r, 2*idx+1, rangeL, rangeM);
        T b = getImpl_(l, r, 2*idx+2, rangeM, rangeR);
        return operate_(a, b);
    }
    void eval_(int idx, int rangeL, int rangeR){
        if(!mDirty[idx]) return;
        mVal[idx] += (rangeR - rangeL) * mLazy[idx];
        if(idx < N-1){
            setLazy_(2*idx+1, mLazy[idx]);
            setLazy_(2*idx+2, mLazy[idx]);
        }
        mLazy[idx] = 0;
        mDirty[idx] = 0;
    }
    T operate_(T a, T b) const { return a + b; }
    const int N;
    const T def;
    vector<T> mVal; 
    vector<T> mLazy;
    vector<int> mDirty;
};

int main(){
    int n, q;
    while(cin >> n >> q){
        LazySegTree<long long> seg(n, 0, 0);
        for(int i=0;i<q;i++){
            int c; cin >> c;
            if(c == 0){
                int s, t, x; cin >> s >> t >> x;
                seg.update(s-1, t, x);
            } else {
                int s, t; cin >> s >> t;
                cout << seg.get(s-1, t) << endl;
            }
        }
    }
}



Measured memory_bytes: 7868
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

using namespace std;

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

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

	//~read
	int n, m;
	cin >> n >> m;
	string s, t;
	cin >> s >> t;
	//~solve
	ll len = 1ll * n * m / __gcd(n, m);
	for (int i = 0; i < n; i++)
	{
		ll pos1 = 1ll * i * (len / n) + 1;
		if ((pos1 - 1) % (len / m) == 0)
		{
			ll j = (1ll * (pos1 - 1) / (len / m));
			if (j < m && s[i] != t[j])
			{
				cout << -1 << endl;
				return 0;
			}
		}
	}
	cout << len << endl;

	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N, K, Q;
ll A[2010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> K >> Q;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  ll ans = 1LL << 60;
  for (int i = 0; i < N; i++) {
    vector<ll> mins;
    priority_queue<ll, vector<ll>, greater<ll>> que;
    for (int j = 0; j < N; j++) {
      if (A[j] < A[i]) {
        while (que.size() >= K) {
          mins.emplace_back(que.top());
          que.pop();
        }
        que = priority_queue<ll, vector<ll>, greater<ll>>();
      } else {
        que.emplace(A[j]);
      }
    }
    while (que.size() >= K) {
      mins.emplace_back(que.top());
      que.pop();
    }
    sort(mins.begin(), mins.end());
    if (mins.size() >= Q) ans = min(ans, mins[Q-1] - A[i]);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int a,b,c,x,y,t,res=0;
  cin >> a >> b >> c >> x >> y;
  if(x<y){
    t=x; x=y; y=t;
    t=a; a=b; b=t;
  }
  if(a+b<=2*c)
    res=a*x+b*y;
  else
    res=2*c*y+min(a,2*c)*(x-y);
  cout << res << endl;
  return 0;
}

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

inline void Disp(int a, int b)
{
	for (int i = 0; i < a; i++)
	{
		for (int j = 0; j < b; j++)
		{
			cout << "#";
		}
		cout << endl;
	}
	cout << endl;
}

int main(void)
{
	int a, b;

	while (true)
	{
		cin >> a >> b;
		if (a == 0 && b == 0) break;
		Disp(a, b);
	}
	return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
int main(){
int A,B,C;
  cin>>A>>B>>C;
  if(A==5){
if(B==5 && C==7){
cout<<"YES"<<endl;
}
else if(B==7 && C==5){
cout<<"YES"<<endl;
}
else{
cout<<"NO"<<endl;
}
  }
  else if(A==7){
if(B==5 && C==5){
cout<<"YES"<<endl;
}
else {
cout<<"NO"<<endl;
}
  }
return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
public class Main{
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		long n = sc.nextInt();
		long mod = 1000000007;
		long ans = (powmod(10,n)-powmod(9,n)*2+powmod(8,n))%mod;
		ans = (ans + mod) % mod;
		System.out.println(ans);
	}
	public static long powmod(long x, long n){
		long mod = 1000000007;
      	long res = 1;
      
		for(long i = 0; i < n; i++){
			res = res * x % mod;
		}
		return res;
	}
}

Measured memory_bytes: 35684
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());

        var trump = new int[4,13];

        string str;
        int num = 0;

        for (int i = 0; i < n; i++)
        {
            str = Console.ReadLine();
            var strer = str.Split(' ');
            num = int.Parse(strer[1]) - 1;

            if (str.Contains("S"))
            {
                trump[0,num] = 1;
            }
            else if (str.Contains("H"))
            {
                trump[1, num] = 1;
            }
            else if (str.Contains("C"))
            {
                trump[2, num] = 1;
            }
            else if (str.Contains("D"))
            {
                trump[3, num] = 1;
            }
        }

            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 13; j++)
                {
                    if (i == 0 && trump[0,j] == 0)
                    {
                        Console.WriteLine($"S {j + 1}");
                    }
                    else if (i == 1 && trump[1, j] == 0)
                    {
                        Console.WriteLine($"H {j + 1}");
                    }
                    else if (i == 2 && trump[2, j] == 0)
                    {
                        Console.WriteLine($"C {j + 1}");
                    }
                    else if (i == 3 && trump[3, j] == 0)
                    {
                        Console.WriteLine($"D {j + 1}");
                    }
                }
            }
        
       
    }
}


Measured memory_bytes: 15948
"""
最大公約数を求める
最大公約数の約数を列挙
素数かどうかを判定
"""

import math

def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

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

def is_prime(n):
    """素数判定関数

    Arguments:
        n {[type]} -- [description]

    Returns:
        [type] -- [description]
    """
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return True

A, B = map(int,input().split())

gcd = max_yakusu(B,A)
numbers = divisor(int(gcd))
ans = 0
for i in numbers:
    if is_prime(i):
        ans += 1
print(ans)

Measured memory_bytes: 3956
import math
A, B, H, M = map(int, input().split())
sitaH = (H*60+M) / 720 * 2 * math.pi
sitaM =  M/60 * 2 * math.pi

posXH = A * math.cos(sitaH)
posYH = A * math.sin(sitaH)
posXM = B * math.cos(sitaM)
posYM = B * math.sin(sitaM)

delX = posXH - posXM
delY = posYH - posYM

d = (delX*delX + delY*delY)**(1/2)
print(d)

Measured memory_bytes: 9580
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};
string Ans[2] = {"Yes", "No"};
string ANS[2] = {"YES", "NO"};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

int Root(int x, vector<int> &root)
{
    if (x == root[x]) return x;
    return root[x] = Root(root[x], root);
}

void Merge(int v, int u, vector<int> &root, vector<int> &sz)
{
    v = Root(v, root), u = Root(u, root);
    if (v == u) return;
    if (sz[v] < sz[u])
    {
        sz[u] += sz[v];
        root[v] = u;
    }
    else
    {
        sz[v] += sz[u];
        root[u] = v;
    }
}

int ok(int x, int n)
{
    return 0 <= x && x < n;
}

void bfs(int v, vi &dist, vector<vi> &graph)
{
    fill(all(dist), -1);
    dist[v] = 0;
    vi q = {v};
    for (int i = 0; i < q.size(); i++)
    {
        for (auto u : graph[q[i]])
        {
            if (dist[u] == -1)
            {
                dist[u] = dist[q[i]] + 1;
                q.push_back(u);
            }
        }
    }
}


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int k, x;
    cin >> k >> x;
    cout << Ans[1 - (k * 500 >= x)];
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main(){
  int n,r;
  while(1){
    cin >> n >> r;
    if(n==0&&r==0)break;
    int p,c;
    vector<int> bef(n);
    vector<int> aft(n);
    rep(i,n){
      bef[i] = n-i;
    }
    rep(i,r){
      cin >> p >> c;
      for(int j=0;j<c;j++){
        aft[j]=bef[p-1+j];
      }
      for(int j=0;j<p-1;j++){
        aft[c+j]=bef[j];
      }
      for(int j=c+p-1;j<n;j++){
        aft[j]=bef[j];
      }
      bef=aft;
    }
    cout << bef[0] << endl;
  }
  return 0;
}



Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int value=700;
  string S;

  cin >> S;
  
  
  if(S.at(0)=='o') value+=100;

  if(S.at(1)=='o') value+=100;

  if(S.at(2)=='o') value+=100;


  cout << value << endl;
 
  return 0;
}

Measured memory_bytes: 256