akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater(){
    #ifndef ONLINE_JUDGE
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
    #endif
}//continue break
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define fastio  cin.sync_with_stdio(0); cin.tie(0);cin.exceptions(cin.failbit);
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a,v) memset(a, v, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long int> vll;
typedef vector<pii> vpii;
ll p=1e9+7;
const int N=2e5+5;
int main() {
   
    fastio;
    int T=1;
    // cin>>T;
    while(T--){
        ll n;cin>>n;
        ll a[n];rep(i,n)cin>>a[i];
        ll money=1000;
        for(ll i=1;i<n;i++){
            if(a[i]>a[i-1]){
                ll st=(money)/a[i-1];
                money=money%(a[i-1]);
                money+=(a[i]*st);
            }
        }
        cout<<money;
    }   
    timecalculater();
    return 0;   
} 


Measured memory_bytes: 3640
#include<stdio.h>
#include<string.h>
int main(void){
    char weather[20];

    scanf("%s",&weather);


    if(strcmp(weather,"Sunny")==0){
        printf("Cloudy");
    }if(strcmp(weather,"Cloudy")==0){
        printf("Rainy");
    }if(strcmp(weather,"Rainy")==0){
        printf("Sunny");
    }

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
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;
}
int main(){
    vvl loop;
    ll n,k;cin >> n >>k;
    vl p(n);rep(i,n)cin >> p[i],p[i]--;
    vl v(n);rep(i,n)cin >> v[i];
    vl seen(n,-1);
    rep(i,n){
        if(seen[i]!=-1)continue;
        vl val;ll np=i;
        while(seen[np]==-1){
            seen[np]=1;val.pb(v[np]);np=p[np];
        }
        ll t=val.size();
        rep(i,t)val.pb(val[i]);
        loop.pb(val);
    }
    ll ans=-INF;
    for(auto t:loop){
        vl z=t;
        ll sum=0;for(auto lp:z)sum+=lp;sum/=2;
        ll sz=z.size()/2;
        ll tim=k;
        //rep(i,sz)cout << z[i] <<" ";cout << endl;
        //cout << sum <<endl;
        //cout << sz <<endl;
        vl cum(sz*2+1,0);
        rep(i,sz*2){
            cum[i+1]+=cum[i]+z[i];
        }
        if(sum>0){
            rep(i,sz*2+1){
                repl(j,i+1,sz*2+1){
                    if(tim-(j-i)<0)continue;
                    ll res=sum*((tim-(j-i))/sz);
                    //cout << (tim-(j-i))
                    chmax(ans,res+cum[j]-cum[i]);
                }
            }
        }
        else{
            rep(i,sz*2+1){
                repl(j,i+1,sz*2+1){
                    if(j-i<=tim){
                        chmax(ans,cum[j]-cum[i]);
                    }
                }
            }
        }
        //cout << endl;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 3904
N,Q=map(int,input().split())
S=input()
s=[0]
for i in range(N) :
  s.append(s[-1]+(1 if S[i:i+2]=='AC' else 0))
for i in range(Q) :
  l,r=map(int,input().split())
  print(s[r-1]-s[l-1])

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

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s, t;
	int ans = 0;
	cin >> s >> t;
	for(int i=0; i<(int)s.size(); ++i) {
		if (s[i] != t[i]) ans++;
	}
	cout << ans;
	return 0;
}



Measured memory_bytes: 3804
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
Z = [i for i in range(X + 1, Y + 1)]

for i in Z:
    if max(x) < i <= min(y):
        print('No War')
        exit()
    else:
        continue
print('War')


Measured memory_bytes: 3060
def main():
    N = int(input())
    max_N = 100001
    dp = [N for _ in range(max_N)]
    dp[0] = 0

    for i in range(N):
        for k in range(10):
            if i+6**k <= 100000:
                dp[i+6**k] = min(dp[i+6**k], dp[i]+1)
        for k in range(10):
            if i+9**k <= 100000:
                dp[i+9**k] = min(dp[i+9**k], dp[i]+1)

    return dp[N]

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3864
#include <iostream>
#include <string>
#include <algorithm>


using namespace std;

int main(){
	string s,t;
	cin >> s >> t;

 	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if(s < t) cout << "Yes\n";
	else cout << "No\n"; 
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(){
  int n;
  long a[100002],i,sum=0;
  scanf("%d",&n);
  a[0]=0;
  for(i=1;i<n+2;i++){
    if(i==n+1) a[i]=0;
    else scanf("%ld",&a[i]);
    sum+=abs(a[i]-a[i-1]);
  }
  for(i=1;i<n+1;i++){
    printf("%ld\n",sum-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i+1]-a[i-1]));
  }
}

Measured memory_bytes: 1920
//#include<bits/stdc++.h>
//using namespace std;
//#define ll double
//
//
//int bigmod_iterative(ll a,ll b,ll m)
//{
//    ll res =1.0;
//    ll x=a;
//    while(b)
//    {
//        if(b%2.0==1)
//            res = (res*x)%m;
//        x=(x*x)%m;
//        b=b>>1;
//    }
//    return res;
//}
//
//int main()
//{
//    cout<<setprecision(20)<<fixed;
//    ll n,m;
//    cin>>n>>m;
//    double k;
//    k=1.618033988749894848;
//    cout<<k<<endl;
//    cout<<bigmod_iterative(k,n,1000000007.0)<<endl;
//
//}
//


#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int l=s.size()-1,f=0,l2;
    l2=l;
    for(int i=0;i<s.size()/2;i++)
    {
        if(s[i]!=s[l])
        {
            f=1;
            cout<<"No"<<endl;
            return 0;
        }
        l--;
    }
    int p=(l2-1)/2,k;
    k=p;
    int f1=0;
    for(int i=0;i<k;i++)
    {
        if(s[i]!=s[p])
        {
            f=1;
            cout<<"No"<<endl;
            return 0;
        }
        p--;
    }
    int len=(l2+3)/2;
    for(int i=len;i<s.size();i++)
    {
        if(s[i]!=s[l2])
        {
            f=1;
            cout<<"No"<<endl;
            return 0;
        }
        l2--;
    }
    cout<<"Yes"<<endl;


}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 100005
#define int long long
using namespace std;
int n,cev;
string s;
map<string,int> tp;
main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++){
		cin>>s;
		sort(s.begin(),s.end());
		cev+=tp[s];
		tp[s]++;
	}
	printf("%lld\n",cev);
	return 0;
}




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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }

  const int K = 29;
  int ans = 0;
  for (int k = 0; k < K; k++) {
    vector<int> c(n);
    for (int i = 0; i < n; i++) {
      c[i] = b[i] % (1 << (k + 1));
    }
    sort(c.begin(), c.end());

    long long cnt = 0, l, r;
    for (auto v : a) {
      v %= (1 << (k + 1));
      l = lower_bound(c.begin(), c.end(), (1 << k) - v) - c.begin();
      r = lower_bound(c.begin(), c.end(), (1 << k) * 2 - v) - c.begin();
      cnt += (r - l);
      l = lower_bound(c.begin(), c.end(), (1 << k) * 3 - v) - c.begin();
      r = lower_bound(c.begin(), c.end(), (1 << k) * 4 - v) - c.begin();
      cnt += (r - l);
    }
    if (cnt & 1) ans += (1 << k);
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 5528
#include <stdio.h>
#include <stdlib.h>

#define MAX_H (500)
#define MAX_W (500)

int main(int argc, char *argv[]) {
  // read inputs
  int H, W, as[MAX_H * MAX_W];
  scanf("%d %d", &H, &W);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      scanf("%d", &as[j + i * W]);
    }
  }

  // solve
  int i1s[MAX_H * MAX_W], j1s[MAX_H * MAX_W];
  int i2s[MAX_H * MAX_W], j2s[MAX_H * MAX_W];
  int N = 0;
  for (int i = 0; i < H - 1; i++) {
    for (int j = 0; j < W; j++) {
      if (as[j + i * W] % 2 == 1) {
        as[j + i * W]--;
        as[j + (i + 1) * W]++;
        i1s[N] = i;
        j1s[N] = j;
        i2s[N] = i + 1;
        j2s[N] = j;
        N++;
      }
    }
  }
  for (int j = 0; j < W - 1; j++) {
    if (as[j + (H - 1) * W] % 2 == 1) {
      as[j + (H - 1) * W]--;
      as[j + 1 + (H - 1) * W]++;
      i1s[N] = (H - 1);
      j1s[N] = j;
      i2s[N] = (H - 1);
      j2s[N] = j + 1;
      N++;
    }
  }

  // print ans
  printf("%d\n", N);
  for (int k = 0; k < N; k++) {
    printf("%d %d %d %d\n", i1s[k] + 1, j1s[k] + 1, i2s[k] + 1, j2s[k] + 1);
  }

  return 0;
}


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

