akhauriyash/Code-Regression huggingface dataset:
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(ll n,ll m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];

int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, v, n, m;
    cin>>n>>x>>t;
	y=n/x;
	if(n%x>0)
	y++;
	cout<<y*t;
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(ll n, ll m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 10652
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) {
 
		// 読み込み
		Scanner sc = new Scanner(System.in);
      	int N = 5;
      	int x[] = new int[5];
      	int ans = 0;
	      for (int i=0; i<N; i++){
            x[i] = sc.nextInt();
            if(x[i] == 0){
            	ans = i + 1;
            }
    	    }
      	      	
         System.out.println(ans);
	}
}

Measured memory_bytes: 27076
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    priority_queue<ll, vector<ll>, greater<ll> > p, q;
    priority_queue<ll> r;
    rep(i, a) {
        int pp;
        cin >> pp;
        p.push(pp);
    }
    rep(i, b) {
        int qq;
        cin >> qq;
        q.push(qq);
    }
    rep(i, c) {
        int rr;
        cin >> rr;
        r.push(rr);
    }

    rep(i, a-x) p.pop();
    rep(i, b-y) q.pop();

    rep(i, y) {
        p.push(q.top());
        q.pop();
    }

    while(!r.empty() and p.top() < r.top()) {
        p.pop();
        p.push(r.top());
        r.pop();
    }

    ll ans = 0;
    rep(i, x+y) {
        ans += p.top();
        p.pop();
    }

    cout << ans << endl;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
#define int long long
int n;
char board[310][310];
bool check(int a, int b){
    char board2[310][310];
    rep(i,n)rep(j,n) board2[(i+a)%n][(j+b)%n] = board[i][j];
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++) if(board2[i][j]!=board2[j][i]) return false;
    }
    return true;
}
signed main(void){
    cin>>n;
    rep(i,n) rep(j,n) cin>>board[i][j];
    int ans = 0;
    rep(i,n){
        bool ok;
        ok = check(0,i);
        if(ok) ans+=n;
    }
    cout<<ans<<endl;
}


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

//#define int long long 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<typename T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<typename T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T> T Min(T a, T b) { return a > b ? b : a; }
template<typename T> T Max(T a, T b) { return a < b ? b : a; }
template<typename T> bool mySec( const 	T& a, const T& b) { return a.se < b.se ; }
template<typename T> void de(T a){ 
#ifdef LOCAL_DEFINE
	cout<< a << endl;
#endif
}	
const int INF = 2e5+1;
const int mod = 1e9+7;

i64 cn2(int a, i64 ans){
	ans = 1ll;
	if(a==1) return 1ll;
	ans*=a*(a-1);
	ans /=2;
	return ans;
}
         	
void solve(){
	int n;
	cin>>n;
	string s[n];
	forn(i,n){
		cin>>s[i];
		sort(all(s[i]));
	}
	sort(s,s+n);
	i64 ans=0,res = 1;
	for1(i,n){
		if(s[i]==s[i-1]){
			res++;
		}else{
			if(res>1){
			 	ans += (res*(res-1))/2;
			}
			res=1;
		}
	}
	if(res>1) ans+=(res*(res-1))/2;
	cout<<ans<<endl;
}
 
 
int32_t main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    	cout.precision(10);
    	cout << fixed;
#ifdef LOCAL_DEFINE
   	freopen("input.txt", "rt", stdin);
	freopen("output.txt","w",stdout);
#endif  
        int q=1;
#ifdef LOCAL_DEFINE
        cin>>q;
#endif
        while(q--){
         	solve();
        }
 
#ifdef LOCAL_DEFINE
         
             
        cerr << "Time elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms.\n";
#endif
 
	return 0;
}	

Measured memory_bytes: 5760
N = int(input())
s = [0] * N
ans = 0
for i in range(N):
    s[i] = int(input())
    ans += s[i]

s.sort()
if ans % 10 != 0:
    print(ans)
else:
    ok = False
    for si in s:
        if si % 10 != 0:
            ok = True
            print(ans - si)
            break
    if not ok:
        print(0)


Measured memory_bytes: 3060
import Control.Monad
import Data.List

solve :: [(Int, Int)] -> [(Int, (Int, Int))] -> [Int]
solve [] _ = []
solve (ab:abs) cds = (fst . head . sortOn snd $ map (calc ab) cds) : solve abs cds

calc :: (Int, Int) -> (Int, (Int, Int)) -> (Int, Int)
calc (a, b) (i, (c, d)) = (i, dx + dy)
  where dx = abs $ a - c
        dy = abs $ b - d

main :: IO ()
main = do
  [n, m] <- map read . words <$> getLine
  let toPair [x, y] = (x, y)
  abs <- replicateM n $ toPair . map read . words <$> getLine
  cds <- replicateM m $ toPair . map read . words <$> getLine
  mapM_ print $ solve abs $ zip [1..] cds

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

