akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x, a, b;
	cin >> x >> a >> b;
	string ans;
	if(b-a <= 0)ans = "delicious";
	else if(b-a <= x )ans = "safe";
	else ans = "dangerous";
	cout << ans << endl;
}

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

using namespace std;

string s[] = {"MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};

int main() {
    int shift;
    string cur;
    cin >> shift >> cur;
    for(int i=0; i<cur.size(); i++){
        char &c = cur[i];
        c = (c - 'A' + shift) % 26 + 'A';
    }
    printf("%s\n", cur.c_str());
}


Measured memory_bytes: 256
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val (n, m, x, y) = readListOfInt()
    val xList = readListOfInt().sorted()
    val yList = readListOfInt().sorted()
    val s = xList.last() + 1
    val e = yList.first()
    var isWar = true
    for(pt in s .. e) {
        if(x < pt && pt <= y) {
            isWar = false
            break
        }
    }
    println(if(isWar) "War" else "No War")

    pw.flush()
}

/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 37848
# frozen_string_literal: true

line = gets.chomp!.split(' ')

n = line[0].to_i

k = line[1].to_i

s = gets

happiness = 0

s.length.times do |i|
  happiness += 1 if %w[LL RR].include?(s[i, 2])
end

puts [n - 1, happiness + 2 * k].min


Measured memory_bytes: 1916
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<math.h>
#include<utility>

using namespace std;

int main(){
	int n,temp;
	cin>>n;
	vector<int> cost;
	for(int i=0;i<n;i++){
		cin>>temp;
		cost.push_back(temp);
	}
	vector<int> dp(n,0);
	dp[0]=0;
	dp[1]=abs(cost[1]-cost[0]);
	for(int i=2;i<n;i++){
		dp[i] = min(dp[i-2]+abs(cost[i]-cost[i-2]), dp[i-1]+abs(cost[i]-cost[i-1]));
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 1144
#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)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll h,w;cin>>h>>w;
    ll t[h][w];
    rep(i,h)rep(j,w){
        cin>>t[i][j];
        t[i][j]%=2;
    }
    queue<pair<int,int>> p1,p2;
    vector<bool> used(h,false);
    ll res=0;
    rep(i,h-1){
        rep(j,w){
            if(t[i][j]%2==1){
                t[i+1][j]++;
                p1.push({i+1,j+1});
                p2.push({i+2,j+1});
                res++;
            }
        }
    }
    rep(i,w-1){
        if(t[h-1][i]%2==1){
            t[h-1][i+1]++;
            p1.push({h,i+1});
            p2.push({h,i+2});
            res++;
        }
    }
    cout<<res<<endl;
    rep(i,res){
        auto F=p1.front(),T=p2.front();p1.pop();p2.pop();
        cout<<F.first<<" "<<F.second<<" "<<T.first<<" "<<T.second<<endl;
    }
}

Measured memory_bytes: 6144
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int X, Y;
    cin >> X >> Y;
    ll res = 0;
    if(X == 1)
        res += 300000;
    else if(X == 2)
        res += 200000;
    else if(X == 3)
        res += 100000;

    if(Y == 1)
        res += 300000;
    else if(Y == 2)
        res += 200000;
    else if(Y == 3)
        res += 100000;

    if(X == 1 && Y == 1)
        res += 400000;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
#include <string>
#include <string.h>
#include <limits>
#include <utility>
#include <vector>
#include <algorithm>
#include <functional>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <chrono>

using namespace std;

namespace
{

}

#if 1
int main()
{
	int a, b;
	cin >> a >> b;
	b /= 2;
	cout << a + b;
}
#endif


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int max(int a,int b){return (a>b ? a:b);}
int min(int a,int b){return (a<b ? a:b);}

//int compare_int(const void *a, const void *b){return *(int*)a - *(int*)b;}
//これは昇べきの順のソート

int compare_int(const void *a, const void *b){return *(int*)b - *(int*)a;}
//これは降べきの順のソート

//qsort(配列, 長さ, sizeof(int), compare_int);

double BS(int array[],int len,int target);

//////////////////////////////////////////

int N,Q;
int l[100010],r[100010];
int dp[100010]= {};

char S[100010];

int main(){
    scanf("%d %d\n",&N,&Q);
    scanf("%s",S);
    for(int i = 0;i < Q;i++){
        scanf("%d %d",&l[i],&r[i]);
    }

    int mark = 0;
    for(int i = 0;i < N;i++){
        if(S[i] == 'A'){
            dp[i+1] = dp[i];
            mark = 1;
        }else if(S[i] == 'C' && mark == 1){
            dp[i+1] = dp[i] + 1;
            mark = 0;
        }else{
            dp[i+1] = dp[i];
            mark = 0;
        }
    }

    
    //printf("%s\n",S);
    for(int i = 1;i <= N;i++){
        //printf("%d",dp[i]);
    }
    //printf("\n");
    

    for(int i = 0;i < Q;i++){
        printf("%d\n",dp[r[i]] - dp[l[i]]);
    }

    return 0;
}



///////////////////////////////////////////


double BS(int array[],int len,int target){ //(配列,長さ,見つける値)
    int low,mid,high;

    low = 0;
    high = len-1;

    int mark;

    while(low <= high){
        mid = (low + high) / 2;
        if(array[mid] == target){
            mark = 0;
            break;
        }else if(array[mid] < target){
            low = mid + 1;
            mark = 1;
        }else{
            high = mid - 1;
            mark = -1;
        }
    }
    if(mark == 0){
        return mid; //配列の何番目か（０から）
    }else if(mark == 1){
        return (double)mid + 0.5;//なかったらどこのあいだか
    }else{
        return (double)mid - 0.5;
    }
}


Measured memory_bytes: 2048
from collections import Counter
N,K,Q = map(int,input().split())
counter = Counter()
for _ in range(Q):
  counter[int(input())] += 1

for i in range(1, N+1):
  p = counter[i]
  if K+p-Q > 0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 54872
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
	int r;
	cin >> r;
    if(r<1200)cout << "ABC" << endl;
	else if(r<2800)cout << "ARC" << endl;
	else cout << "AGC" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <functional>
#include <utility>
#define INF 9999999
using namespace std;
typedef long long int ll;

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	int one = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (A[i] == 1)one = i;
	}
	
	int ans = 0;
	int tmp = 0;
	while (tmp > one) {
		tmp += K - 1;
		ans++;
	}
	int tmp2 = N - 1;
	while (tmp < tmp2) {
		tmp2 -= K - 1;
		ans++;
	}

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