int main()
{
  int x, y, ans = 0;
  cin >> x >> y;
  if (x <= 3)
    ans += (4 - x) * 100000;
  if (y <= 3)
    ans += (4 - y) * 100000;
  if (x == 1 && y == 1)
    ans += 400000;
  cout << ans << endl;
}


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

int main() {
  string s;
  cin >> s;
  
  if(s == "SSS") cout << 0 << endl;
  else if(s == "SSR" || s == "SRS" || s == "RSS" || s == "RSR") cout << 1 << endl;
  else if(s == "SRR" || s == "RRS") cout << 2 << endl;
  else if(s == "RRR") cout << 3 << endl;
  
  return(0);
}

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

//ゾロ目判定
  bool zoro(int i, vector<vector<int>> saikoro){
      if (saikoro.at(i).at(0) == saikoro.at(i).at(1)){
          return true;
      }else{
          return false;
      }
  }

int main() {
  int n;
  
  cin >> n;
  
  vector<vector<int>> saikoro(n, vector<int>(2));
  
  for (int i = 0; i < n; i++){
      cin >> saikoro.at(i).at(0) >> saikoro.at(i).at(1);
  }
  
  //ゾロ目が3回連続したか
  bool isOk = false;
  
  for (int i = 0; i < n - 2; i++){
      
      if (zoro(i, saikoro) && zoro(i + 1, saikoro) && zoro(i + 2, saikoro)){
          isOk = true;
      }
  }
  
  if (isOk == true){
      cout << "Yes" << endl;
  }else{
      cout << "No" << endl;
  }
  
}



