akhauriyash/Code-Regression huggingface dataset:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,a,b = readInts()
X = readInts()
cnt = 0
for i in range(n-1):
    cnt += min((X[i+1]-X[i]) * a, b)
print(cnt)


Measured memory_bytes: 21484
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#define ll long long
#define oku7 1000000007
using namespace std;
int ans[100][100];

pair<int, int> pmove(pair<int, int> now, int W){
	if (now.first + 1 < W && now.second%2==0){
		return make_pair(now.first + 1, now.second);
	}
	else if(now.first-1>=0 && now.second%2==1){
		return make_pair(now.first - 1, now.second);
	}
	else{
		return make_pair(now.first, now.second + 1);
	}
}

int main(){
	vector<int> v;
	int H,W,N;
	cin >> H>>W>>N;
	for (int i = 0; i < N; i++){
		int tnp;
		cin >> tnp;
		v.push_back(tnp);
	}
	pair<int, int> place=make_pair(0,0);	//x,y
	for (size_t j = 0; j < v.size();j++){
		for (int i = 0; i < v[j]; i++){
			ans[place.second][place.first] = j + 1;
			place = pmove(place, W);
		}
	}
	for (int i = 0; i < H; i++){
		for (int j = 0; j < W; j++){
			cout << ans[i][j] << " ";
		}
		cout << "\n";
	}


	

	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
  int n; cin >> n;
  vector<int> a(n);
  vector<bool> ok(1000010,false);
  vector<int> cnt(1000010);
  rep(i,n){
    cin >> a[i];
    ok[a[i]] = true;
    cnt[a[i]]++;
  }
  int ans = 0;
  rep(i,1000010){
    if(ok[i]){
      if(cnt[i] == 1) ans++;
      for(int j = i; j <= 1000000; j += i){
        ok[j] = false;
      }
    }
  }
  cout << ans << endl;

}


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

int main() {
  int n;
  cin >> n;
  int flag = 0;
  int p, q;
  rep(i, n) {
    cin >> p;
    if (p!=i+1) flag++;
  }
  if (flag <= 2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

import static java.lang.System.exit;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] n = sc.next().toCharArray();
        for(int i = 0 ; i< n.length; i++){
            if(n[i] == '7'){
                System.out.println("Yes");
                exit(0);
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 35608
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		long[] a = new long[n];
		for(int i = 0; i < n; i++) {
			a[i] = stdIn.nextLong();
		}
		
		long[]s = new long[n+1];
		for(int i = 0; i < n; i++) {
			s[i+1] = s[i] + a[i];
		}
		Map<Long,Long> map = new HashMap<>();
		
		for(int i = 0; i < n+1; i++) {
			if(!map.containsKey(s[i])) {
				map.put(s[i], (long)0);
			}
			map.put(s[i], map.get(s[i])+1);
		}
		long cnt = 0;
		
		/*for(int i = 0; i < map.size(); i++) {
			if(map.get(s[i]) < 2) {
				continue;
			}else {
				cnt += map.get(s[i])*(map.get(s[i])-1)/2;
			}
		}*/
		
		for(long ss: map.keySet()) {
			if(map.get(ss) < 1) {
				continue;
			}else {
				cnt += map.get(ss)*(map.get(ss)-1)/2;
			}
		}
		
		System.out.println(cnt);
		
	}

}

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

using namespace std;

typedef long long LL;

const int N = 110;

int n;
int a[N];

bool check(int i)
{
    if(a[i] > a[i - 1] && a[i] < a[i + 1]) return true;
    if(a[i] < a[i - 1] && a[i] > a[i + 1]) return true;
    return false;
}

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];

    int res = 0;
    for(int i = 2; i < n; i++)
        if(check(i))
            res++;

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


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
 
#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)
 
int n;
vector<int> es[200000], esr[200000];
 
int cn;
vector<int> cy;
 
void cycle() {
	int v = 0;
	vector<int> temp;
	REP(i, n + 1) {
		temp.push_back(v);
		v = esr[v][0];
	}
	int t = temp[temp.size() - 1];
	cy.push_back(t);
	REP(i, n + 1) {
		int u = temp[temp.size() - 2 - i];
		cy.push_back(u);
		if (u == t) break;
	}
	cn = cy.size() - 1;
}
 
int gr[200000][2], cand[200000];
 
int dfs(int v, int u) {
	vector<int> cand;
	REP(i, es[v].size()) if (es[v][i] != u) cand.push_back(dfs(es[v][i], -1));
	sort(ALL(cand));
	gr[v][0] = 0;
	REP(i, cand.size()) {
		if (cand[i] == gr[v][0]) ++gr[v][0];
		else if (cand[i] > gr[v][0]) break;
	}
	gr[v][1] = gr[v][0] + 1;
	REP(i, cand.size()) {
		if (cand[i] == gr[v][1]) ++gr[v][1];
		else if (cand[i] > gr[v][1]) break;
	}
	return gr[v][0];
}
 
