akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;




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

	int n;
	cin >> n;

	if (n >= 30) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const ll INF = 1001001001;
const ll MOD = 1e9 + 7;

int main(){
  int n;
  cin >> n;
  int a[100000];
  bool flag = false;//負数が奇数個
  ll ans = 0;
  int mi = INF;
  rep(i, n){
    int tmp;
    cin >> tmp;
    if(tmp < 0){
      flag = !flag;
    }
    mi = min(mi, abs(tmp));
    ans += abs(tmp);
  }
  if(flag){
    ans -= 2*mi;
  }
  cout << ans <<endl;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Pb push_back
using namespace std;
typedef long long ll;
const int MAXN = 1e3 + 7, Mod = 1e9 + 7;
inline int Mop ( int na ) { return na >= Mod ? na - Mod : na; }

inline int R()
{
    int rt = 0; char ch = getchar(); bool isn = false;
    for ( ; ch < '0' || ch > '9'; ch = getchar() ) isn = ch == '-' ? true : isn;
    for ( ; ch >= '0' && ch <= '9'; ch = getchar() ) rt = rt * 10 + ch - '0';
    return isn ? -rt : rt;
}

inline ll Pow ( ll bs, int t )
{
	ll rt = 1;
	for ( ; t; t >>= 1, bs = bs * bs % Mod )
		if ( t & 1 )
			rt = rt * bs % Mod;
	return rt;
}

ll c[MAXN][MAXN], dp[MAXN][MAXN];
ll g[MAXN][MAXN];
ll Get ( int x, int y )
{
	if ( g[x][y] != -1 )
		return g[x][y];
	ll rt = 1;
	for ( int i = x; i; i -= y )
		rt = rt * c[i - 1][y - 1] % Mod;
	return g[x][y] = rt;
}

int main()
{
	int n = R(), a = R(), b = R(), cl = R(), d = R();
	memset ( g, -1, sizeof g );
	for ( int i = 0; i <= n; ++i )
		c[i][0] = 1;
	for ( int i = 1; i <= n; ++i )
		for ( int j = 1; j <= i; ++j )
			c[i][j] = Mop ( c[i - 1][j - 1] + c[i - 1][j] );
	dp[a - 1][0] = 1;
	for ( int i = a; i <= b; ++i )
		for ( int j = 0; j <= n; ++j )
		{
			dp[i][j] = dp[i - 1][j];
			for ( int k = cl; k <= d; ++k )
			{
				if ( j - k * i < 0 )
					break;
				dp[i][j] = Mop ( dp[i][j] + dp[i - 1][j - k * i] * c[j][k * i] % Mod * Get ( i * k, i ) % Mod );
			}
		}
	printf ( "%lld\n", dp[b][n] );
	return 0;
}

Measured memory_bytes: 23936
#include<stdio.h>
int main(){
	int n,sum=0,i;
	int a[50],b[50],c[50];
	scanf("%d",&n);
	for(i=1;i<=n;i++) scanf("%d",&a[i]);
	for(i=1;i<=n;i++) scanf("%d",&b[i]);
	for(i=1;i<=n-1;i++) scanf("%d",&c[i]);
	c[i]=0;
	sum=b[a[1]];
	for(i=2;i<=n;i++){
		sum+=b[a[i]];
		if(a[i]==a[i-1]+1)
		    sum+=c[a[i-1]];
	}
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    vector<vector<int>> ans(h, vector<int>(w, 0));
    vector<bool> cont(h, false);
    for (int i = 0; i < h; ++i) {
        cin >> s[i];
        for (int j = 0; j < w; ++j) {
            if (s[i][j] == '#') {
                cont[i] = true;
                break;
            }
        }
    }
    int ti = 0;
    int di;
    int cc = 1;
    int cr;
    while (ti < h) {
        if (!cont[ti] & ti != 0) {
            ++ti;
            continue;
        }
        if (ti == 0 && !cont[ti]) {
            di = 1;
            while (!cont[di]) {
                ++di;
            }
            cr = di;
            ++di;
        } else {
            di = ti + 1;
            cr = ti;
        }
        while (di < h && !cont[di]) {
            ++di;
        }
        int li = 0;
        int ri;
        while (li < w) {
            if (s[cr][li] != '#' & li != 0) {
                ++li;
                continue;
            }
            if (li == 0 && s[cr][li] != '#') {
                ri = 1;
                while (s[cr][ri] != '#') {
                    ++ri;
                }
                ++ri;
            } else {
                ri = li + 1;
            }
            while (ri < w && s[cr][ri] != '#') {
                ++ri;
            }
            for (int i = ti; i < di; ++i) {
                for (int j = li; j < ri; ++j) {
                    ans[i][j] = cc;
                }
            }
            ++cc;
            li = ri;
        }
        ti = di;
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cout << ans[i][j] << " ";
        }
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 1280
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Data.Function (on)

getInts :: IO [Int]
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

div'::Int->Int->Double
div' = (/) `on` fromIntegral

main = do
  [n,k] <- getInts
  an <- getInts
  let minCount = length $ filter (== 1) an
  print $ ceiling $ div' (n-minCount) (k-1)

Measured memory_bytes: 2172
s = input()
for _ in range(int(input())):
    code=input().split()
    if code[0]=='print'  :
        print(s[int(code[1]):int(code[2])+1])
    elif code[0]=='reverse':
        s = s[:int(code[1])] + s[int(code[1]):int(code[2])+1][::-1] + s[int(code[2])+1:]
    elif code[0]=='replace':
        s = s[:int(code[1])] + code[3] + s[int(code[2])+1:]


Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int x;
  int ans;
  rep(i,5){
    cin>>x;
    if(x==0){
      ans=i+1;
    }
  }
  cout<<ans<<'\n';
  return(0);
}


Measured memory_bytes: 3624
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;

Int GCD(Int a, Int b){
if(b==0) return a;
if(a < b) return GCD(b, a);
unsigned r;
while ((r=a%b)) {
a = b;
b = r;
}
return b;
}

int main() {
    int A,B,K;
    vi divisions;
    cin >> A >> B >> K;

    REP(i,1,101){
        if(A%i == 0 && B%i ==0){
            divisions.push_back(i);
        }
    }

    cout << divisions[divisions.size() - K];
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define ull unsigned long long int  // ranges from (0 - twice of long long int)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define mod 1000000007LL
#define llpair pair<ll,ll>
#define INF 1000000000000000000ll
#define np next_permutation
//ALWAYS USE ll DATA TYPE FOR INTEGER(FASTER THAN INTEGER AS WELL AS SOMETIMES WITHOUT USE LONG UR ANSWER WILL NOT ACCEPTED) && DOUBLE FOR DECIMAL VALUE
template<typename T> // for removing front element from the vector
void pop_front(std::vector<T> &v)
{
    if (v.size() > 0) {
        v.erase(v.begin());
    }
}
template<typename R> // for removing back element from the vector or can directly
void pop_back(std::vector<R> &v) // use vec.pop_back() function...
{
    if (v.size() > 0) {
        v.erase(v.begin()+v.size()-1);
    }
}

bool isprime(ll n)  //IN  O(sqrt(n))
{
    if(n<=1) return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;

    return true;
}

vector<ll> factors(ll n){    //IN  O(sqrt(n))

    vll v;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            v.pb(i);
            if((n/i)!=i)
            v.pb(n/i);
        }
    }
    return v;
}

