akhauriyash/Code-Regression huggingface dataset:
fn main () {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let a : i32 = s.trim().parse().ok().unwrap();
    let mut t = String::new();
    std::io::stdin().read_line(&mut t).ok();
    let b : i32 = t.trim().parse().ok().unwrap();
    println!("{}", (2 * b - a));
}


Measured memory_bytes: 4352
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, x;
    cin >> n >> x;

    --x;
    cout << (n - 1 - x) + 1 << '\n';

    return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main{

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

        int N = sc.nextInt();
        int[] A = new int[N];
        for(int i = 0; i < N; i++){
            A[i] = sc.nextInt();
        }
        int[] L = new int[N];
        int[] R = new int[N];
        int[] M = new int[N];

        for(int i = 0; i < N; i++){
            if(i == 0)
                L[i] = A[0];
            else
                L[i] = gcd(A[i], L[i-1]);
        }
        for(int i = N-1; i >= 0; i--){
            if(i == N-1)
                R[i] = A[N-1];
            else
                R[i] = gcd(A[i], R[i+1]);
        }
        for(int i = 0; i < N; i++){
            if(i == 0)
                M[i] = R[1];
            if(i == N-1)
                M[i] = L[N-2];
            if(i!= 0 && i!=N-1)
                M[i] = gcd(L[i-1], R[i+1]);
        }
        int max = M[0];
        for(int i = 1; i < N; i++){
            max = Math.max(max, M[i]);
        }
        sc.close();
        System.out.println(max);
    }

    static int gcd(int a, int b){
        if(b > a){
           return gcd(b, a);
        }
        if(b == 0)
            return a;
        else
            return gcd(b, a%b);
    }
}


Measured memory_bytes: 52252
n = int(input())
s = [input() for i in range(n)]

#ac,wa,tle,re
result = ["AC", "WA", "TLE", "RE"]
li = [0]*4

for i in s:
	li[result.index(i)] += 1

for i in range(4):
	print(result[i], "x", li[i])

Measured memory_bytes: 16180
def IsPalindrome(st):
    if len(st)%2==0:
        e = int(n/2-1)
    else:
        e = int((n-1)/2-1)
        
    for i in range(0, e):
        if st[i]!=st[-(i+1)]:
            return(False)
    return(True)


s = input()
n = len(s)
s1 = s[:int((n-1)/2)]
s2 = s[int((n+3)/2)-1:]


if IsPalindrome(s)==IsPalindrome(s1)==IsPalindrome(s2)==True:
    print("Yes")
else:
    print("No")


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


#define MAX 100002

int n;

unsigned long long int a;
unsigned long long int b;


vector<unsigned long long int> v;

int im[MAX];

#define MOD 1000000007

long long int dp[MAX][2];

int main(){
	cin >> n;
	long long int aa, bb;
	scanf("%lld%lld", &aa, &bb);
	a = aa;
	b = bb;
	if (a < b)swap(a, b);
	for (int i = 0; i < n; i++){
		long long int s;
		scanf("%lld", &s);
		v.push_back(s);
	}
	for (int i = 0; i + 1 < n; i++){
		if (v[i] + b > v[i + 1]){
			im[i]++;
		}
	}
	for (int i = 0; i <= n; i++){
		if (i){
			im[i] += im[i - 1];
		}
	}
	dp[0][0] = 1;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < 2; j++){
			if (dp[i][j] == 0)continue;
			//select
			int id = lower_bound(v.begin(), v.end(), v[i] + a) - v.begin();
			if (id > i + 1){
				if (j == 0){
					if (max(0,im[id - 2] - im[i])){

					}
					else{
						dp[id][1] += dp[i][j];
					}
				}
				else{
					if (max(0,im[id - 2] - im[i])){

					}
					else{
						if (v[i + 1] < v[i - 1] + b){

						}
						else{
							dp[id][1] += dp[i][j];
						}
					}
				}
			}
			else{
				dp[id][0] += dp[i][j];
			}
			dp[id][0] %= MOD;
			dp[id][1] %= MOD;
			//not choose
			if (j == 0){
				dp[i + 1][1] += dp[i][j];
				dp[i + 1][1] %= MOD;
			}
			else{
				if (v[i] - v[i - 1] >= b){
					dp[i + 1][1] += dp[i][j];
					dp[i + 1][1] %= MOD;
				}
			}
		}
	}
	long long int ans = dp[n][0] + dp[n][1];
	ans %= MOD;
	printf("%lld\n", ans);
	return 0;
}

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

