akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n,k;
ll a[200000];
ll cnt[200001];

int main(){
	cin >> n >> k;
	rep(i,n){
		cin >> a[i];
		cnt[a[i]]++;
	}
	vector<ll> vl;
	rep(i,200000+1){
		if(cnt[i] >= 0)vl.push_back(cnt[i]);
	}
	sort(ALL(vl));
	reverse(ALL(vl));
	k = min(k,(ll)vl.size());
	rep(i,k)n -= vl[i];
	cout << n << endl;
}




Measured memory_bytes: 5492
a, b, c, x, y = map(int, input().split())

cost_a = a * x
w_x = x

cost_b = b * y
w_y = y

if c * 2 < a + b:
    w_c = min(x, y) * 2
    w_x = x - min(x, y)
    w_y = y - min(x, y)

    if w_x > 0:
        if a > c * 2:
            w_c += w_x * 2
            w_x = 0

    if w_y > 0:
        if b > c * 2:
            w_c += w_y * 2
            w_y = 0

    print(w_x * a + w_y * b + w_c * c)
else:
    print(cost_a + cost_b)





Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define fr(i,x,n) for(int i=x;i<=n;i++)
#define rf(i,n,x) for(int i=n;i>=x;i--)
#define mst(x,i) memset(x,i,sizeof(x))
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define PB push_back
#define X first
#define Y second
using namespace std;
typedef long long LL;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int maxn=1E5+5;
const int maxm=1E5+5;
const int inf=0x3f3f3f3f;
const LL INF=0x3f3f3f3f3f3f3f3f;
const LL mod=1E9+7;
const double eps=1E-6;
const double PI=acos(-1.0);
template<class T>
bool scan(T &ret){
    char c;int sgn;
    if(c=getchar(),c==EOF) return 0;
    while(c!='-'&&(c<'0'||c>'9')) c=getchar();
    sgn=(c=='-')?-1:1;
    ret=(c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
    ret*=sgn;
    return 1;
}
template<class T>
T gcd(T a,T b){
    return b==0?a:gcd(b,a%b);
}
template<class T>
T qpow(T a,T b,T mod){
    T ret=1;
    a%=mod;
    while(b){
        if(b&1) ret=(a*ret)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return ret%mod;
}
void solve(){
    int a,b,k;cin>>a>>b>>k;
    k--;
    int _gcd=__gcd(a,b);
    vector<int> t;
    t.PB(_gcd);
    rep1(i,sqrt(_gcd)){
        if(_gcd%i==0) t.PB(i),t.PB(_gcd/i);
    }
    sort(t.begin(),t.end(),greater<int>());
    t.erase(unique(t.begin(),t.end()),t.end());
    //rep(i,t.size()) cout<<t[i]<<" \n"[i==t.size()-1];
    cout<<t[k]<<endl;
}
int main(){
#ifdef LOCAL
    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif
    //IOS;
    int T=1;
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int l = sc.nextInt();
    int r = sc.nextInt();
    int d = sc.nextInt();
    int cnt = 0;

    for (int i = l; i <= r; i++) {
      if ((i % d) == 0) {
        cnt++;
      }
    }

    System.out.println(cnt);

  }
}

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

int main()
{
	int a,b,c,d,sum=0;
	string s;

	cin>>s;
    if(s[0]=='9' ||s[1]=='9')
        cout<<"Yes";
    else
    {
        cout<<"No";
    }
    
	
	return 0;
}
	

Measured memory_bytes: 256
#include<iostream>
#include <vector>
class Coordinate {
	struct Relation {
		Coordinate *origin{ nullptr };
		int distance{ 0 };
		Relation() {};
		Relation(Coordinate* o, int dist) :origin{ o }, distance{ dist } {}
	};
	Relation origin;
	enum class Coordinate_type :bool {
		origin = true, relational = false
	};
	Coordinate_type c_type{ Coordinate_type::origin };
	bool is_non_paradoxical(Coordinate &other, int distance) {
		auto this_relation = relation();
		auto other_relation = other.relation();
		if (this_relation.origin != other_relation.origin) return true;
		else return this_relation.distance == other_relation.distance + distance;
	}
	Relation relation() {
		switch (c_type) {
		case Coordinate_type::origin: return Relation{ this, 0 };
		case Coordinate_type::relational:
			auto prev = origin.origin->relation();
			return origin = Relation(prev.origin, origin.distance + prev.distance);
		}
	}
public:
	Coordinate() {}
	bool set_relation(Coordinate &other, int distance) {
		if (is_non_paradoxical(other, distance)) {
			if (relation().origin == other.relation().origin) return true;
			switch (c_type) {
			case Coordinate_type::origin:
				origin = Relation(&other, distance);
				c_type = Coordinate_type::relational;
				break;
			case Coordinate_type::relational:
				origin.origin->set_relation(other, distance - origin.distance);
				break;
			}
			return true;
		}
		else return false;
	}
};
int main() {
	int n, m;
	std::cin >> n >> m;
	std::vector<Coordinate> peoples(n);
	bool is_paradoxical{ false };
	{
		int l, r, d;
		for (auto i = 0; i < m && !is_paradoxical; ++i) {
			std::cin >> l >> r >> d;
			if (!peoples[l - 1].set_relation(peoples[r - 1], d)) {
				is_paradoxical = true;
			}
		}
	}
	if (is_paradoxical) std::cout << "No" << std::endl;
	else std::cout << "Yes" << std::endl;
}

Measured memory_bytes: 2560
#include <vector>
#include <bitset>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
using namespace std;

int pow2(int a){
    return a*a;
}

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<int> x(n), y(n), r(n), c(n);
        for(int i=0; i<n; ++i)
            cin >> x[i] >> y[i] >> r[i] >> c[i];

        vector<vector<bool> > cant(n, vector<bool>(n, false));
        for(int i=0; i<n; ++i){
            for(int j=i+1; j<n; ++j){
                if(i == j)
                    continue;
                if(pow2(x[i]-x[j]) + pow2(y[i]-y[j]) < pow2(r[i] + r[j]))
                    cant[j][i] = true;
            }
        }

        vector<bool> dp(1<<n, false);
        dp[0] = true;
        queue<int> q;
        q.push(0);

        int ret = 0;
        while(!q.empty()){
            bitset<24> bs(q.front());
            q.pop();
            ret = max(ret, (int)bs.count());

            vector<bool> remove(n, true);
            for(int i=0; i<n; ++i){
                for(int j=0; j<n; ++j){
                    if(bs[i] || (cant[i][j] && !bs[j]))
                        remove[i] = false;
                }
            }

            for(int i=0; i<n; ++i){
                for(int j=0; j<i; ++j){
                    if(remove[i] && remove[j] && c[i] == c[j]){
                        bs[i] = bs[j] = true;
                        if(!dp[bs.to_ulong()]){
                            dp[bs.to_ulong()] = true;
                            q.push(bs.to_ulong());
                        }
                        bs[i] = bs[j] = false;
                    }
                }
            }
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 4456
#include<iostream>
#include<vector>
#define f first
#define s second
#define mp make_pair 
#define pv push_back
using namespace std;

int main()
{
  char a;
  int n,l,b;
  vector<pair<int,int> > ant; 

  while(1){
    cin>>n>>l;
    if(n+l==0)break;
    ant.clear();
    for(int i=0;i<n;i++){
      cin>>a>>b;
      if(a=='R')ant.pv(mp(1,b));
      else ant.pv(mp(-1,b));
    }
    int time=0,lastant,leavetime=0;
    while(1){
      int nest[101]={};
      bool flag=false,LR=false;

      for(int i=0;i<ant.size();i++)if(ant[i].f!=0)flag=true;
      if(!flag)break;

      for(int i=0;i<ant.size();i++){
	if(ant[i].f==0)continue;
	ant[i].s+=ant[i].f;
	if(ant[i].s==l){
	  if(!LR)lastant=i+1;
	  ant[i].f=0;
	  continue;
	}
	if(ant[i].s==0){
	  lastant=i+1;
	  LR=true;
	  ant[i].f=0;
	  continue;
	}
	nest[ant[i].s]++;
      }

      for(int i=0;i<l;i++){
	if(nest[i]>=2){
	  for(int j=0;j<ant.size();j++){
	    if(ant[j].s==i)ant[j].f=-ant[j].f;
	  }
	}
      }
      time++;
    }
    cout<<time<<" "<<lastant<<endl;
  }
  return 0;
}

Measured memory_bytes: 1200
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		while (!str.equals("0")) {
			int n = Integer.parseInt(str);
			int[] num = new int[n];
			int max = 0 ;
			for (int i = 0; i < n; i++) {
				str = br.readLine();
				num[i] = Integer.parseInt(str);
				if(i==0)
					max=num[0];
				int sum = 0;
				for (int j = i; j >= 0; j--) {
					sum = sum + num[j];
					if (sum > max)
						max = sum;
				}
			}
			System.out.println(max);
			str = br.readLine();
		}
	}
}

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

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