ll power(ll a, ll n)  // using Binary Exponential in TC O(logn)
{                     // Self Written By </ME> :)
    ll res=1;
    while(1)
    {
        if(n%2){
            res=res*a; n--;
        }
        if(n==0) break;
        a=a*a; n/=2;
    }
    return res;
}


int main() {

    fio;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n; cin>>n;
        ll arr[n]; rep(i,0,n) cin>>arr[i];
        int flag=1;
        rep(i,0,n)
        {
            if(arr[i]%2==0)
            {
                if(arr[i]%3!=0 && arr[i]%5!=0)
                {
                    flag=0;
                    break;
                }

            }
        }

        if(flag==0)
            cout<<"DENIED"<<"\n";
        else
            cout<<"APPROVED"<<"\n";
    }
      
    return 0;
}


Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    ll n;
    cin >> n;

    ll best = INF;
    ll now = 1;
    ll rest = n;

    for(ll i = 2; i * i <= n; i++){

        if(n % i == 0){
            best = min(best, i + n / i - 2);
        }

    }

    if(best == INF){
        best = n - 1;
    }

    cout << best << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

int f(int x){
	int l = 0;
	while(x){
		x /= 10;
		l++;
	}
	return l % 2;
}

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

	int n;
	cin >> n;
	int res;
	for(int i = 1; i <= n; i++)
		res += f(i);
	cout << res;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
s = [a[0]]
for i in range(1, n):
    s.append(s[i-1]+a[i])
ans1, ans2 = 0, 0
for i in range(n):
    if s[i]*((-1)**i) <= 0:
        ans1 += abs(s[i]-(-1)**i)
        s[i] = (-1)**i
    if i+1 <= n-1:
        s[i+1] = s[i]+a[i+1]