int arr[200001];
int assign[200000];
 
bool solve(int gri) {
	arr[cn] = gr[cy[0]][gri];
	REP(i, cn) {
		int ci = cn - 1 - i;
		int v = cy[ci];
		if (arr[ci + 1] == gr[v][0]) arr[ci] = gr[v][1];
		else arr[ci] = gr[v][0];
	}
	if (arr[cn] != arr[0]) return false;
	REP(i, n) assign[i] = gr[i][0];
	REP(i, cn) assign[cy[i]] = arr[i];
	REP(i, n) {
		if (assign[i] == assign[esr[i][0]]) return false;
		set<int> s;
		REP(j, es[i].size()) if (assign[es[i][j]] < assign[i]) s.insert(assign[es[i][j]]);
		if (s.size() != assign[i]) return false;
	}
	return true;
}
 
int main(int argc, char **argv) {
	cin >> n;
	REP(i, n) {
		int p;
		cin >> p;
		--p;
		es[p].push_back(i);
		esr[i].push_back(p);
	}
	cycle();
	REP(i, cn) dfs(cy[i], cy[i + 1]);
	cout << (solve(0) || solve(1) ? "POSSIBLE" : "IMPOSSIBLE") << endl;
	return 0;
}

Measured memory_bytes: 25204
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  int n;
  map<string,int> mp;
  string s;
  cin >> n;
  rep(i,n){
    string s;
    cin >> s;
    mp[s]++;
  }
  cout << "AC x " << mp["AC"] << endl;
  cout << "WA x " << mp["WA"] << endl;
  cout << "TLE x "<< mp["TLE"] << endl;
  cout << "RE x " << mp["RE"] << endl;
 
  return 0;
}


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

void push(int);
int  pop(void);
int CheckNumber(string);
int CheckDigit(string input);

#define MAXCOUNT 100
int stack[MAXCOUNT];
int stackcount = 0;

int main(void){
  string input;
  int data;
  int temp;

    while(cin >> input){

      if(CheckNumber(input)==1){
        data = 0;
        for ( int i = 0  ; i < CheckDigit(input) ; i++){
          data *= 10;
          data += input[i] - '0';
        }
        push(data);
      }else{
        switch(input[0]){
          case '+':
          push(pop() + pop());
          break;

          case '-':
          temp = pop();
          push(pop() - temp);
          break;

          case '*':
          push(pop() * pop());
          break;

          default:
          break;
        }
      }
    }

    cout << pop() << endl;

    return 0;
}

void push(int input){
  if(stackcount < MAXCOUNT ){
    stack[stackcount] = input;
    stackcount++;
  }
}

int pop(void){
  int ret;
  if (stackcount > 0){
    stackcount--;
    ret = stack[stackcount];
  }
  return ret;
}

int CheckNumber(string input){

  int i = 0;
  int flag = 0;

  while ( input[i] != '\0'){
    if ( (input[i] >= '0') && (input[i] <= '9')){
      flag = 1;
    }else{
      flag = 0;
      break;
    }
    i++;
  }
  return flag;
}

int CheckDigit(string input){

  int i = 0;
  int digit = 0;

  while ( input[i] != '\0'){
    if ( (input[i] >= '0') && (input[i] <= '9')){
      digit++;
    }else{
      digit = 0;
      break;
    }
    i++;
  }
  return digit;
}

Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  Int n;
  cin>>n;
  vector<Int> c(n-1),s(n-1),f(n-1);
  for(Int i=0;i<n-1;i++) cin>>c[i]>>s[i]>>f[i];
  for(Int i=0;i<n-1;i++){
    Int x=0;
    for(Int j=i;j<n-1;j++){
      if(x<=s[j]) x=s[j]+c[j];
      else{
	x-=s[j];
	x=(x+f[j]-1)/f[j]*f[j];
	x+=s[j];
	x+=c[j];
      }
    }
    cout<<x<<endl;
  }
  cout<<0<<endl;
  return 0;
}


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

typedef pair<int,int> P;

bool comp(P a,P b){
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
    int n;
    cin >> n;
    vector<P> red(n);
    vector<P> blue(n);
    for(int i=0;i<n;i++){
        cin >> red[i].first >> red[i].second;
    }
    for(int i=0;i<n;i++){
        cin >> blue[i].first >> blue[i].second;
    }
    sort(red.begin(),red.end());
    sort(blue.begin(),blue.end());
    int cnt=0;
    vector<bool> used(n,false);
    for(int i=0;i<n;i++){
        int maxv=-1;
        int index=-1;
        for(int j=0;j<n;j++){
            if(red[j].second<blue[i].second&&red[j].first<blue[i].first&&used[j]==false&&maxv<red[j].second){
                maxv=red[j].second;
                index=j;
            }
        }
        if(index!=-1){
            cnt++;
            used[index]=true;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    internal static class CR
    {
        public static string GetText() { return Console.ReadLine(); }
        public static List<string> GetTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long GetLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> GetLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }
    }

    public class Program
    {
        public static long M { get; private set; }
        public static long N { get; private set; }

        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var inputs = CR.GetLongs();
            M = inputs[0];
            N = inputs[1];

            return M * (M - 1) / 2 + N * (N - 1) / 2;
        }
    }
}