Measured memory_bytes: 640
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

a,b,c = input().split()
if (a[-1] == b[0] and b[-1] == c[0]):
  print("YES")
else:
  print("NO")

Measured memory_bytes: 38256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) {ll ans = 1; while (b) {if (b % 2)ans = ans * a % MOD; a = a * a % MOD; b /= 2;} return ans;}
inline void getInt(int* p);
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
ll a[maxn];
ll n, x;
int main()
{
    //freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
    //freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);

    gbtb;
    cin >> n >> x;
    repd(i, 1, n)
    {
        cin >> a[i];
    }
    ll ans = 0ll;
    for (int i = 1; i <= n; i++)
    {
        if (a[i] > x)
        {
            ans += a[i] - x;
            a[i] = x;
        }
        if (a[i] + a[i + 1] > x)
        {
            ans += a[i] + a[i + 1] - x;
            a[i + 1] -= a[i] + a[i + 1] - x;
        }
        // if(a[i-1]>x)
        // {
        //     ans+=a[i-1]-x;
        //     a[i-1]=x;
        // }
        // if(a[i+1]>x)
        // {
        //     ans+=a[i+1]-x;
        //     a[i+1]=x;
        // }
        // if(a[i-1]+a[i]>x)
        // {
        //     ans+=a[i-1]+a[i]-x;
        //     a[i]-=a[i-1]+a[i]-x;
        // }
        // if(a[i+1]+a[i]>x)
        // {
        //     ans+=a[i+1]+a[i]-x;
        //     a[i]-=a[i-1]+a[i]-x;
        // }
    }
    cout << ans << endl;


    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



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

int main () {
      ll n,k;
      cin>>n>>k;
      if(n%k==0)cout<<0;
      else if(n<k)
      cout<<min(n,k-n);
      else cout<<min(n%k,k-n%k);
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner  sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m =  sc.nextInt();
		
		if ( n < m ) {
			for(int i=0;i<m;i++) {
				System.out.print(n);
			}
			System.out.println();
		}else {
			for(int i=0;i<n;i++) {
				System.out.print(m);
			}
			System.out.println();
		}
		
	}
}


Measured memory_bytes: 23764
n = int(input())
s = list(map(int,list(input())))


ans_L = []
length = len(s)
count = 0

for i in range(1000):
    i = list(str(i).zfill(3))
    idx = 0
    cnt = 0
    for j in range(3):
        for k in range(idx,length):
            if str(i[j]) == str(s[k]):
                idx = k+1
                cnt += 1
                break
        if cnt ==0:
            break

    #if len(tmp_L) == 3:
    #    ans_L.append("".join(tmp_L))
    if cnt == 3:
        count +=1

print(count)
#print(set(ans_L))

Measured memory_bytes: 43740
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可

const ll INF=1000000000000000000;

