akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define lli long long int
#define scantype int
#define endl "\n"
#define unique(x) x.erase(unique(x.begin(),x.end()), x.end())
 
lli MOD  = 1000000007;
lli inf = 1e15;
 
void scan(scantype &x);
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli string_to_number(string s){lli x=0; stringstream convert(s); convert>>x; return x;}
lli add(lli a,lli b){lli x = (a+b)%MOD; return x; }
lli mul(lli a,lli b){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b){lli x = (a-b+MOD)%MOD; return x; }
lli divi(lli a,lli b){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}
 
#define N 100003

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

  map< pair<int,pair<int,int> >, bool> mp;
 
  pair<int,pair<int,int> > curr = {a,{b,c}};

  int cnt = 0;

  while(1)
  {
  	if(mp[curr])
  	{
  		cout<<"-1";
  		return 0;
  	}
  	
  	mp[curr] = true;

  	if(curr.first&1 | curr.second.first&1 | curr.second.second&1)
  	{
  		cout<<cnt;
  		break;
  	}

  	pair<int,pair<int,int> > cp;

  	cp.first = curr.second.first/2 + curr.second.second/2;
  	cp.second.first = curr.first/2 + curr.second.second/2;
  	cp.second.second = curr.first/2 + curr.second.first/2;
  	
    curr = cp;
  	cnt++;
  }
  return 0;
}
 
 
void scan(scantype &x)
{
    register int c = getchar(); //for negative/positive
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = getchar());
    if(c=='-') {neg=1;c=getchar();}
    for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final int m = scanner.nextInt();

        final int[] heights = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            heights[i] = scanner.nextInt();
        }
        
        final boolean[] isHighest = new boolean[n + 1];
        Arrays.fill(isHighest, true);
        for (int i = 0; i < m; i++) {
            final int a = scanner.nextInt();
            final int b = scanner.nextInt();

            if (heights[a] == heights[b]) {
                isHighest[a] = false;
                isHighest[b] = false;
            } else if (heights[a] > heights[b]) {
                isHighest[b] = false;
            } else {
                isHighest[a] = false;
            }
        }

        final long answer = IntStream.rangeClosed(1, n)
                .mapToObj(i -> isHighest[i])
                .filter(Boolean::booleanValue)
                .count();
        System.out.println(answer);
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}
    

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

template <typename T>
class BinaryIndexedTree
{
    vector<T> arr;
    T initial_value;
    long long size;
    function<T(T, T)> operation;

public:
    BinaryIndexedTree(const long long N, function<T(T, T)> func, T init)
    {
        set_size(N);
        set_initial_value(init);
        initialize_array();
        set_operation(func);
    }

    void set_size(const long long N)
    {
        this->size = N + 1;
    }

    void set_initial_value(const T init)
    {
        this->initial_value = init;
    }

    void initialize_array()
    {
        this->arr = vector<T>(size, initial_value);
    }

    void initialize_array(const T init)
    {
        set_initial_value(init);
        initialize_array();
    }

    void set_operation(const function<T(T, T)> func)
    {
        this->operation = func;
    }

    void update(long long idx, T value)
    {
        while (idx <= this->size)
        {
            this->arr[idx] = this->operation(this->arr[idx], value);
            idx += (idx & -idx);
        }
    }

    T query(long long idx)
    {
        T ret = this->initial_value;
        while (idx > 0)
        {
            ret = this->operation(ret, this->arr[idx]);
            idx -= (idx & -idx);
        }
        return ret;
    }
};

