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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))

template<typename V,typename T>
T find_num(V v, T num) {
    if ( find(ALL(v), num) == v.end() ) {
        return false;
    } else {
        return true;
    }
}

// π M_PI
// deg = rad*180/M_PI

int main() {
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    if ( n <= m ) {
        ans = 1;
    }

    cout << ( ans ? "unsafe" : "safe" ) << endl;
    return 0;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(x); cout<<#x<<"="<<x<<endl;
#define debug2(x,y); cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define int long long
using namespace std;
const long long mod=1e9+7;


long long inverseMod(long long x,long long mod);
long long nCr(long long n,long long r,long long mod){
    //when r is lesser and is greater
    long long res=1;
    if(r>n-r)r=n-r;
    long long div=1;
    for(long long  i=0;i<r;i++){
        res=(res*(n-i))%mod;
    }

    for(long long i=1;i<=r;i++){
        div=(div*i)%mod;
    }
    return (res*inverseMod(div,mod))%mod;
}


long long power(long long x,long long n,long long mod){
//(x^n)%mod
long long result=1;

    while(n){
        if(n%2)
            result=(result*x)%mod;
        x=(x*x)%mod;
        n/=2;
    }
    return result;
}

long long inverseMod(long long x,long long mod){

return power(x,mod-2,mod);
}


int32_t main(){

    fast
    string s;
    string t;
    cin>>s>>t;
    int n=s.size();
    if(s==t.substr(0,s.size())){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }




    return 0;
}



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

vector<vector<int>> v(100010);
bool used[100010];
bool roop[100010];

int ep = -1;

bool dfs(int p,int pre){
    used[p] = 1;
    bool ret = false;
    for(auto i:v[p]){
        if(i!=pre){
            if(used[i]){
                roop[p] = 1;
                roop[i] = 1;
                ep = i;
                return true;
            }
            else{
                ret |= dfs(i,p);
                if(ret){
                    roop[p]=1;
                    break;
                }
            }
        }
    }
    if(p==ep) ret = false;
    return ret;
}



signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(20);

    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        v[a].push_back(b);
        v[b].push_back(a);

    }
    dfs(0,-1);
    int q;
    cin>>q;
    while(q--){
        int a,b;
        cin>>a>>b;
        a--,b--;
        if(roop[a] && roop[b]){
            cout << 2 << "\n";
        }
        else cout << 1 << "\n";
    }
}


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

int main() {
    int A, B; cin >> A >> B;
    map<int64_t, int> ret_a;
    map<int64_t, int> ret_b;
    for (int i=2; i<100000000; i++) {
        while (A % i == 0) {
            ret_a[i]++;
            A /= i;
        }
        while (B % i == 0) {
            ret_b[i]++;
            B /= i;
        }
    }
    for (auto kv : ret_b) {
        if (ret_a.count(kv.first)) {
            ret_a[kv.first] = max(ret_a[kv.first], ret_b[kv.first]);
        } else {
            ret_a[kv.first] = kv.second;
        }
    }

    long result = 1;
    for (auto kv : ret_a) {
        result *= pow(kv.first, kv.second);
    }
    cout << result << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int a = 0;
	string str;
	while (1){
		a = 0;
		cin >> str;
		for (int i = 0; i < str.size(); i++){
			a += str[i] - '0';
			
		}
		if (a == 0)break;
		cout << a << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 3164
n, k = [ int(v) for v in input().split() ]
path_mat = [ [ int(v) for v in input().split() ] for i in range(n) ]

mod = 10**9+7

def mat_mul(inmat1,inmat2,m):
    outmat = [ [ 0 for j in range(m) ] for i in range(m) ]

    for i in range(m):
        for j in range(m):
            for g in range(m):
                outmat[i][j] += inmat1[i][g] * inmat2[g][j]
            outmat[i][j] %= mod
    return outmat


ans_mat = [ [ 1 if i == j else 0 for j in range(n) ] for i in range(n) ]

while k != 0:
    if k % 2 == 1:
        ans_mat = mat_mul(ans_mat,path_mat,n)
    k = k // 2
    path_mat = mat_mul(path_mat,path_mat,n)
    

print(sum([ sum(i) for i in ans_mat ])%mod)


Measured memory_bytes: 70492
#include <bits/stdc++.h>
 
using namespace std;
 
#define MD 1000000007
typedef long long int ll;

int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(s[i]!=','){
            cout<<s[i];
        }else{
            cout<<' ';
        }
    }
    cout<<endl;
    return 0;
}

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