map<ll,ll> prime_factor(ll n){
    map<ll,ll> res;
    for(ll j=2;j<=n;j++){
        ll m=j;
        for(ll i=2;i*i<=m;i++){
            while(m%i==0){
                ++res[i];
                m/=i;
            }
        }
        if(m!=1) res[m]++;;
    }
    return res;
}

signed main(){
    ll n;
    cin>>n;
    map<ll,ll> mp=prime_factor(n);
    ll ans=0;
    ll c2=0,c4=0,c24=0,c74=0,c14=0;
    for(auto p:mp){
        if(p.sc>=2) c2++;
        if(p.sc>=4) c4++;
        if(p.sc>=14) c14++;
        if(p.sc>=24) c24++;
        if(p.sc>=74) c74++;
    }
    ans+=max((ll)0,c2-2)*c4*(c4-1)/2;
    ans+=c74;
    ans+=max((ll)0,c4-1)*c14;
    ans+=max((ll)0,c2-1)*c24;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
using ll = long long;
using ld = long double;
const int N = 5050;

int d[N*2];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int k, q; cin >> k >> q;
  for (int i = 0; i < k; i++) {
    cin >> d[i];
  }
  /*
  int nk = k;
  while (nk < N) nk += k;
  for (int i = k; i < nk; i++) {
    d[i] = d[i%k];
  }
  k = nk;*/
  while (q--) {
    int n, x, m; cin >> n >> x >> m;
    n--;
    x %= m;
    ll tot = 0;
    int zcnt = 0;
    for (int i = 0; i < k; i++) {
      tot += (d[i] % m);
      zcnt += (d[i] % m == 0);
    }
    int num_cyc = n / k, rem_cyc = n % k;
    ll ans = num_cyc * k - (x + tot * num_cyc) / m - num_cyc * zcnt;
    //cout << ans << nl;
    x = (x + tot * num_cyc) % m;
    for (int i = 0; i < rem_cyc; i++) {
      int nx = (x + d[i]) % m;
      //cerr << x << " " << nx << nl;
      ans += (x < nx);
      x = nx;
    }
    cout << ans << nl;
  }
}


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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  while (cin >> n, n) {
    vector<char> t(n);
    vector<int> win(n, 0), lose(n, 0), ord(n);
    iota(ord.begin(), ord.end(), 0);
    for (int i = 0; i < n; i++) {
      cin >> t[i];
      for (int j = 0; j < n - 1; j++) {
        int r;
        cin >> r;
        if (r == 0) win[i]++;
        else if (r == 1) lose[i]++;
      }
    }
    sort(ord.begin(), ord.end(), [&](int a, int b) {
      if (win[a] != win[b]) return win[a] > win[b];
      return lose[a] < lose[b];
    });
    for (int i = 0; i < n; i++) {
      cout << t[ord[i]] << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3188
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
#include <bitset>
#include <deque>
using namespace std;
#define N (1000000000+7)
//#define N 998244353
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> Q;
typedef vector<ll> vec;
typedef vector<vec> mat;
const int inf = (int)1e9; 
 
ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}

int main(void){
	string s;
	cin>>s;
	if(s[s.length()-1]!='s')cout<<s<<"s"<<endl;
	else cout<<s<<"es"<<endl;
	return 0;
}


Measured memory_bytes: 3620
/*
  Very good question on DP on Graphs + Matrix Exponentiation
  User:- sanyam
*/

#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long int
#define mod 1000000007
#define w(t) int t;	cin>>t while(t--)
#define triplet pair<int,pair<int,int>>
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define fastIO ios_base::sync_with_stdio(0);	cin.tie(0);	cout.tie(0);
#define loop(i, k, n) for(ll i=k; i<n; i+=1)
#define loop2(i, k, n) for(ll i=k; i>=n; i--)
#define base(i,val) memset(i, val, sizeof(val))

const ll inf = 1e18;

void take_fileIO(){
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
  return;
}


/* ---------------------From here main coding part starts--------------------  */

vector<vector<ll>> multiply(vector<vector<ll>> a, vector<vector<ll>>b){
  ll n = a.size();
  vector<vector<ll>> res(n, vector<ll>(n, 0));

  loop(i, 0, n){
    loop(j, 0, n){
      loop(k, 0, n){
        res[i][j] = (res[i][j] + a[i][k] * b[k][j])%mod;
      }
    }
  }
  return res;
}

vector<vector<ll>> power(vector<vector<ll>> a, ll exp){
  if(exp==1)
    return a;
  
  vector<vector<ll>>res = power(a, exp/2);
  if(exp&1){
    return multiply(a, multiply(res, res));
  }
  else{
    return multiply(res, res);
  }
}

void solve(){
  ll n, k; 
  cin>>n>>k;
  vector<vector<ll>>adj(n, vector<ll>(n));

  loop(i, 0, n)
    loop(j, 0, n)
      cin>>adj[i][j];

  vector<vector<ll>>Ak = power(adj, k);

  ll ans = 0;
  
  loop(i, 0, n){
    loop(j, 0, n){
      ans = (ans + Ak[i][j])%mod;
    }
  }
  cout<<ans<<endl;
}

int main(){

  fastIO;
  //take_fileIO();
  solve();

  return 0;
}

Measured memory_bytes: 1664
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

type Edge struct {
	to, cost int
}

// 辺のリストで表現されるグラフ
type Graph struct {
	Edges [][]Edge // Edge[i][j]: 頂点iのj番目の辺
	Cost  []int    // 始点からの最小コスト
}

// 頂点数nのリスト型グラフを返す
func NewGraph(n int) *Graph {
	g := &Graph{
		Edges: make([][]Edge, n),
		Cost:  make([]int, n),
	}
	for i := 0; i < n; i++ {
		g.Edges[i] = make([]Edge, 0)
		g.Cost[i] = 1 << 60
	}
	return g
}

// 辺の追加
func (g *Graph) AddEdge(from, to, cost int) {
	g.Edges[from] = append(g.Edges[from], Edge{to, cost})
}

type Elem struct {
	value    interface{}
	priority int
	index    int
}

type PriorityQueue []*Elem

func (pq PriorityQueue) Len() int {
	return len(pq)
}

func (pq PriorityQueue) Less(i, j int) bool {
	return pq[i].priority < pq[j].priority
}

func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index, pq[j].index = i, j
}