using ll = long long;
#define repi(n) for (int i = 0; i < (n); i++)
#define repj(n) for (int j = 0; j < (n); j++)
#define repk(n) for (int k = 0; k < (n); k++)
#define repl(n) for (int l = 0; l < (n); l++)
#define rep(i, n) for (int i = 0; (i) < (n); i++)
#define repr(i, a, b) for (auto i = (a); i < (b); i++)
#define repv(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = max((t), (v)))
#define updatemin(t, v) (t = min((t), (v)))
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
ll modpow(ll a, ll b, ll m) {
  ll re = 1, k = 1;
  while (k <= b) {
    if (b & k) {
      re *= a;
      re %= m;
    }
    k = k << 1;
    a *= a;
    a %= m;
  }
  return re;
}
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=200100;
int a[maxn];
map<long long,int> mp;
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	long long sum=0;
	mp[0]++;
	long long ans=0;
	for(int i=1;i<=n;i++){
		sum=sum+a[i];
		ans=ans+mp[sum];
		mp[sum]++;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
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; }

struct edge { int to; int cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int n,k;
ll ans = 1;
vi v[100010],vv[100010];
int flag[100010];

void dfs(int now, int par){
	flag[now] = 1;
	ans = (ans*(k-vv[par].size()))%MOD;
	//if(par != 0) vv[now].push_back(par);
	for(auto x : v[now]){
		if(flag[x]) continue;
		//vv[par].push_back(x);
		//vv[x].push_back(par);
		vv[now].push_back(x);
		vv[x].push_back(now);
		
		dfs(x,now);
	}
}

int main() {
	cin >> n >> k;
	vi a(n-1),b(n-1);
	rep(i,n-1){
		cin >> a[i] >> b[i];
		v[a[i]].push_back(b[i]);
		v[b[i]].push_back(a[i]);
	}
	int s;
	for(int i = 1; i <= n; i++){
		if(v[i].size() == 1) s = i;
	}
	dfs(s,0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 18560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
/* clang-format off */
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

vector<ll> lc(90, -1);

int main() {
  int n;
  ll n1 = 0, n2 = 0;
  cin >> n;
  vector<int> a(n);
  REP(i, n) { cin >> a.at(i); }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int pre = -1;
  int cnt = 1;
  REP(i, n) {
    if (a.at(i) == pre) {
      cnt++;
      if (n1 == 0)
        n1 = pre;
      else if (n2 == 0) {
        if (n1 == a.at(i)) {
          if (cnt >= 4) n2 = pre;
        }else
          n2 = pre;
      }
    } else {
      cnt = 1;
    }
    pre = a.at(i);
  }
  cout << n1 * n2 << "\n";
  return 0;
}

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

int main() {

    int N,M;
    scanf("%d %d",&N,&M);

    int s;
    int c;
    int count[M];
    int info[M];
    int worth = 0;
    for(int i = 0; i < N; ++i){
        info[i] = 0;
        count[i] = 0;
    }
    if(N >1) {
        info[0] = 1;
    }
    for(int j = 0; j < M; ++j){
        scanf("%d %d",&s,&c);
        if(info[s-1] == c && count[s-1] >=1) {
        }
        else if(s== 1 && c == 0 && N > 1){
            worth = -1;
            count[0]++;
        }
        else if(count[s-1] == 0){
            info[s-1] = c;
            count[s-1]++;
        } else{
            worth = -1;
        }

    }
    if(worth == -1){
        printf("-1");
    }
    else{
        for(int i = 0; i < N; ++i) {
            printf("%d",info[i]);
        }
    }


}

int A(){
    int N;
    scanf("%d",&N);
    printf("%d",N/2 + N % 2);
    return 0;
}

int B(){
    int bingo[3][3];
    for(int i = 0; i < 3; ++i){
        for(int j = 0; j < 3; ++j){
            scanf("%d",&bingo[i][j]);
        }
    }
    int N;
    scanf("%d",&N);
    int S[N];
    for(int i = 0; i < N; ++i){
        scanf("%d",&S[i]);

        for(int j = 0; j < 3; ++j){
            for(int k = 0; k < 3; ++k){
                if(bingo[j][k] == S[i]){
                    bingo[j][k] = 0;
                }
            }
        }
    }

    if(bingo[0][0]==bingo[0][1]&& bingo[0][1]==bingo[0][2]){
        printf("Yes");
        return 0;
    }
    else if(bingo[1][0] == bingo[1][1] &&bingo[1][1]== bingo[1][2] ){
        printf("Yes");
        return 0;
    }
    else if(bingo[2][0] == bingo[2][1] && bingo[2][1]== bingo[2][2] ){
        printf("Yes");
        return 0;
    }
    else if(bingo[0][0] == bingo[1][0] && bingo[1][0]== bingo[2][0] ) {
        printf("Yes");
        return 0;
    }
    else if(bingo[0][1] == bingo[1][1]&&bingo[1][1] == bingo[2][1] ){
        printf("Yes");
        return 0;
    }
    else if(bingo[0][2] == bingo[1][2] && bingo[1][2]== bingo[2][2] ){
        printf("Yes");
        return 0;
    }
    else if(bingo[0][0]== bingo[1][1]&&bingo[1][1] == bingo[2][2] ) {
        printf("Yes");
        return 0;
    }
    else if(bingo[0][2] == bingo[1][1]&&bingo[1][1] == bingo[2][0] ) {
        printf("Yes");
        return 0;
    }
    else {
        printf("No");
        return 0;
    }
}


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

typedef long long LL;
const int INF=0x3f3f3f3f;

int main(){
    int l,r,ans=0;
    string s;
    cin>>s;
    l=0,r=s.size()-1;
    while(l<r){
        if(s[l]==s[r]){
            l++;r--;
            continue;
        }
        else if(s[l]=='x'){
            l++;ans++;
            continue;
        }
        else if(s[r]=='x'){
            r--;ans++;
            continue;
        }
        else{
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int antenna[5];
  int k;
  bool judge = true;
  for(int i = 0; i < 5; i++) {
    cin >> antenna[i];
  }
  cin >> k;
  sort(antenna, antenna + 5);
  for(int i = 0; i < 5; i++) {
	  if(antenna[4] - antenna [0] > k) {
		 judge = false;
	  }
  }
  if(judge) {
	  cout << "Yay!" << endl;
  }else {
	  cout << ":(" << endl;
  }
}
  
  


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

ll n;
vector<ll> a(100100), b(100100);

ll dif(ll x, ll m) {
    ll y = (x+m-1)/m*m;//x以上の最小のmの倍数
    return y-x;
}

int main() {
    cin >> n;
    a.resize(n);
    b.resize(n);
    rep(i, n) cin >> a[i] >> b[i];
    reverse(all(a));
    reverse(all(b));
    ll cnt = 0;
    rep(i, n) {
        a[i] += cnt;
        cnt += dif(a[i], b[i]);
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/


int main() {
    cin >> n >> m;
    cout << (n % m ? n : -1) << endl;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new ABC127().SolveC(new ConsoleInput(Console.In, ' '));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
  class ABC127
    {
    	public void SolveC(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            var m = cin.ReadInt;
            var L = new int[m];
            var R = new int[m];
            for (int i = 0; i < m; i++)
            {
                L[i] = cin.ReadInt;
                R[i] = cin.ReadInt;
            }
            int min = L[0];
            int max = R[0];
            for (int i = 1; i < m; i++)
            {
                if (min < L[i]) min = L[i];
                if (max > R[i]) max = R[i];
            }
            if (max < min) WriteLine(0);
            else WriteLine(max - min + 1);
            ReadLine();
        }
    }
}


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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

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

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<ll> A(N);
    for (int i=0;i<N;i++) cin >> A[i];
    vector<int> zero(61);
    vector<int> one(61);
    for (int i=0;i<N;i++){
        for (int bit=0;bit<61;bit++){
            if ((A[i]>>bit)&1) {
                one[bit]++;
                one[bit] %= mod;
            } else {
                zero[bit]++;
                zero[bit] %= mod;
            } 
        }
    }
    mint ans = 0;
    for (int bit=0;bit<61;bit++){
        ans += mint(1LL<<bit)*one[bit]*zero[bit];
    }
    cout << ans << "\n";
}

Measured memory_bytes: 5544
import java.io.*;
import java.math.*;
import java.util.*;
import java.lang.*;
public class Main { 
 
	public static void main(String[] args) { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		long[] a = new long[N];
		long ans = 1;
		for (int i = 0; i < N; i++) a[i] = I.nextLong();
		Arrays.sort(a);
		long[] pref = new long[N+1];
		for (int i = 0; i < N; i++) {
			pref[i+1]=pref[i];
			pref[i+1]+=a[i];
		}
		for (int cur = N-2; cur >= 0; cur--) {
			if (pref[cur+1]*2>=a[cur+1]) ans++;
			else break;
		}
		O.pln(ans);
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(boolean x) {w.println(x);w.flush();}
	}
}

Measured memory_bytes: 47432
s=input()
ans=0
y=0
for i in range(len(s)):
    if(s[i]=='g'):
        if(y>0):
            ans=ans+1
            y=y-1
        else:
            y=y+1
    else:
        if(y>0):
            y=y-1
        else:
            y=y+1
            ans=ans-1
print(ans)
            


Measured memory_bytes: 3316
// <<<<GOD>>>> lET'S gO

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

typedef long long ll;
const ll N = 1e5 + 100, inF = 1e15;

ll n, e, t, mini = inF, a[N], dp[N];

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> e >> t;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	int p = 0;
	for (int i = 1; i <= n; i++) {
		while(2 * (a[i] - a[p]) > t) {
			mini = min(mini, dp[p - 1] - 2 * a[p]);
			p++;
		}
		dp[i] = dp[p - 1] + t;
		dp[i] = min(dp[i], 2 * a[i] + mini);
	}
	cout << e + dp[n];
	return 0;
}

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


int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];

    sort(v.begin(), v.end());
    double sum = v[0];
    for(int i = 1; i < n; i++) {
        sum = (sum + v[i]) / 2;
    }

    printf("%.10f",sum);
}


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

int main(){
	int N, K, X=1;
	scanf("%d %d", &N, &K);
	while (N>0){
		if(X<=K){
			X*=2;
		}
		else{
			X+=K;
		}
		N--;
	}
	printf ("%d", X);
return 0;
}


Measured memory_bytes: 1728
n = int(input())
 
if (n % 10 == 2) | (n % 10 == 4) | (n % 10 == 5) | (n % 10 == 7) | (n % 10 == 9):
  print("hon")
 
elif (n % 10 == 0) | (n % 10 == 1) | (n % 10 == 6) | (n % 10 == 8):
  print("pon")
 
else:
  print("bon")

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define All(v) v.begin(), v.end()
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int a, p; cin >> a >> p;
    cout << (3*a+p) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define MODB 998244353
#define INF 9223372036854775807
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
signed main()
{
  int x=0,y=0,z=0,w=0,n=0,m=0;
  std::cin >> x>>y;
  string s[x];
  rep(i,x){
      std::cin >> s[i];
  }
  rep(i,y+2){
    std::cout << '#';
  }
  std::cout  << '\n';
  rep(i,x){
      std::cout <<'#'<<s[i]<<'#' << '\n';
  }
  rep(i,y+2){
    std::cout << '#';
  }
  std::cout  << '\n';
}


Measured memory_bytes: 256
#詳しくはcollections pythonで検索。出てきた文字列の数をカウントする。
from collections import Counter
#入力。文字列は扱いやすくするためリスト化した。
#先に空のリスト作らないとリストに入れられないので作る。
N = int(input())
S = [None for _ in range(N)]
for i in range(N):
  S[i] = input()
#出てきた要素とその数をリストに記録。
count = Counter(S)
countkey = list(count.keys())
countval = list(count.values())
#出てきた要素をリストに記録しその数をlcvとする。
lcv = len(countkey)
#再頻出の要素の出現回数を記録。
maxval = max(countval)
#出現回数が最大の要素を記録するためのリストを作製。
Se = [None for _ in range(N)]
#出現回数が最大の要素を記録。
for i in range(lcv):
  if countval[i] == maxval:
    Se[i] = countkey[i]
#記録された要素のみ抽出。型が全てstr型なので一発。
Seprint = [se for se in Se if type(se) == str]
#辞書順に並べろとのことなので並び替え。
Seprint = sorted(Seprint)
#改行して出力するため、最後に残った要素の数を調べる。
lSe = len(Seprint)
#結果
for i in range(lSe):
  print(Seprint[i])

Measured memory_bytes: 39644
' Imports System.Collections.Generic
' Imports System.Text.RegularExpressions

Class Main
    Public Shared Sub Main()
        Dim N As Long = Console.ReadLine()
        Console.WriteLine(calc(1, N) - calc(3, N) - calc(5, N) + calc(15, N))
        Return
    End Sub

    Shared Function calc(ByVal n As Long, ByVal X As Long) As Long
        Dim Qt As Long = Math.Floor(CType(X, Decimal) / n)
        return Math.Floor(CType((n + Qt * n) * Qt, Decimal) / 2)
    End Function
End Class


Measured memory_bytes: 28364
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#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 per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif
struct UnionFind{
	vector<int> par,rank;
	UnionFind(int N){
		par.assign(N,0);
		rank.assign(N,0);
		rep(i,N) par[i]=i;
	}
	int find(int x){
		if(par[x]==x) return x;
		return par[x]=find(par[x]);
	}
	bool same(int x,int y){
		return find(x)==find(y);
	}
	void unite(int x,int y){
		x=find(x),y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y]) swap(x,y);

		//x becomes root
		par[y]=x;
		if(rank[x]==rank[y]) rank[x]++;
	}
};
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	int N,M; cin >> N >> M;
	UnionFind UF(N);
	rep(i,M){
		int x,y; cin >> x >> y; x--,y--;
		UF.unite(x,y);
	}
	int c = 0;
	rep(i,N)if(UF.find(i) == i) c++;
	cout << c-1 << endl;
}