s = [a[0]]
for i in range(1, n):
    s.append(s[i-1]+a[i])
for i in range(n):
    if s[i]*((-1)**(i+1)) <= 0:
        ans2 += abs(s[i]-(-1)**(i+1))
        s[i] = (-1)**(i+1)
    if i+1 <= n-1:
        s[i+1] = s[i]+a[i+1]
print(min(ans1, ans2))

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

int main()
{
    int n;
    int a[11];
    cin>>n;
    while(n--)
    {
        int p=0,q=0;
        int flag=1;
        for(int i=0; i<10; i++)
        {
            cin>>a[i];
        }
        for(int i=0; i<10; i++)
        {
            if(a[i]<p&&a[i]<q)
            {
                flag=0;
                break;
            }
            else if(a[i]>p&&a[i]<q)
            {
                p=a[i];
                continue;
            }
            else if(a[i]<p&&a[i]>q)
            {
                q=a[i];
                continue;
            }
            else
            {
                if(p>q)
                    p=a[i];
                if(p<q)
                    q=a[i];
                if(p==q)
                    p=a[i];
            }
        }
        if(flag==0)
            cout<<"NO"<<endl;
        else
            cout<<"YES"<<endl;
    }
    return 0;
}


Measured memory_bytes: 2976
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
const ll mod=1e9+7;


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

    ll n,k;
    cin>>n>>k;
    n++;
    ll ans=0;
    for(ll i=k;i<=n;i++){
        //ans=(ans+ncr(n,i,mod))%mod;
        ans=(ans+(n-i+1)+(n-i)*(i-1))%mod;
    }
    cout<<ans;


    return 0;
}

Measured memory_bytes: 3648
N, M = map(int, input().split())


class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード

    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断

    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]


V = []
for i in range(M):
    V.append(tuple(map(int, input().split())))

uf = UnionFind(N)

ans = []
c = N*(N-1)//2
for A, B in V[::-1]:
    ans.append(c)
    if not uf.isSameGroup(A, B):
        c -= uf.Count(A)*uf.Count(B)
        uf.Unite(A, B)

print(*ans[::-1], sep='\n')


Measured memory_bytes: 25484
#include <iostream>
#include <algorithm>

const int MAX = 200005;

int D[MAX][2];

int main()
{
    std::ios_base::sync_with_stdio(0);
    std::string s;
    std::cin >> s;
    D[0][0] = 1;
    D[0][1] = 0;
    if (s.length() > 1)
    {
        D[1][0] = s[0]==s[1] ? 0 : 2;
        D[1][1] = 1;
    }
    for (int i=2;i<s.length();++i)
    {
        if (s[i]==s[i-1]) D[i][0] = D[i-1][1] + 1;
        else D[i][0] = std::max(D[i-1][0], D[i-1][1]) + 1;
        if (i>2 && s[i]==s[i-2] && s[i-1]==s[i-3]) D[i][1] = D[i-2][0] + 1;
        else D[i][1] = std::max(D[i-2][0], D[i-2][1]) + 1;
    }
    std::cout << std::max(D[s.length()-1][0], D[s.length()-1][1]);

    return 0;
}

Measured memory_bytes: 2196
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long x;
	long long i = 100;
	cin >> x;
	long long ans = 0;
	while(i<x) {
		++ans;
		i = i + (long long)(i*(1.0/100));
	}
	cout << ans;
	return 0;
}



Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <vector>
 
#define REP(i,n) for(int i=0;i<(n);i++)
 
using namespace std;
 
struct av{int a,v;};
 
bool operator<(const av &dat1, const av &dat2)
{
    if(dat1.v==dat2.v)
        return dat1.a>dat2.a;
    return dat1.v<dat2.v;
}
 
 
int main(void)
{
    //read input
    int n, q;
    cin >> n >> q;
    vector<int> in_a(q, 0);
    vector<int> in_v(q, 0);
    vector<av> out(q);
    REP(i,q){
        cin >> in_a[i] >> in_v[i];
    }
    //calc
    int a_max = *max_element(in_a.begin(), in_a.end());
    int a_min = *min_element(in_a.begin(), in_a.end());
    vector<av> avlst(a_max+1);
    REP(i,a_max+1){
        avlst[i].a = 0;
        avlst[i].v = 0;
    }
    //for each av
    int a = in_a[0];
    avlst[a].a = a;
    avlst[a].v = (in_v[0]>0) ? in_v[0] : 0;
    out[0] = avlst[a];
    for(int i=1;i<q;i++){
        //sum
        a = in_a[i];
        avlst[a].a = a;
        avlst[a].v += in_v[i];
        if(avlst[a].v<0) avlst[a].v = 0;
        //find max
        av av_max;
        if(in_v[i]>0){
            av_max = (out[i-1]<avlst[a]) ? avlst[a] : out[i-1];
        }
        else if(out[i-1].a!=a){
            av_max = out[i-1];
        }
        else{
            av_max.a = a_max+1;
            av_max.v = -1;
            for(int j=a_min;j<=a_max;j++){
                if(!avlst[j].a) continue;
                if(av_max<avlst[j]) av_max = avlst[j];
            }
        }
        out[i] = av_max;
   }
    //write output
    REP(i,q){
        cout << out[i].a << " " << out[i].v << endl;
    }
    return 0;
}

