akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int N;
int P[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	int ma=N+1;
	int ret=0;
		FOR(i,N) {
		cin>>x;
		if(x<ma) {
			ret++;
			ma=x;
		}
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <ctime>

using namespace std;

int n, a, b;

int main()
{
    cin >> n;
    if (n == 1)
        cout << "Hello World" << endl;
    else if (n == 2)
    {
        cin >> a >> b;
        cout << a + b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
function main(input){
        const lines = input.split(/\n/);
        const coin500 = parseInt(lines[0]);
        const coin100 = parseInt(lines[1]);
        const coin50 = parseInt(lines[2]);
        const goal = parseInt(lines[3]);
        var count = 0;
        var i = 0,j = 0 ,k = 0;
        end:
        for(i = coin50; i >= 0; i--){
            for(j = coin100; j >= 0; j--){
                for(k = coin500; k >= 0; k--){
                    if(i * 50 + j * 100 + k * 500 === goal){
                        count++;
                    }
                }   
            }
        }
        console.log(count);
    }
    main(require('fs').readFileSync('/dev/stdin','utf-8'));

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

using namespace std;
const int INF = (1 << 30);
const int N = 100000 + 5;
const double eps = 1e-8;
const int M = 100 + 5;
const int MOD = 1e9;

char str[N];
int main(){
    scanf("%s", str);
    int len = strlen(str);
    for(int i = 0; i < len; i += 2) putchar(str[i]);
    puts("");
}


Measured memory_bytes: 384
#include<stdio.h>
#include<algorithm>
#include<deque>
using namespace std;
int c[10][10];
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int bfs[10][10][10][10];
int main(){
	int a,b;
	while(scanf("%d%d",&b,&a),a){
		for(int i=0;i<a;i++)for(int j=0;j<b;j++)scanf("%d",&c[i][j]);
		int sr,sc,pr,pc,gr,gc;
		for(int i=0;i<a;i++)for(int j=0;j<b;j++){
			if(c[i][j]==2){pr=i;pc=j;}
			if(c[i][j]==3){gr=i;gc=j;}
			if(c[i][j]==4){sr=i;sc=j;}
		}
		for(int i=0;i<a;i++)for(int j=0;j<b;j++)
			for(int k=0;k<a;k++)for(int l=0;l<b;l++)
				bfs[i][j][k][l]=999999999;
		deque<pair<pair<int,int>,pair<int,int> > > Q;
		Q.push_back(make_pair(make_pair(sr,sc),make_pair(pr,pc)));
		bfs[sr][sc][pr][pc]=0;
		while(Q.size()){
			int ar=Q.front().first.first;
			int ac=Q.front().first.second;
			int br=Q.front().second.first;
			int bc=Q.front().second.second;
			Q.pop_front();
			for(int i=0;i<4;i++){
				int nr=ar+dx[i];
				int nc=ac+dy[i];
				if(nr<0||nc<0||nr>=a||nc>=b||c[nr][nc]==1)continue;
				if(br==nr&&bc==nc){
					int tr=br+dx[i];
					int tc=bc+dy[i];
					if(tr<0||tc<0||tr>=a||tc>=b||c[tr][tc]==1)continue;
					if(bfs[nr][nc][tr][tc]>999999){
						bfs[nr][nc][tr][tc]=bfs[ar][ac][br][bc]+1;
						Q.push_back(make_pair(make_pair(nr,nc),make_pair(tr,tc)));
					}
				}else{
					if(bfs[nr][nc][br][bc]>999999){
						bfs[nr][nc][br][bc]=bfs[ar][ac][br][bc];
						Q.push_front(make_pair(make_pair(nr,nc),make_pair(br,bc)));
					}
				}
			}
		}
		int ret=999999999;
		for(int i=0;i<a;i++)for(int j=0;j<b;j++)
			ret=min(ret,bfs[i][j][gr][gc]);
		if(ret>999999)printf("-1\n");
		else printf("%d\n",ret);
	}
}

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

int main()
{
	int n,m;
	cin >> n >> m;
	atcoder::dsu DSU(n);

	for(int i = 0;i<m;i++)
	{
		int a,b;
		cin >> a >> b;
		a--;b--;

		DSU.merge(a,b);
	}
	int cnt = 0;
	for(int i = 0;i<n;i++)
	{
		if(DSU.same(0,i)==false)
		{
			cnt++;
			DSU.merge(0,i);
		}
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 3820
from collections import deque

def dfs(tree, cost, root):
    q = deque([root])
    dist = [-1]*N

    dist[root] = cost[root]

    while q:
        v = q.pop()
        for n_v in tree[v]:
            if dist[n_v] < 0:
                dist[n_v] = dist[v] + cost[n_v]
                q.append(n_v)

    return dist

N, Q = map(int, input().split())
tree = [[] for _ in range(N)]

for _ in range(N - 1):
    a, b = map(int, input().split())
    tree[a - 1].append(b - 1)
    tree[b - 1].append(a - 1)

pts = [0]*N

for _ in range(Q):
    p, x = map(int, input().split())
    pts[p - 1] += x

dist = dfs(tree, pts, 0)

for i in range(N):
    print(dist[i])

Measured memory_bytes: 121108
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main()
{
	string str = "";

	while (getline (cin, str ) ){
		int a,b,n;
		stringstream ss(str);

		ss >> a >> b >> n;
		if (a % b == 0){
			cout << '0' << endl;
			continue;
		} // end if

		while (a > b){
			a -= b;
		} // end if	

		int sum = 0;
		
		for (int i = 0; i < n; ++i){
			int c = (10*a)/b;
			int d = (10*a % b);
			a = d;
			sum += c;
		} // end for
		cout << sum << endl;

	} // end loop
		
	return 0;
}

Measured memory_bytes: 1220
import math
A,B,H,M = map(int,input().split())
Ad = H * 30 + M * 0.5
Bd = M * 6
difAB = abs(Ad - Bd)
if difAB >=180:
    difAB = 360-difAB
print(math.sqrt(A**2+B**2-2*A*B*math.cos(math.radians(difAB))))

Measured memory_bytes: 9508
import math
def main():
    n, d = map(int, input().split())
    sum = 0
    for i in range(n):
        x, y = map(int, input().split())
        dest = math.sqrt(x**2+y**2)
        if dest <= d:
            sum += 1
    print(sum)

if __name__ == '__main__':
    main()

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

using namespace std;

using llong = long long int;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000007;
const static int INF = 1000000000;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

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

    string S;
    cin >> S;

    int sum = 0;
    rep(i, (int)S.size()) sum += (int)(S[i] - '0');

    if (sum % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3704
from collections import defaultdict
n=int(input())
dd = defaultdict(int)
A=[int(i) for i in input().split()]
for i in A:
    dd[i]+=1
memo = [0]*(n+1)
for i in dd:
    memo[i]=(dd[i]*(dd[i]-1))//2
ans = sum(memo)
done = [-1]*(n+1)
for i in range(n):
  print(int(ans-memo[A[i]]+(memo[A[i]])*((dd[A[i]]-2)/dd[A[i]])))
        



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

typedef pair<int,int> P;

int trans(int x){
  return x/100 * 60 + x %100;
}

int main(){
  int n,p,q;

  while(cin >> n >> p >> q, n||p||q){
    p = trans(p); q = trans(q);
    int k,a,b;
    vector<P> v;
    for(int i=0;i<n;i++){
      cin >> k;
      for(int j=0;j<k;j++){
	cin >> a >> b;
	a = trans(a); b = trans(b);
	v.push_back(P(a,1));
	v.push_back(P(b,0));
      }
    }
    sort(v.begin(),v.end());

    int ans = 0,prv = p,num = 0;
    for(int i=0;i<(int)v.size();i++){
      if(v[i].first<p)continue;
      if(v[i].first>q)break;

      if(num == n){
	ans = max(ans,v[i-1].first - prv);
	prv = v[i].first;
      }

      if(v[i].second)num++;
      else num--; 
    }
    cout << max(ans,q-prv) << endl;
  }
}
      

Measured memory_bytes: 0
import collections

n = int(input())
s = [input() for i in range(n)]

# リストsに含まれる単語と出現回数の辞書を作成
# keyに要素　valueに出現回数 
a = collections.Counter(s)

# 出現回数の最大値を取得
max_a = max(a.values())

# value=max_a　なら　keys　に key（単語） を書き込む
# k / for k, v in a.items() / if v == max_a
keys = [k for k, v in a.items() if v == max_a]
keys.sort()

for word in keys:
    print(word)

Measured memory_bytes: 35568
#include <stdio.h>

int main(void) {
  int i;
  char s[4];
  int flag=0;


  scanf("%s",s );

  for ( i = 0; i < 3; i++) {
    if (s[i]=='a') {
      flag=flag+1;
    }
    if (s[i]=='b') {
      flag=flag+10;
    }
    if (s[i]=='c') {
      flag=flag+100;
    }
  }
 

  if (flag==111) {
    printf("Yes");
  }
  else{
    printf("No");
  }




  return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

namespace ALDS1_4_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var S = ReadInt();
            
            int q = int.Parse(Console.ReadLine());
            var T = ReadInt();

            int count = 0;
            for (int i = 0; i < q; i++)
            {
                if (BinatySearch(S, T[i], 0, n - 1)) count++;
            }


            Console.WriteLine(count);
            Console.ReadKey();
        }

        static bool BinatySearch(int[] sortedNums, int num, int left, int right)
        {
            if (left == right)
            {
                return sortedNums[left] == num ? true : false;
            }

            int mid = (left + right) / 2;
            if (sortedNums[mid] < num)
            {
                return BinatySearch(sortedNums, num, mid + 1, right);
            }
            else
            {
                return BinatySearch(sortedNums, num, left, mid);
            }

        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}



Measured memory_bytes: 31256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
//#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
//#define EXIST(s, e) ((s).find(e)!=(s).end())
//#define SORT(c) sort(begin(c),end(c))
//#define pb emplace_back
//#define MP make_pair
//#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int N,X;
    cin >> N >> X;
    int ans = 0;
    int min_v = INT_MAX;
    vector<int> m(N);
    rep(i,0,N){
        cin >> m[i];
        ans++;
        min_v = min(min_v, m[i]);
        X -= m[i];
    }

    ans += X / min_v;

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
function Main(input) {
    const args = input.split(' ');
	const a = parseInt(args[0], 10);
	const b = parseInt(args[1], 10);
    
    var res = Math.max(a+b,Math.max(a-b,a*b))

    console.log(res);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include<bits/stdc++.h>
using namespace std;
int a[105];
int main()
{
	int n;
	cin>>n;
	long long a[n],b=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		b=max(b,a[i]);
	}
	int m=(b+1)/2;
	int c=abs(m-a[0]),t=a[0];
	for(int i=1;i<n;i++)
	if(c>=abs(m-a[i]))
	{
		c=abs(m-a[i]);
		t=a[i];
	}
	cout<<b<<" "<<t;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    char a, b;
    cin >> a >> b;
    cout << (a == b ? 'H':'D') << endl;

    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
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;}

int main(){
  ll N,ans=0,cnt=0;
  cin>>N;
  
  RREP(i,N) ans+=N/i;
  RREP(i,N) if(N%i==0) cnt++;
  
  cout<<ans-cnt<<endl;
  return 0;
}

Measured memory_bytes: 3628
//be name khoda

#include <iostream>
#include <string>
using namespace std;

char F(char c,int n)
{
	n%='z'-'a'+1;
	while(n--)
	{
		if(c=='z')
			c='a';
		else
			c=c+1;
	}
	return c;
}

int main()
{
	int k,l;
	string s;
	cin>>s>>k;
	l=s.length();
	for(int i=0;i<l;i++)
		if('z'-s[i]+1<=k && s[i]!='a')
		{
			k-='z'-s[i]+1;
			s[i]='a';
		}
	s[l-1]=F(s[l-1],k);
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

ll N, K;
int A[200010];
ll num[200010];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> K;
    ll cnt = 0;
    for(int i = 1; i <= N; ++i){
        cin >> A[i];
        num[i] = -1;
    }
    int to = 1;
    while(true){
        if(num[to] != -1){
            ll d = cnt - num[to];
            K -= num[to];
            K %= d;
            K += num[to];
            break;
        }
        if(cnt > K) break;
        num[to] = cnt++;
        to = A[to];
    }

    for(int i = 1; i <= N; ++i){
        if(num[i] == K) cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 5984
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  long long int a,b,c,d,x,y;
  long long int mul[4];
  cin>>a>>b>>c>>d;
  mul[0]=b*d;
  mul[1]=a*c;
  mul[2]=a*d;
  mul[3]=b*c;
  sort(mul,mul+4);
  cout<<mul[3]<<"\n";
}


Measured memory_bytes: 3640
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(scanString(sc)))
}

func resolve(str string) int {
	// O(n^2)
	for i := 2; i < len(str); i += 2 {
		if isEvenStr(str[0 : len(str)-i]) {
			return len(str) - i
		}
	}
	return 0
}

func isEvenStr(str string) bool {
	l := len(str)
	if l%2 == 1 {
		return false
	}
	// O(n)
	for i := 0; i < l/2; i++ {
		if str[i] != str[l/2+i] {
			return false
		}
	}
	return true
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
// #define long long long 

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;


int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
   long double val = 2 * 3.141592653589793238;
   long int r;
   cin>>r;

   val *= r;

   cout<<fixed<<setprecision(15)<<val;
   return 0;
}

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

string s;
int x,y;

int main(){
	while(cin >> s){
		cin >> x >> y;
		vector<int> X,Y;
		int check = 0;
		int count = 0;
		for(int i=0;i<s.size();i++){
			if(s[i] == 'F' && i!=s.size()-1) count++;
			else{
				if(check==0){
					X.push_back(count);
					check = 1;
					count = 0;
				}else{
					Y.push_back(count);
					check = 0;
					count = 0;
				}
			}
		}
		if(s[s.size()-1] == 'F'){
			if(check==1){
				X[X.size()-1]++;
			}else{
				Y[Y.size()-1]++;
			}
		}
		bool judgex = false, judgey = false;
		bool px[X.size()+10][16010] = {{0}};
		if(!X.empty()){
			px[1][8000+X[0]] = true;
			for(int i=1;i<X.size();i++){
				for(int j=0;j<16001;j++){
					if(px[i][j]){
						px[i+1][j+X[i]] = true;
						px[i+1][j-X[i]] = true;
					}
				}
			}
		}else px[X.size()][8000] = true;
		if(px[X.size()][8000+x]) judgex = true;
		bool py[Y.size()+10][16010] = {{0}};
		if(!Y.empty()){
			py[1][8000+Y[0]] = true;
			py[1][8000-Y[0]] = true;
			for(int i=1;i<Y.size();i++){
				for(int j=0;j<16001;j++){
					if(py[i][j]){
						py[i+1][j+Y[i]] = true;
						py[i+1][j-Y[i]] = true;
					}
				}
			}
		}else py[Y.size()][8000] = true;
		if(py[Y.size()][8000+y]) judgey = true;
		if(judgex && judgey) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

#define MAXN 3000

// dp[i][j]:表がi枚、裏がj枚出ている確率
double dp[MAXN+1][MAXN+1];

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

  dp[0][0]=1.0;

  rep(i, n)rep(j, n){
    int c = i+j;
    if(c==n)continue;
    dp[i+1][j] += dp[i][j]*p[c];
    dp[i][j+1] += dp[i][j]*(1.0-p[c]);
  }

  double result = 0.0;
  rep(i, n+1){
    if(i<=n-i)continue;
    result += dp[i][n-i];
  }

  cout<<fixed<<setprecision(12)<<result<<endl;

  return 0;

  rep(i, n+1){
    rep(j, n+1)cout<<dp[i][j]<<"   ";
    cout<<endl;
  }
 
  return 0;
}

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

int f(int x) {
    return(x * x);
}

int main(void) {
    int d;
    while(cin >> d) {
        int width = d; int height = d;
        long long sum = 0;
        while(height <= 600 - d) {
            sum += width * f(height);
            height += d;
        }
        cout << sum << endl;
    }
    return(0);
}

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

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  if (n == 3) {
    if (a[0] ^ a[1] == a[2]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
    return 0;
  }
  map<int, int> c;
  for (int i = 0; i < n; ++i) {
    ++c[a[i]];
  }
  if (n % 3 != 0) {
    if (c[0] == n) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else if (c.size() == 3) {
    auto tmp = 0;
    for (auto it : c) {
      tmp ^= it.first;
      if (it.second != n / 3) {
        cout << "No" << endl;
        return 0;
      }
    }
    if (tmp != 0) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  } else if (c.size() == 1) {
    if (c[0] == n) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else if (c.size() != 2) {
    cout << "No" << endl;
  } else {
    if (c[0] == n / 3) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}



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

#define gc( ) std::getchar( )
#define pc( i ) std::putchar( i )
#define space ' '
#ifdef ONLINE_JUDGE
#define enter '\n'
#else
#define enter std::endl
#endif
#define RE cout << "Passing [" << __FUNCTION__ << "] on " << __LINE__ << enter
#define DEBUG(...) for( auto &i: __VA_ARGS__ ) cout << i << " "; cout << enter
using std::make_pair;

template < typename T >
inline T read( )
{
 T x = 0;
 char ch = gc( );
 bool f = 0;
 while( !std::isdigit( ch ) )
 {
  f = ( ch == '-' );
  ch = gc( );
 }
 while( std::isdigit( ch ) )
 {
  x = x * 10 + ( ch - '0' );
  ch = gc( );
 }
 return f ? -x : x;
}

template < typename T >
void print( T x )
{
 if( x < 0 )
 {
  x = -x;
  pc( '-' );
 }
 if( x < 10 )
 {
  pc( x + 48 );
  return;
 }
 print < T > ( x / 10 );
 pc( x % 10 + 48 );
 return ;
}

namespace Solution
{
#define IOS std::ios::sync_with_stdio( false ), std::cin.tie( 0 ), std::cout.tie( 0 )
#define Rep( i, j, k ) for( int i = j; i >= k; --i )
#define rdi( ) read < int > ( )
#define rdl( ) read < long long > ( )
#define pti( i ) print < int > ( i ), putchar( space )
#define ptl( i ) print < long long > ( i ), putchar( space )
#define For( i, j, k ) for( int i = j; i <= k; ++i )
 using std::cin;
 using std::cout;
 using std::endl;
 using std::vector;
 using std::map;
 using std::queue;
 using std::deque;
 using std::set;
 using std::pair;
 const int N = 104001, mod = 1e9 + 7;
 int n, m, x[ N ], y[ N ];
 long long ansx, ansy;
 void Fakemain( )
 {
  n = rdi( );
  m = rdi( );
  For( i, 1, n )
  {
   x[ i ] = ( rdi( ) % mod + mod ) % mod;
   ansx = ( ansx + 1LL * ( 2 * i - n - 1 ) * x[ i ] ) % mod; 
  }
  For( i, 1, m )
  {
   y[ i ] = ( rdi( ) % mod + mod ) % mod;
   ansy = ( ansy + 1LL * ( 2 * i - m - 1 ) * y[ i ] ) % mod; 
  }
  ptl( ansx * ansy % mod );
  return;
 }

} // namespace Solution

int main( int argc, char* argv[] )
{
 Solution::Fakemain( );
 return 0;
}

Measured memory_bytes: 4388
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication59
{
    class Program
    {
        static void Main()
        {
            while (true)
            {
                int a = int.Parse(Console.ReadLine());
                if (a == 0) break;
                int x, y; x = y = 0;
                for (int b = 0; b < a; b++)
                {
                    int[] c = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    if (c[0] > c[1])
                    {
                        x += c[0] + c[1];
                    }
                    else if (c[1] > c[0])
                    {
                        y += c[0] + c[1];
                    }
                    else
                    {
                        x += c[0];
                        y += c[1];
                    }
                }
                Console.WriteLine("{0} {1}", x, y);
            }
        }
    }
}

Measured memory_bytes: 9624
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    int N;
    cin >> N;
    vint B(N - 1);
    rep(i, N - 1) cin >> B[i];
    ll ans = 0;
    //ans += B[0];
    rep(i, N - 2) {
        ans += min(B[i], B[i + 1]);
    }
    ans += B[0];
    ans += B[N - 2];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a,b,x,y;
		a = sc.nextInt();
		b = sc.nextInt();
		x=a*b;
		y=a*2+b*2;
		System.out.println(x+" "+y);
	}
}

Measured memory_bytes: 26192
#include <iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
using namespace std;

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

	map<string, int> mp;
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		mp[s]++ ;
	}
	int ans = mp.size();
	cout << ans << endl;

}

Measured memory_bytes: 19228
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
int a[55],b[55],c[55],d[55];
signed main(){
	int n,m;cin>>n>>m;
	rep(i,n)cin>>a[i]>>b[i];
	rep(i,m)cin>>c[i]>>d[i];
	
	rep(i,n){
		int dis=1145141919,num=-1;
		rep(j,m){
			int di=abs(a[i]-c[j])+abs(b[i]-d[j]);
			if(dis>di){
				dis=di;
				num=j;
				}
			}
			cout<<num+1<<endl;
		}
	}


Measured memory_bytes: 256
a,b,c,X,Y=map(int,input().split())

s=min(X,Y)
t=max(X,Y)

ans1=2*c*s+a*(X-s)+b*(Y-s)
ans2=a*X+b*Y
ans3=2*c*t

print(min(ans1,ans2,ans3))

  

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define per(i,n) for(int i = (n)-1; i >= 0; --i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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


Measured memory_bytes: 3636
from collections import deque
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readlines

def remove(p):
    if len(s) < 2:
        return
    a = s.pop()
    b = s.pop()
    s.append(b)
    s.append(a)

    x1, y1 = a; x0, y0 = b ; x,y = p
    x1 -= x0;y1 -= y0; x -= x0;y -= y0

    if x1 * y < x * y1:
        s.pop()
        remove(p)

    return

lines = input()
#with open("./chapter16/input.txt") as f:
    #lines = f.readlines()

n = int(lines[0])

v = []
for i in range(1, n+1):
    v.append(list(map(int, lines[i].split())))

v = sorted(v, key = lambda x: (x[1], x[0]))
s = deque()
s.append(v[0]);s.append(v[1])


#right side
for k in v[2:]:
    remove(k)
    s.append(k)

v.reverse()
s.append(v[1])

#left side
for k in v[2:]:
    remove(k)
    s.append(k)

s.pop()
le = len(s)
print(le)
for i in range(le):
    print(*s.popleft())






Measured memory_bytes: 39108
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))

pos = [0 for i in range(n+1)]
pos[0] = 1 - a[0]
for i in range(n):
    pos[i+1] = pos[i] * 2 - a[i+1]

for i in range(n+1):
    if pos[i] < 0:
        print(-1)
        exit()

cnt = a[-1]
memo = 0
for i in range(n-1, -1, -1):
    cnt += min(pos[i], memo + a[i+1]) + a[i]
    memo = min(pos[i], memo + a[i+1])


print(cnt)

Measured memory_bytes: 699984
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iostream>

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n)	 for(int i = 0; i < (n); i++)
#define all(a)		 begin(a), end(a)

typedef long long int		   ll;
typedef long long unsigned int llu;

void solve(ll r, ll g, ll b) {
	if((r * 100 + g * 10 + b) % 4 == 0) printf("YES");
	else printf("NO");
}

int main() {
	ll r;
	ll g;
	ll b;
	scanf("%lld", &r);
	scanf("%lld", &g);
	scanf("%lld", &b);
	solve(r, g, b);
	return 0;
}


Measured memory_bytes: 384
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
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<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
int N;
ll A,B,h[100000];
bool can(ll t){
	ll left = 0;
	rep(i,N){
		ll x = h[i]-t*B;
		if(x<=0) continue;
		left += (x-1)/(A-B)+1;
	}
	return left<=t;
}
int main(){
	cin>>N>>A>>B;
	rep(i,N) cin>>h[i];
	ll ub = 1e9, lb = 0;
	while(ub-lb>1){
		ll m = (ub+lb)/2;
		if(can(m)) ub=m;
		else lb=m;
	}
	cout<<ub<<endl;
}


Measured memory_bytes: 1024
N,A,B,C,D = map(int,input().split())
S = str(input())
S = list(S)
Flag = False
if D > C:
  for i in range(B,D):
    if S[i] == "#" and Flag == True:
      print("No")
      exit()
    elif S[i] == "#":
      Flag = True
    else:
      Flag = False

  Flag = False
  for i in range(A,C):
    if S[i] == "#" and Flag == True:
      print("No")
      exit()
    elif S[i] == "#":
      Flag = True
    else:
      Flag = False
  print("Yes")
else:
  P = False
  for i in range(B-2,D-1):
    if S[i] == "." and S[i+1] == "." and S[i+2] == ".":
      P = True
  if not P:
    #print("unko")
    print("No")
    exit()
  #Flag = False
  for i in range(B,D):
    if S[i] == "#" and Flag == True:
      print("No")
      exit()
    elif S[i] == "#":
      Flag = True
    else:
      Flag = False

  Flag = False
  for i in range(A,C):
    if S[i] == "#" and Flag == True:
      print("No")
      exit()
    elif S[i] == "#":
      Flag = True
    else:
      Flag = False
  print("Yes")  
    

Measured memory_bytes: 10732
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		//		new Main().solveB();
		new Main().solveC();
		//		new Main().solveC2();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			if (numN % 2 == 0) {
				System.out.println(numN);
			} else {
				System.out.println(numN * 2);
			}

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();
			int[] wk = new int[numN];

			for (int i = 0; i < wk.length; i++) {
				wk[i] = scanner.nextInt();
			}
			Arrays.sort(wk);

			System.out.println(wk[wk.length - 1] - wk[0]);

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private int getCry(int b, int currentI, int maxI, int[] wk) {
		if (currentI == maxI) {
			return 0;
		}

		return getCry(b, currentI + 1, maxI, wk) + Math.abs(wk[currentI] - (b + currentI + 1));
	}

	private void solveC2() {
		Scanner sc = null;
		int numN = 0;

		try {
			sc = new Scanner(System.in);
			numN = sc.nextInt();
			int[] wk = new int[numN];
			for (int i = 0; i < numN; i++) {
				wk[i] = sc.nextInt() - (i + 1);
			}
			Arrays.sort(wk);
			int med = numN % 2 == 0 ? numN / 2 - 1 : numN / 2;
			int b = wk[med];
			long ans = 0;
			for (int a : wk) {
				ans += Math.abs(a - b);
			}

			System.out.println(ans);
		} finally {
			if (sc != null) {
				sc.close();
			}
		}
	}

	/**
	 * ⅰ)abs(xi-a)の総和(aとの距離の総和)を最小にするのは中央値で、
	 * ⅱ)(xi-a)^2の総和を最小にするのは平均値
	 */
	private void solveC() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			int[] wk = new int[numN];
			for (int i = 0; i < numN; i++) {
				wk[i] = scanner.nextInt() - (i + 1);
			}
			Arrays.sort(wk);

			//			int b = 0;
			//			if (numN % 2 == 0) {
			//				b = wk[(numN / 2) - 1];
			//			} else {
			//				b = wk[numN / 2];
			//			}

			int med = numN % 2 == 0 ? numN / 2 - 1 : numN / 2;
			int b = wk[med];

			long res = 0;

			for (int a : wk) {
				res += Math.abs(a - b);
			}
			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 64584
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
	int n, p[15];
	cin >> n;
	for (int i = 0; i < n; i++) cin >> p[i];
	sort(p, p + n);
	int sum = 0;
	for (int i = 0; i < n - 1; i++) {
		sum += p[i];
	}
	sum += p[n - 1] / 2;
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
import static java.util.Arrays.deepToString;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc = new Scanner(System.in);
	public void run() {
		for (;sc.hasNext();) {
			int n = sc.nextInt();
			if (n == 0) break;
			int[] count = new int[7];
			while (n-->0) {
				int x = sc.nextInt();
				if (x >= 60) x = 60;
				count[x/10]++;
			}
			for (int x : count) System.out.println(x);
		}
	}
}

Measured memory_bytes: 209800
#include<stdio.h>
int mpow(long long a,int n,int m){return n?(mpow((a*a)%m,n/2,m)*(n%2?a:1))%m:1;}
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  printf("%d\n",mpow((long long)a,b,1000000007));
  return 0;
}

Measured memory_bytes: 596
#c
#ignore t,s,z
a = [int(i) for i in input().split()]
ans = a[1]
b = [a[0],a[3],a[4]] #select

for i,v in enumerate(b):
    if v>2:
        if v%2==1: #odd
            ans += v-1
            b[i] = 1
        else:
            ans += v-2
            b[i] = 2

s = sum(b)
if s==6:
    ans += 6
elif s==5:
    ans += 4
elif s==4:
    if min(b)==0:
        ans += 4
    else:
        ans += 3
elif s==3:
    if max(b)==2:
        ans += 2
    else:
        ans += 3
elif s==2:
    if max(b)==2:
        ans += 2

print(ans)
        


Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

i64 modpow(i64 a, i64 p = MOD - 2)
{
	if (p == 0) return 1;
	i64 tmp = modpow(a, p / 2);
	tmp = tmp * tmp % MOD;
	if (p % 2 == 1) tmp = tmp * a % MOD;
	return tmp;
}

int H, W, A, B;
i64 fact[202020], frev[202020];

i64 C(int p, int q)
{
	if (q < 0 || p < q) return 0;
	return fact[p] * frev[q] % MOD * frev[p - q] % MOD;
}

i64 pat(int p, int q) { return C(p + q - 2, q - 1); }

int main()
{
	scanf("%d%d%d%d", &H, &W, &A, &B);

	fact[0] = frev[0] = 1;
	for (int i = 1; i <= 200000; ++i) {
		fact[i] = (fact[i - 1] * i) % MOD;
		frev[i] = modpow(fact[i]);
	}

	i64 ret = 0;
	for (int i = 0; i < H - A; ++i) {
		ADD(ret, pat(i + 1, B) * pat(H - i, W - B) % MOD);
	}
	printf("%lld\n", ret);

	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    if (N < 105)
    {
        cout << 0 << endl;
    }
    else if (N < 135)
    {
        cout << 1 << endl;
    }
    else if (N < 165)
    {
        cout << 2 << endl;
    }
    else if (N < 189)
    {
        cout << 3 << endl;
    }
    else if (N < 195)
    {
        cout << 4 << endl;
    }
    else
    {
        cout << 5 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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

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

ll n;

ll modinv(ll a) {
    ll m=mod;
    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;
}


ll comb(int a){
  ll ans=1;
  for(int i=1;i<=a;i++){
    ans*=(n+1-i);
    ans%=mod;
    ans*=modinv(i);
    ans%=mod;
  }
  return ans;
}

ll calc(int p){
  ll c=2;
  ll ans=1;
  while(p>=1){
    if(p%2==1) ans*=c;
    c*=c;
    c%=mod;
    ans%=mod;
    p>>=1;
  }
  return ans-1;
}

int main(){
  int i,j;
  cin>>n;
  int a,b;
  cin>>a>>b;
  ll ans=(mod+mod+calc(n)-comb(a)-comb(b))%mod;
  cout<<ans<<endl;
  //cout<<calc(1)<<calc(2)<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)



int main(){
    int cur[3],prev[3];
    rep(i,3)cin>>cur[i];

    auto ok = [](int v[3]){
        rep(i,3)if(v[i]%2)return false;
        return true;
    };
    
    int ans = 0;
    while(ok(cur)){
        prev[0] = (cur[1]+cur[2])/2;
        prev[1] = (cur[2]+cur[0])/2;
        prev[2] = (cur[0]+cur[1])/2;
        rep(i,3)cur[i] = prev[i];
        ans++;
        if(ans>100){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
s = []
for _ in range(n):
    s.append(ns())

m = ni()
t = []
for _ in range(m):
    t.append(ns())

ns = set(s)
ns = list(ns)
ts = [0]*len(ns)
for i in range(len(ns)):
    for j in s:
        if ns[i] == j:
            ts[i] += 1
    for j in t:
        if ns[i] == j:
            ts[i] -= 1
ts.sort(reverse=True)
if ts[0] > 0:
    print(ts[0])
else:
    print(0)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<int, ll> pli;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
const ll MAXN = 100005;

int n, a[MAXN], x;
ll ans;
/********** Good Luck :) **********/
int main()
{
    TIME(main);
    IOS();

    cin >> n >> x;
    REP (i, n) {
        cin >> a[i];
        if (i && a[i] + a[i-1] > x) {
            int mn = min(a[i] + a[i-1] - x, a[i]);
            a[i] -= mn;
            ans += mn;
            mn = min(a[i] + a[i-1] - x, a[i - 1]);
            a[i-1] -= mn;
            ans += mn;
        }
    }

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


Measured memory_bytes: 640
N, M, X, Y = map(int, input().split())
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
x.append(X)
y.append(Y)
x.sort()
y.sort()
if x[N] < y[0]:
    print("No War")
else:
    print("War")

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        String[] wt={"Sunny", "Cloudy", "Rainy"};
        String s=in.nextLine();
        if(s.contains(wt[0])){
            System.out.println(wt[1]);
        }else if(s.contains(wt[1])){
            System.out.println(wt[2]);
        }else{
            System.out.println(wt[0]);
        }
    }
}

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

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;
    static long N;
    static long M;
    static void input()
    {
        cin = new Scanner();
        N = cin.nextLong();
        M = cin.nextLong();
    }
    static void solve()
    {
        input();
        if(N == 1 && M == 1)
        {
            WriteLine(1);
            return;
        }
        WriteLine(Abs(M - 2) * Abs(N - 2));
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }
        
        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }

        public double[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	int a,b;
	string aa,bb;
	int i;
	
	
	cin>>n;
	a=0;	b=0;
	for(i=0;i<n;i++){
		cin>>aa>>bb;
		if(aa>bb)	a+=3;
		else if(aa<bb)	b+=3;
		else			a++,b++;
	}
	cout<<a<<" "<<b<<endl;
	return 0;
}



Measured memory_bytes: 3188