Measured memory_bytes: 256
s = input()
#s = 'erasedream'

a1 = 'dreamer'
a2 = 'dream'
a3 = 'eraser'
a4 = 'erase'

end = False
while (not end) and (len(s) > 0):
    if s.endswith(a1):
        s = s[:-len(a1)]
    elif s.endswith(a2):
        s = s[:-len(a2)]
    elif s.endswith(a3):
        s = s[:-len(a3)]
    elif s.endswith(a4):
        s = s[:-len(a4)]
    else:
        end = True

if len(s) == 0:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(v) v.begin(), v.end()
#define sz size()
#define mp make_pair
#define pb push_back
#define rep(p, a, b) for (ll p = a; p < b; p++)
#define rap(p, a, b) for (ll p = a; p <= b; p++)
#define per(p, a, b) for (ll p = a; p >= b; p--)
#define F first
#define S second
using namespace std;

typedef vector<ll> vll;
typedef vector<ld> vld;
typedef pair<ll, ll> pll;

ll n, k, dp[111][5][2];
string u;
vll num;

ll call(ll pos, ll cnt, ll f)
{
    //base case
    if (cnt > k)
        return 0;
    if (pos == n)
    {
        if (cnt == k)
            return 1;
        else
            return 0;
    }
    if (dp[pos][cnt][f] != -1)
        return dp[pos][cnt][f];

    //recur
    ll ret = 0, up;
    if (f == 0)
        up = num[pos];
    else
        up = 9;

    //if(cnt==k)up=0;
    rep(p, 0, up + 1)
    {
        ll ncnt = cnt, nf = f;
        if (f == 0)
        {
            if (p < up)
                nf = 1;
        }
        if (p > 0)
            ncnt++;
        if (ncnt <= k)
            ret += call(pos + 1, ncnt, nf);
    }

    dp[pos][cnt][f] = ret;
    return dp[pos][cnt][f];
}

