akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define ll long long
#define F(i,a,b) for(int i=(a);i<=(b);i++)
#define mst(a,b) memset((a),(b),sizeof(a))
#define PII pair<int,int>
using namespace std;
template<class T>inline void read(T &x) {
    x=0; int ch=getchar(),f=0;
    while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    if(f)x=-x;
}
const int inf=0x3f3f3f3f;
ll n;
int main()
{
	cin>>n;
	ll x=1,i=0;
	while(x<=n) 
	{
		i++;
		x=(1ll<<i);
	}
	i--;
	cout<<(1ll<<(i+1))-1<<endl;
	return 0;
}


Measured memory_bytes: 256
#import<iostream>
#define l long
l N,M,c,n=1,i,o=1e9+7;l m(l a){l g=1,h=2*o-4;while(h/=2){if(h&1)g=g*a%o;a=a*a%o;}return g;}l C(l b){l r=1,d=1;for(;b;--b)r=r*(N-1+b)%o,d=d*b%o;return r*m(d)%o;}main(){std::cin>>N>>M;for(i=2;i*i<=M;++i){c=0;while(!(M%i))++c,M/=i;n=n*C(c)%o;}std::cout<<n*(M^1?N:1)%o<<std::endl;}

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

#define ll long long
#define pii pair<int,int>
#define pll pair<long long, long long>
#define rep(i,l,r) for(int i = l;i<r;i++)

#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()

#define fastout  ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;

const int INF = (int)1e9 + 7;
const long long LLINF = (long long)1e18 + 7;

void kekek()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef EBUCHKA
        freopen("in.txt", "r", stdin), freopen("out.txt", "w", stdout);
    #endif
}

int main() {
    kekek();
    string s;
    cin >> s;
    int ans = 0;
    string prev = "";
    for (int i = 0; i < s.size(); i++) {
        string ts = "";
        ts += s[i];
        // cout << prev << ' ' << ts << endl;
        if (prev != ts) {
            prev = ts;
            ans++;
        }
        else {
            if (i < (int)s.size() - 1) {
                i++;
                ans++;
                prev = ts + s[i];
            }
        }; 
    }   
    cout << ans;
}

Measured memory_bytes: 1228
N,K=map(int,input().split())
a=list(map(int,input().split()))

s=[]
ord=[-1]*(N+1)
c=1
l=0
v=1
while(ord[v]==-1):
    ord[v]=len(s)
    s.append(v)
    v=a[v-1]
c=len(s)-ord[v]
l=ord[v]
if K<l:
    print(s[K])
else:
    K-=l
    K%=c
    print(s[l+K])

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;


