akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];

    ll sum = 0, cnt1 = 0, cnt2 = 0;

    for (int i = 0, s = 1; i < n; i++, s *= -1)
    {
        sum += a[i];
        if (sum * s <= 0)
            cnt1 += abs(sum) + 1, sum = s;
    }
    sum = 0;
    for (int i = 0, s = -1; i < n; i++, s *= -1)
    {
        sum += a[i];
        if (sum * s <= 0)
            cnt2 += abs(sum) + 1, sum = s;
    }

    OP(min(cnt1, cnt2));
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main(int argc, char const *argv[])
{
    int R[MAX], n;
    
    cin >> n;
    for ( int i = 0; i < n; i++ ){ cin >> R[i]; }

    int maxv = - 2000000000;
    int minimum = R[0];
    
    for(int i = 1; i < n; i++)
    {
        maxv = max(maxv, R[i]-minimum);
        minimum = min(minimum, R[i]);
    }

    cout << maxv << endl;

    return 0;
}



Measured memory_bytes: 3904
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,ans = 0;
	int a[202];
	cin >> n;
	for (int i = 1; i <= n * 2; i++) cin >> a[i];
	sort(a+1,a+n+n+1);
	for (int i = n * 2 - 1; i >= 1; i -= 2) ans += a[i];
	cout << ans << endl;
 } 

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

#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define int long long

/*
 */

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

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

  sort(a.begin(), a.end());
  sort(b.rbegin(), b.rend());

  int m = (n-1)/2;
  int l = a[m], r = b[m];
  int ans = r-l+1;
  if(n%2 == 0){
    int l2 = a[m+1], r2 = b[m+1];
    int l3 = l+l2, r3 = r+r2;

    ans = r3-l3+1;
  }
  cout << ans << endl;

  return 0;
}



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

int main(){
  char a, b; std::cin >> a >> b;
  char ans;
  if ((a == 'H') && (b == 'H')) {
    // AtCodeerくんが正直者で、かつ「TopCoDeerくんは正直者だ」と発言しているとき
    ans = 'H';
  } else if ((a == 'D') && (b == 'H')) {
    // AtCodeerくんが嘘つきで、かつ「TopCoDeerくんは正直者だ」と発言しているとき
    ans = 'D';
  } else if ((a == 'H') && (b == 'D')) {
    // AtCodeerくんが正直者で、かつ「TopCoDeerくんは嘘つきだ」と発言しているとき
    ans = 'D';
  } else {
    // AtCodeerくんが嘘つきで、かつ「TopCoDeerくんは嘘つきだ」と発言しているとき
    ans = 'H';
  }
  printf("%c\n", ans);
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(long long int i=a; i<n; i++)
#define loop(i,a,n)	for(long long int i=a; i>=n; i--)
const long long int m=1e9+7;
int main() 
{	
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);	

	long long int a,b,ct=0;
	cin>>a>>b;
	forr(i,b,a+2)
	{
		long long int x=(i*(i-1)/2);
		long long int y=(a*(a+1)/2)-((a-i)*(a-i+1)/2);
		ct+=(y-x+1);
		ct%=m;
	}
	cout<<ct;
	
	return 0;	
}

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

#define INF 100000000