Measured memory_bytes: 12180
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N, sum = 0;
  
  cin >> N;	//N組の団体
  
  for (int i = 0; i < N ; i++) {
    int li,ri;	//liからriまで
    
    cin >> li >> ri;
    
    sum += ri - li + 1;
  }
  
  cout << sum << endl;

}

Measured memory_bytes: 256
n,m,k = gets.to_s.split.map{ |v| v.to_i }
a = gets.to_s.split.map{ |v| v.to_i }
b = gets.to_s.split.map{ |v| v.to_i }

csa = a.each_with_object([0]) { |v, h| h << h[-1] + v }
csb = b.each_with_object([0]) { |v, h| h << h[-1] + v }

ans = 0
# aを読まない選択肢
0.upto(n) do |i|
  next if csa[i] > k
  r = k - csa[i] # 残っている時間
  j = csb.bsearch_index {|v| r < v } || m + 1
  ans = i + j - 1 if ans < i + j - 1
end
puts ans


Measured memory_bytes: 45240
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        char c =s.next().charAt(0);
        if(c=='T') System.out.println("A");
        else if(c=='A') System.out.println('T');
        else if(c=='G') System.out.println('C');
        else System.out.println("G");

    }




}


class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

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

int main(){
  int N;
  cin >> N;
  vector<long long> L(N+1);
  L.at(0)=2;
  L.at(1)=1;
  if(N>=2){
    for(int i=2;i<=N;i++){
      L.at(i)=L.at(i-1)+L.at(i-2);
    }
  }
  cout << L.at(N) << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int K = scan.nextInt();
        int R = scan.nextInt();
        int S = scan.nextInt();
        int P = scan.nextInt();
        String T = scan.next();
        char[] data = T.toCharArray();
        int[][] dp = new int[N+1][3];
        boolean[][] check = new boolean[N+1][3];
        for (int i = 0; i < N+1; i++) {
            Arrays.fill(dp[i], Integer.MAX_VALUE);
        }
        dp[0][0] = 0;
        dp[0][1] = 0;
        dp[0][2] = 0;
        for (int i = 1; i <= K; i++) {
            int win = win(data[i-1]);
            int point = point(data[i-1], R, S, P);
            for (int j = 0; j < 3; j++) {
                dp[i][j] = Math.max(dp[i-1][0],Math.max(dp[i-1][1],dp[i-1][2]));
                if (win == j) {
                    dp[i][j] += point;
                    check[i][j] = true;
                }
            }
        }
        for (int i = K+1; i <= N; i++) {
            int win = win(data[i-1]);
            int last_K = win(data[i-1-K]);
            int point = point(data[i-1], R, S, P);
            for (int j = 0; j < 3; j++) {
                dp[i][j] = Math.max(dp[i-1][0],Math.max(dp[i-1][1],dp[i-1][2]));
                if (win == j) {
                    if (win != last_K) {
                        dp[i][j] += point;
                        check[i][j] = true;
                        continue;
                    }
                    if (!check[i-K][j]) {
                        dp[i][j] += point;
                        check[i][j] = true;
                    }
                }
            }
        }
        System.out.println(Math.max(dp[N][0],Math.max(dp[N][1],dp[N][2])));
    }
    private int point(char x, int R, int S, int P) {
        if (x == 'r') {
            return P;
        }
        if (x == 's') {
            return R;
        }
        return S;
    }
    private int win(char x) {
        if (x == 'r') {
            return PAPER;
        }
        if (x == 's') {
            return ROCK;
        }
        return SCISSORS;
    }
    private final static int PAPER = 0;
    private final static int ROCK = 1;
    private final static int SCISSORS = 2;
}


Measured memory_bytes: 32660
#include<iostream>
#include<utility>
#include<queue>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
	int n;
	cin >> n;
	int sum = 0;
	int min10 = 100000;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		sum += x;
		if (x % 10 != 0) {
			min10 = min(min10, x);
		}
	}
	if (sum % 10 != 0) {
		cout << sum << endl;
	}
	else if (min10 == 100000) {
		cout << 0 << endl;
	}
	else {
		cout << sum - min10 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    long a, b;
    scan(a, b);
    writeln(a + (b / 2));
}


