akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;

const int ih[5] = { 0,1,0,-1,0 };
const int iw[5] = { 0,0,1,0,-1 };
int h, w,cnt=0;
bool dfs(int nh,int nw,vector<string> grid, vector<vector<bool>> & painted) {
	rep(i,5) {
		int dh = ih[i], dw = iw[i];
			if (nh + dh < 0 || nh + dh >= h || nw + dw < 0 || nw + dw >= w)continue;
			if (grid[nh + dh][nw + dw] == '.')continue;
			if (painted[nh + dh][nw + dw])continue;
			painted[nh + dh][nw + dw] = true;;
			cnt++;
			if(dfs(nh + dh, nw + dw, grid, painted) && cnt == 1) return false;
		}
	return true;
}

int main() {
	string ans = "Yes";
	cin >> h >> w;
	vector<string>grid(h);
	vector<vector<bool>>painted(h, vector<bool>(w, false));
	rep(i, h)cin >> grid[i];
	rep(i, h) {
		rep(j, w) {
			if (painted[i][j])continue;
			if (grid[i][j] == '.')continue;
			cnt = 0;
			dfs(i, j, grid, painted);
			if (cnt == 1) {
				ans = "No";
				break;
			}
			//if (!dfs(i, j, grid, painted)) {
			//	ans = "No";
			//	break;
			//}
		}
		if (cnt == 1)break;
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
  long int i,j,n,k;
  cin>>n>>k;
  vector<long int>h(n);
  for(i=0;i<n;i++)
    cin>>h[i];
  vector<long int>v(n,0);
  v[1]=abs(h[0]-h[1]);
  for(i=2;i<n;i++)
  {
   v[i]=INT_MAX;
   for(j=1;j<=k;j++)
   {
    if(i-j>=0)
     v[i]=min(v[i],abs(h[i]-h[i-j])+v[i-j]);
    else
     break;
   }
  }
  cout<<v[n-1]<<"\n";
 return 0;
}


Measured memory_bytes: 4820
# print('input >>')
N = input()
As = list(map(int,(input().split())))
MOD = 10**9 + 7

As_sum = [As[0]]

for i in range(1, len(As)):
    As_sum.append((As_sum[-1]+As[i]) % MOD)

ans = 0
for i in range(len(As)-1, 0, -1):
    ans += As[i] * As_sum[i-1]
    ans %= MOD

# print('-----output-----')
print(ans % MOD)

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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

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

//---------------------------------------------------------------
// 解説を読んだあと
//---------------------------------------------------------------
int A, B, C;

signed main(){
	cin >> A >> B >> C;
	
	int t = A + B + C;
	int m = max(A, max(B, C));
	if((t % 2) != (m % 2)) {
		m = m + 1;
	}
	int ans = (m * 3 - t) / 2;
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    long long N, A, B; cin >> N >> A >> B;
    if((B-A)%2 == 0){
        cout << (B-A)/2 << endl;
    } else {
        cout << min(A-1, N-B)+(B-A+1)/2 << endl;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define VAR(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    VAR(string, s);
    string ans = "";

    for (char ch : s) {
        if (ch == 'B') {
            if (ans.size()) ans.pop_back();
        } else {
            ans.push_back(ch);
        }
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    vector <double> dp(n+1, 0);
    dp[0] = 1;
    REP(_, n){
        double p; cin >> p;
        for(int i=n-1; i>=0; i--){
            dp[i+1] += dp[i] * p;
            dp[i] = dp[i] * (1-p);
        }
    }
    double ans = 0;
    for(int i=n/2+1; i<n+1; i++){
        ans += dp[i];
    }
    printf("%0.12f", ans);
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL
  
typedef struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
}* Node;

void treeDelete(Node);
void insert(int);
void inorder(Node);
void preorder(Node);

Node root;

Node treeMinimum(Node x){
  
}

Node treeMaximum(Node x){

}

Node treeSearch(Node u, int k){

}

Node treeSuccessor(Node x){

}


int main(){
  int n, i, x;
  char elm[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", elm);
    if ( elm[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( elm[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( elm[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( elm[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

}

void insert(int key){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = key;
  z->left = NIL;
  z->right = NIL;
  
  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x = x->left;// 左の子へ移動
    }
    else x = x->right;// 右の子へ移動
  }
  z->parent = y;

  if(y==NIL){// T が空の場合
    root=z;
  }
  
  else if(z->key < y->key){// z を y の左の子にする
    y->left = z;
  }
  
  else y->right = z;// z を y の右の子にする


}

void inorder(Node u){
  if(u->left!=NIL)inorder(u->left);
  printf(" %d",u->key);
  if(u->right!=NIL)inorder(u->right);
}

void preorder(Node u){
  printf(" %d",u->key);
  if(u->left!=NIL)preorder(u->left);
  if(u->right!=NIL)preorder(u->right);
}





Measured memory_bytes: 25160
import java.util.*;
class Main{
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int x = s.nextInt();
        int y = x % 10;
        String z = "hon";
        if(y==3){
            z = "bon";
        }else if(y==0|y==1|y==6|y==8){
            z = "pon";
        }
        System.out.println(z);        
    }
}

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

using namespace std;
const int N = 1e5 + 1;

typedef int ll;

ll n, c, k, a[N], t, cnt = 1, ans = 1;

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

    for(int i = 1; i <= n; i ++)
        scanf("%d", &a[i]);

    sort(a + 1, a + n + 1);

    t = a[1];

    for(int i = 2; i <= n; i ++)
    {
        cnt ++;
        if(a[i] > t + k || cnt > c)
        {
            t = a[i];
            cnt = 1;
            ans ++;
        }
    }

    printf("%d\n", ans);
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    string s,t,ans;
    cin >> n >> s >> t;
    for( int i = 0; i < n; i++ )
    {
        ans.push_back( s.at(i) );
        ans.push_back( t.at(i) );
    }
    cout << ans << endl;
    return 0;
}



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

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn lcm(a: i64, b: i64) -> i64 {
    a * (b / gcd(a, b))
}

fn main() {
    let n = scan!(i64);
    let vs = scan!(i64;n);

    let mut ans = 1;
    for v in vs.iter() {
        ans = lcm(ans, *v);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

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

    int five_h = 0, five = 0;
    if (x >= 500) {
        five_h = x / 500;
        x %= 500;
    }
    five = x / 5;

    cout << five_h * 1000 + five * 5 << endl;

    return 0;
}


Measured memory_bytes: 256
N , M = map(int,input().split())
L = [0 for _ in range(10**5+10)]

for i in range(M):
    x,y = map(int,input().split())
    L[x] += 1
    L[y+1] -= 1
from itertools import accumulate
accumulated =  list(accumulate(L))
cnt = 0
for x in accumulated:
    if x == M:
        cnt += 1
print(cnt)


Measured memory_bytes: 8100
import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )
import Data.List ( sortBy )

getParm :: IO [Int]
getParm = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  n <- readLn :: IO Int
  ass <- getParm
  print $ g n ass

sort' :: [Int] -> [Int]
sort' = sortBy (flip compare)

f :: Int -> [Int] -> [Int]
f n ass = take n $ h ass'
  where
    h :: [Int] -> [Int]
    h (a:b:bs) = b: h bs

    ass' = sort' ass

g n = sum . f n

Measured memory_bytes: 51580
import itertools
import math

n, d = map(int, input().split())
all_point = []
count = 0

for i in range(n):
    point = list(map(int, input().split()))
    all_point.append(point)

all_comb = list(itertools.combinations_with_replacement(all_point, 2))
for comb in all_comb:
    if comb[0] != comb[1]:
        distance = math.sqrt(sum([(x - y)**2 for x, y in zip(comb[0], comb[1])]))
        if distance == int(distance):
            count = count + 1

print(count)

Measured memory_bytes: 3064
s =int(input())
cnt = 0
f = 0
a=[]
a.append(s)
while (f == 0):
    if a[cnt]%2 == 0:
        n = int(a[cnt]/2)
        if n in  a:
            ans = a.index(n) + 1
            f = 1
        a.append(n)
    else:
        n = int(3*a[cnt]+1)
        if n in a:
            f = 1
            ans = a.index(n) + 1
        a.append(n)
    cnt += 1
print(cnt+1)

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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;

int T[maxn];

int main() {
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin>>n;
    ll SUM=0LL;

    f1(i,n){
        cin >> T[i];
        SUM+=T[i];
    }

    int m;
    cin >> m;

    f1(i,m){
        int p,x;
        cin >> p >> x;

        cout << (SUM+x)-T[p] << endl;
    }


    return 0;
}



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

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int n, k;
    scan(n, k);

    auto a = new int[][](2*k + 1, 2*k + 1);

    foreach (i ; 0 .. n) {
        int xi, yi; char ci;
        scan(xi, yi, ci);
        if (ci == 'W') yi += k;
        xi %= 2*k;
        yi %= 2*k;
        a[xi + 1][yi + 1]++;
    }

    debug {
        //writefln("%(%s\n%)", a);
        writeln;
    }

    foreach (i ; 1 .. 2*k + 1) {
        foreach (j ; 1 .. 2*k + 1) {
            a[i][j] += a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1];
        }
    }

    debug {
        //writefln("%(%s\n%)", a);
    }

    int query(int xs, int xt, int ys, int yt) {
        if (xt == 0) xt = 2*k;
        if (yt == 0) yt = 2*k;
        int res;

        if (xs < xt && ys < yt) {
            res = a[xt][yt] - a[xs][yt] - a[xt][ys] + a[xs][ys];
        }
        else if (xs >= xt && ys < yt) {
            res = a[xt][yt] - a[xt][ys];
            res += a[2*k][yt] - a[xs][yt] - a[2*k][ys] + a[xs][ys];
        }
        else if (xs < xt && ys >= yt) {
            res = a[xt][yt] - a[xs][yt];
            res += a[xt][2*k] - a[xt][ys] - a[xs][2*k] + a[xs][ys];
        }
        else {
            res = a[xt][yt];
            res += a[xt][2*k] - a[xt][ys];
            res += a[2*k][yt] - a[xs][yt];
            res += a[2*k][2*k] - a[xs][2*k] - a[2*k][ys] + a[xs][ys];
        }

        return res;
    }

    int ans;

    foreach (x ; 0 .. k) {
        foreach (y ; 0 .. k) {
            int t = query(x, x + k, y, y + k);
            t += query(x + k, x, y + k, y);
            debug {
                writeln("t: ", t);
            }
            ans = max(ans, t, n - t);
        }
    }

    writeln(ans);
}








void yes(bool b) {writeln(b ? "Yes" : "No");}
void YES(bool b) {writeln(b ? "YES" : "NO");}
T[] readArr(T)() {return readln.split.to!(T[]);}

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

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

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


Measured memory_bytes: 18940
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,cnt = 0;
    cin >> a >> b >> c;
    while(a != b || b != a || c != a){
        if(a%2 || b%2 || c%2){
            cout << cnt << endl;
            return 0;
        }
        cnt++;
        int ta,tb,tc;
        ta = b/2 + c/2;
        tb = a/2 + c/2;
        tc = a/2 + b/2;
        a = ta; b = tb; c = tc;
    }
    cout << (a%2 || b%2 || c%2?0:-1) << endl;
    return 0;
}

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

char set_grade(int a, int b, int c){
    if(a == -1 or b == -1) return 'F';
    else if(a + b >= 80) return 'A';
    else if(a + b >= 65) return 'B';
    else if(a + b >= 50) return 'C';
    else if(a + b >= 30){
        if(c >= 50) return 'C';
        else return 'D';
    } else return 'F';
}

int main(){
    
    while(true){
        int a,b,c;
        cin >> a >> b >> c;
        
        if(a == -1 and b == -1 and c == -1) break;
        cout << set_grade(a, b, c) << endl;
    }
}



Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define prique priority_queue
#define umap unordered_map
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.1415926
#define coutdb cout<<fixed<<setprecision(15)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef int_fast64_t ll;
#define int int_fast64_t

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int N, K; string S; cin >> N >> K >> S;
  int ans = 0;
  REP(i, N-1){
    ans += S[i]==S[i+1];
  }
  cout << min(N-1, ans+2*K) << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll sol[101][100001]={0};
int main()
{
  ll n,c,i,j;
  cin>>n>>c;
  ll w[n];
  ll v[n];
  for(i=0;i<n;i++)
  {
    cin>>w[i];
    cin>>v[i];
  }
  for(i=1;i<100001;i++)
    sol[0][i]=1e18;
  for(i=1;i<=n;i++)
  {
    for(j=1;j<100001;j++)
    {
    sol[i][j]=1e18;
	if(v[i-1]>j)
      sol[i][j]=sol[i-1][j];
    else if(v[i-1]<=j)
      sol[i][j]=min(sol[i-1][j],sol[i-1][j-v[i-1]]+w[i-1]);
    }
  }
  
  for(i=100000;i>=0;i--)
    if(sol[n][i]<=c)
    {
      cout<<i<<endl;
      return 0;
    }
}
  

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;

void run_case()
{
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double angle1 = h * 30.0 + m * 0.5;
    double angle2 = m * 6.0;
    double angle = min(abs(angle1 - angle2), 360 - abs(angle1 - angle2));
    //DBG(angle);
    double t = angle * PI * 1.0 / 180;
    //DBG(cos(t));
    double c = sqrt(a * a * 1.0 + b * b * 1.0 - 2 * a * b * cos(t));
    cout << c << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(15);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 4028
import math
l = int(input())
n = math.floor(math.log2(l)) + 1
e = []
for v in range(n-1):
  e.append([v+1, v+2, 0])
  e.append([v+1, v+2, 2**v])
  if (l>>v)&1:
    e.append([v+1, n, l-2**v])
    l -= 2**v
print(n, len(e))
for x in e:
  print(" ".join(map(str, x)))

Measured memory_bytes: 3064
n, k = gets().split(' ').map(&:to_i)

ret = Rational(0, 1)

# 出た目が k 未満のとき
(1 .. [n, k - 1].min).each{|i|
	ret += Rational(1, n) * Rational(1, 2 ** Math.log2(k.to_f / i).ceil)
}

# 出た目が k 以上のとき
ret += Rational(n - k + 1, n) if k <= n

puts ret.to_f


Measured memory_bytes: 3836
/*
	Name:
	Author: xiaruize
	Date:
*/

#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int a,b;
	cin>>a>>b;
	int k=1;
	while(1)
	{
	//	cout<<floor(k*0.08)<<' '<<floor(k/10)<<endl;
		if(floor(k*0.08)==a&&floor(k/10)==b)
		{
			cout<<k<<endl;
			return 0;
		}
		k++;
		if(k>=10000000)
		{
			cout<<"-1"<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
A=list(map(int,input().split()))
a=A[:]
for _ in range(K):
    t=[0]*(N+1)
    for i in range(N):
        ti=a[i]
        t[max(0,i-ti)]+=1
        t[min(N,i+ti+1)]-=1
    a=[]
    for i in range(N):
        a.append(t[i])
        if i>0:
            a[i]+=a[i-1]
    if min(a)==N:
        break
print(*a)

Measured memory_bytes: 171536
import math

H,N = map(int,input().split())
ARR = [list(map(int,input().split())) for i in range(N)]
def calculate(h, n, arr):

    brr = [math.inf] * (h + 1)

    brr[0] = 0
    for i in range(h + 1):
        for j in range(n):
            damage = arr[j][0]
            cost = arr[j][1]

            nextDamage = i + damage

            if nextDamage > h:
                nextDamage = h

            nextCost = min(brr[nextDamage], brr[i] + cost)
            brr[nextDamage] = nextCost

    print(brr[-1])

calculate(H, N, ARR)


Measured memory_bytes: 68896
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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


    ll Q,H,S,D,N;
    cin >> Q >> H >> S >> D >> N;
    if(Q * 2 < H){
        H = Q * 2;
    }
    if(H * 2 < S){
        S = H * 2;
    }
    if(S * 2 < D){
        D = S * 2;
    }
    ll n = 4 * N;
    ll ans = 0ll;
    ans += (n / 8) * D;
    n -= (n / 8) * 8;

    ans += (n / 4) * S;
    n -= (n / 4) * 4;

    ans += (n / 2) * H;
    n -= (n / 2) * 2;

    ans += n * Q;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }
    val a = readLine()!!.split(' ').map { it.toInt() }

    repeat(n) {
        if (it >= k) {
            if (a[it-k] < a[it]) println("Yes")
            else println("No")
        }
    }
}

Measured memory_bytes: 69856
// sutaz.cpp : Defines the entry point for the console application.
//

//#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;

int main()
{
	string s;
	cin >> s;
	int maxi = 0;
	int pocet = 0;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'R')
		{
			pocet = 0;
			int a=i;
			while (s[a] == 'R')
			{
				a++;
				pocet++;
			}
			i = i + a;
			if (pocet > maxi)
			{
				maxi = pocet;
			}
		}
	}
	cout << maxi << endl;
    return 0;
}



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

using namespace std;

#define ff              first
#define ss              second
#define ll             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output3.txt", "w", stdout);
#endif
}
vector<int> vec;
void se(int n) 
{  
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        {  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    }  
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          vec.push_back(p);
  } 
  
int32_t main()
{
	c_p_c();
		ll int n,m;
		cin>>n>>m;
		vector<int> adj[n+1];
		for(int i=0;i<m;i++)
		{
			int a,b;	cin>>a>>b;
			adj[a].push_back(b);
			adj[b].push_back(a);	
		}
		queue<int> q;
		int par[n+1]={0};
		q.push(1);
		while(!q.empty())
		{
			int top=q.front();
			q.pop();
			for(auto i:adj[top])
			{
				if(par[i]==0)
					{
						par[i]=top;
						q.push(i);
				}
			}
		}
		int flag=0;
		for(int i=2;i<=n;i++)
		{
			if(par[i]==0)
				flag=1;
		}
		if(flag==1)
			cout<<"No"<<"\n";
		else
		{
			cout<<"Yes"<<"\n";
			for(int i=2;i<=n;i++)
				cout<<par[i]<<"\n";
		}
	}



Measured memory_bytes: 10476
N = int(input())
l = [list(map(int, input().split())) for _ in range(N)]

for x, y, h in l:
    if h == 0:
        continue
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            H = abs(Cx-x) + abs(Cy-y) + h
            if all([hh == max(H - abs(Cx-xx) - abs(Cy-yy), 0) for xx, yy, hh in l]):
                print(Cx, Cy, H)
                exit()

Measured memory_bytes: 3064
#coding:utf-8
import sys,os
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7
    S = input()
    Slist = [S]
    Q = II()
    Slist = ['']*Q+Slist+['']*Q
    left = Q-1
    right = Q+1
    r = False
    for _ in range(Q):
        query = input().split()
        if query[0] == '1':
            r ^= True
        else:
            if query[1] == '1':
                    if r:
                        # S = ''.join([S,query[2]])
                        Slist[right] = query[2]
                        right += 1

                    else:
                        # S = ''.join([query[2],S])
                        Slist[left] = query[2]
                        left -=1
            else:
                if r:
                    Slist[left] = query[2]
                    left -=1
                else:
                    # S = ''.join([S,query[2]])
                    Slist[right] = query[2]
                    right += 1
    # print(S[::-1] if r else S)
    if r:
        Slist[Q] = Slist[Q][::-1]

    print(''.join(Slist[::-1]) if r else ''.join(Slist))
                



    

if __name__ == '__main__':
    main()

Measured memory_bytes: 56732
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#define mod 1000000009
#define ll long long
using namespace std;
int main() {
	int a, b, c;
	vector<int>v;
	cin >> a >> b >> c;
	v.push_back(a);v.push_back(b);v.push_back(c);
	sort(v.begin(), v.end());
	cout << (v[2] * 10 + v[1] + v[0]);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x,kyu;
    scanf("%d", &x);
    if (x >= 400 && x <= 599)
        kyu = 8;
    if (x >= 600 && x <= 799)
        kyu = 7;
    if (x >= 800 && x <= 999)
        kyu = 6;
    if (x >= 1000 && x <= 1199)
        kyu = 5;
    if (x >= 1200 && x <= 1399)
        kyu = 4;
    if (x >= 1400 && x <= 1599)
        kyu = 3;
    if (x >= 1600 && x <= 1799)
        kyu = 2;
    if (x >= 1800 && x <= 1999)
        kyu = 1;
    printf("%d\n",kyu);
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define fi first
#define se second

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

int main() {
    while (1){
        int h,w;
        cin>>w>>h;
        if (h==0)return 0;
        int g[h][w][h][w];
        memset(g,0,sizeof(g));
        rep(i,2*h-1){
            if (i%2==0){
                rep(j,w-1){
                    int b;
                    cin>>b;
                    if(b==0){
                        g[i/2][j][i/2][j+1]=1;
                        g[i/2][j+1][i/2][j]=1;
                    }
                }
            }
            else{
                rep(j,w){
                    int b;
                    cin>>b;
                    if (b==0){
                        g[i/2][j][i/2+1][j]=1;
                        g[i/2+1][j][i/2][j]=1;
                    }
                }
            }
        }
        queue<pair<int,int>> q;
        vvi d(h,vi(w,1000));
        d[0][0]=0;
        q.push({0,0});
        vector<pair<int,int>> move;
        move.push_back(make_pair(1,0));
        move.push_back(make_pair(-1,0));
        move.push_back(make_pair(0,1));
        move.push_back(make_pair(0,-1));
        while(q.size()!=0){
            auto p=q.front();
            q.pop();
            int x1=p.fi,y1=p.se;
            for (auto p1:move){
                int x=x1+p1.fi,y=y1+p1.se;
                if (x<0||y<0||x>=h||y>=w)continue;
                else if (g[x1][y1][x][y]==0)continue;
                else if (d[x][y]<=d[x1][y1]+1)continue;
                else{
                    d[x][y]=d[x1][y1]+1;
                    q.push({x,y});
                }
            }
        }
        if (d[h-1][w-1]==1000)cout<<0<<endl;
        else cout<<d[h-1][w-1]+1<<endl;
    }

    return 0;
}


Measured memory_bytes: 6312
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define clr(a,x) memset(a,x,sizeof(a))
#define SZ(x) ((int)(x).size())
#define lson rt<<1
#define rson rt<<1|1
#define pb push_back
#define fi first
#define se second
#define what_is(x) cerr<<#x<<" "<<x<<endl;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
template <typename T>
inline void _read(T& x){
    cin>>x;
}
void R(){}
template <typename T,typename... U>
void R(T&head,U&... tail){
    _read(head);
    R(tail...);
}

template <typename T>
inline void _write(const T& x){
    cout<<x<<' ';
}
void W(){cout<<endl;}
template <typename T,typename... U>
void W(const T&head,const U&... tail){
    _write(head);
    W(tail...);
}
template<typename T>
void debug(vector<T> V){
    for(auto x:V){
        cout<<x<<" ";
    }
    cout<<endl;
}
void go();
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //cout<<fixed<<setprecision(8);
    go();
    return 0;
}
/*************************************/

void go(){
    string str;
    R(str);
    if(str[0]==str[1]||str[1]==str[2]||str[2]==str[3]){
        W("Bad");
    }else{
        W("Good");
    }
}


Measured memory_bytes: 256
# Dictionary

def main():
  n = int(input())
  commands= [input().split() for _ in range(n)]
  dictionary = {}
  
  for command in commands:
    if command[0] == 'insert':
      dictionary[command[1]] = True
    else: # find
      if command[1] in dictionary:
        print('yes')
      else:
        print('no')

main()


Measured memory_bytes: 303800
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <iostream>

using namespace std;

struct edge
{
	int v,nxt,w;
}e[2050];

int head[1050],ecnt;

void adde(int u,int v,int w)
{
	e[++ ecnt].v = v;
	e[ecnt].nxt = head[u];
	e[ecnt].w = w;
	head[u] = ecnt;
}

int fa[1050],fv[1050],dep[1050];

void dfs(int pos,int lst)
{
	for(int i = head[pos];i;i = e[i].nxt)
	{
		int v = e[i].v;
		if(v != lst)
		{
			fa[v] = pos,fv[v] = e[i].w,dep[v] = dep[pos] + 1;
			dfs(v,pos);
		}
	}
}

int query(int u,int v)
{
	int as = 0;
	while(dep[u] > dep[v]) as = max(as,fv[u]),u = fa[u];
	while(dep[v] > dep[u]) as = max(as,fv[v]),v = fa[v];
	while(u != v) as = max(as,max(fv[u],fv[v])),u = fa[u],v = fa[v];
	return as;
}

struct ed
{
	int u,v,w;
	bool operator < (const ed &a) const
	{
		return w < a.w;
	}
}E[2050];

int flg[2060];
int par[1050];

int find_fa(int pos)
{
	return par[pos] == pos ? pos : par[pos] = find_fa(par[pos]);
}

int n,m;
const int mod = 1000000007;
long long qpow(long long base,int tms)
{
	long long tmp = 1;
	while(tms)
	{
		if(tms & 1) tmp = tmp * base % mod;
		base = base * base % mod;
		tms >>= 1;
	}
	return tmp;
}

int main()
{
	scanf("%d%d",&n,&m);
	long long X; scanf("%lld",&X);
	for(int i = 1;i <= m; ++ i)
		scanf("%d%d%d",&E[i].u,&E[i].v,&E[i].w);
	sort(E + 1,E + 1 + m);
	long long M = 0;
	for(int i = 1;i <= n; ++ i) par[i] = i;
	for(int i = 1;i <= m; ++ i)
	{
		int u = E[i].u,v = E[i].v;
		u = find_fa(u),v = find_fa(v);
		if(u != v)
		{
			flg[i] = 1;
			par[u] = v;
			adde(E[i].u,E[i].v,E[i].w);
			adde(E[i].v,E[i].u,E[i].w);
			M += E[i].w;
		}
	}
	dfs(1,0);
	int equ = 0,upp = 0;
	long long S = X - M;
	if(S < 0) printf("0\n");
	else
	{
		for(int i = 1;i <= m; ++ i)
		{
			if(!flg[i])
			{
				long long del = E[i].w - query(E[i].u,E[i].v);
				if(del > S) upp ++;
				else if(del == S) equ ++;
			}
		}
		long long ans = 2ll * (qpow(2,equ) - 1) % mod * qpow(2,upp) % mod;
		if(!S) ans += (qpow(2,n - 1) - 2) * qpow(2,m - n + 1) % mod,ans %= mod;
		ans = (ans + mod) % mod;
		printf("%lld\n",ans);
	}
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.Exception;
import java.lang.String;
import java.lang.System;

public class Main {
    public static void main(String[] a) throws Exception {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        long num[] = new long[2];
        long gcd, lcm;
        String numStr[] = new String[2];
        String str;

        while((str = r.readLine()) != null) {
            numStr = str.split(" ");
            for(int i = 0; i < numStr.length; i++) {
                num[i] = Long.parseLong(numStr[i]);
            }
            gcd = getGCD(num[0], num[1]);
            lcm = getLCM(num[0], num[1]);
            System.out.printf("%d %d\n", gcd, lcm);
        }
    }

    // a, bの最大公約数を求める
    private static long getGCD(long a, long b) {
        if(a > b) {
            long tmp;
            tmp = a;
            a = b;
            b = tmp;
        }

        while(a != 0) {
            long tmp = a;
            a = b%a;
            b = tmp;
        }

        return b;
    }

    // a, bの最小公倍数を求める
    private static long getLCM(long a, long b) {
        return (a * b)/getGCD(a, b);
    }
}

Measured memory_bytes: 16984
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
//#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    string S;
    cin >> S;
    int N = S.length();
    int W = 0;
    for (const char c : S)
    {
        if (c == 'o')
        {
            ++W;
        }
    }

    if (15 - N + W >= 8)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int b[100001];
int main(){
    int n;
    cin>>n;
    int i,x,y=0,z;
    for(i=0;i<n-1;i++){
        cin>>x;
        y+=x*2;
        if(i!=0){
            if(x<z)
            y-=z;
            else y-=x;
        }
        z=x;
    }
    cout<<y<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define REVERSED(v) reverse( ALL(v) )
#define YESNO(x) cout << ( x ? "YES" : "NO" ) << endl
using namespace std;

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

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

    REVERSED(S);
    REP(i,4) REVERSED(divide[i]);

    bool can = true;
    for (int i = 0; i < S.size(); ) {
        can = false;
        REP(j,4) {
            string d = divide[j];
            if ( S.substr(i, d.size()) == d ) {
                can = true;
                i += d.size();
            }
        }
        if (!can) {
            break;
        }
    }

    YESNO(can);
}

Measured memory_bytes: 512
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '1') {
                count++;
            }
        }
        System.out.println(count);
    }

}

Measured memory_bytes: 23252
#include <iostream>
#include <cstdio>

struct Card {
    int number;
    char simbol;
};

Card C[100000];
Card L[100000/2 + 3];
Card R[100000/2 + 3];

void Merge(Card *C, int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;

    for (int i = 0; i < n1; i++) {
        L[i] = C[left + i];
    }
    for (int i = 0; i < n2; i++) {
        R[i] = C[mid + i];
    }

    L[n1].number = 1000000001;
    R[n2].number = 1000000001;

    int i = 0, j = 0;
    for (int k = left; k < right; k++) {
        if (L[i].number <= R[j].number) {
            C[k] = L[i];
            i++;
        } else {
            C[k] = R[j];
            j++;
        }
    }
}

void MergeSort(Card *C, int left, int right)
{
    if (left + 1 < right) {
        int mid = (left + right) / 2 ;
        MergeSort(C, left, mid);
        MergeSort(C, mid, right);
        Merge(C, left, mid, right);
    }
}

int Partition(Card *C, int p, int r)
{
    int x = C[r].number;
    int i = p - 1;

    for (int j = p; j < r; j++) {
        if (C[j].number <= x) {
            i += 1;
            // swap
            Card val_i = C[i];
            C[i] = C[j];
            C[j] = val_i;
        }
    }
    i += 1;
    // swap
    Card val_i = C[i];
    C[i] = C[r];
    C[r] = val_i;
    return i;
}

void QuickSort(Card *C, int p, int r)
{
    if (p < r) {
        int q = Partition(C, p, r);
        QuickSort(C, p, q-1);
        QuickSort(C, q+1, r);
    }
}

int main(int argc, char *argv[])
{
    int n;
    char S[10];
    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf("%s", S);
        scanf("%d", &C[i].number);
        C[i].simbol = S[0];
    }

    Card C_cmp[n];
    for (int i = 0; i < n; i++) {
        C_cmp[i] = C[i];
    }

    QuickSort(C, 0, n-1);
    MergeSort(C_cmp, 0, n);

    bool stable = true;
    for (int i = 0; i < n; i++) {
        if (C[i].simbol != C_cmp[i].simbol) {
            stable = false;
        }
    }

    if (stable) std::cout << "Stable" << std::endl;
    else std::cout << "Not stable" << std::endl;

    for (int i = 0; i < n; i++) {
        std::cout << C[i].simbol << " " << C[i].number << std::endl;
    }
}