int main(){
    int n;
    cin>>n;
    vector<int> p,q;
    rep(i,n){
        int temp;
        cin>>temp;
        p.push_back(temp);
    }
    rep(i,n){
        int temp;
        cin>>temp;
        q.push_back(temp);
    }

    vector<int> v;
    rep(i,n) v.push_back(i+1);

    int count = 0;
    int a = -1;
    int b = -1;
    do{
        if(a == -1 && v == p) a = count;
        if(b == -1 && v == q) b = count;
        if(a != -1 && b != -1) break;
        ++count;
    }while(next_permutation(v.begin(),v.end()));
    
    cout<< abs(a-b) <<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divCeil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

vector<vector<ll>> G(222222);
vector<ll> cnt(222222, 0);
vector<bool> visited(222222, false);
void dfs(ll V)
{
  if (visited.at(V))
    return;
  visited.at(V) = true;

  //cerr << V << endl;

  for (ll i = 0; i < G.at(V).size(); i++)
  {
    if (!visited.at(G.at(V).at(i)))
      cnt.at(G.at(V).at(i)) += cnt.at(V);
    dfs(G.at(V).at(i));
  }
}

int main()
{
  ll N, Q;
  cin >> N >> Q;
  for (ll i = 0; i < N - 1; i++)
  {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    G.at(a).push_back(b);
    G.at(b).push_back(a);
  }
  for (ll i = 0; i < Q; i++)
  {
    ll p, x;
    cin >> p >> x;
    p--;
    cnt.at(p) += x;
  }

  dfs(0);

  for (ll i = 0; i < N; i++)
  {
    cout << cnt.at(i);
    if (i == N - 1)
      cout << endl;
    else
      cout << " ";
  }
}

Measured memory_bytes: 28160
// Problem D - Interesting Cards
#include<bits/stdc++.h>
using namespace std;
vector<int> v;
vector<pair<int, int> > vec;
int arr[100010];
int main()
{
    int n, m;
    cin >> n >> m;
    for(int i=0; i<n; i++)
    {
        int tmp;
        cin >> tmp;
        v.push_back(tmp);
    }
    for(int i=0; i<m; i++)
    {
        int a, b;
        cin >> a >>b;
        vec.push_back(make_pair(b, a));
    }
    sort(v.begin(), v.end());
    sort(vec.rbegin(), vec.rend());
    int l = 0;

    // cout << "loop" << endl;
    for(int i=0; i<m; i++)
    {
        int a = vec[i].first;
        int b = vec[i].second;

        int num = upper_bound(v.begin(), v.end(), a) - v.begin() - l;
        // cout << i << " " << l << " " << num << endl;
        if(num >= b)
        {
            arr[l] += a;
            arr[l+b] -= a;
            l = l + b;
        }
        else if(num > 0 && num < b)
        {
            arr[l] += a;
            arr[l+num] -= a;
            l = l + num;
        }
    }
    // cout << "printing" << endl;
    // cout << 0 << " " << arr[0] << endl;
    for(int i=1; i<n; i++)
    {
        arr[i] += arr[i-1];
        // cout << i << " " << arr[i] << endl;
    }
    long long int sum = 0;
    for(int i=0; i<n; i++)
    {
        if(i<l)
        {
            sum += (long long int)arr[i];
        }
        else
        {
            sum += (long long int)v[i];
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1908
def li():
    return list(map(int, input().split()))


def mi():
    return map(int, input().split())


def ii():
    return int(input())


N, M, X = mi()
A = li()

filterdA = list(filter(lambda x: x <= X, A))

print(min(M - len(filterdA), len(filterdA)))


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#define M_PI 3.1415926535897932384626433832795

int main() {
	int n;
	cin >> n;
	vector<int>l(n);
	rep(i, n) {
		cin >> l[i];
	}
	int count(0);
	sort(l.begin(), l.end());
	rep(i, n-1) {
		for (int j = i + 1; j < n - 1; ++j) {
			int ab = l[i] + l[j];
			int k = lower_bound(l.begin(), l.end(), ab) - l.begin();
			count += k - j-1;
		}
	}
	cout << count;
	return 0;
}

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

int n;
string s;

int main() {
	int i;
	
	cin >> n >> s;
	
	int cnt = 0;
	for (i = 0; i + 2 < n; i++) {
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
			cnt++;
		}
	}
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1145141919810364;
int main(){
    ll h,n;
    cin >> h >> n;
    vector<ll> dp(h + 1,INF);
    dp[0] = 0;
    for(ll i = 0; i < n; i++){
        ll a,b;
        cin >> a >> b;
        for(ll j = 0; j < h; j++){
        ll nj = min(j + a, h);
        dp[nj] = min(dp[nj], dp[j] + b);
        }
    }
    cout << dp[h] << endl;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n=1,cnt=0,cntt=0,ans=0,a[10000],b,c,cmp,data,m,h,x,y,xcmp=0,ycmp=0,sum=0;

string s,le,ri;

vector<int> z;

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

      cin >> n >> s;
      rep(i,n){
          if(s[i]=='('){
              b++;
              a[i+1]=b;
          }
          else{
              b--;
              a[i+1]=b;
          }
          x=min(x,a[i+1]);
      }
     if(x>0){
         x=0;
     }
      a[0]=0;
      c=a[n];
     // Cout(c);
      //Cout(x);
      //if(x<0){
      rep(i,x*-1){
          cout << '(';
      }
      //}
      rep(i,n){
          cout << s[i];
      }
     // if(c-x>0){
      rep(i,c-x){
          cout << ")";
      }
     // }
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <unordered_map>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 998244353;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

//入出力高速化(非同期化)
void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main(void) {
    string S; cin >> S;
    int mae = (S[0] - '0') * 10 + (S[1] - '0');
    int usiro = (S[2] - '0') * 10 + (S[3] - '0');
    bool yymm = false;
    bool mmyy = false;
    if (0 <= mae && 1 <= usiro && usiro <= 12) {
        yymm = true;
    }
    if (1 <= mae && mae <= 12 && 0 <= usiro) {
        mmyy = true;
    }
    if (yymm && mmyy) {
        cout << "AMBIGUOUS" << endl;
    } else if (yymm) {
        cout << "YYMM" << endl;
    } else if (mmyy) {
        cout << "MMYY" << endl;
    } else {
        cout << "NA" << endl;
    }
    return 0;
}   



Measured memory_bytes: 760
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * @author khokharnikunj8
 */

public class Main {
    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                new Main().solve();
            }
        }, "1", 1 << 26).start();
    }

    void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CAttackSurvival solver = new CAttackSurvival();
        solver.solve(1, in, out);
        out.close();
    }

    static class CAttackSurvival {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int n = in.scanInt();
            int[] ar = new int[n];
            Arrays.fill(ar, in.scanInt());
            int q = in.scanInt();
            for (int i = 0; i < q; i++) ar[in.scanInt() - 1]++;
            for (int i = 0; i < n; i++)
                if (ar[i] - q <= 0) {
                    out.println("No");
                } else
                    out.println("Yes");

        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}



Measured memory_bytes: 26308
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e15;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,x,ans,s;
    cin >> n >> x;
    rep(i,n){
        cin >> s;
        s = abs(s-x);
        if (i == 0) ans = s;
        ans = gcd(ans,s);
    }
    PRINT(ans);
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(lambda x: int(x) - 1, input().split()))