Measured memory_bytes: 3648
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  int n;
  string s, t;
  cin >> n >> s >> t;
  for (int i = 0; i <= n; i++) {
    string u = s + t.substr(n-i, i);
    int m = u.size();
    if (u.substr(m-n, n) == t) {
      cout << u.size() << endl;
      return 0;
    }
  }
}

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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

void ALLIN1_NUMBER(vector<ll>& V)
{
    for(auto& x : V)
    {
        cin >> x;
    }
}

template<class T>
void OUT0(T N)
{
    cout << N << endl;
}

static const double pi = acos(-1.0);

double Cos(double D)
{
    return cos(pi/180 * D);
}

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

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

int main() {

	int A[3];

	for (int i = 0; i < 3; i++) {
		cin >> A[i];
	}

	int sum = A[0] + A[1] + A[2];

	if (sum >= 22) {
		cout << "bust" << endl;
	}
	else {
		cout << "win" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    if (N == 'A') {
        cout << "T" << endl;
    } else if (N == 'T') {
        cout << "A" << endl;
    } else if (N == 'C') {
        cout << "G" << endl;
    } else if (N == 'G') {
        cout << "C" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n, k;
  cin >> n >> k;
  ll temp = n % k;
  if (temp == 0)
    cout << "0";
  else
  {
    cout << min(temp, k - temp);
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  //ios::sync_with_stdio(false);
  long double a,b,c;
  cin>>a>>b>>c;
  long double num=sqrtl(a)*sqrt(b);
  
  num*=2;
  // cout<<num<<endl;
  //cout<<a+b+num<<endl;
  
  if((a+b+num) < c) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
target=input()
list_abc=["A","B","C"]
old=[]
new=[]
check=[]
flag=False
if "ABC" in target:
    old.append([target,[]])
while old !=[] and flag==False:
    for i in old:
        if i[0]=="ABC":
            check.append(i[1])
            flag=True
            break
        for j in list_abc:
            element=i[0].replace("ABC",j)
            if "ABC" in element:
                new.append([element,i[1]+[j]])
    else:
        old=new[:]
        new=[]
flag=False
for i in check:
    abc="ABC"
    li=i
    li.reverse()
    for j in li:
        abc=abc.replace(j,"ABC")
    if abc==target:
        flag=True
print("Yes" if flag==True else "No")
        

Measured memory_bytes: 7536
X,K,D = map(int, input().split())

n = 0
if abs(X) < D:
    if K % 2 == 0:
        n = abs(X)
    else:
        n = D - abs(X)
else:
    if D*K < abs(X):
        n = abs(X) -D*K
    else:
        r = abs(X) % D
        m = K - (abs(X) // D)
        if m % 2 == 0:
            n = r
        else:
            n = abs(r-D)

print(n)


Measured memory_bytes: 9196
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        char[] S = scanner.next().toCharArray();

        Map<Character, Integer> map = new HashMap<>();
        for (char c : S) {
            Integer count = map.get(c);
            if (count == null) {
                count = 0;
            }
            map.put(c, ++count);
        }

        if (map.size() != 2) {
            System.out.println("No");
            return;
        }
        for (Map.Entry<Character, Integer> e : map.entrySet()) {
            if (e.getValue() != 2) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    }
}

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

int main() {
  int n;
  cin >> n;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    // for (int j = i; j <= n; j += i) ans += j;
    ans += (long long)i * (n / i) * (n / i + 1) / 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
import sys

read = sys.stdin.readline

N = int(read())
A = list(map(int, read().split()))
B = list(map(int, read().split()))

if sum(A) < sum(B):
    print(-1)
    exit()

d = [A[i] - B[i] for i in range(N)]
d.sort()
if d[0] >= 0:
    print(0)
    exit()

n = 0
below = 0
for i in d:
    if i < 0:
        below -= i
        n += 1
    else:
        break

tmp = 0
for i in d[::-1]:
    tmp += i
    n += 1
    if tmp > below:
        print(n)
        exit()


Measured memory_bytes: 19124
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //  repマクロ
#define leng(n) (int)(log10(n)+1)  //  桁数leng
#define INF 9223372036854775807 //  巨大数INF
using namespace std;

signed main() {
  int a, b, k;
  cin >> a >> b >> k;
  int count = 0;
  for (int i = min(a, b); i > 0; i--) {
    if (a % i == 0 && b % i == 0) count++;
    if (count == k) {
      cout << i << endl;
      break;
    }
  }
}


Measured memory_bytes: 256
import sys
 
 
def is_prime(x):
    if x == 2:
        return True
    elif x < 2 or not x % 2:
        return False
 
    return pow(2, x - 1, x) == 1
 
 
def solve(_c_list):
    cnt = 0
    for ele in _c_list:
        if is_prime(ele):
            cnt += 1
    return cnt
 
 
if __name__ == '__main__':
    _input = sys.stdin.readlines()
    c_num = int(_input[0])
    c_list = list(map(int, _input[1:]))
    ans = solve(c_list)
    print(ans)

Measured memory_bytes: 8672
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  vector<int> prime(100000);
  REP(i,100000) prime[i] = i;
  prime[1] = 0;
  REP(i,100000)
    if (prime[i])
      for (int j=i*2; j<100000; j+=i)
        prime[j] = 0;
  prime.erase(remove(ALL(prime), 0), prime.end());
  int m, a, b;
  while(cin>>m>>a>>b,m) {
    int res = 0;
    int ansp, ansq;
    for (int i=0; prime[i]*prime[i]<=m; ++i) {
      int p = prime[i];
      int q = *(upper_bound(ALL(prime), min(m/p, p*b/a))-1);
//      cout << p << " " << q << " " << m/prime[i] << " " << p*b/a<<endl;
      if (a*q<=b*p) {
        if (res < p*q) {
          ansp = p;
          ansq = q;
        }
        res = max(res, p*q);
      }
    }
    printf("%d %d\n", ansp, ansq);
  }
}

Measured memory_bytes: 0
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
 
#include <iostream>
#include <sstream>
#include <vector>
#include <iterator>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <stdint.h>
#include <limits.h>
 
#define    pi          acos(-1)
#define    ll          long long
#define    mp          make_pair
#define    pb          push_back
#define    vi          vector <int>
#define    vs          vector <string>
#define    maxx(a,b,c) max(a,max(b,c))
#define    minn(a,b,c) min(a,min(b,c))
#define    all(x)      (x).begin(),(x).end()
#define    fill(x,y)   memset(x, y, sizeof(x))
#define    trace(x)    cout << #x << " = " << x << endl
#define    bug         cout << "Bug check" << endl
#define    eps         1e-10
#define    endl        '\n'
 
using namespace std;

int main(){
	//freopen("in.txt","r", stdin);
	//freopen("out.txt","w", stdout);
	
	ios::sync_with_stdio(0);
	cin.tie(0);

	int n; cin >> n;
	bool flg=1;
	while(n--){
		int a; cin >> a;
		if(a%2==0 && (a%3!=0 && a%5!=0)) flg=0;
	}
	puts( flg? "APPROVED" : "DENIED");
 	return 0;
}

Measured memory_bytes: 256
class TemplateTree:
  def __init__(self, iterable):
    self.iter_size = self.get_size(iterable)
    self.size = self.iter_size * 2 - 1
    self.value = [None] * self.size
    for i, v in enumerate(iterable):
      self.value[self.iter_size + i - 1] = v
    self.set_value(0)
    self.range = [None] * self.size
    self.set_range(0, 0, self.iter_size - 1)
  
  def get_size(self, iterable):
    ret = 1
    x = len(iterable)
    while ret < x:
      ret *= 2
    return ret
  
  def set_range(self, x, left, right):
    self.range[x] = (left, right)
    if left != right:
      self.set_range(x * 2 + 1, left, (right + left) // 2)
      self.set_range(x * 2 + 2, (right + left) // 2 + 1, right)

  def set_value(self, x):
    if x >= self.iter_size - 1:return self.value[x]
    a = self.set_value(x * 2 + 1)
    b = self.set_value(x * 2 + 2)
    if a == None and b == None:
      self.value[x] = None
    elif a == None:
      self.value[x] = b
    elif b == None:
      self.value[x] = a
    else:
      self.value[x] = a + b
    return self.value[x]

  def update(self, i, x):
    target = self.iter_size + i - 1
    while target >= 0:
      self.value[target] += x
      target = (target - 1) // 2

  def query(self, x, left, right):
    x_left, x_right = self.range[x]
    if right < x_left or x_right < left:
      #print("A")
      return 0
    if x_left < left and right < x_right:
      #print("B")
      return self.query(x * 2 + 1, left, right) + self.query(x * 2 + 2, left, right)
    if x_left < left and x_right <= right:
      #print("C")
      return self.query(x * 2 + 1, left, right) + self.query(x * 2 + 2, left, right)
    if left <= x_left and right < x_right:
      #print("D")
      return self.query(x * 2 + 1, left, right) + self.query(x * 2 + 2, left, right)
    if left <= x_left and x_right <= right:
      #print("E")
      return self.value[x]

  def print_tree(self):
    print(self.value)
    print(self.range)

n, q = map(int, input().split())
tree = TemplateTree([0] * n)

for _ in range(q):
  c, x, y = map(int, input().split())
  if c == 0:
    tree.update(x - 1, y)
  else:
    print(tree.query(0, x - 1, y - 1))




Measured memory_bytes: 37888
n = int(input())
p = list(map(int,input().split()))
# print(p)
temp_min = int(10**6)
ans = 0
for i in p:
    if i < temp_min:
        temp_min = i
        ans += 1
# for i in p:
#     if i < temp_min:
#         temp_min = p
#         ans += 1
print(ans)

Measured memory_bytes: 24744
import math
from scipy.misc import comb

X, Y = map(int, input().split())

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result



if (X+Y) % 3 == 1 or (X+Y) % 3 == 2:
  print(0)
else:
  if 2*X < Y or 2*Y < X:
    print(0)
  else:
    if X >= Y:
      #print()
      #print()
      a = cmb(int((X+Y)/3), int((2*Y-X)/3))
      #print(a)
      q, mod = divmod(a, 10**9+7)
      print(mod)
    else:
      a = cmb(int((X+Y)/3), int((2*X-Y)/3))
      #print(a)
      q, mod = divmod(a, 10**9+7)
      print(mod)

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll k,dp[1000001][11],nr,suma,st[100001];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>k;
    if(k<=9)
    {
        cout<<k;
        return 0;
    }
    for(int i=1;i<=9;i++)
        dp[1][i]=1;
    for(int i=2;i<=30;i++)
        for(int j=0;j<=9;j++)
        {
            if(j==0)
                dp[i][j]=suma+dp[i-1][0]+dp[i-1][1];
            if(j==9)
                dp[i][j]=suma+dp[i-1][9]+dp[i-1][8];
            else
                dp[i][j]=suma+dp[i-1][j]+dp[i-1][j-1]+dp[i-1][j+1];
        }
    for(int i=1;i<=30;i++)
    {
        for(int j=0;j<=9;j++)
            suma+=dp[i][j];
        if(suma>=k)
        {
            nr=i;
            break;
        }
    }
    suma=0;
    for(int i=1;i<nr;i++)
        for(int j=0;j<=9;j++)
            suma+=dp[i][j];
    for(int i=1;i<=9;i++)
    {
        for(int j=1;j<=nr;j++)
            st[j]=-1;
        st[1]=i;
        int niv=2;
        while(niv>1)
        {
            bool q=0;
            bool ok=1;
            if(st[niv]==-1)
            {
                if(st[niv-1]>0)
                    st[niv]=st[niv-1]-1;
                else
                    st[niv]=0;
            }
            else
            {
                st[niv]++;
                if(abs(st[niv]-st[niv-1])>1||st[niv]>9)
                    ok=0;
            }
            if(ok)
            {
                if(niv<nr)
                    niv++;
                else if(niv==nr)
                {
                    suma++;
                    if(suma==k)
                    {
                        for(int j=1;j<=nr;j++)
                            cout<<st[j];
                        return 0;
                    }
                }
            }
            else
            {
                st[niv]=-1;
                niv--;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
B = [int(input()) for _ in range(N)]

count = 0
next_index = 1

for _ in range(N):
    if next_index == 2:
        break

    next_index = B[next_index-1]
    count += 1

if count == N:
    count = -1
print(count)

Measured memory_bytes: 7084
#include<stdio.h>
int main(){
  int W = 0, H = 0, x = 0, y = 0, r = 0;
  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
  if (x - r < 0 || x + r > W || y - r < 0 || y + r > H) {
    printf("No\n");
  } else {
    printf("Yes\n");
  }
  return 0;
}

Measured memory_bytes: 580
// AOJ DSL_2_A Range Minimum Query (RMQ)
// 2018.5.5 bal4u
// 2018.5.17

#include <stdio.h>
#include <string.h>

#define INF 0xffffffff

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
unsigned in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

char *inf = "2147483647";
void out(unsigned n)
{
	int i;
	char ob[20];

	if (!n) pc('0');
	else if (n == INF) for (i = 0; i < 10; i++) pc(inf[i]);
	else {
		i = 0; while (n) ob[i++] = n%10 + '0', n/=10;
		while (i--) pc(ob[i]);
	}
	pc('\n');
}

#define MAX_N 100005
unsigned node[MAX_N << 2];

unsigned range_min_query(int t, int l, int r, int x, int y)
{
	int m;
	unsigned a, b;

    if (x <= l && r <= y) return node[t];
    m = (l + r) >> 1;
    if (y <= m) return range_min_query( t << 1,      l, m, x, y);
    if (m < x)  return range_min_query((t << 1)|1, m+1, r, x, y);
    else {
        a = range_min_query(t << 1, l, m, x, m);
		b = range_min_query((t<<1)|1, m+1, r, m+1, y);
		if (b < a) a = b;
		return a;
	}
}

void update(int t, int l, int r, int x, unsigned y)
{
	int m;
	unsigned a, b;

	if (l == r) { node[t] = y; return; }
 	m = (l + r) >> 1;
    if (x <= m) update( t << 1,      l, m, x, y);
    else        update((t << 1)|1, m+1, r, x, y);

	a = node[t << 1], b = node[(t << 1)|1];
	if (b < a) a = b;
	node[t] = a;
}


int main()
{
	int n, q, op;
	int x, y;

	n = in(), q = in();
	memset(node, INF, n << 4);

	while (q--) {
		op = gc() & 1, gc();
		x = in()+1, y = in()+1;
		if (op) out(range_min_query(1, 1, n, x, y));
		else update(1, 1, n, x, y-1);
	}
	return 0;
}



Measured memory_bytes: 3216
import java.util.Scanner;

public class Main{

	public static void main(String args[]){
		new Main().mainrun();
	}

	Scanner scan;
	private final int interval_deg = 30;
	private final int interval_r = 100;

	private int N;

	private void mainrun() {
		scan = new Scanner(System.in);

		N = scan.nextInt();

		for(int i = 0;i < N;i++) {
			System.out.println(looprun(scan.nextInt(),scan.nextInt()));
		}

		scan.close();
	}

	private String looprun(double r,double deg) {
		String ans = "";
		int p = (int) (r / interval_r + (int)(deg / interval_deg) * 5);
		ans += p;
		if(r % interval_r != 0) {
			ans += " " + (p + 1);
		}
		if(deg % interval_deg != 0){
			ans += " " + (p + 5);
		}
		if(deg % interval_deg != 0 && r % interval_r != 0){
			ans += " " + (p + 6);
		}

		return ans;
	}
}



Measured memory_bytes: 26372
/*
      Ashraful Islam Paran
      13-September-2020
      17:38:07
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(n) for (int i = 0; i < n; i++)
#define fo(i, x, n) for (int i = x; i < n; i++)
#define fb(i, x, n) for (int i = n - 1; i >= x; i--)
#define w(t)  \
    int t;    \
    cin >> t; \
    while (t--)

typedef unsigned long long ull;
typedef vector<long long> vi;
#define msi map<string, long long>
#define mii map<long long, long long>
const int MX = 2e5 + 5;
const int INF = 1e18;
#define pb push_back
#define endl "\n"
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define all(x) x.begin(), x.end()
#define ff first
#define ss second

void print(int a[], int n)
{
    for (int i = 0; i < n; i++)
    {
        cout << a[i] << " ";
    }
    cout << endl;
}

void print(vi &v)
{
    f(v.size())
    {
        cout << v[i] << " ";
    }
    cout << endl;
}

int32_t main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    // online submission
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(b>0&&d>0)
    {
        cout<<max(a*c,b*d)<<endl;
    }
    else if(a<0&&c<0)
    {
        cout<<max(a*c,b*d)<<endl;
        
    }
    else 
    {
        cout<<max(a*d,b*c)<<endl;

    }
    
    
    cerr<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
    return 0;
}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/math/tools/minima.hpp>

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

namespace adaptor = boost::adaptors;
using namespace std;
using boost::math::tools::brent_find_minima;
using boost::irange;
using boost::algorithm::join;
using boost::algorithm::split;
using boost::algorithm::replace_all;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;

// TOP

void	Main()
{
	string	s, t;
	cin >> s >> t;
	rep(i, s.size())
	{
		s = s.back() + s.substr(0, s.size() - 1);
		if (s == t)
		{
			cout << "Yes" << endl;
			return ;
		}
	}
	cout << "No" << endl;
}
// END

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


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

bool isPrime(llint n) {
    llint i;

    if (n<2) return false;
    else if (n==2) return true;
    if (n%2==0) return false;
    for(i=3;i*i<=n;i+=2) {
        if(n%i==0) return false;
    }
    return true;
}

vector<pair<llint, llint>> prime_factorize(llint n) {
    vector<pair<llint, llint> > res;
    llint num;

    for(llint p=2;p*p<=n;p++) {
        if (n%p!=0) continue;
        num = 0;
        while (n%p==0) { ++num; n /= p; }
        res.push_back(make_pair(p,num));
    }
    if (n!=1) res.push_back(make_pair(n,1));
    return res;
}

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

    llint ans = 1;
    vector<pair<llint, llint>> res(1001);
    for(llint in=1;in<=n;in++) {
        auto restmp = prime_factorize(in);
        for(auto irestmp:restmp) {
            res.at(irestmp.first).second += irestmp.second;
        }
    }
    for(auto ires:res) {
        ans *= 1+ires.second;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

vec<int, 2> solve(const vec<int, 2>& grid) {
  int H = grid.size(), W = grid[0].size();
  vec<int, 2> res = make_v(H, W, 0);
  vector<int> sum(W, 0);
  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      if (grid[y][x] == 1) {
        sum[x] = 0;
      } else {
        ++sum[x];
      }
      res[y][x] = sum[x];
    }
  }
  return res;
}

vec<int, 2> trans(const vec<int, 2>& grid) {
  int H = grid.size(), W = grid[0].size();
  vec<int, 2> res = make_v(W, H, 0);
  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      res[W - x - 1][y] = grid[y][x];
    }
  }
  return res;
}

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int H, W;
  while (cin >> H >> W) {
    vector<string> grid(H);
    for (auto& line : grid) cin >> line;
    vec<int, 2> G = make_v(H, W, 0);
    for (int y = 0; y < H; y++) {
      for (int x = 0; x < W; x++) {
        G[y][x] = grid[y][x] == '#' ? 1 : 0;
      }
    }
    auto A = solve(G);
    G = trans(G);
    auto B = solve(G);
    G = trans(G);
    auto C = solve(G);
    G = trans(G);
    auto D = solve(G);
    G = trans(G);
    int res = 0;
    for (int y = 0; y < H; y++) {
      for (int x = 0; x < W; x++) {
        if (G[y][x]) continue;
        int score = A[y][x] + B[W - x - 1][y] + C[H - y - 1][W - x - 1] + D[x][H - y - 1] - 3;
        res = max(res, score);
      }
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 98560
#include<stdio.h>

int main()
{
    int n,count1=0,count2=0,j;
    scanf("%d",&n);
    int arr[n];
    for(int i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
    }
    for(int i=0;i<n;i++)
    {
        if((arr[i]==(i+1)))
        {
            count1++;
        }
        if(arr[i]!=(i+1))
        {
            count2++;
        }
    }
    if((count1==n))
    {
        printf("YES\n");
    }
    else if(count2<=2)
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }


    return 0;
}



Measured memory_bytes: 1616
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <utility>
#include <random>
#include <chrono>

using namespace std;

#define ll long long
#define encode(node, coins) (((node - 1) * 5010) + coins)

struct Edge {
    int to, len;
};

int n, m, s;

vector<Edge> graph[300005];
ll dist[300005];

void addedge(int node1, int node2, int cost)
{
    Edge e; e.to = node2; e.len = cost;
    graph[node1].push_back(e);
}

int main()
{
    scanf("%d%d%d", &n, &m, &s);
    if (s > 5000) s = 5000;
    for (int i = 1; i <= m; i++) {
        int u, v, a, b;
        scanf("%d%d%d%d", &u, &v, &a, &b);
        for (int oldamt = 5000; oldamt >= a; oldamt--) {
            addedge(encode(u, oldamt), encode(v, oldamt - a), b);
            addedge(encode(v, oldamt), encode(u, oldamt - a), b);
        }
    }
    for (int i = 1; i <= n; i++) {
        int c, d; scanf("%d%d", &c, &d);
        for (int oldamt = 0; oldamt <= 5000; oldamt++) {
            addedge(encode(i, oldamt), encode(i, min(oldamt + c, 5000)), d);
        }
    }
    for (int i = 0; i < 300005; i++) dist[i] = 10000000000000000LL;
    dist[encode(1, s)] = 0;
    set<pair<ll, int> > dij; dij.insert(make_pair(0, encode(1, s)));
    while (!dij.empty()) {
        pair<ll, int> cur = *(dij.begin());
        dij.erase(dij.begin());
        int node = cur.second;
        for (int i = 0; i < graph[node].size(); i++) {
            int nxt = graph[node][i].to;
            ll newdist = (ll)graph[node][i].len + cur.first;
            if (newdist < dist[nxt]) {
                dij.erase(make_pair(dist[nxt], nxt));
                dist[nxt] = newdist;
                dij.insert(make_pair(dist[nxt], nxt));
            }
        }
    }
    for (int i = 2; i <= n; i++) {
        ll curcost = 10000000000000000LL;
        for (int j = 0; j <= 5000; j++) {
            curcost = min(curcost, dist[encode(i, j)]);
        }
        printf("%lld\n", curcost);
    }
    return 0;
}


Measured memory_bytes: 35844
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner seer = new Scanner(System.in);
		char[] s = seer.nextLine().toCharArray();
		for(int i = 0; i < s.length-1; i++){
			if(s[i] == s[i+1]){
				System.out.printf("%d %d\n", i+1, i+2);
				return;
			}
		}
		for(int i = 0; i < s.length-2; i++){
			if(s[i] == s[i+2]){
				System.out.printf("%d %d\n", i+1, i+3);
				return;
			}
		}
		System.out.println("-1 -1");
	}

}


Measured memory_bytes: 27712
#include <cstdio>
#include <algorithm>

using namespace std;

#define INF (1<<28)
#define MD 200
#define MN 200
int D, N;
int T[MD+1];
int CA[MN+1], CB[MN+1], CC[MN+1];

int solve() {
    int dp[D][N];
    for (int i = 0; i < D; i++) {
        for (int j = 0; j < N; j++) {
            if (CA[j] <= T[i] && T[i] <= CB[j]) {
                dp[i][j] = 0;
            } else {
                dp[i][j] = -1;
            }
        }
    }
    for (int i = 1; i < D; i++) {
        for (int j = 0; j < N; j++) {
            if (dp[i][j] < 0) continue;
            for (int k = 0; k < N; k++) {
                if (dp[i-1][k] < 0) continue;
                dp[i][j] = max(dp[i][j], dp[i-1][k] + abs(CC[j] - CC[k]));
            }
        }
    }
    int ret = 0;
    for (int i = 0; i < D; i++) {
        for (int j = 0; j < N; j++) {
            ret = max(ret, dp[i][j]);
        }
    }
    //for (int i = 0; i < D; i++) {
    //    for (int j = 0; j < N; j++) {
    //        printf("%4d", dp[i][j]);
    //    }
    //    printf("\n");
    //}
    return ret;
}

int main() {
    scanf("%d %d", &D, &N);
    for (int i = 0; i < D; i++) scanf("%d", &T[i]);
    for (int i = 0; i < N; i++) scanf("%d %d %d", &CA[i], &CB[i], &CC[i]);
    printf("%d\n", solve());
    return 0;
}

Measured memory_bytes: 1184
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
const int MOD=1000000007;
int K,dist[100000];
deque<int> tobo;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >>K;
	for(int i=0;i<K;i++)
	{
		dist[i]=MOD;
	}
	dist[1]=1;
	tobo.push_back(1);
	while(tobo.size())
	{
		int x=tobo.front();
		tobo.pop_front();
		if(dist[(10*x)%K]>dist[x])
		{
			dist[(10*x)%K]=dist[x];
			tobo.push_back((10*x)%K);
		}
		if(dist[(x+1)%K]>dist[x]+1)
		{
			dist[(x+1)%K]=dist[x]+1;
			tobo.push_back((x+1)%K);
		}
	}
	cout <<dist[0];
    return 0;
}

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

using lint = long long;
#define bit(n) ((lint)1 << n)
const int INF = 1e9;
const lint LINF = 1e18;

const lint MOD = 1e9 + 7;
// const lint MOD = 998244353;

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

    int n, m;
    cin >> n >> m;
    vector<vector<int>> s(m, vector<int>(0));
    for (int i = 0; i < m; i++) {
        int k;
        cin >> k;
        s[i].resize(k);
        for (int j = 0; j < k; j++) {
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    vector<int> p(m);
    for (int i = 0; i < m; i++) {
        cin >> p[i];
    }

    int ans = 0;
    for (int i = 0; i < bit(n); i++) {
        vector<bool> on(n);
        for (int j = 0; j < n; j++) {
            if ((i & bit(j))) {
                on[j] = true;
            }
        }

        bool ok = true;
        for (int j = 0; j < m; j++) {
            int num_on = 0;
            for (int k = 0; k < s[j].size(); k++) {
                if (on[s[j][k]]) {
                    num_on++;
                }
            }
            if (num_on % 2 != p[j]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
const ll mod = 998244353;
vector<int> a(4000);
int n,s;
ll dp[4000][4000][3];
int ways(int l,int r,int S){
    if(S == 0){
        return 1;
    }
    if(r == l){
        return 0;
    }
    return ways(l,r-1,S) + (S>=a[r-1]?ways(l,r-1,S-a[r-1]):0);
}



int main(){
    cin >> n >> s;
    for(int i = 0;i<n;++i){
        cin >> a[i];
    }
   
    /*
     int ans  = 0;
    for(int i = 0;i<n;++i){
        for(int j = i;j < n;++j){
            ans += ways(i,j+1,s);
            if(ans >= mod){
                ans-=mod;
            }
        }
    }
    
    cout << ans <<"\n";
    */
   auto add =[&](ll &x,ll y){
       x += y;
       x %= mod;
   };
   
   memset(dp,0LL,sizeof dp);
   dp[0][0][0] = 1;
   for(int i = 0;i<n;++i){
       for(int j = 0;j<=s;++j){
            add(dp[i+1][j][0],dp[i][j][0]);
            add(dp[i+1][j][1],dp[i][j][0]+dp[i][j][1]);
            add(dp[i+1][j][2],dp[i][j][0]+dp[i][j][1]+dp[i][j][2]);
            if(j + a[i] <= s){
                add(dp[i+1][j+a[i]][1],dp[i][j][0] + dp[i][j][1]);
                add(dp[i+1][j+a[i]][2],dp[i][j][0] + dp[i][j][1]);
            }  
       }
   }
   cout << dp[n][s][2] <<"\n";
    return 0;    
}

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

ans = 0
for i in range(1, int(n ** 0.5) + 1):
    if i > 1 and n % i == 0 and n // (i - 1) == n % (i - 1):
        ans += i - 1
    m = n // i - 1
    if m > 0 and n % i == 0 and n // m == n % m:
        ans += m
print(ans)


Measured memory_bytes: 9352
#include <iostream>

using namespace std;

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


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
    int N, u, v;
    cin >> N >> u >> v;
    u--, v--;
    Graph G(N);
    for (int i = 0; i < N - 1; ++i) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    queue<int> que;
    vector<int> dist1(N, -1);
    que.push(u);
    dist1[u] = 0;
    while (!que.empty()) {
        int k = que.front();
        que.pop();

        for (auto nk : G[k]) {
            if (dist1[nk] != -1)
                continue;
            dist1[nk] = dist1[k] + 1;
            que.push(nk);
        }
    }

    vector<int> dist2(N, -1);
    que.push(v);
    dist2[v] = 0;
    int mdist = 0, lv, dif = 0;
    while (!que.empty()) {
        int k = que.front();
        que.pop();

        for (auto nk : G[k]) {
            if (dist2[nk] != -1)
                continue;
            dist2[nk] = dist2[k] + 1;
            que.push(nk);
        }
    }

    int ans = 0;
    for (int i = 0; i < N; ++i)
        if (dist1[i] < dist2[i])
            ans = max(dist2[i] - 1, ans);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;



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

    vector<tuple<string, int, int>> rs(n);
    for (int i = 0; i < n; ++i) {
        cin >> get<0>(rs[i]) >> get<1>(rs[i]);
        get<1>(rs[i]) *= -1;
        get<2>(rs[i]) = i + 1;
    }
    sort(rs.begin(), rs.end());
    for(const auto x : rs){
        cout << get<2>(x) << endl;;
    }
}


Measured memory_bytes: 3648
from sys import exit, stderr, stdin
input = stdin.readline
# setrecursionlimit(10**7)
import heapq
def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return


def main():
    N, M = [int(n) for n in input().split()]
    A = [-int(n) for n in input().split()]
    heapq.heapify(A)
    while(M):
        targ = heapq.heappop(A)
        targ /= 2
        heapq.heappush(A,targ)
        M-=1

    print(sum([-int(a) for a in A]))



if __name__ == "__main__":
    main()


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

// GCD, LCM
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main()
{
    double R, pie=3.14159265358979323846;

    cin >> R;

    cout << fixed <<setprecision(10)<<endl;

    cout << 2*R*pie <<endl;



    return 0;
}

Measured memory_bytes: 3804