ll solve(string a)
{
    num.clear();
    rep(p, 0, a.sz) num.pb((a[p] - '0'));
    //reverse(all(num));
    n = num.sz;

    //cout<<n<<" "<<k<<"\n";

    memset(dp, -1, sizeof(dp));
    return call(0, 0, 0);
}

int main()
{
    ll t, i, j, ans;

    //cin>>t;
    t = 1;
    while (t--)
    {
        n = 0;
        cin >> u >> k;
        cout << solve(u);
    }

    return 0;
}

Measured memory_bytes: 3612
fun main(args: Array<String>) {
    val (N, Q) = readLine()!!.split(" ").map { it.toInt() }
    val S = readLine()!!.toCharArray()
    val list = arrayListOf<Int>()
    var a = 0
    list.add(a)
    for (i in 0..(S.lastIndex - 1)) {
        if (S[i] == 'A' && S[i + 1] == 'C') {
            a = a.inc()
        }
        list.add(a)
    }

    for (i in 1..Q) {
        val (l, r) = readLine()!!.split(" ").map { it.toInt() }
        println(list[r - 1] - list[l - 1])
    }
}

Measured memory_bytes: 72240
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>


using namespace std;

int main(){
  long long N;
  cin>>N;
  vector<long long> A(N);
  vector<long long> r(N+1);
  r[0] = 0;
  long long sum=0;
  long long mod = 1000000000+7;
  long long ans=0;
  long long m=0;

  for(long long i=0;i<N;i++){
    cin>>A[i];
    r[i+1] = r[i] + A[i];
    
  }

  for(long long i=0;i<N-1;i++){
    sum += A[i] * ((r[N] - r[i+1])%mod);
    sum %= mod;

    

  }


	ans = sum;
	cout << ans << endl;

}


Measured memory_bytes: 6084
n = int(input())
a = sorted(map(int, input().split()))
b = sorted(map(int, input().split()))
c = sorted(map(int, input().split()))

import bisect
ans = 0
for i in b:
    A = bisect.bisect_left(a,i)
    C = n - bisect.bisect_right(c,i)
    ans += A*C

print(ans)


Measured memory_bytes: 23204
#pragma comment(linker, "/stack:200000000")
 #pragma GCC optimize("Ofast")
 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 #include<bits/stdc++.h>
 #define int long long
 using namespace std;


signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif


// -------------------------------------Code starts here--------------------------------------------------------------------- 

    int n,m;
    pair<int,int>p[500][500];
    int k;
    cin>>n>>m>>k;
    string a[n+1];
    for(int i=1;i<=n;i++)
        cin>>a[i];
    int mm[n+1]={0};
    set<int>s;
    int ind[n+1]={0};
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(a[i][j]=='#')
            {
                ind[i]=max(ind[i],j);
                s.insert(i);
                mm[i]=1;
                break;
            }
        }
    }
    
    pair<int,int>ans[n+1][m+1];
    for(int i=1;i<=n;i++)
    {
        int pp=ind[i];
        if(mm[i]==1)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='#')
                    pp=max(pp,j);
                ans[i][j]={i,pp+1};
            }
        }
    }

    for(int i=*s.begin();i>=1;i--)
    {
        for(int j=0;j<m;j++)
            ans[i-1][j]=ans[i][j];
    }

    for(int i=*s.begin();i<=n-1;i++)
        {
            if(mm[i+1]!=1)
            for(int j=0;j<m;j++)
            ans[i+1][j]=ans[i][j];
        }

    map<int,map<int,int> >mp;
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(a[i][j]=='#')
                {
                    mp[i][j+1]=++cnt;
                }
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<m;j++)
            cout<<mp[ans[i][j].first][ans[i][j].second]<<" ";
        cout<<"\n";
    }
// -------------------------------------Code ends here------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
     clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

Measured memory_bytes: 7936
n,m = map(int,input().split())
a = [-1]*n
l = list(list(map(int,input().split())) for i in range(m))
if n==1 and all(a==1 and b==0 for a,b in l):
  print(0)