int main() {

  int n,k;
  cin >> n >> k;
  
  vector<int> t;
  
  rep(i,k) {
    int d;
    cin >> d;
    
    rep(j,d) {
      int a;
      cin >> a;
      t.push_back(a);
    }
  }
  
  sort(t.begin(), t.end());
  t.erase(unique(t.begin(), t.end()), t.end()); 
  
  cout << n - t.size() << endl;
  
  

}


Measured memory_bytes: 3632
from collections import deque
N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for i in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    graph[a].append(b)
    graph[b].append(a)
#print(graph)

queue = deque()
seen = [-1] * N
steps = [-1] * N
steps[0] = 0
parents = [-1] * N
queue.append(0)
while queue:
    node = queue.popleft()

    seen[node] = 1
    #print("now: "+str(node))
    for next in graph[node]:
        if seen[next] > -1:
            continue
        #print("next: " + str(next))
        queue.append(next)
        seen[next] = 1
        steps[next] = steps[node] + 1
        parents[next] = node

print("Yes")
for a in parents[1:]:
    print(a+1)

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

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

const ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head

vector<int> a;

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

    int n;
    cin >> n;

    int ans = 1;
    for(int i = 0; i < n; i++) ans *= 3;

    int cnt = 1;
    for(int i = 0; i < n; i++) {
        int a;
        int odd = 0;
        cin >> a;   
        if(a % 2 == 0) {
            odd += 2;
        } else {
            odd += 1;
        }
        cnt *= odd;
    }

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


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);

    ll N, M;
    cin >> N >> M;
    vll A(N);
    rep(i, N) cin >> A[i];

    sort(all(A));
    ll sum = accumulate(all(A), 0);
    ll d = distance(A.begin(), upper_bound(all(A), (sum-1)/(4*M)));
    if(N-d>=M) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = y.pow(y, n);
  Mint pow(Mint a, long long n) const {
    Mint y(1);
    Mint b(a);
    while (n > 0) {
      if (n & 1) y *= b;
      b *= b;
      n >>= 1;
    }
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return pow(a, mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= i;
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};



int main(){
  int N;
  std::cin >> N;
  std::vector<int > a(N);
  for (int i=0; i<N; i++) {
    std::cin >> a[i];
  }
  std::sort(a.begin(), a.end());
  if (a[N-1]-a[0]>=2) {
    printf("No\n");
    return 0;
  }
  
  if (a[0]==a[N-1]) {
    if (a[0]==N-1) {
      printf("Yes\n");
      return 0;
    } else if (2*a[0]<=N) {
      printf("Yes\n");
      return 0;
    } else {
      printf("No\n");
      return 0;
    }
  }

  int minnum = 0;
  int maxnum = 0;
  for (int i=0; i<N; i++) {
    if (a[0]==a[i]) minnum++;
    else maxnum++;
  }
  if (maxnum==1) {
    printf("No\n");
    return 0;
  }
  int orig = a[N-1];
  if (orig>=minnum+1 && orig <= minnum + maxnum/2) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 3036
/*
cat <<EOF >mistaken-paste
*/

#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

#define BIG 2000000007
#define VERYBIG 200000000000007LL

#define MOD 1000000007
typedef uint64_t ull;
typedef  int64_t sll;

#define N_MAX 10000
#define M_MAX 400

#ifdef __cplusplus
#include <queue>
#include <stack>
#include <tuple>

using namespace std; // I'm NOT gonna use C++ without compro. shit

typedef priority_queue<ull, vector<ull>, greater<ull> > upque123;
typedef priority_queue<ull, vector<ull> > upque321;
typedef priority_queue<sll, vector<sll>, greater<sll> > spque123;
typedef priority_queue<sll, vector<sll> > spque321;

#endif

typedef struct {
	int32_t a;
	int32_t b;
} hw;

typedef struct {
	sll a;
	sll b;
} hwll;

typedef struct {
	hwll a;
	hwll b;
} linell;


typedef struct {
	ull s;
	ull t;
	int32_t c;
} struct_a;

typedef struct {
	int32_t from;
	int32_t to;
	sll cost;
} struct_b;



const hw vector8[8] = {
	{-1, -1},
	{-1,  0},
	{-1, +1},
	{ 0, -1},
	{ 0, +1},
	{+1, -1},
	{+1,  0},
	{+1, +1}
};

ull n, m;
ull h, w;
ull k;
ull q;
ull vua, vub, vuc, vud, vue, vuf;
sll vsa, vsb, vsc, vsd, vse, vsf;
long double vra, vrb, vrc;
double vda, vdb, vdc;
size_t slen;
size_t tlen;
char ch, dh;


int32_t charcomp (const char left, const char right) {
	if (left < right) {
		return -1;
	} else if (left > right) {
		return +1;
	} else {
		return 0;
	}
}


sll dist[N_MAX];
struct_b path[M_MAX * 2];

char s[N_MAX + 1][M_MAX + 1];
char t[N_MAX + 1];

ull alphabets[26];

bool isfaster[N_MAX];
bool islater[N_MAX];

double distance (sll x1, sll y1, sll x2, sll y2) {
	double xdist2, ydist2, origindist, dist;

	xdist2 = (x1 - x2) * (x1 - x2);
	ydist2 = (y1 - y2) * (y1 - y2);
	return sqrt(xdist2 + ydist2);
}

ull solve () {
	sll i, j, ki, l;
	ull result = 0;
	ull maybe = 0;
	ull sum = 0;
	ull item;
	ull *dpcell;
	// qsortの際には"p"ullcompを使う

	for (i = 0; i < n; i++) {
		j = 0;
		while (true) {
			if (s[i][j] == '?') {
				if (!t[j]) {
					isfaster[i] = true;
					break;
				}

				if (t[j] == 'a') {
					isfaster[j] = true;
				} else if (t[j] == 'z') {
					islater[j] = true;
				} else {
					isfaster[i] = islater[i] = true;
					break;
				}
			} else {
				int c = charcomp(s[i][j], t[j]);
				if (c > 0) {
					isfaster[i] = true;
					break;
				}
				if (c < 0) {
					islater[i] = true;
					break;
				}
				if (!s[i][j] && !t[j]) {
					isfaster[i] = islater[i] = true;
					break;
				}
			}

			j++;
		}
	}

	ull minval = 1, maxval = n + 1;
	for (i = 0; i < n; i++) {
		if (!isfaster[i]) minval++;
		if (!islater[i]) maxval--;
	}

	for (i = minval; i <= maxval; i++) {
		printf("%llu%c", i, (i == maxval ? '\n' : ' '));
	}


	return 0;
}

int32_t main (void) {
	int32_t i, j;
	int32_t x, y;

	scanf("%llu", &n, &m);
	for (i = 0; i < n; i++) {
		scanf("%s", s[i]);
	}
	scanf("%s", t);

	solve();

	return 0;
}


Measured memory_bytes: 3968
#include <stdio.h>
int main(void)
{
    int a,b,i;
    char op;
    while(1)
    {
        scanf("%d %c %d",&a,&op,&b);
        if(op=='?')
            break;
        if(op=='+')
        {
            printf("%d\n",a+b);
        }
        if(op=='-')
        {
            printf("%d\n",a-b);
        }
        if(op=='*')
        {
            printf("%d\n",a*b);
        }
        if(op=='/')
        {
            printf("%d\n",a/b);
        }
    }
    return 0;
}


Measured memory_bytes: 2668
s = input()
n = len(s)
if s[-1] == '0' and s[0] == '1' and s[n - 2] == '1' and s[:n - 1] == s[n - 2 :: -1]:
    #s[i] = 「１辺を取り除いてi + 1頂点からなる連結成分を作れる」
    #連結成分のサイズは、1からn//2までチェックすれば十分
    #構成：各iに対し、iの次に1になっているbitを求める
    i = 0
    j = 1
    while j <= n - 2:
        if s[j] == '1':
            for k in range(i, j):
                print(k + 1, j + 1)
            i = j
            j = j + 1
        else:
            j += 1
    print(n - 1, n)

else:
    print(-1)


Measured memory_bytes: 47832
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    S = list(input() for _ in range(n))
    AC = S.count("AC")
    WA = S.count("WA")
    TLE = S.count("TLE")
    RE = S.count("RE")

    print("AC", "x", AC)
    print("WA", "x", WA)
    print("TLE", "x", TLE)
    print("RE", "x", RE)


if __name__ == '__main__':
    resolve()


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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int ans=0;
    for(int i=a; i<=b; ++i){
        if(c%i==0)ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3096
program main;
var
  c : char;
  s, t : string;

begin
  c := 'A';
  s := ''; t := '';
  while c <> ' ' do begin
    read(c);
    if c <> ' ' then
      s := s + c;
  end;
  while not eoln do begin
    read(c);
    t := t + c;
  end;
  writeln(t + s);
end.

Measured memory_bytes: 1388
#include <iostream>

using namespace std;

int main(void){

  int A, B;

  cin >> A >> B;

  if ((A * B * 1) % 2 == 1 || (A * B * 3) % 2 == 1 || (A * B * 3) % 2 == 1){
    cout << "Yes";
  }else{
    cout << "No";
  }

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC087A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, a, b, c;
            x = int.Parse(Console.ReadLine());
            a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());
            c = (x - a) % b;
            Console.WriteLine(c);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 11092
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   String A = sc.next();
   int s = 0;
   
   for(int i =0;i<4;i++)
   {
     if(A.charAt(i)=='+') s++;
     else s--;
   }
   
   System.out.println(s);
 }
}

Measured memory_bytes: 21844
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

const int maxn=100;
const int dx[8]={-1, -1, -1, 0, 0, 1, 1, 1};
const int dy[8]={-1, 0, 1, -1, 1, -1, 0, 1};

int n, m;
char a[maxn][maxn];

char getch()
{
	char ch;
	while ((ch=getchar())!='#' && ch!='.');
	return ch;
}
void read()
{
	scanf("%d%d", &n, &m);
	for (int i=1; i<=n; ++i)
		for (int j=1; j<=m; ++j)
			a[i][j]=getch();
}
void solve()
{
	for (int i=1; i<=n; ++i)
	{
		for (int j=1; j<=m; ++j)
		{
			if (a[i][j]=='#') { putchar('#'); continue; }
			int s=0;
			for (int k=0; k<8; ++k)
			{
				int x1=i+dx[k];
				int y1=j+dy[k];
				if (x1<1 || y1<1 || x1>n || y1>m || a[x1][y1]=='.') continue;
				++s;
			}
			putchar('0'+s);
		}
		putchar('\n');
	}
}
int main()
{
	read();
	solve();
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main(){
	int n,k,i,j,m,t,c=0;
	char s[11],a[21];
	scanf("%s %d",s,&n);
	m=strlen(s);
	for(i=0;i<n;i++){
		scanf("%s",a);
		for(j=0;j<10;j++)a[j+10]=a[j];
		t=0;
		for(j=0;j<10&& !t;j++){
			for(k=j;k<m+j;k++){
				if(s[k-j]!=a[k])break;
				if(k==m+j-1)t=1;
			}
		}
		if(t)++c;
	}
	printf("%d\n",c);
	return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define all(a) (a.begin(),a.end())
typedef long long ll;
using Graph = vector<vector<int>>;
const int INF = 1000000007;
int main(){
  char s;
  cin >> s;
  if('A' <= s && s <= 'Z')cout << "A" << endl;
  else cout << "a" << endl; 
  return 0;
}


Measured memory_bytes: 3620
l=[int(e) for e in input().split(' ')]
a=l.pop(0)
b=l.pop(0)
c=l.pop(0)

if c < (a+b):
    print('No')
    exit()


lt=4*a*b + 2*(a+b)*c
rt=c**2 + (a+b)**2

if lt < rt:
    print('Yes')
else:
    print('No')

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

using namespace std;
typedef long long ll;

ll A,B,K;

int main(){
    cin >> A >> B >> K;
    if(A >= K){
        cout << A-K << " " << B << endl;
        return 0;
    }
    if(A + B >= K){
        cout << 0 << " " << A+B-K << endl;
        return 0;
    }
    cout << 0 << " " <<  0 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Collections;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int K = sc.nextInt();
		Integer[] l = new Integer[N];
		for (int i = 0; i < N; i++)
			l[i] = sc.nextInt();
		Arrays.sort(l, Collections.reverseOrder());
		int ans = 0;
		for (int i = 0; i < K; i++)
			ans += l[i];
		System.out.println(ans);

	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 22228
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}

ll absll(ll a,ll b){
	if(a-b<0){
		return -1*(a-b);
	}else{
		return a-b;
	}
}
ll minll(ll a,ll b){
	if(a>b){
		return b;
	}else{
		return a;
	}
}
int main(){
  fastIO();
  int n;
  cin>>n;
  vector<int>cards(n);
  ll sum1=0,sum2=0;
  for(int i=0;i<n;i++){
  	cin>>cards[i];
  	sum1+=cards[i];
  }
  ll mini = 1e15;
  for(int i=0;i<n-1;i++){
  	sum1-=cards[i];
  	sum2+=cards[i];
  	mini=minll(mini,absll(sum1,sum2));
  }
  cout<<mini<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <queue>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vstr=vector<string>;

void solve() {
    ll A;
    string B;
    cin >> A >> B;
    if(A==0 || B=="0.00"){
        print(0);
        return;
    }
    ll C = (int)(B[0]-'0')*100 + (int)(B[2]-'0')*10 + (int)(B[3]-'0');
    ll ans = A * C;
    ans /= 100;
    print(ans);
}   
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}

int main(){
  int n,m,k;cin>>n>>m>>k ;
  bool ok=0 ;
  rep(i,n+1){
    rep(j,m+1){
      if(i*j+(n-i)*(m-j)==k) ok= 1 ;
    }
  }
  if(ok) cout<<"Yes"<<endl ;
  else cout<<"No"<<endl ;
      return 0;
  }
  

Measured memory_bytes: 3668
#template
def inputlist(): return [int(k) for k in input().split()]
#template
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}


N,M = inputlist()
li = [0]*M
for i in range(M):
    A,B = inputlist()
    A-=1
    B-=1
    li[i] = [A,B]
ans = [N*(N-1)//2]
uf = UnionFind(N)
for i in range(M-1,-1,-1):
    A,B = li[i][0],li[i][1]
    if uf.same(A,B):
        ans.append(ans[-1])
        continue
    tmp = ans[-1]-uf.size(A)*uf.size(B)
    ans.append(tmp)
    uf.union(A,B)
for i in range(M-1,-1,-1):
    print(ans[i])

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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

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

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}
// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";
    ll n,d;
    cin>>n>>d;
    ll cnt = 0;
    d*=d;
    for(ll i=0;i<n;i++)
    {
        ll x,y;
        cin>>x>>y;
        ll d1 = x*x + y*y;
        if(d1<=d)
            cnt++;  
    }   
    cout<<cnt<<"\n";
}

// Driver Function
int main()
{
    ll compte = 1;
   // test()
    //{
        solution(compte);
        compte++;
    //}
    return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

/**
 * Created by shoya on 2017/04/14.
 */
public class Main {
    public static void main(String... args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        final long INF = 1L << 60;
        long currentmin = INF;
        long maxpro = -INF;
        for (int i = 0; i < n; i++){
            long a = sc.nextInt();
            if (maxpro < a - currentmin)
                maxpro = a - currentmin;
            if (currentmin > a)
                currentmin = a;
        }
        System.out.println(maxpro);
        return;
    }
}

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

using namespace std;

string nine(string n){
  for(int i=0;i!=n.size();i++){
    if(n[i]=='9'){
      return "Yes";
    }
  }
  return "No";
}

int main(){
  string s;
  cin >> s;
  string ans=nine(s);
  cout << ans << endl;
}


Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
 
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>
#include<iomanip>
 
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define pii pair<int,int>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define mp(a, b) make_pair(a, b)
#define mt(a,b,c) make_tuple(a,b,c)
#define rank qwertyuio
#define next dfghjk
#define plus fsghsf
#define minus ytryr
#define pb push_back
using namespace std;
 
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
 
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int mod = (int)1e9 + 7;
const int mod1 = (int)1e9 + 9;
const int mod2 = 998244353;
const int mod3 = (int)1e6+3;
const ld eps = 1e-12;
const double pi = atan2(0, -1);
const int ABC = 26;
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 

vector<vector<int>> adj(100007);
vector<bool> visiteda(100007,false);
vector<bool> visitedt(100007,false);
vector<int> aokimove(100007);
vector<int> takamove(100007);


void DFS(int x,int dis){
    aokimove[x]=dis;
    visiteda[x]=true;
    dis++;
    for(auto i:adj[x]){
        if(!visiteda[i]){
            DFS(i,dis);
        }
    }
}
void DFS2(int y,int dis){
    takamove[y]=dis;
    visitedt[y]=true;
    dis++;
    for(auto i:adj[y]){
        if(!visitedt[i]){
            DFS2(i,dis);
        }
    }
}


int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);<<" "
    int n;
    cin>>n;
    int a,t;
    cin>>t>>a;
    a--;
    t--;
    int i;
    rep(i,0,n-1){
        int x,y;
        cin>>x>>y;
        x--;
        y--;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    DFS(a,0);
    DFS2(t,0);
    int max=-1;
    rep(i,0,n){
        //cout<<i<<" "<<takamove[i]<<" "<<aokimove[i]<<endl;
        if(takamove[i]<=aokimove[i]){

            int moves;
            if(aokimove[i]-takamove[i]%2==0){
                moves=aokimove[i]-1;
                if(moves>max){
                    max=moves;
                }
            }
            else{
                moves=aokimove[i]-1;
                if(moves>max){
                    max=moves;
                }
            }
        }
    }
    cout<<max;
    return 0;
             
    
}

Measured memory_bytes: 10368
use std::str::FromStr;
use std::collections::{HashMap,HashSet,VecDeque,BinaryHeap};
use std::cmp::{max,min,Ordering};
use std::io::Read;

fn main() {

    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut buf_it = buf.split_whitespace();

    let mut N = Vec::<isize>::new();
    for s in buf_it{
        match s {
            "+" => {
                let a = N.pop().unwrap();
                let b = N.pop().unwrap();
                N.push(a+b);
            },
            "*" => {
                let a = N.pop().unwrap();
                let b = N.pop().unwrap();
                N.push(a*b);
            },
            "-" => {
                let b = N.pop().unwrap();
                let a = N.pop().unwrap();
                N.push(a-b);
            },
            _ => {
                N.push(s.parse().unwrap());
            }
        }
    }
    println!("{}",N[0]);
}


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

template <typename T> inline void rd(T& x) {
	int si = 1; char c = getchar(); x = 0;
	while(!isdigit(c)) si = c == '-' ? -1 : si, c = getchar();
	while(isdigit(c)) x = x * 10 + c - 48, c = getchar();
	x *= si;
}
template <typename T, typename... Args>
inline void rd(T& x, Args&... args) { rd(x); rd(args...); }

#define fi first
#define se second

typedef long long ll;
typedef double ff;
typedef std::pair<int, int> pii;

const int kN = 2e5 + 5, kInf = 0x3f3f3f3f;
const ll kMod = 1e9 + 7;

ll QPow(ll a, ll b) {
	ll ans = 1, bas = a;
	for(; b; b >>= 1, bas = bas * bas % kMod) if(b & 1) ans = ans * bas % kMod;
	return ans;
}

int fa[kN], siz[kN]; ll fac[kN];
int Find(int x) { return x == fa[x] ? x : fa[x] = Find(fa[x]); }
void Merge(int x, int y) {
	int f_x = Find(x), f_y = Find(y);
	if(f_x == f_y) return;
	siz[f_x] += siz[f_y]; fa[f_y] = f_x;
}

int cm[kN], w[kN], c[kN], ccnt = 0; std::vector <int> cb[kN];
int main() {
	w[0] = kInf;
	int n, X, Y; rd(n, X, Y);
	for(int i = 1; i <= n; ++i) {
		rd(c[i], w[i]); siz[i] = 1; fa[i] = i;
		cb[c[i]].push_back(i);
	}
	if(n == 1) { printf("1"); return 0; }
	ll ans = 1, divans = 1; fac[0] = 1;
	for(int i = 1; i <= n; ++i) fac[i] = fac[i - 1] * i % kMod;
	for(int i = 1; i <= n; ++i) {
		if(!cb[i].size()) continue;
		for(auto x : cb[i]) {
			if(w[x] < w[cm[i]])
				cm[i] = x;
		}
		for(auto x : cb[i]) if(w[x] + w[cm[i]] <= X) Merge(cm[i], x);
	}
	int m1 = 0, m2 = 0;
	for(int i = 1; i <= n; ++i) {
		if(w[cm[i]] < w[m1]) m2 = m1, m1 = cm[i];
		else if(w[cm[i]] < w[m2]) m2 = cm[i];
	}
	for(int i = 1; i <= n; ++i) if(w[m1] + w[i] <= Y && c[m1] != c[i]) Merge(m1, i);
	for(int i = 1; i <= n; ++i) if(w[m2] + w[i] <= Y && c[m2] != c[i]) Merge(m2, i);
	for(int i = 1; i <= n; ++i) if(fa[i] == i) ans = ans * fac[siz[i]] % kMod;
	for(int i = 1; i <= n; ++i) {
		if(!cb[i].size()) continue;
		int cnt = 0;
		for(auto x : cb[i]) if(Find(x) == Find(cm[i])) ++cnt;
		divans = divans * fac[cnt] % kMod;
	}
	printf("%lld", ans * QPow(divans, kMod - 2) % kMod);
	return 0;
}

Measured memory_bytes: 14720
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;



int main(){
  int n, k;
  cin >> n >> k;
  int ans = 1;
  rep(i, n){
    ans = min(ans + k, ans * 2);
  }
  cout << ans << endl;
}


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

using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    string ans = "Yes";
    for(int i=0;i<s.size();i++){
    	if((i+1)%2==0 && s[i]=='R'){
    		ans = "No";
    		break;
		} 
    	if((i+1)%2!=0 && s[i]=='L'){
    		ans = "No";
    		break;
		}
	}
	cout << ans << endl;
    
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>
#include <map>
 
using namespace std;
 
int main(){
    int N;
    
    cin >> N;

    map<long, long> mp;
    mp[0] = 1;
    long long sum = 0;

    for(int i = 0; i < N; i++){
        int A;
        cin >> A;
        sum += A;
        mp[sum]++;
    }
 
    long long ans = 0;
    for(auto x : mp){
        if(x.second > 1) ans += (x.second * (x.second - 1) / 2);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 12800
data = input().split()  
n = int(data[0])
sum = 0.0

for i in range(n):
    tmp = input().split()
    tmp2 = float(tmp[0])
    if(tmp[1] == 'BTC'):
        sum += (380000.0*tmp2)
    else:
        sum += tmp2

print(sum)

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    ll N;
    cin >> N;
    string alphabets = "abcdefghijklmnopqrstuvwxyz";
    string ans;
    
    while (N > 26){
        if (N%26 - 1 < 0)ans += "z";
        else ans += alphabets[(N-1)%26];
        N -= (N-1)%26;
        N /= 26;
    }
    ans += alphabets[(N-1)%26];
    reverse(all(ans));
    cout << ans << endl;
}


Measured memory_bytes: 3620
N,A,B = list(map(int,input().split(" ")))
C = B - A
count = 0
if C % 2 == 0:
    print(str(C // 2))
else:
    count += min(A - 1,N - B)
    count += (C - 1) // 2
    print(str(count + 1))

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

int main(){
  vector<int> T(4);
  for(int i=0; i<6; i++){
    int a;
    cin >> a;
    T.at(a-1)++;
  }
  int cnt=0;
  for(int i=0; i<4; i++){
    cnt=max(cnt, T.at(i));
  }
  if(cnt==2) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	map<string,int> mp;
	rep(i,n){
		string s;
		cin>>s;
		mp[s]++;
	}
	vector<string> ans;
	int ma=0;
	for(auto itr:mp) chmax(ma,itr.se);
	for(auto itr:mp){
		if(itr.se==ma) ans.push_back(itr.fi);
	}
	sort(begin(ans),end(ans));
	cout<<ans<<endl;
}

Measured memory_bytes: 25584
"""
Writer: SPD_9X2
https://atcoder.jp/contests/arc077/tasks/arc077_c

お気に入りを決めてる時、その数字を超えるような移動が発生した場合だけ、ボタン2が有効になる。
ALLボタン１に比べて、何回節約できるかをimos法で計算する

"""

n,m = map(int,input().split())

lis = [0] * m

state = [0] * n

a = list(map(int,input().split()))
for i in range(n):
    a[i] -= 1

start = [ [] for i in range(m) ]
end = [ [] for i in range(m)]

allsum = 0
for i in range(n-1):

    allsum += (a[i+1]-a[i]) % m
    if a[i+1] == (a[i]+1)%m:
        continue

    start[(a[i]+1) % m].append(i)
    end[a[i+1] % m].append(i)

    


imosnum = 0
plus = 0

#print (start,end)

for i in range(2*m):

    plus += imosnum

    lis[i%m] += plus

    for j in end[i%m]:
        if state[j] == 1:
            plus -= ((a[j+1]-(a[j]+1))%m)
            state[j] = 2
            imosnum -= 1

    for j in start[i%m]:
        if state[j] == 0:
            imosnum += 1
            state[j] = 1

    #print (i+1,imosnum,plus)

if (allsum - max(lis) < 0):
    print (asxacscd)
#print (lis)
print (allsum - max(lis))

Measured memory_bytes: 76268
#include<bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
using vpi = vector<pi>;
const ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define M(x) ((x)%mod)
ll bp(ll x, ll p) {
	ll res = 1;
	while(p) {
		if(p&1) res=(res*x)%mod;
		x=(x*x)%mod;
		p>>=1;
	}
	return res;
}
ll n, f[200100];
void setup() {
	f[1]=1;
	for(int i = 2; i <= 200000; i++)
		f[i] = M(f[i-1]+bp(i, mod-2));
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll ans = 0;
	ll n, t, c;
	setup();
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> t;
		c = M(f[i]+f[n-i+1]-1);
		ans = M(ans + M(c*t));
	}
	for(int i = 1; i <= n; i++)
		ans = M(ans*i);
	cout << ans;
}


Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define fi first
//#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<int> ps(N), qs(N);
  F0R(i, N) cin >> ps[i];
  F0R(i, N) cin >> qs[i];

  vector<int> ns(N);
  iota(rng(ns), 1);
  
  int a = -1, b = -1;
  for (int i = 0; true; i++) {

    if (a < 0) {
      bool same = true;
      F0R(i, N) {
        if (ns[i] != ps[i]) {
          same = false;
          break;
        }
      }
      if (same) {
        a = i;
        if (b >= 0) break;
      }
    }
    if (b < 0) {
      bool same = true;
      F0R(i, N) {
        if (ns[i] != qs[i]) {
          same = false;
          break;
        }
      }
      if (same) {
        b = i;
        if (a >= 0) break;
      }
    }

    if (!next_permutation(rng(ns))) break;
  }

  cout << abs(a - b);
}
#endif


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='P'){
            cout << 'P';
        }else if(s[i]=='D'){
            cout << 'D';
        }else{
            cout << 'D';
        }
    }
}


