akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define N 200020
#define ll long long
using namespace std;
inline int read(){
  int x=0,f=1;char ch=getchar();
  while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
  while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
  return f?x:-x;
}

int a[N], b[N], c[N];
int l[N], r[N];

int main(int argc, char const *argv[]) {
  int n = read();
  for (int i = 1; i <= n; ++ i) {
    a[i] = read();
  }

  int top = 0;
  for (int i = 1; i <= n; ++ i) {
    while (top && b[top] > a[i]) {
      -- top;
    }
    l[i] = c[top];
    b[++ top] = a[i];
    c[top] = i;
  }

  top = 0;
  c[0] = n + 1;
  for (int i = n; i; -- i) {
    while (top && b[top] > a[i]) {
      -- top;
    }
    r[i] = c[top];
    b[++ top] = a[i];
    c[top] = i;
  }

  ll ans = 0;
  for (int i = 1; i <= n; ++ i) {
    ans += (ll) a[i] * (i - l[i]) * (r[i] - i);
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    string s;
    cin >> s;
    cout << count(s.begin(), s.end(), '+') - count(s.begin(), s.end(), '-') << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double  
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define LOL cout<<'\n';
#define MOD 1000000007
#define sz(x) ((ll)x.size())
ll powm(ll a,ll n,ll x=MOD){a%=x;ll r=1;while(n>0){if(n&1)r=(r*a)%x;a=(a*a)%x;n>>=1;}return r;}

ll h,w,k;
vector<string> v;

bool f(ll a,ll b){
  ll cnt=0;
  for(ll i=0 ; i<h ; i++){
    for(ll j=0 ; j<w ; j++){
      if(a&(1<<i) || b&(1<<j)) continue;
      if(v[i][j]=='#') cnt++;
    }
  }
  return cnt==k;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  ll _=1; //cin>>_;
  while(_--)
  {
    v.empty();
    cin>>h>>w>>k;
    string s;
    for(ll i=0 ; i<h ; i++){
      cin>>s;
      v.pb(s);
    }
    ll ans=0;
    for(ll i=0 ; i<(1<<h) ; i++){
      for(ll j=0 ; j<(1<<w) ; j++){
        if(f(i,j)) ans++;
      }
    }
    cout<<ans;LOL
  }
  return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<stdlib.h>
#include<string.h>
using namespace std;
int main()
{
    int n,k,a[100]={0};
    scanf("%d%d",&n,&k);
    int i=0,j=0;
    while(n)
    {
        a[i]=n%k;
        n/=k; i++;
        j++;
    }
    printf("%d",j);
    return 0;
}

Measured memory_bytes: 256
import heapq
n = int(input())
xs = list(map(int, input().split()))
head = [(x, x) for x in xs[:n]]
heapq.heapify(head)
body = xs[n:-n]
tail = [(-x, x) for x in xs[-n:]]
heapq.heapify(tail)

def f(heap, body, sign, initial):
    answer = [initial]
    acc = initial
    for b in body:
        heapq.heappush(heap, (sign*b, b))
        _, x = heapq.heappop(heap)
        acc = acc + b - x
        answer.append(acc)
    return answer
 
print(max(x - y for x, y in zip(
    f(head, body, 1, sum(xs[:n])),
    f(tail, body[::-1], -1, sum(xs[-n:]))[::-1])))

Measured memory_bytes: 45584
import java.util.Scanner;

public class Main {
	public static int flag=0;
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n, q, m, i;
		n = scan.nextInt();
		int[] A = new int[n];
		for (i = 0; i < n; i++) {
			A[i] = scan.nextInt();
		}
		q = scan.nextInt();
		for (i = 0; i < q; i++) {
			m = scan.nextInt();
			flag=0;
			work(n, 0, A, m);
			if(flag==1) {
				System.out.println("yes");
			}
			else {
				System.out.println("no");
			}
		}
		scan.close();
	}

	public static void work(int num, int sum, int[] A, int m) {
		if (num!=0 && sum<m) {
			work(num - 1, sum, A, m);
			work(num - 1, sum + A[num - 1], A, m);
		}
		else if (sum == m) {
			flag=1;
		}
	}
}


Measured memory_bytes: 26704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pll pair<ll,ll>
#define pb push_back
#define F first
#define S second
#define I insert
#define vll vector<ll>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){ cout << name << " : " << arg1 << std::endl; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif
#define endl '\n'

ll power(ll a, ll b, ll mod){ ll c = 1; while(b>0){ if(b%2) c*=a, c%=mod; b/=2; a*=a; a%=mod; } return c; }
 
const ll N = (5e3) + 10;
const ll M = 320;
const ll Mod = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout<<setprecision(25);
    ll n,k,a,b,c;
    cin>>n>>k;
    if(k == 1){
    	n = n*n*n;
    	cout<<n<<endl; return 0;
    }
    a = n/k; a *= a*a;
    if(k%2 == 0){
    	b = n/k; n %= k; if(n >= k/2) b++;
    	// cout<<b<<endl;
    	a += b*b*b;
    }
    cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

t1,t2 = LI()
a1,a2 = LI()
b1,b2 = LI()

x,y = a1*t1,b1*t1
z,w = a1*t1 + a2*t2, b1*t1 + b2*t2
if (x > y and z > w) or (y > x and w > z):
    print(0)
    quit()
if (z == w) :
    print('infinity')
    quit()
if x < y:
    x,y = y,x
if z < w:
    z,w = w,z
s1 = x - y
s2 = z - w
p = math.ceil(s1/s2)
q = s1 % s2
ans = 2*p - (q != 0)
print(ans)


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

#define xx first
#define yy second

#define MAX_N 500

using namespace std;

int dp[MAX_N + 1][MAX_N + 1];

int p[MAX_N * MAX_N + 1];

pair <int, int> poz[MAX_N * MAX_N + 1];

int rez;
const int dl[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int n;

int viz[MAX_N + 1][MAX_N + 1];

int ops;

void dfs(int l, int c, int nr)
{
    ops ++;
    for(int dir = 0; dir <= 3; dir ++)
    {
        int nl = l + dl[dir];
        int nc = c + dc[dir];

        if(nl >= 1 && nl <= n && nc >= 1 && nc <= n)
        {
            if(dp[nl][nc] > nr + viz[l][c])
            {
                dp[nl][nc] = nr + viz[l][c];
                dfs(nl, nc, dp[nl][nc]);
            }
        }
    }
}

void afis()
{
    for(int i = 1; i<= n; i ++)
    {
        for(int j = 1; j <= n; j ++)
            cout << dp[i][j] << " " ;
        cout << "\n";
    }

    cout << "\n";
}

void solve()
{
    for(int i = 1; i <= n; i ++)
    {
        for(int j = 1; j <= n; j ++)
        {
            dp[i][j] = min({i - 1, j - 1, n - i, n - j});
            viz[i][j] = 1;
        }
    }

    int cr = 1;
    for(int i = 1; i <= n; i ++)
    {
        for(int j = 1; j <= n; j ++)
        {
            poz[cr] = {i, j};
            cr ++;
        }
    }

    for(int i = 1; i <= n*n; i ++)
    {
        int care = p[i];

        int l = poz[care].xx;
        int c = poz[care].yy;

        rez += dp[l][c];

        viz[l][c] = 0;
        dfs(l, c, dp[l][c]);

       // afis();
    }

    //cout << ops << " OPS \n";

    cout << rez << "\n";
}

int main()
{
    cin >> n;

    for(int i = 1; i <= n*n; i ++)
        cin >> p[i];

    solve();

    return 0;
}


Measured memory_bytes: 27296
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iter = input.split_whitespace();

    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: usize = iter.next().unwrap().parse().unwrap();

    let mut accepted = vec![false; n + 1];
    let mut warnings = vec![0; n + 1];

    let mut accepts: usize = 0;
    let mut penalties: usize = 0;
    for _ in 0..m {
        let p: usize = iter.next().unwrap().parse().unwrap();
        let s: &str = iter.next().unwrap();

        if s == "AC" && accepted[p] == false {
            accepted[p] = true;
            accepts += 1;
            penalties += warnings[p];
        }
        if s == "WA" {
            warnings[p] += 1;
        }
    }

    return format!("{} {}", accepts, penalties);
}

#[test]
fn test() {
    assert_eq!(solve(r"2 5
    1 WA
    1 AC
    2 WA
    2 AC
    2 WA"), "2 2");
    assert_eq!(solve(r"100000 3
    7777 AC
    7777 AC
    7777 AC"), "1 0");
    assert_eq!(solve(r"6 0"), "0 0");
}


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

using namespace std;

using ll = long long;

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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    A.at(0) = 0;
    for(int i=1;i<N;i++)
    {
        cin >> A.at(i);
    }

    vector<int> sin(N,0);
    for(int i=1;i<N;i++)
    {
        sin.at(A.at(i)-1)++;
    }
    
    for(auto x : sin)
    {
        cout << x << endl;
    }

    return 0;
}

Measured memory_bytes: 4844
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next();
  var a = next(1);
  var b = Array(n-1);
  var n2 = n-1, x = [0,0,0];
  for(var i = 0; i < n2; i++){
    var y = Math.abs(a[i]-a[i+1]);
    b[i] = y;
    x[y]++;
  }
  var z = solve(b)[0];
  if(x[1] && z === 2)return 0;
  return z;
}

function solve(b){
  var bl = b.length;
  if(bl === 1)return b;
  var c = [], d = 1 << 31-Math.clz32(bl), s = 0;
  for(var i = 0; i < d; i++){
    s ^= b[i];
  }
  for(i--;;){
    var t = s === 3 ? 1 : s;
    c.push(t);
    i++;
    if(i === bl)break;
    s ^= b[i];
    s ^= b[i-d]
  }
  return solve(c);
}

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

S = input().split(" ")

arr = [int(s) for s in S]

def calculate(m,n):
    if m == n:
        return m
    elif m > n:
        s = m % n
        if s == 0:
            return n
        else:
            return calculate(n,s)
    else:
        s = n % m
        if s == 0:
            return m
        else:
            return calculate(m,s)

v = arr[0]

for index in range(1,n):
    v = calculate(v,arr[index])

print(v)



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

int main() {
	string Sd, T; cin >> Sd >> T;
	bool whole=false, check;
	for(int i=Sd.size()-T.size(); i>=0; --i){
	    check=true;
	    for(int j=0; j<T.size(); ++j){
	        if(Sd[i+j]!='?' && Sd[i+j]!=T[j]){
	            check=false;
	            break;
	        }
	    }
	    if(check){
	        for(int k=0; k<T.size(); ++k) Sd[i+k]=T[k];
	        whole=true;
	        break;
	    }
	}
	if(whole){
	    for(int i=0; i<Sd.size(); ++i){
	        if(Sd[i]=='?') cout << 'a';
	        else cout << Sd[i];
	    }
	    cout << endl;
	}
	else cout << "UNRESTORABLE" << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static boolean checkXOR(long a0, long a1, long a2) {
		long a012 = a0 ^ a1 ^ a2;
		if (0 == a012)
			return true;
		else
			return false;
	}

	public static boolean check3(long[] a) {
		int cnt0 = 0;
		int cnt1 = 0;
		int cnt2 = 0;
		long base0 = 0L;
		long base1 = 0L;
		long base2 = 0L;
		for (int i = 0; i < a.length; i++) {
			if (a[i] != 0) {
				if (base0 == 0) {
					cnt0++;
					base0 = a[i];
				} else if (base1 == 0 && a[i] != base0) {
					cnt1++;
					base1 = a[i];
				} else if (base2 == 0 && a[i] != base0 && a[i] != base1) {
					cnt2++;
					base2 = a[i];
					if (!checkXOR(base0, base1, base2))
						return false;
				} else if (a[i] == base0) {
					cnt0++;
				} else if (a[i] == base1) {
					cnt1++;
				} else if (a[i] == base2) {
					cnt2++;
				} else
					return false;
			} else
				return false;
		}
		if (cnt0 == a.length / 3 && cnt1 == a.length / 3 && cnt2 == a.length / 3)
			return true;
		else
			return false;
	}

	public static boolean check2_3(long[] a) {
		int cnt0 = 0;
		int cnt1 = 0;
		long base = 0L;
		for (int i = 0; i < a.length; i++) {
			if (a[i] != 0) {
				if (base == 0) {
					cnt0++;
					base = a[i];
				} else if (base == a[i]) {
					cnt0++;
				} else
					return false;
			} else {
				cnt1++;
			}
		}
		if (cnt0 == a.length * 2 / 3 && cnt1 == a.length / 3)
			return true;
		else
			return false;
	}

	public static boolean check0(long[] a) {
		for (int i = 0; i < a.length; i++) {
			if (a[i] != 0) {
				return false;
			}
		}
		return true;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] a = new long[N];
		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextLong();
		}
		sc.close();

		if (check0(a)) {
			System.out.println("Yes");
			return;
		}
		
		if (N % 3 != 0) {
			System.out.println("No");
			return;
		}
		
		if (check2_3(a)) {
			System.out.println("Yes");
			return;
		}
		if (check3(a)) {
			System.out.println("Yes");
			return;
		}
		System.out.println("No");
		return;
	}
}

Measured memory_bytes: 61484
n,w = map(int,input().split())
weighs,values = [],[]
for i in range(n):
    wa,va = map(int,input().split())
    weighs.append(wa)
    values.append(va)

dp = [0 for k in range(100001)]
used = [[0 for i in range(n)] for k in range(100001)]

for i in range(1,100001):
    mina = 1000000000000
    useda = [0 for i in range(n)]
    for k in range(n):
        if i-values[k] >= 0:
            if dp[i-values[k]] != -1 and used[i-values[k]][k] == 0 :
                #print(i,k)
                if  dp[i-values[k]]+weighs[k]<mina:
                        #print("いい感じ")
                        mina = dp[i-values[k]]+weighs[k]
                        useda = used[i-values[k]][:]
                        useda[k] = 1
                #print(mina,useda)
    if mina == 1000000000000:
        dp[i] = -1
    else:
        dp[i] = mina
    used[i] = useda

ans = 0
for i in range(100001):
    if dp[i] != -1 and dp[i] <= w:
        #print(i)
        ans = max(ans,i)

print(ans)


Measured memory_bytes: 180060
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vll path;
int main() {
	ll S, W;
	cin >> S >> W;
	if (W >= S) cout << "unsafe";
	else cout << "safe";
}


Measured memory_bytes: 3636
import java.math.BigInteger;
import java.util.*;


public class Main {
	
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int [] data = new int[n];
			for(int i = 0; i < n; i++){
				data[i] = sc.nextInt();
			}
			
			long count = 0;
			int now = 0;
			int left = 0, right = 0;
			while(true){
				if(left >= n){
					break;
				}
				while(right < n){
					int res = now ^ data[right];
					int res2 = now | data[right];
					if(res != res2){
						break;
					}
					now = now ^ data[right];
					right++;
				}
				count += right - left;
				now = now ^ (now & data[left]);
				left++;
			}
			System.out.println(count);
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

}


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

void solve(void){
  int A, B; 

  cin >> A >> B;
  
  if(A>8 || B>8){
    cout << ":(" << endl;
  }
  else
  {
    cout << "Yay!" << endl;
  }
  
  return;
}

int main(int argc, const char * argv[]) {

    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);

  solve();
  
  return 0;
}

Measured memory_bytes: 256
S = input()
l = list(S)

#odd loop
for i in range(0, len(l), 2):
    if l[i] == 'L':
        print('No')
        exit()

#even loop
for j in range(1, len(l), 2):
    if l[j] == 'R':
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 3060
if __name__ == '__main__':
	n,m = map(int,input().split())
	A = list(map(int,input().split()))
	A.sort()

	if n > m:
		print(0)
		exit()

	B = []
	for i in range(m-1):
		#差分を求める
		B.append(A[i+1] - A[i])
	B.sort()
	
	print(sum(B[:m-n]))


Measured memory_bytes: 20224
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ull = unsigned long long;

#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define For(i, s, n) for(int i = s; i < (int)(n); ++i)

int main() {
  ull N, M, K;
  cin >> N >> M >> K;

  vector<ull> As(N + 1);
  vector<ull> Bs(M + 1);

  Rep(n, N) {
    ull i;
    cin >> i;
    As[n + 1] = As[n] + i;
  }

  Rep(m, M) {
    ull i;
    cin >> i;
    Bs[m + 1] = Bs[m] + i;
  }

  int answer = 0;
  int m = M;
  Rep(n, N + 1) {
    if (K < As[n]) continue;
    ull remain = K - As[n];
    while (m) {
      if (remain < Bs[m]) {
        m--;
      } else {
        break;
      }
    }
    answer = max(answer, n + m);
  }

  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 6404
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())


dishes = [A, B, C, D, E]
tens = 0
ones = 10
muda = 10
for d in dishes:
    if d % 10 == 0:
        tens += d // 10
    else:
        tens += d // 10 + 1
        if d % 10 < ones:
            muda = d
            ones = d % 10

#%%
if muda % 10 == 0:
    ans = tens * 10
else:
    ans = tens * 10 - (10 - muda % 10)
print(ans)

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////


int main() {
	ll N, K, C;
	cin >> N >> K >> C;
	string S;
	cin >> S;

	vector<ll> dp(N + 1,0);
	repn(i, N) {
		if (S[i - 1] == 'o') {
			if (i > C) { dp[i] = max(dp[i - 1], dp[i - C - 1] + 1); }
			else { dp[i] = 1; }
		}
		else { dp[i] = dp[i-1]; }
		//cout << dp[i] << endl;
	}

	vector<ll> pd(N + C + 2, 0);

	for (ll i = N; i >= 1; i--) {
		if (S[i - 1] == 'o') { pd[i] = max(pd[i + 1], pd[i + C + 1]+ 1);}
		else { pd[i] = pd[i + 1]; }
		//cout << pd[i] << endl;
	}

	repn(i, N) {
		if (dp[i - 1] + pd[i + 1] == K - 1) { cout << i << endl; }
	}

	system("PAUSE");
}


Measured memory_bytes: 5124
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long int64; 

int nstr;
char strings[40][17];
void init_id(){
	nstr=0;
}
int get_id(char str[]){
	for(int i=0;i<nstr;i++)
		if(strcmp(str,strings[i])==0)return i;
	strcpy(strings[nstr],str);
	return nstr++;
}

inline int64 get_bit(int id){
	return (int64)1<<id;
}

struct A{
	int id;
	int power;
	int64 neighbor;
	int count()const{
		int res=0;
		for(int i=0;i<64;i++)res+= neighbor>>i&1;
		return res;
	}
	bool operator <(const A&a)const{
		return count() > a.count();
	}
}kuni[40];

int search(int i,int n,int power,int64 neighbor){
	int tmp,max;	
	int64 a=neighbor;
	
	for(int j=i;j<n;j++)
		if( (get_bit(kuni[j].id) & neighbor)==0 )
			a |= kuni[j].neighbor;
	for(int j=i;j<n;j++){
		if( (get_bit(kuni[j].id) & a)==0){
			power += kuni[j].power;
			neighbor |= get_bit(kuni[j].id);
		}
	}
	max = power;
	for(;i<n;i++){
		if( (get_bit(kuni[i].id) & neighbor)==0 ){
			tmp = search(i+1,n,power+kuni[i].power,neighbor|kuni[i].neighbor);
			if(max < tmp){
				max = tmp;
			}
		}
	}
	return max;
}
int main(){
	int n;
	while(cin>>n,n){
		init_id();
		for(int i=0;i<n;i++){
			char a[17],d[17];
			int b,c;
			cin>>a>>b>>c;
			kuni[i].id = get_id(a);
			kuni[i].power = b;
			kuni[i].neighbor = 0;
			while(c--){
				cin>>d;
				kuni[i].neighbor |= get_bit(get_id(d));
			}
		}
		sort(kuni+1,kuni+n);
		cout<<search(1,n,kuni[0].power,kuni[0].neighbor)<<endl;
	}
	return 0;
}

Measured memory_bytes: 880
#include <iostream>
#include <map>
#include <cmath>

using namespace std;

int n, m, d;
int p_x[900005];
int p_y[900005];
int p_d[900005];

int main()
{
	int x, q;
	int l, r;

	scanf("%d %d %d", &n, &m, &d);

	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
		{
			scanf("%d", &x);
			p_x[x] = i;
			p_y[x] = j;
		}

	for (int i = d+1; i <= n*m; ++i)
		p_d[i] = p_d[i-d] + abs(p_x[i] - p_x[i-d]) + abs(p_y[i] - p_y[i-d]);

	scanf("%d", &q);

	while (q)
	{
		scanf("%d %d", &l, &r);
		printf("%d\n", p_d[r] - p_d[l]);
		--q;
	}
}

Measured memory_bytes: 5632
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        boolean f=false;
        for (;;) {
            int n = sc.nextInt();
            if(n==0)break;
            if(f) {
                System.out.println("");
            }
            f=true;
            T[] t = new T[n];
            for (int i = 0; i < n; i++) {
                t[i] = new T(sc.next(), sc.nextInt() * 3 + sc.nextInt() * 0 + sc.nextInt());
            }
            Arrays.sort(t, new Comparator<T>() {
                public int compare(T a, T b) {
                    return b.s - a.s ;
                }
            });
            for(T a:t) {
                System.out.println(a.t+","+a.s);
            }
        }
    }
}
class T {
    String t;
    int s;