Measured memory_bytes: 5472
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<ctime>
#include<iostream>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
#include<fstream>
#include<complex>
#include<algorithm>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define ll long long
#define int long long 
using namespace std;
const int INF = 0x3f3f3f3f;
const int mod=1e9+7;
signed main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int n,m;
	cin>>n>>m;
	int res=0;
	for(int i=m;i<=n+1;i++){
		res=(res+i*(n-(i-1))+1)%mod;
		//cout<<res<<" "<<endl;
	}
	cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3656
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
int main(){
  mint dp[100010][15];
  int i,j,l;
  string s;
  cin >> s;
  for(i=0;i<s.size();i++){
    for(j=0;j<13;j++){
      dp[i][j]=0;
    }
  }
  if(s[0]=='?'){
    for(i=0;i<10;i++){
      dp[0][i]=1;
    }
  }
  else{
    dp[0][s[0]-'0']=1;
  }
  for(i=1;i<s.size();i++){
    if(s[i]=='?'){
      for(j=0;j<13;j++){
        for(l=0;l<10;l++){
          dp[i][(10*j+l)%13]+=dp[i-1][j];
        }
      }
    }
    else{
      int a=s[i]-'0';
      for(j=0;j<13;j++){
        dp[i][(10*j+a)%13]+=dp[i-1][j];
      }
    }
  }
  printf("%lld\n",dp[s.size()-1][5]);
  return 0;
}

Measured memory_bytes: 12160
MOD=10**9+7
cnt=0; #sum=0
#h=Hash.new(0)

def gs(): return input()
def gi(): return int(input())
def gsmi(): return [int(n) for n in input().split()]
# min,max,sum,sorted
def desc(ar): return sorted(ar,reverse=True)
def printend(s): print(s);import sys;sys.exit()
###
a,b=gsmi()
diff=b-a
l = sum(range(1,diff-1+1))
print(l-a)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b / gcd(a,b);}

int main() {
    int x,y;
    cin >> x >> y;
    vector<int> v = {300000, 200000, 100000};
    if (x == 1 && y == 1) {
        cout << 1000000 << "\n";
    } else {
        cout << v[x-1]+v[y-1] << "\n";
    }

}


Measured memory_bytes: 256