Measured memory_bytes: 3940
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
#define ll long long
const int maxn = 1e5 + 10;
int b[maxn] = {0}, l[maxn] = {0}, u[maxn] = {0};
long long pre[maxn] = {0}, sum[maxn] = {0};

int mult(int who, int k){
    if(k >= b[who]){return u[who];}
    return l[who];
}

//vector <pair <long long, int> > G;

pair <long long, int> a[maxn];

bool check(int n, int m, int k){
    for(int i = 1; i <= m; i++){
        int p = a[i].second;
        //int p = G[i - 1].second;
        int multi = mult(p, k);
        long long a1 = sum[m + 1] - sum[i] + sum[i - 1] + (long long)(k - b[p]) * multi;
        long long a2 = pre[n] - pre[m + 1];
        /*if(sum[m + 1] - sum[i] + sum[i - 1] +
           (long long)(k - b[p]) * multi - pre[n] + pre[m + 1] >= 0){
            return true;
        }*/
        if(a1 >= a2){
            return true;
        }
    }
    for(int i = m + 1; i <= n; i++){
        int p = a[i].second;
        //int p = G[i - 1].second;
        int multi = mult(p, k);
        long long a1 = sum[m] + (long long)(k - b[p]) * multi;
        long long a2 = pre[n] - pre[i] + pre[i - 1] - pre[m];
        /*if(sum[m] + (long long)(k - b[p]) * multi
           - pre[n] + pre[i] - pre[i - 1] + pre[m] >= 0){return true;}*/
        if(a1 >= a2){return true;}
    }
    //system("pause");
    return false;
}