    T(String t, int s) {
        this.t = t;
        this.s = s;
    }
}




Measured memory_bytes: 27568
// import chie template :) {{{
import std;

// }}}
// nep.scanner {{{
class Scanner {
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType)) {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0) {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }

  void scan()() {
  }

  void scan(T, S...)(ref T x, ref S args) {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType)) {
    str ~= s.to!(char[]).strip.split;
  }
}
// }}}

void main() {
  auto cin = new Scanner;
  int n;
  string s;
  cin.scan(n, s);

  int[][dchar] imos;
  imos['R'] = new int[n + 1];
  imos['G'] = new int[n + 1];
  imos['B'] = new int[n + 1];

  foreach (i, c; s) {
    imos[c][i] = 1;
  }

  imos['R'] = imos['R'].cumulativeFold!"a + b".array;
  imos['G'] = imos['G'].cumulativeFold!"a + b".array;
  imos['B'] = imos['B'].cumulativeFold!"a + b".array;

  alias T = Tuple!(uint, "fst", uint, "snd", dchar, "rem");
  T[] can;

  auto per = permutations("RGB".to!(dchar[]));
  foreach (p; per) {
    foreach (i; 0 .. n) {
      foreach (j; i + 1 .. n) {
        if (p[0] == s[i] && p[1] == s[j]) {
          can ~= T(i, j, p[2]);
        }
      }
    }
  }

  long res;
  foreach (e; can) {
    uint mid = min(2 * e.snd - e.fst, n);
    auto sum = imos[e.rem];

    res += sum[mid - 1] - sum[e.snd] + sum[n] - sum[mid];
  }

  writeln(res);
}


