akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define x first
#define y second
typedef pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
template <typename T> void chkmax(T &x,T y){x<y?x=y:T();}
template <typename T> void chkmin(T &x,T y){x>y?x=y:T();}
template <typename T> bool readint(T &x)
{
	x=0;int f=1;char c;
	for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())x=x*10+c-'0';
	x*=f;
	return c=='.';
}
const int MAXN=200005;

int n;
ll a[MAXN];
pii b[MAXN];
int cnt[100][100];

int main()
{
	#ifdef LOCAL
	freopen("code.in","r",stdin);
//	freopen("code.out","w",stdout);
	#endif
	readint(n);
	int s=0;
	for(int i=1;i<=n;++i)
	{
		ldb d;
		scanf("%Lf",&d);
		a[i]=d*1000000000+0.5;
		while(a[i]%2==0)a[i]>>=1,++b[i].x;
		while(a[i]%5==0)a[i]/=5,++b[i].y;
		++cnt[b[i].x][b[i].y];
		if(b[i].x>=9 && b[i].y>=9)++s;
	}
	sort(b+1,b+n+1);
	ll ans=0;
	for(int i=0;i<=55;++i)
		for(int j=0;j<=55;++j)
			for(int x=0;x<=55;++x)
				for(int y=0;y<=55;++y)
					if(i+x>=18 && j+y>=18)
						ans+=1ll*cnt[i][j]*cnt[x][y];
	printf("%lld\n",(ans-s)/2);
	return 0;
}

Measured memory_bytes: 6936
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int N,mnp=0,mxp=0;
	ll mn=10000000,mx=-10000000;
	vector<ll> V;
	vector<P> res;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		ll t;
		cin>>t;
		if(mn>t)
		{
			mn=t;
			mnp=i;
		}
		if(mx<t)
		{
			mx=t;
			mxp=i;
		}
		V.push_back(t);
	}
	if(abs(mn)>abs(mx))
	{
		for(int i=0;i<N;i++)
		{
			if(V[i]>0)
			{
				res.push_back(make_pair(mnp,i));
				V[i]+=mn;
			}
		}

		for(int i=N-1;i>0;i--)
		{
			if(V[i-1]>V[i])
			{
				res.push_back(make_pair(i,i-1));
				V[i-1]+=V[i];
			}
		}
	}
	else
	{
		for(int i=0;i<N;i++)
		{
			if(V[i]<0)
			{
				res.push_back(make_pair(mxp,i));
				V[i]+=mx;
			}
		}
		for(int i=1;i<N;i++)
		{
			if(V[i-1]>V[i])
			{
				res.push_back(make_pair(i-1,i));
				V[i]+=V[i-1];
			}
		}
	}
	cout<<res.size()<<endl;
	for(int i=0;i<res.size();i++)
		cout<<res[i].first+1<<" "<<res[i].second+1<<endl;
}


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

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

int main(){
  std::size_t n;
  cin >> n;
  set<int> st;
  rep(i, n) {
    int x;
    cin >> x;
    st.insert(x);
  }
  if (n == st.size()) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 12956
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
import std.datetime, std.bigint;

void main() {
    int n, k;
    int[] a;

    scan(n, k);
    a = readln.split.to!(int[]);

    if (n == 1) {
        if (a[0] == k) {
            writeln("POSSIBLE");
        }
        else {
            writeln("IMPOSSIBLE");
        }

        return;
    }

    int lim = a.reduce!max;

    if (k > lim) {
        writeln("IMPOSSIBLE");
        return;
    }

    int g = gcd(a[0], a[1]);

    foreach (i ; 2 .. n) {
        g = gcd(g, a[i]);
    }

    if (k % g == 0) {
        writeln("POSSIBLE");
    }
    else {
        writeln("IMPOSSIBLE");
    }
}

int gcd(int a, int b) {
    return b > 0 ? gcd(b, a % b) : a;
}

unittest {
    assert(gcd(24, 36) == 12);
    assert(gcd(2, 5) == 1);
    assert(gcd(6, 3) == 3);
    assert(gcd(1, 100) == 1);
    assert(gcd(12, 15) == 3);
    assert(gcd(15, 12) == 3);
}
void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 4220
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);

 		
 		long n = Long.parseLong(bf.readLine());
 		Map<Long, Integer> pf = factorize(n);
 		long sum = 0;
 		for(long i : pf.keySet()){
 			int k = pf.get(i);
 			int t = (int)(Math.sqrt(2*k+0.25)-0.5);
 			sum+=t;
 		}
 		out.println(sum);
 		out.close();
 		
 	}
	
	public static Map<Long, Integer> factorize(long n) { 
	 	Map<Long, Integer> pf = new HashMap<Long, Integer>();
        int count = 0; 
        while (!(n % 2 > 0)) { 
            n >>= 1; 
            count++; 
        } 
        if (count > 0) { 
            pf.put((long)(2) , count);
        } 

        for (long i = 3; i <= (long) Math.sqrt(n); i += 2) { 
            count = 0; 
            while (n % i == 0) { 
                count++; 
                n = n / i; 
            } 
            if (count > 0) { 
                pf.put(i, count);
            } 
        } 
 
        if (n > 2) { 
           pf.put(n, 1);
        } 
        return pf;
    }

}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	




Measured memory_bytes: 26028
Ar =list(map(int,input().split()))

if Ar[0]>=Ar[1]:
  A=Ar[0]
  B=Ar[1]
