akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────

vi f(int v) {
	vi res(3, -1);
	int i = 0;
	if (v == 0) res[0] = 0;
	else {
		while (v) {
			res[i] = v % 10;
			v /= 10;
			i++;
		}
	}

	//rep(i, 3) cout << res[i] << " ";
	//cout << endl;
	return res;
}

int main() {
	int n, m;
	cin >> n >> m;
	vii  p(m);
	rep(i, m) cin >> p[i].first >> p[i].second;

	rep(x, 1000) {
		int keta = 1;
		int nx = x / 10;
		vi d(1, x % 10);

		while (nx) {
			keta++;
			d.push_back(nx % 10);
			nx /= 10;
		}

		if (keta != n) continue;
		bool ok = true;
		reverse(ASC(d));
		rep(i, m) {
			if (d[p[i].first - 1] != p[i].second) ok = false;
		}
		if (ok) {
			cout << x << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}


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



int main() {
    int n;string s; char last=0;
    cin>>n;
    bool flag=0;
    unordered_map <string ,bool>  mp;
    while(n--)
    {
        cin>>s;
        if(mp[s]==1) flag=1;
        else{
            if(last!=0)
            {
                if(last!=s[0])
                    flag=1;
            }
            last=s[s.size()-1];
        }
        mp[s]=1;
    }
    if(flag==0 ) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


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

int main(int argc, char const *argv[]) {
  string S;
  std::cin >> S;
  int price=700;
  if (S.at(0)=='o') {
     price+=100 ;/* code */
  }
  if (S.at(1)=='o') {
     price +=100;/* code */
  }
  if (S.at(2)=='o') {
  price +=100 ;/* code */
  }
  std::cout << price << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.math.BigInteger

private fun readStrings() = readLine()!!.split(" ")
private fun readInts() = readStrings().map { it.toInt() }

fun main(args: Array<String>) {
    val N = readInts()[0]
    val a = readInts()
    val bigA = a.map { BigInteger.valueOf(it.toLong())!! }
    val p = bigA.reduce { i1, i2 -> i1.multiply(i2) }
    val q = p.minus(BigInteger.valueOf(1))
    val ans = bigA.map { q.mod(it) }.reduce { i1, i2 -> i1 + i2 }
    println(ans.toString(10))
}

Measured memory_bytes: 45176
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
              int D = sc.nextInt();
        int T = sc.nextInt();
        int S = sc.nextInt();
        String res = D <= T * S ? "Yes" : "No";
        System.out.println(res);
    }
}

Measured memory_bytes: 26832
#include<stdio.h>
int main(void)
{
  long long m,n,k,i,t;
  
  while(1)
    {
      i=0;
      k=1;
      scanf("%lld %lld",&m,&n);
      if(m==0 && n==0)break;

      if(m<n)
	{
	  t=m;
	  m=n;
	  n=t;
	}

      while(k!=0)
	{
	  k=m%n;
	  m=n;
	  n=k;
	  i++;
	}
      printf("%lld %lld\n",m,i);
    }
  return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class B
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		long[] X = new long[N];
		long[] L = new long[N];
		for(long i = 0; i < N; i++)
		{
			X[i] = GetLong();
			L[i] = GetLong();
		}

		var range = new List<Tuple<long, long>>();
		for(long i = 0; i < N; i++)
			range.Add(Tuple.Create(X[i] - L[i], X[i] + L[i]));

		range.Sort((a, b) => a.Item2 != b.Item2 ? a.Item2.CompareTo(b.Item2) : a.Item1.CompareTo(b.Item1));

		long ans = 1;
		long tail = range[0].Item2;
		for(long i = 1; i < N; i++)
		{
			if(range[(int)i].Item1 < tail)
				continue;

			tail = range[(int)i].Item2;
			ans++;
		}
		WriteLine(ans);
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

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

template<long long mod>
class ModInt {
public:
    long long v;
    ModInt(long long v = 0) : v((v % mod + mod) % mod) {}
    ModInt operator+(ModInt t) {return ModInt((v + t.v) % mod);}
    ModInt operator-(ModInt t) {return ModInt((v - t.v + mod) % mod);}
    ModInt operator*(ModInt t) {return ModInt((v * t.v) % mod);}
    ModInt operator+=(ModInt t) {return *this = *this + t;} 
    ModInt operator-=(ModInt t) {return *this = *this - t;}
    ModInt operator*=(ModInt t) {return *this = *this * t;}
    ModInt operator-() {return ModInt(-v);}
    ModInt mpow(long long t) {
        if (t == 0) return ModInt(1);
        ModInt a = mpow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    ModInt inv() {mpow(mod - 2);}
    ModInt operator/(ModInt t) {return ModInt(v) * inv();}
    ModInt operator/=(ModInt t) {return *this = *this / t;}
    ModInt operator==(ModInt t) {return *this.v == t.v;}
    ModInt operator!=(ModInt t) {return *this.v != t.v;}
    friend ostream& operator<<(ostream& os, const ModInt& mi) {
        os << mi.v;
        return os;
    }
};

const long long mod = 1000000007;
using mint = ModInt<mod>;

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

	vector<mint> cnt(26, 0);

	for (int i = 0; i < n; i++) {
		cnt[s[i] - 'a'] += mint(1);
	}

	mint ans = 1;
	for (int i = 0; i < 26; i++) {
		ans *= cnt[i] + mint(1);
	}

	cout << ans - mint(1) << endl;
	
	return 0;
}


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

int main() {
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  map<string, int> mp;
  mp[s] = a;
  mp[t] = b;
  --mp[u];
  cout << mp[s] << ' ' << mp[t] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pll>
#define coutp cout << fixed << setprecision(12)
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

void solve()
{
    int n,m,t;
    cin>>n>>m>>t;
    set<pii> s;
    vi r(n+1,0),c(m+1,0);
    int mr=0,mc=0;
    for(int i=0;i<t;i++) {
        int x,y;
        cin>>x>>y;
        s.insert({x,y});
        r[x]++;
        c[y]++;
        mr=max(r[x],mr);
        mc=max(c[y],mc);
    }
    set<int> s1,s2;
    int ans=mr+mc-1;
    for(int i=1;i<=n;i++) {
        if(r[i]==mr) s1.insert(i);
    }
    for(int i=1;i<=m;i++) {
        if(c[i]==mc) s2.insert(i);
    }
    ll cnt=0;
    for(auto it:s) {
        if (s1.count(it.ff) && s2.count(it.ss)) cnt++;
    }
    ll siz = sz(s1)*sz(s2);
    if(cnt!=siz) ans++; 
    cout<<ans;

}

int main()
{
    fastio;
    int t;
    t = 1;
    //cin >> t;
    //int test=t;
    
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        cout << newl;
    }

    return 0;
}

Measured memory_bytes: 47768
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
typedef long long LL;
const int MAXN = 1e5 + 8;

char s[10];
int a[MAXN];
int main()
{
    #ifdef LOCAL
    //freopen("c.txt", "r", stdin);
    //freopen("c.out", "w", stdout);
    int T = 1;
    while(T--){
    #endif // LOCAL
    //ios::sync_with_stdio(false); cin.tie(0);

    int n, i, l, r, mid;
    bool f;
    scanf("%d", &n);
    l = 0, r = n - 1;

    printf("%d\n", l); fflush(stdout);
    scanf("%s", s);
    if(s[0] == 'M'){
        a[l] = 1;
    }
    else if(s[0] == 'F'){
        a[l] = 2;
    }
    else{
        a[l] = -1;
        return 0;
    }

    printf("%d\n", r);  fflush(stdout);
    scanf("%s", s);
    if(s[0] == 'M'){
        a[r] = 1;
    }
    else if(s[0] == 'F'){
        a[r] = 2;
    }
    else{
        a[r] = -1;
        return 0;
    }

    while(l + 1 < r){
        mid = (l+r)>>1;
        printf("%d\n", mid);  fflush(stdout);
        scanf("%s", s);
        if(s[0] == 'M'){
            a[mid] = 1;
        }
        else if(s[0] == 'F'){
            a[mid] = 2;
        }
        else{
            a[mid] = -1;
            return 0;
        }

        if((r - mid - 1)&1){
            if(a[mid] == a[r]){
                r = mid;
            }
            else{
                l = mid;
            }
        }
        else{
            if(a[r] != a[mid]){
                r = mid;
            }
            else{
                l = mid;
            }
        }
    }





    #ifdef LOCAL
    cout << endl;
    }
    #endif // LOCAL
    return 0;
}



Measured memory_bytes: 852
while True:    
    x, y = map(int, input().split())
    if x == 0 and y == 0:
        break
    if x < y:
        print("{} {}".format(x, y))
    if x > y:
        print("{} {}".format(y, x))
    if x == y:
        print("{} {}".format(x, y))


Measured memory_bytes: 5616
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
using namespace std;
long long a,b;
int main(){
	cin>>a>>b;
	long long gcd=__gcd(a,b);
	if(gcd==1){
		cout<<1;
		return 0;
	}
	long long ans=1;
	for(long long i=2;(long long)(i*i)<=gcd;i++){
		if(gcd%i==0)
		ans++;
		while(gcd%i==0)
		gcd/=i;
	}
	if(gcd>1)
	cout<<ans+1;
	else
	cout<<ans;
	re 0;
}

Measured memory_bytes: 256
import numpy as np
N = int(input())
# = map(int, input().split())
A = np.array(list(map(int, input().split())))
Q = int(input())
BC = [list(map(int, input().split())) for i in range(Q)]

zero = np.zeros(10**5+1)
total = np.sum(A)
#print(total)
for i in A:
    zero[i] += 1

for j in range(Q):
    total += (BC[j][1]-BC[j][0])*zero[BC[j][0]]
    zero[BC[j][1]] += zero[BC[j][0]]
    zero[BC[j][0]] = 0
    print(int(total))


Measured memory_bytes: 46796
/*
    if you can't see the repay
    Why not just work step by step
    rubbish is relaxed
    to ljq
*/
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#include <vector>
#include <stdlib.h>
#include <algorithm>
using namespace std;

#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define lc (rt<<1)
#define rc (rt<<11)
#define mid ((l+r)>>1)

typedef pair<int,int> pll;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int _inf = 0xc0c0c0c0;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll _INF = 0xc0c0c0c0c0c0c0c0;
const ll mod =  (int)1e9+7;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll ksm(ll a,ll b,ll mod){int ans=1;while(b){if(b&1) ans=(ans*a)%mod;a=(a*a)%mod;b>>=1;}return ans;}
ll inv2(ll a,ll mod){return ksm(a,mod-2,mod);}
void exgcd(ll a,ll b,ll &x,ll &y,ll &d){if(!b) {d = a;x = 1;y=0;}else{exgcd(b,a%b,y,x,d);y-=x*(a/b);}}//printf("%lld*a + %lld*b = %lld\n", x, y, d);
const int MAX_N = 405;
ll dp[MAX_N][MAX_N],arr[MAX_N],sum[MAX_N];
int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    int n;scanf("%d",&n);
    for(int i = 1;i<=n;++i) scanf("%lld",&arr[i]),sum[i] = sum[i-1]+arr[i];
    memset(dp,0x3f3f3f3f,sizeof(dp));
    for(int i = 1;i<=n;++i) dp[i][i] = 0;
    for(int len = 2;len<=n;++len)
    {
        for(int l = 1;l+len-1<=n;l++)
        {
            int r = l + len - 1;
            for(int k = l;k<r;++k)
            {
                dp[l][r] = min(dp[l][r],dp[l][k]+dp[k+1][r]+sum[r]-sum[l-1]);
            }
        }
    }
    printf("%lld\n",dp[1][n]);
    //fclose(stdin);
    //fclose(stdout);
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define endl enjoy_codeforces
int main(){
    int A,B,m;std::cin>>A>>B>>m;
    std::vector<int>a(A),b(B);
    for(int&x:a)std::cin>>x;
    for(int&x:b)std::cin>>x;
    int ans=*std::min_element(a.begin(),a.end())+*std::min_element(b.begin(),b.end());
    while(m--){
        int x,y,c;std::cin>>x>>y>>c;
        int z=a.at(x-1)+b.at(y-1)-c;
        if(z<ans)ans=z;
    }
    std::cout<<ans<<'\n';
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  if (n >= 1800) { cout << 1 << endl; return 0; }
  if (n >= 1600)  { cout << 2 << endl; return 0; }
  if (n >= 1400) { cout << 3 << endl; return 0; }
  if (n >= 1200) { cout << 4 << endl; return 0; }
  if (n >= 1000) { cout << 5 << endl; return 0; }
  if (n >= 800)  { cout << 6 << endl; return 0; }
  if (n >= 600)  { cout << 7 << endl; return 0; }
  if (n >= 400)  { cout << 8 << endl; return 0; }
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	int N, X, T;
	cin >> N >> X >> T;

	if (N % X == 0) {
		cout << N / X * T << endl;
	}
	else {
		cout << (N / X + 1) * T << endl;
	}
}


Measured memory_bytes: 3636
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
////////////////////////////

ll comb(ll n,ll k){
    ll res=1;
    rep(i,0,k-1){
        res*=(n-i);
    }
    rep(i,1,k){
        res/=i;
    }
    return res;
}

int main(){fastio
    string s;cin>>s;
    ll n,k;
    n=s.size();
    cin>>k;
    ll ans=0;
    if(n-1>=k)ans+=comb(n-1,k)*(ll)pow(9,k);
    ll top=s[0]-'0';
    if(n-1>=k-1)ans+=(top-1)*comb(n-1,k-1)*(ll)pow(9,k-1);
    string ze;
    ze+=s[0];
    rep(i,1,n-1)ze+='0';
    if(k==1){
        string t=ze;
        if(t<=s)ans++;
    }else if(k==2){
        rep(i,1,n-1){
           
                rep(xi,1,9){
                    
                        string t=ze;
                        t[i]=char('0'+xi);
                        if(t<=s)ans++;
                    
                }
            
        }
    }else{
        rep(i,1,n-1){
            rep(j,i+1,n-1){
                rep(xi,1,9){
                    rep(xj,1,9){
                        string t=ze;
                        t[i]=char('0'+xi);
                        t[j]=char('0'+xj);
                        if(t<=s)ans++;
                    }
                }
            }
        }
    }
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

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




// a^n mod を計算する
long int modpow(long int a, long int n, long int mod) {
    long int res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = (a * a) % mod;
        n >>= 1;
    }
    return res;
}

long int modcomb(long int a, long int b, long int mod){
    long int res = 1;
    for(long int i = a; i > a - b; i--){
        res *= i % mod;
        res %= mod;
    }
    res %= mod;
    for(long int i = 1; i <= b; i++){
        long int i_inv = modpow(i, mod - 2, mod);
        res *= i_inv % mod;
        res %= mod;
    }
    res %= mod;
    // cout << res << endl;
    return res;
}



int main(){
    long int mod = 1000000007;
    long int n;
    cin >> n;
    // n = 2;
    long int a[n];
    rep(i, n) cin >> a[i];
    // for (long int i = 0; i < n; i++){
    //     a[i] = (1152921504606846976 / 2) - i;
    // }
    // cout << (1152921504606846976 - 1) % mod << endl;;
    // 60桁分の1の数
    long int num[61];
    fill(num, num + 61, 0);
    rep(i, n) rep(j, 61){
        if (((a[i] >> j) & 1) == 1){
            num[j]++;
        }
    }
    // rep(i, 61) cout << num[i] << " ";
    // cout << endl;
    // 2のi乗の数がa[i]
    long int ans[61];
    fill(ans, ans + 61, 0);
    rep(i, 61){
        long int num1 = num[i];
        long int num0 = n - num1;
        ans[i] = num0 * num1;
        ans[i] %= mod;
    }
    // rep(i, 60) cout << ans[i] << " ";
    // cout << endl;   
    long int sm = 0;
    long int bin = 1;
    // int count = -1;
    rep(i, 61){
        // count++;
        sm += bin * ans[i];
        sm %= mod;
        bin *= 2;
        bin %= mod;
    }
    // cout << count << endl;
    cout << sm << endl;
}

Measured memory_bytes: 2560
import numpy

N = int(input())

la = list()
for i in range(N):
    la.append(int(input()))

max1 = sorted(la)[-1]
max2 = sorted(la)[-2]

for i in range(N):
    if la[i] == max1:
        print(max2)
    else:
        print(max1)

Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
const int INF = 1 << 29;
const ll LINF = 1l << 61;
const ld PI = abs(acos(-1));
#define pq priotity_queue
#define pb push_back
#define mp make_pair
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define cbuf(buf, init) memset(buf, init, sizeof(buf))

template <class T>
constexpr T modp(T x, T y)
{
    return (y + x % y) % y;
}
template <class T>
constexpr T sq(T x)
{
    return x * x;
}
template <class T>
constexpr double divd(T x, T y)
{
    static_cast<double>(x) / static_cast<double>(y);
}

template <class T>
T nextInput()
{
    T t;
    cin >> t;
    return t;
}

#define netint nextInput<ll>()
#define netstr nextInput<string>()

template <class T>
void print(T&& t)
{
    cout << forward<T&&>(t) << endl;
}

void print(double t) { cout << fixed << setprecision(14) << t << endl; }

//

ll C[1000], S[1000], F[1000];
ll dp[1000];

int main()
{
    //
    ll N = netint;
    rep(i, 0, N - 1)
    {
        C[i] = netint;
        S[i] = netint;
        F[i] = netint;
    }

    rrep(i, N - 1, 0)
    {
        if (i == N - 1) {
            dp[i] = 0;
            continue;
        }
        ll t = 0;
        rep(j, i, N - 1)
        {
            if (t < S[j]) t = S[j];
            while (t % F[j] != 0) t++;
            t += C[j];
        }
        dp[i] = t;
    }
    rep(i, 0, N) { cout << dp[i] << endl; }
}


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

const int maxn=2005;
int gcd(int a,int b)
{
	return b==0?a:gcd(b,a%b);
}


int n,a[maxn];
int vis[maxn];
vector<int>g[maxn],gg[maxn];
int rd[maxn];vector<int>ans;
priority_queue<int>pq;

void dfs(int x)
{
	vis[x]=1;
	for(int i=0;i<(int)g[x].size();i++)
	{
		int to=g[x][i];
		if(vis[to])continue;
		gg[x].push_back(to);
		rd[to]++;
		dfs(to);
	}
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(i==j)continue;
			if(gcd(a[i],a[j])!=1)
			{
				g[i].push_back(j);
			}
		}
	}
	
	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
		{
			dfs(i);
		}
	}
	
	for(int i=1;i<=n;i++)
	{
		if(!rd[i])
		{
			pq.push(i);
		}
	}
	
	while(!pq.empty())
	{
		int x=pq.top();pq.pop();
		ans.push_back(a[x]);
		for(int i=0;i<(int)gg[x].size();i++)
		{
			int to=gg[x][i];
			rd[to]--;
			if(!rd[to])
			{
				pq.push(to);
			}
		}
	}
	
	for(int i=0;i<(int)ans.size();i++)
	{
		printf("%d ",ans[i]);
	}
	
	return 0;
}

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

