akhauriyash/Code-Regression huggingface dataset:
import static java.lang.Math.abs;
import static java.lang.Math.min;

import java.util.Scanner;

public class Main{
	static int counter;
	static int a;
	static int b;
	static int c;
	static int[] bamboos;

	public static void main(String[] args) {
		final Scanner scanner = new Scanner(System.in);
		counter = scanner.nextInt();
		a = scanner.nextInt();
		b = scanner.nextInt();
		c = scanner.nextInt();

		bamboos = new int[counter];
		for (int i = 0; i < counter; i++) {
			bamboos[i] = scanner.nextInt();
		}

		scanner.close();
		System.out.println(result(0, 0, 0, 0));
	}

	public static int result(int index, int aValue, int bValue, int cValue) {
		if (index == counter) {
			if (aValue == 0 || bValue == 0 || cValue == 0) {
				return 1000000000;
			}
			return abs(a - aValue) + abs(bValue - b) + abs(cValue - c) - 30;
		}

		final int ret1 = result(index + 1, aValue, bValue, cValue);
		final int ret2 = result(index + 1, aValue + bamboos[index], bValue, cValue) + 10;
		final int ret3 = result(index + 1, aValue, bValue + bamboos[index], cValue) + 10;
		final int ret4 = result(index + 1, aValue, bValue, cValue + bamboos[index]) + 10;

		return min(min(ret1, ret2), min(ret3, ret4));
	}
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
#define LL long long int
const LL INF = 1e18;
const int N = 3 * 1e5 + 5;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	long double x, ans = 0.0;
	int n;
	cin >> n;
	string s;
	while(n--) {
		cin >> x;
		cin >> s;
		if (s == "JPY") ans += x;
		else ans += 380000.0 * x;
	}
	cout << fixed << setprecision(10) << ans << '\n';

	return 0;
}


Measured memory_bytes: 256
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!size_t;
  auto si = readln.split.to!(int[]);
  auto q = readln.chomp.to!size_t;
  auto ti = readln.split.to!(int[]);
  writeln(ti.count!(t => si.assumeSorted.contains(t)));
}

Measured memory_bytes: 6252
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 200005;
const int mod = 1000000007;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n;
  cin>>n;
  int cur = 0;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    if(x==cur+1){
      cur++;
    }
  }
  if(!cur)cout<<-1<<endl;
  else cout<<n-cur<<endl;
  return 0;
}

Measured memory_bytes: 384
n, k, l = map(int, input().split())
from collections import defaultdict

class UnionFind( ):
    def __init__(self, N):
        self.rank = [0] * N
        self.par = [i for i in range(N)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] > self.rank[y]:
            self.par[y] = x
        else:
            self.par[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)


uf1 = UnionFind(n)
uf2 = UnionFind(n)

for i in range(k):
    p, q = map(int, input().split())
    uf1.unite(p - 1, q - 1)


for i in range(l):
    r, s = map(int, input().split())
    uf2.unite(r - 1, s - 1)

pair = defaultdict(int)
for i in range(n):
    a = uf1.find(i)
    b = uf2.find(i)
    pair[(a, b)] += 1

ans = []
for i in range(n):
    ans.append(pair[(uf1.find(i), uf2.find(i))])

print(" ".join(map(str, ans)))

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

using namespace std;
typedef long long ll;
#define rep(i, n, s) for (int i = s; i < (int)(n); i++)

ll calcNumOfCombination(ll n, ll r) {
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }

int findSumDigits(int s) {
    int num = 0;
    int temp = 0;
    while (s) {
        temp = s % 10;
        num += temp;
        s = s / 10;
    }
    return num;
}

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

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

    reverse(s.begin(), s.end());
    for (int i = 0; i < 4; i++) {
        reverse(comp[i].begin(), comp[i].end());
    }

    bool check = true;

    for (int i = 0; i < s.size();) {
        bool check2 = false;
        for (int j = 0; j < 4; j++) {
            string temp = comp[j];
            if (s.substr(i, temp.size()) == temp) {
                check2 = true;
                i += temp.size();
            }
        }
        if (!check2) {
            check = false;
            break;
        }
    }

    if (check) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
	ll a,b,c;
	cin >> a >> b >> c;
	int i;
	for(i = 0; i < 100000; i++){
		ll ta = a,tb = b,tc = c;
		if(ta%2 || tb%2 || tc%2) break;
		a = tb/2 + tc/2;
		b = ta/2 + tc/2;
		c = tb/2 + tc/2;
	}
	cout << (i == 100000 ? -1 : i) << endl;
    return 0;
}

Measured memory_bytes: 256
'use strict'