else:
  A=Ar[1]
  B=Ar[0]

r=None
while r!=0:
  r = (A%B)
  A = B
  B = r

Ans=int(Ar[0]*Ar[1]/A)
print(Ans)

Measured memory_bytes: 3060
/*
  kadai3_2 Therefore
  unomi
*/
#include <stdio.h>

int main(void){
  int N=0, q=0;

  // N の入力を取得
  scanf("%d",&N);

  // N が二桁以上のとき
  if (N > 9) q = N % 10;
  // N が一桁の時
  else q = N;

  if ((q == 2)||(q == 4)||(q == 5)||(q == 7)||(q == 9)){
    puts("hon");
  }
  else if ((q == 0)||(q == 1)||(q == 6)||(q == 8)){
    puts("pon");
  }
  else if (q == 3){
    puts("bon");
  }

  return 0;
}

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

namespace ABC155C
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            Dictionary<string, int> dic = new Dictionary<string, int>();
            int max = 0;
            for (int i = 0; i < n; i++)
            {
                var str = Console.ReadLine();
                if (dic.ContainsKey(str)) dic[str]++;
                else dic.Add(str, 1);
                max = Math.Max(max, dic[str]);
            }

            var res = new List<string>();
            foreach (var x in dic)
                if (max == x.Value) res.Add(x.Key);
            res.Sort(StringComparer.OrdinalIgnoreCase);
            Console.WriteLine(string.Join("\n", res));
        }
    }
}

Measured memory_bytes: 48888
#include <iostream>

using namespace std;

#define ll long long

const ll int MAX = 1e18;

int main() {

    int i;
    ll int ans = 1;
    int fover = 0;
    int zerocnt = 0;
    cin >> i;

    ll int j[100000];
    for (int cnt = 0; cnt < i; cnt++) {
        cin >> j[cnt];
        if (j[cnt] == 0) {
            zerocnt++;
        }
    }
    if (zerocnt == 0) {

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

            if (j[cnt] <= MAX / ans) {
                ans *= j[cnt];
            }
            else {
                fover++;
                break;
            }
        }
    }

    if (fover > 0) {
        ans = -1;
    }
    if (zerocnt > 0) {
        ans = 0;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4344
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	cin >> N;
	long long int odd = 1;
	long long int ans = 1;
	for (int i = 0; i < N; i++) {
		cin >> M;
		ans *= 3;
		if (M % 2) {
			odd *= 1;
		}
		else {
			odd *= 2;
		}
	}
	cout << ans - odd << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define maxn 100010
#define mod 1000000007
using namespace std;
int n;
char s[maxn];
int a[maxn];
int sum[maxn];
int pos[maxn][3];
int nxt[maxn];
void add(int &x,int y)
{
    x+=y;
    if(x>=mod)  x-=mod;
}
int f[maxn];
int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);  
    for(int i=1;i<=n;i++)
    {
        if(s[i]=='a')  a[i]=1;
        if(s[i]=='b')  a[i]=2;
    }
    for(int i=1;i<=n;i++)  sum[i]=(sum[i-1]+a[i])%3;
    int p=n+1;
    for(int i=n;i>=1;i--)
    {
        nxt[i]=p;
        if(a[i]==a[i-1])  p=i;
        memcpy(pos[i],pos[i+1],sizeof(pos[i+1]));
        pos[i][sum[i]]=i;       
    }
    if(p==n+1)
    {
        puts("1");
        return 0;
    }
    f[0]=1;
    for(int i=0;i<n;i++)
    {
        int x=nxt[i+1];
        int y=pos[x][(sum[i]+1)%3],z=pos[x][(sum[i]+2)%3];
        if(y&&a[i+1]!=1)  add(f[y],f[i]);
        if(z&&a[i+1]!=2)  add(f[z],f[i]);
        add(f[i+1],f[i]);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if((sum[n]-sum[i]+3)%3==0)  add(ans,f[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>

#define rep(i, n) for (int i=0; i< (n); ++i)
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;

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

    //string s[n];
    //rep(i, n) cin >> s[i];

    map<string, int> m{};
    rep(i, n) {
        string a;
        cin >> a;
        if (m.count(a) == 0) {
            m[a] = 1;
        } else {
            m[a]++;
        }
    }


    string items[m.size()];
    pair<string, int> map_pair[m.size()];
    int i = 0;
    for (auto const& x : m) {
        items[i] = x.first;
        map_pair[i] = x;
        i++;
    }


    sort(map_pair, map_pair+m.size(), [](pair<string, int> x, pair<string, int> y) {
        if (x.second == y.second) {
            return strcmp(x.first.c_str(), y.first.c_str()) < 0;
        }
        return x.second > y.second;
    });

    //rep(j, m.size()) cout << map_pair[j].first << " " << map_pair[j].second << endl;

    int prev = -1;
    rep(j, m.size()) {
        if (j != 0 && map_pair[j].second != prev) {
            return 0;
        }
        cout << map_pair[j].first << endl;
        prev = map_pair[j].second;
    }
}

Measured memory_bytes: 29952
#include<stdio.h>

int main(void){
  int a,b,c;
  scanf("%d %d %d",&a ,&b ,&c);
  
  if((a*100 + b*10 + c)%4 == 0){
    printf("YES");
  }
  else{printf("NO");}
  return 0;
}
  


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
  if(a%b==0){
    return(b);
  }else{
    return(gcd(b,a%b));
  }
}
vector<int> sp;
void smallest_prime(int N){//N以下の全ての自然数の最小約数を調べる
  sp.resize(N+1);
  for(int i=0;i<=N;i++){sp.at(i)=i;}
  for(int i=2;i*i<=N;i++){
    if(sp.at(i)==i){
      for(int j=i*i;j<=N;j+=i){
        if(sp.at(j)==j){sp.at(j)=i;}
      }
    }
  }
}
int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  int G=A.at(0);
  for(int i=1;i<N;i++){
    G=gcd(A.at(i),G);
  }
  smallest_prime(1000020);
  vector<int> mp(1000001);
  for(int i=0;i<N;i++){
    int R=A.at(i);
    set<int> C;
    while(R>1){
      if(*C.find(sp.at(R))!=sp.at(R)){
        mp.at(sp.at(R))++;
        C.insert(sp.at(R));
      }
      R/=sp.at(R);
    }
  }
  int check=0;
  for(int i=2;i<=1000000;i++){
    if(mp.at(i)>=2){
      check++;
    }
  }
  if(check==0){
    cout<<"pairwise coprime"<<endl;
  }
  else if(G==1){
    cout<<"setwise coprime"<<endl;
  }
  else{
    cout<<"not coprime"<<endl;
  }
}