else:
  for j in l:
    s,c = j
    if s==1 and c ==0:
      print(-1)
      break
    if a[s-1]!=-1 and a[s-1]!=c:
      print(-1)
      break
    if a[s-1]==-1:
      a[s-1]=c
  else:
    if a[0]==-1:
      a[0]=1
    for j in range(n):
      if a[j]==-1:
        a[j]=0
    print(*a,sep="")


Measured memory_bytes: 3064
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
using namespace std; 
int main(){
  string s;
  while(getline(cin,s),s!="."){
    stack<int> a;
    for(int i=0;i<s.size();i++){
      if(s[i]=='('||s[i]=='['){
	a.push(s[i]);
      }
      else if(s[i]==')'){
	if(a.size()>0&&a.top()=='('){
	  a.pop();
	}else{
	  cout<<"no"<<endl;
	  goto at;
	}
      }
      else if(s[i]==']'){
	if(a.size()>0&&a.top()=='['){
	  a.pop();
	}else{
	  cout<<"no"<<endl;
	  goto at;
	}
      }
    }
    if(a.size()==0){
      cout<<"yes"<<endl;
    }else{
      cout<<"no"<<endl;
    }
  at: ;  
}
  
  return 0;
}

Measured memory_bytes: 3136
/*
 * Author : Sadi
 * Sun 05/07/2020
 * 16:12:09.14
 */
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int a, b, c;
    cin >> a >> b >> c;
    if(b / a >= c) {
        cout << c << '\n';
    }
    else {
        cout << b / a << '\n';
    }
    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