int main(){
  ll r,d,x;
  cin >> r >> d >> x;
  for ( int i = 0; i < 10; ++i ) {
    x = r * x - d;
    cout << x << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  if(a > b){
    rep(i, a) cout << b;
  } else {
    rep(i, b) cout << a;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int B[2010], W[2010], n, D[2010][2010], S[4010];
int BW[2010][2010], WB[2010][2010];
int BB[2010], WW[2010];
int main() {
	int i, a, j;
	char p[3];
	scanf("%d", &n);
	for(i=1;i<=n+n;i++){
		scanf("%s", p);
		scanf("%d", &a);
		if (p[0] == 'W') {
			W[a] = i;
		}
		else {
			B[a] = i;
		}
	}
	D[0][0] = 0;
	for (i = 0; i <= n; i++) {
		if (i) {
			BB[i] = S[B[i]];
			for (j = 1; j <= B[i]; j++)S[j]++;
		}
		for (j = 1; j <= n; j++) {
			BW[i][j] = S[W[j]];
		}
	}
	for (i = 0; i <= n + n; i++)S[i] = 0;
	for (i = 0; i <= n; i++) {
		if (i) {
			WW[i] = S[W[i]];
			for (j = 1; j <= W[i]; j++)S[j]++;
		}
		for (j = 1; j <= n; j++) {
			WB[i][j] = S[B[j]];
		}
	}
	for (i = 0; i <= n; i++) {
		for (j = 0; j <= n; j++) {
			if (!i && !j)continue;
			int t = 1e9;
			if (i) t = min(t, D[i - 1][j] + BB[i] + WB[j][i]);
			if (j) t = min(t, D[i][j - 1] + WW[j] + BW[i][j]);
			D[i][j] = t;
		}
	}
	printf("%d\n", D[n][n]);
}

Measured memory_bytes: 47488
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,N) for(int i=0; i<N; i++) ;
int main() {
long double N,M;
cin>>N>>M;
vector<long double>A(N);
long double count=0;
for(int i=0; i<N; i++){
    cin>>A.at(i);
    count+=A.at(i);
}
count=count/(4*M);
long double answer=0;
for(int i=0; i<N; i++){
    if(count<=A.at(i)){
        answer++;
    }
}
if(M<=answer){
    cout<<"Yes"<<endl;
}
else
cout<<"No"<<endl;
}


Measured memory_bytes: 3764
#include<iostream>

int main(void){
    int n;
    std::cin >> n;
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            if(n == i * j){
                std::cout << "Yes" << std::endl;
                return 0;
            }
        }
    }
    std::cout << "No" << std::endl;
    return 0;
}