Measured memory_bytes: 14792
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>

using namespace std;


int main() {
	
	string N;

	cin >> N;

	for (int i = 0; i < N.length(); i++)
	{
		if (N[i] == '9')
		{
			N[i] = '1';
		}
		else if (N[i] == '1')
		{
			N[i] = '9';
		}

	}

	cout << N.c_str() << endl;

	return 0;
}


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

int main()
{
    int N;
    cin >> N;
    string c;
    cin >> c;

    int cnt_R = 0;
    for (int i = 0; i < N; i++)
    {
        if (c.at(i) == 'R')
            cnt_R++;
    }

    int res = 0;
    for (int i = 0; i < cnt_R; i++)
    {
        if (c.at(i) == 'W')
            res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3700
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#include <iostream>
#define mod 998244353
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;

int main()
{
	int a,b;
	cin>>a>>b;
	if(a<1||a>9||b<1||b>9)
	{
		printf("-1\n");
	}
	else
	{
		cout<<a*b<<endl;
	}
}

Measured memory_bytes: 256
n1, n2 = [int(i) for i in input().split()]

s1 = input()

c1 = ""
r1 = 0

for i1 in range(n1):
    if i1 == 0:
        c1 = s1[0]
    elif i1 == n1 - 1:
        if c1 == s1[i1]:
            r1 += 1
        else:
            c1 = s1[i1]
    else:
        if c1 == s1[i1]:
            r1 += 1
        else:
            c1 = s1[i1]

r1 += (2 * n2)
if r1 >= n1:
    r1 = n1 - 1
print(r1)

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

typedef long long int Int;

void faster()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
Int n,s;

int main()
{
    faster();
    Int n,k,r,s,p;
    string t;
    cin>>n>>k>>r>>s>>p;
    cin>>t;
    char ans[n];
    
    Int i,j;
    for(i=0; i<n; i++) ans[i] = '0';
    
    map < char , Int > c;
    c['r'] = r;
    c['s'] = s;
    c['p'] = p;
    Int cost = 0;
    
    for(i=0; i<k; i++)
    {
        if (  t[i] == 'r' ) { ans[i] = 'p'; cost += p; }
        if (  t[i] == 's' ) { ans[i] = 'r'; cost += r; }
        if (  t[i] == 'p' ) { ans[i] = 's'; cost += s; }
    }
    
    for( ; i<n; i++)
    {
        if (  t[i] == 'r' && ans[i - k] != 'p' ) { ans[i] = 'p'; cost += p; }
        if (  t[i] == 's' && ans[i - k] != 'r') { ans[i] = 'r'; cost += r; }
        if (  t[i] == 'p' && ans[i - k] != 's') { ans[i] = 's'; cost += s; }
    }
    
    // for(i=k; i<n; i++)
    // {
    //     if (  ans[i] != '0' ) continue;
        
    //     c[ ans[i-k] ] = 1;
    //     c[ ans[i+k] ] = 1;
        
    //     if ( c['r'] == 0  ) { ans[i] = 'r'; continue; }
    //     if ( c['s'] == 0  ) { ans[i] = 's'; continue; }
    //     if ( c['p'] == 0  ) { ans[i] = 'p'; continue; }
        
    //     c[ ans[i-k] ] = 0;
    //     c[ ans[i+k] ] = 0;
        
    // }
    
    
    
    
    
    cout<<cost<<'\n';
    
    
    

    return 0;
}

Measured memory_bytes: 592
N = int(input())
p = list(map(float, input().split()))

dp = [[0]*(N+1) for _ in range(N+1)]# dp[i][j]: i枚目まで投げた時, j枚表になってる確率.(i枚の選び方によって変わらん?(dp[N][:]だけみるから途中はどんな順番でもいいってこと？))
dp[0][0] = 1 # 0枚投げた時は, 0枚が表っていう事象しかあり得ない.(dp[0][0]=1で,dp[0][1:]=0)

for i in range(1, N+1):
  for j in range(0, N+1):
    if j - 1 < 0:
      dp[i][j] = dp[i-1][j]*(1-p[i-1])
    else:
      dp[i][j] = (dp[i-1][j-1]*p[i-1]) + (dp[i-1][j]*(1-p[i-1]))

if N % 2==0:
  ans = sum(dp[N][int(N/2):])
else:
  ans = sum(dp[N][int(N//2)+1:])

print(ans)





    

Measured memory_bytes: 259720
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n; cin >> n;
	vector<ld> a(n); cin >> a;
	ld m = 0;
	REP(i, n) m += a[i];
	m /= ld(n);
	vector<ld> v(n);
	REP(i, n) v[i] = abs(m - a[i]);
	ld mn = 1e4;
	int ans = -1;
	REP(i, n)
	{
		if (mn > v[i])
		{
			mn = v[i];
			ans = i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstring>
#include<queue>
#include<tuple>
#include<utility>
#include<map>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define MP make_pair
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
//const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

//https://algo-logic.info/calc-pow/
template<typename T>
T pow(T x, long long n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x;  // n の最下位bitが 1 ならば x^(2^i) をかける
        x = x * x ;
        n >>= 1;  // n を1bit 左にずらす
    }
    return ret;
}

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int N;
	cin >> N;
	mint a, b, c, ans;
	a = pow<mint>(10, N);
	b = pow<mint>(9, N);
	c = pow<mint>(8, N);
	ans = a - b * 2 +c;

	cout << ans << endl;


	return 0;
}



Measured memory_bytes: 3608
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc_090c
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int M = int.Parse(input[1]);
            long result;
            int min = Math.Min(N, M);
            int max = Math.Max(N, M);
            if (min == 1)
            {
                if (max == 1)
                {
                    result = 1;
                }
                else
                {
                    result = max - 2;
                }
            }
            else
            {
                result = ((long)min - 2)*(max - 2);
            }
            Console.WriteLine(result);
            Console.Read();
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    vector<vector<ll> >a(3,vector<ll>(3));
    rep(i,3){
        rep(j,3)cin>>a[i][j];
    }
    vector<vector<ll> >s(3,vector<ll>(3));
    ll n;cin>>n;
    rep(i,n){
        ll b;cin>>b;
        rep(j,3){
            rep(k,3){
                if(a[j][k]==b)s[j][k]=1;
            }
        }
    }
    bool f=0;
    rep(i,3){
        bool t=1;
        rep(j,3){
            if(!s[i][j])t=0;
        }
        f|=t;
    }
    rep(i,3){
        bool t=1;
        rep(j,3){
            if(!s[j][i])t=0;
        }
        f|=t;
    }
    f|=(s[0][0]*s[1][1]*s[2][2]);
    f|=(s[0][2]*s[1][1]*s[2][0]);
    if(f)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<cstdio>

int H, W;

void print_rectangle(){
	for( int i = 1 ; i <= H ; i++ ){
		for( int j = 1 ; j <= W ; j++ ){
			printf("#");
		}
		printf("\n");
	}
	printf("\n");
}

int main(){
	while(1){
		scanf("%d %d", &H, &W);
		if( H == 0 && W == 0 ) break;

		print_rectangle();
	}

	return 0;
}

Measured memory_bytes: 2600
imos = [0]*(10**5+2)#0~10**5+1

N,C = map(int,input().split())
C = 30
mitai = [[] for i in range(C+1)]

for i in range(N):
    s,t,c = map(int,input().split())
    mitai[c].append([s,t])

for i in range(C+1):
    mitai[i].sort()


for i in range(C+1):
    preT = -1
    for j in mitai[i]:
        s,t = j[0],j[1]
        if preT == s:
            imos[s+1]+=1
            imos[t+1]-=1
        else:
            imos[s]+=1
            imos[t+1]-=1
        preT = t

for i in range(1,len(imos)):
    imos[i]=imos[i-1]+imos[i]

print(max(imos))

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

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

    for(int i=1; i<3; i++){
        for(int j=1; j<n+1; j++){
            a[i][j] += max(a[i-1][j], a[i][j-1]);
        }
    }
    cout << a[2][n] << endl;
  
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T & a, T b) { if (a < b)a = b; }
template<class T>void chmin(T & a, T b) { if (a > b)a = b; }
constexpr int INF = 1000000000000000000;
constexpr int mod = 1000000007;
int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
int kaijo[2000010];
struct edge { int to, cost; };
int gcd(int a, int b) {
    if (b == 0)return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}
bool prime(int a) {
    if (a == 1)return false;
    for (int i = 2; i * i <= a; i++) {
        if (a % i == 0)return false;
    }
    return true;
}
void init_fact() {
    kaijo[0] = 1;
    for (int i = 1; i <= 2000000; i++) {
        kaijo[i] = kaijo[i - 1] * i;
        kaijo[i] %= mod;
    }
}
int modpow(int a, int b) {
    if (b == 0)return 1;
    if (b % 2)return modpow(a, b - 1) * a % mod;
    int memo = modpow(a, b / 2);
    return memo * memo % mod;
}
int comb(int a, int b) {
    if (!kaijo[0])init_fact();
    return kaijo[a] * modpow(kaijo[a - b], mod - 2) % mod * modpow(kaijo[b], mod - 2) % mod;
}
int inv(int x) {
    x = modpow(x, mod - 2);
    return x;
}
bool kosa(double ax, double ay, double bx, double by, double cx, double cy, double dx, double dy) {
    double ta = (cx - dx) * (ay - cy) + (cy - dy) * (cx - ax);
    double tb = (cx - dx) * (by - cy) + (cy - dy) * (cx - bx);
    double tc = (ax - bx) * (cy - ay) + (ay - by) * (ax - cx);
    double td = (ax - bx) * (dy - ay) + (ay - by) * (ax - dx);
    return tc * td < 0 && ta * tb < 0;
}
double dist(double ax, double ay, double bx, double by) {
    return sqrt((bx - ax) * (bx - ax) + (ay - by) * (ay - by));
}
int n, m, s[10], c[10], num[10];
signed main() {
    cin >> n >> m;
    fill(num, num + 10, -1);
    rep(i, m) {
        cin >> s[i] >> c[i];
        if (num[s[i]] != -1 && num[s[i]] != c[i]) {
            puts("-1");
            return 0;
        }
        num[s[i]] = c[i];
    }
    if (num[1] == 0 && n != 1) {
        puts("-1");
        return 0;
    }
    for (int i = 1; i <= n; i++) {
        if (num[i] == -1) {
            if (i == 1&&n!=1)num[i] = 1;
            else num[i] = 0;
        }
        cout << num[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n;
	scanf("%d",&n);
	int i,j;
	int temp;
	int data[n];
	for(i=0;i<n;i++){
		scanf("%d",&data[i]);
	}
	for(i=0;i<n;i++){
		temp=data[i];
		j=i;
		while(j>0&&data[j-1]>temp){
			data[j]=data[j-1];
			j--;
		}
		data[j]=temp;
		for(j=0;j<n;j++){
			printf("%d",data[j]);
			if(j+1!=n){
				printf(" ");
			}
		}
		printf("\n");
	}
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	string S;

	for (int i = 0; i < N; i++) {
		cin >> S;
		if (S == "Y") {
			cout << "Four" << endl;
			break;
		}
		else if (i == N - 1) {
			cout << "Three" << endl;
		}
	}
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int kori[90][90];
int n, m;
void saiki(int n,int y, int x, int sub[][90]);
int MAX = 0;

int main()
{
	for(;;){
		cin >> m;			//x²
		cin >> n;			//y²
		MAX = 0;
		if(m == 0&&n == 0){
			break;
		}
		
		int temp[90][90];
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				cin >> kori[i][j];
			}
		}
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				temp[i][j] =  kori[i][j];
			}
		}
		
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				if(kori[i][j] == 1){
					saiki(0,i,j,kori);				//X^[g·éÕÊÌÀWðn·A ÆXÌÕÊ
					/*	Èñ©mçñ¯ÇÕÊªNH³êÆé©çàÆÉß·	*/
					for(int i = 0; i < n; i++){
						for(int j = 0; j < m; j++){
							kori[i][j] =  temp[i][j];
						}
					}
				}
			}
		}
		cout << MAX << endl;
	}
}

void saiki(int n,int y, int x,int sub[][90])
{
	sub[y][x] = 0;
	n++;
	if(sub[y+1][x] == 1){
		sub[y+1][x] = 0;
		saiki(n, y+1,x,sub);
		sub[y+1][x] = 1;
	}
	if(sub[y-1][x] == 1){
		sub[y-1][x] = 0;
		saiki(n,y-1,x,sub);
		sub[y-1][x] = 1;
	}
	if(sub[y][x+1] == 1){
		sub[y][x+1] = 0;
		saiki(n,y,x+1,sub);
		sub[y][x+1] = 1;
	}
	if(sub[y][x-1] == 1){
		sub[y][x-1] = 0;
		saiki(n,y,x-1,sub);
		sub[y][x-1] = 1;
	}
	if(MAX < n){
		MAX = n; 
	}
}
	

Measured memory_bytes: 928
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define int long long
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
signed main(){
	
	int n;
	cin>>n;
	int h[1111],max=0;
	for(int i=0;i<n;i++){
		cin>>h[i];
		max=std::max(max,h[i]);
	}
	int ans=0;
	for(int i=0;i<max;i++){
		int mode=0;
		for(int j=0;j<n;j++){
			if(h[j]!=0){
				h[j]--;
				mode=1;
			}
			else if(mode==1){
				ans++;
				mode=0;
			}
		}
		if(mode==1)ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const int MAX = 1000010;
const ll MOD = (int)1e9 + 7;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int x,y;
    cin >> x >> y;
    int n=x+y;
    if(n%3!=0){
        cout << 0;
        return 0;
    }
    n/=3;
    COMinit();
    cout << COM(n,x-n);

    


}

/*



 */



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

int main(){
    int K;
    cin >> K;
    queue<long long> q1;
    for (int i = 1; i < 10; i++){
        q1.push(i);
    }

    long long ans = 0;
    for (int i = 0; i < K; i++){
        ans = q1.front();
        q1.pop();
        if(ans%10 != 0){
            q1.push(ans * 10 + (ans % 10) - 1);
        }
        q1.push(ans * 10 + (ans % 10));
        if(ans%10 != 9){
            q1.push(ans * 10 + (ans % 10) + 1);
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int n;
ll a[200010];
ll h[200010];
ll seg[1000010]={0};

void update(int t, int l, int r, int pos, ll x)
{
    if(l==r)
    {
        seg[t]=x;
        return;
    }
    int mid=(l+r)/2;
    if(pos<=mid)    update(2*t,l,mid,pos,x);
    else    update(2*t+1,mid+1,r,pos,x);
    seg[t]=max(seg[2*t],seg[2*t+1]);
}

ll maxq(int t, int l, int r, int L, int R)
{
    if(l>R || L>r)
        return 0;
    if(l>=L && r<=R)
        return seg[t];
    int mid=(l+r)/2;
    ll m1=maxq(2*t,l,mid,L,R);
    ll m2=maxq(2*t+1,mid+1,r,L,R);
    return max(m1,m2);
}

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

    cin>>n;
    for(int i=0;i<n;i++)
        cin>>h[i];
    for(int i=0;i<n;i++)
        cin>>a[i];

    for(int i=0;i<n;i++)
    {
        //cout<<maxq(1,1,n,1,h[i]-1)<<endl;
        ll pom=a[i]+maxq(1,1,n,1,h[i]-1);
        //cout<<pom<<" "<<h[i]<<endl;
        update(1,1,n,h[i],pom);
    }
    /*for(int i=1;i<=9;i++)
        cout<<i<<" "<<seg[i]<<endl;
    */
    cout<<seg[1];
	return 0;
}


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

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


using namespace std;
using lint = long long;

int main(void)
{
    int N, R;
    cin >> N >> R;
    int ans;
    if(N >= 10){
        ans = R;
    }
    else{
        ans = R + 100 * (10 - N);
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
#define mp make_pair
#define pb push_back
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define Sort(v) sort(all(v))
#define Rev(v) reverse(all(v))
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,w) vector<vector<type>>name(h,vector<type>(w));in(name)
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
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;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n,k; cin >> n >> k;
    vector<ll> p(n+1), c(n+1);
    rep(i,n) cin >> p[i+1];
    rep(i,n) cin >> c[i+1];
    ll ans = -INF;
    for(int i = 1;i <= n;i++) {
        vector<ll> s(n+1);
        ll tmp = -INF;
        int from = i, loop = 0;
        for(int j = 1;j <= n;j++) {
            s[j] = s[j-1] + c[p[from]];
            if(j != 1 && from == i) break;
            loop++;
            from = p[from];
        }
        if(k <= loop) {
            for(int j = 1;j <= k;j++) chmax(tmp, s[j]);
        }else if(s[loop] < 0) {
            for(int j = 1;j <= loop;j++) chmax(tmp, s[j]);
        } else {
            ll v = s[loop]*(k/loop-1);
            for(int j = 1;j <= loop+k%loop;j++){
                chmax(tmp, v+s[(j-1)%loop+1]+s[loop]*((j-1)/loop));
            }
        }
        chmax(ans, tmp);
    } 
    cout << ans << endl;
}

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

using namespace std;

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

#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 repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898

//------------------------------------------------------

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    Yes(a + b == c || b + c == a || c + a == b);

    return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;

	public static void main(String[] args) throws IOException{
		NScanner sc = new NScanner(System.in);
		int cnt = 0;
		while(sc.hasNext()){
			String s = sc.next();
			if(s.equals("")) break;
			if(cnt != 0) System.out.print(" ");
			for(int i = 0; i < s.length(); ++i){
				char c = s.charAt(i);
				if(Character.isUpperCase(c))
					System.out.print((char)(c - 'A' + 'a'));
				else if(Character.isLowerCase(c))
					System.out.print((char)(c - 'a' + 'A'));
				else System.out.print(c);
			}
			++cnt;
		}
		System.out.println();
	}

}

class NScanner{

	private BufferedReader br;
	private StringTokenizer tok;

	public NScanner(InputStream is) throws IOException{
		br = new BufferedReader(new InputStreamReader(is));
		getLine();
	}

	private void getLine() throws IOException{
		while(tok == null || !hasNext()){
			tok = new StringTokenizer(br.readLine());
		}
	}

	public boolean hasNext(){
		return tok.hasMoreTokens();
	}

	public String next() throws IOException{
		if(hasNext()){
			return tok.nextToken();
		}else{
			getLine();
			return tok.nextToken();
		}
	}

	public int nextInt() throws IOException{
		if(hasNext()){
			return Integer.parseInt(tok.nextToken());
		}else{
			getLine();
			return Integer.parseInt(tok.nextToken());
		}
	}

	public long nextLong() throws IOException{
		if(hasNext()){
			return Long.parseLong(tok.nextToken());
		}else{
			getLine();
			return Long.parseLong(tok.nextToken());
		}
	}

	public double nextDouble() throws IOException{
		if(hasNext()){
			return Double.parseDouble(tok.nextToken());
		}else{
			getLine();
			return Double.parseDouble(tok.nextToken());
		}
	}
}


Measured memory_bytes: 25000
s = input()
n1 = int(s[:2])
n2 = int(s[2:])
if 0 < n1 < 13 and 0 < n2 < 13:
        print("AMBIGUOUS")
elif 0 < n1 < 13:
        print("MMYY")
elif 0 < n2 < 13:
        print("YYMM")
else:
        print("NA")

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <random>
#include <stdio.h>
#include <bitset>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef string ST;


#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl

void func() {
  LD A;
  cin >> A;
  LD B;
  cin >> B;
  LD X;
  cin >> X;
  LD S = X / (A);
  LD radian = 0;
  LD radian_ = 0;
  if (S >= (0.5 * A * B)) {
    //LD digree = atan(2*(A*B-S)/(A*A)) / (2 * M_PI) * 360.0;
    //LD digree = atan2(2*(A*B-S),(A*A)) / (2 * M_PI) * 360.0;
    radian = atan2l(2*(A*B-S),(A*A));

    LD h = (A * B - S) * 2 / A;
    radian_ = atan2(h, A);




    //fprintf(stdout, "%.20llf", digree);
    //cout << atan((2 * A * B - 2 * S) / (A * A))/(2*M_PI)*360;
  }
  else{
    //LD digree = atan(0.5 * B * B / S) / (2 * M_PI) * 360.0;
    //LD digree = atan2(0.5 * B * B , S) / (2 * M_PI) * 360.0;
    //fprintf(stdout, "%.20llf", digree);
    radian = atan2l(0.5 * B * B, S);
    LD w = S * 2 / B;
    radian_ = atan2(B, w);

  }
  LD digree = radian / (2 * M_PI) * 360.0;
  LD digree_ = radian_ / (2 * M_PI) * 360.0;
  fprintf(stdout, "%.20llf\n", digree);
  //fprintf(stdout, "%.20llf\n", digree);
  //fprintf(stderr, "%.20llf\n", digree - digree_);

}

#ifdef CALC_TIME 
#include <windows.h>
int main()
{
  LARGE_INTEGER freq;
  QueryPerformanceFrequency(&freq);
  LARGE_INTEGER start, end;
  QueryPerformanceCounter(&start);
  // 何かの処理
  func();
  QueryPerformanceCounter(&end);
  double time = static_cast<double>(end.QuadPart - start.QuadPart) * 1000.0 / freq.QuadPart;
  fprintf(stderr, "\n%lf[ms]\n", time);
  return 0;
}
#else 
int main()
{
  func();
  return 0;
}
#endif





Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#define FOR(i, l, r) for(int i = l; i <= r; ++i)

using namespace std;

const int N = 1010;
const int M = 200010;

int n, m, cnt, x[M], y[M], a[2][N][N];
vector <int> v[N];

void dfs(int fl, int x, int st, int fir)
{
    a[fl][st][x] = fir;
    for(int i = 0; i < v[x].size(); ++i)
        if (!a[fl][st][v[x][i]]) dfs(fl, v[x][i], st, fir);
}

char B[1 << 26], *S = B;
#define getchar() (*S++)
int read()
{
    int x = 0; char c = getchar();
    while (c < '0' || c > '9') c = getchar();
    while (c >= '0' && c <= '9') {x = x * 10 + c - '0'; c = getchar();}
    return x;
}

int main()
{
    fread(B, 1, 1 << 26, stdin);
    n = read(); m = read();
    FOR(i, 1, m)
    {
        x[i] = read(); y[i] = read();
        v[x[i]].push_back(y[i]);
    }
    FOR(i, 1, n)
    {
        a[0][i][i] = a[1][i][i] = i;
        for(int j = 0; j < v[i].size(); ++j) if (!a[0][i][v[i][j]]) dfs(0, v[i][j], i, v[i][j]);
        if (v[i].size()) for(int j = v[i].size() - 1; ~j; --j) if (!a[1][i][v[i][j]]) dfs(1, v[i][j], i, v[i][j]);
    }
    FOR(i, 1, m) if (((bool) a[0][y[i]][x[i]]) ^ (a[0][x[i]][y[i]] != a[1][x[i]][y[i]]))
        puts("diff"); else puts("same");
    return 0;
}


Measured memory_bytes: 13824
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);

		String[] S=sc.next().split("");

		int ans = 0;

		for (int i = 0; i < 4; i++) {
			if(S[i].equals("+")) {
				ans++;
			}else {
				ans--;
			}
		}

		pln(ans);
	}

	//以下テンプレート

	public static int[] extgcd(int a, int b) {

		int x0 = 1;
		int x1 = 0;

		int y0 = 0;
		int y1 = 1;

		while (b != 0) {
			int q = a / b;
			int r = a % b;

			int x2 = x0 - q * x1;
			int y2 = y0 - q * y1;

			a = b;
			b = r;

			x0 = x1;
			x1 = x2;

			y0 = y1;
			y1 = y2;
		}

		return new int[] { a, x0, y0 };

	}

	static int gcd(int a, int b) {

		if (b == 0)
			return a;

		if (a < b) {
			int t = a;
			a = b;
			b = t;
		}

		return gcd(b, a % b);

	}

	static int lcm(int a, int b) {
		return a * b / gcd(a, b);
	}

	static void swap(int[] a) {
		int t;

		t = a[0];
		a[0] = a[1];
		a[1] = t;

		return;
	}

	static <T> void output(List<T> list) {

		for (int i = 0; i < list.size(); i++) {
			System.out.print(list.get(i));

			if (i != list.size() - 1) {
				System.out.print(" ");
			} else {
				nl();
			}
		}

	}

	static void output(String[][] str) {

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				print(str[i][j]);
			}

			nl();
		}

	}

	static void output(boolean flg, String Yes, String No) {

		if (flg) {
			pln(Yes);
		} else {
			pln(No);
		}

	}

	static void output(String[][] str, int digit) {

		String dig = "%" + String.valueOf(digit) + "s";

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				System.out.printf(dig, str[i][j]);
			}
			nl();
		}

	}

	static void pln(String str) {
		System.out.println(str);
	}

	static void pln(int x) {
		System.out.println(x);
	}

	static void print(String str) {
		System.out.print(str);
	}

	static void print(int x) {
		System.out.print(x);
	}

	static void print(String str, int times) {
		for (int i = 0; i < times; i++) {
			print(str);
		}
	}

	static void print(int x, int times) {
		for (int i = 0; i < times; i++) {
			print(x);
		}
	}

	static void nl() {
		System.out.println();
	}

}