Measured memory_bytes: 3752
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b == c || a == b + c || a + c == b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
	string S;
	cin >> S;
	ll n=S.size();
	ll i;
	for(i=0;i<n;i++){
		if(i%2==0&& S[i]=='L'){
			cout << "No";
			return 0;
		}
		if(i%2==1&& S[i]=='R'){
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i,N) cin >> A[i];  
    RSORT(A);
    ll ans = 0;
    priority_queue<ll> p;
    REP(i, N){
        if(i==0) {
            p.push(A[i]);
        }else{
            // ans += max(A[i], (ll)(i>1?A[i-1]:0));
            ans += p.top();p.pop();
            p.push(A[i]);
            p.push(A[i]);
        }
    }
    pr(ans);
}

Measured memory_bytes: 6864
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		String anss = "";
		
		for(int i = 0; i<s.length(); i++) {
			anss += (char)((int)s.charAt(i) + n > 90 ? (int)s.charAt(i) + n - 26 : (int)s.charAt(i) + n);
		}
		System.out.println(anss);
	}

}


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

int main()
{
	int n;
	while(cin>>n){
		if(n==0) break;
		vector<char> ans;
		map<char,char> M;
		for(int i=0;i<n;i++){
			char in,out;
			cin>>in>>out;
			M[in]=out;
		}
		
		int k;
		cin>>k;
		for(int i=0;i<k;i++){
			char s;
			cin>>s;
			if(!M.count(s)){
				ans.push_back(s);
			}
			else ans.push_back(M[s]);
		}
		for(int i=0;i<ans.size();i++)
			cout<<ans[i];
		cout<<endl;
	}
	return 0;

}

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

int main (){

  string s;
  cin >> s;
  string ans;
  int size = s.size();
  
  for(int i; i<size; i++){
  	if(s.at(i) == '0'){
    	ans +='0';
    }
    else if(s.at(i) == '1'){
    	ans +='1';
    }
    else {
    	if(!ans.empty()){
          ans.pop_back();
        }
    }
  }
  
   
   
    cout << ans << endl;
}

Measured memory_bytes: 256
from sys import stdin

def main():
    S = input()

    prev, now = S[0], ''
    ans = 1
    for i in range(1, len(S)):
        now += S[i]
        if prev != now:
            ans += 1
            prev, now = now, ''
    print(ans)

input = lambda: stdin.readline().rstrip()
main()


Measured memory_bytes: 3628
A ,B = map(int, input().split())
G = 0
if A == 1:
  G += 300000
elif A == 2:
  G += 200000
elif A == 3:
  G += 100000
if B == 1:
  G += 300000
elif B == 2:
  G += 200000
elif B == 3:
  G += 100000
if A == 1 and B == 1:
  G += 400000
print(G)

Measured memory_bytes: 3060