tel = [[0] * n for _ in range(63)]
tel[0] = a
for i in range(62):
    for j in range(n):
        tel[i + 1][j] = tel[i][tel[i][j]]

now = 0
for i in range(62, -1, -1):
    if k >> i & 1:
        now = tel[i][now]
print(now + 1)


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int N, X;
  cin >> N >> X;
  vector<int> x(N);
  vector<int> dif(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i];
    dif[i] = abs(x[i] - X);
  }
  int ans = dif[0];
  for (int i = 1; i < N; i++) {
    ans = __gcd(ans, dif[i]);
  }
  if (N == 1) {
    cout << dif[0] << endl;
  } else {
    cout << ans << endl;
  }
}


Measured memory_bytes: 3972
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define TYPE int
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}

int main(void){
	char s[10];
	chin(s);
	if(strstr(s,"AC")!=NULL)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 128
def resolve():
    '''
    code here
    '''
    N, K = [int(item) for item in input().split()]

    while N >= K:
        if N >= K:
            N = N % K
        else:
            if N <= K//2:
                pass
            else:
                N = K % N
    
    if N >= K:
        N = N % K
    else:
        if N <= K//2:
            pass
        else:
            N = K % N

    print(N)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 3060
#include<algorithm>
#include<stdio.h>
#include<string.h>
using namespace std;
typedef long long ll;
char q[300000];
ll a[40];
int main()
{
   scanf("%s",q);
   ll s=strlen(q);
   for(int i=0;i<s;i++)
   {
       a[q[i]-'a']++;
   }
   ll sum=(s)*(s-1)/2+1;
   for(int i=0;i<26;i++)
   {
       sum-=(a[i])*(a[i]-1)/2;
   }
   printf("%lld\n",sum);
}


Measured memory_bytes: 384
n=gets.to_i
t,a=gets.split.map &:to_f
h=gets.split.map &:to_f
ans=10**18
j=1
kai=0
h.map{|i|
  i=t-i*0.006
  an=ans
  ans=[ans,((i-a).abs)].min
  if an!=ans
    kai=j
  end
  j+=1
}
puts kai


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

bool bfs(vector<vector<char>> &s, vector<vector<int>> &sRes, vector<P> &que, int y, int x){
  vector<int> ny = {1, -1, 0, 0};
  vector<int> nx = {0, 0, 1, -1};

  rep(i,4){
    int nowY = y+ny[i];
    int nowX = x+nx[i];
    if(nowY < 0 || s.size() <= nowY || nowX < 0 || s.at(0).size() <= nowX || s.at(nowY).at(nowX) == '#' || sRes.at(nowY).at(nowX) != -1) continue;

    sRes.at(nowY).at(nowX) = (sRes.at(y).at(x) + 1);
    if(nowY == s.size()-1 && nowX == s.at(0).size()-1) return true;
    que.push_back(make_pair(nowY, nowX));
  }
  return false;
}

int main() {
  int h, w; cin >> h >> w;
  vector<vector<char>> s(h, vector<char>(w));
  vector<vector<int>> sRes(h, vector<int>(w, -1));
  sRes.at(0).at(0) = 0;
  int count = -1;
  vector<P> que;
  rep(i,h) rep(j,w) {
    char x; cin >> x;
    if(x == '.') count++;
    s.at(i).at(j) = x;
  }

  int ans = -1;

  que.push_back(make_pair(0, 0));
  while(que.size() > 0){
    int y = que.at(0).first;
    int x = que.at(0).second;
    que.erase(que.begin() + 0);

    if(bfs(s, sRes, que, y, x)){
      ans = count - sRes.at(h-1).at(w-1);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
  int n1,n2,l,t,i,x,a,b,ans;
  string s;
int main()
{

  	cin>>s;
  	
  	for (i=0;i<=sizeof(s);i++)
  	  if (s[i]=='9')
  	    {
		  cout<<"Yes";
		  return 0;  
	    }
	    
    cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>

int main() {
    long long N;
    std::cin >> N;
    long long ans = 0;
    for (long long i = 1; i * (i + 1) < N; ++i) {
        if (N % i == 0) {
            ans += N / i - 1;
        }
    }
    std::cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, S=1;
  cin >> N >> K;
  for(int i=0; i<N; i++){
    if(S > K){
      S = S + K;
    }else{
      S = 2 * S;
    }
  }
  cout << S << endl;
}

Measured memory_bytes: 256
if __name__ == "__main__":
	N = int(input())
	B = list(map(int,input().split()))
	A = []
	A.append(B[0])
	for i in range(1,int(len(B))):
		# print(i)
		A_left = B[i-1]
		A_right = B[i]
		A.append(min(A_left,A_right))

	A.append(B[-1])
	ans = 0
	for i in range(0,len(A)):
		ans += A[i]

	print(ans)

Measured memory_bytes: 3064
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
 
class Program
 {
        
        static string S;  
  
        static void Main(string[] args)
        {
          //入力を受け取る
          S = Console.ReadLine();
          int[] res = new int[S.Length];
          
          for(int i = 1;i < S.Length ; i++){
            if(S[i-1] == 'R' && S[i] == 'L'){
              //i-1番目より前のRが続く個数を求める
              int Rcount = SuccessiveR(i-1);
              //i番目以降のLが続く個数を求める
              int Lcount = SuccessiveL(i);
              
              //Rから偶数個離れている子供の人数を求めれ
              int evenR = Lcount/2+(Rcount+1)/2;
              int evenL = Lcount+Rcount-evenR;
              res[i-1] = evenR;
              res[i]   = evenL;
            }
          }
          
          Console.WriteLine(string.Join(" ",res));
        }
  
  static int SuccessiveR(int point){
    int count = 0;
    for(int i = point; i >= 0 && S[i] == 'R' ; i--){
      count++;
    }
    return count;
  }
  
  static int SuccessiveL(int point){
    int count = 0;
    for(int i = point; i < S.Length && S[i] == 'L'; i++){
      count++;
    }
    return count;
  }
  
 }

Measured memory_bytes: 13152
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

int main(){
    double pi = 3.14159;
    int n;
    cin >> n;
    cout << 2*pi*n;
    return 0;
}




Measured memory_bytes: 3784
#include <cstring>
#include <climits>
#include <iostream>
#include <vector>
using namespace std;
const int MAX_N = 300;
const int MAX_M = MAX_N * (MAX_N - 1) / 2;

int n, m;
int s, t;
int capacity[MAX_N][MAX_N];
int flow[MAX_N][MAX_N];
vector<int> graph[MAX_N];

bool used[MAX_N];
int dfs(int from, int to, int f) {
	if (from == to) return f;
	used[from] = true;
	for (unsigned i = 0; i < graph[from].size(); i++) {
		const int next = graph[from][i];
		const int cap = capacity[from][next];
		if (!used[next] && cap - flow[from][next] > 0) {
			const int d = dfs(next, t, min(f, cap));
			if (d > 0) {
				flow[from][next] += d;
				flow[next][from] -= d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow() {
	int res = 0;
	while (true) {
		memset(used, 0, sizeof(used));
		int f = dfs(s, t, INT_MAX);
		if (f == 0) return res;
		res += f;
	}
}

int main () {
	vector<pair<int, int> > edges;
	
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		capacity[x][y]++;
		capacity[y][x]++;
		edges.push_back(make_pair(x, y));
		graph[x].push_back(y);
		graph[y].push_back(x);
	}
	cin >> s >> t;
	s--; t--;
	
	cout << max_flow() << endl;
	
	vector<int> ans;
	for (int i = 0; i < m; i++) {
		pair<int, int>& e = edges[i];
		if (flow[e.second][e.first] > 0) {
			ans.push_back(i);
		}
	}
	cout << ans.size() << endl;
	for (unsigned i = 0; i < ans.size(); i++) {
		cout << ans[i] + 1 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1968
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define Test ll t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define rep(i, a, b) for(ll i=a;i<b;i++)
#define repR(i,a,b) for(ll i=a;i>=b;i--)
#define loopS(i,a,b,step) for(ll i=a;i<b;i+=step)
#define loopRS(i,a,b,step) for(ll i=a;i>=b;i-=step)
#define ull unsigned long long int
#define pll pair<ll,ll>
#define puu pair<ull, ull>
#define V vector
#define M map
#define UM unordered_map
#define mp(x,y) make_pair(x,y)
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define inf INT_MAX
#define S3(a,b,c) cin >> a >> b >> c
#define S2(a,b) cin >> a >> b
#define debug(x) cerr << #x << " = " << x << endl;
#define debug2(x,y) cerr << #x << " = " << x << " " << #y << " = " << y << endl;
#define debug3(x,y,z) cerr << #x << " = " << x << " " << #y << " = " << y <<  " " << #z << " = " << z << endl;
using namespace std;

void input(ll n, ll arr[]) {
	rep(i, 0, n)cin >> arr[i];
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cout.tie(NULL);
	ll x; cin >> x;
	if (x >= 30)cout << "Yes\n";
	else cout << "No\n";
}


Measured memory_bytes: 3616
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vd vector<double>
#define vb vector<bool>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define reverse_v(a) reverse(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    (c) ? (cout << "Yes" << endl) : (cout << "No" << endl);
}

void Print(bool c)
{
    (c) ? (cout << "YES" << endl) : (cout << "NO" << endl);
}

//最小公倍数
template <typename T>
T gcd(T a, T b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

//最大公約数
template <typename T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}
//セカンドキー->ファーストキーの順ソート
bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

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

int eve(int x)
{
    if (x % 400 == 0)
        return 1;
    if (x % 100 == 0)
        return 0;
    if (x % 4 == 0)
        return 1;
    return 0;
}

int main(void)
{
    string s;
    cin >> s;
    set<char> mp;
    for (auto c : s)
        mp.insert(c);
    if (mp.size() == 1)
        return cout << 0 << endl, 0;
    int ans = INF;
    for (auto x : mp)
    {
        //cout << x << endl;
        string t = s;
        int cnt = 0;
        while (1)
        {
            bool f = true;
            string tmp;
            rep(i, 0, t.size() - 1)
            {
                if (t[i] == x || t[i + 1] == x)
                    tmp += x;
                else
                    tmp += t[i], f = false;
            }
            //cout << tmp << endl;
            cnt++;
            if (f)
                break;
            t = tmp;
        }
        ans = min(ans, cnt);
        //cout << ans << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

class Edge
{
public:
    int to, cost;
    Edge(){};
    Edge(int to0, int cost0){to = to0; cost = cost0;}
};

void shortestPath(const vector<vector<Edge> >& edges, int start, vector<int>& dist)
{
    dist.assign(edges.size(), INT_MAX);
    dist[start] = 0;
    priority_queue<pair<int,int> ,vector<pair<int,int> >, greater<pair<int,int> > > q;
    q.push(make_pair(0, start));

    while(!q.empty()){
        pair<int, int> p = q.top();
        q.pop();
        int v = p.second;
        if(dist[v] < p.first)
            continue;
        for(unsigned i=0; i<edges[v].size(); ++i){
            Edge e = edges[v][i];
            if(dist[v] + e.cost < dist[e.to]){
                dist[e.to] = dist[v] + e.cost;
                q.push(make_pair(dist[e.to], e.to));
            }
        }
    }
}

int main()
{
    for(;;){
        int c, n, m, s, d;
        cin >> c >> n >> m >> s >> d;
        if(c == 0)
            return 0;
        -- s;
        -- d;

        vector<vector<Edge> > edges((c+1) * n);
        for(int i=0; i<m; ++i){
            int a, b, f;
            cin >> a >> b >> f;
            -- a;
            -- b;

            for(int j=0; j<=c; ++j){
                edges[a+j*n].push_back(Edge(b+j*n, f));
                edges[b+j*n].push_back(Edge(a+j*n, f));
            }
            for(int j=0; j<c; ++j){
                edges[a+j*n].push_back(Edge(b+(j+1)*n, f/2));
                edges[b+j*n].push_back(Edge(a+(j+1)*n, f/2));
            }
        }

        vector<int> dist;
        shortestPath(edges, s, dist);
        int ret = INT_MAX;
        for(int i=0; i<=c; ++i)
            ret = min(ret, dist[d+i*n]);
        cout << ret << endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPD(i,n) for(int i=(n)-1;i>=0;--i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=(b);--i)
#define TLE() cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms.\n";
const ll MOD = 1E9+7;
const ll IINF = 1E18;
const int INF = 1e9;
const double EPS = 1E-9;
const double PI = atan(1.0) * 4.0;
template<class T> T getbit(T s, int i) {return s>>i&1;}
template<class T> void flipbit(T& s, int i) {s^=(1LL<<i);}
constexpr int cntbit(ll x) {return __builtin_popcountll(x);}
constexpr int lg2(ll x) {return __lg(x);} // return int(log2(x))
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 
ll fpow(ll a,ll p){ll res=1LL;while(p){if(p&1LL) res=res*a%MOD;a=a*a%MOD;p>>=1LL;} return res;}

const int N=2e5+5;
int n,q,res[N];
vector<pair<int,pair<int,int>>> b;
set<pair<int,int>> p;

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n>>q;
	REP(i,n){
		int s,t,x;
		cin>>s>>t>>x;
		b.eb(x,mp(s,t));
	}	
	sort(all(b));
	REP(i,q){
		int d;
		cin>>d;
		p.emplace(d,i);
	}	
	memset(res,-1,sizeof res);
	for(auto i:b){
		int x=i.fi;
		int s=i.se.fi;
		int t=i.se.se-1;
		auto it=p.lower_bound(mp(s-x,-1));
		vector<pair<int,int>> tmp;
		while(it!=p.end()&&s<=it->first+x&&it->first+x<=t){
			res[it->second]=x;
			tmp.eb(*it);
			it++;
		}	
		for(auto j:tmp) p.erase(j);
	}
	REP(i,q) cout<<res[i]<<'\n';
}



Measured memory_bytes: 18328
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxm=2e5+5;
const int mod=1e9+7;
int fac[maxm],inv[maxm];
int a[maxm],b[maxm];
int d[4444][4444];
int n;
int ppow(int a,int b,int mod){
    int ans=1%mod;a%=mod;
    while(b){
        if(b&1)ans=ans*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ans;
}
void init(){
    fac[0]=1;
    for(int i=1;i<maxm;i++)fac[i]=fac[i-1]*i%mod;
    inv[maxm-1]=ppow(fac[maxm-1],mod-2,mod);
    for(int i=maxm-2;i>=0;i--)inv[i]=(i+1)*inv[i+1]%mod;
}
int C(int n,int m){
    if(m<0||m>n)return 0;
    return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
signed main(){
    init();
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i]>>b[i];
    const int base=2000;
    for(int i=1;i<=n;i++){
        d[-a[i]+base][-b[i]+base]++;
    }
    for(int i=0;i<=4010;i++){
        for(int j=0;j<=4010;j++){
            if(i-1>=0)d[i][j]+=d[i-1][j];
            if(j-1>=0)d[i][j]+=d[i][j-1];
            d[i][j]%=mod;
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        ans+=d[a[i]+base][b[i]+base];
        ans%=mod;
    }
    for(int i=1;i<=n;i++){
        ans-=C(2*(a[i]+b[i]),2*a[i]);
        ans%=mod;
    }
    ans=(ans*ppow(2,mod-2,mod)%mod+mod)%mod;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 149108
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int A, B;
    cin >> A >> B;
    if ((A + B) % 2 == 0) {
        cout << (A + B) / 2 << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<cmath>
#include<set>
#include<stack>
#define ll long long
#define max(x,y) (x)>(y)?(x):(y)
#define min(x,y) (x)>(y)?(y):(x)
#define cls(name,x) memset(name,x,sizeof(name))
using namespace std;
const int inf=1<<28;
const int maxn=200010;
const int maxm=110;
const int maxk=100010;
const int mod=1e9+7;
const double pi=acos(-1.0);
int n,t;
int main()
{
    //freopen("in.txt","r",stdin);
    while(~scanf("%d%d",&n,&t))
    {
        int time[maxn];
        int ans=0;
        for(int i=0;i<n;i++)
        {
            scanf("%d",&time[i]);
        }
        for(int i=1;i<n;i++)
        {
            if(time[i]-time[i-1]>=t)
                ans+=t;
            else
                ans+=time[i]-time[i-1];
        }
        ans+=t;
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(){
  int N,i;
  char S[100],T[100],X[200];
  
  scanf("%d\n",&N);
  scanf("%s",S);
  scanf("%s",T);
  
  for(i=0;i<N;i++){
    X[2*i]=S[i];
    X[2*i+1]=T[i];
  }
  for(i=0;i<2*N;i++)
	printf("%c",X[i]);
  printf("\n");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <bits/stdc++.h>
using namespace std;

int main(){
    string S;
    bool flag;
    cin >> S;
    if(S[0] == S[1]){
        if(S[2] == S[3] && S[0] != S[2]){
            flag = true;
        }else{
            flag = false;
        }
    }else if(S[0] == S[2]){
        if(S[1] == S[3] && S[0] != S[1]){
            flag = true;
        }else{
            flag = false;
        }
    }else if(S[0] == S[3]){
        if(S[1] == S[2] && S[0] != S[1]){
            flag = true;
        }else{
            flag = false;
        }
    }else{
        flag = false;
    }
    if(S.length() != 4){
        flag = false;
    }else if('A'<=S[0] && S[0]<='Z'){
        if('A'<=S[1] && S[1]<='Z'){
            if('A'<=S[2] && S[2]<='Z'){
                if('A'<=S[3] && S[3]<='Z'){
                    int k;
                }else{
                    flag = false;
                }
            }else{
                flag = false;
            }
        }else{
            flag = false;
        }
    }else{
        flag = false;
    }


    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
n,m,q = [int(i) for i in readline().split()]
abcd = [[int(i) for i in readline().split()] for _ in range(q)]

ans = 0

def dfs(A):
    if len(A) == n:
        now = 0
        for a, b, c, d in abcd:
            if A[b-1] - A[a-1] == c: # a,bは1始まりの値になっているので、indexとして使う時は-1する
                now += d
        global ans
        ans = max(ans, now)
    else:
        for i in range(A[-1], m+1):
            dfs(A+[i])

for i in range(1, m+1):
    dfs([i])

print(ans)

Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {
	
	int h, w, k;
	cin >> h >> w >> k;
	V<string> c(h);
	rep(i, h)cin >> c[i];

	int black = 0;
	rep(i, h)rep(j, w)if (c[i][j] == '#')black++;

	int ans = 0;
	
	rep(i, 1 << h)rep(j, 1 << w) {
		int now = black;
		rep(k, h)rep(l, w) {
			if ((((i >> k) & 1) || ((j >> l) & 1)) && c[k][l] == '#')now--;
		}
		if (k == now)ans++;
	}
	cout << ans << endl;
}

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

template<typename T>
vector<T> compressed(vector<T> v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    return v;
}

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (int &ai: a) cin >> ai;
    int i = 0; for (int x: compressed(a)) cout << (i++ ? " " : "") << x;
    cout << endl;
    return 0;
}


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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

int main() {
    int n, k; cin >> n >> k;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    int m = *max_element(a.begin(), a.end());
    int g = gcd(a[0], a[1]);
    for (int i = 1; i < n - 1; i++) g = gcd(a[i], a[i + 1]);
    if (m >= k && k % g == 0) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#include<assert.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int inf = 1e17;
const int mod = 1000000007;
typedef pair<int, int> P;
typedef pair<int, P> PP;
int dp[100006];
vector<int>K;
signed main() {
	int n; cin >> n;
	int now = 1;
	rep(i, 7){K.push_back(now); now *= 6;
}
	now = 1;
	rep(i, 7) {
		K.push_back(now); now *= 9;
	}
	fill(dp, dp + n + 1, inf);
	dp[0] = 0;
	rep(i, n) {
		rep(j, K.size()) {
			if (i + K[j] <= n)dp[i + K[j]] = min(dp[i + K[j]], dp[i] + 1);
		}
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 1024
def solve(string):
    n, c = string.split()
    n, c = int(n), list(c)
    wi, ri = 0, n - 1
    while wi < n and c[wi] == "R":
        wi += 1
    while ri >= 0 and c[ri] == "W":
        ri -= 1
    ans = 0
    while wi < n and ri >= 0 and wi < ri:
        c[wi], c[ri], ans = c[ri], c[wi], ans + 1
        wi, ri = wi + 1, ri - 1
        while wi < n and c[wi] == "R":
            wi += 1
        while ri >= 0 and c[ri] == "W":
            ri -= 1
    return str(ans)
 
 
if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Measured memory_bytes: 84176
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
	int p,q;
	cin>>p>>q;
	p=q/__gcd(p,q);
	vector<int> v;
	//cout<<p<<endl;
	for(int i=2;i<=p;i++){
		if(i*i>p){
			v.push_back(p);
			break;
		}
		if(p%i)continue;
		v.push_back(i);
		while(p%i==0)p/=i;
	}
	int ans=1;
	for(int i=0;i<v.size();i++){
		ans*=v[i];
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3156
#include <iostream>
#include <algorithm>
#define MOD 1000000007
using namespace std;
typedef long long ll;

int a[100010];
int c[100010];

ll modpow(ll b, ll x)
{
    b %= MOD;
    ll res = 1;
    
    while(x > 0)
    {
        if (x & 1)
            res = res * b % MOD;
        b = b * b % MOD;
        x >>= 1;
    }
    return res;
}

int main()
{
    int n;
    cin >> n;
    
    fill(a, a + 100010, 0);
    fill(c, c + 100010, 0);
    
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    
    for (int i = 0; i < n; i++)
    {
        int j = a[i];
        if (j % 2 == n % 2)
        {
            cout << 0 << endl; return 0;
        }
        c[j]++;
    }
    
    if (n % 2 == 1 && c[0] != 1) 
    {
        cout << 0 << endl; return 0;
    }

    for (int i = (n % 2 == 1) ? 2 : 1; i <= n - 1; i+=2)
    {
        if (c[i] != 2)
        {
            cout << 0 << endl; return 0;
        }
    }

    cout << modpow((ll)2, (ll)n / 2) << endl;
    
    return 0;
}

Measured memory_bytes: 1024
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n = I()
    x, y = MI()
    x1 = x
    x2 = x
    x3 = x
    x4 = x
    y1 = y
    y2 = y
    y3 = y
    y4 = y
    for _ in range(n-1):
        x, y = MI()
        if x+y > x1+y1:
            x1 = x
            y1 = y
        if -x+y > -x2+y2:
            x2 = x
            y2 = y
        if -x-y > -x3-y3:
            x3 = x
            y3 = y
        if x-y > x4-y4:
            x4 = x
            y4 = y
    temp = [abs(x1-x2)+abs(y1-y2), abs(x1-x3)+abs(y1-y3), abs(x1-x4)+abs(y1-y4), abs(x2-x3)+abs(y2-y3), abs(x2-x4)+abs(y2-y4), abs(x3-x4)+abs(y3-y4)]
    ans = max(temp)
    print(ans)

if __name__ == '__main__':
    main()

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

#define ii pair<int, int>
#define vi vector<int>
#define LL long long int 
#define VLL vector<LL>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define INF int(1e9)

using namespace std;

int main () {
    ios_base::sync_with_stdio(false);
    
    int n, k;
    int r, p, s;
    string str;
    
    cin >> n >> k >> r >> s >> p;
    cin >> str;

    LL sum = 0;

    string plays;
    vector<bool> lost(n, 0);

    for(int i=0; i<str.size(); i++){
        if(i<k){
            if(str[i]=='s'){
                sum+=r;
                plays+='r';
            }
            if(str[i]=='p'){
                sum+=s;
                plays+='s';
            }
            if(str[i]=='r'){
                sum+=p;
                plays+='p';
                
            }
            lost[i] = 0;
        }else{ 
            if(str[i]=='s'){
                if(plays[i-k]!='r')
                    sum+=r, plays+='r';
                else{
                    if(i+k<n and str[i+k]=='p')
                        plays+='p';
                    else 
                        plays+='s';
                }
            }
            if(str[i]=='p'){
                if(plays[i-k]!='s')
                    sum+=s, plays+='s';
                else{
                    if(i+k<n and str[i+k]=='r')
                        plays+='r';
                    else 
                        plays+='p';
                }
            }
            if(str[i]=='r'){
                if(plays[i-k]!='p')
                    sum+=p, plays+='p';
                else{
                    if(i+k<n and str[i+k]=='s')
                        plays+='s';
                    else 
                        plays+='r';
                }
            }
        }
    }

    //cout << plays << endl;
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 640
a=int(input())
b=list(map(int,input().split()))
i=2
num=0
count=1
while num<100:
    list_c=[]
    j=i**count
    for k in range(0,a):
            list_c.append(b[k]%j)
            
    if all(elem == 0 for elem in list_c):
        count+=1
        num+=1
                
    else:
        break
print(count-1)

Measured memory_bytes: 3064
n = int(input())
p = []
s = input().split()
p.append(int(s[0]))
p.append(int(s[1]))
for _ in range(n - 1):
    s = input().split()
    p.append(int(s[1]))

m = [[-1 for _ in range(n)] for _ in range(n)]
for i in range(n):
    m[i][i] = 0

for l in range(2, n + 1):
    for i in range(0, n - l + 1):
        j = i + l - 1
        for k in range(i, j):
            x = m[i][k] + m[k + 1][j] + p[i] * p[k + 1] * p[j + 1]
            if m[i][j] < 0:
                m[i][j] = x
            elif m[i][j] > x:
                m[i][j] = x

print(m[0][n - 1])


Measured memory_bytes: 5680
#include<stdio.h>

int main() {
	int row, col, n;
	scanf("%d %d %d", &row, &col, &n);
	
	int bucket;
	if (row >= col){
		bucket = row;
	} else	{
		bucket = col;
	}
	
	int i = 0, j;
	int count = 0;
	
	while (i < n){
		count++;
		i += bucket;
	}
	
	printf("%d\n", count);
	
	return 0;
}



Measured memory_bytes: 1704
def solve():
    n=int(input())
    a=[0]+list(map(int,input().split()))
    b=[0]*(n+1)
    for i in range(1,n+1) :
        b[i]=b[i-1]+a[i]
    m=int(1e9+7)
    ans=0
    for i in range(1,n+1) :
        ans= (ans+a[i]*b[i-1])%m
    return ans

print(solve())


Measured memory_bytes: 31652
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    int sum = a + b + c;
    int mini = min(a,min(b,c));
    int maxi = max(a,max(b,c));
    int zhog = sum - mini - maxi;
    int cha = maxi*2 - mini - zhog;
    while(cha % 2 != 0)
    {
        cha += 3;
    }
    printf("%d\n",cha/2);
    return 0;
}


Measured memory_bytes: 256
//CODING ME ACCHHA KARNEKA HAI TERKO TO BAS PRACTICE KARTE REH
#include <bits/stdc++.h>
#define pragma
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define aisort sort(a,a+n)
#define adsort sort(a,a+n,greater<ll>())
#define PI 2 * acos(0)

typedef pair<ll, ll> pii;
typedef pair<ll, pii> piii;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef set<ll> Set;

const ll maxs = 1e5+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;

//MODULO OPEARTIONS
    inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
    inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
    inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

//POWER
    ll fastpow(ll x,ll y)
    {ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

//MODULAR INVERSE
    ll inv(ll x){ return fastpow(x , mod - 2);}
    
//PRIME
    bool isPrime(ll 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; } 

bool pali(string s)
{
    string r;
    r=s;
    reverse(s.begin(),s.end());
    if(s==r)
    return true;
    else
    return false;
    
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    ll n=s.size();
    string s1=s.substr(0,(n-1)/2);
    string s2=s.substr((n+1)/2,n);
    if(pali(s)&&pali(s1)&&pali(s2))
    cout<<"Yes";
    else
    cout<<"No";
}




Measured memory_bytes: 3656