Measured memory_bytes: 23764
N = int(input())
C = [input() for i in range(N)]

AC_num = 0
WA_num = 0
TLE_num = 0
RE_num = 0

for c in C:
    if(c == "AC"):
        AC_num += 1
    elif(c == "WA"):
        WA_num += 1
    elif(c == "TLE"):
        TLE_num += 1
    elif(c == "RE"):
        RE_num += 1

print("AC x {}".format(AC_num))
print("WA x {}".format(WA_num))
print("TLE x {}".format(TLE_num))
print("RE x {}".format(RE_num))

Measured memory_bytes: 79116
# coding: utf-8

import sys
input = sys.stdin.readline

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

ac_set = set()
penalty = 0
wa_count = [0] * (n+1)

for i in range(m):
    p, s = input().split()
    p = int(p)

    if s == "AC":
        if not p in ac_set:
            penalty += wa_count[p]
            ac_set.add(p)
    elif s == "WA":
        wa_count[p] += 1


print(len(ac_set), penalty)

Measured memory_bytes: 12780
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	static long[][] dp;
    static int ind=1;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int[] A=new int[3];
	    
        for (int i=0; i< 3;i++) {
        	A[i]=gi();
        }
        
        Arrays.parallelSort(A);
        
        long ans=0;
        ans+=A[2]-A[1];
        if((A[1]-A[0])%2==0) {
        	ans+=(A[1]-A[0])/2;
        } else {
        	ans+=((A[1]-A[0]+1)/2) + 1;
        }

        System.out.println(ans);
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35636
from collections import deque