const main = (input) => {
    input = input.split('\n')
    const N = parseInt(input[0])
    let X = []
    let Y = []
    let Z = []
    input.slice(1, N + 1).forEach(v => {
        let tmp = v.split(' ').map(j => parseInt(j))
        X.push(tmp[0])
        Y.push(tmp[1])
        Z.push(tmp[2])
    })

    const MAX = 100
    for(let y = 0; y <= MAX; y++){
        for(let x = 0; x <= MAX; x++){
            let needH = -1
            for(let i = 0; i < N; i++){
                if(Z[i] > 0){
                    let tmp = Z[i] + Math.abs(Y[i] - y) + Math.abs(X[i] - x)
                    if(needH === -1){
                        needH = tmp
                    }else if(needH !== tmp){
                        needH = -2
                        break
                    }
                }
            }
            if(needH === -2) continue
            for(let i = 0; i < N; i++){
                if(Z[i] === 0){
                    let dist = Math.abs(Y[i] - y) + Math.abs(X[i] - x)
                    if(needH > dist){
                        needH = -2
                        break
                    }
                }
            }
            if(needH === -2) continue
            console.log('%d %d %d', x, y, needH)
        }
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 7884
#include <iostream>
#include <cmath>
#include <string>
#include <map>
#include <queue>
using namespace std;
#define N 3
#define N2 9

struct puzzle{
  int x[N2];
  int space;
  string path;
  bool operator < (const puzzle &p)const{
    for(int i=0;i<N2;i++){
      if(x[i]==p.x[i]) continue;
      return x[i]>p.x[i];
    }
    return false;
  }
};

int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
char dir[4] = {'u','l','d','r'};

bool target(puzzle);
string bfs(puzzle);

int main(){
  int i;
  string answer;
  puzzle in;

  for(i=0;i<N2;i++){
    cin >> in.x[i];
    if(in.x[i] == 0){
      in.x[i] = N2;
      in.space = i;
    }
  }
  answer = bfs(in);
  cout << answer.size() << endl;

  return 0;
}

bool target(puzzle p){
  int i;
  for(i=0;i<N2;i++)
    if(p.x[i] != (i+1)) return false;
  return true;
}

string bfs(puzzle p){
  int px,py,tx,ty,r;
  queue<puzzle> Que;
  map<puzzle,bool> V;
  puzzle m,k;
  p.path="";
  Que.push(p);
  V[p]=true;

  while(!Que.empty()){
    m=Que.front(); Que.pop();
    if(target(m)==true) return m.path;
    px=m.space/N;
    py=m.space%N;
    for(r=0;r<4;r++){
      tx=px+dx[r];
      ty=py+dy[r];
      if(tx<0 || ty<0 || tx>=N || ty>=N) continue;
      k=m;
      swap(k.x[m.space],k.x[tx*N+ty]);
      k.space=tx*N+ty;
      if(!V[k]){
	V[k]=true;
	k.path += dir[r];
	Que.push(k);
      }
    }
  }
  return "unsolvable";
}



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

const int inf = 1000000000;
int main()
{
    int N,k=inf,c=0;
    cin >> N;
    vector<int>X(N);
    for(int i=0; i<N; i++)
        cin>>X[i];
    for(int i=1; i<=100; i++)
    {
        c=0;
        for(int j=0; j<N; j++)
            c+=(X[j]-i)*(X[j]-i);
            k= min(k,c);
    }
    cout<<k<<endl;
    return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define ZERO (1e-10)
#define INF int(1e9+1)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define DEB printf("DEB!\n");
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define EQ(A,B) (A+ZERO>B&&A-ZERO<B)
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
#define IN(n) int n;scanf("%d",&n);
#define FOR(i, m, n) for (int i(m); i < n; i++)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)
#define FT(m, n) FOR(k, m, n)
#define aa first
#define bb second
void ga(int N,int *A){F(N)scanf("%d",A+i);}
#define MX 16
int N,A[MX],dp[MX][2];
int dyn(int u,bool x){
    if(u==N)return x;
    int&v=dp[u][x];
    if(~v)return v;
    v=0;
    FOR(i,A[u]-1,A[u]+2)v+=dyn(u+1,x|!(i&1));
    return v;
}
int main(void){
    scanf("%d",&N),ga(N,A),CL(dp,-1);
    printf("%d\n",dyn(0,0));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <tuple>
using namespace std;
typedef pair<int,int> P;//h,w
typedef tuple<int,int,int,int> T;//cost,h,w,d;
//d 0:north, 1:east, 2:south, 3:west

int S[30][30];//h,w
int memo[30][30][4];//h,w,d

int main(){
    int W,H;
    while(cin>>W>>H,W|H){
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                cin>>S[i][j];
            }
        }
        int C[4];
        for(int i=0;i<4;i++) cin>>C[i];
        fill(memo[0][0],memo[30][0],1LL<<30);
        priority_queue<T,vector<T>,greater<T>> que;
        que.emplace(0,0,0,1);
        memo[0][0][1]=1;
        while(!que.empty()){
            auto t = que.top(); que.pop();
            int cost=get<0>(t), h=get<1>(t), w=get<2>(t), d=get<3>(t);
            if(memo[h][w][d]<cost) continue;
            if(h==H-1&&w==W-1){
                cout<<cost<<endl;
                break;
            }
            int c,d_;
            int dh[4]={-1,0,1,0};
            int dw[4]={0,1,0,-1};
            //??´???
            c = (S[h][w]==0?0:C[0]);
            if(h+dh[d]>=0&&h+dh[d]<H&&w+dw[d]>=0&&w+dw[d]<W){
                if(memo[h+dh[d]][w+dw[d]][d]>cost+c){
                    memo[h+dh[d]][w+dw[d]][d]=cost+c;
                    que.emplace(cost+c,h+dh[d],w+dw[d],d);
                }
            }
            //??????
            d_=(d+1)%4;
            c = (S[h][w]==1?0:C[1]);
            if(h+dh[d_]>=0&&h+dh[d_]<H&&w+dw[d_]>=0&&w+dw[d_]<W){
                if(memo[h+dh[d_]][w+dw[d_]][d_]>cost+c){
                    memo[h+dh[d_]][w+dw[d_]][d_]=cost+c;
                    que.emplace(cost+c,h+dh[d_],w+dw[d_],d_);
                }
            }
            //?????¢
            d_=(d+2)%4;
            c = (S[h][w]==2?0:C[2]);
            if(h+dh[d_]>=0&&h+dh[d_]<H&&w+dw[d_]>=0&&w+dw[d_]<W){
                if(memo[h+dh[d_]][w+dw[d_]][d_]>cost+c){
                    memo[h+dh[d_]][w+dw[d_]][d_]=cost+c;
                    que.emplace(cost+c,h+dh[d_],w+dw[d_],d_);
                }
            }
            //??????
            d_=(d+3)%4;
            c = (S[h][w]==3?0:C[3]);
            if(h+dh[d_]>=0&&h+dh[d_]<H&&w+dw[d_]>=0&&w+dw[d_]<W){
                if(memo[h+dh[d_]][w+dw[d_]][d_]>cost+c){
                    memo[h+dh[d_]][w+dw[d_]][d_]=cost+c;
                    que.emplace(cost+c,h+dh[d_],w+dw[d_],d_);
                }
            }
        }
        while(!que.empty()) que.pop();
    }
    return 0;
}

Measured memory_bytes: 3140
locA, locB, locC, disD = map(int, input().split())
checker = False
if abs(locC - locA) <= disD:
    checker = True
elif abs(locC - locB) <= disD and abs(locB - locA) <= disD:
    checker = True
else:
    checker = False

if checker:
    print ("Yes")
else:
    print ("No")

Measured memory_bytes: 3060
//use proconio::{input, fastout};
use proconio::input;
use itertools::*;

//#[fastout]
fn main() {
    input! {
        n: usize, m: usize, x: u32,
        mut d: [(u32, [u32; m]); n],
    }

    d.sort_by(|(c0, _), (c1, _)| c0.cmp(c1));
    let mut v = Vec::new();
    for i in 0..n {
        let c = (0..n).combinations(i + 1);
        for ci in c {
            let mut sum = 0;
            for i in &ci {
                sum += d[*i].0;
            }
            v.push((sum, ci));
        }
    }
    v.sort_by(|(c0, _), (c1, _)| c0.cmp(c1));

    for (c, i_s) in v {
        let mut sum_a = vec![0; m];
        for i in i_s {
            for j in 0..m {
                sum_a[j] += d[i].1[j];
            }
            if *sum_a.iter().min().unwrap() >= x {
                println!("{}", c);
                return;
            }
        }
    }

    println!("{}", -1);
}


Measured memory_bytes: 2540
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n, x, y;
    cin >> n >> x >> y;

    vs32 ans(n, 0);
    for (int i = 1; i <= n; ++i)
    {
        for (int j = i + 1; j <= n; ++j)
        {
            int k;
            k = MIN(j - i, abs(x - i) + 1 + abs(y - j));
            ++ans[k];
        }
    }

    for (int k = 1; k < n; ++k)
    {
        cout << ans[k] << "\n";
    }

    return 0;
}



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

int main()
{
  int N, M;
  while( cin >> N, N ) {
    int treasure[21][21] = {{0}};
    for(int i=0; i<N; i++) {
      int x, y;
      cin >> x >> y;
      treasure[y][x] = 1;
    }

    int x = 10, y = 10;
    int cnt = 0;
    cin >> M;
    while( M-- ) {
      char d;
      int l;
      cin >> d >> l;
      if( d == 'N' ) {
	for(int i=y; i<=y+l; i++) {
	  if( treasure[i][x] ) cnt++, treasure[i][x] = 0;
	}
	y += l;
      }
      if( d == 'E' ) {
	for(int i=x; i<=x+l; i++) {
	  if( treasure[y][i] ) cnt++, treasure[y][i] = 0;
	}
	x += l;
      }
      if( d == 'S' ) {
	for(int i=y; i>=y-l; i--) {
	  if( treasure[i][x] ) cnt++, treasure[i][x] = 0;
	}
	y -= l;
      }
      if( d == 'W' ) {
	for(int i=x; i>=x-l; i--) {
	  if( treasure[y][i] ) cnt++, treasure[y][i] = 0;
	}
	x -= l;
      }
    }

    if( cnt == N ) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
int a[1000];
int main(){
    int N,sum,m=0;
    cin>>N;
    for(int i=0;i<N;i++) cin>>a[i];
    for(int i=0;i<N;i++){
        if(m<a[i]) m=a[i];
        if(m<=a[i]) sum++;
    }
    cout<<sum;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<climits>
 
using namespace std;
 
#define debug(x,y) cout<<(#x)<<" " <<(#y)<<" is " << (x) <<" "<< (y) << endl
#define watch(x) cout<<(#x)<<" is " << (x) << endl
#define fast ios_base::sync_with_stdio(false)
#define fie(i,a,b) for(i=a;i<b;i++)
#define MOD 1000000007
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define ll long long
#define lld long long int
#define ALL(x) (x).begin(),(x).end()
 
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<pair<int,int>> vpi;
 
const long long OO = 2e18;
const double pi=2*acos(0.0);
 
bool isprime(long long int a){
    if(a==1){
        return false;
    }
    for(int i=2;i*i<=a;i++){
        if(a%i==0){
            return false;
        }
    }
    return true;
} 

bool iscoprime(int a,int b){
    int i;
    for(i=2;i<=min(a,b);i++){
        if(a%i==0 && b%i==0){
            return false;
        }
    }
    return true;
}

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

int maxA(vi a){
    int m=0;
    for(int i=0;i<a.size();i++){
        m=max(m,a[i]);
    }
    return m;
}

int minA(vi a){
    int m=100000;
    for(int i=0;i<a.size();i++){
        m=min(m,a[i]);
    }
    return m;
}

vi freqN(vi a, int n){
    vi f(n);
    f={0};
    for(int i=0;i<a.size();i++){
        f[a[i]]++;
    }
    return f;
}

vi freqA(vi a){
    vi f(26);
    f={0};
    for(int i=0;i<a.size();i++){
        f[a[i]-'0']++;
    }
    return f;
}

bool mycomp(const pair<long int,long int>&p1 , const pair<long int,long int>&p2){
    if(p1.second < p2.second) return true;
    else if(p1.second==p2.second) return p1.first<p2.first;
    else return false;
}

unsigned int rightmostsetbit(unsigned int n){
    return n & -n;
}

bool cmp(pair<string,int>&p1 , pair<string,int>&p2){
    if(p1.second==p2.second) return p1.first<p2.first;
    return p1.second>p2.second;
}

int main(){
fast;
cin.tie(0);
lld n;
cin>>n;
vector<pair<int,int>> p(n+1);
lld count=0;
for(lld i=1;i<=n;i++){
    cin>>p[i].first;
    p[i].second=i;
}
lld shift=0;
for(lld i=1;i<=n;i++){
    if(p[i].first!=p[i].second-shift){
        count++;
        shift++;
    }
}
if(count==n){
    cout<<"-1"<<endl;
}
else{
    cout<<count<<endl;
}
}

Measured memory_bytes: 1792
/* ex9_1
   reo012 */

#include <stdio.h>
#include <stdlib.h>
//スタックに格納するデータの最大数
#define SIZE 11

//スタックの定義
typedef struct stack{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;

//スタックの初期化
void initialize_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);
}

//データの追加
void push(stack *stk, char elem){
    if(stk->count >= stk->size){
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
        exit(1);
    }
    else{
        stk->top--;
        *(stk->top) = elem;
        stk->count++;
    }
}

//データの削除
void pop(stack *stk){
    if(stk->count <= 0){
        fprintf(stdout, "Error: stack underflow.\n");
        exit(1);
    }
    else{
        stk->top++;
        stk->count--;
        return;
    }
}

int main(void){
    stack stk;
    char input_s[11], *ptr;
    scanf("%s", input_s);

    //スタックを初期化（ポインタ渡しで関数にわたすこと）
    initialize_stack(&stk);

    //スタックへのデータの追加・削除
    ptr = input_s;
    while(*(ptr)!='\0'){
        if(*(ptr)=='0' || *(ptr)=='1'){ //0か1が入力されたとき
            push(&stk, *(ptr)); //スタックに０、1を追加
        }else if(stk.count > 0){    //Bが入力され、かつスタックが空でないとき
            pop(&stk);  //スタックの一番上（最後に入力されたもの）を削除
        }
        ptr++;
    }

    //スタックを下から順に表示
    for (int i=0; i<stk.count; i++){
        printf("%c", stk.data[SIZE-i-1]);   //最後尾から出力していく
    }
    printf("\n");
    return 0;
}


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

int main(){
  string s;
  cin >> s;
  if(s=="RSS") return cout << 1 <<endl,0;
  if(s=="SRS") return cout << 1 <<endl,0;
  if(s=="SSR") return cout << 1 <<endl,0;
  if(s=="RSR") return cout << 1 <<endl,0;
  if(s=="RRS") return cout << 2 <<endl,0;
  if(s=="SRR") return cout << 2 <<endl,0;
  if(s=="RRR") return cout << 3 <<endl,0;
  if(s=="SSS") return cout << 0 <<endl,0;
}


Measured memory_bytes: 3624
#include<cstdio>

int main()
{
	int n,a,la=0,ans=0,k=1;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a);
		if(a==la)
			k++;
		else
			ans+=k>>1,k=1;
		la=a;
	}
	ans+=k>>1;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>

#define sz(x) (int)((x).size())
#define endl '\n'
#define x first
#define y second
#define int long long
#define all(a) (a).begin(), (a).end()
#define ar vector
#define vse(a) a.begin(), a.end()

#ifdef LOCAL
	#define dbg(x) cout << #x << " = " << x << endl;
#else 
	#define dbg(x)
#endif 

using namespace std;

void solve(); signed main() {
#ifdef LOCAL
    freopen("file1.txt", "r", stdin);                                       
    freopen("file2.txt", "w", stderr);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(15);
    solve();  	
}

const int INF = 1e18, MAXN = 1e5 + 10;
int n, m;
int used[MAXN];
vector<int> g[MAXN];                     

void dfs(int v) {
 	used[v] = 1;
 	for (auto u : g[v]) {
 	 	if (!used[u]) {
 	 	 	dfs(u);
 	 	}
 	}
}

void solve() {
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
	    int x, y, z;
	    cin >> x >> y >> z;
	    z %= 2;
	    x--, y--;
	     	g[x].push_back(y);
	     	g[y].push_back(x);
 	}	

	int cnt = 0;
	for (int v = 0; v < n; ++v) {
	    if (!used[v]) {
	        dfs(v);
	        cnt++;
	    }	
	}	

	cout << cnt << endl;
}


Measured memory_bytes: 9600
#include <iostream>
using namespace std;
int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int dx = tx-sx, dy = ty-sy;
    cout << string(dy, 'U') << string(dx, 'R');
    cout << string(dy, 'D') << string(dx, 'L');
    cout << "L" << string(dy+1, 'U') << string(dx+1, 'R') << "D";
    cout << "R" << string(dy+1, 'D') << string(dx+1, 'L') << "U";
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <deque>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

int main()
{
	long long n;
	cin >> n;
	long long ceiling = ceil(sqrt(static_cast<double>(n)));

	vector<long long> divisor;

	for (long long i = 1; i <= ceiling; ++i)
	{
		if (n % i == 0)
		{
			divisor.emplace_back(i);
		}
	}

	long long res = 1e12 + 1;

	for (long long i = 0; i < divisor.size(); ++i)
	{
		res = min(res, divisor.at(i) + n / divisor.at(i));
	}

	cout << res - 2 << endl;
}

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

int main() {
	int x,y;
	cin>>x>>y;
	ll ans=0;
	if(x==3)
	{
	    ans+=100000;
	}
	if(x==2)
	{
	    ans+=200000;
	}
	if(x==1)
	{
	    ans+=300000;
	}
		if(y==1)
	{
	    ans+=300000;
	}
		if(y==2)
	{
	    ans+=200000;
	}
		if(y==3)
	{
	    ans+=100000;
	}
	if(x==1 && y==1)
	{
	    ans+=400000;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main (String[] args) throws IOException
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));

		String word = input.readLine();

		String WORD = word.toUpperCase();

		int count = 0;

		while(true)
		{
			String[] str = input.readLine().split(" ");

			if(str[0].equals("END_OF_TEXT"))
				break;

			String[] STR = new String[str.length];

			for(int num = 0; num < str.length; num++)
				STR[num] = str[num].toUpperCase();

			//単語の数を数える
			for(int num = 0; num < STR.length; num++)
			{
				if(STR[num].equals(WORD))
				{
					count++;
				}
			}
		}

		System.out.println(count);
	}
}