Measured memory_bytes: 3620
function main(arg){
    arg = arg.split("\n")
    var _tmp  = arg[0].split(" ")
    var h = _tmp[0]
    var w = _tmp[1]
    var data = []
    var buffer_w = []
    var buffer_h = []
    arg.shift()

    var i = 0
    var j = 0
    for (i = 0;i < h; i++) {
        data.push(arg[i].split(""))
    }

    for (i = 0; i < h; i++) {        
        if (data[i].join("").indexOf("#") === -1) {
            buffer_w.push(i)
        }
    }

    for (i = 0; i < w; i++) {
        var text = ""
        for (j = 0; j < h;j++) {
            text += data[j][i]
        }

        if (text.indexOf("#") === -1) {
            buffer_h.push(i)
        }
    }

    for (i = 0;i<h;i++) {
        var text = ""
        if (buffer_w.indexOf(i) !== -1) {
            continue;
        }
        for (j=0;j<w;j++) {
            if (buffer_h.indexOf(j) === -1) {
                text += data[i][j]
            }
        }
        if (text !== "") {
            console.log(text)
        }
    }

    // console.log(JSON.stringify(data))
    // console.log(JSON.stringify(buffer_w))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

const ll mod = 1000000000+7;

int main(){
    int n;  cin >> n;
    vector<ll>a(n);
    rep(i, n)   cin >> a[i];
    vector<ll>sum(n);
    sum[0] = a[0];
    for(int i = 1; i < n; i++){
        sum[i] = sum[i-1] + a[i];
        sum[i] %= mod;
    }
    ll ans = 0;
    rep(i, n-1){
        ll tmp = mod + sum[n-1] - sum[i];
        tmp %= mod;
        tmp *= a[i];
        tmp %= mod;
        ans += tmp;
        ans %= mod;
    }
    cout << ans << endl;
}



Measured memory_bytes: 6408
let () = Scanf.scanf "%d %d %d" @@ fun a b k ->
    let rec f n = function
        | 1 when a mod n == 0 && b mod n == 0 -> n
        | k when a mod n == 0 && b mod n == 0 -> f (n-1) (k-1)
        | k -> f (n-1) k
    in Printf.printf "%d" @@ f 100 k


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

int n, pos;
vector<int> pre, in ,post;

void rec(int l, int r) {
    if(l >= r) return ;
    int root = pre[pos++];
    int m = distance(in.begin(),find(in.begin(), in.end(), root));
    rec(l,m);
    rec(m+1, r);
    post.push_back(root);
}

void solve() {
    pos = 0;
    rec(0,pre.size());
    for(int i = 0; i<n; i++) {
        if(i) cout << " ";
        cout << post [i];
    }
    cout << endl;
}

int main() {
    int k;
    cin >> n;
    for (int i = 0; i<n; i++) {
        cin >> k;
        pre.push_back(k);
    }
    for(int i = 0; i<n; i++) {
        cin >> k;
        in.push_back(k);
    }
    
    solve();
    
    return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

template <class T> class SegmentTree {
public:
  SegmentTree(const int n, const T id, function<T(T, T)> op,
              function<T(T, T)> updateOp);
  void update(const int index, const T value);
  T find(const int l, const int r);

private:
  int leftChildIndex(const int parent);
  int rightChildIndex(const int parent);
  int parent(const int child);
  int leaf(const int index);
  T query(const int l, const int r, const int node, const int al, const int ar);

private:
  vector<T> data;
  int leafNum;
  T id;
  function<T(T, T)> op;
  function<T(T, T)> updateOp;
};

template <class T>
SegmentTree<T>::SegmentTree(const int n, const T id, function<T(T, T)> op,
                            function<T(T, T)> updateOp)
    : id(id), op(op), updateOp(updateOp) {
  leafNum = 1;
  while (leafNum < n)
    leafNum *= 2;
  data = vector<T>(2 * leafNum - 1, id);
}

template <class T> int SegmentTree<T>::leftChildIndex(const int parent) {
  return parent * 2 + 1;
}

template <class T> int SegmentTree<T>::rightChildIndex(const int parent) {
  return parent * 2 + 2;
}

template <class T> int SegmentTree<T>::parent(const int child) {
  return (child - 1) / 2;
}

template <class T> int SegmentTree<T>::leaf(const int index) {
  return index + leafNum - 1;
}

// [l,r)で探す
template <class T> T SegmentTree<T>::find(const int l, const int r) {
  return query(l, r, 0, 0, leafNum);
}

template <class T>
T SegmentTree<T>::query(const int l, const int r, const int node, const int al,
                        const int ar) {
  if (r <= al || ar <= l)
    return id;
  if (l <= al && ar <= r)
    return data[node];
  int mid = (al + ar) / 2;
  T leftValue = query(l, r, leftChildIndex(node), al, mid);
  T rightValue = query(l, r, rightChildIndex(node), mid, ar);
  return op(leftValue, rightValue);
}

template <class T> void SegmentTree<T>::update(const int index, const T value) {
  int i = leaf(index);
  data[i] = updateOp(data[i], value);
  while (i > 0) {
    i = parent(i);
    data[i] = op(data[rightChildIndex(i)], data[leftChildIndex(i)]);
  }
}

int main() {
  ll n, m;
  cin >> n >> m;
  priority_queue<pair<ll, pair<ll, ll>>, vector<pair<ll, pair<ll, ll>>>,
                 greater<pair<ll, pair<ll, ll>>>>
      lrc, clr;

  REP(i, m) {
    ll l, r, c;
    cin >> l >> r >> c;
    l--;
    r--;
    lrc.push(make_pair(l, make_pair(r, c)));
  }

  SegmentTree<ll> seg(n, (1LL << 60),
                      [](ll a, ll b) -> ll { return min(a, b); },
                      [](ll a, ll b) -> ll { return min(a, b); });
  seg.update(0, 0);

  while (!lrc.empty()) {
    auto p = lrc.top();
    lrc.pop();
    ll l = p.first, r = p.second.first, c = p.second.second;
    auto mi = seg.find(l, r) + c;
    seg.update(r, mi);
  }
  if (seg.find(n - 1, n) == (1LL << 60)) {
    cout << -1 << endl;
  } else {
    cout << seg.find(n - 1, n) << endl;
  }
}


Measured memory_bytes: 5360
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

typedef pair<int, int> P;

bool pairCompare(const P &p1, const P &p2)
{
    return p1.second > p2.second;
}

int main(int argc, char const *argv[])
{
    priority_queue<int, vector<int>, greater<int>> que;
    int N, M;
    cin >> N >> M;

    vector<P> v;

    for (int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        que.push(a);
    }
    for (int i = 0; i < M; i++)
    {
        int b, c;
        cin >> b >> c;

        v.push_back(P(b, c));
    }

    sort(v.begin(), v.end(), pairCompare);

    for (int i = 0; i < M; i++)
    {
        int b, c;
        //cout << v[i].first << " " << v[i].second << endl;
        b = v[i].first;
        c = v[i].second;
        for (int j = 0; j < b; j++)
        {
            if (que.top() < c)
            {
                que.pop();
                que.push(c);
            }
            else
            {
                break;
            }
        }
    }

    long long ans = 0;
    while (!que.empty())
    {
        //cout << que.top() << endl;
        ans += que.top();
        que.pop();
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
	int q; cin >> q;
	for (int i = 0; i < q; i++) {
		ll a, b; cin >> a >> b;
		ll r = (ll)sqrt(a * b), ans = r * 2;
		if (a != b)ans--;
		if (a * b <= r * r)ans--;
		if (a * b <= r * (r + 1))ans--;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  unordered_map<int,int> hash;
  for(int i=1;i<=n;i++){
    int x;
    cin>>x;
    hash[x]=i;
  }
  for(int i=1;i<=n;i++) cout<<hash[i]<<" ";
  return 0;
}

Measured memory_bytes: 4900
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>

using namespace std;

const int maxn=1010;
int c[maxn][maxn];
string s1,s2;

int lcs(int x,int y)
{
	for(int i=1;i<=x;i++)c[i][0]=0;
	for(int j=1;j<=y;j++)c[0][j]=0;
	s1=' '+s1;
	s2=' '+s2;//插入空格
	int maxl=0; 
	for(int i=1;i<=x;++i){
		for(int j=1;j<=y;++j){
			if(s1[i]==s2[j]){
				c[i][j]=c[i-1][j-1]+1;
			}else{
				c[i][j]=max(c[i-1][j],c[i][j-1]);
			}
			maxl=max(maxl,c[i][j]);//每次取最大值并更新 
		}
	}
	return maxl;
}

int main()
{
	int t;
	cin>>t;
	while(t--){
		memset(c,0,sizeof(c));
		cin>>s1>>s2;
		int len1=s1.length();
		int len2=s2.length();
		int ans=lcs(len1,len2);
		cout<<ans<<endl;
	}
	return 0;	
}


Measured memory_bytes: 7156
#include <iostream>
#include <string>
#include <vector>

using namespace std;

string s;
int index;

vector<char> st;

bool cat() {
    for (int i = 0; i < s.size(); i++) {
        st.push_back(s[i]);
        if (st.size() >= 3 && st[st.size()-3] == 'm' && st[st.size()-2] == 'e' && st[st.size()-1] == 'w') {
            st.pop_back();
            st.pop_back();
            st.pop_back();
        }
        if (st.empty() && i != s.size()-1) return false;
    }

    if (st.empty()) return true;
    return false;
}

int main() {
    cin >> s;
    index = 0;
    cout << (cat() ? "Cat" : "Rabbit") << endl;
    return 0;
}

Measured memory_bytes: 1204
#include <cstdio>
#include <vector>

using namespace std;

vector<int> factors[1000005];
bool composite[1000005];
int mu[1000005];
int n;
int a[200005];
int f[1000005];
int func[1000005];
/* f[i] = sum of all values currently seen that are multiples of i */

#define ll long long
#define MOD 998244353
#define mul(a, b) (((ll)(a) * (ll)(b)) % MOD)

int main()
{
    for (int i = 1; i <= 1000000; i++) {
        for (int j = i; j <= 1000000; j += i) factors[j].push_back(i);
    }
    for (int i = 2; i <= 1000000; i++) {
        if (composite[i]) continue;
        for (int j = i * 2; j <= 1000000; j += i) {
            composite[j] = true;
        }
    }
    for (int i = 1; i <= 1000000; i++) mu[i] = 1;
    for (int i = 2; i <= 1000000; i++) {
        if (composite[i]) continue;
        if (i <= 1000) {
            for (int j = i * i; j <= 1000000; j += i * i) mu[j] = 0;
        }
        for (int j = i; j <= 1000000; j += i) mu[j] = -mu[j];
    }

    for (int i = 1; i <= 1000000; i++) {
        for (int j = i; j <= 1000000; j += i) {
            func[j] += i * mu[i];
        }
    }

    for (int i = 1; i <= 1000000; i++) {
        if (func[i] < 0) func[i] += MOD;
    }

    //fprintf(stderr, "done");

    scanf("%d", &n);
    int ans = 0;
    for (int i = 1; i <= n; i++) scanf("%d", a + i);
    for (int i = 1; i <= n; i++) {
        for (int idx = 0; idx < factors[a[i]].size(); idx++) {
            int gcdval = factors[a[i]][idx];
            ans += mul(f[gcdval], mul(a[i] / gcdval, func[gcdval]));
            if (ans >= MOD) ans -= MOD;
        }
        for (int idx = 0; idx < factors[a[i]].size(); idx++) {
            int factor = factors[a[i]][idx];
            f[factor] += a[i];
            if (f[factor] >= MOD) f[factor] -= MOD;
        }
        //printf("%d %d\n", i, ans);
    }
    printf("%d", ans);
    return 0;
}


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

int main(){

    int a,b,c;
    cin >> a >> b >> c;

    if(b-a==c-b){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

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

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    vector<int> v;
    map<int, int> mp;
    for(int i=0;i<n;++i){
        int a;
        cin >> a;
        v.push_back(a);
        mp[a]++;
    }
    sort(v.rbegin(), v.rend());
    int ans = 0;
    for(auto e: v){
        if(mp[e] == 0)continue;
        int num = 1;
        while(num <= e)num <<= 1;
        //cerr << num << endl;
        if(num-e != e && mp[num-e] > 0 || num-e == e && mp[e] > 1){
            ans++;
            mp[num-e]--;
        }
        mp[e]--;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 19828
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	int n,i,j,x,y,h=0,k,yn,hn;
	cin>>n;
	int a[n+1][3];
	rep(i,n){
		cin>>a[i+1][0]>>a[i+1][1]>>a[i+1][2];
	}
	
	for(i=0;i<=100;i++){//y
		for(j=0;j<=100;j++){//x
		
			int hmax=(1<<30) + (1<<29);
			int hmin=-1;
			for(k=1;k<=n;k++){
				int hn=abs(a[k][0]-j)+abs(a[k][1]-i);
				if(a[k][2]==0){
					hmax=min(hmax,hn);
				}
				else{
					hmin=max(hmin,a[k][2]+hn);
					hmax=min(hmax,a[k][2]+hn);
				}
//				cout<<hn<<" "<<hmin<<" "<<hmax<<endl;
			}
			
			if(hmax==hmin){
				cout<<j<<" "<<i<<" "<<hmin<<endl;
				return 0;
			}
		}
	}
	
	
//////////////////////////////////////////////////////
return 0;}











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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#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 mp(v1, v2)       make_pair(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 n;
  cin >> n;
  arrll(a,n);

  map<ll, ll> mpL, mpR;
  rep(i,n){
    ll l=i+1+a[i];
    ll r=i+1-a[i];

    if(mpL.find(l)==mpL.end()){
      mpL.emplace(l, 1);
    } else {
      mpL[l]++;
    }

    if(mpR.find(r)==mpR.end()){
      mpR.emplace(r, 1);
    } else {
      mpR[r]++;
    }
  }

  ll ans=0;
  for(auto itr : mpL){
    if(mpR.find(itr.first)!=mpR.end()){
      ans += itr.second * mpR[itr.first];
    }
  }

  prt(ans);

}


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

int main(){

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


}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define int long long int
#define double long double
#define inf (int)(1e15)
#define all(x) (x).begin(), (x).end()
#define pair pair<int, int>
typedef vector<int> vi;   // Vector of long long
typedef vector<vi> vvi;   // Vector of vi
typedef vector<pair> vii; // Vector of pairs
typedef vector<vii> vvii; // Vector of Vector of pairs
typedef vector<bool> vb;  // Vector of bool
#define pq priority_queue // Max heap (To convert to min heap, use negative sign before every value)
#define ff first          // For pairs
#define ss second
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, -1, 0, 1};
const int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}, dy8[] = {1, -1, 1, 0, -1, 1, -0, -1};
#define testcases(t) \
    int(t);          \
    cin >> (t);      \
    while ((t)--)
int power(int a, int b)
{
    int res = 1;
    while (b > 0)
    {
        if (b & 1)
        {
            res = (res * a) % mod;
        }
        a = (a * a) % mod;
        b = b / 2;
    }
    return res;
}
int modinv(int a)
{
    return power(a, mod - 2);
}
int n, num, cnt, ans = 0, lcm = 1;
vi a, prime_fac;
signed main()
{
    cin >> n;
    a.resize(n + 1);
    prime_fac.assign(((int)(1e6 + 5)), 0);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        num = a[i];
        for (int i = 2; i * i <= num; i++)
        {
            cnt = 0;
            while (num % i == 0 && num > 0)
            {
                cnt++;
                num /= i;
            }
            prime_fac[i] = max(prime_fac[i], cnt);
        }
        if (num > 1)
            prime_fac[num] = max(prime_fac[num], 1ll);
    }
    for (int i = 2; i <= (int)(prime_fac.size()); i++)
    {
        lcm = (lcm * power(i, prime_fac[i])) % mod;
    }
    // cout << lcm << endl;
    // return 0;
    for (int i = 0; i < n; i++)
    {
        ans += ((lcm * modinv(a[i]))) % mod;
    }
    ans %= mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8192
N, x = map(int, input().split())
alist = list(map(int, input().split()))
ans = 0
if alist[0] > x:
    ans += alist[0] - x
    alist[0] = x
for i in range(1, N):
    cost = alist[i] + alist[i-1]
    if cost > x:
        over = cost - x
        ans += over
        alist[i] -= over
print(ans)

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] array = new int[3];
		for(int i = 0; i < 3; i++)
			array[i] = sc.nextInt();
		Arrays.sort(array);
		System.out.println(array[2] * 10 + array[1] + array[0]);
	}
}