Measured memory_bytes: 108388
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
   int a,b,c ;
   cin >> a >> b >> c ;
  
   int ans = c-(a-b) ;
   if(ans<0)  ans = 0;
   cout << ans << endl;
  
  
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int h,w;
int sx,sy,gx,gy;


                      
vector <string> field;
vector <vector<int>> dp(100,vector<int> (100,-1));

int main() {
cin >> h>>w ;
field.resize(h);
rep(i,h)
{ 
  cin >> field.at(i);
}
rep(i,h)
{
  rep(j,w)
  {  int left=1e4,top=1e4;
    if(j-1>=0 )//一個左のますがフィールド内なら
    { 
      left=dp[i][j-1];
      if(field[i][j-1]!='#'&& field[i][j]=='#')
      {left++;}
    }

    if(i-1>=0)//一個上のますがフィールド内なら
    {
      top=dp[i-1][j];
      if(field[i-1][j]!='#'&&field[i][j]=='#')
      {top++;}
    }

    dp[i][j]=min(left,top);
    if(i==0&&j==0)
    {dp[0][0]=0;
    if(field[0][0]=='#')
    {
      dp[0][0]=1;
    }}


    
  }
}
int ans=dp[h-1][w-1];

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


Measured memory_bytes: 256
//
// Created by Hideaki Imamura on 2020-03-16.
//
# include <bits/stdc++.h>

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

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

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

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

int N;
vector<double> p;

int main() {
    cin >> N;
    p.assign(N, 0);
    for (int i = 0; i < N; ++i) cin >> p[i];

    vector<vector<double>> dp(N + 1, vector<double>(N + 1, 0));
    dp[0][0] = 1;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            dp[i + 1][j + 1] += dp[i][j] * p[i];
            dp[i + 1][j] += dp[i][j] * (1 - p[i]);
        }
    }

    double ans = 0;
    for (int i = N / 2 + 1; i <= N; ++i) ans += dp[N][i];
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 70656
#include"iostream"
#include"vector"
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
class vertex
{
public:
  vector<int> next;
  int first;
  int second;
  int color;
  vertex()
  {
    this->color=WHITE;
  }
};
vector<vertex> V;
int Time;
void visit(int u)
{
  V[u].color=GRAY;
  V[u].first=++Time;
  for(int v=0;v<V[u].next.size();v++)
    {
      if(V[V[u].next[v]].color==WHITE)
        {
          visit(V[u].next[v]);
        }
    }
  V[u].color=BLACK;
  V[u].second=++Time;
}
void dfs()
{
  for(int u=1;u<V.size();u++)
    {
      V[u].color=WHITE;
    }
  Time=0;
  for(int u=1;u<V.size();u++)
    {
      if(V[u].color==WHITE)
        {
          visit(u);
        }
    }
}
int main()
{
  int n;
  cin>>n;
  for(int i=0;i<=n;i++)
    {
      vertex a;
      V.push_back(a);
    }
  for(int i=1;i<=n;i++)
    {
      int num;
      cin>>num;
      int k;
      cin>>k;
      for(int j=0;j<k;j++)
        {
          int next;
          cin>>next;
          V[num].next.push_back(next);
        }
    }
  dfs();
  for(int i=1;i<=n;i++)
    {
      cout<<i<<" "<<V[i].first<<" "<<V[i].second<<endl;
    }
  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}