using namespace std;
int main(){
	int t[]={1000,500,100},a[3],x,y;
	while(cin>>x>>y,x||y){
		x=y-x;
		for(int i=0;i<3;i++){
				a[i]=x/t[i];
				x-=x/t[i]*t[i];
			}
		cout<<a[2]<<' '<<a[1]<<' '<<a[0]<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
from collections import Counter
def main():
    n=int(input())
    A=list(map(int,input().split()))
    A.sort()
    C=Counter(A)
    m=A[-1]
    Flag=[True]*(m+1)
    ans=0
    for i,a in enumerate(A):
        if Flag[a]:
            ans+=int(C[a]==1)
            for i in range(a*2,m+1,a):
                Flag[i]=False
    print(ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 120884
N=int(input())
ls=[int(s) for s in input().split()]
dicA={}
dicB={}
for i in range(N):
  a=i+ls[i]
  if a in dicA:
    dicA[a]+=1
  else:
    dicA[a]=1
  b=i-ls[i]
  if b in dicB:
    dicB[b]+=1
  else:
    dicB[b]=1
ans=0
for a,na in dicA.items():
  if a in dicB:
    ans+=na*dicB[a]
print(ans)
    

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

int main() {
	int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i){
      cin >> a[i];
    }
    ll cnt = 0;
    int right = 0;
    int sum = 0; 
    for (int left = 0; left < n; left++) {
        while (right < n && (sum ^ a[right]) == (sum + a[right])) {
            sum += a[right];
            ++right;
        }
        cnt += (right - left);
        if (left == right) ++right;
        else {
            sum -= a[left]; // a[left] を削除 (sum ^= a[left] でも OK)
        }
    }
  	cout<<cnt<<endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;
class Main
{
 public static void main(String args[])
 {
  int h,w,i,j;
  Scanner sc = new Scanner(System.in);
  while(true)
  {
   h=sc.nextInt();
   w=sc.nextInt();
   if(h==0 && w==0)
    break;
   for(i=0;i<h;i++)
   {
    for(j=0;j<w;j++)
    {
     if((i+j)%2==0)
      System.out.print("#");
     else
      System.out.print(".");
    }
    System.out.println("");
   }
   System.out.println("");
  }
 }
}


Measured memory_bytes: 36832
'use strict'

function main(input) {
  input = input
    .trim()
    .split('\n')
    .map(v => v.split(' '))
  const N = parseInt(input[0][0], 10)
  const D = parseInt(input[0][1], 10)
  const p = input.slice(1)
  let count = 0
  for (let i = 0; i < N; i++) {
    for (let j = i + 1; j < N; j++) {
      let sum = 0
      for (let k = 0; k < D; k++) {
        sum += Math.pow(p[i][k] - p[j][k], 2)
      }
      const sqrt = Math.sqrt(sum)
      if (sqrt === Math.floor(sqrt)) count++
    }
  }
  console.log(count)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

int main(){
    int a,b;
    int k;
    cin >> a >> b >> k;
    for(int i = a;i <= min(b,a+k-1);i++){
        cout << i << endl;
    }
    for(int i = max(b-k+1,a+k);i <= b;i++){
        cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma optimize("unroll-loops");
#pragma optimize("Ofast");
// #include "pch.h"    
using namespace std;

#ifdef DEBUG_BUILD
#  define DEBUG(x) cerr << x
#else
#  define DEBUG(x) do {} while (1)
#endif

#define imie(x) do { std::cerr << #x << ": " << x << std::endl; } while (0)

using ll = long long;
const int nax = 5e3 + 10;

vector<int> primes;
ll lcm(ll a, ll b) {
    return (a*b)/__gcd(a, b);
}

int main() {
    
    ll a;
    double b;
    cin >> a >> b;
    b *= 100;
    b += 0.00001;
    a = (a * (ll)b)/100;
    cout << a << "\n";
}


Measured memory_bytes: 3720
N, A, B = gets.chomp.split.map(&:to_i)
hps = []
N.times{ hps << gets.chomp.to_i }
additional_damage = A - B
times = (hps.min/A)..(hps.max/B+1)
answer = times.bsearch do |t|
  additional_times = 0
  hps.each do |hp|
    additional_times += [hp - (B * t), 0].max.fdiv(additional_damage).ceil
  end
  additional_times <= t
end
puts answer

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

using namespace std;

int main(int argc, char const *argv[]) {
  string s, ans;
  cin >> s;
  for (size_t i = 0; i < s.size(); i++) {
    if (s[i]=='0' || s[i]=='1') ans.push_back(s[i]);
    else {
      if (ans.size()==0) continue;
      else ans.pop_back();
    }
  }
  cout << ans << endl;
  return 0;
}


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

#include <bits/stdc++.h>


using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<pair<ii, ii>> vii;

const int Mod = (int)1e9 + 7;

int mul(int a, int b) {
    return 1LL * a * b % Mod;
}

const int MAXN = 100005;
int n;
int memo[MAXN];
set<int> st;
int count(int step) {
    if (step == n)
        return 1;
    if (step > n)
        return 0;
    if (st.find(step) != st.end())
        return 0;
    int &ret = memo[step];
    if (~ret)
        return ret;
    ret = 0;
    ret += count(step + 1);
    ret %= Mod;
    ret += count(step + 2);
    ret %= Mod;
    return ret;
}

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

    int m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int x;
        cin >> x;
        st.insert(x);
    }

    memset(memo, -1, sizeof memo);
    cout << count(0) << '\n';
}

Measured memory_bytes: 5376
def main():
    k, s = map(int, input().split())
    ans = 0
    for z in range(s//3, k+1):
        for y in range((s-z)//2, s-z+1):
            x = s-z-y
            if x <= y and y <= z:
                if x == y and y == z:
                    ans += 1
                elif x == y or y == z:
                    ans += 3
                else:
                    ans += 6
    print(ans)


if __name__ == "__main__":
    main()

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

int main()
{
    int N;
    cin >> N;
    string str[N];
    int AC, WA, TLE, RE;
    AC = WA = TLE = RE = 0;

    for (int i = 0; i < N; i++)
    {
        cin >> str[i];
        if ("AC" == str[i])
            AC++;
        else if ("WA" == str[i])
            WA++;
        else if ("TLE" == str[i])
            TLE++;
        else
            RE++;
    }

    cout << "AC x " << AC << "\n";
    cout << "WA x " << WA << "\n";
    cout << "TLE x " << TLE << "\n";
    cout << "RE x " << RE << "\n";

    return 0;
}

Measured memory_bytes: 6764
// Created by ...Lusifer
#include<bits/stdc++.h>
using namespace std;
 
#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void solveTest(){
	int a,b;
	cin>>a>>b;
	int cnt=0;
	for(int i=a;i<=b;i++){
		string s = to_string(i);
		if(s[0]==s[4]&&s[1]==s[3]){
			cnt++;
		}
	}
	cout<<cnt<<endl;
	
	return ;
}
 
int main(){
	fastio();

	int t=1;
	//cin>>t;
	while(t--){
		solveTest();
 
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ff first               // For pairs
#define ss second              // For pairs
#define sz(a) int((a).size())  // Function to determine size of any container
#define pb push_back           // Pushback to vector
#define mp make_pair           // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end()
#define tr(container, it) for (auto it = container.begin(); it != container.end(); it++)  //traversing macro
#define present(c, x) (c.find(x) != c.end())
using namespace std;
typedef vector<ll> vi;            // Vector of long long
typedef vector<vi> vvi;           // Vector of vi
typedef vector<pair<ll, ll>> ii;  // Vector of pairs
typedef vector<ii> vii;           // Vector of ii

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // ll t;
    // cin >> t;
    // while (t--) {

    // }
    ll x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << "\n";
    return 0;
}


Measured memory_bytes: 256
import math
N = int(input())
digit = int(math.log10(N)) + 1
ans = 0
for i in range(1, digit, 2):
  ans += 9 * (10 ** (i-1))
 
if digit % 2 == 1:
  ans += N - (10 ** (digit - 1) - 1)
 
print(ans)

Measured memory_bytes: 9268
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int A,B,C,D,E;
    cin>>A>>B>>C>>D>>E;
    vi v= {A,B,C,D,E};
    rep(i,5) v.at(i)%=10;
    sort(all(v));
    int a;
    rep(i,5) {
        if(v.at(4)==0) a=0;
        else if(v.at(i)!=0) {
            a=v.at(i);
            break;
        }
    }
    if(A%10!=0) A=(A/10+1)*10;
    if(B%10!=0) B=(B/10+1)*10;
    if(C%10!=0) C=(C/10+1)*10;
    if(D%10!=0) D=(D/10+1)*10;
    if(E%10!=0) E=(E/10+1)*10;
    int counter=A+B+C+D+E;
    if(a==0) cout<<counter<<endl;
    else cout<<counter-10+a<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/agc018/tasks/agc018_b>
 問題文============================================================
 B - Sports Festival
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N,M; cin >> N >> M;
    vector<vector<int>> A(N,vector<int>(M));
    for(auto& vec:A) for(auto& in: vec) cin >> in,in--;

    for(int i = 0; i < N;i++){
        reverse(A[i].begin(),A[i].end());
    }
    res = N;
    vector<int> selected(M,true);
    // cout << A << endl;

    int K = M;
    while(K--){
        vector<int> cnt(M);
        for(int i = 0; i < N;i++){
            cnt[A[i].back()]++;
        }

        ll max_v = *max_element(cnt.begin(),cnt.end());
        res = min(res,max_v);

        for(int i = 0; i < M; i++){
            if(cnt[i] == max_v){
                selected[i] = false;
                for(int i = 0; i < N;i++){
                    while(A[i].size() && !selected[A[i].back()]){
                        A[i].pop_back();
                    }
                }
            }
        }
        // cout << "!!!" << endl;
        // cout << A << endl;
    }

    return res;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    //solve<ll>(0);
    cout << fixed << setprecision(12) << solve<ll>() << endl;
    return 0;
}

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

#define int long long
#define ld long double

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repb(i,a,b) for(int i=a;i>b;i--)

#define pb push_back
#define mp make_pair
#define all(A) A.begin(),A.end()
#define allr(A) A.rbegin(),A.rend()
#define precise(i) fixed << setprecision(i)
#define fi first
#define se second

#define err() cout<<"\n==================================\n";
#define errA(A) for(auto i:A) cout<<i<<" "; cout<<"\n";
#define err1(a) cout<<#a<<" "<<a<<"\n";
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<"\n";
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<"\n";
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<"\n";

const int logN = 20;
const int M = 1000000007;
const int INF = 1e12;
#define PI 3.14159265;
const int N = 200005;

#define Pii pair<int,int>
#define Vi vector<int>
#define Vpii vector<Pii>

void solve()
{
       int d,t,s;
       cin>>d>>t>>s;
       if(d<=(s*t))
       {
              cout<<"Yes";
       }
       else
       {
              cout<<"No";
       }
}

int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--)
    {
           solve();
    }
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include <math.h>

using namespace std;

int main()
{
	const double PI = acos(-1);

	double r;
	cin >> r;

	cout << fixed << setprecision(6) << PI * r * r << " " << 2 * PI * r << endl;

	return 0;
}




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

int main()
{
    int n, q;
    int order, index1, index2, value;
    
    cin >> n >> q;

    list<int> l[n];

    for( int i = 0; i < q; i++ )
    {
        cin >> order >> index1;

        if( order == 0 )
        {
            cin >> value;
            l[index1].push_back(value);
        }
        else if( order == 1 )
        {
            int cnt = l[index1].size();

            if( cnt == 0 )
                cout << endl;
            
            list<int>::iterator itr = l[index1].begin();
            while( cnt )
            {
                if( cnt == 1 )
                    cout << *itr << endl;
                else
                {
                    cout << *itr << " ";
                    itr++;
                }
                cnt--;
            }
        }
        else if( order == 2 )
        {
            cin >> index2;
            l[index2].splice( l[index2].end(), l[index1] );         //spliceという関数がある
        }                                                           //その際、第二引数に指定されたリストは空になる
        else;
    }
    return 0;
}


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

#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define list_input(x, n) x[n]; rep(i,n){ cin >> x[i];}
#define ll long long

int main(){
  bool result = true;
  int H, W;
  cin >> H >> W;
  string input[100];
  rep(i, W+2){
    input[0] += '.';
    input[H+1] += '.';
  }
  FOR(i,1,H+1){
    string tmp = "";
    cin >> tmp;
    tmp = "." + tmp + ".";
    input[i] = tmp;
  }
  FOR(i, 1, H+1){
    FOR(j, 1, W+1){
      if (input[i][j] == '#') {
        if (input[i-1][j] != '#' && input[i+1][j] != '#' && input[i][j-1] != '#' && input[i][j+1] != '#') {
          result = false;
        }
      }
    }
  }
  string ans = result ? "Yes":"No";
  cout << ans << '\n';
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtcoderTemplateForCSharp
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var n = int.Parse(str.Split(' ').First());
            var x = int.Parse(str.Split(' ').Last());
            var list = new List<int>();
            for (int i = 0; i < n; i++)
            {
                list.Add(int.Parse(Console.ReadLine()));
            }

            var count = 0;
            x -= list.Sum();
            count += list.Count;
            var min = list.Min();
            var div = x / min;
            count += div;
            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 13268
N = int(input())
numbers = [int(x) for x in input().split()]


def solve():
  xor = numbers[0]
  total = numbers[0]
  count = 0
  right = 1
  
  for left in range(N):
    while right < N and xor ^ numbers[right] == total + numbers[right]:
      xor ^= numbers[right]
      total += numbers[right]
      right += 1
   
    count += right - left
  
    xor ^= numbers[left]
    total -= numbers[left]
  
  return count
  
    
print(solve())

Measured memory_bytes: 77772
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramC
    {
        static void Main()
        {
            long w = NextInt, h = NextInt, x = NextInt, y = NextInt;
            
            if (x * 2 == w && y * 2 == h)
            {
                System.Console.WriteLine($"{(decimal)w * h / 2} {1}");
            }
            else
            {
                System.Console.WriteLine($"{(decimal)w * h / 2} {0}");
            }
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

// 1次元 vector
template <class T>
ostream &operator<<(ostream &s, vector<T> vec) {
    for (int i = 0; i < (int)vec.size(); ++i) {
        if (i > 0) {
            s << " ";
        }
        s << vec[i];
    }
    return s << endl;
}
using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
//const int MOD = 1e9 + 7;

ll N, M, K, Q, P;
string S;

vector<ll> cnt(10005);
int main() {
    cin >> N >> P >> S;
    ll now = 0;
    ll k = 1;
    cnt[0] = 1;
    for (int i = N - 1; i >= 0; i--) {
        now += ((int)(S[i] - '0') * k) % P;
        k *= 10;
        k %= P;
        cnt[now % P]++;
    }
    ll ans = 0;
    if (P == 2 || P == 5) {
        for (int i = 0; i < N; i++) {
            if ((S[i] - '0') % P == 0) {
                ans += i + 1;
            }
        }
    } else {
        for (int i = 0; i < P; i++) {
            ans += cnt[i] * (cnt[i] - 1LL) / 2LL;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main(void) {
    int sum = 0;
    int largest_diff = 0;
    for (int i = 0; i < 5; i++){
        int temp;
        cin >> temp;
        int mod_ten = 0;
        if (temp % 10 != 0){
            mod_ten = 10 - (temp % 10);
            if (largest_diff < mod_ten) largest_diff = mod_ten;
        }
        sum += temp + mod_ten;
    }
    
    cout << sum - largest_diff << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <string.h>
#include<algorithm>
#include <numeric>      // std::accumulate
#include <iomanip>      // std::setprecision


using namespace std;
#define ll           long long
#define all(v)       (v).begin() , (v).end()
#define v           vector <int>
#define vi           vector <ll>
#define vii          vector <pair<ll,ll>>
#define ii           pair<ll,ll>
#define sz(v)	     ((int)((v).size()))
#define lp(i,a,b)    for(int i=a;i<b;i++)
#define pb           push_back
#define pf           push_front
#define F            first
#define S            second
#define EPS			 1e-9
#define endl         "\n"
#define IOS          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const double PI = 3.14159265358979323846;

bool cmp(const pair<int, int>& a, const pair<int, int>& b)
{
    return (a.second < b.second);
}

int gcd(int a, int b) 
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
long long power(ll n, ll k) 
{
    if (k == 0) return 1;
    ll sq = (power(n, k / 2));
    sq = (sq * sq);
    if (k % 2 == 1)
        sq = (sq * n);
    return sq;
}
bool isPrime(int n)
{
    if (n <= 1)  return false;
    if (n <= 3)  return true;

    if (n % 2 == 0 || n % 3 == 0) return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}
string to_binary(int x) 
{
    string s;
    while (x > 0) 
    {
        s += (x % 2 ? '1' : '0');
        x /= 2;
    }
    reverse(s.begin(), s.end());
    return s;
}
bool isPerfect(ll x)
{
    if (x < 1) 
        return false;
    ll root(round(sqrt(x)));
    return x == root * root;
}
void solve()
{
    int n;
    cin >> n;
    
    v ans(10050 + 3);
    for (int i = 1; i <= 105; i++)
    {
        int x = 0;
        for (int j = 1; j <= 105; j++)
        {
            for (int k = 1; k <= 105; k++)
            {
                x = i * i + j * j + k * k + i * j + j * k + k * i;
                if (x < 10050)
                    ans[x]++;
            }
        }
    }
        
    for (int i = 1; i <= n; i++)
        cout << ans[i] << "\n";
}

int main()
{
    IOS;    
    
    int tt;
    tt = 1;
    // cin >> tt;
    while (tt--)
    {
        solve();
    }
    
}
       

Measured memory_bytes: 3116
N = int(input())

A = list(map(int, input().split()))

# +先行の場合
ans_plus = 0
total = 0
for i in range(N):
    total += A[i]
    # 奇数個目（合計が正を期待）
    if i % 2 == 0:
        if total <= 0:
            ans_plus += (1 - total)
            total = 1
    # 偶数個目（合計が負を期待）
    else:
        if total >= 0:
            ans_plus += (total + 1)
            total = -1

ans_minus = 0
total = 0
for i in range(N):
    total += A[i]
    # 奇数個目（合計が負を期待）
    if i % 2 == 0:
        if total >= 0:
            ans_minus += (1 + total)
            total = -1
    # 偶数個目（合計が正を期待）
    else:
        if total <= 0:
            ans_minus += (-total + 1)
            total = 1

print(min(ans_plus, ans_minus))


Measured memory_bytes: 14468
/*input
1 2
*/

#include <bits/stdc++.h>
#define ll long long

using namespace std;

void run() {
	int a, b;
	cin >> a >> b;
	cout << (b % 2 || b<a*2 || b>a*4 ? "No" : "Yes") << endl;
}

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


Measured memory_bytes: 3640
import sys
from collections import deque
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def divisor(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

N = I()

l = divisor(N)
l = list(set(l))

cnt = 0
for x in l:
  if x == 1:
    continue
  num = N
  while num%x == 0:
    num //= x
  if num%x == 1:
    cnt += 1

l = []

k = divisor(N-1)
cnt += len(k) - 1
print(cnt)

Measured memory_bytes: 39664
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

const ll inf = 1LL << 60;

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

    ll N, X, D;
    cin >> N >> X >> D;
    ll ans = 0;
    if (D == 0) {
        if (X == 0) ans = 1;
        else ans = N+1;
        cout << ans << "\n";
        return 0;
    }

    // if (D < 0) X *= -1, D *= -1;

    map<ll, vector<pair<ll, ll>>> m;
    Rep (i, N+1) {
        ll mod = (i*X%D+D)%D;
        ll off = (i*X-mod)/D;
        m[mod].push_back({(i-1)*i/2+off, (2*N-1-i)*i/2+off+1});
    }

    // for (auto e : m) {
    //     cout << e.first << "\n";
    //     for (auto f : e.second) {
    //         cout << f.first << " " << f.second << "\n";
    //     }
    // }

    for (auto e : m) {
        auto v = e.second;
        sort(v.begin(), v.end());
        ll before = v[0].first;
        for (auto f : v) {
            chmax(f.first, before);
            ll num = f.second - f.first;
            if (num > 0) ans += num;
            chmax(before, f.second);
        }
    }

    cout << ans << "\n";
}

Measured memory_bytes: 22144
#include<iostream>
#include<string>
#include<math.h>
using namespace std;
int main(){
int n;
long long int x=100000;
cin>>n;

for (int i=0;i<n;i++){
	x*=1.05;
	x=ceil((double)x/1000)*(1000);
}
cout<<x<<endl;
}

Measured memory_bytes: 1156
/*
    Problem 62
    https://atcoder.jp/contests/abc079/tasks/abc079_d
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int H, W;
    cin >> H >> W;
    int V = 10;
    vector<vector<int>> G(V, vector<int>(V, INF));
    for (int i = 0; i < V; i++)
        for (int j = 0; j < V; j++)
            cin >> G[i][j];

    for (int k = 0; k < V; k++) {
        for (int i = 0; i < V; i++) {
            if (G[i][k] == INF) continue;
            for (int j = 0; j < V; j++) {
                if (G[k][j] == INF) continue;
                G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            int num;
            cin >> num;
            if (num == -1) continue;
            ans += G[num][1];
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


typedef pair<ll,int> P;
vector<ll> dijkstra(int s, const vector<vector<pair<int,int> > >& G, const int* dd){
    priority_queue< P, vector<P>, greater<P> > que;
    vector<ll> d(G.size(), LINF);
    d[s] = 0;
    que.push(P(0, s));
    while(!que.empty()){
        int curr  = que.top().second;
        ll  dcurr = que.top().first;
        que.pop();
        if(d[curr] < dcurr) continue;
        int i;
        for(i=0; i<(int)G[curr].size(); i++){ 
            int next = G[curr][i].first;
            ll  dist = dd[G[curr][i].second];
            if(d[next] > d[curr] + dist){
                d[next] = d[curr] + dist;
                que.push(P(d[next], next));
            }
        }
    }
    return d;
}

int main(int argc, char* argv[])
{
    int n,m,s,t;
    scanf("%d%d%d%d", &n,&m,&s,&t);
    s--; t--;

    vector<vector<pair<int,int> > > g(n);   // to, edgeid
    vector<int> a(m), b(m);
    int i;
    for(i=0; i<m; i++) {
        int u, v;
        scanf("%d%d%d%d", &u, &v, &a[i], &b[i]);
        g[u-1].push_back(make_pair(v-1,i));
        g[v-1].push_back(make_pair(u-1,i));
    }

    vector<ll> vd0 = dijkstra( s, g, &a[0] );
    vector<ll> vd1 = dijkstra( t, g, &b[0] );

    ll ans_curr=LINF;
    vector<ll> ans(n);
    for(i=n-1; i>=0; i--) {
        ll val = vd0[i]+vd1[i];
        ans[i] = ans_curr = min(ans_curr, val);        
    }
    for(i=0; i<n; i++) {
        printf("%lld\n", (ll)1000000000000000-ans[i]);
    }
    return 0;
}


Measured memory_bytes: 10944