Measured memory_bytes: 256
// #include {{{
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <random>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>
// }}}

using namespace std;

// macros {{{
template<typename T, size_t N>
constexpr size_t NELEMS(T (&)[N]) { return N; }

template<typename InputIt>
void PRINT_RANGE(InputIt first, InputIt last)
{
    for(; first != last; ++first)
        cout << *first << (first==last ? "" : " ");
    cout << "\n";
}

template<typename T>
void PRINT_MATRIX(T mat, size_t nr, size_t nc)
{
    for(size_t r = 0; r < nr; ++r) {
        for(size_t c = 0; c < nc; ++c) {
            cout << mat[r][c] << (c==nc-1 ? "" : " ");
        }
        cout << "\n";
    }
}

#define FOR(i, start, end) for(int i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)
// }}}

// types {{{
using ll  = long long;
using ull = unsigned long long;
// }}}

int N;
//int A[100000];

int BIN[100001] = {};

void solve()
{
    int k = count_if(begin(BIN), end(BIN), [](int c) { return c>0; });
    int n_even = count_if(begin(BIN), end(BIN), [](int c){ return c>0 && c%2==0; });

    int cnt = n_even%2 ? k-1 : k;

    cout << cnt << "\n";
}

int main()
{
    cin >> N;
    REP(i, N) {
        //cin >> A[i];
        int a;
        cin >> a;
        ++BIN[a];
    }

    solve();

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(a, max(b, c))
#define MIN(x, y, z) min(a, min(b, c))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll A, B, C;
  cin >> A >> B >> C;
  if (A == B) {
    COUT(C);
    return 0;
  }
  if (B == C) {
    COUT(A);
    return 0;
  }
  if (A == C) {
    COUT(B);
    return 0;
  }
  return 0;
}

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

ll N;
vector<ll> a;
set<ll> pool;

int main() {
    cin >> N;
    ll res = 0;
    for (int i = 0; i < N; i++) {
        ll temp; scanf("%Ld", &temp);
        if (temp > 100000) {
            res++;
            continue;
        }
        a.push_back(temp);
        pool.insert(temp);
    }
    for (auto iter = pool.begin(); iter != pool.end(); ++iter) {
        ll num = *iter;
        int countnum = count(a.begin(), a.end(), num);
        if (num <= countnum) res += countnum - num;
        else res += countnum;
    }
    cout << res << endl;
}

Measured memory_bytes: 1400
//Program.cpp
//Author : Aaryan Srivastava 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#define pb push_back
#define popb pop_back
#define ull unsigned long long  
#define beg begin
#define mp make_pair
#define pii pair<int, int>
#define piii pair<pii,int>
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define ff first
#define ss second 
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
using ll = long long;
#define int ll
const int N = 2*1e5 +5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace std;

#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) coutz
#define mycerr if(false) cerr
#define AaryanS 0 
#endif


void solve()
{
    int n,ans= inf,cnt = 0;
    cin >> n ;
    string s;
     cin >> s ;
    int f = 0 ;
    vector<int> a(n,0) ;
    rep(i,n) a[i] = (s[i] == '.');
    repD(i,n-2,0)
        a[i] += a[i+1] ;
    rep(i,n){
        ans = min(ans,cnt+a[i]) ;
        if(s[i] == '#')
            cnt++ ;

    }
    cout << min(cnt,ans) ;
}   

     
int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case " << t << ":\n" ;
        solve();
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define x first
#define y second

ll d;

ll pt[50];
ll key[50];
ll us[50];
int kn;

ll ans;

int Wc[50];
int WcNZ[50];

void dfs(ll d, int p, ll cnt){
	if(p == kn){
		if(d == 0) ans += cnt;
		return;
	}
	for(int i=-9; i<=9; ++i){
		ll cd=d+key[p]*i;
		if(cd > 9*us[p+1] || cd < -9*us[p+1]) continue;
		ll nw = (p ? Wc[i+10] : WcNZ[i+10]);
		dfs(cd, p+1, nw * cnt);
	}
}