#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#define endl "\n"
#define all(V) V.begin( ), V.end( )
#define Unique(V) sort( all( V ) ), V.erase( unique( all( V ) ), V.end() )
#define Check( N , p ) ( !( ( N & ( 1LL << p ) ) == 0 ) )
#define ON( N , p ) ( N = N | ( 1LL << p ) )
#define OFF( N , p ) ( N = N & ~( 1LL << p ) )
std::mt19937 rng( chrono::steady_clock::now().time_since_epoch().count() );
#define rnd(a, b) ((((rand() << 15) ^ rand()) % ((b) - (a) + 1)) + (a))
#define ran(a, b) rng() % ( (b) - (a) + 1 ) + (a)
#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template < typename Arg1 >
void __f( const char* name , Arg1&& arg1 ) { cerr << name << " : " << arg1 << "\n"; }
template < typename Arg1 , typename... Args >
void __f( const char* names , Arg1&& arg1 , Args&&... args ) {
const char* comma = strchr( names + 1 , ',' );
cerr.write( names , comma - names ) << " : " << arg1 << " , " ; __f( comma + 1 , args... ); }
typedef long long int LL;
typedef pair <int,int> pii;
typedef pair <long long,long long> pll;
const int MOD = 1e9 + 7;
const double EPS = 1e-8;
const int N = 1e5 + 5;
const int inf = 1e9;
const long long INF = 1e18;


int main( int argc , char const *argv[] ) {
        ios_base::sync_with_stdio( false ); cin.tie( nullptr );
        string s;
        cin >> s;
        stack <char> S;
        for( int i = 0; i < s.size(); i++ ) {
                if( S.empty() ) {
                        S.push( s[i] );
                }
                else if( !S.empty() && S.top() != s[i] ) {
                        S.pop();
                }
                else S.push( s[i] );
        }
        cout << (int)s.size() - (int)S.size() << endl;
        return 0;
}














Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <unordered_map> 
using namespace std; 
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI1 3.14159265358979311599796346854418516159057617187500

typedef long long int ll;  


int main() 
{ 
    FIO
    int t;
    t=1;

    while(t--)
    {
        int n,m,x;
        cin >> n >> m >> x;

        vector<int> v[n];
        int c[n];
        for(int i=0;i<n;i++)
        {
            cin >> c[i];
            for(int j=0;j<m;j++)
            {
                int h;
                cin >> h;
                v[i].push_back(h);
            }
        }       

        int ans = 1e9;
        for(int i=1;i<(int)pow(2,n);i++)
        {
            int temp[m]={0};
            int cost = 0;
            for(int j=0;j<n;j++)
            {
                if(i & (int)pow(2,j))
                {
                    cost += c[j];
                    for(int k=0;k<m;k++)
                        temp[k] += v[j][k];
                }
            }

            bool f=1;
            for(int j=0;j<m;j++)
            {
                if(temp[j]<x)
                {
                    f=0;
                    break;
                }
            }
            //cout <<i << " " <<  f << endl;
            if(f)
                ans = min(ans , cost);
        }    

        if(ans==1e9)
            cout << -1 << endl;
        else
            cout << ans << endl;
    }

    return 0; 
} 