int main(){
    int n, x;
    scanf("%d%d", &n, &x);
    for(int i = 1; i <= n; i++){
        scanf("%d%d%d", &b[i], &l[i], &u[i]);
        long long anw = (long long)b[i] * l[i] + (long long)(x - b[i]) * u[i];
        a[i] = make_pair(anw, i);
    }
    sort(a + 1, a + 1 + n);
    reverse(a + 1, a + 1 + n);
    for(int i = 1; i <= n; i++){
        int j = a[i].second;
        pre[i] = pre[i - 1] + (long long)b[j] * l[j];
        sum[i] = sum[i - 1] + (long long)(x - b[j]) * u[j];
    }
    long long L1 = 0, R = (long long)n * x;
    while(L1 < R){
        long long mid = (L1 + R) >> 1;
        if(check(n, mid / x, mid % x)){
            R = mid;
        }
        else{
            L1 = mid + 1;
        }
    }
    printf("%lld", L1);
    return 0;
}

/*int main()
{
	int n, x;
	scanf("%d%d", &n, &x);
	for(int i = 1; i <= n; i++)
	{
		scanf("%d%d%d", &b[i], &l[i], &u[i]);
		long long anw = (long long)b[i] * l[i] + (long long)(x - b[i]) * u[i];
		a[i] = make_pair(anw, i);
		//a[i] = make_pair((ll)(x-b[i])*u[i]+(ll)b[i]*l[i], i);
	}
	sort(a+1, a+1+n);
	reverse(a+1, a+1+n);
	for(int i = 1; i <= n; i++)
	{
	    int j = a[i].second;
		pre[i] = pre[i-1]+(long long)b[j]*l[j];
		sum[i] = sum[i-1]+(long long)(x-b[j])*u[j];
	}
	ll l = 0, r = (ll)n*x;
	while(l<r)
	{
		ll mid = (l+r)>>1;
		if(check(n, mid/x, mid%x))
		{
			r = mid;
		}
		else
		{
			l = mid+1;
		}
	}
	printf("%lld\n", l);
	return 0;
}*/


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