func (pq *PriorityQueue) Push(x interface{}) {
	n := len(*pq)
	elem := x.(*Elem)
	elem.index = n
	*pq = append(*pq, elem)
}

func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(*pq)
	elem := old[n-1]
	old[n-1] = nil
	elem.index = -1
	*pq = old[0 : n-1]
	return elem
}

// 0-indexed
func (g *Graph) DijkstraSearch(origin int) {
	// init
	g.Cost[origin] = 0
	done := make([]bool, len(g.Edges))
	pq := make(PriorityQueue, 0)
	heap.Init(&pq)
	heap.Push(&pq, &Elem{
		value:    origin,
		priority: 0,
	})

	// seaech
	for pq.Len() > 0 {
		v := heap.Pop(&pq).(*Elem)
		from := v.value.(int)
		done[from] = true
		for _, edge := range g.Edges[from] {
			to := edge.to
			if done[to] {
				continue
			}
			// 隣接頂点の最小コストを更新
			nextCost := v.priority + edge.cost
			if nextCost < g.Cost[to] {
				g.Cost[to] = nextCost
				heap.Push(&pq, &Elem{
					value:    to,
					priority: nextCost,
				})
			}
		}
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, u, v := nextInt(), nextInt()-1, nextInt()-1
	g1 := NewGraph(n) // 逃げる（高橋）
	g2 := NewGraph(n) // 追う（青木）
	for i := 0; i < n-1; i++ {
		a, b := nextInt()-1, nextInt()-1
		g1.AddEdge(a, b, 1)
		g1.AddEdge(b, a, 1)
		g2.AddEdge(a, b, 1)
		g2.AddEdge(b, a, 1)
	}

	if len(g1.Edges[u]) == 1 && g1.Edges[u][0].to == v {
		puts(0)
		return
	}

	g1.DijkstraSearch(u)
	g2.DijkstraSearch(v)

	// 青木から一番遠い葉を探す
	x := v
	for i := 0; i < n; i++ {
		if g1.Cost[i] < g2.Cost[i] && g2.Cost[x] < g2.Cost[i] {
			x = i
		}
	}
	// 青木が最後に到着する点
	last := g1.Edges[x][0].to
	puts(g2.Cost[last])
}


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


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

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

#define int ll
typedef long long ll;

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

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = LONG_LONG_MAX;

bool cmp(int a, int b) {
	return a > b;
}

void solve() {
	int a;
	cin >> a;
	cout << a + a*a + a*a*a;
}

int32_t main() {_
	
#ifndef ONLINE_JUDGE
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif

	// tc(t)
		solve();
	cerr << "[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
}



Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	int t = 1;
	//cin >> t;
	while(t--){
		int n, ac = 0, wa = 0, tle = 0, re = 0;
		cin >> n;
		string s;
		while(n--){
			cin >> s;
			if(s == "AC")
				++ac;
			else if(s == "WA")
				++wa;
			else if(s == "TLE")
				++tle;
			else
				++re;
		}
		cout << "AC x " << ac << endl;
		cout << "WA x " << wa << endl;
		cout << "TLE x " << tle << endl;
		cout << "RE x " << re << endl;
	}

	return 0;
}

Measured memory_bytes: 3656
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    if(s[0] == '7' || s[1] == '7' || s[2] == '7') {
    	cout<<"Yes\n";
    } else {
    	cout<<"No\n";
    }
}