n, m, k = map(int, input().split())
friend = [list(map(int, input().split())) for _ in range(m)]
block = [list(map(int, input().split())) for _ in range(k)]

f = [set() for _ in range(n+1)]
b = [set() for _ in range(n+1)]

for i,j in friend:
    f[i].add(j)
    f[j].add(i)
for i,j in block:
    b[i].add(j)
    b[j].add(i)

stack = deque()
ans = [0]*(n+1)
visited = [0]*(n+1)

for i in range(1, n+1):
    if visited[i]:
        continue
    link = {i}
    visited[i] = 1
    stack.append(i)
    while stack:
        n = stack.pop()
        for j in f[n]:
            if visited[j] == 0:
                stack.append(j)
                visited[j] = 1
                link.add(j)
    for i in link:
        ans[i] = len(link) - len(link & f[i]) - len(link & b[i]) -1
    
print(*ans[1:])

Measured memory_bytes: 116828
n,m=map(int,input().split())
a=list(map(int,input().split()))
dp=[0]*(n+9)
d=[0,2,5,5,4,5,6,3,7,6]
for i in range(n+1):
  for j in a:
    if dp[i]or i<1:dp[i+d[j]]=max(dp[i+d[j]],dp[i]*10+j)
print(dp[n])

Measured memory_bytes: 14692
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                                     \
  ifstream in("abc158/abc158_d.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  string s;
  cin >> s;

  int q;
  cin >> q;

  string pre = "";
  string sus = "";
  bool rev = false;
  rep(i, q) {
    int t;
    cin >> t;
    if (t == 1) {
      rev = !rev;
      pre.swap(sus);
    } else {
      int f;
      cin >> f;
      char c;
      cin >> c;
      if (f == 1) {
        pre += c;
      } else {
        sus += c;
      }
    }
  }

  if (rev) {
    reverse(s.begin(), s.end());
  }
  reverse(pre.begin(), pre.end());

  cout << pre + s + sus << endl;
}

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