Measured memory_bytes: 13396
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut says = vec![vec![]; n];
    for i in 0..n {
        let a = read::<usize>();
        for _ in 0..a {
            let v = read_vec::<usize>();
            says[i].push((v[0] - 1, v[1]));
        }
    }

    let mut ans = 0;
    'outer: for i in 0..1 << n {
        let mut is_honest = vec![0; n];

        for j in 0..n {
            is_honest[j] = (i >> j) & 1;
        }

        for j in 0..n {
            if is_honest[j] == 0 {
                continue;
            }
            for &(x, y) in says[j].iter() {
                if y != is_honest[x] {
                    continue 'outer;
                }
            }
        }
        ans = max(ans, i.count_ones());
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    vector<ll> x(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> x[i];
    }

    ll _min = LLONG_MAX;
    for (ll i = 1; i <= 100; i++)
    {
        ll temp = 0;
        for (auto&& t : x)
        {
            temp += (t - i) * (t - i);
        }

        _min = min(_min, temp);
    }
    cout << _min << endl;
}


Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define NCK_MAX 510000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
  int k,x;std::cin >> k >> x;
  int sum = 500 * k;
  if (sum >= x) std::cout << "Yes" << '\n';
  else std::cout << "No" << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=max(a, b)
#define chmin(a, b) (a)=min(a, b)
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/

class LazySegTree {
public:
  ll n, height;
  vector<ll> data, lazy;
  
  LazySegTree(ll _n) {
    n=1;
    height=1;
    while(n<_n) {
      n*=2;
      height++;
    }
    data=vector<ll>(2*n-1);
    lazy=vector<ll>(2*n-1);
  }
  
  void eval(ll k, ll l, ll r) {
    if(lazy[k]!=0) {
      data[k]+=lazy[k];
      
      if(r-l>1) {
        lazy[k*2+1]+=lazy[k]/2;
        lazy[k*2+2]+=lazy[k]/2;
      }
      lazy[k]=0;
    }
  }
  
  void _add(ll a, ll b, ll x, ll k, ll l, ll r) {
    eval(k, l, r);
    if(r<=a || b<=l) return;
    
    if(a<=l && r<=b) {
      lazy[k]+=(r-l)*x;
      eval(k, l, r);
    }else {
      _add(a, b, x, k*2+1, l, (l+r)/2);
      _add(a, b, x, k*2+2, (l+r)/2, r);
      data[k]=data[k*2+1]+data[k*2+2];
    }
  }
  
  void add(ll a, ll b, ll x) {_add(a, b, x, 0, 0, n);}
  
  //[a, b):要求区間，[l, r):今見ている区間
  ll _sum(ll a, ll b, ll k, ll l, ll r) {
    if(r<=a || b<=l) return 0;
    
    eval(k, l, r);
    if(a<=l && r<=b) {
      return data[k];
    }else {
      ll s=_sum(a, b, k*2+1, l, (l+r)/2);
      ll t=_sum(a, b, k*2+2, (l+r)/2, r);
      return s+t;
    }
  }
  
  ll sum(ll a, ll b) {return _sum(a, b, 0, 0, n);}
  
};



int main() {
  ll i, j, k;
  
  ll N, D, A;
  cin >> N >> D >> A;
  pll p[MAX*2];
  
  
  for(i=0; i<N; i++) {
    cin >> p[i].ft >> p[i].sc;
    p[i].sc=(p[i].sc+A-1)/A;
  }
  p[N]=pll(INF, INF);
  sort(p, p+N);
  
  LazySegTree lst=LazySegTree(N);
  
  ll ans=0;
  for(ll l=0; l<N; l++) {
    ll r=upper_bound(p, p+N+1, pll(p[l].ft+D*2, INF))-p; r--;
    
    ll t=max(0LL, p[l].sc-lst.sum(l, l+1));
    lst.add(l, r+1, t);
    ans+=t;
  }
  
  pt(ans);
  
  
}




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

int main()
{
    int H, W;

    for (int k = 0; k<10000; k++)
    {
        cin >> H >> W;
        if (H != 0 && W != 0)
        {
            for (int h=0; h<H; h++)
            {
                if (h%2==0)
                {
                    for (int w=0; w<W; w++)
                    {
                        if (w%2==0) cout << "#";
                        else cout << ".";
                        //cout << endl;
                    }
                }
                else
                {
                    for (int w=0; w<W; w++)
                    {
                        if (w % 2 == 1) cout << "#";
                        else cout << ".";
                        //cout << endl;
                    }
                }
                cout << endl;
            }
            cout << endl;
        }
        else k = 10000;
    }
    return 0;
}