Measured memory_bytes: 3592
n=int(input())
s=["".join(sorted(input())) for _ in range(n)]
d={}
ans = 0
for i in s:
	k = d.get(i, 0)
	ans += k
	if k == 0:
		d[i] = 1
	else:
		d[i] += 1
print(ans)

Measured memory_bytes: 19400
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string S;
  cin >> N >> S;
  
  int countR = 0;
  int countB = 0;
  
  for(int i = 0; i < N; i++) {
    if(S.at(i) == 'R') countR++;
    else countB++;
  }
  if(countR > countB) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<queue>
using namespace std;
int main(){
    for(;;){
        int n,m;
        scanf("%d%d",&n,&m);
        if(n==0&&m==0)break;
        vector<vector<int> > costs(m,vector<int>(m,-1));
        vector<vector<int> > times(m,vector<int>(m,-1));
        for(int i=0;i<n;i++){
            int a,b,cost,time;
            scanf("%d%d%d%d",&a,&b,&cost,&time);
            a--;b--;
            costs[a][b]=cost;
            costs[b][a]=cost;
            times[a][b]=time;
            times[b][a]=time;
        }
        int k;
        scanf("%d",&k);
        for(int i=0;i<k;i++){
            int p,q,r;
            scanf("%d%d%d",&p,&q,&r);
            p--;q--;
            if(r==1){
                vector<int> d(m,-1);
                d[p]=0;
                priority_queue<pair<int,int>, vector<pair<int,int> >, greater<pair<int,int> > > lens;
                lens.push(make_pair(0,p));
                while(!lens.empty()){
                    pair<int,int> p = lens.top();
                    lens.pop();
                    int v=p.second;
                    if(d[v]<p.first)continue;
                    for(int j=0;j<m;j++){
                        if(times[v][j]!=-1&&(d[j]>d[v]+times[v][j]||d[j]==-1)){
                            d[j]=d[v]+times[v][j];
                            lens.push(make_pair(d[j],j));
                        }
                    }
                }
                printf("%d\n",d[q]);
            }else{
                vector<int> d(m,-1);
                d[p]=0;
                priority_queue<pair<int,int>, vector<pair<int,int> >, greater<pair<int,int> > > lens;
                lens.push(make_pair(0,p));
                while(!lens.empty()){
                    pair<int,int> p = lens.top();
                    lens.pop();
                    int v=p.second;
                    if(d[v]<p.first)continue;
                    for(int j=0;j<m;j++){
                        if(costs[v][j]!=-1&&(d[j]>d[v]+costs[v][j]||d[j]==-1)){
                            d[j]=d[v]+costs[v][j];
                            lens.push(make_pair(d[j],j));
                        }
                    }
                }
                printf("%d\n",d[q]);
            }
        }
    }
}