void solve()
{
   int a[5];
    
   f(i,5)
   {
       cin >> a[i];
   }
    
   f(i,5) if(a[i] ==0) cout << i+1; 
    
    
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 3608
//defalt
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
typedef pair<int, int> P_i;
typedef pair<double,double> P_d;
#define rep(i,n) for(int i=0;i<(n);++i)
#define alrep(i,j,n) for(int i=0;i<(n);++i)for(int j=i+1;j<(n);++j)
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
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; }
const int MOD=1e9+7;
const long long INF = 1LL << 60;
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}

signed main(){
  int N;
  cin >> N;
  int count=1;
  rep(i,N){
    int a;
    cin >> a;
    if(a==count){
      count++;
    }
    //cout << count << endl;
  }
  count--;
  if(count==0) cout << -1 << endl;
  else cout << N-count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
	int n, a, b, t;
	scanf("%d\n%d %d", &n,&a,&b);
	for (int i = 0; i < n-1; i++)
	{
		scanf("%d", &t);
		if (t > a)
		{
			a = t;
			scanf("%d", &b);
		}
		else
		{
			scanf("%d", &t);
		}
	}
	printf("%d", a + b);
	return 0;
}

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

using namespace std;

#define llong long long 
#define ii pair<int, int>
#define xx first
#define yy second
#define rep(i,n) for (int i = -1; ++i < n; )
#define rep1(i,n) for (int i = 0; i++ < n; )
#define len(x) ((int)x.size())