int main(){
    int N; cin>>N;
    ll a[N]; CINA(a,N);
    bool ok = (a[0]==0);
    ll ans = -1;
    if(ok){
        REP(i,N-1){
            ll dif = a[i+1]-a[i];
            if(dif>1){
                ok = false; break;
            }
        }
    }
    if(ok){
        ans = a[N-1];
        REP(i,N-1){
            if(a[i+1]-a[i]!=1){
                ans += a[i];
            }
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 5192
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef pair<int,int>P;
typedef long long ll;

int main(){
	int a,b,c;cin>>a>>b>>c;
	if(a==b&&b==c){
		puts("Yes");
	}
	else puts("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
int gcd(int x,int y){
    if(y == 0)return x;
    return gcd(y,x%y);
}
int lcm(int x,int y){
    return x*y/gcd(x,y);
}
signed main(){
    int x;cin >> x;
    cout << 360/gcd(x,360) << endl;
    return 0;
}

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

using namespace std;

bool ok(int x, int y, int z, vector <int> v)
{
    return (v[x] < v[y] && v[y] < v[z]);
}

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

    int n;
    cin >> n;

    vector <int> v(n + 1, 0);

    for(int i = 1; i <= n; i++)
        cin >> v[i];

    int nr = 0;

    for(int i = 2; i < n; i++)
        if(ok(i - 1, i, i + 1, v) || ok(i + 1, i, i - 1, v))
            nr++;

    cout << nr;
}


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

typedef long long ll;
typedef pair<int,int> P;
ll const mod = 1e9+7;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

ll pow_mod(ll a,ll b) {
    ll ret;
    if (b < 0) ret = pow_mod(a,mod+b-1);
    else if (b == 0) ret = 1;
    else if (b == 1) ret = a;
    else {
        ll c = pow_mod(a,b/2);
        if (b%2) ret = (c*c)%mod*a%mod;
        else ret = c*c%mod;
    }
    return ret;
}

int main() {
    int n;
    cin >> n;
    vector<ll> dp1(1<<20,0),dp2(1<<20,0);
    for (int i = 0;i < n;++i) {
        int a;
        cin >> a;
        dp1[a]++;
    }
    for (int i = 0;i < 20;++i) for (int j = 0;j < (1<<20);++j) if (!(j&(1<<i))) (dp1[j] += dp1[j|(1<<i)]) %= mod;
    for (int i = 0;i < (1<<20);++i) dp2[i] = pow_mod(2,dp1[i])-1;
    for (int i = 0;i < 20;++i) for (int j = 0;j < (1<<20);++j) if (!(j&(1<<i))) (dp2[j] -= dp2[j|(1<<i)]) %= mod;
    cout << (dp2[0]+mod)%mod << endl;
    // p_ary(dp1,0,1<<4);
    // p_ary(dp2,0,1<<4);
}


Measured memory_bytes: 19128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,D;cin>>N>>D;
  vector<long long> X(N);
  vector<long long> Y(N);
  int Ans=0;
  for(int i=0;i<N;i++){
    cin>>X.at(i)>>Y.at(i);
    if(sqrt(X.at(i)*X.at(i)+Y.at(i)*Y.at(i))<=D){
      Ans++;
    }
  }
  cout<<Ans<<endl;
}

Measured memory_bytes: 6488
#include<stdio.h>

int fib(int);

int dp[50];

int main(){
  int n,i;
  for(i=0;i<50;i++)
    dp[i]=-1;
    
  scanf("%d",&n);
  printf("%d\n",fib(n));
  
  return 0;
}

int fib(int n)
{
  if(n==0||n==1) return dp[n]=1;
  if(dp[n]!=-1)return dp[n];
  return dp[n]=fib(n-1)+fib(n-2);
}



Measured memory_bytes: 2108
using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.Text.RegularExpressions;
    using System.Text;
     
    public class Program
    {
        public void Proc() {
            Reader.IsDebug = false;
            long[] inpt = Reader.ReadLine().Split(' ').Select(a=>long.Parse(a)).ToArray();

            int itemCount = (int)inpt[0];
            long minLength = inpt[1];

            long[] list = Reader.ReadLine().Split(' ').Select(a=>long.Parse(a)).ToArray();

            for(int i=1; i<list.Length; i++) {
                if(list[i-1]+list[i]>=minLength) {
                    Console.WriteLine("Possible");
                    StringBuilder ans = new StringBuilder();
                    for(int j=0; j<i-1; j++) {
                        ans.AppendLine((j+1).ToString());
                    }
                    for(int j=list.Length-2; j>=i; j--) {
                        ans.AppendLine((j+1).ToString());
                    }
                    ans.AppendLine(i.ToString());
                    Console.Write(ans.ToString());
                    return;
                }
            }
            Console.WriteLine("Impossible");
        }



        public class Reader {
            public static bool IsDebug = true;
            private static System.IO.StringReader SReader;
            private static string InitText = @"




2 21
10 10





";
            public static string ReadLine() {
                if(IsDebug) {
                    if(SReader == null) {
                        SReader = new System.IO.StringReader(InitText.Trim());
                    }
                    return SReader.ReadLine();
                } else {
                    return Console.ReadLine();
                }
            }
        }
        public static void Main(string[] args)
        {
            Program prg = new Program();
            prg.Proc();
        }
    }

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

int main(){
    string s;
    cin >> s;
    if(s == "SUN") cout << 7 <<endl;
    if(s == "MON") cout << 6 <<endl;
    if(s == "TUE") cout << 5 <<endl;
    if(s == "WED") cout << 4 <<endl;
    if(s == "THU") cout << 3 <<endl;
    if(s == "FRI") cout << 2 <<endl;
    if(s == "SAT") cout << 1 <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

string s;
int k;

string solve() {
    vector<string> vec;
    for (int i = 0; i < s.size(); i++) {
        string t = "";
        for (int j = i; j < i+k && j < s.size(); j++) {
            t += s[j];
            vec.push_back(t);
        }
    }
    sort(ALL(vec));
    UNIQ(vec);
    return vec[k-1];
}

void input() {
    cin >> s >> k;
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 1660
#include <iostream>
#include <cmath>
#include <vector>


int main(int argc, char const *argv[]) {
  int N = 100;
  std::cin >> N;
  int score[2][N];
  int a = 0;

  for(int i =0 ; i < 2; i++){
    for(int j = 0; j < N; j++){
      std::cin >> score[i][j];
      if(i == 0 && j == 0){
        a += score[0][0];
      }
      if(i == 1){
        a += score[i][j];
      }
    }
  }
  int tmp = a;
  for(int i = 1; i < N; i++){
    a += (score[0][i] - score[1][i-1]);
    if(tmp < a){
      tmp = a;
    }
  }
std::cout << tmp << '\n';
  return 0;
}


Measured memory_bytes: 256
from itertools import accumulate
def solve():
    n, k = map(int, input().split())
    P = list(map(int, input().split()))
    A = [a * (a + 1) / 2 / a for a in P]
    B = [0.0] + list(accumulate(A))
    ans = 0
    for i in range(k, n + 1):
        ans = max(ans, B[i] - B[i - k])
    print(ans)
solve()


Measured memory_bytes: 26364
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const ll N=1e5+3;
vector<int> v[N];
ll ans=0,n,dp[N];
#define eb emplace_back
ll dfs(int node,int par);

int main(){
ll i,j,k,m;
cin>>n>>m;
memset(dp,-1,sizeof(dp));
while(m--){
    cin>>i>>j;
    v[i].eb(j);
}
for(i=1;i<=n;i++){
    if(dp[i]==-1)
        dfs(i,-1);
} 
cout<<ans<<"\n";
    return 0;
}

ll dfs(int node,int par){
    if(dp[node]!=-1)
        return dp[node];
    else if(v[node].empty())
        return dp[node]=0;
    for(auto it:v[node]){
        if(it==par)continue;
        dp[node]=max(dp[node],dfs(it,node)+1);
    }
    ans=max(ans,dp[node]);
    return dp[node];
}

Measured memory_bytes: 8576
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int[] a = new int[2*n];
		for(int i = 0; i < 2*n; i++) a[i] = s.nextInt();
		Arrays.sort(a);;
		long ans = 0;
		for(int i = 0; i < 2*n; i+=2) {
			ans += Math.min(a[i], a[i+1]);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 10068
#include"bits/stdc++.h"
using namespace std;

typedef pair<int, int> P;

void Main() {
  int n, k;
  cin >> n >> k;

  vector<P> sushi(n);
  for (int i = 0; i < n; i++) {
    int t, d;
    cin >> t >> d;
    sushi[i] = P(d, t - 1);
  }
  sort(sushi.rbegin(), sushi.rend());

  priority_queue<P, vector<P>, greater<P>> s;
  priority_queue<P> not_s;
  int type_nums[n];
  memset(type_nums, 0, sizeof(type_nums));
  int num_types = 0;
  long long base_point = 0;
  for (int i = 0; i < k; i++) {
    base_point += sushi[i].first;
    type_nums[sushi[i].second]++;
    if (type_nums[sushi[i].second] == 1) num_types++;
    if (type_nums[sushi[i].second] > 1) s.push(sushi[i]);
  }
  for (int i = k; i < n; i++) {
    if (type_nums[sushi[i].second] == 0) not_s.push(sushi[i]);
  }
  long long f[n + 1];
  memset(f, 0, sizeof(f));
  f[num_types] = base_point;

  for (int i = num_types + 1; i < n; i++) {
    vector<P> tmp;
    if (s.size() == 0) break;
    P min_sushi = s.top(); s.pop();
    type_nums[min_sushi.second]--;

    while(not_s.size() > 0) {
      P max_sushi = not_s.top(); not_s.pop();
      if (type_nums[max_sushi.second] == 0) {
        type_nums[max_sushi.second]++;
        f[i] = f[i - 1] - min_sushi.first + max_sushi.first;
        break;
      };
    }
  }

  long long ans = 0;
  for (long long i = 0; i <= n; i++) {
    if (f[i] > 0) {
      ans = max(ans, f[i] + i * i);
    };
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 2936
#include<cstdio>
long long gcd(long long a,long long b){
	if(a<b)return gcd(b,a);
	else if(a%b==0)return b;
	else return gcd(b,a%b);
}
int main(){
    int n;
    long long k,a,maxa,gcda;
    scanf("%d%lld",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%lld",&a);
        if(i==0){
            maxa=a;
            gcda=a;
        }
        if(a>maxa)maxa=a;
        if(gcda>1)gcda=gcd(a,gcda);
        if(k<=maxa && k%gcda==0){
            printf("POSSIBLE");
            return 0;
        }
    }
    printf("IMPOSSIBLE");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int N=S.size();
  
  int i;
  
  for(i=0;i<(N-1)/2;i++){
    if(S[i]!=S[N-1-i]){
      cout << "No" << endl;
      return 0;
    }
  }
  
  if(N==3){
    cout << "Yes" << endl;
    return 0;
  }
  
  for(i=0;i<(N-1)/4;i++){
    if(S[i]!=S[(N-1)/2-1-i]){
      cout << "No" << endl;
      return 0;
    }
  }
  
  for(i=0;i<(N-1)/4;i++){
    if(S[(N-1)/2+1+i]!=S[N-1-i]){
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int p,q,r,ans;
  scanf("%d %d %d",&p,&q,&r);
  ans=p+q;
  if(q+r<ans){
    ans=q+r;
  }
  else {}
  if(p+r<ans){
    ans=p+r;
  }
  else{}
  printf("%d",ans);
 return 0; 
}

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

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> dp(k + 1);
    for (int stones = 0; stones <= k; stones++) {
        for (int x : a) {
            if (stones >= x and !dp[stones - x]) {
                dp[stones] = 1;
            }
        }
    }
    puts(dp[k] ? "First" : "Second");
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
typedef	long long ll;
typedef unsigned long long ull;
#define all(v) ((v).begin()),((v).end())
#define PI(n) ((double)acos(n))
#define clr0(n) (memset(n,0,sizeof n))
#define clr1(n) (memset(n,-1,sizeof n))
int dx8[8] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy8[8] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file()
{
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	// online submission
#endif
}
void fast()
{
	std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
}
int a[120][120];
int main()
{
	
	string x;
	cin >> x;
	cout << x[0] << (int)x.size() - 2 << x[(int)x.size() - 1] << endl;
}

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

int main() {
  int a[9];
  REP(i,9){
    cin>>a[i];
  }
  int n;
  cin>>n;
  int b[n];
  REP(i,n){
    cin>>b[i];
  }
 bool appear[3][3];
 for (int i = 0; i < 9; i++)
 {
   /* code */
   for (int j = 0; j < n; j++)
   {
     /* code */
     if (a[i]==b[j])
     {
       /* code */
       appear[i/3][i%3]=true;
       break;
     }
     else
     {
       appear[i/3][i%3]=false;
     }
     
     
   }
   
 }
 string ANS = "No";
for(int i = 0; i < 3; i++) {
 if(appear[i][0] and appear[i][1] and appear[i][2]) ANS = "Yes";
 }
 for(int i = 0; i < 3; i++) {
 if(appear[0][i] and appear[1][i] and appear[2][i]) ANS = "Yes";
 }
 if(appear[0][0] and appear[1][1] and appear[2][2]) ANS = "Yes";
 if(appear[0][2] and appear[1][1] and appear[2][0]) ANS = "Yes";
 cout << ANS << endl;
 
  
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

#define val const auto &

using namespace std;

int main()
{
    int n;
    string s;
    cin >> n >> s;

    int count = 0;
    for (val c : s)
        if (c == 'R')
            ++count;

    if (count * 2 > n)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int A,B,p;
	scanf("%d%d",&A,&B);
	if(A>B)
	{
		p=A;
		A--;
	}
	else
	{
		p=B;
		B--;
	}
		if(A>B)
	{
		p+=A;
		A--;
	}
	else
	{
		p+=B;
		B--;
	}
	printf("%d",p);
	return 0;
}


Measured memory_bytes: 128
/*
    AUTHOR:shivam51
    IIESTS
*/
  #include<bits/stdc++.h>
  using namespace std;
  //
  #define add	 	accumulate
  #define ll 	 	long long int
  #define ff	 	first
  #define ss 	 	second
  #define pb 	 	push_back
  #define pob		pop_back
  #define pf 	 	push_front
  #define pof		pop_front
  #define mp 	 	make_pair
  #define vll 	 	vector<ll>
  #define lb 	 	lower_bound
  #define ub     	upper_bound
  #define pll 	 	pair<ll,ll>
  #define vpll   	vector<pll>
  #define all(v) 	v.begin(), v.end()
  #define rep(i,k,n)    for(int i=k;i<n;i++)
  #define hs            ios_base::sync_with_stdio(false);cin.tie(NULL);
  template <class C> void setmin(C &a,C b){if(a>b)a=b;}
  template <class C> void setmax(C &a,C b){if(a<b)a=b;}
  const ll mod=1e9+7;
  const ll MAX=1e5;
  //
  //
  	void solve(){
  		ll n,ans=0;
  		cin>>n;
  		map<string,ll> m;
  		rep(i,0,n){
  			string s;
  			cin>>s;
  			sort(all(s));
  			m[s]++;
  		}
  		for(auto itr:m){
  			ans+=max(0ll,(itr.ss)*(itr.ss-1)/2);
  		}
  		cout<<ans;
  	}

	int main(){ 
		hs;
		ll t;
		// cin>>t;
		t=1;
		while(t--)
		  solve();
    return 0; 
} 	


Measured memory_bytes: 11264
// 23
#include <bits/stdc++.h>
using namespace std;
#define coutc "\033[48;5;196m\033[38;5;15m"
#define endc "\033[0m"
#define endl '\n'
#define M(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) \
  M(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep4(_, x, n, s) \
  for (int _ = x; (s < 0) ? _ > n : _ < n; _ += s)
#define rep3(_, x, n) rep4(_, x, n, (x < n ? 1 : -1))
#define rep2(_, n) rep3(_, 0, n)
#define rep1(n) rep2(i, n)
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define len(x) int(x.size())
#define lli __int128_t
#define li long long int
#define ld long double
#ifdef DEBUG
// 3
ostream &operator<<(ostream &o, pair<auto, auto> p) {
  return o << "(" << p.fi << ", " << p.se << ")";
}
// 4
ostream &operator<<(ostream &o, vector<auto> v) {
  rep(i, len(v)) o << setw(7) << right << v[i];
  return o << endc << endl << coutc;
}
// 4
ostream &operator<<(ostream &o, map<auto, auto> m) {
  for (auto &kv : m) o << kv;
  return o;
}
// 7
void debug(const auto &e, const auto &... r) {
  cerr << coutc << e;
  ((cerr << " " << r), ..., (cerr << endc << endl));
}
#else
#define debug(...)
#endif
// 3
const double eps = 1e-9;
li multiply(double a, li b) {
  double ans = a * b;
  if (ceil(ans) - ans <= eps) return (li) ceil(ans);
  return ans;
}

void _main(int tc) {
  li a;
  cin >> a;
  double b;
  cin >> b;
  li bb = multiply(b, 100);
  debug(bb);
  cout << (li)(a * bb) / 100 << endl;
}
// 7
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    cout<<string(ty-sy, 'U');
    cout<<string(tx-sx, 'R');
    cout<<string(ty-sy, 'D');
    cout<<string(tx-sx, 'L');
    cout<<'L';
    cout<<string(ty-sy+1, 'U');
    cout<<string(tx-sx+1, 'R');
    cout<<'D';
    cout<<'R';
    cout<<string(ty-sy+1, 'D');
    cout<<string(tx-sx+1, 'L');
    cout<<'U';
    cout<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
int n;
int main()
{
	cin>>n;
	if(n%10==3) re("bon")
	if(n%10==0||n%10==1||n%10==6||n%10==8) re("pon")
	re("hon")
	return 0;}

Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef vector<ll> vi;

const ll INF = 1e17;

int main(){
  ll n,m,r;
  while(cin >> n >> m){
    if(n==0)break;
    vector< vi > sg(n,vi(n,INF)), lg(n,vi(n,INF));
    rep(i,n)sg[i][i] = lg[i][i] = 0;

    rep(i,m){
      ll x,y,t;
      string s;
      cin >> x >> y >> t >> s; x--; y--;
      if(s == "L")lg[x][y] = lg[y][x] = min(lg[x][y],t);
      else sg[x][y] = sg[y][x] =  min(sg[x][y],t);
    }

    rep(k,n)rep(i,n)rep(j,n)lg[i][j] = min(lg[i][j], lg[i][k] + lg[k][j]);
    rep(k,n)rep(i,n)rep(j,n)sg[i][j] = min(sg[i][j], sg[i][k] + sg[k][j]);

    /*
    rep(i,n){rep(j,n)cout << lg[i][j] << " "; cout << endl;}
    rep(i,n){rep(j,n)cout << sg[i][j] << " "; cout << endl;}
    */

    cin >> r;
    ll cur; cin >> cur; cur--;
    vi dis(n,INF); dis[cur] = 0;

    rep(z,r-1){
      ll nxt; cin >> nxt; nxt--;
      vi ndis(n,INF);

      rep(i,n){
	ndis[i] = min(ndis[i], dis[i] + lg[cur][nxt]);
	rep(j,n){
	  ndis[j] = min(ndis[j], dis[i] + lg[cur][i] + sg[i][j] + lg[j][nxt]);
	}
      }

      dis = ndis;
      cur = nxt;
    }

    cout << *min_element(dis.begin(), dis.end()) << endl;
  }
}

Measured memory_bytes: 1796
#include<bits/stdc++.h>
using namespace std;
#define LL long long int

LL a, b, c, lhs, rhs;

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

    lhs = a * b * 4;
    rhs = (c - a - b)*(c - a - b);

    if (c >= a + b && lhs < rhs)
        cout << "Yes\n";
    else
        cout << "No\n";
}


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

int main() {
    long long N, A, B, C, D, E; cin >> N >> A >> B >> C >> D >> E;

	long long res = 0;

	long long min_ = min({A, B, C, D, E});

	res = ceil((double)N/min_) + 4;

    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  string s;
  string t;
  cin>>s>>t; 
  
  int ans=0;
  int j=0;
  int flag=0;
  for(int i=0;i<n;i++)
  {
    j=0;
    ans=0;
    if(s[i]==t[j]){
      int p=i;
      ans=0;
      while(p<n && s[p]==t[j])
      {
        ans++;
        p++;
        j++;
      }
      if(p==n)flag=1;
    }
    if(flag)break;
  }
  cout<<(2*n)-ans<<endl;
  return 0;
}

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

template<class T> bool find(T v,int a){
  for (auto b :v){
    if (a==b){
      return true;
    }
  }
  return false;
}
int main(){
  string s;
  int x,y;
  cin >>s;
  cin >>x>>y;
  int tmp=0;
  bool T=true;
  int asize=0,bsize=0;
  vector<int> a(8000,0),b(8000,0);
  for(auto i:s){
    if (i=='T') {
      tmp=1-tmp;
      T=true;
    }
    else if (tmp==0){
      if (T){
        asize+=1;
        T=false;
      }
      a[asize-1]+=1;
    }
    else{
      if (T) {
        bsize+=1;
        T=false;
      }
      b[bsize-1]+=1;
    }
  }
  set<int> c={0};
  for (int i=0;i<asize;++i){
    set<int> d;
    if (i==0){
      if (s[0]=='T') d.insert(-a[i]);
      d.insert(a[i]);
    }
    else{
      for(auto j :c){
        d.insert(j+a[i]);
        d.insert(j-a[i]);
      }
    }
    c=d;
  }
  if (!(find(c,x))){
    cout << "No"<<endl;
    exit(0);
  }
  c={0};
  for(int i=0;i<bsize;++i){
    set<int> d;
    for (auto j:c){
      d.insert(j+b[i]);
      d.insert(j-b[i]);
    }
    c=d;
  }
  if (!(find(c,y))){
    cout << "No"<<endl;
    exit(0);
  }
  cout << "Yes"<<endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
const int max_v = 1000;
int v,E,n,m;
int d[max_v][max_v];
int b[max_v];
const int INF = 1e9;
vector<int> ls;
int used[max_v][max_v];
void solve(){
    for(int i=0 ; i<3 ; i++){
        for(int j=0 ; j<3 ; j++){
            for(int k=0 ; k<n ; k++){
                if(d[i][j] == b[k]){
                    used[i][j] = true;
                }
            }
        }
    }
    for(int i=0 ; i<3 ; i++){
        if(used[i][0] && used[i][1] && used[i][2] ){
            puts("Yes"); return;
        }
    }
    for(int i=0 ; i<3 ; i++){
        if( used[0][i] && used[1][i] && used[2][i]){
            puts("Yes");    return;
        }
    }
    if(used[0][2] && used[1][1] && used[2][0]){
        puts("Yes");    return;
    }
    if(used[0][0] && used[1][1] && used[2][2]){
        puts("Yes");    return;
    }
    puts("No");
}
int main(){
    for(int i=0 ; i<3 ; i++){
        for(int j=0 ; j<3 ; j++){
            cin >> d[i][j];
        }
    }
    cin >> n;
    for(int i=0 ; i<n ; i++){
        cin >> b[i];
    }
    solve();
    return 0;
}

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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Yes or No
void yesno(bool ok, string yes = "Yes", string no = "No") {
  cout << (ok ? yes : no) << endl;
}

// Paste snippets here!!

//

void solve(std::string S) {
  bool ok = true;
  bool hasC = false;
  rep(i,S.size()){
    if(i==0) { if(S[i]!='A') ok = false; }
    else if(1<i && i+1<S.size() && S[i]=='C' && !hasC) { hasC = true; }
    else {
      if( !('a'<=S[i] && S[i]<='z') ) { 
        //dump(i, S[i]);
        ok = false;
      }
    }
  }
  //dump(hasC, ok);
  if(hasC && ok) cout << "AC" << endl;
  else cout << "WA" << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  cout.precision(12);
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 3624
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
#include<list>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int n,a[110],i;
  cin >> n;
  double ans=0;
  for(i=0;i<n;i++){
    cin >> a[i];
    double b=a[i];
    ans+=1/b;
  }
  printf("%.12lf\n",1/ans);
  return 0;
}

Measured memory_bytes: 3740
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
  ll a,b,k;
  cin >> a >> b >> k;
  if(a > k){
    cout << a - k << endl;
    cout << b << endl;
  }
  else
  { 
    cout << 0 << endl;
    if((a+b) > k)cout << a+b-k << endl;
    else{cout << 0 << endl;}
  }
   return 0;
} 
    


Measured memory_bytes: 256
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!size_t;
  auto dij = n.iota.map!(_ => readln.split.map!(to!int).array).array;

  auto d0 = new Dice(dij[0]);
  dij = dij[1..$];

  auto rollings = ["", "T", "TT", "TTT",
                   "N", "NT", "NTT", "NTTT",
                   "W", "WT", "WTT", "WTTT",
                   "E", "ET", "ETT", "ETTT",
                   "S", "ST", "STT", "STTT",
                   "NN", "NNT", "NNTT", "NNTTT"];

  foreach (di; dij) {
    auto d1 = new Dice(di);
    foreach (r; rollings) {
      auto d2 = d1.dup;
      d2.roll(r);

      if (d0.di == d2.di) {
        writeln("No");
        return;
      }
    }
  }

  writeln("Yes");
}

class Dice
{
  int[] di;

  this(int[] di)
  {
    this.di = di;
  }

  int top()   { return di[0]; }

  auto dup()
  {
    return new Dice(di.dup);
  }

  void roll(string si)
  {
    foreach (c; si) roll(c);
  }

  void roll(char d)
  {
    auto rolled = ['N': [1, 5, 2, 3, 0, 4],
                   'E': [3, 1, 0, 5, 4, 2],
                   'S': [4, 0, 2, 3, 5, 1],
                   'W': [2, 1, 5, 0, 4, 3],
                   'T': [0, 2, 4, 1, 3, 5]];

    di = di.indexed(rolled[d]).array;
  }
}

Measured memory_bytes: 3200
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    string s, t;
    cin>>s>>t;
    lli ans=0;
    rep(i,3){
        if(s[i]==t[i]){ 
            ans++;
        }
    }
    out(ans);
}


Measured memory_bytes: 3568
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		int cost = 0;
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
			if (i == 0) {
				cost = Math.abs(arr[i]);
			} else {
				cost += Math.abs(arr[i] - arr[i - 1]);
			}
		}
		cost += Math.abs(arr[n - 1]);
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
			int a;
			if (i == 0) {
				a = 0;
			} else {
				a = arr[i - 1];
			}
			int b = arr[i];
			int c;
			if (i == n - 1) {
				c = 0;
			} else {
				c = arr[i + 1];
			}
			sb.append(cost - Math.abs(a - b) - Math.abs(b - c) + Math.abs(a - c)).append("\n");
		}
		System.out.print(sb);
	}
}


Measured memory_bytes: 53480
D = int(input())
c = list(map(int, input().split()))
s = []
for i in range(D):
  s.append(list(map(int, input().split())))
  
sdictlist = []
sdictlistsorted = []
for i in range(D):
  onedict = {}
  for j in range(26):
    onedict[j] = s[i][j]
  sdictlist.append(onedict)
  onesorteddict = sorted(onedict.items(), key=lambda x:x[1], reverse=True)
  sdictlistsorted.append(onesorteddict)

lenpastmax = 24 #26まで設定できる
#26 -> 145419
#25 -> 18657778
#24 ->
pastlist = []
for i in range(D):
  j = 0
  while(sdictlistsorted[i][j][0] in pastlist):
    j += 1
  print(sdictlistsorted[i][j][0]+1)
  pastlist.append(sdictlistsorted[i][j][0])
  if(len(pastlist)==lenpastmax):
    pastlist.pop(0)

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

class Program
{
    static void Main(string[] args)
    {
        char[] S = Console.ReadLine().ToCharArray();
        long K = long.Parse(Console.ReadLine());
        for (int i = 0; i < S.Length&&i<K; i++)
        {
            if (S[i] != '1')
            {
                Console.WriteLine(S[i]);
                return;
            }
        }
        Console.WriteLine(1);
    }
}


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

#define int long long

vector<int> ret;

void divisor(int n) {
  for(int i = 1LL; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end());
  return ;
}
int ans=0;
signed main(){
    int N;
    cin>>N;
    divisor(N);
    
    for(int i=0LL;i<(int)ret.size();i++){
        {   
            //cerr<<"i="<<ret[i]<<endl;;

            if(N/(ret[i])-1 <= ret[i])continue;
            ans+=max(N/(ret[i])-1,0LL);
        
            
        }
    }
    cout<<max(0LL,ans)<<endl;




    


 
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <iterator>

using namespace std;

int main()
{
  int N; cin >> N;
  vector<int> v(N), u;
  for_each(v.begin(), v.end(), [](int& e) { cin >> e; });
  for (int i = 0; i < N-1; i++) {
    int S1 = accumulate(v.begin(), v.begin() + i+1, 0);
    int S2 = accumulate(v.begin() + i+1, v.end(), 0);
    u.push_back(abs(S1 - S2));
  }
  cout << *min_element(u.begin(), u.end()) << endl;
  return 0;
}


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

int N, W;

int main(int argc, char const *argv[]) {
  cin >> N >> W;
  vector<int> value(N);
  vector<int> weight(N);
  for (size_t i = 0; i < value.size(); i++) {
    cin >> value[i] >> weight[i];
  }
  int dp[110][10010];
  for (int w = 0; w <= W; ++w) dp[0][w] = 0;
  for (int i = 0; i < N; ++i) {
    for (int w = 0; w <= W; ++w) {
      if (w >= weight[i])
        dp[i + 1][w] = max(dp[i][w - weight[i]] + value[i], dp[i][w]);
      else
        dp[i + 1][w] = dp[i][w];
    }
  }
  cout << dp[N][W] << endl;

  return 0;
}



Measured memory_bytes: 7032
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo (1LL<<63-1)
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >


using namespace std;

int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};

const long double Pi=acos(-1),e=2.718;
const int N=1e5+10,mod=1e9+7;

ll sqrt5(ll x){
    for(ll i=-1e3;i<=1e3;i++){
        if(i*i*i*i*i==x)return i;
    }
    return oo;
}

int main ()
{
    FASTIO
    ll n;
    cin >> n;
    map<ll,ll> Map;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        Map[i-a[i]]++;
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        ans += Map[i+a[i]];
    }
    cout << ans << endl;
    return 0;
}
/**

*/


Measured memory_bytes: 27344
k = int(input())

c = [i for i in range(1, 10)]


for k in range(k + 1):
    n = c[k]
    m = n % 10
    for i in range(-1, 2):
        if 0 <= m + i <= 9:
            c.append(n * 10 + m + i)


print(c[k - 1])


Measured memory_bytes: 15724
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define Cout(s) cout<<s<<endl

bool sosuu(const int x)
{
	if (x == 2)return true;
	if (x < 2 || x % 2 == 0)return false;
	for (int i = 3; i * i <= x; i += 2)
		if (x % i == 0)return false;
	return true;
}
int gcd(int a, int b)
{
	if (a % b == 0) { return b; }
	else { return gcd(b, a % b); }
}
int ketawa(int a)
{
	if (a < 10)return a;
	else return a % 10 + ketawa(a / 10);
}

typedef long long ll;
using namespace std;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

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


int main()
{
	long double n;
	cin >> n;
	long double x = n / 3;
	printf("%.10Lf\n", x * x * x);

	return 0;
}


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

int main()
{
    ll ans;
    ll n, a, b;
    cin >> n >> a >> b;
    ans = n / (a + b) * a + min(n % (a + b), a);
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
object Main extends App{
    val n = scala.io.StdIn.readInt
    
    def get(in: Int): Int = {
        var count = 0
        var numbe = in
        while(numbe % 2 == 0){
            count += 1
            numbe /= 2
        }
        count
    }
    
    val list = (1 to n).map(get(_))
    println((1 to n).filter(get(_) == list.max).mkString)
}

Measured memory_bytes: 25408
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
struct BIT {
  vector<ll> data;
  BIT(int sz) {
    data.assign(++sz, 0);
  }
  ll sum(int k) {
    ll ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }
  void add(int k, ll x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
ll N;
vector<int> a;
bool f(int x) {
  vector<int> m(1, 0);
  FOR(i,0,N) {
    int tmp = m.back();
    tmp += a[i] >= x ? 1 : -1;
    m.push_back(tmp);
  }
  BIT bit(300005);
  ll sum = 0;
  bit.add(N + 1, 1);
  FOR(r,1,N+1) {
    sum += bit.sum(m[r] + N + 1);
    bit.add(m[r] + N + 1, 1);
  }
  return sum >= (ll(N)*(N+1)/2+1)/2;
}
int main() {
  cin >> N;
  a.resize(N);
  FOR(i,0,N) cin >> a[i];
  vector<int> b = a;
  sort(b.begin(), b.end());
  // 重複要素を削除
  b.erase(unique(b.begin(), b.end()), b.end());
  int l = -1, r = b.size();
  while(r - l > 1) {
    int m = (l + r) / 2;
    if(f(b[m])) {
      l = m;
    } else {
      r = m;
    }
  }
  cout << b[l] << endl;
}

Measured memory_bytes: 4428
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 



#define ll long long
#define ld long double
#define pb push_back
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<double, double>
#define mk make_pair
#define ff first
#define ss second
#define vi vector<int>
#define vii vector <pair <int , int>>
#define all(n) (n).begin(), (n).end()
#define INF 1000000000
#define pbds tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
void show(int a[],int n)
{
	for(int i=0;i<n;i++)
	{
	   cout<<a[i]<<" ";
	}
}

ll minCost(ll n,ll h[])
{
	ll dp[n+1]={0};
    
    dp[1]=0;
    ll ans1,ans2;
    ans1=ans2=INT_MAX;
    for(int i=2;i<=n;i++)
    {
    	if(i>1)
    	ans1=dp[i-1]+abs(h[i]-h[i-1]);
    	if(i>2)
    	ans2=dp[i-2]+abs(h[i]-h[i-2]);
    	
    	dp[i]=min(ans1,ans2);
    }
	return dp[n];
}

int main()
{
   ios::sync_with_stdio(0);
   cin.tie(0);
   ll n,h[100005];

   /*
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
  */ 
  cin>>n;
  for(int i=1;i<=n;i++)
  {
  	cin>>h[i];
  }
  cout<<minCost(n,h);
  return 0;
}

Measured memory_bytes: 5168
S = [int(input()) for i in range(5)]
R = list(S)
for i in range(5):
    R[i]=R[i]%10
#print(R)
for i in range(5):
    if R[i]!=0:
        R[i]=10-R[i]
w=sorted(R)
#print(w)
W=w[0]+w[1]+w[2]+w[3]
ans = sum(S) + W
#print(W)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
#include <iomanip>
#include <set>
#include <map>
#include <unordered_map>
#include <cassert>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

int main(){
    std::string s, t;
    std::cin >> s >> t;
    int ans = 0;
    for(int i=0; i<s.size(); i++){
        if(s[i]!=t[i]) ans++;
    }
    std::cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3916
def primes_eratosthenes(n:int) -> list:
    isprime = [True] * (n+1)
    isprime[0] = isprime[1] = False

    for i in range(2, n+1):
        if isprime[i]:
            j = i + i
            while j <= n:
                isprime[j] = False
                j += i
    return [i for i in range(2,n+1) if isprime[i]]


def add_factor(d: dict, n: int, primes: list) -> dict:
    for p in primes:
        while n%p == 0:
            n /= p
            d[p] = d.get(p, 0) + 1
        if n==1:
            break
    return d 


def solve(n):
    primes = primes_eratosthenes(n)

    d = {}

    for i in range(2,n+1):
        d = add_factor(d, i, primes)

    MOD = 10**9 + 7
    ans = 1
    for v in d.values():
        ans = ans * (v+1) % MOD
    
    return ans
    

def main():
    n = int(input())
    ans = solve(n)
    print(ans)


main()


Measured memory_bytes: 3064
//#pragma GCC optimise("Ofast,unroll-loops,no-stack-protector,fast-math");
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,popcnt,avx,avx2,tune=native")
          
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
          
using namespace std;
using namespace __gnu_pbds;
          
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
          
using matrix = vector<vector<ll>>;
template<typename T>
using kawaii_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
          
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
//#define int long long
 
void FAST_IO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.setf(ios::fixed);
    //cout.precision(20);
    #ifndef _offline
    //freopen("chess.in", "r", stdin);
    //freopen("chess.out", "w", stdout);
    #endif
}

signed main() {
    FAST_IO();
    int n, m, a, b;
    cin >> n >> m >> a >> b;
    for (int i = 0; i < b; ++i) {
        for (int j = 0; j < a; ++j) {
            cout << '0';
        }
        for (int j = a; j < m; ++j) {
            cout << '1';
        }
        cout << '\n';
    }
    for (int i = b; i < n; ++i) {
        for (int j = 0; j < a; ++j) {
            cout << '1';
        }
        for (int j = a; j < m; ++j) {
            cout << '0';
        }
        cout << '\n';
    }
} 

Measured memory_bytes: 1280