int main()
{
	for(int i=0; i<=9; ++i) for(int j=0; j<=9; ++j){
		Wc[i-j+10] ++;
		if(j) WcNZ[i-j+10] ++;
	}
	
	pt[0]=1; for(int i=1; i<=18; ++i) pt[i]=pt[i-1]*10;

	read(d);
	
	ll Ans=0;
	for(int len=2; len<=18; ++len){
		kn = 0;
		for(int i=len-1; 0<=i; --i) if(i > len-1-i) key[kn++]=(pt[i] - pt[len-1-i]);
		fill(us, us+20, 0);
		for(int i=kn-1; 0<=i; --i) us[i]=key[i]+us[i+1];
		ans=0;
		dfs(-d, 0, 1);
		if(len % 2 == 1) ans *= 10;
		Ans += ans;
	}

	printf("%lld\n", Ans);
    return 0;
}


Measured memory_bytes: 256
class Dice:
    index_list_map = [[[-1],[2,3,4,5],[4,1,3,5],[1,4,2,5],[3,2,1,5],[-1]],
                      [[3,2,5,4],[-1],[0,5,3,4],[5,0,2,4],[-1],[2,3,0,4]],
                      [[1,4,5,3],[5,0,4,3],[-1],[-1],[0,5,1,3],[4,1,0,3]],
                      [[4,1,5,2],[0,5,4,2],[-1],[-1],[5,0,1,2],[1,4,0,2]],
                      [[2,3,5,1],[-1],[5,0,3,1],[0,5,2,1],[-1],[3,2,0,1]],
                      [[-1],[3,2,4,0],[1,4,3,0],[4,1,2,0],[2,3,1,0],[-1]]]

    def __init__(self,list):
        self.num = list

    def lookup_east_side(self,u,s):
        index_upside = u
        index_sside = s
        return self.num[self.index_list_map[index_upside][index_sside][0]]


    def lookup_west_side(self,u,s):
        index_upside = u
        index_sside = s
        return self.num[self.index_list_map[index_upside][index_sside][1]]

    def lookup_north_side(self,u,s):
        index_upside = u
        index_sside = s
        return self.num[self.index_list_map[index_upside][index_sside][2]]

    def lookup_down_side(self,u,s):
        index_upside = u
        index_sside = s
        return self.num[self.index_list_map[index_upside][index_sside][3]]

    def is_same(self,dice):
        index_u = [ i for i,x in enumerate(dice.num) if x == self.num[0]]
        index_s = [ i for i,x in enumerate(dice.num) if x == self.num[1]]

        combinations_u_s = [ [x,y] for x in index_u for y in index_s if x != y and (abs(x-2.5) != abs(y-2.5))]
        for comb in  combinations_u_s :
            e = dice.lookup_east_side(comb[0],comb[1])
            w = dice.lookup_west_side(comb[0],comb[1])
            n = dice.lookup_north_side(comb[0],comb[1])
            d = dice.lookup_down_side(comb[0],comb[1])
            if e == self.num[2] and w == self.num[3] and n == self.num[4] and d == self.num[5]:
                return True
        return False

n = input()
dices = []
for i in range(n):
  spots = map(int,raw_input().split())
  dices.append(Dice(spots))

flag = False
for i in range(len(dices)):
    for j in range(i+1, len(dices)):
        if dices[i].is_same(dices[j]):
            flag = True
            break
if flag:
    print "No"
else:
    print "Yes"

Measured memory_bytes: 6492
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static IntStream INS(int n) {return REPS(n).map(i->getInt());}
	static Scanner s=new Scanner(System.in);
	static int getInt(){return Integer.parseInt(s.next());}

	public static void main(String[]$){
		int n=getInt(),a[]=new int[n],b[]=new int[n];

		for(int i=0;i<n;++i)
			b[n-i-1]=a[i]=getInt();
		
		//System.out.println(Arrays.toString(a));
		//System.out.println(Arrays.toString(b));

		System.out.println(solve(n,a)&&solve(n,b)?"yes":"no");
	}
	private static boolean solve(int n,int[]a){
		int max=0;
		for(int i=0;i<=max&&i/10<n;i+=10) {
			max=Math.max(max,i+a[i/10]);
		}
		return max>=n*10;
	}
}

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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>>  var(n, vector<int>(m, 0))
#define vecb2(var, n, m)   vector<vector<bool>> var(n, vector<bool>(m, false))
#define vecll2(var, n, m)  vector<vector<ll>>   var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  int x;
  cin >> x;
  prt(8-(x-400)/200);

}


