akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>
#include <chrono>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
const double EPS = 1e-9;

const int MAX = 3 * 1e5 + 10;
int N;
long long a[MAX], l[MAX], r[MAX];

int main() {
    scanf("%d", &N);
    for (int i = 0; i < 3 * N; ++i) {
        scanf("%lld", a + i);
    }
    priority_queue<long long, vector<long long>, greater<long long>> pq;
    priority_queue<long long> pq2;
    for (int i = 0; i < N; ++i) {
        l[0] += a[i];
        r[0] += a[N * 2 + i];
        pq.push(a[i]);
        pq2.push(a[N * 2 + i]);
    }
    for (int i = 0; i < N; ++i) {
        pq.push(a[N + i]);
        l[i + 1] = l[i] + a[N + i] - pq.top();
        pq.pop();
        pq2.push(a[2 * N - i - 1]);
        r[i + 1] = r[i] + a[2 * N - i - 1] - pq2.top();
        pq2.pop();
    }
    long long ans = -LLINF;
    for (int i = 0; i <= N; ++i) {
        ans = max(ans, l[i] - r[N - i]);
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 7788
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;

class CIrohasObsession {
public:
	void solve(std::istream& cin, std::ostream& cout) {
	    int n, k;
	    cin >> n >> k;
	    vector<int> d_vec(k, 0);
        for (int i = 0; i < k; ++i) {
            cin >> d_vec[i];
        }
        while (true){
            bool flag = true;
            int price = n;
            for (int i = 0; i < floor(log10(n))+1; ++i) {
                int digit = price%10;
                if (find(d_vec.begin(), d_vec.end(), digit) != d_vec.end()){
                    flag = false;
                }
                price /= 10;
            }
            if (flag){
                cout << n << endl;
                break;
            }
            n++;
        }
	}
};


int main() {
	CIrohasObsession solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

const int c = 4, d = 7;

int solve(int n) {
  for (int i = 0; i <= 100; ++i) {
    for (int k = 0; k <= 100; ++k) {
      if (c * i + d * k == n) return true;
    }
  }
  return false;
}

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

  if (solve(n)) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum[ohara],pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
ll one[ohara],ze[ohara];
ll cnt_one,cnt_ze;
ll cou_one,cou_ze;

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>k>>s;
    rep(i,n){
        if(s[i]=='0'){
            if(cnt_one>=1){
                one[cou_one++]=cnt_one;
                ze[cou_ze++]=0;
                cnt_one=0;
            }
            cnt_ze++;
        }
        else{
            if(cnt_ze>=1){
                ze[cou_ze++]=cnt_ze;
                one[cou_one++]=0;
                cnt_ze=0;
            }
            cnt_one++;
        }
    }
    if(cnt_one>=1){
            one[cou_one++]=cnt_one;
            ze[cou_ze++]=0;
            cnt_one=0;
    }       
    if(cnt_ze>=1){
        ze[cou_ze++]=cnt_ze;
        one[cou_one++]=0;
        cnt_ze=0;
    }
    if(cou_one==0){
        Cout(n);
        return 0;
    }
    ans=*max_element(one,one+cou_one);

    rep(i,ohara)one[i+1]+=one[i];
    rep(i,ohara)ze[i+1]+=ze[i];

    rep(i,cou_ze){
        if(i==0){
            cnt=ze[(k-1)*2+i];
        }
        else{
            cnt=ze[(k-1)*2+i]-ze[i-1];
        }
        if(k>=2)cnt+=(one[(k-1)*2+i-1]-one[i]);
        if(i>=1){
            if(i==1)cnt+=one[i-1];
            else cnt+=one[i-1]-one[i-2];
        }
        cnt+=one[(k-1)*2+i+1]-one[(k-1)*2+i];
        ans=max(ans,cnt);
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 16848
void main() {
	auto ip = readAs!(int[]), A = ip[0], B = ip[1], C = ip[2], X = ip[3], Y = ip[4];
	int x = X, y = Y;
	int res;
	if(A <= C*2-B) {
		res += A*X;
		X = 0;
	} else {
		res += C*Y*2;
		X -= Y;
		Y = 0;
	}
	//"%d %d".writefln(X, Y);

	/*if(X > 0) res += A*X;
	if(Y > 0) {
		if(B < C*2-A) {
			res += B*Y;
			Y = 0;
		} else {
			res += C*X*2;
			Y = 0;
		}
	}*/
	if(X > 0) res += min(A*X, 2*C*max(X, 0));
	if(Y > 0) res += min(B*Y, 2*C*max(Y, 0));

	int res2;
	if(B <= C*2-A) {
		res2 += B*y;
		y = 0;
	} else {
		res2 += C*x*2;
		y -= x;
		x = 0;
	}

	if(x > 0) res2 += min(A*x, 2*C*max(x, 0));
	if(y > 0) res2 += min(B*y, 2*C*max(y, 0));
	min(res, res2).writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i, j, a, h, w, k, x = 0;
	cin >> h >> w >> k;
	vector<string> d(h);
	vector<vector<int>> ans(h, vector<int>(w, 0));
	rep(i, h)
		cin >> d[i];
	rep(i, h) {
		a = d[i].find("#");
		if (a < 0 || a >= w)
			continue;
		x++;
		rep(j, a + 1)
			ans[i][j] = x;
		for (; j < w; j++) {
			if (d[i][j] == '#')
				x++;
			ans[i][j] = x;
		}
	}
	for(i = 1; i < h; i++) {
		if (ans[i][0] == 0) {
			rep(j, w)
				ans[i][j] = ans[i - 1][j];
		}
	}
	for (i = h - 2; i >= 0; i--) {
		if (ans[i][0] == 0) {
			rep(j, w)
				ans[i][j] = ans[i + 1][j];
		}
	}
	rep(i, h) {
		rep(j, w) {
			cout << ans[i][j] << " ";
		}
		cout << "\n";
	}
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll n,m;
vector<P> ps;

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

  cin>>n>>m;
  multiset<ll> st;
  rep(i,n){
    ll a,b;
    cin>>a>>b;
    ps.push_back(P(a,b));
  }
  sort(all(ps));

  ll j=0;
  ll res=0;
  for(ll i=m-1;i>=0;i--){
    while(j<n&&ps[j].fi<=(m-i)){
      st.insert(ps[j].se);
      j++;
    }
    if(st.size()>0){
      res+=(*st.rbegin());
      st.erase(st.find(*st.rbegin()));
    }
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 6512
import java.util.*;
import java.io.*;

/*
   AtCoder contest code
   coder : yoichidon
 */

public class Main {
    public static boolean[] primes(int max){
        boolean[] p = new boolean[max+1];
        Arrays.fill(p,true);
        p[0]=false; p[1]=false;
        for(int i=2; i*i<=max; i++){
            if(p[i]){
                for(int j=2; i*j<=max; j++) p[i*j]=false;
            }
        }
        return p;
    }

    public static void main(String[] args) {

        int max = 100000;
        boolean[] prime = primes(max);
        boolean[] like2017 = new boolean[max+1];
        for(int i=1; i<=max; i+=2){
            like2017[i] = prime[i] && prime[(i+1)/2];
        }


        int[] count = new int[max+1];
        count[0]=0;
        for(int i=1; i<=max; i++){
            count[i] = count[i-1] + (like2017[i] ? 1 : 0);
        }


        Scanner sc = new Scanner(System.in);
        int Q = sc.nextInt();
        for(int q=0; q<Q; q++){
            int l = sc.nextInt();
            int r = sc.nextInt();
            System.out.println(count[r] - count[l-1]);
        }


    }
}


Measured memory_bytes: 65088
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall

n, m = map(int, readline().split())
graph = [[0] * (n + 1) for _ in range(n + 1)]
abc = [list(map(int, readline().split())) for _ in range(m)]
for a, b, c in abc:
    graph[a][b] = c
    graph[b][a] = c
cost = floyd_warshall(csr_matrix(graph))
cnt = 0
for a, b, c in abc:
    if cost[a][b] < c:
        cnt += 1
print(cnt)


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

int main() {
  string S;
  cin>>S;
  int a=0;
  if(S.at(0)=='0'){
  for(int i=0; i<S.size();i++){
    if(S.at(i)%2!=i%2){
       a++;
    }
  }
  }
  else{
    for(int i=0; i<S.size();i++){
     if(S.at(i)%2!=(i+1)%2){
       a++;
    }
    }
  }

    cout<<a<<endl;
  
}

Measured memory_bytes: 512
BIG_NUM = 2000000000

while True:

    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for k in range(W):
            if (i+k)%2 == 0:
                print("#",end = "")
            else:
                print(".",end = "")
        print()

    print() #データセットの区切り



Measured memory_bytes: 7000
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;
double eps = 1e-11;

double cross_product (xy_t a, xy_t b) {
    return (conj(a) * b).imag();
}

int main() {
    int n;
    cin >> n;
    pii c[n];
    int x, y;
    for (int i = 0; i < n; i++) {
        cin >> x >> y;
        c[i] = pii(x, y);
    }
    sort(c, c + n);
    xy_t cc[n];
    for (int i = 0; i < n; i++) {
        cc[i] = xy_t(c[i].first, c[i].second);
    }
    vector<xy_t> down;
    down.push_back(cc[0]);
    for (int i = 1; i < n; i++) {
        while (true) {
            if (down.size() == 1) {
                down.push_back(cc[i]);
                break;
            } else {
                xy_t a = down[down.size() - 2];
                xy_t b = down[down.size() - 1];
                double diff = cross_product(b - a, cc[i] - a);
                if (diff > -1 * eps) {
                    down.push_back(cc[i]);
                    break;
                } else {
                    down.pop_back();
                }
            }
        }
    }
    vector<xy_t> up;
    up.push_back(down[down.size() - 1]);
    for (int i = n - 2; i >= 0; i--) {
        while (true) {
            if (up.size() == 1) {
                up.push_back(cc[i]);
                break;
            } else {
                xy_t a = up[up.size() - 2];
                xy_t b = up[up.size() - 1];
                double diff = cross_product(b - a, cc[i] - a);
                if (diff > -1 * eps) {
                    up.push_back(cc[i]);
                    break;
                } else {
                    up.pop_back();
                }
            }
        }
    }
    int num = down.size() + up.size() - 2;
    cout << num << endl;
    int bottom = 0;
    for (int i = 0; i < down.size() - 1; i++) {
        if (down[i].imag() <= down[i + 1].imag()) {
            break;
        }
        bottom++;
    }
    for (int i = bottom; i < down.size(); i++) {
        cout << down[i].real() << " " << down[i].imag() << endl;
    }
    for (int i = 1; i < up.size() - 1; i++) {
        cout << up[i].real() << " " << up[i].imag() << endl;
    }
    for (int i = 0; i < bottom; i++) {
        cout << down[i].real() << " " << down[i].imag() << endl;
    }
}



Measured memory_bytes: 6716
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

fn main() {
    let w = get!(String).chars().collect::<Vec<char>>();
    let mut cs = vec![0; 26];
    for c in w {
        cs[((c as i32) - ('a' as i32)) as usize] += 1;
    }
    for c in cs {
        if c%2 == 1 {
            println!("No");
            return;
        }
    }
    println!("Yes");
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <utility>

using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef pair<char, int> P;
typedef long long ll;

int main()
{
  string s;
  cin >> s;
  vector<P> rl;

  int cnt = 1;
  for(int pos = 1; pos < s.length();++pos)
  {
    if(s[pos] != s[pos-1])
    {
      rl.emplace_back(P(s[pos-1], cnt));
      cnt = 1;
    }
    else ++cnt;
  }
  rl.emplace_back(P(s.back(), cnt));

  vector<int> ans(s.length(), 0);
  int pos = 0;
  for(int i = 0; i < rl.size(); i+=2)
  {
    int rnum = rl[i].second;
    int lnum = rl[i+1].second;
    for(int j = 0; j < rnum + lnum; ++j)
    {
      ans[pos + j] = 0;
    }
    ans[pos + rnum - 1] =
      (rnum / 2 + (rnum%2&1)) + (lnum / 2);
    ans[pos + rnum] =
      (rnum / 2) + (lnum / 2 + (lnum%2&1));

    pos += rnum + lnum;
  }
  for(auto x : ans)
    cout << x << " ";
  cout << endl;

  return 0;
}


Measured memory_bytes: 1780
#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> pint;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;

constexpr int M = 2000;
bool ab[100000], ac[100000], bc[100000];

bool match(char a, char b) {
    if (a == '?' || b == '?' || a == b) {
        return true;
    } else {
        return false;
    }
}

int main() {
    string a, b, c; cin >> a >> b >> c;
    memset(ab, 1, sizeof(ab));
    memset(ac, 1, sizeof(ac));
    memset(bc, 1, sizeof(bc));
    int A = a.size();
    int B = b.size();
    int C = c.size();

    rep(i, A) rep(j, B) if (!match(a[i], b[j])) ab[i-j+50000] = false;
    rep(i, A) rep(j, C) if (!match(a[i], c[j])) ac[i-j+50000] = false;
    rep(i, B) rep(j, C) if (!match(b[i], c[j])) bc[i-j+50000] = false;

    int ans = INF;
    for (int i = -2*M; i <= 2*M; i++) {
        for (int j = -2*M; j <= 2*M; j++) {
            if (ab[i+50000] && ac[j+50000] && bc[j-i+50000]) {
                int l = min(0, min(i, j));
                int r = max(A, max(i+B, j+C));
                ans = min(ans, r-l);
            }
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 640
//  SMOKE SHISHA PLAY FIFA  // 
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define MP make_pair
#define ff first
#define ss second
#define PB push_back
#define mod 1000000007
#define lp(i,start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;


ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

int main()
{
	fastio
	ll t=1;
	//cin >> t;
	while(t--)
	{
		ll n,m;
		cin>>n>>m;
		ll w[n+1],v[n+1];
		lp(i,1,n)
			cin>>w[i]>>v[i];
		ll dp[m+1];
		lp(i,1,m)
			dp[i]=-1;
		dp[0]=0;
		for(ll i=1; i<=n; i++){
			for(ll j=m; j>=w[i]; j--){
				dp[j]=max(dp[j], v[i]+ dp[j-w[i]]);
			}
		} 
		ll ans=0;
		lp(i,1,m)
			ans=max(ans,dp[i]);
		cout<<ans<<endl;
	}
	return 0;	
}


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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  vector<int> t(n);
  rep (i, n) {
    cin >> s.at(i);
    cin >> t.at(i);
  }
  string x;
  cin >> x;

  int no = 0;
  rep (i, n) { if (s.at(i) == x) no = i; }

  int time = 0;
  for (int i = no + 1; i < n; i++) { time += t.at(i); }

  cout << time << endl;
  return 0;
}

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

using namespace std;

int H, W, K;

bool tbl[6][6];

int main(){
    for(int i = 0; i < 6; i++){
        for(int j = 0; j < 6; j++){
            tbl[i][j] = false;
        }
    }

    cin >> H >> W >> K;
    cin.ignore();
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            char c;
            cin >> c;
            if(c == '#'){
                tbl[i][j] = true;
            }
        }
        cin.ignore();
    }

    unsigned int cnt = 0;
    unsigned int en = 0; // 有効/無効スイッチ bit 0: 無効 bit1: 有効 上H桁 H 下W桁 W
    const unsigned int MAX = 1 << (H + W);
    for(en = 0; en < MAX; en++){
        unsigned int sum = 0;
        for(unsigned int i = 0; i < H; i++){
        #ifdef DBG
            if(en == 0){
                printf("en = %u val = %u\n", en,en & (1 << (W + i)));
            }
            #endif
            if((en & (1 << (W + i))) == 0) continue;
            for(unsigned int j = 0; j < W; j++){
                // 有効無効確認
                if((en & (1 << j)) == 0) continue;
                if(tbl[i][j]) ++sum;
            }
        }
        #ifdef DBG
        printf("en=%x sum = %u\n", en, sum);
        #endif

        if(sum == K) ++cnt;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};
 
int main(){
    
    ll N, X, Y; 
    cin >> N >> X >> Y;
    vector<vector<pair<ll,ll>>> G(N+1);
    rep(i, 1, N){
        G[i].push_back({i+1, 1});
        G[i+1].push_back({i, 1});
    }
    G[X].push_back({Y,1});
    G[Y].push_back({X,1});
 
    vector<ll> ans(N+1, 0);
    rep(i, 1, N+1){
        ll srt = i;
        vector<ll> d(N+1, 1e18);
        /* dijkstra's scope */{
            priority_queue<pair<ll,ll>, vector<pair<ll,ll>>, greater<pair<ll,ll>>> que;
            que.push({0, srt});
            d[srt] = 0;
            while(!que.empty()){
                auto q = que.top();
                que.pop();
                if(q.first > d[q.second]) continue;
                for(auto g : G[q.second]){
                    if(d[g.first] <= q.first + g.second) continue;
                    d[g.first] = q.first + g.second;
                    que.push({d[g.first], g.first});
                }
            }
        }
        rep(j, 1, N+1){
            if(i >= j) continue;
            ans[d[j]]++;
        }
    }
    rep(i, 1, N){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define P pair<long,long>
#define all(a) a.begin(),a.end()
using namespace std;
signed main(){
    int n; cin>>n;
    vector<int> a(n);
    int cnt=0;
    rep(i,n){
        cin>>a.at(i);
        if(a.at(i)%2==1) cnt++;
    }
    cout<<(cnt%2==0?"YES":"NO")<<endl;
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
 
func nextLine() string {
	sc.Scan()
	return sc.Text()
}
 
func main() {
	sc.Split(bufio.ScanWords)
  var n int
  fmt.Scan(&n)
  
  var odd, even int
  
  s := make([]int ,n)
  for i := 0; i < n; i++ {
    fmt.Scan(&s[i])
  }
  
  for i := 0; i < n; i++ {
    if s[i] % 2 == 0 {
      even++
    } else if s[i] % 2 == 1 {
      odd++
    }
  }
  
  if odd % 2 == 0 {
    fmt.Println("YES")
  } else {
    fmt.Println("NO")
  }
}

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

int main() {
    int l, r, d;
    cin >> l >> r >> d;

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

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3616
import sys
from collections import defaultdict, deque, Counter
import math
 
# import copy
from bisect import bisect_left, bisect_right
# import heapq
 
# sys.setrecursionlimit(1000000)
 
# input aliases
input = sys.stdin.readline
 
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]
 
INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def getmoji(k):
    return chr(ord("a") + k)

def main():
    # print("start")
    n = getN()
    # print(n)
    n -= 1
    ans = []
    while(n>=0):
        ans.append(getmoji(n % 26))
        n //= 26
        n -= 1
        # print(n)?
    ans.reverse()
    print("".join(ans))



if __name__ == "__main__":
    main()
   

Measured memory_bytes: 65532
#include <bits/stdc++.h>
using namespace std;
#define int 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 rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

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

    int a, b;
    cin >> a >> b;
    cout << (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0 ? "Possible" : "Impossible") << endl; 
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

typedef long long ll;


int main() {

    ll N;
    cin>>N;

    vector<ll> A;
    vector<ll> B;
    vector<ll> C;
    vector<ll> error;

    A.resize(N);
    B.resize(N);
    C.resize(N);
    error.resize(N);

    for(int i=0; i<N; ++i)
        cin>>A[i];

    for(int i=0; i<N; ++i)
        cin>>B[i];

    ll sum=0;
    bool flag = true;
    for(int i=0; i<N; ++i)
    {
        if(A[i]>B[i])
            sum+=(A[i]-B[i]);
        error[i]=A[i]-B[i];
        if(error[i]<0)
            flag = false;
    }

    if(flag)
    {
        cout<<0<<endl;
        return 0;
    }

    sort(error.begin(), error.end(), greater<ll>());

    ll give=0;
    for(int i=0; i<N; ++i)
    {
        if(A[i]<B[i])
        {
            C[i] = A[i]+abs(A[i]-B[i]);
            sum-=abs(A[i]-B[i]);
            give+=abs(A[i]-B[i]);
        }
    }

    if(sum<0)
    {
        cout<<-1<<endl;
        return 0;
    }

    ll ans = 0;
    for(int i=0; i<N; ++i)
    {
        if(error[i]<0)
            ++ans;
    }

    for(int i=0; i<N; ++i)
    {
        give-=error[i];
        if(give<=0)
        {
            ans+=(i+1);
            cout<<ans<<endl;
            return 0;

        }
    }

    cout<<-1<<endl;



    return 0;
}


Measured memory_bytes: 3328
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPL(i,f,n) for(int i=f, i##_len=(n); i<i##_len; ++i)
typedef long long ll;

int main() {
	string MARCH = "MARCH";
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N,A[100010];
	cin >> N;
	REP(i, N) {
		cin >> A[i];
	}
	int D = abs(A[0]);
	REPL(i,1, N) {
		D+=abs(A[i]-A[i-1]);
	}
	D += abs(A[N-1]);
	REP(i, N) {
		int ans = D;

		if(i > 0)ans -= abs(A[i] - A[i - 1]);
		else ans -= abs(A[i]);

		if (i < N - 1)ans -= abs(A[i] - A[i + 1]);
		else ans -= abs(A[i]);

		if (i == 0)ans += abs(A[i+1]);
		else if (i == N - 1)ans += abs(A[i-1]);
		else ans += abs(A[i + 1] - A[i - 1]);

		cout << ans << endl;
	}
	return 0;
}


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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1'000'000'000ll + 7;
//const i64 smod = 998244353ll;
//const i64 inf = 1'000'000'000'000'000'000ll + 7;
//const i64 inf = 1'000'000'007;

const double inf = 1e12;

const long double eps = 1e-8;

const i64 MAXN = 400'000 + 5;

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed); cerr.precision(15); cerr.setf(ios::fixed);


    i64 x, k, d;
    cin >> x >> k >> d;

    i64 t = min(k, abs(x) / d);

    x += (x >= 0 ? -1 : 1) * t * d;
    k -= t;
    if (k % 2 == 0) {
        cout << abs(x) << endl;
    }
    else {
        cout << abs(d - abs(x)) << endl;
    }

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b;
}

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


int main() {
    int n; cin >>n;
    int k; cin >> k; int ans;
    if (k==1) {
        ans = 0;
    }
    else {
        ans = n - k;
    }
    cout << ans << endl;
}


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

using namespace std;

int N, Q;

int Solve(int latte[])
{
    int ma = 0, res = 0;
    for (int i = 1; i <= 100; i++)
    {
        if (ma < latte[i])
        {
            ma = latte[i]; res = i;
        }
    }
    return (ma >= Q) ? res : 0;
}

int main()
{
    while (cin >> N >> Q, N || Q)
    {
        int latte[101] = {};
        for (int i = 0; i < N; i++)
        {
            int M;
            cin >> M;
            for (int j = 0; j < M; j++)
            {
                int D;
                cin >> D;
                latte[D]++;
            }
        }
        printf("%d\n", Solve(latte));
    }
    return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int n,m,a,b; cin >> n >> m >> a >> b;
    cout << fixed << setprecision(6) << (double)n * m / 2 << ' ' << (n == 2 * a && m == 2 *b) ? '1' : '0' << '\n';
}


Measured memory_bytes: 384
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdio>
using namespace std;
#define ll long long
ll n,m,mod,f[305][305][305];
#define add(x) (x>=mod?x-mod:x)
int main(){
	scanf("%lld%lld%lld",&n,&m,&mod);
	f[0][1][0]=1;
	for(ll i=0;i<=n;i++){
		for(ll t=1;t<=m;t++){
			for(ll j=i;j>=0;j--){
				if(j) f[i][t][j-1]=add(f[i][t][j-1]+f[i][t][j]);
				else f[i][t+1][i]=add(f[i][t+1][i]+f[i][t][j]);
				f[i+1][t][j]=(f[i+1][t][j]+f[i][t][j]*(j+1))%mod;
			}
		}
	}
	printf("%lld",f[n][m][0]);
}

Measured memory_bytes: 221244
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 200009
#define mod 100000000007
#define pi acos(-1.0)
ll n,m,j,k,l,t,arr[sz],brr[sz],crr[sz],drr[sz];
int main()
{
 scanf("%lld %lld",&n,&m);
 for(int i=0;i<m;i++)
 {
     scanf("%lld",&l);
     t+=l;
 }
 n-=t;
 printf("%lld\n",n>=0?n:-1);
}


Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
ll A[5000001],bin[5000001];
vector<ll>v;
map<int,int>myMap;
set<int>mySet;
vector<pair<ll,ll> >vp;
/* Precode Start Here *\


    Integer  to Binary

void bti(ll n)
{
ll k=1;
  while(n!=0)
    {
    bin[k++]=n%2;
    n/=2;
    }
}

     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}


/* Precode Ends */
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}
ll gcd(ll a,ll b)
{
    while(b!=0)
    {
        ll t=b;
        b=a%b;
        a=t;
    }
    return a;
}
int main()
{
    sieve();
   ll a,b,cnt=0;
   cin>>a>>b;
   ll d=gcd(max(a,b),min(a,b));
   for(ll i=0;v[i]<=sqrt(d);i++)
   {
       if(d%v[i]==0)
       {
           while(d%v[i]==0)
             {
                 d/=v[i];
             }
           cnt++;
       }
   }
   if(d!=1)
   {
       cnt++;
   }
   cout<<cnt+1<<endl;
return 0;
}



Measured memory_bytes: 39280
#include<iostream>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int x, mx = 999, i, len = s.size();
    for(i = 0; i <= len - 3; i++)
    {
        x = abs(100*(s[i] - '0') + 10*(s[i+1] - '0') + s[i+2] - '0' - 753);
        mx = min(x, mx);
    }
    printf("%d", mx);
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(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 rrepi(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 itn int
#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 lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    string s,t;
    cin >> s >> t;
    s += t;
    intl a = stoi(s);
    fp((intl)sqrt(a) * (intl)sqrt(a) == a);
    return 0;
}

Measured memory_bytes: 256
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
l = []
for i in range(n):
    d = abs(t - h[i] * 0.006 - a)
    P = [d,i+1]
    l.append(P)
L = sorted(l)
print(L[0][1])

Measured memory_bytes: 3188
# -*- coding: utf-8 -*-
#E - Friendships
import sys 
from itertools import combinations
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, K = map(int,readline().split())
if K > (N-1)*(N-2)//2:
    print(-1)
else:
    # Nを頂点とするスターグラフを考える
    x = (N-1)*(N-2)//2
    rest = x-K
    ans = [(x,N) for x in range(1,N)] + list(combinations(range(1,N),2))
    ans = ans[:N-1+rest]
    print(len(ans))
    for x,y in ans:
        print(x,y)

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

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

    if (s[0] == s[1] && s[1] == s[2] && s[0] == s[2])
        cout << "No" << endl;
    else
    {
        cout << "Yes" << endl;
    }

    return 0;
}

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

vector<int> g[50];
vector<P> bridge;
vector<int> articulation;
int ord[50], low[50];
bool vis[50];

void dfs(int v, int p, int &k) {
    vis[v] = true;
    ord[v] = k++;
    low[v] = ord[v];

    bool isArticulation = false;
    int ct = 0;

    for (auto u : g[v]) {
        if (!vis[u]) {
            ct++;
            dfs(u, v, k);
            low[v] = min(low[v], low[u]);
            if (~p and ord[v] <= low[u]) isArticulation = true;
            if (ord[v] < low[u]) bridge.push_back(P(min(v, u), max(v, u)));
        }
        else if (u != p) {
            low[v] = min(low[v], ord[u]);
        }
    }

    if (p == -1 and ct > 1) isArticulation = true;
    if (isArticulation) articulation.push_back(v);
}

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

    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    int k = 0;
    rep(i, n) {
        if (!vis[i]) dfs(i, -1, k);
    }

    cout << bridge.size() << endl;

    //sort(bridge.begin(), bridge.end());
}


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

int main() {
  int N, P; cin >> N >> P;
  string S; cin >> S;
  if (10 % P == 0) {
    long long ans = 0;
    for (int i = 0; i < N; i++) {
      if ((S.at(i) - '0') % P == 0) ans += i+1;
    }
    cout << ans << endl;
    return 0;
  }
  vector<int> A(N+1, 0);
  int ten = 1;
  for (int i = N-1; i >= 0; i--) {
    int tmp = (S.at(i) - '0') * ten % P;
    A.at(i) = (A.at(i+1) + tmp) % P;
    ten *= 10;
    ten %= P;
  }
  long long ans = 0;
  map<long long, long long> M;
  for (int i = 0; i < N+1; i++) {
    if (M.count(A.at(i))) M[A.at(i)]++;
    else M[A.at(i)] = 1;
  }
  for (auto p : M) ans += (p.second * (p.second - 1)) / 2;
  cout << ans << endl;
}

Measured memory_bytes: 1796
#include <stdio.h>
int main(){
 int n,pl,i;
 scanf("%d",&n);
  char s[n+1];
  scanf("%s\n%d",s,&pl);
  for(i=0;i<n;i++){
    if(s[i]==s[pl-1])printf("%c",s[i]);
    else printf("*");
  }
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef int64_t ll;

ll INF = 1e10;

int main(){
  int N, W;
  cin >> N >> W;
  vector<int> w(N), v(N);
  REP(i,N) cin >> w[i] >> v[i];

  int V = 100001;
  vector<vector<ll>> dp(N + 1, vector<ll> (V, INF));
  dp[0][0] = 0;
  REP(i,N)REP(j, V) {
    if(dp[i][j] > W) continue;
    dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
    dp[i + 1][j + v[i]] = min(dp[i + 1][j + v[i]], dp[i][j] + w[i]);
  }

  int ret = 0;
  REP(j, V) if(dp[N][j] <= W) ret = max(ret, j);
  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 80256
#include <cstdio>
int main(){
  int n;
  int data[2],sum[2]={0,0};

  for(;;){
    scanf("%d",&n);
    if(n==0)
       break;
    for(int i=0;i<n;i++){
      scanf("%d%d",&data[0],&data[1]);
      if(data[0]>data[1])
	sum[0]+=data[0]+data[1];
      else if(data[0]<data[1])
	sum[1]+=data[0]+data[1];
      else{
	sum[0]+=data[0];
	sum[1]+=data[1];
      }
    }
    printf("%d %d\n",sum[0],sum[1]);
    sum[0]=0;
    sum[1]=0;
  }
  return 0;
}

Measured memory_bytes: 1028
// Sky's the limit :)
#include<bits/stdc++.h>
using namespace std;
#define int long long


int n, m;
vector<pair<int, int>> v;

bool satisfy(int x) {
    string s = to_string(x);
    if(s.size() != n)
        return 0;
    for(int i = 0; i < m; i++) {
        if(s[v[i].first] != v[i].second + '0')
            return 0;
    }
    return 1;
}

signed main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    //int t = 1; cin >> t; while(t--)
    {
        cin >> n >> m;

        for(int i = 0; i < m; i++) {
            int x, y;
            cin >> x >> y;
            v.push_back({--x, y});
        }

        for(int i = 0; i < 1000000; i++) {
            if(satisfy(i)) {
                cout << i;
                return 0;
            }
        }

        cout << -1;
        
    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
#define llint long long
using namespace std;

llint W, H;
vector<pair<llint, int> > vec;

int main(void)
{
	cin >> W >> H;
	int p, q;
	for(int i = 0; i < W; i++){
		cin >> p;
		vec.push_back( make_pair(p, 0) );
	}
	for(int i = 0; i < H; i++){
		cin >> q;
		vec.push_back( make_pair(q, 1) );
	}
	sort(vec.begin(), vec.end());
	
	llint ans = 0;
	llint wcnt = W+1, hcnt = H+1;
	for(int i = 0; i < vec.size(); i++){
		if(vec[i].second == 0){
			ans += vec[i].first * hcnt;
			wcnt--;
		}
		else{
			ans += vec[i].first * wcnt;
			hcnt--;
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6512
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>
#include <iomanip>
#include <limits>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int asc(const void* a, const void* b) {
	return *(int*)a- *(int*)b;
}

int main()
{
	int m, d, ans = 0;
	int e, f;
	cin >> m >> d;
	for (int i = 1; i <= m; i++) {
		for (int j = 22; j <= d; j++) {
			e = j % 10;
			f = j / 10;
			if (e >= 2 && e * f == i) {
				ans++;
				//cout << i << " " << j << endl;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m;
vi a;
vvi g;

int main(){
	cin>>n>>m;
	g=vvi(m);
	a=vi(m);
	for(int i=0;i<m;i++){
		int s,x;
		cin>>s;
		for(int j=0;j<s;j++){
			cin>>x;
			g[i].push_back(x-1);
		}
	}
	for(auto &i:a) cin>>i;
	int res=0;
	for(int i=0;i<1<<n;i++){
		int B=1;
		for(int j=0;j<m;j++){
			int t=0;
			for(auto k:g[j]) if(i&1<<k) t++;
			if(t%2!=a[j]) B=0;
		}
		res+=B;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES // M_PIなどの定義を使用するのに必要
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>
#include <limits>
#include <map>
#include <set>
#include <functional>

using namespace std;

int main()
{
  string T;

  cin >> T;

  for (int i = 0; i < T.size(); i++) {
    if (T[i] == '?') {
      T[i] = 'D';
    }
  }

  cout << T << endl;

  return 0;
}


Measured memory_bytes: 3724
def c_id(N, M, City):
    # City には、県番号Pと誕生年Yの他に、市番号Kを加えている
    # 県番号が小さい順、同じ県なら誕生年が若い順にソート
    city = sorted(City, key=lambda x: (x[0], x[1]))

    checking_city_num = city[0][0]  # 今調べている県の番号
    x = 1  # 同じ県の中で何番目に誕生した市か
    for j, (p, y, k) in enumerate(city):
        if p == checking_city_num:  # 同じ県番号が連続している
            city[j] = [p, x, k]
            x += 1  # 次の市が同じ県だったときのための設定
        else:
            checking_city_num = p  # 新しい県を調べている
            city[j] = [p, 1, k]
            x = 2  # 次の市が同じ県だったときのための設定

    ans_tmp = []
    # 市番号の若い順に出力することを要請されているため、市番号でソートしている
    for p, q, k in sorted(city, key=lambda x: x[2]):
        ans_tmp.append('{0:06d}{1:06d}'.format(p, q))
    ans = '\n'.join(ans_tmp)
    return ans

N, M = [int(i) for i in input().split()]
City = [[int(i) for i in input().split()] + [k] for j, k in enumerate(range(M), 1)]
print(c_id(N, M, City))


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

int main(){
    int N,Q;
    string S;
    cin >> N >> S >> Q;
    int type,iq,lq,rq;
    char cq;
    vector<char> s(N);
    vector<set<int>> v(26);
    rep(i,N){
        v[S[i]-'a'].insert(i);
        s[i] = S[i];
    }
    rep(i,Q){
        cin >> type;
        if(type == 1){
            cin >> iq >> cq;
            v[S[iq-1]-'a'].erase(iq-1);
            v[cq-'a'].insert(iq-1);
            S[iq-1] = cq;
            s[iq-1] = cq;
            //cout << S << endl;
        }else{
            cin >> lq >> rq;
            int cnt = 0;
            rep(k,26){
                auto itr = v[k].lower_bound(lq-1);
                if(itr != v[k].end() && *itr <= rq-1) {
                    cnt++;
                    //cout << char(k+'a')<<endl;
                }
                /*for(int j=lq-1;j<=rq-1;j++){
                    auto itr = v[k].find(j);
                    if(itr != v[k].end()){
                        cnt++;
                        break;
                    }

                }*/
            }
            //int cnt = 0;
            cout << cnt << endl;
        }
    }

//    cout << endl;
}


Measured memory_bytes: 24708