int main()
{
    int N;
    string S;
    cin >> N >> S;
    S = " " + S;

    BinaryIndexedTree<int> bit(26 * (N + 1), [](int a, int b) { return a + b; }, 0);
    for (int i = 1; i <= N; i++)
    {
        bit.update(N * (S[i] - 'a') + i, 1);
    }

    int Q;
    cin >> Q;
    for (int q = 0; q < Q; q++)
    {
        int t;
        cin >> t;
        if (t == 1)
        {
            int i;
            char c;
            cin >> i >> c;

            bit.update(N * (S[i] - 'a') + i, -1);
            bit.update(N * (c - 'a') + i, 1);
            S[i] = c;
        }
        if (t == 2)
        {
            int l, r;
            cin >> l >> r;
            int ans = 0;
            for (int i = 0; i < 26; i++)
            {
                if (bit.query(i * N + r) - bit.query(i * N + l - 1) > 0)
                {
                    ans++;
                }
            }
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 51736
#include<cstdio>
#include<unordered_set>
using namespace std;
int n,m;
unordered_set<int> s[300000];
int main()
{
	scanf("%d%d",&n,&m);
	while(m--)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		s[a].insert(b);
		s[b].insert(a);
	}
	for(int i=2;i<n;i++)
		if(s[i].count(1)&&s[i].count(n)){puts("POSSIBLE");return 0;}
	puts("IMPOSSIBLE");
	return 0;
}


Measured memory_bytes: 37320
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n, m = map(int, input().split())
ab = [0]*n
cd = [0]*m
for i in range(n):
    ab[i] = readints()
for i in range(m):
    cd[i] = readints()
# print(ab)
# print(cd)
x = []
for i in range(n):
    tmp_li = []
    ans = 10**100
    tmp = 0
    for j in range(m):
        tmp = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        # print(ab[i][0], cd[j][0], ab[i][1], cd[j][1])
        # print(i, j)
        tmp_li.append(tmp)
    # print(tmp_li)
    x.append(tmp_li.index(min(tmp_li)))
# print(x)
for i in range(len(x)):
    y = x[i]+1
    print(y)


Measured memory_bytes: 61164
//header{{{
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <boost/hana/functional/fix.hpp>
#include <boost/sort/spreadsort/spreadsort.hpp>
//#include <boost/graph/adjacency_list.hpp>
//#include <boost/graph/dijkstra_shortest_paths.hpp>
//#include <boost/graph/graph_utility.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
  
using namespace std;
//using namespace boost::multiprecision;
//using namespace boost::math;

/*
typedef boost::adjacency_list<boost::listS, boost::vecS, boost::undirectedS,
        boost::no_property, boost::property<boost::edge_weight_t, int> > Graph;
*/


#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define FixPoint boost::hana::fix
#define bsort boost::sort::spreadsort::spreadsort
#define int int_fast64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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


signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout.setf(ios_base::fixed);
    cout.precision(10);

    int n;
    cin >> n;

    vector<int> a(n);

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

    stable_sort(all(a));
    a.erase(unique(all(a)), a.end());

    if(a.size() == n){
        cout << "YES\n";
    }else{
        cout << "NO\n";
    }

    return 0;
}


Measured memory_bytes: 5544
#include <stdio.h>

int check(int a, int b, int r){
	return (a * a + b * b < r * r * 4) ? 1 : 0;
}

int main(void){
	int x,y,z,r;
	int n,i;
	while(scanf("%d%d%d",&x,&y,&z) != EOF){
		if(x == 0 && y == 0 && z == 0){break;}
		scanf("%d",&n);
		for(i = 0; i < n; i++){
			scanf("%d",&r);
			puts(
				(check(x,y,r) || check(y,z,r) || check(z,x,r)) ?
				"OK" : "NA"
			);
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << "NO" << endl;return 0
#define MM <<" "<<
#define Endl endl


signed main(void){
    int R,C,N;
    int x[114514][2],y[114514][2];
    vector<pair<int,int>> G;
    cin >> R >> C >> N;
    REP(i,N){
        REP(j,2){
            cin >> x[i][j] >> y[i][j];
        }
        int r=0;
        REP(j,2){
            if((x[i][j]==0 || x[i][j]==R)||(y[i][j]==0 || y[i][j]==C)){
                r++;
            }
        }
        if(r==2){
            REP(j,2){
                int c=0;
                if(y[i][j]==0){
                    c=x[i][j];
                }else if(x[i][j]==R){
                    c=R+y[i][j];
                }else if(y[i][j]==C){
                    c=2*R+C-x[i][j];
                }else if(x[i][j]==0){
                    c=2*R+2*C-y[i][j];
                }
                //cout << c MM i << endl;
                G.push_back({c,i});
            }
        }
    }
    int M=G.size();
    sort(G.begin(),G.end());
    //REP(i,M){cout << G[i].second << " ";}cout << endl;
    stack<int> K;map<int,bool> L;
    REP(i,M){
        if(L[G[i].second]==0){
            L[G[i].second]=1;
            K.push(G[i].second);
        }else{
            L[G[i].second]=0;
            if(K.top()==G[i].second){
                K.pop();
            }else{
                GOODBYE;
            }
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 13548
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#define mp make_pair
#define pb push_back
using namespace std;

typedef long long li;
template<class T>inline void read(T &x) {
  x = 0;
  T tmp = 1;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') tmp = -1, c = getchar();
  while (c >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + c - '0', c = getchar();
  x *= tmp;
}
template<class T>inline void Max(T &x, T y) {
  if (y > x) x = y;
}
template<class T>inline void Min(T &x, T y) {
  if (y < x) x = y;
}

const int Mod = 998244353;
inline int Add(int x, int y) {
  x += y;
  if (x >= Mod) x -= Mod;
  if (x < 0) x += Mod;
  return x;
}
inline int Mul(int x, int y) {
  return 1LL * x * y % Mod;
}
inline int Pow(int a, int b) {
  int res = (a == 0) ? 0 : 1;
  while (b) {
    if (b & 1) res = Mul(res, a);
    a = Mul(a, a);
    b >>= 1;
  }
  return res;
}
const int N = 3e5 + 10;
int n;
li A, B, K;
int inv[N], fac[N];

inline int C(int n, int m) {
  if (n <= m || m == 0) return 1;
  return Mul(fac[n], Mul(inv[m], inv[n - m]));
} 

int main(void) {
  read(n), read(A), read(B), read(K);
  
  fac[0] = 1;
  for (int i = 1; i <= n; ++i)
    fac[i] = Mul(fac[i - 1], i);
  inv[n] = Pow(fac[n], Mod - 2);
  for (int i = n; i; --i)
    inv[i - 1] = Mul(inv[i], i);
  
  int ans = 0;
  li limx = min(K / A, 1LL * n);
  for (int x = 0; x <= limx; ++x) {
    li tmp = K - 1LL * x * A;
    if (tmp % B != 0) continue;
    int y = tmp / B;
    if (y > n) continue;
    ans = Add(ans, Mul(C(n, x), C(n, y)));
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 2560
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
using namespace std;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef double d;
typedef long double ld;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    ll n=s.size();
    vector<ll> v(n,0);
    for(ll i=n-1;i>=0;i--)
    {
        if(s[i]=='W')
        {
            v[i]++;
        }
    }
    for(ll i=n-2;i>=0;i--)
    {
        v[i]+=v[i+1];
    }
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        if(s[i]=='B')
        {
            ans+=v[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 2196
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void)
{
    long long int a, b, x;

    scanf("%lld%lld%lld", &a, &b, &x);


    if (a == 0 && x != 1)
        printf("%lld", b/x - (a-1)/x + 1);
    else
        printf("%lld", b/x - (a-1)/x);

    return 0;
}


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

double dp[301][301][301];
double solve(int x, int y, int z, int& n)
{
    if(x < 0 || y < 0 || z < 0)
        return 0;
    if(x == 0 && y == 0 && z == 0)
        return 0;
    if(dp[x][y][z] > -0.9)
        return dp[x][y][z];
    double exp = n + x*solve(x-1,y,z,n) + y*solve(x+1,y-1,z,n) + z*solve(x,y+1,z-1,n);
    return dp[x][y][z] = exp/(x+y+z);
}

int main() {
   int n, x;
   cin >> n;
   memset(dp, -1, sizeof dp);
   int o = 0, tw = 0, thr = 0;
   for(int i=1; i <= n; i++)
   {
       cin >> x;
       if(x == 1)
            o++;
       else if(x == 2)
            tw++;
       else thr++;
   }
   cout<<fixed<<setprecision(10)<<solve(o, tw, thr, n);
}


Measured memory_bytes: 213376
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] x = new long[n];
    long[] y = new long[n];
    for(int i = 0;i<n;i++){
      x[i] = sc.nextLong();
      y[i] = x[i];
    }
    Arrays.sort(x);
    for(long a:y){
      if(a<x[n/2]){
        System.out.println(x[n/2]);
      }else{
        System.out.println(x[n/2-1]);
      }
    }
  }
}


Measured memory_bytes: 67380
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1e9+7
#define LINF (long long)4e18


int main(){
  string S;
  cin >> S;
  vector<bool> ok(26,false);
  rep(i,S.size()){
      ok[S[i] - 'a'] = true;
  }
  string ans = "";
  rep(i,26){
      if(ok[i] == false){
        ans = i + 'a';
        break;
      }
  }
  if(ans == "")ans = "None";
  cout << ans << endl; 

} 

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

#define N 200123
#define mod 1000000007

int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    if(fopen("input.in", "r")){
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    long long ans = 0, n;
    cin >> n;
    for(long long i = 1 ; i <= n ; i++){
    	if(i % 3 != 0 && i % 5 != 0) ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
int main(void)
{
	int d,t,s,x;
	scanf("%d %d %d",&d,&t,&s);
	x=t*s;
	if(d<=x){
	printf("Yes\n");
	}
	else{
	printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1636
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
signed main() {
  int N, L;
  cin >> N >> L;
  int eat = INF;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += L+i;
    if (abs(eat) > abs(L+i)) {
      eat = L+i;
    }
  }
  ans -= eat;
  cout << ans << endl;
}


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

int N, M;

int main()
{
    //
    scanf("%d %d", &N, &M);
    int C = 100 * (N - M) + 1900 * M;
    double r = 1 - pow(0.5, M);
    printf("%d\n", int(C / (pow(2, M) * (1 - r) * (1 - r))));
}


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

int main() {

    int N;
    cin >> N;

    int w;
    vector<int> W;
    int sum = 0;

    for (int i = 0; i < N; i++) {
        cin >> w;
        W.push_back(w);
        sum += w;
    }

    int sum_0 = 0;
    int sum_1 = 0;
    for (int i = 0; i < N; i++) {
        sum_0 += W[i];
        if (sum_0 >= 1.0 * sum / 2) {
            sum_1 = sum_0 - W[i];
            break;
        }
    }

    if (abs(sum - sum_0 * 2) > abs(sum - sum_1 * 2)) {
        cout << abs(sum - sum_1 * 2) << endl;
    }
    else {
        cout << abs(sum - sum_0 * 2) << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <numeric>
#include <iomanip>
#include <sstream>
using namespace std;

vector<string> split(const string& s, char delim) {
	vector<string> elems;
	stringstream ss(s);
	string item;
	while (getline(ss, item, delim)) {
		if (!item.empty()) {
			elems.push_back(item);
		}
	}
	return elems;
}

int main() {

	int n, q;
	cin >> n;
	vector<int> tbl(100001);

	long sum = 0;

	for (int i = 0; i < n; i++) {
		int temp;
		cin >> temp;
		sum += temp;
		tbl[temp]++;
	}

	cin >> q;

	int b, c;
	for (int i = 0; i < q; i++) {
		cin >> b >> c;
		sum += (c - b) * tbl[b];
		tbl[c] += tbl[b];
		tbl[b] = 0;
		cout << sum << endl;
	}

	return 0;
};

Measured memory_bytes: 3788
#include<iostream>
using namespace std;
int main(void)
{
    int N,k[10001],A=0,B=0;
    while(1){
        cin>>N;
        if(N==0)break;
        for(int i=0;i<N;i++){
            cin>>k[i];
            if(k[i]==0)B++;
            else if(k[i]>=2)A=1;
            if(i==N-1){
                if(A==0)cout<<"NA\n";
                else cout<<N+1-B<<"\n";
            }
        }
        A=0;B=0;
    }
}

Measured memory_bytes: 1200
let [| A; B |] = stdin.ReadLine().Split() |> Array.map int64

let rec gcd a b =
    match (a, b) with
    | (x, 0L) -> x
    | (0L, y) -> y
    | (a, b) -> gcd b (a % b)

let lcm a b = a * b / (gcd a b)

lcm A B |> stdout.Write


Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

const string YES = "Yes";
const string NO  = "No";

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

    int n, a;

    cin >> n >> a;

    while (n >= 500) {
        n -= 500;
    }

    if (n <= a) {
        cout << YES;
    } else {
        cout << NO;
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAXN=200010,MAXP=10000;
ll n,p;
ll a[MAXN],t[MAXN],b[MAXP];
ll s[MAXN];
char c[MAXN];
int main()
{
	scanf("%lld%lld",&n,&p);
	scanf("%s",c);
	for(ll i=0;i<n;++i) s[i]=c[i]-'0';
	if(p==2||p==5){
		ll num=0;
		for(ll i=0;i<n;++i){
			if(s[i]%p==0) num+=i+1;
		}
		printf("%lld",num);
	}
	else{
		t[0]=1;//t[x]是10的x次方除以p的余数
		for(ll i=1;i<n;++i){
			t[i]=10*t[i-1]%p;
		}
		for(ll i=n-1;i>=0;--i){
			a[i]=t[n-i-1]*s[i]+a[i+1];
			a[i]%=p;
			++b[a[i]];
		}
		ll num=b[0]*(b[0]+1)/2;
		for(ll i=1;i<p;++i) num+=b[i]*(b[i]-1)/2;
		printf("%lld",num);
	}
}

Measured memory_bytes: 5248
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>

using namespace std;
int main() {
	int n, q;
	string name;
	int t;
	cin >> n >> q;
	queue<pair<string, int> > Q;
	for(int i=0; i<n; i++){
		cin >> name >> t;
		Q.push(make_pair(name, t));
	}
	pair<string, int> u;
	int c, timesum = 0;
	while (!Q.empty()) {
		u = Q.front();
		c = min(u.second, q);
		u.second -= c;
		timesum += c;
		Q.pop();
		if(u.second > 0){
			Q.push(u);
		}else {
			cout << u.first << " " << timesum << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 6368
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> PII;
typedef long long ll;
const int MAXN = 302;
ll dis[MAXN][MAXN];
vector<vector<PII> > edges;
vector<pair<int,PII>  >   d;
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			dis[i][j] = LLONG_MAX;
		}
	}
	
	edges.resize(n);
	for(int i=0;i<n;i++)
		edges[i] =vector<PII>();
	int a;

	for(int i=0;i<n;i++){
		for(int j= 0;j<n;j++){
			scanf("%d",&a);
			if (j> i){
				edges[i].pb(mp(j,a));
				edges[j].pb(mp(i,a));
				d.pb(mp(a,mp(i,j)));
			}
		}
	}
	//cout<<__LINE__<<endl;
	for (int i =0;i<n;i++){
		dis[i][i]  =0;
	}
	ll result = 0;
	for(int i=0;i<n;i++){
		for(PII p: edges[i]){
			dis[i][p.fi]  = p.se;
			result+=p.se;
		}
	}
	result = result/2;
	for(int k =0;k<n;k++){
		for(int i = 0;i<n;i++){
			for(int j =0;j<n;j++){
				dis[i][j] = min(dis[i][j],dis[i][k]+dis[k][j]);
			}
		}
	}
	sort(d.begin(),d.end());
	//cout<<__LINE__<<endl;
	for(int i=d.size();i>= 0;i--){
		pair<int,PII> p  = d[i];
		int new_w = p.fi;
		int x = p.se.fi, y = p.se.se;
		bool other = false;
		for(int j=0;j<n;j++){
			if ( j==x || j==y)
				continue;
			if (dis[x][j]+dis[j][y] < new_w){
				printf("-1\n");
				return 0;
			}
			if (dis[x][j]+dis[j][y] == new_w){
				other = true;
			}
		}
		if (other){
			result -= new_w;
		}
	}
	printf("%lld",result);
	return 0;
}

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

for h in range(1, 3501):
    a = 4 * h - N
    if a <= 0:
        continue
    for n in range(max(h, N * h // a + 1), 3501):
        q = 4 * h * n - N * h - N * n
        if q <= 0:
            continue
        p = N * h * n
        if p % q == 0:
            print(h, n, int(p / q))
            quit()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
ll p[111];
ll c[111];
void solve(){
    ll d,g;
    cin>>d>>g;
    
    for(int i=0;i<d;i++)cin>>p[i]>>c[i];
    ll ans =  1e9;
    for(int i=0;i<(1<<d);i++){
        ll trt = 0;
        ll cnt = 0;
        ll lst = 0;
        for(int j=0;j<d;j++){
            if(i&(1<<j)){
                trt+=p[j]*(j+1ll)*100ll+c[j];
                cnt+=p[j];
            }
            else{
                lst = j+1;
            }
        }
        if(trt>=g){
            ans = min(ans,cnt);
        }
        else{
            int dif = g-trt;
            assert(lst>0);
            dif/=(lst*100);
            if(dif<=p[lst-1]){
                ans = min(ans,cnt+dif);
            }
        }
    }
    if(ans<=0)ans = 1;
    cout<<ans<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
int main() {
ll n,m;
cin>>n>>m;
vector <vector <ld> > a(n,vector <ld> (m));
for (int i = 0;i < n;i++)
{
    for (int j = 0;j < m;j++)
    {
        cin>>a[i][j];
    }
}
ll ans = 0;
for (int i = 0;i < n;i++)
{
    for (int j = i + 1;j < n;j++)
    {
        vector <ld> v = a[i];
        vector <ld> u = a[j];
        ld rast = 0;
        for (int q = 0;q < m;q++)
            rast+=((v[q]-u[q])*(v[q]-u[q]));
        rast = sqrt(rast);
        ll e = rast;
        if (rast==e) ans++;
    }
}cout<<ans;
return 0;}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<sys/time.h>
#include<cstring>
#include<set>
#include<cmath>
using namespace std;
typedef long long ll;
inline int ri()
{
	register int x=0;register bool f=0;register char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();}
	return f?-x:x;
}
void wi(ll x)
{
	if(x<0)	x=-x,putchar('-');
	if(x>9)	wi(x/10);
	putchar('0'+x%10);
}
const int N=1e5+7;
int a[N],mx[N];
multiset<int> s;
set<int> s2;
int main()
{
	int n=ri(),i;
	for(i=1;i<=n;i++)	a[i]=ri();
	sort(a+1,a+1+n);
	for(i=n;i>=1;i--)
	{
		if(s2.count(a[i]))	s2.erase(a[i]),mx[++mx[0]]=a[i];
		else	s2.insert(a[i]);
	}
	wi(1ll*mx[1]*mx[2]);
	return 0;
}


Measured memory_bytes: 5376
//dhruv
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
#define ll long long
#define ffor(i,n) for(int i = 0;i < (n); ++i)
#define fro(i,j,n) for(int i = (j);i < (n); ++i)
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pii>
#define ff first
#define ss second
const int mod = 1e9 + 7;
const int inf = 1e18 + 5;
 
template<typename T>
T binpow(T a,T b,T modi){
	T res = 1;
	while(b){
		if(b&1){
			res = (res*a)%modi;
		}
		b /= 2;
		(a *= a) %= modi;
	}
	return res;
}
 
 
template<typename T>
T binpow(T a,T b){
	T res = 1;
	while(b){
		if(b&1){
			res = (res*a);
		}
		b /= 2;
		a *= a;
	}
	return res;
}
 
template<typename T>
T add(T a,T b){
	return (a + b)%mod;
}
template<typename T>
T sub(T a,T b){
	return add(a,mod - b);
}
template<typename T>
T mul(T a,T b){
	return (a*b)%mod;
}

int make_int(string s){
	int x = 0;
	reverse(s.begin(),s.end());
	string tmp = s;
	for(int i = 0;i < s.length(); ++i){
		x *= 10;
		x += (int)(tmp.back() - '0');
		tmp.pop_back();
	}
	return x;
}
 
string make_string(int s){
	string x;
	while(s){
		x.push_back(char(s%10 + '0'));
		s /= 10;
	}
	reverse(x.begin(),x.end());
	return x;
}

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



const int N = 100;
int lp[N + 1];
vector<int> pr;
void ls(){
	for(int i = 2;i <= N; ++i){
		// means prime
		if(lp[i] == 0){
			lp[i] = i;
			pr.push_back(i);
		}
		for(int j = 0;j < pr.size() && pr[j] <= lp[i] && i*pr[j] <= N; j++){
			lp[i*pr[j]] = pr[j];
		}
	}
}


// getting the prime factorisation

vector<int> getfc(int n){
	vi fact;
	while(n != 1){
		int x = lp[n];
		fact.push_back(x);
		while(n%x == 0){
			n /= x;
		}
	}
	return fact;
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;
	vi a(n);
	int cum = 0;
	ffor(i,n){
		cin >> a[i];
		cum ^= a[i];
	}
	for(int i = 0;i < n; ++i){
		cout << (cum^a[i]) << ' ';
	}
	return 0;
}

Measured memory_bytes: 4732
#include<iostream>
#define int long long
using namespace std;
signed main(){
	int n;
	cin>>n;
	int num[n];
	int ans[n];
	int a[n+1];
	for(int i=0;i<=n;++i)
		a[i]=0;
	for(int i=0;i<n;++i){
		cin>>num[i];
		++a[num[i]];
	}
	int start=0;
	for(int i=1;i<=n;i++)
		start=start+(a[i]*a[i]-a[i])/2;
	for(int i=1;i<=n;i++)
		ans[i]=start-(a[i]-1);
	for(int i=0;i<n;++i)
		cout<<ans[num[i]]<<endl;
	return 0;	
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
using ll = long long;
#define ull unsigned ll
#define endl "\n"
#define vi vector<int>
#define vl vector<ll>
#define all(v) (v).begin(),(v).end()
#define mst(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ppi pair<int, pii>
#define mt make_tuple
#define eb emplace_back
using namespace std;

const int N = 2e5 + 5, mod = 1e9 + 7;
const int inf = 1e9;

void solve(){
    int n;
    cin >> n;
    vi a(n);
    int x = 0;
    for(int &i : a){
        cin >> i;
        x ^= i;
    }
    for(int i = 0; i < n; i++){
        int ans = x ^ a[i];
        cout << ans << " ";
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);//cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll t,p;
    t=1;
    //cin>>t;
    for(p=1;p<=t;p++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3988
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl a,b,c,d;
    cin >> a >> b;
    cout << b * 2 - a << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	string s;cin>>s;
	bool flag=true;
	if(s.size()%2==0){	
		rep(i,0,s.size()){
			if(i%2==0){if(s[i]!='h') flag=false;}
			else if(i%2==1){if(s[i]!='i') flag=false;}
        }
	}else{
		flag=false;
	}
	if(flag) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
#define mod 1000000007
#define mmod 998244353
#define all(v) v.begin(), v.end()
using namespace std;
int mypow(int a, int b, int c) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1, c)*a%c;
	int z = mypow(a, b / 2, c);
	return z * z%c;
}
signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (c >= a + b && (c - a - b)*(c - a - b) > 4 * a*b)cout << "Yes" << endl;
	else puts("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

struct MaxSegTree{
    int n; vector<ll> dat;
    //初期化
    MaxSegTree(int _n){
        n=1;
        while(n<_n) n*=2;
        dat=vector<ll>(2*n-1,LLONG_MIN);
    }
    //k番目(0-indexed)の値をaに変更
    void update(int k, ll a){
        k+=n-1;
        dat[k]=max(dat[k], a);
        //更新
        while(k>0){
            k=(k-1)/2;
            dat[k]=max(dat[2*k+1],dat[2*k+2]);
        }
    }
    //内部的に投げられるクエリ
    ll _query(int a, int b, int k, int l, int r){
        if(r<=a || b<=l) return LLONG_MIN;

        if(a<=l && r<=b) return dat[k];

        ll vl=_query(a,b,2*k+1,l,(l+r)/2);
        ll vr=_query(a,b,2*k+2,(l+r)/2,r);
        return max(vl,vr);
    }
    //[a,b)
    ll query(int a, int b){
        return _query(a,b,0,0,n);
    }
};

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

    vector<pair<int,int>> v(n);
    rep(i,n) v[i] = {h[i],i};
    sort(all(v));

    MaxSegTree s(n);
    for(const auto &p:v){
        int idx = p.se;
        ll x = max(0LL, s.query(0,p.se))+a[idx];
        s.update(idx,x);
    }
    cout << s.query(0,n) << "\n";
    return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var d = ReadLine();
            var result = 0;

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    if (j <= i) continue;

                    result += d[i] * d[j];
                }
            }

            Console.WriteLine(result);
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13268
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;


void main() {
    int x, y;
    scan(x, y);
    writeln(x + y / 2);
}





















void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

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

int main(){
  int n,t[50];
  t[0] = 0;
  for(int i=1;i<=30;i++)t[i] = t[i-1]*3+1;

  while(cin >> n){
    if(n&1)cout << t[n/2]*4+1 << endl;
    else cout << t[n/2-1]*3+t[n/2]+1 << endl;
  }
}

Measured memory_bytes: 0
import sys
import math
from bisect import bisect_right
n = 1000000
a = set(range(3, n, 2))
diff = a.difference_update
for i in range(3, int(math.sqrt(n)), 2):
    if i in a:
        diff(range(i*2, n+1, i))

primes = [2] + list(a)
for l in map(int, sys.stdin.readlines()):
    print(bisect_right(primes, l))

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

bool u[110];
int n,k,m,x,R;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cin>>n>>k;
    while (k--){
        cin>>m;
        while (m--){
            cin>>x;
            u[x]=true;
        }
    }
    for (int i=1;i<=n;i++) R+=(!u[i]);
    cout<<R<<'\n';
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
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; }
const long long INF = 1LL <<60;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

ll choose2(ll n){
    return n*(n-1)/2;
}

vector<ll> ans(0);

void dfs(ll a){
    if(a>3234566667) return;
    ans.push_back(a);
    int m = a % 10;
    if(m>0) dfs(a*10 + m-1);
    dfs(a*10 + m);
    if(m<9) dfs(a*10 + m+1);
}

int main(){
    int k;
    cin>>k;
    for(ll i=1;i<10;i++) dfs(i);
    sort(ans.begin(),ans.end());
    cout<<ans[k-1]<<endl;
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(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 = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = 700;
    rep(i,3){
        if (s[i] == 'o') ans += 100;
    }
    PRINT(ans);
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define M 2000001
#define VM 10000

int main(){
  unsigned short *A, *B;
  int C[VM+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
  for(i=0;i<=VM;i++)C[i]=0;
  for(i=0;i<n;i++){
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }
  for(i=1;i<=VM;i++){
    C[i]=C[i]+C[i-1];
  }
    for(j=1;j<=n;j++){
      B[C[A[j]]]=A[j];
      C[A[j]]--;
    }
    for(i=1;i<=n;i++){
      if(i>1)printf(" ");
      printf("%d",B[i]);
    }
    printf("\n");

}



Measured memory_bytes: 9596
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll p = a-b;
    cout << (k%2 == 0 ? p : -p) << endl; 
}

Measured memory_bytes: 3568
a, b = map(int, input().split())

if int(a) == 1 and int(b) != 1:
    print("Alice")
elif int(a) != 1 and int(b) == 1:
    print("Bob")
elif int(a) > int(b):
    print("Alice")
elif int(a) < int(b):
    print("Bob")
elif int(a) == int(b):
    print("Draw")

Measured memory_bytes: 9128
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>

#define rep(i,n) for(int i = 0;i < n;i++)
#define Rep(i,m,M) for(int i = m;i < M;i++)
#define print(var) cout<<#var" = "<<var<<endl;

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;


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

	string S, A;

	cin >> S;
	A = S;
	rep(i, S.size())
	{
			A[i] = S[i] + N;
			if (A[i] > 'Z')
				A[i] -= 26;
	}
	cout << A;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
  long long a,b;
  
  scanf("%lld %lld",&a,&b);
  
  for(long long i = 1; i <= b; i++)
  {
    if((a*i)%b == 0){
      printf("%lld",a*i);
      break;
    }
  }
  return 0;
}

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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<=N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///



void _case()
{
    ll n,i,m,k;
    string a;
    cin>>k>>n>>m;
    if(n%k==0 or m%k==0) {cout<<"OK" el;
    return;}
    while(n!=m){
        if(n%k==0){cout<<"OK" el; return;}
        n++;
    }
    cout<<"NG" el;
}

main()
{
      fastio();
        _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


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

int main()
{
  int N;
  int a, b;
  bool ans = false;
  
  cin >> N;
  for (a = 1; a < 10; a++) {
    b = N / a;
    if (b < 10 && (a * b == N)) {
      ans = true;
      break;
    }
  }
  if (ans == true) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

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

ll N;
vector<ll> a, b, c;
ll memo[100005][4];

ll dp(ll idx, ll cur, ll prev){
    if(idx == N){
        return memo[idx][prev]=0;
    }
    if(memo[idx][prev] != -1){
        return memo[idx][prev];
    }
    ll ans = 0;
    if(prev == 0){
        ans = max(dp(idx+1,b[idx+1],1),dp(idx+1,c[idx+1],2));
    }else if(prev == 1){
        ans = max(dp(idx+1,a[idx+1],0),dp(idx+1,c[idx+1],2));
    }else if(prev == 2){
        ans = max(dp(idx+1,a[idx+1],0),dp(idx+1,b[idx+1],1));
    }
    //cout<<ans<<"\n";
    memo[idx][prev] = cur+ans;
    //cout<<memo[idx]<<"\n";
    return memo[idx][prev];
}
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    memset(memo, -1, sizeof memo);

    cin>>N;
    ll d, e, f;
    for (int i = 0; i < N; ++i)
    {
        cin>>d>>e>>f;
        a.pb(d), b.pb(e), c.pb(f);
    }
    ll q1 = dp(0,a[0],0), q2 = dp(0,b[0],1), q3 = dp(0,c[0],2);
    //cout<<q1<<" "<<q2<<" "<<q3<<"\n";
    cout<<max(q1,max(q2,q3));

}

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

class Program {
    static Scanner cin = new Scanner();

    static void Main(string[] args) {
        int N = cin.Int();
        int W = cin.Int();

        var w = new int[N];
        var v = new int[N];
        for (int i = 0; i < N; i++) {
            w[i] = cin.Int();
            v[i] = cin.Int();
        }

        var dp = new long[110, 100010];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j <= W; j++) { //重さ
                if (j - w[i] >= 0) dp[i + 1, j] = Math.Max(dp[i + 1, j], dp[i, j - w[i]] + v[i]);
                dp[i + 1, j] = Math.Max(dp[i + 1, j], dp[i, j]);
            }
        }
        Console.WriteLine(dp[N, W]);
        Console.ReadLine();
    }
}

class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Long() + add;
        }
        return Array;
    }

    public double Double()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Double() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 92000