Measured memory_bytes: 912
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int n,m;
int a[25];
int ans1[25];
int ans2[25];
int main()
{
    scanf("%d",&n);
    while(n--)
    {
        memset(a,0,sizeof(a));
        memset(ans1,0,sizeof(ans1));
        memset(ans2,0,sizeof(ans2));
        for(int i=1;i<=10;i++)
        {
            scanf("%d",&a[i]);
        }
        ans1[1]=a[1];
        ans2[0]=0;
        int p1=0,p2=0;
        int i;
        for(i=2;i<=10;i++)
        {
            if(a[i]>ans1[p1])
            {
                ans1[++p1]=a[i];
            }else if(a[i]>ans2[p2]){
                ans2[++p2]=a[i];
            }else{
                printf("NO\n");
                break;
            }
        }
        if(i>10)
        {
            printf("YES\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2564
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, n) for (int i = (s); i < (int)(n); i++)
#define INF 100000000

using namespace std;

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

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define PI 3.141592653
int main(void){
	double a, b, C, S, L, h, c;
	scanf("%lf %lf %lf", &a, &b, &C);
	S = 0.5 * a * b * sin(C * PI / 180.0);
	c = sqrt(a * a + b * b - 2 * a * b * cos(C * PI / 180.0));
	L = a + b + c;
	h = 2 * S / a;
	printf("%f\n", S);
	printf("%f\n", L);
	printf("%f\n", h);
	return 0;
}

Measured memory_bytes: 648
import sys
sys.setrecursionlimit(10000000)


n = input()

# a[i]: ans for n[:i]
# a = [0 for i in range(len(n) + 1)]
# a[0] = 0
# a[1] = max(a[0] + int(n[0]), (10 - int(n[0])) + 1)
# a[2] = max(a[1] + int(n[1]), a[0] + (10 - int(n[1])) + 1)

# def inv(n):
#     n_new = list()
#     for i in range(len(n)):
#         if n[i] == '9':
#             n_new.append(0)
#         else:
#             n_new.append(9 - int(n[i]))
#     for i in range(len(n)):
#         if n_new[-i] != 9:
#             n_new[-1] += 1
#             break
#         else:
#             n_new[-1] = 0

#     return ''.join(map(str, n_new))


# def func(n, calc_inv=True):
#     if len(n) == 0:
#         return 0

#     if calc_inv:
#         return min(1 + func(inv(n), calc_inv=False), func(n, calc_inv=False))
    
#     else:            
#         return int(n[0]) + func(n[1:])

# print(func(n))

# a = [0 for i in range(len(n) + 1)]
# for i in range(len(n)):
#     if int(n[i]) < 5:
#         a[i + 1] += int(n[i])
#     elif int(n[i]) > 5:
#         a[i] += 1
#         a[i + 1] -= (10 - int(n[i]))
#     else: # 5
#         if a[i] >= 0:
#             a[i + 1] += 5
#         else:
#             a[i] += 1
#             a[i + 1] - 5

# print(a)
# print(sum(map(abs, a)))


a = [0 for i in range(len(n) + 1)]
for i in range(1, len(n) + 1):
    # print(a)
    m = int(n[-i]) + a[i - 1]
    # print(m)
    if m < 5:
        a[i - 1] = m
    elif m > 5:
        a[i] += 1
        a[i - 1] = - (10 - m)
    else: # 5
        if i != len(n) and int(n[-i-1]) >= 5:
            a[i] += 1
            a[i - 1] = - m
        else:
            a[i - 1] = m

# print(a[::-1])
print(sum(map(abs, a)))



Measured memory_bytes: 15672
import scala.math._

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
//  val a, b, c = sc.nextInt
  val list = List.fill(3)(sc.nextInt)

  val ans = if (list.count(_ == 5) == 2 && list.count(_ == 7) == 1) YES else NO

  println(ans)


  ///////////////////////////////////////////

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int cnt = 0;
    rep(i,n){
        if(i+1 == a[a[i]-1]) cnt++;
    }
    cout << cnt/2 << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    int a,b;
    cin>>a>>b;
    if(a<=b) cout<<"unsafe";
    else cout<<"safe";
    cout<<"\n";
}

Measured memory_bytes: 3632
#include<stdio.h>

int main()
{
  int n,k;
  
  scanf("%d%d",&n,&k);
  
  int x[n];
  int i;
  int ans=0;
  for(i=0;i<n;i++)
  {
    scanf("%d",&x[i]);
  }
  
  for(i=0;i<n;i++)
  {
    if(x[i]<=k-x[i])
    {
      ans+=x[i]*2;
    }
    else
    {
      ans+=(k-x[i])*2;
    }
  }
  
  printf("%d\n",ans);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(v) v.begin(), v.end()
#define pb push_back
#define INF 1e9
#define MOD 1000000007
using namespace std;

// vector<ll> fac(500001); //n!(mod M)
// vector<ll> ifac(500001); //k!^{M-2} (mod M)
// //a,bの範囲的にこれだけ配列を用意していけば十分

// ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
//     ll ans = 1;
//     while(n != 0){
//         if(n&1) ans = ans*x % MOD;
//         x = x*x % MOD;
//         n = n >> 1;
//     }
//     return ans;
// }

// ll comb(ll a, ll b){ //aCbをmod計算
//     if(a == 0 && b == 0)return 1;
//     if(a < b || a < 0)return 0;
//     ll tmp = ifac[a-b]* ifac[b] % MOD;
//     return tmp * fac[a] % MOD;
// }

// ll cmb(ll a, ll b) {
//   b = min(a - b, b); ll r = 1;
//   for (int i = 1; i <= b; i++)
//    r = ((r%MOD) * ((a - b + i)%MOD) / i)%MOD;
//   return r;
// }

const int MAX = 1000010;
//const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    int x,y;
    cin>>x>>y;

    if((x+y)%3!=0 || max(x,y)/2>min(x,y)){
        cout<<0;
        return 0;
    }

    int n=(x+y)/3;
    int k;
    if(n%2==0){
        k=n/2+abs(x-y)/2;
    }else{
        k=(n+1)/2+(abs(x-y)-1)/2;
    }


    // fac[0] = 1;
    // ifac[0] = 1;
    // for(ll i = 0; i<500000; i++){
    //     fac[i+1] = fac[i]*(i+1) % MOD; // n!(mod M)
    //     ifac[i+1] = ifac[i]*mpow(i+1, MOD-2) % MOD; // k!^{M-2} (mod M) ←累乗にmpowを採用
    // }

    // 前処理
    COMinit();

    ll ans=0;
    //cout<<n<<" "<<k<<endl;
    ans = COM(n, k)%MOD;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 23680
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy

## input

# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))

R,G,B,N = map(int,input().split()) 

ans = 0
tmp1 = N//R + 1

for i in range(tmp1):
    tmp2 = (N - R*i)//G + 1
    for j in range(tmp2):
        if (N - R*i - G*j)%B == 0:
            ans += 1



print(ans)

Measured memory_bytes: 77800
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;



int main()
{
	int n, m;
	cin >> n >> m;
	char x;
	int w[60]={}, b[60]={}, r[60]={};
	rep(i, n) rep(j, m)
	{
		cin >> x;
		if(x=='W') w[i]++;
		else if(x=='B') b[i]++;
		else r[i]++;
	}
	w[0]=m-w[0];
	b[0]=m-b[0];
	r[0]=m-r[0];
	reps(i, n-1)
	{
		w[i]=m-w[i]+w[i-1];
		b[i]=m-b[i]+b[i-1];
		r[i]=m-r[i]+r[i-1];
	}
	int ans=n*m;

	reps(i, n-2)
	{
		for(int j=i+1; j<n; j++)
		{
			ans=min(ans, w[i-1]+(b[j-1]-b[i-1])+(r[n-1]-r[j-1]));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3100
#include<iostream>


using namespace std;

int main()
{
  int n;
  int k,pos;
  cin>>n>>k;
  int temp,count=0;
  for(auto i=0 ; i<n ;i++)
  {
    cin>>temp;
    if(temp>=k)
      count++;
  }
  cout<<count;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back
#define fi first
#define be begin()
#define en end()
#define se second

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  string s;
  cin>>s;
  int cnt(0);
  for (int i(0);i<3;i++){
    if (s[i] == 'o') cnt += 1;
  }
  cout << 700 + cnt*100 << endl;
  return 0;
}



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

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

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

struct UnionFind {
    vector<int> par, rank, _size;
    UnionFind(int n):par(n), rank(n), _size(n, 1) { for (int i = 0; i < n; ++i) par[i] = i; }
    int find(int x) {
        if (par[x] == x) return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return;
        if (rank[x] > rank[y]) swap(x, y);
        par[x] = y; _size[y] += _size[x];
        if (rank[x] == rank[y]) rank[y]++;
    }
    int size(int x) { return _size[find(x)]; }
    bool same(int x, int y) { return find(x) == find(y); }
};

vector<int> F[MAX], B[MAX];

int main(){
    int N, M, K;
    cin >> N >> M >> K;

    UnionFind uf(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        F[a].push_back(b);
        F[b].push_back(a);

        uf.unite(a, b);
    }

    rep(i, K) {
        int c, d;
        cin >> c >> d;
        c--, d--;
        B[c].push_back(d);
        B[d].push_back(c);
    }

    rep(i, N) {
        int ans = uf.size(i) - 1;
        for (auto &j : F[i]) {
            if (uf.same(i, j)) ans--;
        }
        for (auto &j : B[i]) {
            if (uf.same(i, j)) ans--;
        }
        cout << ans << " ";
    }
}

Measured memory_bytes: 13048
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#define maxn (210)
#define ll long long
#define il inline
#define RG register
using namespace std;
const ll inf=0x1f1f1f1f1f1f1f1f;
il ll gi(){ RG ll x=0,q=1; RG char ch=getchar(); while( ( ch<'0' || ch>'9' ) && ch!='-' ) ch=getchar();
  if( ch=='-' ) q=-1,ch=getchar(); while(ch>='0' && ch<='9') x=x*10+ch-48,ch=getchar(); return q*x; }

char s[2];
int n,m,R,Q[maxn*5];
ll L[maxn][maxn],S[maxn][maxn],C[maxn*5][maxn];

il ll dfs(){  
  for(RG int k=1;k<=n;k++){  
    for(RG int i=1;i<=n;i++)    
      for(RG int j=1;j<=n;j++){  
        S[i][j]=min(S[i][j],S[i][k]+S[k][j]);  
        L[i][j]=min(L[i][j],L[i][k]+L[k][j]);  
      }  
  }  
  C[1][Q[1]]=0;  
  for(RG int i=1;i<=R;i++) 
    for(RG int j=1;j<=n;j++){
      C[i][j]=min(C[i][j],C[i-1][j]+L[ Q[i-1] ][ Q[i] ]);
      for(RG int k=1;k<=n;k++){  
        C[i][k]=min(C[i][k],C[i-1][j]+L[ Q[i-1] ][j]+S[j][k]+L[k][ Q[i] ]);  
      }
    }  
  RG ll ans=inf;  
  for(RG int i=1;i<=n;i++) ans=min(ans,C[R][i]);  
  return ans;  
} 

il void init(){
  memset(L,inf,sizeof(L));  
  memset(S,inf,sizeof(S));  
  memset(C,inf,sizeof(C));  
  for(RG int i=1;i<=n;++i) L[i][i]=S[i][i]=0;
}

int main(){
  while(scanf("%d%d",&n,&m),n|m){  
    init();  
    for(int i=1;i<=m;++i){  
      RG int a=gi(),b=gi();RG ll c=gi();
      scanf("%s",s);  
      if(s[0]=='S') S[a][b]=S[b][a]=min(S[a][b],c);   
      else L[a][b]=L[b][a]=min(L[a][b],c);  
    }
    R=gi();  
    for(RG int i=1;i<=R;++i) Q[i]=gi();
    printf("%lld\n",dfs());  
  }  
  return 0;  
}

Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 10;
int li[10];
int ans = INT_MAX;
int N,A,B,C;
void dfs(int x,int alg,int blg,int clg,int merge_count){
	if(x > N){
		if(alg&&blg&&clg){
		ans = min(ans,(abs(alg - A)+abs(blg - B)+abs(clg-C))+(merge_count-3)*10);
		//cout << ans << " " << alg << " " << blg << " " << clg << " " << merge_count << endl;
		}
		return ;
	}
	dfs(x+1,alg+li[x],blg,clg,merge_count+1);
	dfs(x+1,alg,blg+li[x],clg,merge_count+1);
	dfs(x+1,alg,blg,clg+li[x],merge_count+1);
	dfs(x+1,alg,blg,clg,merge_count);
}
int main() {
	cin >> N >> A >> B >> C;
	for(int i = 0; i < N; i++){
		cin >> li[i];
	}
	dfs(0,0,0,0,0);
	cout << ans << endl;
    return 0;
}

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

int solve(vector<int>& v, int k) {
  int n = v.size();
  vector<int> dp(n, INT_MAX);
  dp[0] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 1; j <= k; ++j) {
      if (i - j >= 0) {
        dp[i] = min(dp[i], dp[i - j] + abs(v[i] - v[i - j]));
      }
    }
  }
  return dp[n - 1];
}

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for(auto& e: v) {
    cin >> e;
  }
  int k = 2;
  cout << solve(v, k) << '\n';
  return 0;
}


Measured memory_bytes: 4032
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt()

	for i := int(math.Floor(math.Sqrt(float64(n)))); i > 0; i-- {
		if n%i == 0 {
			fmt.Println(math.Ceil(math.Log10(float64((n / i) + 1))))
			return
		}
	}
	panic("Error!")
}


Measured memory_bytes: 640
#!/usr/bin/env python3

import sys

DEBUG = False


def read(t):
    return t(sys.stdin.readline().rstrip())


def read_list(t, sep=" "):
    return [t(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


def main():
    n = read(int)
    zorome_times = 0
    for _ in range(n):
        dices = read_list(int)
        if dices[0] == dices[1]:
            zorome_times += 1
            if zorome_times >= 3:
                print("Yes")
                return
        else:
            zorome_times = 0
    print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9192
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class ChocolateBar {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long h = in.nextLong();
            long w = in.nextLong();

            long result = Long.MAX_VALUE;
            // 横割り
            for (long i = 0; i <= h; i++) {
                // 横割り
                long hh = h - i;
                long h2 = hh / 2;
                long h3 = hh - h2;
                long res = Math.max(Math.max(i * w, h2 * w), h3 * w) - Math.min(Math.min(i * w, h2 * w), h3 * w);
                result = Math.min(result, res);

                // 縦割り
                long w2 = w / 2;
                long w3 = w - w2;
                long res2 = Math.max(Math.max(i * w, hh * w2), hh * w3) - Math.min(Math.min(i * w, hh * w2), hh * w3);
                result = Math.min(result, res2);
            }
            // 縦割り
            for (long i = 0; i <= w; i++) {
                // 横割り
                long ww = w - i;
                long h2 = h / 2;
                long h3 = h - h2;
                long res = Math.max(Math.max(i * h, h2 * ww), h3 * ww) - Math.min(Math.min(i * h, h2 * ww), h3 * ww);
                result = Math.min(result, res);

                // 縦割り
                long w2 = ww / 2;
                long w3 = ww - w2;
                long res2 = Math.max(Math.max(i * h, h * w2), h * w3) - Math.min(Math.min(i * h, h * w2), h * w3);
                result = Math.min(result, res2);
            }
            out.println(result);
        }

    }
}



Measured memory_bytes: 35952
S = gets.strip
f = S[0..1].to_i
b = S[2..3].to_i
r = 'NA'
if (0 < f && f <= 12) && (0 < b && b <= 12)
  r = 'AMBIGUOUS'
elsif 0 < b && b <= 12
  r = 'YYMM'
elsif 0 < f && f <= 12
  r = 'MMYY'
end
puts r

Measured memory_bytes: 1788