Measured memory_bytes: 24252
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long lli;
#define int long long
const int NMAX = 300005;
lli bit[NMAX];
lli h[NMAX];
lli a[NMAX];
int n;

void update(lli val, int i){
	while(i <= n){
		bit[i] = max(bit[i], val);
		i += i & (-i);
	}
}

lli query(int i){
	lli ans = 0;
	while(i >= 1){
		ans = max(ans, bit[i]);
		i -= i & (-i);
	}
	return ans;
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin >> n;
	for(int i=1; i<=n; i++) cin >> h[i];
	for(int i=1; i<=n; i++) cin >> a[i];

	for(int i=1; i<=n; i++)
		update(query(h[i]-1) + a[i], h[i]);
	cout << query(n);

	return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	int ab = static_cast<int>(abs(a - b));
	int bc = static_cast<int>(abs(b - c));
	int ac = static_cast<int>(abs(a - c));

	bool id_ok(ab <= d && bc <= d);  // indirectly ok
	bool dok(ac <= d);               // directly ok

	cout << ((id_ok || dok) ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))
p_ind = [ (p[i], i+1) for i in range(n) ]
p_ind.sort(reverse=True)

# 平方分割します。
max_n = 10**5
div_n = int(max_n**(1/2))+1
a = [[] for _ in range(div_n)]
a[0] = [0,0]
a[(n+1)//div_n].append(n+1)
a[(n+1)//div_n].append(n+1)
a_count = [0] * (div_n)
a_count[0] += 2
a_count[(n+1)//div_n] += 2

import bisect
ans = 0
for tmp in p_ind:
    val, i = tmp
    group = i//div_n
    j = bisect.bisect(a[group],i)
    #left
    if(j>1):
        left1 = a[group][j-1]
        left2 = a[group][j-2]
    elif(j==1):
        left1 = a[group][j-1]
        lg = group-1
        while(True):
            if(a_count[lg]>0):
                break
            lg -=1
        left2 = a[lg][-1]
    else:
        lg = group-1
        while(True):
            if(a_count[lg]>0):
                break
            lg -=1
        if(a_count[lg]>=2):
            left1 = a[lg][-1]
            left2 = a[lg][-2]
        else:
            left1 = a[lg][-1]
            while(True):
                lg -=1
                if(a_count[lg]>0):
                    break
            left2 = a[lg][-1]
    #right
    if(a_count[group]>=j+2):
        right1 = a[group][j]
        right2 = a[group][j+1]
    elif(a_count[group]>=j+1):
        right1 = a[group][j]
        rg = group
        while(True):
            rg += 1
            if(a_count[rg]>0):
                break
        right2 = a[rg][0]
    else:
        rg = group
        while(True):
            rg += 1
            if(a_count[rg]>0):
                break
        if(a_count[rg]>=2):
            right1 = a[rg][0]
            right2 = a[rg][1]
        else:
            right1 = a[rg][0]
            while(True):
                rg += 1
                if(a_count[rg]>0):
                    break
            right2 = a[rg][0]

    ans += ((right2 - right1)* (i - left1) + (right1 - i)* (left1 - left2)) * val
    a[group].insert(j,i)
    a_count[group] += 1

print(ans)

Measured memory_bytes: 63980
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1e9;
const long long LINF = 1LL << 50;
#define int long long

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int x; cin >> x;
	int ans = 2 * (x / 11);
	int tmp = x % 11;
	if (!(0 <= tmp && tmp <= 6))ans += 2;
	else if(tmp>0)ans++;
	COUT(ans);
	return 0;
}


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

int main(){
    int W, H, N;
    cin >> W >> H >> N;

    int X = 0, Y = 0;
    for(int i = 0; i < N; i++){
        int x, y, a;
        cin >> x >> y >> a;
        switch(a){
        case 1:
            X = max(x, X);
            break;
        case 2:
            W = min(x, W);
            break;
        case 3:
            Y = max(y, Y);
            break;
        case 4:
            H = min(y, H);
            break;
        }
    }
    if(W < X || H < Y)
        cout << 0 << endl;
    else
        cout << (W-X) * (H-Y) << endl;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
AB=list(list(map(int,input().split())) for _ in range(N))
AB.sort(key=lambda x:x[0])
cost=0
for ab in AB:
    if M>=ab[1]:
        M-=ab[1]
        cost+=ab[0]*ab[1]
    else:
        cost+=ab[0]*M
        break
print(cost)

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

int main()
{

    int n, ara[100001] = {0};
    int pp = 1, c = 0;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)scanf("%d", &ara[i]);
    while(1)
    {
        if(ara[pp] == -1)break;
        int f = pp;
        pp = ara[pp];
        ara[f] = -1;
        c++;
        if(pp == 2)
        {
            printf("%d", c);
            return 0;
        }
    }
    printf("-1");
    return 0;
}


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

int main()
{
    int n; cin>>n;
    vector<int> a(n); for(auto& e: a) cin>>e;

    int k=0, res=0;
    for(auto& e: a)
        (e==k+1 ? k : res)++;
    cout<<(k ? res : -1)<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include<vector>
#include<queue>

#define ll long long
#define ld long double

using namespace std;

const int MAXN = 1001 * 1001 , MOD = 1e9 + 7 ;

string s[MAXN] ;


int cmp(string s , string t , char x)
{
    int n = s.size() ;
    for(int i = 0 ; i < n ; i ++  ) if(s[i]=='?') s[i] = x ;
    if(s<t) return 0 ;
    if(s==t) return 1 ;
    return 2 ;
}

int main() {
    ios::sync_with_stdio(0) ;
    cin.tie(0) ; cout.tie(0) ;
    int n ;
    cin >> n ;
    for(int i = 0 ; i < n ; i ++ )
        cin >> s[i] ;
    string t ;
    cin >> t ;

    int x = 0 , y = 0 ;

    int m = t.size() ;

    for(int i = 0 ; i < n ; i ++ )
    {
        if(!cmp(s[i],t,'z'))
            x ++ ;
    }


    for(int i = 0 ; i < n ; i ++ )
    {
        if(cmp(s[i],t,'a')==2)
            y ++ ;
    }

  //  cout << x << ' ' << y << endl ;

    //for(int i = 1 ; i <= n ; i ++ )
    vector<int> v ;
    for(int i = x + 1 ; i + y  <= n + 1 ; i ++ )
        v.push_back(i) ;
    x = v.back() ;
    v.pop_back() ;
    for(auto u : v) cout << u << ' ' ;
    cout << x ;
    cout << endl ;

    return 0;
}


Measured memory_bytes: 35116
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(ll i=ll(x);i<(ll)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<ll,ll>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;



int main(){
    ll n;
    cin>>n;
    vector<ll>x(n),y(n),z(n);
    int sx,sy,sz;
    rep(i,n){
        cin>>x[i]>>y[i]>>z[i];
        if(z[i]>0){
            sx=x[i];
            sy=y[i];
            sz=z[i];
        }
    }
    ll ax,ay,az;
    rep(i,101)rep(j,101){
        bool ok=true;
        ll h=sz+abs(i-sx)+abs(j-sy);
        rep(k,n){
            ll tmp=h-abs(i-x[k])-abs(j-y[k]);
            tmp=max(tmp,0ll);
            if(tmp!=z[k]){
                ok=false;
                break;
            }
        }
        if(ok){
            ax=i;
            ay=j;
            az=h;
            break;
        }
    }
    cout<<ax<<" "<<ay<<" "<<az<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n, a, b = map(int, input().split())
    r = 0
    for i1 in range(1, n + 1):
        i1sum = sum(tuple(map(int, str(i1))))
        if a <= i1sum <= b:
            r += i1
    print(r)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9140
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <limits.h>
#include <float.h>
#include <math.h>

int main(int argc, char *argv[])
{
    char s[100];
    int c, i, len;

    scanf("%s", s);
    
    len = strlen(s);
    c = 0;
    for (i = 0; i < len; i++) {
        if (s[i] == 'o') {
            c++;
        }
    }

    c += 15 - len;

    if (c >= 8) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 128
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

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

    for(int i = 1; i <= 50000; i++){
        if(floor((double)i * 1.08) == n){
            cout << i << endl;
            return 0;
        }
    }

    cout << ":(" << endl;
}

Measured memory_bytes: 256
n = int(input())
a = []
for i in range(n):
    suit, num = input().split()
    a.append([suit, int(num), int(i)])

b = a[:]

def partition(a, p, r):
    x = a[r][1]
    i = p - 1
    for j in range(p,r):
        if a[j][1] <= x:
            i += 1
            a[i], a[j] = a[j], a[i]
    a[i + 1], a[r] = a[r], a[i + 1]
    return i + 1

def quickSort(a, p, r):
    if p < r:
        q = partition(a, p, r)
        quickSort(a, p, q - 1)
        quickSort(a, q + 1, r)

def checkStable(a):
    for i in range(len(a) - 1):
        if a[i][1] == a[i + 1][1] and a[i][2] > a[i + 1][2]:
            return "Not stable"
    return "Stable"

quickSort(a, 0, n - 1)

print(checkStable(a))
for a_i in a:
    print(a_i[0],a_i[1])

Measured memory_bytes: 25508
using System;

class Program {
    static void Main( string[] args )
    {
        int n = int.Parse( Console.ReadLine() );

        for ( int i = 1; i <= n; ++i ) {
            if ( 0 == i % 3 ) {
                Console.Write( " {0}", i );

            } else {
                int x = i;

                while ( 0 != x ) {
                    if ( 3 == x % 10 ) {
                        Console.Write( " {0}", i );
                        break;
                    }

                    x /= 10;
                }
            }
        }

        Console.WriteLine();
    }
}

Measured memory_bytes: 9260
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

const int N = 2e5+4;
int a[N],b[N];
void solve(){  
	int n,k;
	cin>>n>>k;
	rep(i,0,n) cin>>a[i];
	rep(i,0,n) cin>>b[i];
	sort(a,a+n);
	reverse(a,a+n);
	sort(b,b+n);
	int lo=-1;
	int hi=1e13;
	while(hi-lo>1){
		int mid=(hi+lo)/2;
		int f=1;
		int changes=0;
		rep(i,0,n){
			changes+=max(0LL,a[i]-mid/b[i]);
		}
		if(changes<=k) hi=mid;
		else lo=mid;
	}  
	cout<<hi<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct aaa{
	ll x,y;
}a[1010];
const ll p=1e9+7;
ll ans,n,m,i,j,l,r,flag,sz,in,out,b[1010],f[602][602],g[602][602];
int main(){
	scanf("%lld%lld",&n,&m);
	for(i=1;i<=m;i++)scanf("%lld%lld",&a[i].x,&a[i].y);
	b[0]=1;
	for(i=1;i<=n;i++)b[i]=b[i-1]*(i*2-1)%p;
	for(l=n*2;l;l--)
	 for(r=l;r<=n*2;r++)if((r-l+1)%2==0){
	 	flag=in=out=0;
	 	for(i=1;i<=m;i++){
	 		sz=0;
		  if(a[i].x>=l&&a[i].x<=r)sz++;
		  if(a[i].y>=l&&a[i].y<=r)sz++;
		  if(sz==1)flag=1;
		  if(sz==0)out++;
		   else in++;
	    }
	    if(flag)continue;
	    f[l][r]=g[l][r]=b[(r-l+1)/2-in];
	    for(i=l;i<r;i++)f[l][r]=(f[l][r]-f[l][i]*g[i+1][r]%p+p)%p;
	    ans=(ans+f[l][r]*b[n-(r-l+1)/2-out])%p;
	 }
	printf("%lld",ans);
}

Measured memory_bytes: 9292
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n;
	string s;
	cin >> n >> s;
	int cntr = 0;
	for (auto c : s)
		if (c == 'R') cntr++;
	int ans = 0;
	rep(i, cntr) if (s[i] == 'W') ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
#define li long long  int
#define pb push_back
using namespace std;
int main(){
 li n , count1=0 ,t;
 cin>>n;
 vector<li>a(n);
 for(int i = 0; i < n; i++)
    cin>>a[i];

 for(int i = 0 ; i < n - 1; i++){
    if(a[i - 1] >= a[i])
        a[i] ;
    else
        a[i]-- ;
 }
 int p=0;
for(int i = 0 ; i < n - 1; i++){
    if(a[i+1] < a[i]){
        p=1;
        break;
    }

}
if(p==1&&n>1)
    cout<<"No"<<endl;
else
    cout<<"Yes"<<endl;




}


Measured memory_bytes: 1024
#include <stdio.h>
int main()
{

    int i,a,b,c,j,n,m,k,l;
    scanf("%d%d",&a,&b);
l=a-b*2;
    if(l<=0){
        printf("0\n");
    } else{
        printf("%d\n",l);
    }
    return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <queue>
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++) 

int main() {
    ll a, b, n;
    cin >> a >> b >> n;
    ll ans = -1;
    for(ll i = min(b, n); i > -1; i--) {
        if(i <= n) {
            ll tmp = floor(a*i/b)-a*floor(i/double(b));
            //cout << tmp << endl;
            //cout << i/double(b) << "  " << floor(i/double(b)) << endl;
            if(ans < tmp) {
                //cout << floor(a*i/b) << " " << a*floor(i/b) << endl;
                ans = tmp;
            }
            else {
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
while 1:
    n=int(input())
    if n==0:break
    nk=1
    while nk*(nk+1)/2<n:nk+=1
    ans=0
    for i in range(2,nk+1):
        if i%2==1 and n%i==0 or i%2==0 and int(n/i-i/2+0.5)==n/i-i/2+1/2:ans+=1
    print(ans)


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

int main() {
  int n, m;
  cin >> n >> m;
  
  string ans;
  for(int i=0; i<n; i++) ans.push_back('X');
  
  int a; char b;
  bool check = false;
  for(int i=0; i<m; i++) {
    cin >> a >> b;
    if(ans[a-1]=='X' || ans[a-1]==b) {
      if(a==1 && b=='0' && ans.size()!=1) {check = true; break;}
      else ans[a-1]=b;
    }
    else {check = true; break;}
  }
  
  if(check) cout << "-1" << endl;
  else {
    for(int i=0; i<n; i++) {
      if(ans[i]=='X') {
        if(i==0) {
          if(ans.size()==1) ans[i]='0';
          else ans[i]='1';
        }
        else ans[i]='0';
      }
    }
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3600
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <algorithm>
#include <functional>

using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(itr,c) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)

#define INF (1<<29)

int N;
int a[1010],dp[2][1000010];

void make(){
  int n;
  for(n = 1; n <= 1000; n++) a[n] = n * (n+1) * (n+2) / 6;
}

int main(){
  int i,j,k;

  make();

  rep(i,2) rep(j,1000010) dp[i][j] = INF;

  dp[0][0] = dp[1][0] = 0;
  for(i = 1; a[i] <= 1000000 && i < 1010; i++){
    for(j = 0; j <= 1000000; j++){
      if(j - a[i] >= 0) dp[0][j] = min(dp[0][j], dp[0][j - a[i]] + 1);
      if(a[i] % 2 == 1 && j - a[i] >= 0) dp[1][j] = min(dp[1][j], dp[1][j - a[i]] + 1);
    }
  }

  for(;;){
    scanf("%d",&N); if(N == 0) break;
    cout << dp[0][N] << ' ' << dp[1][N] << endl;
  }

  return 0;
}

Measured memory_bytes: 8564
def calc(x):
    ans = 0
    n = len(x)
    for i,a in enumerate(x):
        ans += i*a - (n-1-i)*a
    return ans


n,m = map(int,input().split())
x = tuple(map(int,input().split()))
y = tuple(map(int,input().split()))

print(calc(x)*calc(y)%(int(1e9+7)))

Measured memory_bytes: 19472
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;
vector<vector<int> > g;
vector<int> color,flag;
void dfs(int x,int dst,int max_dst,int c){
	color[x] = color[x]==0?c:color[x];
	if(flag[x]>=max_dst-dst){
		return;
	}

	flag[x] = max_dst-dst;
	if(dst >= max_dst)
		return;
	for(int i = 0; i < g[x].size(); i++){
			dfs(g[x][i],dst+1,max_dst,c);
	}
}

int main()
{
	int n,m;
	cin>>n>>m;
	g.resize(n,vector<int>());
	color.resize(n,0);
	for(int i = 0; i < m; i++){
		int a,b;
		cin>>a>>b;
		g[a-1].push_back(b-1);
		g[b-1].push_back(a-1);
	}
	int q;
	cin>>q;
	vector<int> v(q),d(q),c(q);
	for(int i = 0; i < q; i++){
		cin>>v[i]>>d[i]>>c[i];
		v[i]--;
	}

	flag.resize(n,0);
	for(int i = q-1; i >= 0; i--){
		dfs(v[i],0,d[i],c[i]);
	}

	for(int i = 0; i < n; i++){
		cout << color[i] << endl;
	}


	return 0;
}

Measured memory_bytes: 8440
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = solve(k);

        // 出力
        System.out.println(result);
    }

    private static int solve(int k) {
        if (k % 2 == 0 || k % 5 == 0) {
            return -1;
        }

        int num = 7;
        int count = 0;
        for (int i = 0; i <= 1000000; i++) {
            int mod = num % k;
            count++;
            if (mod == 0) {
                break;
            }
            num = mod * 10 + 7;
        }
        return count;
    }
}


Measured memory_bytes: 35392
#!/usr/bin/env python3
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    A, B = map(int, readline().split())
    print(max(A - 2 * B, 0))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M = 1e9+7;
const int MN = 5010;
ll dp[2][2][MN];
ll ew[MN];
int main() {
	ll n,a,b;
	cin >> n >> a >> b;
	if(a > b) {swap(a,b);}
	int cu = 0;
	memset(dp,0,sizeof(dp));
	dp[cu][0][0] = 1;
	memset(ew,0,sizeof(ew));
	ew[0] = 1;
	for(int i=0;i<=n;i++) {
		ew[i+1] += ew[i];
		if(ew[i+1] >= M) {ew[i+1] -= M;}
		for(int j=a;j+i+1<=n;j++) {
			ew[i+j+1] += ew[i];
			if(ew[i+j+1] >= M) {ew[i+j+1] -= M;}
		}
	}
	for(int i=0;i<n;i++) {
		int nu = 1-cu;
		memset(dp[nu],0,sizeof(dp[nu]));
		for(int j=0;j<a;j++) {
			dp[nu][0][j+1] += dp[cu][0][j];
			if(dp[nu][0][j+1] >= M) {dp[nu][0][j+1] -= M;}
			dp[nu][1][1] += dp[cu][0][j];
			if(dp[nu][1][1] >= M) {dp[nu][1][1] -= M;}
		}
		for(int j=0;j<b;j++) {
			dp[nu][1][j+1] += dp[cu][1][j];
			if(dp[nu][1][j+1] >= M) {dp[nu][1][j+1] -= M;}
			ll tr = dp[cu][1][j];
			if(j == i) {
				tr = tr*ew[max(j,0)]%M;
			} else {
				tr = tr*ew[max(j-1,0)]%M;
			}
			dp[nu][0][1] += tr;
			if(dp[nu][0][1] >= M) {dp[nu][0][1] -= M;}
		}
		cu = nu;
	}
	ll res = 0;
	for(int i=0;i<a;i++) {
		res += dp[cu][0][i];
	}
	for(int i=0;i<b;i++) {
		ll tr = dp[cu][1][i];
		tr = tr*ew[max(i,0)]%M;
		res += tr;
	}
	res %= M;
	ll go = 1;
	for(int i=0;i<n;i++) {
		go *= 2;
		if(go >= M) {go -= M;}
	}
	res = go-res;
	res = ((res%M)+M)%M;
	cout << res << '\n';
}


Measured memory_bytes: 3832
#include <iostream>
#include<string>
#include<vector>
#include<array>

using namespace std;

int main()
{
	int N, c, s;
	vector<int> b;
	cin >> N;
	b.push_back(0);
	for (int i = 1; i < N; i++)
	{
		cin >> c;
		b.push_back(0);

		b[c]++;
	}
	for (int i = 1; i < N; i++)
	{
		cout << b[i] << endl;
	}
	cout << 0;
}

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

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

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

	int N,K; cin >> N >> K;
	int ans = 0;

	for (int i = 0;i < N;i++){
		int x; cin >> x;
		ans += min(abs(K-x),x)*2;
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
        int N,L[10];
        int i;
        int total=0;
        int max=0;

        scanf("%d",&N);
        for(i=0;i<N;i++){
                scanf("%d",&L[i]);
                total+=L[i];
                if(max < L[i])max=L[i];
        }

        if( max < (total-max) ){
                printf("Yes\n");
        }else{
                printf("No\n");
        }

        return 0;
}

Measured memory_bytes: 128