akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#define watch(x) cout << (#x) << " = " << x << endl;
#define mkp make_pair
#define mkt make_tuple
#define pb push_back
#define ll long long
#define ld long double

using namespace std;

int n, m, dp[100010];
vector<int> adj[100010];
stack<int> st;
vector<int> topoSort;
bitset<100010> vis = 0;

void dfs(int u){
	if(vis[u]) return;
	vis[u] = 1;
	for(auto v : adj[u]) dfs(v);

	st.push(u);
}


int main(){
	scanf("%d%d", &n, &m);

	while(m--){
		int u, v;
		scanf("%d%d", &u, &v);
		adj[u].pb(v);
	}

	for(int i = 1; i <= n; i++){
		if(!vis[i]) dfs(i);
	}

	while(!st.empty()){topoSort.pb(st.top()); st.pop();}

	int ans = 0;
	for(auto u : topoSort){
		for(auto v : adj[u]){
			dp[v] = max(dp[v], dp[u] + 1);
			ans = max(dp[v], ans);
		}
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 8876
n, m = map(int, input().split())
a, b, c = [], [], []
for i in range(m):
    ai, bi = map(int, input().split())
    a.append(ai); b.append(bi)
    ci = list(map(int, input().split()))
    c.append(ci)

dp = [[10**9 for j in range(2**n)] for i in range(m)]
key = 0
for i in range(b[0]):
    key += 1<<(c[0][i]-1)
dp[0][key] = a[0]
dp[0][0] = 0

for i in range(1, m):
    ai, bi, ci = a[i], b[i], c[i]
    key = 0
    for j in range(bi):
        key += 1<<(ci[j]-1)
    for j in range(2**n):
        dp[i][j|key] = min(dp[i-1][j|key], dp[i-1][j]+ai, dp[i][j|key])
    for j in range(2**n):
        dp[i][j] = min(dp[i-1][j], dp[i][j])

if dp[m-1][2**n-1] == 10**9:
    print(-1)
else:
    print(dp[m-1][2**n-1])

Measured memory_bytes: 106412
while(1):
	try:
		a = [int(i) for i in input().split()]
		b = [int(i) for i in input().split()]
		hit = 0
		for i,j in zip(a,b):
			if i == j:
				hit += 1
		sa = set(a)
		sb = set(b)
		u = sa & sb
		blow = len(u) - hit
		print(hit, blow)
	except EOFError:
		break


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[205];
int main(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll t=__gcd(d,c);
	ll e=d/t*c/t*t;
	cout<<(b-a+1)-(b/c-(a-1)/c)-(b/d-(a-1)/d)+(b/e-(a-1)/e)<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;

public class Main {

    int[] needs = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

    Set<String> nums = new HashSet<>();
    int n, m, t, min;
    Set<Integer> use = new HashSet<>();

    void run() {

        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        for (int i = 0; i < m; i++) {
            use.add(sc.nextInt());
        }

        String[] dp = new String[n + 1];


        dp[0] = "";
        for (int i = 0; i <= n; i++) {
            if (dp[i] == null) {
                continue;
            }
            for (int u: use) if (i + needs[u] <= n) {
                String next = next(dp[i], u);
                if (dp[i + needs[u]] == null || isLarge(next, dp[i + needs[u]])) {
                    dp[i + needs[u]] = next;
                }
            }
        }

        System.out.println(dp[n]);

    }

    boolean isLarge(String a, String t) {
        if (a.length() > t.length()) {
            return true;
        }
        return a.compareTo(t) > 0;
    }

    String next(String cur, int d) {
        for (int i = 0; i < cur.length(); i++) if(d > cur.charAt(i) - '0') {
            return cur.substring(0, i) + d  + cur.substring(i);
        }
        return cur + d;
    }
    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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


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

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

int main()
{
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;

    if (e - a <= k)
        OP("Yay!");
    else
        OP(":(");
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,c;
  int count;
  int ans;
  scanf("%d %d %d",&a,&b,&c);
  count=a-b;
  if(count<c){
    ans=c-count;
  }
  else ans=0;
  
  printf("%d",ans);
  return 0;
}

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

using ll = long long;
using namespace std;

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

    vector<ll> ans1(n+1,0), ans2(n+1,0);

    ll count = 0;
    priority_queue<ll,vector<ll>,greater<ll>> a1;
    rep(i,n) count += a[i], a1.push(a[i]);
    ans1[0] = count;
    rep(i,n){
        ll k = a[n+i], l = a1.top();
        if(k <= l){ ans1[1+i] = count; continue; }
        a1.pop(); a1.push(k);
        count += k-l;
        ans1[1+i] = count;
    }

    count = 0;
    priority_queue<ll,vector<ll>,less<ll>> a2;
    rep(i,n) count += a[3*n-1-i], a2.push(a[3*n-1-i]);
    ans2[0] = count;
    rep(i,n){
        ll k = a[2*n-1-i], l = a2.top();
        if(k >= l){ ans2[1+i] = count; continue; }
        a2.pop(); a2.push(k);
        count += k-l;
        ans2[1+i] = count;
    }

    ll res = -100100100100100;
    rep(i,n+1) if(ans1[i]-ans2[n-i] > res) res = ans1[i]-ans2[n-i];
    cout << res << endl;
    return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long n, std::vector<long long> a){
    sort(ALL(a));
    double diff = a[a.size()-1];
    LL ans = a[0];

    REP(i, n) {
        double tmp = abs(a[a.size()-1] / 2.0 - a[i]);
        if(tmp < diff) {
            diff = tmp;
            ans = a[i];
        }
    }

    cout << a[a.size()-1] << " " << ans << endl;
}

int main(){
    long long n;
    scanf("%lld",&n);
    std::vector<long long> a(n);
    for(int i = 0 ; i < n ; i++){
        scanf("%lld",&a[i]);
    }
    solve(n, std::move(a));
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 100010, LOG=20;

ll n, A, B, u, v, x, y, t, a, b, ans;
ll H[MAXN];

bool check(ll x){
	ll res=0;
	for (int i=1; i<=n; i++) res+=(max(0ll, H[i]-x*B)+A-B-1)/(A-B);
	return res<=x;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>A>>B;
	for (int i=1; i<=n; i++) cin>>H[i];
	ll dwn=0, up=inf;
	while (up-dwn>1){
		ll mid=(dwn+up)>>1;
		if (check(mid)) up=mid;
		else dwn=mid;
	}
	cout<<up<<'\n';
	
	
	return 0;
}


Measured memory_bytes: 1024
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
 
// ------------------------------------------------------------------------------------------------

ll n, c, p, ans;

int main() {
    fast_io; cout_precision;
    cin >> n;
    c = 0, p = 1;
    for (ll n2 = n; n2 > 0; c++, p *= 10, n2 /= 10);
    ans = 0;
    while (c > 0) {
        p /= 10;
        if (c & 1) {
            ans += n - p + 1;
        }
        c--;
        n = p - 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
class Node:
    def __init__(self, key):
        self.key = key
        self.left = None
        self.right = None
        self.p = None

def insert(z,root):
    y = None
    x = root
    while x != None:
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.p = y
    if y == None:
        root = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z

    return root

def printPreorderList(p):
    if p == None:
        return
    print("",p.key,end = "")
    printPreorderList(p.left)
    printPreorderList(p.right)

def printInorderList(p):
    if p == None:
        return
    printInorderList(p.left)
    print("",p.key,end = "")
    printInorderList(p.right)

def find(key, root):
    x = root
    while x != None and key != x.key:
        if key < x.key:
            x = x.left
        else:
            x = x.right
    return x

def delete(key, root):
    z = find(key, root)
    if z == None:
        return root
    elif z.left == None and z.right == None: 
        if z.p.left == z:
            z.p.left = None
        else:
            z.p.right = None
        #z = None
    elif z.left != None and z.right == None:
        if z == root:
            root = z.left

        if z.p.left == z:
            z.p.left = z.left
        else:
            z.p.right = z.left
        z.left.p = z.p
        #z = None
    elif z.left == None and z.right != None:
        if z == root:
            root = z.right

        if z.p.left == z:
            z.p.left = z.right
        else:
            z.p.right = z.right
        z.right.p = z.p
        #z = None
    else:
        y = z.right
        while y.left != None:
            y = y.left
        z.key = y.key
        if y.right != None:
            y.right.p = y.p
        if y.p.left == y:
            y.p.left = None
        else:
            y.p.right = None
        #y = None

    return root

n = int(input())
root = None
for ni in range(n):
    s = input()
    if s[0] == "i":
        s, key = s.split()
        key = int(key)
        root = insert(Node(key), root)
    elif s[0] == "p":
        printInorderList(root)
        print()
        printPreorderList(root)
        print()
    elif s[0] == "f":
        s, key = s.split()
        key = int(key)
        ans = find(key, root)
        if ans == None:
            print("no")
        else:
            print("yes")
    elif s[0] == "d":
        s, key = s.split()
        key = int(key)
        root = delete(key, root)


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

divcnt = {n: 0 for n in range(1, (n + 1), 2)}
for i in range(1, (n + 1), 2):
    for j in range(i, (n + 1), (i * 2)):
        divcnt[j] += 1

ans = 0
for i in divcnt:
    if divcnt[i] == 8:
        ans += 1
print(ans)


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

char mp[1005][1005];
int dist[1005][1005];

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

class state {
 public:
  int x;
  int y;
  int d;
  state(int x, int y, int d) : x(x), y(y), d(d){};
};

int main() {
  int h, w, ch, cw, dh, dw;
  cin >> h >> w >> ch >> cw >> dh >> dw;
  ch--;
  cw--;
  dh--;
  dw--;
  rep(y, h) rep(x, w) {
    cin >> mp[x][y];
    dist[x][y] = INF;
  }
  deque<state> q;
  q.emplace_back(cw, ch, 0);
  while (!q.empty()) {
    int x = q.front().x;
    int y = q.front().y;
    int d = q.front().d;
    q.pop_front();
    if (d >= dist[x][y]) continue;
    dist[x][y] = d;
    rep(v, 4) {
      int nx = x + dx[v];
      int ny = y + dy[v];
      if (nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
      if (mp[nx][ny] == '#') continue;
      q.emplace_front(nx, ny, d);
    }
    for (int ex = -2; ex <= 2; ex++) {
      for (int ey = -2; ey <= 2; ey++) {
        int nx = x + ex;
        int ny = y + ey;
        if (nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
        if (mp[nx][ny] == '#') continue;
        q.emplace_back(nx, ny, d + 1);
      }
    }
  }
  int ans = dist[dw][dh];
  if (ans == INF) ans = -1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9836
#include<iostream>
#include<algorithm>

using namespace std;

long int a, b;
long int sum,ans;

int main(){
	while (cin>>a>>b){
		sum = a+b;
		ans = 0;
		while (sum){
			sum /= 10;
			ans++;
		}
		cout << ans << endl;	
	}
}

Measured memory_bytes: 1160
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


bool check(string s,string a){
    rep(i,a.size()){
        if(a[i]=='*')s[i]='*';
    }
    if(a==s)return true;
    else return false;
}

int main() {
    int n,m;
    while(cin>>n>>m){
        if(n==0)break;
        string hit[200]={};
        int v[200]={};
        rep(i,n){
            cin>>hit[i];
            cin>>v[i];
        }
        
        string mine[2000]={};
        rep(i,m) cin>>mine[i];
        
        ll sum=0;
        rep(i,m){
            rep(j,n){
                if(check(mine[i],hit[j])){
                    sum+=v[j];
                    break;
                }
            }
        }
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 1276
use std::io::stdin;

fn main() {
    let mut count: i32 = 0;
    let mut buf = String::new();
    match stdin().read_line(&mut buf) {
        Ok(_) => {
            let mut chars = buf.chars();
            for _ in 0..buf.chars().count() {
                if chars.next() == Some('1') { count += 1; }
            }
            print!("{}", count);
        },
        Err(error) => println!("error: {}", error)
    }
}


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

int main() {
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n - 1);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	rep(i, n - 1) cin >> c[i];
	int ans = 0;
	rep(i, n) ans += b[a[i] - 1];
	rep(i, n - 1) {
		if (a[i] + 1 == a[i + 1]) ans += c[a[i] - 1];
	}
	cout << ans << endl;
	return 0;
}


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

int main(void){
  int k,a,b,i;
  (void)scanf("%d",&k);
  (void)scanf("%d %d",&a,&b);
  for(i=a;i<=b;i++){
    if(i%k==0){
      printf("OK\n");
      return 0;
    }
  }
  printf("NG\n");
  return 0;
}

Measured memory_bytes: 1648
#include<iostream>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
int map[55][55],w,h;

void d(int y,int x){
  if(y==h||x==w||y==-1||x==-1)return;
  if(map[y][x]==0)return;
  if(map[y][x]==1)map[y][x]=0;
  d(y-1,x-1),d(y+1,x+1),d(y+1,x),d(y,x+1),d(y-1,x),d(y,x-1),d(y-1,x+1),d(y+1,x-1);
}

int main(){
  while(cin>>w>>h,w){
    int ans=0;
    int x,y;
    r(i,h)r(j,w)cin>>map[i][j];
    while(1){
      x=-1;
      r(i,h)r(j,w)if(map[i][j]==1)y=i,x=j;
      if(x==-1)break;
      d(y,x);
      ans++;
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
#include <bitset>
using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

const double PI=3.14159265358979323846;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REP1(i, n) for(int i = 1; i <= (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())
#define ZERO(a) memset(a, 0, sizeof(a))

#define RAD(d) (PI * (d) / 180)
#define DEG(r) (180.0 * (r) / PI)

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<class T> void dump(const vector<T> &v)
{
	REP(i, SZ(v)-1){ cout << v[i] << " "; }
	cout << v[SZ(v)-1] << endl;
}

template<class T> void dump(int w, int h, const vector<T> &v)
{
	REP(j, h){
		REP(i, w-1){ cout << v[j * w + i] << " "; }
		cout << v[j * w + w-1] << endl;
	}
}

template<class T> T accumulate(const vector<T> &v)
{
	T sum = 0;
	REP(i, SZ(v)){ sum += v[i]; }
	return sum;
}

template<class T> struct Matrix
{
	T w, h;
	vector<T> A;
	Matrix(T w_, T h_) : w(w_), h(h_), A(w * h) {}
	T get(T x, T y) const { return A[y * w + x]; }
};

template<class T> void input(Matrix<T> &m)
{
	REP(j, m.h){
		REP(i, m.w){
			cin >> m.A[j * m.w + i];
		}
	}
}

template<class T> Matrix<T> prod(const Matrix<T> &a, const Matrix<T> &b)
{
	Matrix<T> m(b.w, a.h);

	REP(j, m.h){
		REP(i, m.w){
			ll c = 0;
			REP(k, a.w){
				c += a.A[j * a.w + k] * b.A[k * b.w + i];
			}
			m.A[j * m.w + i] = c;
		}
	}

	return m;
}

void dump(const Matrix<ll> &m)
{
	REP(j, m.h){
		REP(i, m.w-1){ printf("%lld ", m.A[j * m.w + i]); }
		printf("%lld\n", m.A[j * m.w + m.w-1]);
	}
}

void dump(const Matrix<double> &m)
{
	REP(j, m.h){
		REP(i, m.w-1){ printf("%f ", m.A[j * m.w + i]); }
		printf("%f\n", m.A[j * m.w + m.w-1]);
	}
}

string &to_upper(string &s)
{
	REP(i, s.length()){
		if('a' <= s[i] && s[i] <= 'z'){
			s[i] -= 32;
		}
	}

	return s;
}

string &to_lower(string &s)
{
	REP(i, s.length()){
		if('A' <= s[i] && s[i] <= 'Z'){
			s[i] += 32;
		}
	}

	return s;
}

template <class T> vector<T> get_divisors(T n)
{
	vector<T> ret;
	for(T i = 1; i * i <= n; i++){
		if(n % i == 0){
			ret.push_back(i);
			if(i * i != n)
				ret.push_back(n / i);
		}
	}
	sort(ALL(ret));
	return ret;
}

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

	int cnt = 0;
	for(int i = 1; i <= N; i+=2){
		auto div = get_divisors(i);
		if(SZ(div) == 8)
			cnt++;
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(string, "x", long, "y");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long k, x;
    scan(k, x);
    if(500 * k >= x)
        writeln("Yes");
    else
        writeln("No");
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int K = int.Parse(str[1]);
		int S = int.Parse(str[2]);
		var ans = new List<int>();
		if(S>N){
			for(var i=0;i<K;i++){
				ans.Add(S);
			}
			for(var i=K;i<N;i++){
				ans.Add(1);
			}
		} else {
			for(var i=0;i<K;i++){
				ans.Add(S);
			}
			for(var i=K;i<N;i++){
				ans.Add(1000000000);
			}
		}
		Console.Write(ans[0]);
		for(var i=1;i<N;i++){
			Console.Write(" "+ans[i]);
		}
	}
}

Measured memory_bytes: 17112
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long,long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

double pow(double a,int n) {
    double ans = 1;
    REP(i,n) ans *= a;
    return ans;
}

int main() {
    double N,K; cin >> N >> K;
    double ans = 0;
    for(double i = 1; i <= N; i++) {
        //cout << i << " " << ceil(log2(K/i)) << endl;
        if(i < K) ans += 1/N*pow(0.5,ceil(log2(K/i)));
        else ans += 1/N;
    }
    printf("%.10f\n",ans);
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] arr = new int[n+1];
		for(int i = 1; i <= n ; ++i) {
			for(int j = i; j <= n; j += i) {
				++arr[j];
			}
		}

		long ans = 0;
		for(int i = 1; i <= n; ++i) 
			ans += ( (long)i * arr[i]);

			System.out.println(ans);


	}
}


Measured memory_bytes: 66524
#include<iostream>
using namespace std;
int main(){
	int N,W[100],ans=10000;
	cin>>N>>W[0];
	for(int i=1;i<N;i++){
		cin>>W[i];
		W[i]+=W[i-1];
	}
	for(int i=0;i<N;i++)ans=min(ans,max(W[N-1]-2*W[i],-W[N-1]+2*W[i]));
	cout<<ans;
	return 0;
}

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

int a[101010],b[101010];

signed main(void){
  int n,k; cin >> n >> k;
  for(int i = 0; i < n; i++){ 
    cin >> a[i] >> b[i];
  }
  
  //先ずはmskを変更しない
  int sum = 0;
  
  for(int i = 0; i < n; i++){ 
    bool ok = true;
    
    for(int j = 0; j <= 40; j++){ 
      if( !(k >> j & 1LL) && (a[i] >> j & 1)){
        ok = false;
      }
    }
    
    if(ok){ sum += b[i];}
  }
  
  int ans = sum;
  //次は0を立てる
  
  
  for(int i = 40; i >= 0; i--){ 
    
    sum = 0;
    
    if( k >> i & 1 ){ //このビットを０にして、それ未満を全て立てる
      
      int res = k;
      res = (res >> i)<<i;
      res--;
      
      for(int j = 0; j < n; j++){ 
        
        if( (a[j] | res) == res ){  sum += b[j];}
        
      }
      
    }

    ans = max(ans,sum);
    
  }
  
  cout << ans << endl;
  
  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll a,b,c,k;
  cin>>a>>b>>c>>k;

  if(k<a)
    cout<<k<<endl;
  else if(k<=a+b)
    cout<<a<<endl;
  else
    cout<<a-(k-a-b)<<endl;
}



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

using namespace std;

int main(){
    int h,w;
    cin >> h >> w;
    char d[h+5][w+5];
    int a[h+5][w+5];
    int b[h+5][w+5];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            a[i][j]=0;
            b[i][j]=0;
        }
    }
    for(int i=0;i<h;i++){
        string s;
        cin >> s;
        for(int j=0;j<w;j++){
            d[i][j]=s[j];
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(j>=1){
                if(d[i][j]==d[i][j-1]){
                    a[i][j]=a[i][j-1];
                    continue;
                }
            }
            if(d[i][j]=='.'){
                bool flag=true;
                int cnt=1;
                int pos=0;
                while(flag){
                    pos++;
                    if(d[i][j+pos]=='.'){
                        cnt++;
                    }
                    else{
                        break;
                    }
                }
                a[i][j]=cnt;
            }
        }
    }
    for(int i=0;i<w;i++){
        for(int j=0;j<h;j++){
            if(j>=1){
                if(d[j][i]==d[j-1][i]){
                    b[j][i]=b[j-1][i];
                    continue;
                }
            }
            if(d[j][i]=='.'){
                bool flag=true;
                    int cnt=1;
                    int pos=0;
                    while(flag){
                        pos++;
                        if(d[j+pos][i]=='.'){
                            cnt++;
                        }
                        else{
                            break;
                        }
                    }
                b[j][i]=cnt;
            }
        }
    }
    int c[h+5][w+5];
    int ans=-1;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            c[i][j]=a[i][j]+b[i][j];
            //cout << c[i][j] << endl;
            ans=max(c[i][j],ans);
        }
    }
    cout << ans-1 << endl;
}


Measured memory_bytes: 51200
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

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

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

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

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

string s;

int main(){
	cin >> s;
	int ans = 0;
	rep(i,s.size()){
		ans += (s[i] == '1');
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);
    
    while (in.hasNext()) {
      long A = in.nextLong();
      long B = in.nextLong();
      long K = in.nextLong();
      
      if (K >= A) {
        K -= A;
        A = 0;
        
        if (K >= B) {
          K -= B;
          B = 0;
        } else {
          B -= K;
        }
      } else {
        A -= K;
      }
      
      System.out.println(A + " " + B);
    }
  }
}

Measured memory_bytes: 22996
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define rep1(i,s,e) for(int i=s;i<e;i++)
#define rep2(i,s,e,c) for(int i=s;i>=e;i--)
#define pfi(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define pfn() printf("\n")
#define pfs() printf(" ")
#define sfi(x) scanf("%d",&x)
#define sfi1(x,y) scanf("%d%d",&x,&y)
#define sff(x) scanf("%lf",&x)
#define sfl(x) scanf("%lld",&x)
#define memset1(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
const int MAX = 1e3 + 50;
const int mod = 996873654;
int ar[MAX][MAX],top[MAX],vis[MAX]={0};
int main(){
	int n;
	sfi(n);
	for(int i=1;i<=n;i++){
		top[i]=1;
		for(int j=1;j<=n-1;j++){
			sfi(ar[i][j]);
		}
	}
	int cnt=1;
	while(1){
		bool flag=false;
		for(int i=1;i<=n;i++){
			if(top[i]>=n || vis[i]==cnt) continue;
			int v=ar[i][top[i]];
			if(vis[v]!=cnt && ar[v][top[v]]==i){
				top[v]++; top[i]++;
				vis[i]=vis[v]=cnt;
				flag=true;
			}
		}
		if(!flag) break;
		cnt++;
	}
	for(int i=1;i<=n;i++){
		if(top[i]!=n){
			pfi(-1);
			return 0;
		}
	}
	pfi(cnt-1);
	return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

typedef long long ll;

int x,y;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	
	cin >> x >> y;
	
	if(x%y==0){
		cout << -1 << endl;
	}
	else{
		cout << x << endl;
	}
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, raw_input().split())
Q = [map(int, raw_input().split()) for _ in range(M)]

cnt = [0 for _ in range(N)]
for a, b in Q:
    cnt[a-1] += 1
    cnt[b-1] += 1

for k in range(N):
    if cnt[k] % 2 != 0:
        print "NO"
        exit()
print "YES"

Measured memory_bytes: 22388
#include <stdio.h>
#define swap(type, a, b) do{ type t = a; a = b; b = t; }while(0)

int gojo(int a, int b){
  if(!(a % b))
    return b;
  else
    gojo(b, a%b);
}

int main(){
  int k;  scanf("%d", &k);

  long long int sum = 0;
  for(int a=1; a<=k; a++)
    for(int b=1; b<=k; b++)
      for(int c=1; c<=k; c++)
	sum += gojo(a, gojo(b, c));

  printf("%lld\n", sum);

  return 0;
}

	 


Measured memory_bytes: 1700
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <typeinfo>
#include <climits>
using namespace std;
#define INIT cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)

int main()
{
    INIT;

    double a, b;
    cin >> a >> b;
    cout << round((a + b) / 2) << endl;


    return 0;
}

Measured memory_bytes: 256
const MOD: u64 = 1e9 as u64 + 7;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let m: usize = sc.read();

    let mut constraint = vec![vec![]; n + 1];
    for _ in 0..m {
        let l: usize = sc.read();
        let r: usize = sc.read();
        let x: usize = sc.read();
        constraint[r].push((l, x));
    }

    let mut dp = vec![vec![vec![0; n + 1]; n + 1]; n + 1];
    dp[0][0][0] = 1;
    for pos in 1..(n + 1) {
        for last_x in 0..pos {
            for last_y in 0..pos {
                for &(last_r, last_g, last_b) in [
                    (last_x, last_y, pos - 1),
                    (last_x, pos - 1, last_y),
                    (pos - 1, last_x, last_y),
                ]
                .into_iter()
                {
                    if dp[last_r][last_g][last_b] == 0 {
                        continue;
                    }
                    if last_r > 0 && (last_r == last_g || last_r == last_b) {
                        continue;
                    }
                    if last_g > 0 && last_g == last_b {
                        continue;
                    }
                    for &(r, g, b) in [
                        (last_r, last_g, pos),
                        (last_r, pos, last_b),
                        (pos, last_g, last_b),
                    ]
                    .into_iter()
                    {
                        let mut ok = true;
                        for &(left, x) in constraint[pos].iter() {
                            let count = if left <= r { 1 } else { 0 }
                                + if left <= g { 1 } else { 0 }
                                + if left <= b { 1 } else { 0 };
                            if count != x {
                                ok = false;
                                break;
                            }
                        }

                        if ok {
                            dp[r][g][b] += dp[last_r][last_g][last_b];
                            dp[r][g][b] %= MOD;
                        }
                    }
                }
            }
        }
    }

    let mut ans = 0;
    for i in 0..n {
        for j in 0..n {
            ans += dp[i][j][n];
            ans %= MOD;
        }
    }

    println!("{}", ans);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 237948
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  string s;
  cin >> s;
  
  bool gate1 = false;
  bool gate2 = false;
  bool gate3 = false;
  
  if (s[0] == 'A') gate1 = true;
  
  int count = 0;
  for (int i = 2; i < s.size() - 1; i++){
    if(s[i] == 'C') count++;
  }
  if (count == 1) gate2 = true;
  
  count = 0;
  for (int i = 0; i < s.size(); i++){
    if(islower(s[i])) count++;
  }
  if(count == s.size()-2) gate3 = true;
  
  if(gate1 && gate2 && gate3) cout << "AC";
  else cout << "WA";
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int map[100000]={0};
  int a[100000];
  int N;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  int b=0;
  map[0]=1;
  for(int i=0;i<=N;i++){
    b=a[b]-1;
    if(b==1){
      cout << i+1 <<endl;
      break;
    }else if(map[b]==1){
      cout << "-1" <<endl;
      break;
    }
    map[b]=1;
  }
}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int n;
    cin >> n;
    int s, sum = 0;
    vector<int> v;
    for (int i=0; i<n; i++) {
        cin >> s;
        v.push_back(s);
        sum += s;
    }
    sort(v.begin(), v.end());
    if (sum % 10 == 0) {
        auto iter = v.begin();
        while ((*iter) % 10 == 0 && iter != v.end()) {
            iter++;
        } 
        if (iter == v.end()) {
            cout << 0 << endl;
        } else {
            sum -= *iter;
            cout << sum << endl;
        }
    } else {
        cout << sum << endl;
    }
}

Measured memory_bytes: 3612
s = input()
ss = s + s
sss = s + s + s
k = int(input())
n = 0
nn = 0
nnn = 0
s = list(s)
for i in range(1,len(s)):
  if s[i-1] == s[i]:
    n += 1
    s[i] = '.'
ss = list(ss)
for i in range(1,len(ss)):
  if ss[i-1] == ss[i]:
    nn += 1
    ss[i] = '.'
sss = list(sss)
for i in range(1,len(sss)):
  if sss[i-1] == sss[i]:
    nnn += 1
    sss[i] = '.'
a = nn-n*2
if nnn == n*3+a*2:
  print(n*k+a*(k-1))
else:
  print((len(s)*k)//2)

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

#define ull unsigned long long
#define endl '\n'
#define ll long long
const int N = 2e5 + 5;
ll ans[N];
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        //freopen("VLJUM.INP", "r", stdin);
        //freopen("VLJUM.OUT", "w", stdout);
        ll n;
        cin >> n;
        for (int i = 1; i < n; i++) {
                ll a;
                cin >> a;
                ans[a]++;
        }
        for (int i = 1; i <= n; i++){
                cout << ans[i] << " ";
        }
}



Measured memory_bytes: 5216
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e10;
const ll MAX_N = 1010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dp[201010][2];
ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };

//long longしか使わない
//素数は1より大きい
int main() {
	ll n;
	cin >> n;
	string s;
	cin >> s;
	ll left = 0;
	ll right = 0;
	rep(i, n) {
		if (s[i] == '(') {
			left++;
		}
		else {
			right++;
			if (left > 0) {
				left--;
				right--;
			}
		}
	}
	string left2;
	string right2;
	rep(i, left) {
		right2 += ')';
	}
	rep(i, right) {
		left2 += '(';
	}
	left2 += s;
	left2 += right2;
	cout << left2 << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
using namespace std;

inline bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
inline bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
    int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
    return x * fh;
}

int main () {
	int n = read(), m = read();
	if (n > m) swap(n, m);
	if (n == 1 && m == 1) { printf ("1"); return 0; }
	if (n == 1) { printf ("%d\n", m - 2); return 0; }
	printf ("%lld\n", 1ll * (n - 2) * (m - 2));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <sstream>
#define ull unsigned long long
#define ll long long
#define INF 1000000007
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c;
    cin >> a >> b >> c;
    if(a%2==0 || b%2==0 || c%2==0) {
        cout << 0 << endl;
        return 0;
    }
    vector<ll> w = {a*b,a*c,b*c};
    ll ans = *min_element(w.begin(),w.end());
    cout << ans << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;

constexpr int MAXN = 200000;

pair<int, int> monster[MAXN + 2];

int main() {
	int N, D, A;
	cin >> N >> D >> A;
	for(int i = 0; i < N; i++)
		cin >> monster[i].first >> monster[i].second;
	sort(monster, monster + N);
	queue<pair<int, int>> atk;
	int d = 2 * D + 1;
	ll ans = 0;
	for(int i = 0, cur = 0; i < N; i++) {
		int x = monster[i].first, h = (monster[i].second + A - 1) / A;
		while(!atk.empty() && x >= atk.front().first) {
			cur -= atk.front().second;
			atk.pop();
		}
		if(cur < h) {
			ans += h - cur;
			atk.push({x + d, h - cur});
			cur = h;
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 2688
#include<stdio.h>
#include<math.h>
int main()
{
    int N,x,p,count=0,i;
    scanf("%d",&N);
    while(N--)
    {
        p=1;
        scanf("%d",&x);
        for(i=2;i<=sqrt(x);i++)
        {
            if(x%i==0)
            {
                p=0;
                break;
            }
        }
        if(p==1)
            count++;
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 1764
def d():
    s = input()

    for i in range(len(s)-1):
        if s[i] == s[i+1]:
            print("{:g} {:g}".format(i+1, i+2))
            return

    for i in range(len(s)-2):
        if s[i] == s[i+2]:
            print("{:g} {:g}".format(i+1, i+3))
            return

    print("-1 -1")

if __name__ == "__main__":
    d()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i=(a); i<=int(b); i++)
using namespace std;
int n, A, B, tot;
int main() {
	scanf("%d%d%d", &n, &A, &B);
	if (A + B > n + 1 || 1LL * A * B < n) return puts("-1"), 0;
	n -= A; 
	rep (i, 1, A) {
		tot += min(n, B-1) + 1;
		rep (j, 0, min(n, B-1))
			printf("%d ", tot - j);
		n -= min(n, B-1);
	}
	return 0;
}

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

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define pmod 1000000007
#define maxn 100005
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(int i=a ; i<=b ; i++)
#define INF 1000000000
#define ll long long int
#define eps (1e-8)
#define sq(x) ( (x)*(x) )

using namespace std;

typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

int main()
{while (1){ ll res=0;
int n,x;
    cin>>n>>x;
    if (n==0) return 0;
    FOR (i,1,n){
        FOR (j,i+1,n){
            FOR (k,j+1,n){
                if (j+k+i==x) res++;
            }
        }
    }
    cout<<res<<endl;
}

         return 0;
}

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

int main(){
  int ans=0;
  cin>>ans;
    while(1){
      char c;
      cin>>c;
            if(c=='=') break;
      int a;
      cin>>a;
      if(c=='+')ans+=a;
      else if(c=='-') ans-=a;
      else if(c=='*')ans*=a;
      else if(c=='/')ans/=a;
    }
    cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1164
from sys import stdin
from collections import deque
def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())
    G=[[] for _ in range(n+1)]
    for i in range(m):
        a,b=map(int,readline().split())
        G[a].append(b)
        G[b].append(a)

    ans=[0]*(n+1)
    flags=[False]*(n+1)
    flags[1]=True
    d=deque([1])
    while len(d)>0:
        now=d.popleft()
        v=now
        for u in G[v]:
            if flags[u]==False:
                flags[u]=True
                ans[u]=v
                d.append(u)

    print("Yes")
    for i in range(2,n+1):
        print(ans[i])
        
if __name__=="__main__":
    main()

Measured memory_bytes: 95528
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N[2];
int bit[2][100010];

void add(int t, int a, int w) {
  for (int x=a; x<=N[t]; x += x & -x) {
    bit[t][x] += w;
  }
}

int sum(int t, int a) {
  int ret = 0;
  for (int x=a; x>0; x -= x & -x) {
    ret += bit[t][x];
  }
  return ret;
}

string S[2];
int q;
int a[2][100010], b[2][100010];

int h(char a) {
  return (a - 'A' + 1);
}

int main () {
  fill(&bit[0][0], &bit[0][0]+2*100010, 0);
  cin >> S[0] >> S[1];
  cin >> q;
  for (auto i = 0; i < q; ++i) {
    cin >> a[0][i] >> b[0][i] >> a[1][i] >> b[1][i];
  }
  for (auto t = 0; t < 2; ++t) {
    N[t] = S[t].size();
    for (auto i = 0; i < N[t]; ++i) {
      // cerr << "S[" << t << "][" << i << "] = " << h(S[t][i]) << endl;
      add(t, i+1, h(S[t][i]));
    }
  }
  for (auto i = 0; i < q; ++i) {
    int score[2] = {0, 0};
    for (auto t = 0; t < 2; ++t) {
      int genten = ((a[t][i] == 1) ? 0 : (sum(t, a[t][i] - 1)));
      int katen = sum(t, b[t][i]);
      score[t] = katen - genten;
    }
    cout << ((score[0]%3 == score[1]%3) ? "YES" : "NO") << endl;
  }
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include<unordered_map>
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
ll ans = 0;

int main() {
	ll a[3];
	cin >> a[0] >> a[1] >> a[2];
	ll dif[3];
	dif[0] = abs(a[0] - a[1]);
	dif[1] = abs(a[1] - a[2]);
	dif[2] = abs(a[2] - a[0]);
	ans = max(dif[0], max(dif[1], dif[2]));
	cout << dif[0] + dif[1] + dif[2] - ans << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include"math.h"
#include<vector>
#include<deque>
#include<map>
#include<set>
#define ll long long
#define dou(s) atof(s.c_str())
#define lll(s) atoll(s.c_str())
#define str(n) to_string(n)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define ALL(a) a.begin(),a.end()
#define delete(a,i) a.erase(a.begin()+i)
#define fion(n) fixed<<setprecision(n)
#define endl "\n"
#define OR ||
#define AND &&
#define NOT !
#define line(s) getline(cin,s)
#define START int main(){cin.tie(0);ios::sync_with_stdio(false);
#define END }
using namespace std;
START
deque<ll> a;
ll n; cin >> n;
string s; ll k;
rep(q, 0, n) {
	cin >> s;
	if (s == "insert") {
		cin >> k;
		a.push_front(k);
	}
	else if (s == "delete") {
		cin >> k;
		rep(i, 0, a.size()) {
			if (a[i] == k) {
				delete(a, i);
				break;
			}
		}
	}
	else if (s == "deleteFirst")a.pop_front();
	else a.pop_back();
}
cout << a[0];
rep(i, 1, a.size())cout << ' ' << a[i];
cout << endl;
END


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

using namespace std;

int main(void){
    int N;
    cin >> N;
    vector<long long> X(N);
    for(int i = 0; i < N; i++) cin >> X[i];
    long long ans = 100000000LL;
    for(long long P = 0; P <= 100; P++){
        long long s = 0;
        for(int i = 0; i < N; i++) s += (X[i] - P) * (X[i] - P);
        ans = min(ans, s);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int A[100000][3];
int max(int a, int b){
	if (a >= b)return a;
	else return b;
}
int main(){
	IOS;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> A[i][0] >> A[i][1] >> A[i][2];
	}
	for (int i = 1; i < n; i++){
		A[i][0] += max(A[i - 1][1], A[i - 1][2]);
		A[i][1] += max(A[i - 1][0], A[i - 1][2]);
		A[i][2] += max(A[i - 1][0], A[i - 1][1]);
	}
	int x = max(A[n-1][0], A[n-1][1]);
	x = max(x, A[n-1][2]);
	cout << x << endl;
}

Measured memory_bytes: 1536