Measured memory_bytes: 3088
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

using ll = int64_t;

int main(int, const char**)
{
    int n;
    cin >> n;
    int c = 0;
    rep(i, n)
    {
        int a, b;
        cin >> a >> b;
        if(a == b)
        {
            c++;
            if(c >= 3)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
        else
        {
            c = 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};

int main(){
    int m;
    cin>>m;
    cout<<48-m<<endl;
}





Measured memory_bytes: 256
N = gets.chomp.to_i
otoshidamas = []
N.times do |i|
    otoshidamas << gets.chomp.split(" ")
end
sum = 0
otoshidamas.each_with_index do |otoshidama,i|
    if otoshidama[1] == "JPY"
        sum += otoshidama[0].to_f
    else
        sum += (otoshidama[0].to_f * 380000.0)
    end
end

puts sum


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main(){
	IOS;
	int n;
	cin >> n;
	vector <int> arr(n), p(n), q(n);

	for(int i = 0; i < n; i++){
		cin >> p[i];

		arr[i] = i+1;
	}

	for(int i = 0; i < n; i++){
		cin >> q[i];
	}

	int a = 0, b = 0;
	int count = 1;
	do{
		int flag = 1;
		for(int i = 0; i < n; i++){
			if(p[i] != arr[i]){
				flag = 0;
				break;
			}
		}
		if(flag == 1){
			a = count;
		}

		flag = 1;

		for(int i = 0; i < n; i++){
			if(q[i] != arr[i]){
				flag = 0;
				break;
			}
		}
		if(flag == 1){
			b = count;
		}

		if(a && b)
			break;

		count++;

	}while(next_permutation(arr.begin(), arr.end()));

	cout << abs(a-b) << endl;




	return 0;
}

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

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}

#define PRINT_VECTOR_MAX 100
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)min(v.size(),PRINT_VECTOR_MAX); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)min(v.size(),PRINT_VECTOR_MAX); i++) {for (ll j = 0; j < (ll)min(v[i].size(),PRINT_VECTOR_MAX); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

void Main();
int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	Main();
	return 0;
}

void Main(){
	int t; cin >> t;
	ll n, m, a, b;
	Rep(t){
		cin >> n >> m >> a >> b;
		cout << floor_sum(n,m,a,b) << endl;
	}
}


Measured memory_bytes: 3688
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
int main()
{
	int n;
	vector<int>vec;
	cin >> n;
	for(int i=0;i<n;i++)
	{
		int a; scanf("%d",&a);
		vec.pb(a);
	}
	int a=0,b=0,c=0,d=0,e=0;
	for(int i=1;i<n-1;i++)
	{
		if(vec[i-1] < vec[i] && vec[i] > vec[i+1]) d++;
		if(vec[i-1] > vec[i] && vec[i] < vec[i+1]) e++;
	}
	vector<int>v;
	int cur = -1;
	int lt = -1;
	for(int i=0;i<n-1;i++)
	{
		if(cur == -1)
		{
			if(vec[i] < vec[i+1]) cur=0;
			if(vec[i] == vec[i+1]) cur=1;
			if(vec[i] > vec[i+1]) cur=2;
			continue;
		}
		if(cur == 0 && !(vec[i] < vec[i+1]))
		{
			v.pb(0); lt = i;
		}
		if(cur == 1 && !(vec[i] == vec[i+1]))
		{
			v.pb(1); lt = i;
		}
		if(cur == 2 && !(vec[i] > vec[i+1]))
		{
			v.pb(2); lt = i;
		}
		if(vec[i] < vec[i+1]) cur=0;
		if(vec[i] == vec[i+1]) cur=1;
		if(vec[i] > vec[i+1]) cur=2;
	}
	v.pb(cur);

	for(int i=1;i<v.size()-1;i++)
	{
		if(v[i-1] == 0 && v[i] == 1 && v[i+1] == 2) a++;
		if(v[i-1] == 2 && v[i] == 1 && v[i+1] == 0) b++;
		if(v[i-1] == 0 && v[i] == 1 && v[i+1] == 0) c++;
		if(v[i-1] == 2 && v[i] == 1 && v[i+1] == 2) c++;
	}
	cout << a << " " << b << " " << c << " " << d << " " << e << endl;
}


Measured memory_bytes: 2120
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#define MAXN 310
int n, k, m, f[MAXN][MAXN], g[MAXN][MAXN], c[MAXN][MAXN];
inline void up(int &x, int y) {
	if ((x += y) >= m) x -= m;
}
int main() {
	scanf("%d%d%d", &n, &k, &m);
	c[0][0] = 1;
	for (int i = 1; i < 300; i++) {
		c[i][0] = 1;
		for (int j = 1; j <= i; j++)
			c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % m;
	}
	f[1][0] = 1;
	g[1][0] = 1;
	for (int i = 0; i <= k; i++) f[1][i] = 1;
	for (int i = k; i >= 0; i--) g[1][i] = (g[1][i + 1] + f[1][i]) % m;
	for (int i = 2; i <= n + 1; i++) {
		for (int j = 0; j <= k; j++) {
			for (int l = 1; l < i; l++) {
				up(f[i][j], 1LL * f[i - l][j] * g[l][j + 1] % m * c[i - 2][l - 1] % m);
			}
		}
		for (int j = k; j >= 0; j--) {
			g[i][j] = (g[i][j + 1] + f[i][j]) % m;
		}
	}
	printf("%d\n", f[n + 1][0]);
	return 0;
}

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

int main(){
    int n, m;
    while(cin >> n >> m, n+m){
        vector<pair<int,int>> v;
        int d, p, sum = 0;
        for(int i = 0; i < n; i++){
            cin >> d >> p;
            sum += p*d;
            v.push_back({p,d});
        }
        sort(v.rbegin(), v.rend());

        for(int i = 0; m > 0 && i < n; i++){
            int use = min(m, v[i].second);
            m -= use;
            sum -= use*v[i].first;
        }

        cout << sum << endl;
    }
    return 0;
}


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

long int pair(int num) {
  if (num  > 0) {
    return ((long int) num * ((long int) num - (long int) 1) / (long int) 2);
  }
  return 0;
}

int main(void) {
  int max_count;
  scanf("%d", &max_count);
  int num[max_count];
  int num_count[max_count];
  for (int i = 0; i < max_count; i++) {
    num_count[i] = 0;
  }
  for (int i = 0; i < max_count; i++) {
    scanf(" %d", &num[i]);
    num_count[num[i] - 1]++;
  }

  long int pairs_diff[max_count];
  long int max_pairs = 0;
  for (int i = 0; i < max_count; i++) {
    pairs_diff[i] = pair(num_count[i] - 1) - pair(num_count[i]);
    // printf("%ld\n", pairs_diff[i]);
    max_pairs += pair(num_count[i]);
  }
  // printf("%ld\n", max_pairs);
  for (int i = 0; i < max_count; i++) {
    int k_num = num[i];
    printf("%ld\n", max_pairs + pairs_diff[k_num - 1]);
  }

  return 0;
}


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

#define MOD 1000000007

using namespace std;

int main() {
	int n;
	string s;
	cin >> n >> s;
	int cnt[26];
	memset(cnt, 0, sizeof(cnt));
	for (int i = 0; i < n; i++) {
		cnt[s[i] - 'a'] += 1;
	}
	int ans = 1;
	for (int i = 0; i < 26; i++) {
		ans = 1LL * ans * (cnt[i] + 1) % MOD;
	}
	cout << ans - 1 << endl;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
 int main(void)
 {
 int a,b,i;
 char op;
 for(i=1;i>0;i++)
{
 scanf("%d %c %d",&a,&op,&b);
 if(op=='+') printf("%d\n",a+b);
 else if(op=='-') printf("%d\n",a-b);
 else if(op=='*') printf("%d\n",a*b);
 else if(op=='/') printf("%d\n",a/b);
 else if(op=='?') break;
 }
 return 0;
 } 


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

using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define pf 				push_front
#define mp              make_pair
#define pii             pair<int,int>
#define MAX 			1000000
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
void c_p_c()
{
#ifndef  ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
bool complete(int satisfied[], int n)
{
	int i;
	for (i = 0; i < n; i++)
	{
		if (satisfied[i] != 1)
			return false;
	}
	return true;
}
void swap(int *x, int *y)
{
	int t = *x;
	*x = *y;
	*y = t;
}

bool f(int x, int y)
{
	return x > y;
}
int Lucky(int n)
{
	int c = 0;
	while (n != 0)
	{
		int r = n % 10;
		if (r == 4 || r == 7)
			c++;
		n /= 10;
	}
	return c;
}
bool isPrime(int x)
{
	int i;
	for (i = 2; i <= sqrt(x); i++)
	{
		if (x % i == 0)
			return false;
	}
	return true;
}
int32_t main()
{
	
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	int sum = 0;
	int i;
	for (i = 1; i <= n; i++)
	{
		if (i % 3 == 0 || i % 5 == 0)
			continue;
		else
			sum += i;
	}
	cout << sum;
}



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

int main() {
    int A, B;
    cin >> A >> B;

    cout << A * B << endl;
    return 0;
}

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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    long double l;
    cout << fixed << setprecision(15);
    cin >> l;
    cout << (l*l*l)/27 << "\n";
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=505;
const int mod=1e9+7;
int pow_mod(int a,int b)
{
	int ret=1;
	for(;b;b>>=1,a=1LL*a*a%mod)if(b&1)ret=1LL*ret*a%mod;
	return ret;
}
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
void dl(int &x,int y){x-=y;if(x<0)x+=mod;}
int f[MAXN][MAXN],g[MAXN][MAXN];
int n,X,num[MAXN],pw[MAXN][MAXN],C[MAXN][MAXN],inv[MAXN],pre[MAXN];
int main()
{
	for(int i=0;i<MAXN;i++)
	{
		C[i][0]=1;
		for(int j=1;j<=i;j++)C[i][j]=C[i-1][j],ad(C[i][j],C[i-1][j-1]);
	}
	for(int i=0;i<MAXN;i++)
	{
		pw[i][0]=1;
		for(int j=1;j<MAXN;j++)pw[i][j]=1LL*pw[i][j-1]*i%mod;
	}
	pre[0]=1;for(int i=1;i<MAXN;i++)pre[i]=1LL*pre[i-1]*i%mod;
	inv[MAXN-1]=pow_mod(pre[MAXN-1],mod-2);
	for(int i=MAXN-2;i>=0;i--)inv[i]=1LL*inv[i+1]*(i+1)%mod;
	n=read();X=read();
	for(int i=1;i<=n;i++)num[read()]++;
	f[0][0]=1;
	for(int i=X;i>=1;i--)
	{
		for(int j=0;2*j-1<=X;j++)for(int k=i*j;k+j-1<=X;k++)if(f[j][k])
			for(int l=0;k+l*i<=X&&2*(j+l)-1<=X;l++)
				ad(g[j+l][k+l*i],1LL*f[j][k]*inv[l]%mod);
		for(int j=0;2*j-1<=X;j++)for(int k=i*j;k<=X;k++)
		{
			f[j][k]=1LL*g[j][k]*pw[k-i*j+j][num[i]]%mod;
			g[j][k]=0;
		}
	}
	int ans=0;
	for(int i=0;2*i-1<=X;i++)for(int j=0;j+i-1<=X;j++)if(f[i][j])
	{
		int t=1LL*C[X-(j+i-1)+i][i]*f[i][j]%mod*pre[i]%mod;
		if((X-j)&1)dl(ans,t);else ad(ans,t);
	}pr2(ans);
	return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 93,mo=1e9+7;
ll n,m,a[N],b[N],len,res;vector<Pll> s[N];
inline bool gg(int d, ll x, ll y){
	while(y<=n&&y+x<=m)x+=y,swap(x,y),d++;
	return d<len;
}
int tot;
void dfs(int dep, ll x, ll y){
	if(dep>len)return;
	if(x>=a[dep+1]&&y>=b[dep+1])return;
//	if(gg(dep,x,y))return;
	/*if(dep==len){
		printf("%d %lld %lld\n",dep,x,y);
		res+=(x<=n&&y<=m)+(x!=y&&y<=n&&x<=m);return;
	}*/
	if(dep==len-1){
	//	printf("%d %lld %lld\n",dep,x,y);
		/*tot++;
		if(y<=n&&y+x<=m)res+=(m-x)/y;
		if(y<=m&&y+x<=n)res+=(n-x)/y;
		if(!x&&y<=n&&y<=m)res--;*/
		s[len].pb(Pll(x,y));return;
	}
	dfs(dep+1,y,y+x);
	dfs(dep+1,y,2*y+x);
}
int main() {
	a[0]=0;b[0]=1;a[1]=1;b[1]=2;a[2]=2;b[2]=3;len=2;
	while(b[len]<=1e18){
		a[len+1]=b[len],b[len+1]=b[len]+a[len];dfs(0,1,1);
		len++;
	//	printf("%d:%d\n",len,SZ(s[len-1]));
	}
	
	int T;read(T);
	while(T--){
		read(n);read(m);if(n>m)swap(n,m);
		a[0]=0;b[0]=1;len=1;a[1]=1;b[1]=2;
		while(b[len]<=n&&b[len]+a[len]<=m)
			a[len+1]=b[len],b[len+1]=b[len]+a[len],len++;
		a[len+1]=b[len+1]=6e18;
		if(len<=1){printf("1 %lld\n",n==1?m%mo:4LL);continue;}
		res=0;rep(i,0,SZ(s[len])-1){
			ll x=s[len][i].fi,y=s[len][i].se;
			if(y<=n&&y+x<=m)res+=(m-x)/y;
			if(y<=m&&y+x<=n)res+=(n-x)/y;
			if(!x&&y<=n&&y<=m)res--;
		}
		printf("%d %lld\n",len,(res%mo+mo)%mo);
		if(T%10000==9999)cerr<<T<<endl;
	}
	return 0;
}


Measured memory_bytes: 4224
#include <bits/extc++.h>

#ifndef DUMP
#define DUMP(...) (void)0
#endif

using namespace std;

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int64_t x, k, d;
  cin >> x >> k >> d;
  x = abs(x);
  if (x - (__int128_t)k * d >= 0) {
    cout << x - k * d << '\n';
  } else {
    auto q = x / d;
    if ((k + q) & 1) {
      cout << d - (x - q * d) << '\n';
    } else {
      cout << x - q * d << '\n';
    }
  }
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
int main(void){
    string s;cin>>s;
    bool jud=false;
    rep(i,s.size()){
        int x=s.size()-i;
        if(i==0){
            if(s[i]!='A'){
                cout<<"WA"<<endl;
                return 0;
            }
        }else if(i>=2&&x>=2){
            if(s[i]=='C'){
                if(jud){
                    cout<<"WA"<<endl;
                    return 0;
                }else{
                    jud=true;
                }
            }else{
                if(s[i]-'a'<0){
                    cout<<"WA"<<endl;
                    return 0;
                }
            }
        }else{
            if(s[i]-'a'<0){
                cout<<"WA"<<endl;
                return 0;
            }
        }
    }
    if(!jud)cout<<"WA"<<endl;
    else cout<<"AC"<<endl;
}

Measured memory_bytes: 256
s, t = [input() for _ in range(2)]

n, m = map(len, [s, t])
for i in range(n-m, -1, -1):
	if not all(s_j in ["?", t_j] for s_j, t_j in zip(s[i:i+m], t)):
		continue
	print((s[:i] + t + s[i+m:]).replace("?", "a"))
	exit()
print("UNRESTORABLE")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define ll long long
#define PI 3.141592653589
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-7
#define f first
#define s second
using namespace std;
const ll MOD = 1e9+7;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int random_int(int l,int r){return uniform_int_distribution<int>(l,r)(rng);}
ll fast_power(ll x, ll p){
    ll res = 1;
    while(p > 0){
        if(p & 1){
            res = (res * x);
        }
        p = p >> 1;
        x = (x*x);
    }
    return res;
}
struct Matrix
{
    vector< vector<ll> > mat; // the contents of matrix as a 2D-vector
    int n_rows, n_cols; // number of rows and columns

    Matrix(vector< vector<ll> > values): mat(values), n_rows(values.size()),
        n_cols(values[0].size()) {}

    static Matrix identity_matrix(int n)
    {
        // Return I_n - the identity matrix of size n.
        // This function is static, because it creates a new Matrix instance
        vector< vector<ll> > values(n, vector<ll>(n, 0));
        for(int i = 0; i < n; i++)
            values[i][i] = 1;
        return values;
    }

    Matrix operator*(const Matrix &other) const
    {
        int n = n_rows, m = other.n_cols;
        vector< vector<ll> > result(n_rows, vector<ll>(m, 0));
        for(int i = 0; i < n; i++)
            for(int k = 0; k < n_cols; k++) {
                for(int j = 0; j < m; j++) {
                    result[i][j] = (result[i][j] + (mat[i][k] * 1LL * other.mat[k][j])%MOD) % MOD;
                }
            }
        // Multiply matrices as usual, then return the result as the new Matrix
        return Matrix(result);
    }

    inline bool is_square() const
    {
        return n_rows == n_cols;
    }
};

Matrix fast_exponentiation(Matrix m, ll power)
{
    assert(m.is_square());
    Matrix result = Matrix::identity_matrix(m.n_rows);

    while(power) {
        if(power & 1)
            result = result * m;
        m = m * m;
        power >>= 1;
    }

    return result;
}
vector<vector<ll>> values;
int main() {
    IO;
    int n;
    ll k;
    cin >> n >> k;
    values.resize(n);
    for (int i = 0; i < n; i++) {
        values[i].resize(n);
        for (int j = 0 ; j < n; j++) {
            cin >> values[i][j];
        }
    }
    Matrix m(values);
    Matrix x = fast_exponentiation(m, k);
    ll ans = 0;
    for (vector<ll>& v: x.mat) {
        for (int s: v) {
            ans = (ans + s) %MOD;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s, t;    cin >> s >> t;
  
    int ls = s.length(), lt = t.length();
    bool can = false;

    if (ls < lt) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    
    int ans = 0;

    for (int i = 0; i <= ls-lt; i++) {
        bool can_ = true;
        for (int j = 0; j < lt; j++) {
            if (s[i+j] != t[j] && s[i+j] != '?')
                can_ = false;
        }
        if (can_) {
            ans = i;
            can = true;
        }
    }
    if (can) {
        for (int i = 0; i < ls; i++) {
            if (i != ans)
                cout << ((s[i] != '?') ? s[i] : 'a');
            else {
                cout << t;
                i += lt-1;
            }
        }
        cout << endl;
    }
    else 
        cout << "UNRESTORABLE" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.String;


class Main {
    static class Position {
        public Position(int x, int y) {
            this.x = x; this.y = y;
        }
        public int x;
        public int y;
    }

    static int solve(String[] G) {
        int H = G.length;
        int W = G[0].length();
        int INF = Integer.MAX_VALUE/2;
        int[][] step = new int[H][W];
        ArrayList<Position> starts = new ArrayList<Position>();
        for (int i=0; i<H; i++) {
            for(int j=0; j<W; j++) {
                step[i][j] = INF;
                if (G[i].charAt(j) == '#') {
                    starts.add(new Position(i, j));
                }
            }
        }

        int[] dx = new int[] {0,1,0,-1};
        int[] dy = new int[] {1,0,-1,0};

        ArrayDeque<Position> que = new ArrayDeque<Position>();

        for (int i = 0; i < starts.size(); i++) {
            que.addLast(starts.get(i));
            step[starts.get(i).x][starts.get(i).y] = 0;
        }

        int res = 0;
        while (!que.isEmpty()) {
            Position pos = que.removeFirst();
            int x = pos.x; int y = pos.y;
            for (int i=0; i<dx.length; i++) {
                int nx = x + dx[i]; int ny = y + dy[i];
                if (nx<0 || H<=nx || ny<0 || W<=ny) {
                    continue;
                }

                if (step[nx][ny] > step[x][y] + 1) {
                    step[nx][ny] = step[x][y] + 1;
                    que.addLast(new Position(nx, ny));
                    res = Math.max(res, step[nx][ny]);
                }
            }
        }

        return res;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();

        String[] A = new String[H];
        for (int i=0; i<H; i++) {
            A[i] = sc.next();
        }

        int ans = solve(A);

        System.out.println(ans);
    }
}


Measured memory_bytes: 95444
#include<stdio.h>
#include<string.h>
int main(void){
	int p1=0,p2=0,i,n;
	char word1[101],word2[101];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s %s",&word1,&word2);
		if(strcmp(word1,word2)==0){
			p1++;
			p2++;
		}
		if(strcmp(word1,word2)>0){
			p1+=3;
		}
		if(strcmp(word1,word2)<0){
			p2+=3;
		}
	}
	printf("%d %d\n",p1,p2);
	
	return 0;
}


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

int main() {
    int N, M;
    map<string, int> map;

    cin >> N;
    string s[N];
    for (int i = 0; i < N; i++){
        cin >> s[i];
        map[s[i]] += 1;
    }
    
    cin >> M;
    string t[M];
    for (int i = 0; i < M; i++){
        cin >> t[i];
        map[t[i]] -= 1;
    }

    int max_val = 0;

    for (auto p : map) {
        auto key = p.first;
        auto value = p.second;
        if (max_val < value){
            max_val = value;
        }
    }

    cout << max_val << endl;
}

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

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

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

  ll ans = 1;

  unordered_set<ll> res;
  for (ll i = 1; i * i <= m; ++i) {
    if (m % i == 0) {
      res.insert(i);
      res.insert(m / i);
    }
  }

  for (auto a : res)
    if (a * n <= m) ans = max(ans, a);

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


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

int main(){
  bool p[10] = {0};
  int N, M;
  cin >> N >> M;
  rep(i, M){
    int a;
    cin >> a;
    p[a] = true;
  }
  int L = N;
  while(L>0){
    int b = L%10;
    if(p[b]){
      N ++;
      L = N*10;
    }
    L /= 10;
  }
  cout << N << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int i,j;
    string s;
    cin >> s;
    
    for(i = 0; i < s.size(); i++) {
        if(s[i] == 'A') {
            break;
        }
    }
    
    for(j = s.size()-1; j >= 0; j--) {
        if(s[j] == 'Z'){
            break;
        }
    }
    
    
    cout << j - i + 1 << endl;
 return 0;   
}

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

using namespace std;

int main(){
  string S;
  cin >> S;
  
  int Q;
  cin >> Q;
  
  int rev = 0;
  deque<char> front;
  deque<char> back;
  while(Q--){
    int T;
    cin >> T;
    if(T == 1){
      rev ^= T;
    }else{
      int F;
      char C;
      cin >> F >> C;
      F--;
      if(F){
        if(rev) front.push_front(C);
        else back.push_back(C);
      }else{
        if(rev) back.push_back(C);
        else front.push_front(C);
      }
    }
  }
  
  if(rev){
    for(int i = back.size(); i > 0; i--) cout << back[i - 1];
    for(int i = S.size(); i > 0; i--) cout << S[i - 1];
    for(int i = front.size(); i > 0; i--) cout << front[i - 1];
  }else{
    for(int i = 0; i < front.size(); i++) cout << front[i];
    for(int i = 0; i < S.size(); i++) cout << S[i];
    for(int i = 0; i < back.size(); i++) cout << back[i];
  }
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
/* END OF TEMPLATE */

ll dp[100010];

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    vll a(m);
    rep(i, m){
        cin >> a[i];
    }
    vll dp(n+1, 0);
    vll valid(n+1, 1);
    rep(i, m){
        valid[a[i]] = 0;
    }
    dp[0] = 1;
    if(valid[1]) dp[1] = 1;
    else dp[1] = 0;
    repr(i, 2, n+1){
        if(valid[i]) dp[i] = (dp[i-1] + dp[i-2]) % MOD;
        else dp[i] = 0;
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 2560