#define maxn 2020
int n, x, y;
llong a[maxn];

llong dp[maxn][2];
llong process(int pos, bool minimize) {
  //clog << pos << ' ' << linimize << endl;
  if (dp[pos][minimize] != -1) return dp[pos][minimize];
  llong ans = abs(a[pos - 1] - a[n]);
  for (int i = pos; i < n; ++i) {
    llong val = process(i + 1, !minimize);
    if (minimize) ans = min(ans, val);
    else ans = max(ans, val);
  }
  //clog << pos << ' ' << minimize << ' ' << ans << endl;
  return dp[pos][minimize] = ans;
}

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin >> n >> x >> y;
  rep1(i, n) cin >> a[i];
  a[0] = y;
  memset(dp, -1, sizeof(dp));
  cout << process(1, 0);

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {

    int A, B, T;
    cin >> A >> B >> T;

    int sum = 0;
    for (double i = (double) A; i < (double) T + 0.5; i += (double) A) {
        sum += B;
    }

    cout << sum << endl;
    return 0;

}

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

int n;
ll a[200005];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
	}
	sort(a,a+n);
	bool flag=true;
	for(int i=0;i+1<n;i++){
		if(a[i]==a[i+1]){
			flag=false;
		}
	}
	printf("%s\n",flag?"YES":"NO");
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);cout<<fixed<<setprecision(16);
#define ll long long int
#define ld long double
#define el '\n'
#define El '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < n; i++)
#define pll pair<ll, ll>
#define ml map<ll,ll>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << t<<" "; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << v.first << " " << v.second ; }

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)

      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}


