akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

const int N=105;

int n,t[N];
char s[N][N],sta[N];

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%s%d",s[i],&t[i]);
	scanf("%s",sta);
	int ans=0;
	for (int i=n;i>=1;i--)
	{
		if (!strcmp(sta,s[i])) break;
		ans+=t[i];
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let v : Vec<f32> = s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
    let ans = f32::ceil((v[0] + v[1]) / 2.0 );

    println!("{}", ans);
}


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

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

int main() {
  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  string u;
  cin >> u;
  if (u == s) {
    cout << a-1 << ' ' << b << endl;
  } else {
    cout << a << ' ' << b-1 << endl;
  }
}

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

int main(void) {
  int X, Y, Z;
  cin >> X >> Y >> Z;
  int answer = 0;
  while (true) {
    int need = (answer + 1) * Y + (answer + 2) * Z;
    if (need > X) break;
    ++answer;
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pii pair<int,int>
#define pll pair<lli, lli>
#define vi  vector<int>
#define vii vector<pair<int,int>>
#define vll vector<lli>
#define pb  push_back
#define mpr  make_pair
#define ss  second
#define ff  first
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define all(x) x.begin(),x.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define testcase() int tc;cin>>tc;while(tc--)
#define clean(x) memset(x,0,sizeof(x))
const lli maxn = 1e5+9;
vector<lli> catlan(int n) {
    vector<lli> dp(n + 1, 0);
    dp[0] = 1;
    dp[1] = 1;
    for (int i = 2; i <= n; i ++) {
        for (int j = 0; j < i; ++ j) {
            dp[i] += dp[j] * dp[i - j - 1];
        }
    }
    return dp;
}
lli b_ex(lli n,lli a){lli res=1;while(n){if(n%2==1)res*=a;n>>=1;a=a*a;}return res;}
lli ncr(lli n,lli k){lli ans=1;if(k>n-k)k=n-k;for(lli i=1;i<=k;i++){ans*=(n-i+1),ans=ans/i;}return ans;}
lli power(lli a , lli n){lli ans = 1;while(n){if(n % 2)ans = (ans * a) % mod;n /= 2;a = (a * a) % mod;}return ans;}
lli set_bits(lli n)
{
    int c=0;
    if(n==0)return 0;
    while(n)
    {
        if((n&1)==1)
        {
           cout<<c<<" ";
        }
        c++;
        n=n>>1;
    }
    return c;
}
lli lcm(lli a,lli b)
{
    lli ans=(a*b)/(__gcd(a,b));
    return ans;
}
///------------------ALWAYS lli-----TEMP TSF99--------------------------------------------------------------------------------------///
bool good(lli mid,lli n)
{
    lli ans=mid*(mid+1)/2;
    if(ans<=n)return true;
    return false;
}
void solve()
{
    int n,t;cin>>n>>t;
    cout<<(n+t)%24<<endl;
}
int main()
{
    FAST;
    //int tc=1;cin>>tc;while(tc--)solve();
    solve();
}




Measured memory_bytes: 3656
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include<list>
#include<map>
#include<utility>
#include<tuple>
#include<numeric>
#include<set>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),a.end()
using namespace std;

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

	cout << a / 3 << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/math>
using namespace std;
#ifdef __DEBUG__
    void debug_out() { cerr << endl; } 
    template <typename Head, typename... Tail>
    void debug_out(Head H, Tail... T) {cerr << " " << H; debug_out(T...);}
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 
#endif

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int T;
inline void input(){
    fast_io();
    cin >> T;
}

inline int solve(){
    ll N,M,A,B;
    cin >> N >> M >> A >> B;
    cout << atcoder::floor_sum(N,M,A,B) << "\n";


    return 0;
}   

int main()
{
    input();
    while(T--) solve();
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main(void)
{
	int a,b,c,d;

	cin >> a >> b >> c >> d;

	int l = a + b;
	int r = c + d;

	if(l > r)
		cout << "Left" << endl;
	else if (r > l)
		cout << "Right" << endl;
	else 
		cout << "Balanced" << endl;

	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn main() {
    let s: String = read();
    let v = vec![
        "BAA", "ABA", "AAB", "ABB", "BAB", "BBA"
    ];
    let v: Vec<String> = v.iter().map(|s| s.to_string()).collect();
    if v.contains(&s) {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn read<T: FromStr>() -> T {
	let stdin = stdin();
	let stdin = stdin.lock();
	let token: String = stdin
		.bytes()
		.map(|c| c.expect("failed to read char") as char)
		.skip_while(|c| c.is_whitespace())
		.take_while(|c| !c.is_whitespace())
		.collect();
	token.parse().ok().expect("failed to parse token")
}



Measured memory_bytes: 4352
#include <iostream>
using namespace std;
#include <stdio.h>
#include <math.h>

int digit(int d){
  return (int)log10((double)d) + 1;
}

int main(){
  int a,b;
  
  while( scanf("%d %d",&a,&b) != EOF ){
    int dig = digit(a+b);
    cout << dig << endl;
  }
  
  return 0;
}

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

int n,m;

char a[55][55],b[55][55];

int main(){
    cin >> n >> m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin >> a[i][j];
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(a[i][j]=='#') continue;
            a[i][j]='0';
            if(a[i+1][j]=='#') a[i][j]++;
            if(a[i-1][j]=='#') a[i][j]++;
            if(a[i][j+1]=='#') a[i][j]++;
            if(a[i][j-1]=='#') a[i][j]++;
            if(a[i+1][j+1]=='#') a[i][j]++;
            if(a[i+1][j-1]=='#') a[i][j]++;
            if(a[i-1][j+1]=='#') a[i][j]++;
            if(a[i-1][j-1]=='#') a[i][j]++;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cout << a[i][j];
        }
        cout << '\n';
    }
}


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

int main(void){
  int n;
  cin >> n;
  int d[n];
  for(int i = 0; i < n; i++) cin >> d[i];
  sort(d, d + n);
  int ans = 1;
  for(int i = 0; i < n; i++){
    int temp = 1;
    for(int j = i + 1; j < n; j++){
      if(d[j - 1] < d[j]) temp++;
    }
    ans = max(ans, temp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import std.functional,
       std.algorithm,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

void main() {
  ulong[] NK = readln.chomp.split.to!(ulong[]);
  ulong N = NK[0],
        K = NK[1];
  ulong[ulong] AB;

  foreach (i; 0..N) {
    ulong[] ab = readln.chomp.split.to!(ulong[]);
    if (ab[0] in AB) {
      AB[ab[0]] += ab[1];
    } else {
      AB[ab[0]] = ab[1];
    }
  }
  ulong[] keys = AB.keys;
  sort!"a<b"(keys);
  ulong k;
  ulong ans;
  foreach (key; keys) {
    if (k <= K && K <= k + AB[key]) {
      ans = key;
      break;
    }
    k += AB[key];
  }
  writeln(ans);
}


Measured memory_bytes: 12156
#include<stdio.h>

int main (void){

	int x,y;

	while(1){
		scanf("%d %d",&x,&y);
		if(x == 0 && y == 0)break;
		if(x<y){
			printf("%d %d\n",x,y);
		}else{
			printf("%d %d\n",y,x);
		}
	}
return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>
#include<map>
#include<set>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

long long gcd(long long x, long long y){
    if(y == 0)return x;
    return gcd(y, x % y);
}

bool is_prime(ll x){
    for(ll i = 2; i * i <= x; i++){
        if(x % i == 0) return false;
    }
    return true;
}

int main(){
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a, b);
    set<ll> st;
    st.insert(1);
    if(is_prime(g)) st.insert(g);
    ll ans = 0;
    for(ll i = 1; i * i <= g; i++){
        if(g % i == 0){
            if(is_prime(i)) ans++;
            if(i * i != g && is_prime(g / i)) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

  const int MOD = 1000000007;

  //long long
  using ll = long long;

  //出力系
  #define print(x) cout << x << endl
  #define yes cout << "Yes" << endl
  #define YES cout << "YES" << endl
  #define no cout << "No" << endl
  #define NO cout << "NO" << endl
  
  // begin() end()
  #define all(x) (x).begin(),(x).end()

  //for
  #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

  //最大公約数（ll）
  ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

  //素因数分解
  vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
      if(n % i) continue;
      res.emplace_back(i, 0);
      while(n % i == 0){
        n /= i;
        res.back().second++;
      }
    }
  if(n != 1) res.emplace_back(n, 1);
  return res;
  }


int main()
{
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a, b);
    ll l = (a * b) / g;
    print(l);
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,k,count=0;
  cin>>a>>b>>c>>k;
  while(a>=b)
  {
    count++;
    b=b*2;
  }
  while(b>=c)
  {
    count++;
    c=c*2;
  }
  if(count<=k)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 3600
import java.util.*

fun main(args: Array<String>) {
    abc151d()
}

fun abc151d() {
    val (h, w) = readLine()!!.split(' ').map { it.toInt() }
    val isRoad = (1..h).map { readLine()!!.map { it == '.' }.toBooleanArray() }.toTypedArray()

    val direction = listOf(-1 to 0, 1 to 0, 0 to -1, 0 to 1)

    var answer = 0

    for (y in 0 until h) {
        for (x in 0 until w) {
            if (!isRoad[y][x]) continue

            val visited = Array(h) { BooleanArray(w) }
            val minCosts = Array(h) { IntArray(w) { 1000000 } }
            val queue = ArrayDeque(listOf(listOf(Coordinate(y, x, -1))))

            while (queue.isNotEmpty()) {
                val coordinates = queue.poll()
                for (c in coordinates) {
                    val currCost = c.beforeCost + 1
                    if (c.y in 0 until h && c.x in 0 until w && isRoad[c.y][c.x] && !visited[c.y][c.x]) {
                        visited[c.y][c.x] = true
                        minCosts[c.y][c.x] = Math.min(minCosts[c.y][c.x], currCost)
                        queue.add(
                            listOf(
                                Coordinate(c.y + 1, c.x, currCost),
                                Coordinate(c.y - 1, c.x, currCost),
                                Coordinate(c.y, c.x + 1, currCost),
                                Coordinate(c.y, c.x - 1, currCost)
                            )
                        )
                    }
                }
            }

            answer = Math.max(answer, minCosts.map { it.filterNot { it == 1000000 }.max() ?: 0 }.max() ?: 0)
        }
    }

    println(answer)
}

private data class Coordinate(val y: Int, val x: Int, val beforeCost: Int)


Measured memory_bytes: 45396
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
inline int getint(){
    char c=getchar();int x=0;bool p=0;
    while((c>'9'||c<'0')&&c!='-')c=getchar();
    if(c=='-')p=1,c=getchar();
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    if(p)x=-x;return x;
}
int main(){
	int n=getint(),k=getint();
	if(k<=(n+1)/2)puts("YES");
	else puts("NO"); 
	return 0;
}

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

int main(int argc, const char * argv[]) {
    int w, a, b;
    cin >> w >> a >> b;
    if(a < b){
        if(b-w-a > 0){
            cout << b-w-a << endl;
            return 0;
        }else{
            cout << 0 << endl;
            return 0;
        }
    }else if(a > b){
        if(a-w-b > 0){
            cout << a-w-b << endl;
            return 0;
        }else{
            cout << 0 << endl;
            return 0;
        }

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


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

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

int main(){
	int N, W;
	cin >> N >> W;
	vector<P> item(N);
	rep(i,N)cin >> item[i].first >> item[i].second;
	vector<vector<ll>> dp(N+1, vector<ll>(100100, INF));
	rep(i, N+1)dp[i][0] = 0;
	REP(i,N){
		REP(j,100100){
			chmin(dp[i][j], dp[i-1][j]);
			if(j-item[i-1].second >= 0)chmin(dp[i][j], dp[i-1][j-item[i-1].second] + item[i-1].first);	
		}
	}
	for(int i = 100000; i >= 0; --i){
		if(dp[N][i] <= W){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}


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

int main() {
  
  int x,y,z,sum=0;
  cin >> x >> y >> z >> sum;
  
  for( int i=x; i<=y; i++ ){
    
    if( z%i == 0 )
      
    sum++;
    
  } 
   cout << sum << endl;
  
  
}



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

#include <bits/stdc++.h>

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

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

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

const int N = (int)1e5 + 228;

using namespace std;

int n, k, a[N];
ll pref[N];

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

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

	//~read
	scanf("%d%d", &n, &k);
	forn(i, n)
		scanf("%d", &a[i]);
	//~solve
	forn(i, n - 1)
	{
		if (a[i] + a[i + 1] >= k)
		{
			cout << "Possible" << endl;
			for (int j = 1; j < i; j++)
				printf("%d\n", j);
			for (int j = n - 1; j >= i + 1; j--)
				printf("%d\n", j);
			printf("%d\n", i);
			return 0;
		}
	}
	cout << "Impossible" << endl;
	return 0;
}



Measured memory_bytes: 1152
#include <stdio.h>

int main()
{
    int n, k;
    int graph[105][105] = {};
    int maxv;
    int edge = 0;

    scanf("%d %d", &n, &k);

    maxv = (n - 1) * (n - 2) / 2;

    if (maxv < k) {
        printf("-1\n");
        return 0;
    }

    for (int i = 2; i <= n; i++) {
        graph[1][i] = 1;
        edge++;
    }

    int i = 2;
    while (maxv > k) {
        for (int j = i + 1; j <= n && maxv > k; j++) {
            graph[i][j] = 1;
            edge++;
            maxv--;
        }
        i++;
    }

    printf("%d\n", edge);
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (graph[i][j]) {
                printf("%d %d\n", i, j);
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X;
  cin>>X;
  int N[100010];
  N[1]=0;
  N[2]=1;
  for (int i=3;i<100010;i++){
    N[i]=1;
  }
  
  for (int i=2;i<100010;i++){
    for(int j=2;j<i;j++){
      if(i%j==0){
        N[i]=0;
        break;
      }
    }
  }
  
  for (int i=X;i<100010;i++){
    if(N[i]==1){
      cout<<i<<endl;
      return 0;
    }
  }
  
    cout<<"Error"<<endl;
    return 0;  
}





Measured memory_bytes: 768
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,s,d;
    s=0;
    d=0;
    cin>>a>>b>>c;
    while(1){
        if(s>=c){
            break;
        }
        s=s+a;
        d=d+1;
        if(d%7==0){
            s=s+b;
        }
    }
    cout<<d<<endl;
}




Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <unordered_set>
#include <algorithm>
#include <cmath>

using namespace std;

template <int base>
int digit_sum(int n)
{
	int sum = 0;
	while (n > 0) {
		sum += n % base;
		n /= base;
	}
	return sum;
}

using ivec = vector<int>;

ivec read_int_args()
{
	int N;
	cin >> N;
	ivec v(N);
	for (auto& e : v) {
		cin >> e;
	}
	return v;
}

int compar(const void * b, const void* a)
{
	return (*(int*)a - *(int*)b );
}

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

int main()
{
	int N, Yen;
	cin >> N >> Yen;
	
	int sum = 0;
	
	for (int X = 0; X <= N; X++)
	for (int Y = 0; Y + X <= N; Y++)
	{
		int Z = N - X - Y;
		if (10000 * X + 5000 * Y + 1000 * Z == Yen) {
			cout << X << " " << Y << " " << Z << endl;
			return 0;
		}
	}

	cout << "-1 -1 -1" << endl;

	return 0;
}


Measured memory_bytes: 888
n = gets.to_i
p = gets.split.map(&:to_i)
r = 'NO'
s = []

1.upto(n) do |i|
  if i != p[i - 1]
    s.push([i, p[i - 1]])
  end
end

if s.length == 2
  if s[0][1] == s[1][0] &&
     s[1][1] == s[0][0]
    r = 'YES'
  end
elsif s.length == 0
  r = 'YES'
end

puts r


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

int main()
{
    string S;
    int K;
    cin >> S >> K;
    for(int i = 0; i < S.size(); i++) {
        if(S[i] != 'a' && 'z' - S[i] < K) {
            K -= 'z' - S[i] + 1;
            S[i] = 'a';
        }
    }
    ((S[S.size() - 1] += (K % 26) - 'a') %= 26) += 'a';
    cout << S << endl;
    return (0);
}

Measured memory_bytes: 512
<>=~$";$G=$';for(<>){/ /;$i+=100;for$k(reverse@a=1..1e3){$_>$k||($p[$k]+=$-=$p[$k-$_]+$i*$_+($_==$`&&$')-$p[$k])for 1..$`}}printf grep$p[$_]>=$G,@a

Measured memory_bytes: 640
from collections import Counter
def resolve():
    MOD = 998244353
    N = int(input())
    D = list(map(int, input().split()))

    if D[0] != 0:
        print(0)
        return

    CNT = Counter(D)
    if CNT[0] > 1:  # 距離0は1個
        print(0)
        return

    ans = 1
    for i in range(1, max(D) + 1):
        ans *= pow(CNT[i - 1], CNT[i], MOD)
        ans %= MOD

    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 24404
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n; cin >> n;
    int m = inf;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int p;
        cin >> p;
        if (p <= m) ++ans;
        m = min(m, p);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
fn main() {
    proconio::input! {
        n: usize,
        k: usize,
    }

    let mut flags = vec![true; n]; // いたずらフラグ

    for _ in 0..k {
        proconio::input! {
            d: usize,
            xs: [usize;d],
        }
        xs.iter().for_each(|m| { flags[m-1] = false; });
    }

    println!("{}", flags.iter().filter(|&b| *b == true).count());
}


Measured memory_bytes: 2196
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}
ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
int p[200001];
void solve()
{
	int n,sol=0;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> p[i];
	sort(p, p + n);
	cout << p[n / 2] - p[n / 2 - 1];
}
int main()
{
	int t = 1;
	//cin>>t;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000009
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef unsigned long long ull;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main() {
    int n;
    while(cin>>n){
    if(n==0)return 0;
    vector<pair<int,ll> > v;
    bool f=true;
    rep(i,0,n){
        int num;
        ll a,b;
        scanf("%d %lld %lld",&num,&a,&b);
        if(i==0)v.pb(mp(num,a*b));
        else {
            bool judge=true;
            rep(j,0,v.size()){
                if(num==v[j].fi) {
                    judge=false;
                    v[j].se+=a*b;
                }
            }
            if(judge)v.pb(mp(num,a*b));
        }
    }
    
    rep(i,0,v.size()){
        if(v[i].se>=1e6){
            cout<<v[i].fi<<endl;
            f=false;   
        }
    }
    if(f)cout<<"NA"<<endl;
    }
    
    return 0;
}




Measured memory_bytes: 3160
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>

using namespace std;

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



int main() {
	int n;
	cin >> n;
	int px[n], py[n], ph[n];


	rep(i, n) {
		cin >> px[i] >> py[i] >> ph[i];
	}

	rep(y , 101) {
		rep(x, 101) {
			int is_ok = true;
			int cur_h = 0;
			rep(i , n) {
				if (ph[i] != 0) {
					cur_h = ph[i] + abs(x - px[i]) + abs(y - py[i]);
					break;
				}
			}
			for (int i = 0; i < n; i++) {

				if (ph[i] == 0) {
					 if (cur_h - abs(x -px[i]) - abs(y - py[i]) > 0) {
						is_ok = false;
						break;					 	
					 }
					 continue;

				}


				if (cur_h != ph[i] + abs(x -px[i]) + abs(y - py[i])) {
					is_ok = false;
					break;
				}
			}
			if (is_ok) {
				cout << x << " " << y << " " << cur_h << endl;
				return 0;
			}

		}
	}
	px[-99999999] = 1;

	return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    int sum = 0;

    cin >> n;
    vector<int> v(n);
    for (auto &x: v) {
        cin >> x;
        sum += x;
    }
    int avg = sum / n;
    int ans1 = 0;
    int ans2 = 0;
    int ans3 = 0;
    for (int i = 0; i < n; ++i) {
        ans1 += (v[i] - avg - 1) * (v[i] - avg - 1);
        ans2 += (v[i] - avg) * (v[i] - avg);
        ans3 += (v[i] - avg + 1) * (v[i] - avg + 1);
    }
    cout << min(ans1, min(ans2, ans3)) << '\n';
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vll = vector<vector<ll> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using the = pair<int, int>;
using lthe = pair<ll, ll>;

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

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };

int main() {
    int n, w;
    cin >> n >> w;
    Vl W(n), V(n);
    rep(i, n)  cin >> W[i] >> V[i];

    ll MAXV = (1e3 + 1) * n;
    Vll dp(n, Vl(MAXV, 1LL << 60));
    //初期条件
    dp[0][V[0]] = W[0];
    for (int i = 0; i < n; i++)  dp[i][0] = 0;


    for (int i = 1; i < n; i++) {
        for (int j = 0; j < MAXV; j++) {
            if (j - V[i] >= 0)  dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - V[i]] + W[i]);
            else dp[i][j] = dp[i - 1][j];
        }
    }

    ll ans = 0;
    for (ll j = 0; j < MAXV; j++) {
        if (dp[n - 1][j] <= w)  ans = j;
        //cout << dp[n][j] << endl;
    }
    cout << ans << endl;
}


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

int main() {
  int A,B;
  char op;
  cin >> A >> op >> B;
  int s;
  if(op=='+'){
    s=A+B;
  }else if(op=='-'){
    s=A-B;
  }
  cout << s << endl;
}


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

int main() {
  long long N,K;
  cin >> N>>K;
  if(N>=K){
    if(N%K==0){
      cout<<0<<endl;
    }
    else if(N%K>=K-N%K){
      cout<<K-N%K<<endl;
    }
    else{
      cout<<N%K<<endl;
    }
  }
  else if(K-N>=N){
    cout<<N<<endl;
  }
  else{
    cout<<K-N<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 200000+10;
int n; LL a[N],inv[N];
int main() {
    inv[1]=1;
    for(int i=2;i<N;i++){
        inv[i]=(MOD-(MOD/i))*inv[MOD%i]%MOD;
    }
    for(int i=1;i<N;i++){
        inv[i]+=inv[i-1]; inv[i]%=MOD;
    }
    scanf("%d",&n);
    LL res=0;
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
        res+=a[i]*(inv[i]+inv[n-i+1]-1)%MOD;
        res%=MOD;
    } 
    for(int i=1;i<=n;i++) res=res*i%MOD;
    cout<<res<<endl;
}

Measured memory_bytes: 2560
if __name__ == '__main__':
    n = int(input())

    result = []
    dict_ = {}
    for i in range(n):
        temp = input().split()

        if temp[0][0] == 'i':
            dict_[temp[1]] = True
        else:
            if temp[1] in dict_:
                result.append('yes')
            else:
                result.append('no')
    print('\n'.join(result))


Measured memory_bytes: 39484
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <bitset>
#include <sstream>
#include <queue>

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long int64;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);

template <class T> T sqr (T x) {return x * x;}
template <class T> T abs (T x) {return x < 0 ? -x : x;}

const string s = "RYGB";

int main () {
    ios_base::sync_with_stdio(0);
//	freopen("input.txt", "rt", stdin);
//	freopen("output.txt", "wt", stdout);

	int n, m, d;
	cin >> n >> m >> d;

	vector<vector<int>> a(n, vector<int>(m));
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			int x = (i + j) % (2 * d);
			int y = (i - j) % (2 * d);
			y = (y + 2 * d) % (2 * d);
			a[i][j] = x / d + 2 * (y / d);
		}
	}

	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			cout << s[a[i][j]];
		}
		cout << "\n";
	}

	return 0;
}


Measured memory_bytes: 1536
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
#define mp make_pair
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  ll a,b;
  cin >> a >> b;
  cout << max(max(a+b,a-b),a*b) << endl;
}

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

int N, M;
int sum[210];
int target[210];

int main() {
    cin >> N >> M;
    for (int i = 0; i < 210; ++i) sum[i] = 0;
    for (int i = 0; i < M; ++i) cin >> target[i];
    for (int i = 0; i < M; ++i) {
        int X = 0;
        for (int j = 1; j <= N; ++j) {
            int a; cin >> a;
            if (a == target[i]) {
                sum[j]++;
            }
            else ++X;
        }
        sum[target[i]] += X;
    }
    for (int i = 1; i <= N; ++i) {
        cout << sum[i] << endl;
    }
}


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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(A+B < C+D){
    cout <<"Right";
  }
  else if(A+B == C+D){
    cout << "Balanced";
  }
  else{
    cout << "Left";
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<string,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const long long MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse

vector<P> s[10];

int main () {

    int n;cin>>n;

    s[0].push_back(P("a",1));
    if (n==1) {
        cout<<"a"<<endl;
        return 0;
    }
    rep(i,n-1) {
        rep(j,s[i].size()) {
            string t = s[i][j].first;
            int p = s[i][j].second;
            rep(k,p+1) {
                if (k==p) {
                    if (k==0) s[i+1].push_back(P(t+"a",p));
                    else if (k==1) s[i+1].push_back(P(t+"b",p+1));
                    else if (k==2) s[i+1].push_back(P(t+"c",p+1));
                    else if (k==3) s[i+1].push_back(P(t+"d",p+1));
                    else if (k==4) s[i+1].push_back(P(t+"e",p+1));
                    else if (k==5) s[i+1].push_back(P(t+"f",p+1));
                    else if (k==6) s[i+1].push_back(P(t+"g",p+1));
                    else if (k==7) s[i+1].push_back(P(t+"h",p+1));
                    else if (k==8) s[i+1].push_back(P(t+"i",p+1));
                    else if (k==9) s[i+1].push_back(P(t+"j",p+1));
                } else {
                    if (k==0) s[i+1].push_back(P(t+"a",p));
                    else if (k==1) s[i+1].push_back(P(t+"b",p));
                    else if (k==2) s[i+1].push_back(P(t+"c",p));
                    else if (k==3) s[i+1].push_back(P(t+"d",p));
                    else if (k==4) s[i+1].push_back(P(t+"e",p));
                    else if (k==5) s[i+1].push_back(P(t+"f",p));
                    else if (k==6) s[i+1].push_back(P(t+"g",p));
                    else if (k==7) s[i+1].push_back(P(t+"h",p));
                    else if (k==8) s[i+1].push_back(P(t+"i",p));
                    else if (k==9) s[i+1].push_back(P(t+"j",p));
                }
            }
        }
    }

    rep(i,s[n-1].size()) {
        cout<<s[n-1][i].first<<endl;
    }

}

Measured memory_bytes: 10736
import java.util.Scanner;

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

    int N = scanner.nextInt();
    long A = scanner.nextInt();
    long B = scanner.nextInt();
    long C = scanner.nextInt();
    long D = scanner.nextInt();
    long left = A - (N - 1) * D;
    long right = A - (N - 1) * C;
    for (int i = 0; i < N - 1; i++) {
      if (left <= B && B <= right) {
        System.out.println("YES");
        return;
      }
      left += C + D;
      right += C + D;
    }
    System.out.println("NO");
  }
}


Measured memory_bytes: 23508
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
  string s;
  cin >> s;
  sort(s.begin(),s.end());
  if(s[0]==s[1] && s[2]==s[3] && s[0] != s[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
#define fi first
#define se second
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 9e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
	if(y<=0) return 1;
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

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

//const ll N = 1e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

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


	ll n;
	cin>>n;
	ll a[n], b[n];
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	sort(a, a+n);
	sort(b, b+n);

	if (n % 2 == 0) {
		cout<<b[n/2 - 1] + b[n/2] - a[n/2 - 1] - a[n/2] + 1;
	}
	else {
		cout<<b[n/2] - a[n/2] + 1;
	}


    return 0;
}


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

inline long int c() {
  long int N, M;
  cin >> N >> M;
  if (N < M) swap(N, M);
  if (N == 1 and M == 1) return 1;
  if (N >= 2 and M == 1) return N - 2;
  if (M == 2) return 0;
  return (N - 2) * (M - 2);
}

inline long int d() {
  long int N;
  long int K;
  cin >> N >> K;
  if (K == 0) return N * N;
//  if (K == 2)
  long int count = 0;
  for (long int b = K + 1; b <= N; ++b) {
    long int amari1 = (N - K) % b;
    long int amari2 = (N - b + 1) % b;
    if (amari1 < amari2) {
      count += (b - K) * ((N - K + b) / b) - (b - amari2);
    } else {
      count += (b - K) * ((N - K + b) / b);
    }
  }
  return count;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << d() << endl;
  return 0;
}

Measured memory_bytes: 256
def resolve():
	n = int(input())
	s = []
	mo = float('inf')
	for _ in range(n):
		t = int(input())
		if t % 2:
			mo = min(t, mo)
		s.append(t)
	a = sum(s)
	if a % 10 == 0:
		if mo == float('inf'):
			print(0)
		else:
			print(a - mo)
	else:
		print(a)
resolve()

Measured memory_bytes: 38256
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from math import floor, ceil, sqrt, factorial, log
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
from itertools import product
import sys
stdin = sys.stdin
mod = 10**9 + 7


def ns(): return stdin.readline().rstrip()


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


a, b, k = na()
if a > k:

    print(a - k, b)
elif (a + b) > k:
    print(0, a + b - k)
else:
    print(0, 0)


Measured memory_bytes: 3444
#include<iostream>
#include<string>
using namespace std;
int main(){
	string a;
	while (getline(cin, a) && a!="0") {
		a += " ";
		int c = 0, sum = 0;
		string h = "";
		for (int i = 0; i < a.length(); i++) {
			if (a[i] == ' ') {
				int d = atoi(h.c_str());
				h = "";
				if (d == 1) c++;
				else {
					if (d == 10 || d == 11 || d == 12 || d == 13)
						sum += 10;
					else sum += d;
				}
			}
			else h += a[i];
		}
		if (sum > 21) {
			cout << 0 << endl;
			goto stop;
		}
		else {
			sum += c;
			if (sum > 21) {
				cout << 0 << endl;
				goto stop;
			}
			else {
				while ((21 - sum) >= 10&&c!=0) {
					sum += 10;
					c--;
				}
			}
		}
		cout << sum << endl;
	stop:;
	}
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
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; }
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

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

    ll N;
    cin >> N;
    vec M;
    M.emplace_back(1);
    ll x = 6, y = 9;
    while(x <= N) M.emplace_back(x), x *= 6;
    while(y <= N) M.emplace_back(y), y *= 9;

    vec f(N + 1, 1e18);
    f[0] = 0;

    while(f[N] == 1e18) rep1(i, N) for(auto m : M) if(i >= m) chmin(f[i], f[i - m] + 1);
    
    print(f[N]);

    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

//K Poker
public class Main{

	int suit(char c){
		return c=='S'?0:c=='C'?1:c=='H'?2:3;
	}
	
	int num(char c){
		return c=='K'?13:c=='Q'?12:c=='J'?11:c=='T'?10:c=='A'?1:c-'0';
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		boolean top = true;
		while(sc.hasNext()){
			if(!top)System.out.println();
			top = false;
			int n = sc.nextInt();
			int[][] p = new int[4][14];
			for(int i=0;i<4;i++)for(int j=1;j<14;j++)p[i][j] = sc.nextInt();
			//0: no 1: one-pair 2:two-pair 3:three-cards 4:straight 5:flash 6:fullhouse 7:fourcard 8:straight-flash 9:royal
			int[] r = new int[10];
			for(int i=1;i<10;i++)r[i]=sc.nextInt();
			while(n--!=0){
				int b = 0;
				int X = 0;
				int maxS = 0;
				int maxN = 0;
				int[] suitNum = new int[4];
				int[] numNum = new int[14];
				for(int i=0;i<5;i++){
					char[] ch = sc.next().toCharArray();
					int s = suit(ch[1]);
					int x = num(ch[0]);
					b+=p[s][x];
					suitNum[s]++;
					numNum[x]++;
					maxS = Math.max(maxS, suitNum[s]);
					maxN = Math.max(maxN, numNum[x]);
				}
				if(maxN==4){
					X = 7;
				}
				else if(maxN==3){
					boolean f = true;
					for(int i=1;i<=13;i++){
						if(numNum[i]==2){
							f = false;
						}
					}
					if(f)X = 3;
					else X = 6;
				}
				else if(maxN==2){
					int c = 0;
					for(int i=1;i<=13;i++)if(numNum[i]==2)c++;
					if(c==2)X = 2;
					else X = 1;
				}
				else{
					boolean flash = maxS==5;
					boolean straight = false;
					for(int i=1;i+4<=13;i++){
						boolean f = true;
						for(int j=0;j<5;j++){
							if(numNum[i+j]==0)f = false;
						}
						if(f){
							straight = true;break;
						}
					}
					boolean royal = numNum[1]==1&&numNum[10]==1&&numNum[11]==1&&numNum[12]==1&&numNum[13]==1;
					if(royal&&flash)X = 9;
					else if(flash&&(royal||straight))X = 8;
					else if(flash)X = 5;
					else if(straight||royal)X = 4;
				}
				System.out.println(b*r[X]);
			}
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

int main(void) {
	int ans;
	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			ans = i*j;
			cout << i << "x" << j << "=" << ans << endl;
		}
	}

	return 0;
}

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

int main()
{
	int a, b, c, x;
	cin >> a >> b >> c >> x;
	
	int ans = 0;
	for(int i = 0; i <= a; i++)
		for(int j = 0; j <= b; j++)
			for(int k = 0; k <= c; k++){
				int sum = 500*i + 100*j + 50*k;
				if(sum == x) ans++;
			}
	
	cout << ans << endl;	
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: Picture Frame
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;

typedef long long ll;

const int INF = 1 << 30;
const ll LINF = 1LL << 60;

/* typedef */

typedef vector<string> vs;

/* global variables */

/* subroutines */

/* main */

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

  vs flds(h + 2, string(w + 2, '#'));

  for (int y = 1; y <= h; y++)
    for (int x = 1; x <= w; x++) cin >> flds[y][x];

  for (int y = 0; y < h + 2; y++) cout << flds[y] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cassert>

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

const int MAXN = 1e5+1;
const int MOD = 1e9 + 7;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define FAILNO {cout << "NO\n"; return 0;}
#define FAIL1 {cout << "-1\n"; return 0;}

int N;
int P[21];
int ans;

int main() {
#ifdef OJ
	freopen("input.txt", "rt", stdin);
	//freopen("output.txt", "wt", stdout);
#endif

	cin >> N;
	for (int i = 0; i < N; i++) cin >> P[i];
	for (int i = 1; i < N-1; i++) {
		int mx = P[i-1];
		int mn = P[i-1];

		mx = max(mx,P[i]);
		mx = max(mx,P[i+1]);

		mn = min(mn,P[i]);
		mn = min(mn,P[i+1]);

		if (P[i] != mx && P[i] != mn) ans++;
	}

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



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

def main():
    # # 整数の入力
    # a = int(input())
    # # スペース区切りの整数の入力
    # b, c = map(int, input().split())
    # # 文字列の入力
    # s = input()
    # # 出力
    # print("{} {}".format(a+b+c, s))
    N = int(input())
    a_list = [int(i) for i in input().split()]
    b_list = [0] * N
    ret_b = []

    # a_listの後ろから順に検討していき，箱にボールをいれるかどうかが
    # 決定していく
    for i, a in enumerate(a_list[::-1]):
        index = N - 1 - i # N-1 --> 0
        ball_sum = get_sum(index, b_list)
        # print('ball_sum', ball_sum)
        if ball_sum % 2 != a:
            b_list[index] = 1
            ret_b.append(index + 1)
        # print(index)
        # print(b_list)
    print(len(ret_b))
    if len(ret_b)>0:
        print(' '.join(map(str, ret_b)))




def get_sum(index, b_list): # index: 0-(N-1)
    index_ = index + 1
    cur = index_
    ret_sum = 0
    while (cur<len(b_list)+1):
        ret_sum += b_list[cur-1]
        cur += index_
    return ret_sum


if __name__=='__main__':
    main()


Measured memory_bytes: 29312
#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;
int n;
bool ed[202][202];
int dis[202];
int q[212];
int fin(int now)
{
    for (int i=1;i<=n;i++)
        dis[i]=0;
    dis[now]=1;
    q[0]=now;
    int upp=1,downn=0;
    while (downn<upp)
    {
        int tmp=q[downn];

        for (int i=1;i<=n;i++)
        if (ed[tmp][i])
        {
            if (!dis[i]){
                q[upp++]=i;
                dis[i]=dis[tmp]+1;
                continue;
            }
            if (dis[i]!=dis[tmp]+1 && dis[i]!=dis[tmp]-1)
            {
                //printf("%d %d\n",i,tmp);
                return -1;
            }
        }
        downn++;
    }
    int ans=-1;
    for (int i=1;i<=n;i++)
        if (dis[i]>ans)
            ans=dis[i];
    //for (int i=1;i<=n;i++)
    //    printf("%d ",dis[i]);
    //printf("\n");
    return ans;


}


int main()
{

    scanf("%d",&n);
    for (int i=1;i<=n;i++)
    for (int j=1;j<=n;j++)
    {
        char ch=getchar();
        while (ch!='0' && ch!='1') ch=getchar();
        if (ch=='0') ed[i][j]=false;
        else ed[i][j]=true;
    }
    int ans=-1;
    for (int i=1;i<=n;i++)
    {
        int tmp=fin(i);
        //printf("%d %d\n",i,tmp);
        if (tmp>ans) ans=tmp;
    }
    printf("%d\n",ans);


}


Measured memory_bytes: 256
h, w = map(int, input().split())
grid = [str(input()) for _ in range(h)]
dp = [[0] * 1050 for _ in range(1050)]
MOD = int(1e9+7)
dp[0][0] = 1
for i in range(h):
    for j in range(w):
        dp[i][j] %= MOD
        if i + 1 < h and grid[i+1][j] == '.':
            dp[i+1][j] += dp[i][j]
        if j + 1 < w and grid[i][j+1] == '.':
            dp[i][j+1] += dp[i][j]
print(dp[h-1][w-1])

Measured memory_bytes: 84056
#include<bits/stdc++.h>
using namespace std;
int fa(int a){
    if(a%2==0){
        return a/2;
    }
    else{
        return 3*a+1;
    }
}
int main(){
    int s;
    cin>>s;
    set<int> S;
    int sum=0;
    while(!S.count(s)){
        S.insert(s);
        s=fa(s);
        sum++;
    }
    cout<<sum+1<<endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const mod = 1000000007

var fac, finv, inv []int
var wr = bufio.NewWriter(os.Stdout)

func initCmb(x int) {
	fac, finv, inv = make([]int, x+1), make([]int, x+1), make([]int, x+1)
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1
	for i := 2; i <= x; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func cmb(a, b int) int {
	if b > a {
		return 0
	}
	return fac[a] * (finv[b] * finv[a-b] % mod) % mod
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	initCmb(max(n-k+1, k-1))
	for i := 1; i <= k; i++ {
		wr.WriteString(strconv.Itoa(cmb(n-k+1, i)*cmb(k-1, i-1)%mod) + "\n")
	}
	wr.Flush()
}


Measured memory_bytes: 640