int main() {
    int N, K;  cin >> N >> K;
    vector<int> h(N);
    for (int i = 0; i < N; ++i) cin >> h[i];
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        if (h[i] >= K) ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<stdio.h>
#define N 100
void swap(int *x, int *y);
int main(){
  int n,i,j,a[N],min,count=0,flag=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<=n-2;i++){
    min=i;
    for(j=i;j<=n-1;j++){
      if(a[j]<a[min]){
	min=j;
	flag=1;
      }
    }
    if(flag==1){
      count++;
      flag=0;
    }
    swap(a+i,a+min);
  }
  for(i=0;i<n-1;i++){
    printf("%d ",a[i]);
  }
  printf("%d\n",a[n-1]);
  printf("%d\n",count);
  return 0;
}

void swap(int *x,int *y){
  int z;
  z=*x;
  *x=*y;
  *y=z;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

constexpr ll MAX = 1e15;

template <typename T>
vector<T> Dijkstra(int s, vector<vector<pair<int, T>>>& G,
                   /*vector<int> & prev,*/ const T INF = 1e9) {
    using P = pair<T, int>;
    int V = G.size();
    vector<T> dist(V, INF);
    priority_queue<P, vector<P>, greater<P>> que;
    dist[s] = 0;
    que.emplace(0, s);
    // prev.assign(V, -1);
    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (dist[v] < p.first) continue;
        for (int i = 0; i < (int)G[v].size(); i++) {
            int to = G[v][i].first;
            T cost = G[v][i].second;
            if (dist[to] > dist[v] + cost) {
                dist[to] = dist[v] + cost;
                // prev[to] = v;
                que.emplace(dist[to], to);
            }
        }
    }
    return dist;
}