int main(){
	int n,count=0;
	cin>>n;
	vector<int> a(n),b(100);
	rep(i,n) cin>>a.at(i);
	rep(i,n){
		if(a.at(i)%2==0){
			b.at(count)=a.at(i);
			count++;
		}
	}
	rep(i,count){
		if(b.at(i)%3!=0&&b.at(i)%5!=0){
			cout<<"DENIED"<<endl;
			return 0;
		}
	}
	cout<<"APPROVED"<<endl;
}


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

using namespace std;

int n;
int arr[200100];
int ord[200100];
set<int> s;

int main() {
    int i;
    long long res = 0;
    scanf("%d",&n);
    for (i=0;i<n;i++) scanf("%d",&arr[i]);
    for (i=0;i<n;i++) ord[arr[i]] = i;
    s.insert(-1); s.insert(n);
    for (i=1;i<=n;i++) {
        res += 1LL*i*((*s.upper_bound(ord[i]))-ord[i])*(ord[i]-(*(--s.lower_bound(ord[i]))));
        s.insert(ord[i]);
    }
    printf("%lld\n",res);

    return 0;
}


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

void code();

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    code();
}

void code()
{
	int a, b;
	cin >> a >> b;
	int cnt =0;
	for (int i = a; i <= b; ++i)
	{
		int rem, temp = i;
		int reverse = 0;
		while(temp){
			rem = temp%10;
			temp *= 0.1;
			reverse = reverse*10+rem;
		}
		if(reverse == i)
			cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3500