Measured memory_bytes: 4092
#include <bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;++i)
#define fod(i,a,b) for(int i=a;i>=b;--i)
#define N 100005
#define LL long long
#define mo 1000000007
using namespace std;
LL ct[26];
char ch[N];
int n;
int main()
{
	cin>>n;
	scanf("%s",ch+1);
	LL ans=0;
	fo(i,1,n)
	{
		int c=ch[i]-'a';
		LL s1=1;
		fo(j,0,25)
		{
			if(j!=c) s1=s1*(ct[j]+1)%mo;
		}
		ct[c]++;
		ans=(ans+s1)%mo;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 892
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <string>
using namespace std;

bool isEven(string s) {
	if (s.length() % 2 != 0) return false;
	if (s.substr(0, s.length() / 2) == s.substr(s.length() / 2, s.length() / 2)) return true;
	else return false;
}

int main() {
	string S;
	cin >> S;
	for (size_t i = 1; i < S.length(); i++) {
		if (isEven(S.substr(0, S.length() - i))) {
			cout << S.length() - i << endl;
			return 0;
		}
	}
}

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

int main(void){
    long long N, ans=0;
    std::cin >> N;
    std::vector<long long> A(N + 1);

    for (int i=0; i<N+1; ++i){
        std::cin >> A.at(i);
    }

    for (int i=0; i<N; ++i){
        long long b, tmp;
        std::cin >> b;
        tmp = A.at(i) - b;
        if (tmp < 0){
            ans += A.at(i);
            if (A.at(i + 1) + tmp < 0){
                ans += A.at(i + 1);
                A.at(i + 1) = 0;
            } else {
                ans += -tmp;
                A.at(i + 1) += tmp;
            }
        } else {
            ans += b;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3972
/*package whatever //do not write package name here */

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		LinkedHashSet<String> lhs = new LinkedHashSet<>();
		LinkedList<String> ll = new LinkedList<>();
		int n = sc.nextInt();
		sc.nextLine();
		int f = 0;
		while(n-- != 0)
		{
		    String s = sc.nextLine();
		    if(lhs.contains(s))
		    f = 1;
		    lhs.add(s);
		}
		if(f == 1)
		System.out.print("No");
		else
		{
		    ll.addAll(lhs);
		    for(int i = 0;i < ll.size() - 1;i++)
		    {
		        String s1 = ll.get(i);
		        String s2 = ll.get(i + 1);
		        if(s1.charAt(s1.length() - 1) != s2.charAt(0))
		        {
		        f = 1;
		        break;
		        }
		    }
		    if(f == 1)
		    System.out.print("No");
		    else
		    System.out.print("Yes");
		}
	}
}

Measured memory_bytes: 25044
import fileinput


def solve_slimes(slimes):
    slime_union_table = [0] * len(slimes) * len(slimes)
    slime_cost_table = [0] * len(slimes) * len(slimes)

    for i in range(len(slimes)):
        slime_union_table[i] = slimes[i]

    for gap in range(1, len(slimes)):
        for li in range(len(slimes) - gap):
            split_size = slime_union_table[li] + slime_union_table[li + 1 + (gap - 1) * len(slimes)]
            slime_union_table[li + gap * len(slimes)] = split_size

            for split in range(0, gap):
                split_cost = slime_cost_table[li + split * len(slimes)] + slime_cost_table[li + split + 1 + (gap - split - 1) * len(slimes)] + split_size

                if slime_cost_table[li + gap * len(slimes)] == 0:
                    slime_cost_table[li + gap * len(slimes)] = split_cost

                else:
                    slime_cost_table[li + gap * len(slimes)] = min(
                        split_cost,
                        slime_cost_table[li + gap * len(slimes)]
                    )
    return slime_cost_table[len(slimes) * (len(slimes) - 1)]


inp = fileinput.FileInput()

inp.readline()
slimes = [int(v) for v in inp.readline().split()]

print(solve_slimes(slimes))

Measured memory_bytes: 44140
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, x, y;
  cin >> n >> x >> y;
  x--; y--;
  vector<vector<int>> gr(n, vector<int>());
  rep2(i, 1, n){
    gr.at(i-1).push_back(i);
    gr.at(i).push_back(i-1);
  }
  gr.at(x).push_back(y);
  gr.at(y).push_back(x);
  vector<int> ans(n-1, 0);
  rep(i, n){
    vector<int> d(n, -1);
    d.at(i) = 0;
    queue<int> q; q.push(i);
    while(!q.empty()){
      int now = q.front(); q.pop();
      for(auto nx : gr.at(now)){
        if(d.at(nx) != -1) continue;
        d.at(nx) = d.at(now) + 1;
        q.push(nx);
      }
    }
    rep2(j, i+1, n){
      ans.at(d.at(j)-1)++;
    }
  }
  rep(i, n-1){
    cout << ans.at(i) << endl;
  }
  return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Card {
	final private String str;
	final private int number, id;
	public Card(String str, int id) {
		super();
		this.str = str;
		this.number = Integer.parseInt(str.substring(2));
		this.id = id;
	}
	public final int getNumber() {
		return number;
	}
	public final int getId() {
		return id;
	}
	@Override
	public final String toString() {
		return str;
	}

}


public class Main {

	private static void swap(Card[] arr, int a, int b) {
		Card c = arr[a];
		arr[a] = arr[b];
		arr[b] = c;
	}

	private static int partition(Card[] arr, int p, int r) {
		Card x = arr[r];
		int i = p - 1;
		for (int j = p; j < r; j++) {
			if (arr[j].getNumber() <= x.getNumber()) {
				swap(arr, ++i, j);
			}
		}
		swap(arr, ++i, r);
		return i;
	}
	private static void quickSort(Card[] arr, int p, int r) {
		if (p >= r) return;
		int q = partition(arr, p, r);
		quickSort(arr, p, q - 1);
		quickSort(arr, q + 1, r);
	}
	private static boolean isStable(Card[] arr) {
		for (int i = 0, n = arr.length; i < n - 1; i++) {
			if (arr[i].getNumber() == arr[i + 1].getNumber() &&
					arr[i].getId() > arr[i + 1].getId()) {
				return false;
			}
		}
		return true;
	}
	public static void main(String[] args)  {
		try(BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));) {
			int n = Integer.parseInt(br.readLine());
			Card[] arr = new Card[n];
			for (int i = 0; i < n; i++) {
				arr[i] = new Card(br.readLine(), i);
			}
			quickSort(arr, 0, n - 1);
			if (isStable(arr)) {
				System.out.println("Stable");
			} else {
				System.out.println("Not stable");
			}
			for (int i = 0; i < n; i++) {
				System.out.println(arr[i].toString());
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}


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

#define ll                  long long
#define ld                  long double
#define pb                  push_back
#define mp                  make_pair
#define fi                  first
#define se                  second
#define all(c)              (c).begin(),(c).end()
#define for0(i, n)          for (ll i = 0; i < n; ++i)
#define for1(i, n)          for (ll i = 1; i <= n;++i)
#define for2(i, n)          for (ll i = 1; i < n; ++i)
#define for3(i, k, n)       for (ll i = k; i < n; ++i)
#define input(a, i, n)      for (int i = 0; i < n; ++i) {cin >> a[i]; }
#define output(a, i, n)     for (int i = 0; i < n; ++i) {cout << a[i] << ' '; }
//cout.precision(12);

using namespace std;

int64_t TN = 1;

void solve()
{
    int a[5];
    for (int i = 0; i < 5; ++i) cin >> a[i];
    for (int i = 0; i < 5; ++i) if (a[i] == 0) cout << i + 1;
}


int main()
{
    //cin >> TN;
    for (int i = 0; i < TN; ++i) {
        solve();
    }
    return 0;
}


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

void dfs(int x,int y);
int h,w;
char ta[22][22];
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int cou=0;

int main(){
  int a,b;
  while(1){
    cin >> w >> h;
    if(w==0 && h==0) break;
    cou=0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> ta[i][j];
	if(ta[i][j]=='@'){
	  a=i,b=j;
	}
      }
    }
    dfs(a,b);
    cout << cou << endl;
  }
}

void dfs(int x,int y){
  ta[x][y]='#';
  cou++;
  for(int i=0;i<4;i++){
    int nx=x+dx[i];
    int ny=y+dy[i];
    if(nx>=0 && nx<h && ny>=0 && ny<w && ta[nx][ny]=='.'){
      dfs(nx,ny);
    }
  }
}

Measured memory_bytes: 1168
/**
*    created: 24.06.2020 00:03:04
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcount(bit)
#define mod 1000000007
#define pi acos(-1.0)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> d(n);
    rep2(i,1,n) d[i] = a[i] - a[i-1];
    d[0] = a[0] + k - a[n-1];
    sort(all(d)); 
    int sum = 0;
    rep(i,n-1) sum += d[i];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 6400
#define __USE_MINGW_ANSI_STDIO
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef long long ull;
typedef pair<int, int> ii;

#define all(v)		((v).begin()), ((v).end())
#define sz(v)		((int)((v).size()))
#define endl		"\n"
#define fx(n)		fixed<<setprecision(n)
#define mk			make_pair	

void file()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
#ifdef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("pyramid.in", "r", stdin);
#endif
}
const double pi = 2 * acos(0.0);
const ll oo = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int nn = 5e3 + 15;
int dx[8] = { -1, 0, 0, 1, 1, -1, 1, -1 };
int dy[8] = { 0, -1, 1, 0, 1, -1, -1, 1 };


int main()
{
	//file();
	ios::sync_with_stdio(NULL);
	cout.tie(NULL);
	cin.tie(NULL);
	ll a, b, c;
	cin >> a >> b >> c;
	if (a + b == c || a + c == b || a == b + c)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    string s;
    cin >> s;
    for (char c : s){
        if (c == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

const long long modi = 998244353;
const int mxn = 3001;
long long dp2[mxn][mxn];
long long dp[mxn][mxn][3];
int main(){
	long long a,b,c,d;
	cin >> a >> b >> c >> d;

	long long rows = (c-a); // for each r op i can palong long one of the nodes black
	long long cols = (d-b); // for eeach c op i can palong long one of hte nodes black

	// long long  dp[c+1][d+1][3];
	// memset(dp,1LL,sizeof(dp));
	for(long long i =1;i<=a;i++){
		for(long long j =1;j<=b;j++){
			dp[i][j][0] = 1LL;
			dp[i][j][1] = 1LL;
			dp[i][j][2] = 1LL;
		}
	}
	
	for(long long i =a+1;i<=c;i++){
		dp[i][b][0] = 0;
		dp[i][b][1] = dp[i-1][b][1]*b%modi;
		dp[i][b][2] = dp[i][b][1];
		dp[i][b][2]%=modi;
	}
	for(long long i =b+1;i<=d;i++){
		dp[a][i][1] = 0;
		dp[a][i][0] = dp[a][i-1][0]*a%modi;
		dp[a][i][2] = dp[a][i][0];
		dp[a][i][2]%=modi;
	}

	for(long long i =a+1;i<=c;i++){
		for(long long j = b+1;j<=d;j++){
			dp[i][j][2] = dp[i-1][j][2] + (dp[i][j-1][2]*i)%modi;
			// dp[i][j][0] = dp[i-1][j][2]*(j)%modi;
			// dp[i][j][1] = dp[i][j-1][2]*(i)%modi;
			dp[i][j][2]%=modi;
			// cout << dp[i][j][2] << " " << i << " " << j << endl;
		}

	}
	// cout << dp[c][d][2] << endl;
	memset(dp2,0,sizeof(dp2));
	dp2[a][b] = 1;
	for(int i =a;i<=c;i++){
		for(int j =b;j<=d;j++){
			dp2[i][j] = dp2[i][j] + (modi+ dp2[i-1][j]*j%modi+dp2[i][j-1]*i%modi-dp2[i-1][j-1]*(i-1)%modi*(j-1)%modi)%modi;
			dp2[i][j]%=modi;
		}
	}

	cout << dp2[c][d] << endl;

}

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


int main(){
    char p;
    while (1) {
        scanf("%c",&p);
        if(p == '\n')break;
        else if (islower(p)) cout << (char)toupper(p);
        else if(isupper(p))  cout << (char)tolower(p);
        else                 cout<< p;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1144
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
vector<int> b;
int a[4010];char c[4010];
int pos[2][2010];
int dp[4010][2010];
int num[2][2010][2010];
int main()
{
	int n,out=0,inf=1001001001;
	cin>>n;
	rep(i,n*2){
		cin>>c[i]>>a[i];a[i]--;
		if(c[i]=='B') pos[0][a[i]]=i;else pos[1][a[i]]=i;
	}
	memset(num,0,sizeof(num));
	rep(i,n*2) rep(j,i){
		if(c[i]!=c[j]){
			if(c[i]=='W') num[0][a[i]][a[j]]++;
			else num[1][a[i]][a[j]]++;
		}
		else if(a[i]<a[j]){
			if(c[i]=='W') num[0][a[i]][n]++;
			else num[1][a[i]][n]++;
		}
	}
	rep(i,2) rep(j,n) for(int k=n;k>0;k--) num[i][j][k-1]+=num[i][j][k];
	rep(i,4010) rep(j,2010) dp[i][j]=inf;dp[0][0]=0;
	rep(i,n*2) rep(j,n+1){
		if(dp[i][j]>=inf || j>i) continue;
		dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+num[0][j][i-j]);
		dp[i+1][j]=min(dp[i+1][j],dp[i][j]+num[1][i-j][j]);
	}
	cout<<dp[n*2][n]<<endl;
}


Measured memory_bytes: 63360
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#include<string>
#define ll long long
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vi vector<ll>
#define el printf("\n")
#define N 100001
using namespace std;
vector<vector<int>> adj(N); // graph represented as an adjacency list // number of vertices
vector<long long> ans;
bool visited[2*N-1]={0};
ll nbr[2];
void dfs(int v) {
    visited[v] = true;
    for (int u : adj[v]) {
        if (!visited[u])
            dfs(u);
    }
    ans.push_back(v);
}

/*void topological_sort() {
    ans.clear();
    for (int i = 1; i <= n; ++i) {
        if (!visited[i])
            dfs(i);
    }
    reverse(ans.begin(), ans.end());
}

bool compare(int a,int b)
{
    if(a>b) return true;
    return false;
}*/

int main()
{   IOS;
    ll a;
    cin >> a;
    vector <ll> L;
    for(int i=0;i<a;i++)
    {
        ll e;
        cin >> e;
        L.push_back(e);
    }
    reverse(L.begin(),L.end());
    ll res=0;
    ll mini=0;
    for(int i=0;i<a-1;i++)
    {
        if(L[i]<=L[i+1])
            res++;
        else
            {mini=max(res,mini);
            res=0;}

    }
    mini=max(res,mini);

    cout << mini;


    cout.precision(30);
    return 0;
}


Measured memory_bytes: 3832
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		char[] a = sc.next().toCharArray();
		boolean lw = false;
		int rn = 0;
		int ws = 0;
		int last = 0;
		for(int i = 0; i < n; i++) {
			if(lw) {
				if(a[i] == 'R') {
					rn++;
				}
				if(rn == 1) {
					last = i;
				}
			}else {
				if(a[i] == 'W') {
					lw = true;
					ws = i;
				}
			}
		}
		int ans = 0;
		int end = ws + rn;
		for(int j = ws; j < end; j++) {
			if(a[j] == 'W') {
				ans++;
			}
			rn--;
		}
		System.out.println(ans);
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

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

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

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

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

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 36712
fn main() {
    let n: usize = read_line_as_value();
    let mut xys: Vec<Vec<i32>> = Vec::new();

    for i in 0..n {
        let xy: Vec<i32> = read_line_as_vector();
        xys.push(xy);
    }

    let mut total: f64 = 0.0;
    for i in 0..n {
        for j in 0..n {
            if i == j {
                continue
            } else {
                let pos_i = &xys[i];
                let pos_j = &xys[j];
                let dist = (((pos_i[0]-pos_j[0]).pow(2)+(pos_i[1]-pos_j[1]).pow(2)) as f64).sqrt();
                total += dist;
            }
        }
    }
    let ans = total / (n as f64);
    println!("{}", ans);
}

fn read_line_as_value<T: std::str::FromStr>() -> T {
    let mut input = String::new();
    let res = std::io::stdin().read_line(&mut input);
    if let Err(error) = res {
        panic!("io error at stdin.read_line: {}", error);
    };
    match input.trim().parse() {
        Ok(val) => val,
        _ => panic!("error while parsing input: {}", input)
    }
}

fn read_line_as_vector<T: std::str::FromStr>() -> Vec<T> {
    let mut input = String::new();
    let res = std::io::stdin().read_line(&mut input);
    if let Err(error) = res {
        panic!("io error at stdin.read_line: {}", error);
    };
    match input.trim().split_whitespace().map(|x| x.parse()).collect::<Result<Vec<T>, _>>() {
        Ok(vec) => vec,
        _ => panic!("error while parsing input: {}", input)
    }
}


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

/*iamsorry*/
 
#define thegamebegins   ios_base::sync_with_stdio(false); cin.tie(nullptr); //cout.tie(nullptr);
#define fileio          freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define int             long long
#define float           long double
#define E               "\n"
#define S               " "
#define INF             9e18
#define M7              1000000007
#define M9              998244353
#define PI              3.141592653589793238L
#define lcm(a,b)        ((a)/__gcd((a),(b)))*(b)
#define midl(l,r)       ((l)+((r)-(l))/2)
#define prec(n)         fixed<<setprecision(n)
#define in(arr,n)       for(int i=0; i<(n); ++i) cin>>arr[i]
#define fi(i,x,y)       for(int i=(x); i<(y); ++i)
#define fb(i,x,y)       for(int i=(x); i>=(y); --i)
#define fa(i,s)         for(auto i:(s))
#define fp(i,s)         for(auto i=(s).begin(); i!=(s).end(); ++i)
#define pf(i,s)         for(auto i=(s).rbegin(); i!=(s).rend(); ++i)
#define all(s)          (s).begin(), (s).end()
#define rev(s)          (s).rbegin(), (s).rend()
#define vc              vector
#define fr              first
#define sc              second
#define pb              push_back
#define eb              emplace_back
#define ins             insert
#define emp             emplace

#ifdef DOPPELLEBEN
template<typename T1,typename T2> ostream& operator<<(ostream &out,const pair<T1,T2> &p) {return out<<'('<<p.first<<", "<<p.second<<')';}
template<typename T> auto operator<<(ostream &out,T &&x)->decltype(x.begin(),out) {out<<'{'; for(auto it=x.begin();it!=x.end();++it)out<<*it<<(it==prev(x.end())?"":", "); return out<<'}';}
void dump() {}
template<typename T,typename... Args> void dump(T &&x,Args... args) {cerr<<" "<<x; dump(args...);}
struct ND{~ND(){cerr<<"]\n";}};
#define dbg(x...) cerr<<" ["<<(strcmp(#x,"")?#x ":":""),dump(x),ND(),cerr<<""
#else
#define dbg(...) 0 && cerr
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rann(n) rng()%(n)
#define ran(l,r) (l)+rng()%((r)-(l)+1)

template<typename T,typename t> T maxm(T &x,t y) {if(y>x)x=y; return x;}
template<typename T,typename t> T minm(T &x,t y) {if(y<x)x=y; return x;}
template<typename T> int sz(T &&x) {return (int)((x).size());}

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using pii = pair<int,int>;
using mii = map<int,int>;
using vvi = vector<vector<int>>;
using vpii = vector<pair<int,int>>;
using seti = set<int>;
using setd = set<int,greater<int>>;
using pqmx = priority_queue<int>;
using pqmn = priority_queue<int,vector<int>,greater<int>>;

/*__*/

void Main() {
	int t; cin>>t;
	cout<<(t>=30?"Yes":"No");
}

signed main() {
    thegamebegins

    int T=1;
    // cin>>T;
    while(T--) Main();

    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
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;
// inline int c2i(char c){
//     return (int)(c-'a');
// }
int main(){
    int n;
    string s;
    int q;
    cin >> n >> s >> q;
    vector<set<int>> se(26);
    rep(i,n){
        se[s[i]-'a'].insert(i);
    }
    
    
    rep(qi,q){
        int a;
        cin >> a;
        if(a==1){
            int i;
            char c;
            cin >> i >> c;
            i--;
            //cout << i << c << endl;    
            se[s[i]-'a'].erase(i);
            s[i] = c;
            se[c-'a'].insert(i);
        }else{
            int l,r;
            cin >> l >> r;
            l--; r--;
            int ans = 0;
            rep(i,26){
                //auto tmp = lower_bound(se[i].begin(),se[i].end(),l);
                auto tmp = se[i].lower_bound(l);
                if(tmp != se[i].end() && *tmp<=r) ans++;
            }
            cout << ans << endl;
            //cout << "aaaaa" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 24196
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a=sc.nextInt();
		int b=sc.nextInt();
		sc.close();
		int c=a*n;

		if(b>c) {
			System.out.println(c);
		}
		else {
			System.out.println(b);
		}
	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int
string s;
int jmp[(int)2e5 + 10][27] = {0};
int nex[(int)2e5 + 10] = {0};
int dp[(int)2e5 + 10] = {0};
bool vis[(int)2e5 + 10] = {0};
int sol(int i){
   if(i == -1)return 1;
   if(vis[i])return dp[i];
   vis[i] = true;
   int& minLen = dp[i];
   minLen = 1e9;
   FOR(j, 26){
       int ans = sol(jmp[i][j]);
       ans++;
       if(ans < minLen){
            nex[i] = j; 
            minLen = ans;
       }
   }
   return minLen;
}
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    cin >> s;
    map<char, int> last;
    map<char, bool> found;
    for(int i = s.length() - 1; i >= 0; i--){
       FOR(j, 26){
           jmp[i][j] = !found[char('a' + j)] ? -1 : last[char('a' + j)];
       }
       found[s[i]] = true;
       last[s[i]] = i; 
    }
    int minLen = 1e9; char x;
    FOR(i, 26){
        if(found['a' + i]){
            int ans = sol(last['a' + i]);
            if(ans < minLen){
                minLen = ans;
                x = 'a' + i;
            }
        }else{
            cout << char('a' + i);
            return 0;
        }
    }
   // debug(minLen);
    int ind = last[x];
    cout<< s[ind];
    while(ind != -1){
        int j = nex[ind];
        cout << char('a' + j);
        ind = jmp[ind][j];
    }
   

}




Measured memory_bytes: 46356
n=gets.to_i
a=[]
max=0
max_idx=0
n.times do|i|
	a[i]=gets.to_i
	if(a[i]>max)
		max=a[i]
		max_idx=i
	end
end
for i in 0..n-1
	if(i==max_idx)
		a.delete_at(max_idx)
		puts(a.max)
		i-=1
	else
		puts(max)
	end
end

Measured memory_bytes: 5192
def main():
    from collections import defaultdict
    from collections import Counter
    import sys

    n = int(input())
    a = list(map(int, sys.stdin.readline().split()))

    d = Counter(a)
    e = defaultdict(int)

    func = lambda x: x * (x - 1) // 2 if x >= 2 else 0
    v = list(d.values())
    base = sum(list(map(func, v)))

    for k, v in d.items():
        if v <= 1:
            e[k] = base - 0
        else:
            e[k] = base - (v * (v - 1) // 2 - (v - 1) * (v - 2) // 2)

    p = [str(e[x]) + '\n' for x in a]
    q = ''.join(p)
    print(q)


if __name__ == '__main__':
    main()


Measured memory_bytes: 44256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
using namespace std;


int main() {
	long long int a, b, c, d, n,res=0, m, tmp = 1, q, sum[200000] = {}, x[200000] = {}, v[200000] = {};
	string str;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> x[i];
	}
	sort(x + 1, x + n + 1);
	for (int i = 2; i <= n; i++) {
		if (x[i] == x[i - 1]) { tmp++; }
		else {
			if (tmp % 2 == 1) { res++; }
			tmp = 1;
			
		}
	}

	if (tmp % 2 == 1) { res++; }
	cout << res;
}

Measured memory_bytes: 1792
import sys
import math

alphabet = [chr(i) for i in range(97, 97+26)]
result = []

def alphabet_decimal(v):
    quotient = math.floor(v / len(alphabet))
    surplus = v % len(alphabet)
    quotient -= 1 if surplus == 0 else 0
    surplus = len(alphabet) if surplus == 0 else surplus
    result.append(surplus)
    if len(alphabet) < quotient:
        alphabet_decimal(quotient)
    elif len(alphabet) < v:
        result.append(quotient)
    return "".join([alphabet[i - 1] for i in reversed(result)])

n = int(input())
print(alphabet_decimal(n))

Measured memory_bytes: 9216
def main():
    n = int(raw_input().strip())
    data = map(int, raw_input().split())
    print " ".join([str(x) for x in data])
    insertion_sort(n, data)

def insertion_sort(n, data):
    for i in xrange(1, n):
        if data[i - 1] > data[i]:
            temp = data[i]
            while i > 0 and data[i - 1] > temp:
                data[i] = data[i - 1]
                i -= 1
            data[i] = temp
        print " ".join([str(x) for x in data])

if __name__ == '__main__':
    main()


Measured memory_bytes: 4656
#include "bits/stdc++.h"
using namespace std;
int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	int N; cin >> N;
	int i ;
	for (i = 0; i*i <= N; i++); i--;
	printf("%d\n", i*i);
	return 0;
}

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

using namespace std;

int main(){

    int N;
    int Amax = 0;
    vector<int> divisible;
    vector<int> A;

    cin >> N;
    A.resize(N);
    for (int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        Amax = max(Amax, a);
        A[i] = a;
    }
    divisible.resize(Amax + 1, 0);
    for (int i = 0; i < N; i++){
        int a = A[i];
        divisible[a] += 1;
        for (int i = 2; i * a <= Amax; i++){
            divisible[i * a] += 2;
        }   
    }
    int count = 0;
    for (int i = 0; i < N; i++){
        if(divisible[A[i]] < 2){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 7996
#!/usr/bin/env python3
n,m = map(int,input().split())
a = [0]*n
b = [0]*n
for i in range(n):
	a[i],b[i] = map(int,input().split())
a,b = zip(*sorted(zip(a,b)))
cur_sum = 0
for i in range(n):
	cur_sum += b[i]
	if cur_sum >= m:
		print(a[i])
		exit(0)

Measured memory_bytes: 25932
from collections import deque
n = int(input())
path = [[] for _ in range(n)]
ab = []
color = {}
for i in range(n-1):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  ab.append((a,b))
  path[a].append(b)
  path[b].append(a)
  
que = deque()
que.append((0,0))
reached = [False]*n
reached[0] = True
while que:
  p,pc = que.popleft()
  c = 0
  for i in path[p]:
    if reached[i] == False:
      while True:
        c += 1
        if c == pc:continue
        color[tuple(sorted((p,i)))] = c
        break
      reached[i] = True
      que.append((i,c))
print(max(color.values()))
for i in ab:
  print(color[i])


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

#define rep(X, N) for (ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(), (V).end()
#define endl "\n"

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;

class ModInt{
public:
    long long n;
    int p;

    ModInt(){
    }

    //値と割る値を受け取って、オブジェクトを返す
    ModInt(long long _n, int _p){
        p = _p;
        n = _n % _p;

        //負の値を受け取ったときには正の値に戻す
        if(n < 0){
            n += p;
        }
    }

    ModInt operator+(ModInt a){

        ModInt tmp = ModInt(*this);

        tmp.n += a.n;

        if(tmp.n > tmp.p){
            tmp.n -= tmp.p;
        }
        
        return tmp;
    }

    ModInt operator-(ModInt a){

        ModInt tmp = ModInt(*this);

        tmp.n -= a.n;

        if(tmp.n < 0){
            tmp.n += tmp.p;
        }

        return tmp;
    }

    ModInt operator*(ModInt a){

        ModInt tmp = ModInt(*this);

        tmp.n = (tmp.n * a.n) % tmp.p;

        return tmp;
    }

    int modpow(int b, int k){
        if(k == 0){
            return 1;
        }else if(k % 2 == 1){
            long long tmp = b;
            tmp = tmp * modpow(b, k - 1) % p;
            
            return tmp;
        }else{
            long long tmp = modpow(b, k / 2);
            return tmp * tmp % p;
        }
    }

    int modinv(int b){
        return modpow(b, p - 2);
    }

    ModInt operator/(ModInt a){

        ModInt tmp = ModInt(*this);

        tmp.n = tmp.n * modinv(a.n) % tmp.p;
        return tmp;
    }
};

int main(){

    int n;
    cin >> n;

    vector<ModInt> pow10(n + 1);
    pow10[0] = ModInt(1, MODN);
    ModInt ten = ModInt(10, MODN);

    for(int i = 1; i <= n; i++){
        pow10[i] = pow10[i - 1] * ten;
    }

    vector<ModInt> pow9(n + 1);
    pow9[0] = ModInt(1, MODN);
    ModInt nine = ModInt(9, MODN);
    for(int i = 1; i <= n; i++){
        pow9[i] = pow9[i - 1] * nine;
    }

    vector<ModInt> pow8(n + 1);
    pow8[0] = ModInt(1, MODN);
    ModInt eight = ModInt(8, MODN);
    for(int i = 1; i <= n; i++){
        pow8[i] = pow8[i - 1] * eight;
    }

    if(n == 1){
        cout << 0 << endl;
    }else if(n == 2){
        cout << 2 << endl;
    }else{
        cout << (pow10[n] - pow9[n] - pow9[n] + pow8[n]).n << endl;
    }
    return 0;
}


Measured memory_bytes: 50200
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pii pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)
#define ios ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
int main() 
{
    ios;
 int n;cin>>n;
  int ar[n];
   f(i,0,n)cin>>ar[i];
  
   int min=100000,sum=0,sum1=0;
   f(i,0,n)
   { sum+=ar[i];sum1=0;
   	f(j,i+1,n)
   	  sum1+=ar[j];
   	 if(abs(sum-sum1)<min)
		 min=abs(sum-sum1);  
   }
   cout<<min;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int k, a, b, count = 0;
    scanf("%d%d%d",&k,&a,&b);
    int i;
    for( ; a <= b; a++){
        if(a % k == 0){
            count++;
        }

    }
    //printf("i: %d\n",i);
    if(count > 0){
        printf("OK\n");
    }
    if(count == 0) {
        printf("NG\n");
    }


    return 0;
}


Measured memory_bytes: 1648
#include <iostream>

int main() {
    int n, m;
    std::cin >> n >> m;

    int a[n], b[n], i, min[n], min_index[n];
    for(i=0; i<n; i++) {
        std::cin >> a[i] >> b[i];
        min[i] = 500000000;
    }
    int c[m], d[m], j, dist;
    for(j=0; j<m; j++) {
        std::cin >> c[j] >> d[j];
        for(i=0; i<n; i++) {
            dist=0;
            if(a[i]-c[j]<0) {
                dist = c[j]-a[i];
            } else {
                dist = a[i]-c[j];
            }
            if(b[i]-d[j]<0) {
                dist += d[j]-b[i];
            } else {
                dist += b[i]-d[j];
            }
            if(min[i]>dist) {
                min[i] = dist;
                min_index[i] = j+1;
            }
        }
    }

    for(i=0; i<n; i++) {
        std::cout << min_index[i] << std::endl;
    }

    return 0;
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>

void merge(int,int,int);
void mergeSort(int,int);

#define MAX 500000

int A[MAX],L[MAX],R[MAX],N,count=0,left=0,right;

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

  right=N;
  mergeSort(left,right);

  for (i=0;i<N-1;i++){
    printf("%d ", A[i]);
  }

  printf("%d\n",A[N-1]);
  printf("%d\n",count);

  return 0;
}


void merge(int left,int mid,int right){
  int n1,n2,k,i,j;
  n1 = mid - left;
  n2 = right - mid;
  //L[0...n1], R[0...n2] ?????????
  for( i = 0 ;i< n1;i++){
    L[i] = A[left + i];
  }
  for(i = 0;i<n2;i++){
    R[i] = A[mid + i];
  }
  L[n1] = INT_MAX;
  R[n2] = INT_MAX;
  i = 0;
  j = 0;
  for(k = left ;k<right;k++){
    count++;
    if(L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    }
    else {
      A[k] = R[j];
      j = j + 1;
    }
  }

}

void mergeSort(int left,int right){
  int mid;
  if(left+1<right){
    mid = (left + right)/2;
    mergeSort(left, mid);
    mergeSort(mid, right);
    merge(left, mid, right);

  }

}

Measured memory_bytes: 5484
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	int n;
	ll x;
	cin >> n >> x;
	ll a[n];
	REP(i,n) cin >> a[i];
	sort(a, a + n);
	int ans = 0;
	REP(i,n - 1){
		if(a[i] <= x){
			x -= a[i];
			ans++;
		}else break;
	}
	if(a[n - 1] == x) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
#define pb push_back
#define mp make_pair
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
 
const int inf = int(1e9);
const int mod = 1e9 + 7;
const int N = 1e6 + 555;
const long double PI = acos(-1.0);

void solve()
{
	int a;
	cin >> a;
	if(a <= 9) cout << (a);
	else{
		int res = 9, cur = 10, cnt = 0;
		while(cur <= a){
			if(cnt % 2 == 0 && cnt){
				res *= 100;
				res += 9;
			}
			cur *= 10;
			cnt++;
		}
		cur /= 10;
		cout << res + (cnt % 2 == 0) * (a - cur + 1); 

	}





}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 int n,x,t;
  cin >> n >> x >> t;
  int sho = n/x;
  int out = 0;
if(n%x!=0){
  out = (sho+1)*t;
}else{
  out = sho*t;
}
  cout << out << endl;
   return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int count = 0;
        for (int i = 0; i < s.length() / 2; i++) {
            if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
                count++;
            }
        }
        System.out.println(count);
        sc.close();
    }
}

Measured memory_bytes: 21332