signed main() {
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--;
    t--;
    int u, v, a, b;
    vector<vector<pair<int, ll>>> Gs(n), Gt(n);
    rep(i, m) {
        cin >> u >> v >> a >> b;
        u--;
        v--;
        Gs[u].emplace_back(v, a);
        Gs[v].emplace_back(u, a);
        Gt[u].emplace_back(v, b);
        Gt[v].emplace_back(u, b);
    }
    auto dists = Dijkstra(s, Gs, LINF), distt = Dijkstra(t, Gt, LINF);
    ll mx = 0;
    ll ans[n];
    for (int v = n - 1; v >= 0; v--) {
        mx = max(mx, MAX - (dists[v] + distt[v]));
        ans[v] = mx;
    }
    rep(i, n) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 21008
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,K;
int num[200010];
int A[200010];

int mod_pow(int b,int e,int m){
    if(e==0){
        return 1;
    }else{
        int sum = mod_pow(b,e/2,m);
        if(e%2==0){
            return (sum*sum)%m;
        }else{
            return (((sum*sum)%m)*b)%m;
        }
    }
}

signed main(){
	cin>>N>>K;
	int sum=0;
	for(int i=0;i<=N;i++){
		sum+=i;
		sum%=MOD;
		A[i+1]=sum;
	}
	int ans=0;
	for(int i=K;i<=N+1;i++){
		int s=A[i]-A[0]+MOD;
		s%=MOD;
		int t=A[N+1]-A[N+1-i]+MOD;
		t%=MOD;
		ans+=(t-s+1+MOD)%MOD;
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}


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

int A[200001];
map<int, int> D;

int main(){
  int N;
  cin >> N;
  rep(i, N-1) cin >> A[i];
  rep(i, N-1){
    if (D.count(A[i])) D[A[i]]++;
    else D[A[i]] = 1;
  }
  rep(i, N) cout << D[i+1] << endl;
}


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

using namespace std;

int main() {
    int N, D;
    cin >> N >> D;
    int start = D + 1;
    int ans = 1;
    while (start + D < N) {
        ans++;
        start += 2 * D + 1;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    ll x2 = 0;
    rep(i,n){
        if(i%2) x2 -= a[i];
        else x2 += a[i];
    }
    vector<int> ans(n);
    ans[0] = x2/2;
    rep(i,n-1){
        ans[i+1] = a[i] - ans[i];
    }
    rep(i,n) ans[i] *= 2;
    rep(i,n) printf("%d%c",ans[i],i==n-1?'\n':' ');
    return 0;
}

Measured memory_bytes: 2048
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define KOZYUN(a) sort(all(a),greater<int>())
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    INT(n);
    if(n%2 == 1) OUT(n/2+1);
    else OUT(n/2);

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a=0, b = 0,c,d, n, k;
string s, t;


int main()
{
	cin >>n>> a >> b;
	cout << min( a*n,b) << endl;

	return 0;
}

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

using namespace std;


#define INF 1000000000

const long long DIMN = 22;
const long long DIMMASK = (1LL<<21)+7;
const long long MODULO = 1000000007;

long long a[DIMN][DIMN];
long long alln,m,k,i,j,res;
long long d[DIMN][DIMMASK];

long long f(int n, long long mask) {
    if(d[n][mask] == -1) {
        if(n == 0 && mask != 0) d[n][mask] = 0;
        else {
            d[n][mask] = 0;
            for(int b = 1; b <= alln; b++)
                if(a[n][b] == 1 && (mask & (1<<(b-1))) )
                    d[n][mask] = (d[n][mask] + f(n-1,mask - (1<<(b-1))) )  % MODULO;
        }
    }
    return d[n][mask];
}

int main() {
    //freopen("input.txt", "r", stdin);

    cin >> alln;
    for(int i = 1; i <= alln; i++)
        for(int j = 1; j <= alln; j++) cin >> a[i][j];

    memset(d, -1, sizeof(d));
    d[0][0] = 1;
    res = f(alln,(1<<alln)-1);
    cout<<res<<endl;
/*
    for(int i = 0; i <= alln; i++) {
        for(int m = 0; m < (1<<alln); m++) cout<<d[i][m]<<' ';
        cout<<endl;
    }
*/
    return 0;
}


Measured memory_bytes: 360704
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

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

Measured memory_bytes: 256
while True:
    n = int(raw_input())
    if n == 0: break
    t = 0
    for i in range(int(raw_input())):
        t += reduce(lambda x, y: y-x, map(int, raw_input().split()))
    else:
        if n <= t:
            print 'OK'
        else:
            print n-t

Measured memory_bytes: 4296
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    if(s.equals("Sunny")){
      System.out.println("Cloudy");
    }else if(s.equals("Cloudy")){
      System.out.println("Rainy");
    }else{
      System.out.println("Sunny");
    }
  }
}


Measured memory_bytes: 21844
#!/usr/bin/env python
import itertools

def main():
    N = int(input())
    p = list(map(int, input().split()))

    compArr = list(range(1, N+1))
    arr = list(range(N))
    combs = list(itertools.combinations(arr, 2))

    ans = 'NO' 
    if p == compArr:
        ans = 'YES'
    for c in combs:
        tmpArr = compArr.copy()
        tmpArr[c[0]], tmpArr[c[1]] = tmpArr[c[1]], tmpArr[c[0]]
        if p == tmpArr:
            ans = 'YES'

    return ans

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  int i;
  cin >> n;
  int num[n];
  for(i = 0; i < n; i++){
	cin >> num[i];
  }
  int f1 = 0;
  for(i = 0; i < n; i++){
    if(num[i] % 2 == 0 && num[i] % 3 != 0 && num[i] % 5 != 0){
          f1++;
    }
  }
  if(f1 == 0){
    cout << "APPROVED" << endl;
  }
  else if(f1 != 0){
    cout << "DENIED" << endl;
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, a;
  cin >> n;
  a = n % 10;
  if(a == 3) cout << "bon";
  else if(a == 0 || a == 1 || a == 6 || a == 8) cout << "pon";
  else cout << "hon";

}

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

int main() {
    string wet;
    cin >> wet;
    if(wet.at(0) == 'R' && wet.at(1) == 'R' && wet.at(2) == 'R'){
        cout << 3 << endl;
    }else if((wet.at(0) == 'R' && wet.at(1) == 'R') || (wet.at(1) == 'R' && wet.at(2) == 'R')){
        cout << 2 << endl;
    }else if(wet.at(0) == 'R' || wet.at(1) == 'R' || wet.at(2) == 'R'){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3640
//
// Created by Mahmoud Rashad on 11/27/19.
//

#include <bits/stdc++.h>


using namespace std;

typedef pair<int, int> ii;

long long count_P_in_nfact(long long n , long long p) {
    long long res = 0;
    while (n) {
        n /= p;
        res += n;
    }
    return res;
}
long long count_5_in_nfact(long long n , long long p) {
    long long res = 0;
    while (n) {
        n /= p;
        res += n / 2;
    }
    return res;
}

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.out", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;

    int a, b;
    cin >> a >> b;
    cout << 1LL * a * b / __gcd(a, b) << '\n';

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,w,x,y;
    cin>>n>>w;
    vector<ll> value(n+1),weight(n+1);
    value[0]=0;weight[0]=0;
    for(ll i=0;i<n;i++)
    {
        cin>>x>>y;
        weight[i+1]=x;
        value[i+1]=y;
    }
    ll ans[n+1][w+1];
    for(ll i=0;i<=n;i++) ans[i][0]=0;
    for(ll i=1;i<=w;i++) ans[0][i]=0;
    for(ll i=1;i<=n;i++)  //i means no. of items to consider, j means weight considered
    {
        for(ll j=1;j<=w;j++)
        {
            if(j<weight[i]) ans[i][j]=ans[i-1][j];
            else{
                ans[i][j]=max(ans[i-1][j],value[i]+ans[i-1][j-weight[i]]);
            }
        }
    }
    cout<<ans[n][w];
    return 0;
}

Measured memory_bytes: 79104
#include<iostream>
#include<vector>
#include<string>
#include<cstdio>
#include<map>
#include<algorithm>

using namespace std;

int main(){
	int n1,n2;
	char after,before;
	map<char,char> data;
	char input;

	while(cin>>n1,n1 != 0){
		data.clear();
		for(int i=0;i<n1;i++){
			cin>>before>>after;
			data.insert( pair<char,char>(before,after) );
		}
		cin>>n2;

		for(int i=0;i<n2;i++){
			cin>>input;
			if(data.find(input) == data.end() ){
				cout<<input;
			}else{
				cout<<data[input];
			}
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1188
S = str(input())
N = len(S)
x,y = map(int,input().split())
X = []; Y =[]
Flag = True #Trueならx軸、Falseならy軸
seq = 0
for i in range(N):
  if S[i] == "T":
    if Flag:
      X.append(seq)
    if not Flag:
      Y.append(seq)
    Flag = not Flag
    seq = 0
  else:
    seq += 1
    if i == N-1:
      if Flag:
        X.append(seq)
      if not Flag:
        Y.append(seq)
#print(X,Y)
num = 8100 #真ん中
MAX = num*2+1
#X方向i回目でjにいる
dpx = [0 for _ in range(MAX)]
dpx[num] = 1
dpy = [0 for _ in range(MAX)]
dpy[num] = 1
for i in range(len(X)):
  px = [0 for _ in range(MAX)]
  px,dpx = dpx,px
  step = X[i]
  for j in range(MAX):
    if j -step >= 0:
      dpx[j] = max(dpx[j],px[j-step])
    if j + step < MAX and i != 0: #一番最初は左に戻れない
      dpx[j] = max(dpx[j],px[j+step])
for i in range(len(Y)):
  py = [0 for _ in range(MAX)]
  py,dpy = dpy,py
  step = Y[i]
  for j in range(MAX):
    if j -step >= 0:
      dpy[j] = max(dpy[j],py[j-step])
    if j + step < MAX:
      dpy[j] = max(dpy[j],py[j+step])
x += num;y+= num
#print(dpx)
#print(dpy)
if dpx[x] == 1 and dpy[y] == 1:
  print("Yes")
else:
  print("No")
  
      
     


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

#define ff first
#define ss second
#define endl '\n'

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

	int n, k;
	cin >> n >> k;

	vector<int> invalid;
	for (int i = 0, x; i < k; ++i) {
		cin >> x;
		invalid.push_back(x);
	}

	bool valid = 0;
	for (int i = n, t, r; ; ++i) {
		valid = 1;
		for (t = i; t > 0; t /= 10) {
			r = t % 10;
			for (int x : invalid) {
				if (x == r) {
					valid = 0;
					break;
				}
			}

			if (!valid) {
				break;
			}
		}

		if (valid) {
			cout << i << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

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

	cout << (a - 1) * (b - 1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
static char c, prev;
static int i;
int main(void) {
    prev = getchar();
    putchar(prev);
    c = getchar();
    while (1) {
        prev = c;
        c = getchar();
        if (c == '\n') break;
        ++i;
    }
    printf("%d%c\n", i, prev);
    return 0;
}

Measured memory_bytes: 128