Measured memory_bytes: 3636
function main(input) {
    var n = input[0].split("");
    var ans = 0;
    for(var i=1;i<n.length;i++){
        if(n[i-1] != n[i]) ans++;
    }
    console.log(ans);
    
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


Measured memory_bytes: 8268
#include <stdio.h>
int main(void){
    char number[1001];
    int num, i;
    for (;;){
        num = 0;
        scanf("%s", number);
        for (i = 0; i < 1001; i++){
            if (number[i] == '\0'){
                break;
            }else{
                num += number[i] - '0';
            }
        }
        if (num != 0){
            printf("%d\n", num);
        }else{
            break;
        }
    }
 
    return 0;
}



Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <cassert>
#include <csetjmp>
using namespace std;

int n;
pair<int, int> domino[28];
bool used[28];
jmp_buf env;

void dfs(int depth, int num)
{
  if (depth == n) {
    longjmp(env, 1);
  }

  for (int i = 0; i < n; ++i) {
    if (used[i]) continue;
    if (domino[i].first == num) {
      used[i] = true;
      dfs(depth + 1, domino[i].second);
      used[i] = false;
    } else if (domino[i].second == num) {
      used[i] = true;
      dfs(depth + 1, domino[i].first);
      used[i] = false;
    }
  }
}

int main()
{
  while (cin >> n) {
    for (int i = 0; i < n; ++i) {
      int k; cin >> k;
      domino[i].first = k / 10;
      domino[i].second = k % 10;
    }

    if (!setjmp(env)) {
      memset(used, false, sizeof(used));
      for (int i = 0; i < n; ++i) {
        used[i] = true;
        dfs(1, domino[i].first);
        dfs(1, domino[i].second);
        used[i] = false;
      }
      puts("No");
    } else {
      puts("Yes");
    }
  }
}

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

int main() {
    int a, b, c;  cin >> a >> b >> c;
    if (b/a >= c)  cout << c << endl;
    else  cout << b/a << endl;
}

Measured memory_bytes: 256
from sys import stdin 
from bisect import bisect_left
n = int(stdin.readline().rstrip())
l = [int(x) for x in stdin.readline().rstrip().split()]
l.sort()
answer = 0
for i in range(len(l)):
    for j in range(i):
        if i != j:
            k = bisect_left(l, l[i]+ l[j])
            answer += k - i - 1
print(answer)

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

int main(){
    int a, b;
    cin >> a >> b;
    for(int x = 1; x <= 1250; x++){
        if(int(x*0.08) == a && int(x*0.1) == b){
            cout << x << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
# coding=utf-8

if __name__ == '__main__':
    N = int(input())
    score_list = list(map(int, input().split()))
    score_list.sort(reverse=True)

    ctr = 1
    for element in score_list:
        if ctr > element:
            print(ctr-1)
            break
        ctr += 1
    else:
        print(ctr-1)



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

int main() {
  ll X;
  cin >> X;
  
  int year = 0;
  ll sum = 100;
  while (sum < X){
    sum = sum * 1.01;
    year += 1;
  }
  
  cout << year << endl;
}


Measured memory_bytes: 3608
import java.util.Scanner

object Main {
  val sc = new Scanner(System.in)
  def main (args: Array[String]): Unit={
    val n = sc.nextInt
    val s = sc.next
    val r = s.split("(?<=.)").count(_ == "R")
    val b = n - r
    println(if(r > b) "Yes" else "No")
  }
}



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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)
#define REP(i, n, m) for (long long i = (long long)(n); i < (long long)(m); i++)

namespace solver {
  using namespace std;
  typedef long long ll;

  static const ll MAX = 200020LL;
  ll N, A[MAX];
  map<ll, ll> L, R;

  void init() {
    scanf("%lld", &N);
    rep(i, N) scanf("%lld", A+i);
  }

  void solve() {
    rep(i, N) {
      L[i + A[i]]++;
      R[i - A[i]]++;
    }
    ll ans = 0;
    for(const auto& l : L) {
      ans += l.second * R[l.first];
    }
    cout << ans << endl;
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 39496
#include <stdio.h>
#include <map>
using namespace std;
int main(void){
	int n,m;
	int i,j;
	map<int,int> mp;
	int count=0;
	int a[100000]={0};
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(mp.find(a[i]) == mp.end()){
			mp[a[i]] = 1;
			count++;
		}else{
			mp[a[i]]+=1;
			if(mp[a[i]] % 2 == 0){
				count--;
			}else{
				count++;
			}
		}
	}
	printf("%d",count);
	return 0;
}

Measured memory_bytes: 5248
n,k = map(int, input().split())

if k>(n-2)*(n-1)//2:
  print(-1)
elif k==(n-2)*(n-1)//2:
  print(n-1)
  for i in range(2,n+1):
    print(1,i)
else:
  num=(n-2)*(n-1)//2 - k
  print(n-1+num)
  for i in range(2,n+1):
    print(1,i)

  while True:
    for j in range(2,n+1):
      for i in range(j+1,n+1):
        print(j,i)
        num=num-1
        
        if num==0:
          exit()

Measured memory_bytes: 42736
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
	int main()
	{
		int nokori = 0,a, b, c;
		std::cin >> a >> b >> c;
		nokori = a-b;
		if (c - nokori <= 0) {
			std::cout<<0<<std::endl;
		}
		else
			std::cout<<c - nokori<<std::endl;
		return false;
	}



Measured memory_bytes: 256
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/04/04.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//  ABC161
//
//

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

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
//#define __DBG__



void solve(void){
  
  int X, Y, Z;
    
  cin >> X >> Y >> Z;
  

  
  cout << Z << " " << X << " " << Y << endl;
  
  
  
  return;
}

#define TESTCASES 1

int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);

    REP(i,TESTCASES){
      solve();
    }
 
    return 0;
}



Measured memory_bytes: 256
n, a, b = map(int, input().split())
MOD = 10**9 + 7
def comb(n, r, MOD):
    X = 1
    Y = 1
    for i in range(1, r+1):
        X = (X*(n-i+1))%MOD
        Y = (Y*i)%MOD
    return (X*pow(Y, MOD-2, MOD))%MOD

ans = (pow(2, n, MOD)-1 - comb(n, a, MOD) - comb(n, b, MOD))%MOD
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cmath>
#include <ios>
using namespace std;

struct Point
{
    double x;
    double y;
    Point(double d1, double d2): x{d1}, y{d2} {};
};

vector<Point> split(vector<Point> & vecP){
    vector<Point> result;
    bool is_first = true;
    Point p1{0, 0};
    for (auto & p2 : vecP){
        if (is_first){
            result.push_back(p2);
            p1 = p2;
            is_first = false;
            continue;
        }
        Point s{(2.0 * p1.x + p2.x) / 3.0, (2.0 * p1.y + p2.y) / 3.0};
        Point t{(2.0 * p2.x + p1.x) / 3.0, (2.0 * p2.y + p1.y) / 3.0};
        Point u{0, 0};
        u.x = s.x + (t.x - s.x) / 2.0 - sqrt(3) * (t.y - s.y) / 2.0;
        u.y = s.y + (t.y - s.y) / 2.0 + sqrt(3) * (t.x - s.x) / 2.0;
        result.push_back(s);
        result.push_back(u);
        result.push_back(t);
        result.push_back(p2);
        p1 = p2;
    }
    return result;
}

int main()
{
    int n = 0;
    cin >> n;
    vector<Point> vecP;
    vecP.push_back(Point{0, 0});
    vecP.push_back(Point{100, 0});
    for (int i = 0; i != n; ++i) vecP = split(vecP);
    cout.precision(12);
    cout << fixed;
    for (auto p : vecP) cout << p.x << ' ' << p.y << endl;
    return 0;
}

Measured memory_bytes: 3284
n = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    if arr == [[1, 1]]:
        return []
    else:
        return arr

prime_factor = factorization(n)

result = 0

for _, count in prime_factor:
    i = 1
    while count >= i:
        result += 1
        count -= i
        i += 1

print(result)

Measured memory_bytes: 63340
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
  int n, K;
  cin >> n >> K;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = 1e9;
  for (int i = 0; i + K <= n; i++) {
    ans = min(ans, abs(a[i]) + abs(a[i + K - 1] - a[i]));
    ans = min(ans, abs(a[i + K - 1]) + abs(a[i + K - 1] - a[i]));
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <limits.h>
using namespace std;

int beau = 1000000009;

int main() {
	int n, m, ms = 0;
	char a[55][55], b[55][55];
	bool ans = false;
	cin >> n >> m;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < m; i++) cin >> b[i];
	for (int i = 0; i < n - m + 1; i++) {
	    for (int j = 0; j < n - m + 1; j++) {
	        for (int k = 0; k < m; k++) {
	            for (int l = 0; l < m; l++) {
	                if (b[k][l] == a[i + k][j + l]) ms++;
	            }
	        }
	        if (ms == m * m) ans = true;
	        ms = 0;
	    }
	}
	if (ans) cout << "Yes";
	else cout << "No";
	return 0;
}


Measured memory_bytes: 256
import math
b=input()
c=[]
for i in range(len(b)):
	c.append(b[i])
#a = list(map(int,input().split()))
#b = list(map(int,input().split()))
#s=int(input())

f=input()
t=[]
for i in range(len(f)):
	t.append(f[i])
d=[]
for i in range(len(c)):
	d.append(c[-(i+1)])
	
if d==t:
	print("YES")
else:
	print("NO")

Measured memory_bytes: 8988