ll kv;
ll t,n,x,y,h,k,z,p,q,w,r;
string s,s1,s2;
//vvl v;
//vl vis,d;

inline ld dis(pll a,pll b){
    return sqrt((a.ff-b.ff)*(a.ff-b.ff)+(a.ss-b.ss)*(a.ss-b.ss));
}

int main() {
    IOS;
    cin>>n;
    vpl v(n);vl a(n);
    fo(i,n)cin>>v[i].ff>>v[i].ss,a[i]=i+1;
    ld kv=0;
    do{
        fo(i,n-1)kv+=dis(v[a[i]-1],v[a[i+1]-1]);
    }while(next_permutation(all(a)));
    fo(i,n)kv/=i+1;
    cout<<kv<<el;
    return 0;
}



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


int main() {
    // N, M, X, Y
    int l;
    std::vector<int> v(4);

    for (int i=0; i<4 ; i++){
        std::cin >> l;
        v[i] = l;
    }

    //x[]
    int n = v[0];
    std::vector<int> x(n);

    for (int i=0; i<n ; i++){
        std::cin >> l;
        x[i] = l;
    }

    //y[]
    int m = v[1];
    std::vector<int> y(m);

    for (int i=0; i<m ; i++){
        std::cin >> l;
        y[i] = l;
    }

    std::sort(x.begin(),x.end(),std::greater<int>());
    std::sort(y.begin(),y.end());

    int max_x = x[0];
    int min_y = y[0];

    if (max_x < v[3] && min_y > v[2] && max_x < min_y){
        std::cout << "No War" << std::endl;
    }
    else {
        std::cout << "War" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
def comb(n, k):
    nCk = 1
    MOD = 10**9+7

    for i in range(n-k+1, n+1):
        nCk *= i
        nCk %= MOD

    for i in range(1, k+1):
        nCk *= pow(i, MOD-2, MOD)
        nCk %= MOD
    return nCk


n, a, b = map(int, input().split())
mod = 10**9+7
ans = pow(2, n, mod)-1-comb(n, a)-comb(n, b)
print(ans % mod)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
typedef long long ll;
const double PI = acos(-1);
using namespace std;

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

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

int main(void){
    ll A,B;cin>>A>>B;
    cout<<lcm(A,B)<<endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <cmath>
#include <bitset>

using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
  ll N, M;
  cin >> N >> M;
  
  vector<vector<ll>> G(N);
  
  rep(i,M){
    ll a, b;
    cin >> a >> b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }
    
  ll seen[200010];
  rep(i,N){
    seen[i]=-1;
  }
  
  queue<int> que;
  ll ans = 0;
  ll count = -1;
  ll tmp;
  
  rep(i,N){
    if(seen[i]==-1){
      //cout << seen[1] << endl;
      ans++;
      tmp = 1;
      seen[i] = 0;
	  que.push(i);
      
      while (!que.empty()) {
          int v = que.front(); // キューから先頭頂点を取り出す
          que.pop();

          // v から辿れる頂点をすべて調べる
          for (int nv : G[v]) {
              if (seen[nv] != -1) continue; // すでに発見済みの頂点は探索しない

              // 新たな白色頂点 nv について距離情報を更新してキューに追加する
              seen[nv] = seen[v] + 1;
              tmp++;
              que.push(nv);
          }
      }
      
      count = max(count, tmp);
    }
  }
  
  cout << count << endl;

  
}

Measured memory_bytes: 18172
#include<cstdio>
int main(void){
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++){
if(i%3==0)printf(" %d",i);
else if(i%10==3)printf(" %d",i);
else if((i/10)%10==3)printf(" %d",i);
else if((i/100)%10==3)printf(" %d",i);
else if((i/1000)%10==3)printf(" %d",i);
}
printf("\n");
return 0;
}

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


int main() {
    int e;
    while(cin >> e, e) {
        int ret = 1e9;
        for(int y=0; y*y<=e && y<=1000; ++y) {
            for(int z=0; z*z*z<=e-y*y && z<=100; ++z) {
                int x = e - y*y - z*z*z;
                ret = min(ret, x + y + z);
            }
        }
        cout << ret << endl;
    }
}


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

#define FOR(i,b,e) for (int i = (b); i <= (e); i++)
#define FORD(i,b,e) for (int i = (b); i >= (e); i--)
#define SIZE(c) ((int) (c).size())

#define pb push_back
#define st first
#define nd second

using namespace std;


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

typedef vector <int> VI;
typedef vector <ll> VL;
typedef vector <bool> VB;
typedef vector <pii> VP;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000000000000001LL;


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

    string s;
    int k;

    cin >> s >> k;

    int n = SIZE(s);

    vector <int> runs;

    int l = 0;
    while (l < n) {
        int r = l;
        while (r < n && s[r] == s[l]) r++;

        runs.pb(r - l);
        l = r;
    }

    long long ans = 0;

    if (SIZE(runs) == 1) {
        long long len = (long long) n * k;
        ans = len / 2;
    } else {
        long long sum = 0;
        for (int x : runs) {
            sum += x / 2;
        }

        ans = sum * k;

        if (s[0] == s[n-1] && runs[0] % 2 == runs.back() % 2) {
            ans += k - 1;
        }
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

int main()
{
    int a, b;
    cin >> a >> b;
    cerr << "a=" << a << " b=" << b << endl;
    cout << a * b << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<int,int>
#define push_back emplace_back
#define push emplace
#define insert emplace
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 10000000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
set<int>s;
int dp[100000];
int fun(int i,int n){
	if(i==n)return 1;
	if(s.find(i)!=s.end()||i>n)return 0;
	if(dp[i]!=-1)return dp[i];
	return dp[i]=(fun(i+1,n)+fun(i+2,n))%mod;
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,m;
	cin>>n>>m;
	while(m--){
		int x;
		cin>>x;
		s.insert(x);
	}
	memset(dp,-1,sizeof(dp));
	cout<<fun(0,n);
	return 0;

}

Measured memory_bytes: 5760
#include<stdio.h>

int main(void){
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	
	if(a<b){
		if(b<c){
			printf("Yes\n");
	}else{
		printf("No\n");
	}
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <string>
#include <map>
#include <iterator>
#include <set>
#include <queue>
#include <bitset>
#include <cassert>

using namespace std;

long long M = 1000000007;


int main() {
    int N;
    cin >> N;
    long long res = 0;
    vector<long long> vs;

    long long AA = 0;
    for (int i = 0; i < N; ++i) {
        long long A;
        cin >> A;
        vs.push_back(A);
        AA += A;
        AA %= M;
    }

    for (int i = 0; i < N - 1; ++i) {

        AA -= vs[i];
        if(AA < 0) {
            AA += M;
        }
        AA %= M;

        long long tmp = vs[i] * AA;
        tmp %= M;
        res += tmp;
        res %= M;
    }
    cout << res << endl;
}

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


int main(){
  string s,t;
  cin>>s>>t;
  int n = s.length(), m = t.length();
  int dp[n+1][m+1];
  for(int i = 0;i<=n;i++){
    dp[i][0] = 0;
  }

  for(int i = 0;i<=m;i++){
    dp[0][i] = 0;
  }

  for(int i = 1;i<=n;i++){
    for(int j = 1;j<=m;j++){
      if(s.at(i-1)==t.at(j-1)){
        dp[i][j] = dp[i-1][j-1]+1;
      }

      else{
        dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
      }
    }
  }

  int i = n,j = m;
  string ans = "";
  while(i>0&&j>0){
    if(s.at(i-1)==t.at(j-1)){
      ans = s.at(i-1)+ans;
      i--;
      j--;
    }

    else{
      if(dp[i-1][j]>dp[i][j-1]){
        i = i-1;
      }
      else{
        j = j-1;
      }
    }
  }

  cout<<ans;



}






Measured memory_bytes: 35456
def main():
    from math import gcd
    K = int(input())
 
    ans = 0
    for a in range(1, K + 1):
        for b in range(1, K + 1):
            for c in range(1, K + 1):
                ans += gcd(gcd(a, b), c)
 
    print(ans)
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 9032
n, A, B, C = (int(i) for i in input().split())
l = [int(input()) for i in range(n)]
a = []
b = []
c = []

def furiwake(x):
    global a
    global b
    global c
    a = []
    b = []
    c = []
    for i in range(1, n+1):
        if dig4(x, i) == 0:
            a.append(l[i-1])
        if dig4(x, i) == 1:
            b.append(l[i-1])
        if dig4(x, i) == 2:
            c.append(l[i-1])

def dig4(n, k):
    return (n%(4**k))//(4**(k-1))

def cost():
    costa = 10 * (len(a)-1) + abs(sum(a)-A)
    costb = 10 * (len(b)-1) + abs(sum(b)-B)
    costc = 10 * (len(c)-1) + abs(sum(c)-C)
    return costa+costb+costc

ans = 1000000000
for i in range(1, 4**8):
    furiwake(i)
    if(len(a)*len(b)*len(c)):
        ans = min(ans, cost())
print(ans)

Measured memory_bytes: 3064
//   __                    .__              ________ .________ ________   ______  
//  |  | __  ____    ______|  |__   __ __  /  _____/ |   ____//   __   \ /  __  \ 
//  |  |/ /_/ __ \  /  ___/|  |  \ |  |  \/   __  \  |____  \ \____    / >      < 
//  |    < \  ___/  \___ \ |   Y  \|  |  /\  |__\  \ /       \   /    / /   --   \
//  |__|_ \ \___  >/____  >|___|  /|____/  \_____  //______  /  /____/  \______  /
//       \/     \/      \/      \/               \/        \/                  \/ 

#include<bits/stdc++.h>
#define range 100005
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

int dp[200000];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
		int output = 0;
	for(int i=n-2;i>=0;i--){
		if(a[i]>=a[i+1])
			dp[i] = dp[i+1]+1;
		else dp[i] = 0;
		output = max(output,dp[i]);
	}
	cout<<output;
	return 0;
}


Measured memory_bytes: 1024