Measured memory_bytes: 23252
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            //var c = Console.ReadLine();
            //var NK = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var Q = long.Parse(Console.ReadLine());
            var dic = new Dictionary<long, long>();
            for (int i = 0; i < N; i++)
            {
                if (dic.ContainsKey(A[i]))
                {
                    dic[A[i]]++;
                }
                else
                {
                    dic.Add(A[i], 1);
                }
                
            }

            long sum = A.Sum();

            for (int i = 0; i < Q; i++)
            {
                var BC = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
                var B = BC[0];
                var C = BC[1];
                if (!dic.ContainsKey(B))
                {
                    Console.WriteLine(sum);
                    continue;
                }
                sum -= B * dic[B];
                sum += C * dic[B];
                if (dic.ContainsKey(C))
                {
                    dic[C] += dic[B];
                }
                else
                {
                    dic.Add(C, dic[B]);
                }
                
                dic[B] = 0;
                Console.WriteLine(sum);

            }

            


        }
    }

}


Measured memory_bytes: 49320
def solve(target: int, dislike_numbers: set) -> int:
    for i in range(target, target * 10):
        used_numbers = set(int(n) for n in str(i))
        if not used_numbers.intersection(dislike_numbers):
            return i

target, n = map(int, input().split())
values = map(int, input().split())
print(solve(target, set(values)))

Measured memory_bytes: 3060