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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    int h, w, k;
    ll ans = 0;
    cin >> h >> w >> k;
    vector<string> a(h);
    for(int i = 0; i < h; i++) cin >> a[i];
    // {0, 1, ..., n-1} の部分集合の全探索
    for (int bit = 0; bit < (1<<(h+w)); ++bit) {
        vector<string> tmp(a);
        /* bit で表される集合の処理を書く */
        for(int i = 0; i < h; i++){
            if(bit & (1<<i)){
                // 立っているbit
                for(int j = 0; j < w; j++){
                    tmp[i][j] = '.';
                }
            }
        }
        for(int i = 0; i < w; i++){
            if(bit & (1<<(h+i))){
                // 立っているbit
                for(int j = 0; j < h; j++){
                    tmp[j][i] = '.';
                }
            }
        }
        ll cnt = 0;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(tmp[i][j] == '#') cnt++;
            }
        }
        if(cnt == k) ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> c(n-1), s(n-1), f(n-1);
    rep(i, n-1)cin >> c[i] >> s[i] >> f[i];
    for(int i = 0; i < n; i++){
        int now = 0;
        for(int j = i; j < n-1; j++){
            if(now < s[j])now = s[j];
            else if(now % f[j] == 0);
            else now += f[j] - now % f[j];
            now += c[j];
        }
        cout << now << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    int N; cin >> N;
    vector<vector<int>> A(N, vector<int>(N-1));
    
    for(int i=0; i<N; i++){
        for(int j=0; j<N-1; j++){
            int a; cin >> a;
            a--;
            A[i][j] = a;
        }
    }
    
    vector<int> cur(N);
    set<PII> S;

    auto Add = [&](int i){
        if(cur[i]==N-1) return;
        int j = A[i][cur[i]];
        if(A[j][cur[j]]==i){
            if(i>j) swap(i, j);
            S.insert({i, j});
        }
    };
    
    for(int i=0; i<N; i++) Add(i);
    
    int cnt = 0;
    while(S.size()!=0){
        cnt++;
        set<PII> PrevS;
        swap(PrevS, S);
        for(PII p:PrevS){
            int i = p.fs;
            int j = p.sc;
            cur[i]++;
            cur[j]++;
        }
        
        for(PII p:PrevS){
            int i = p.fs;
            int j = p.sc;
            Add(i);
            Add(j);
        }
    }
    
    for(int i=0; i<N; i++){
        if(cur[i]!=N-1){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << cnt << endl;
    return 0;
}



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

int main() {
  queue<int>que;
  int n;
  cin >> n;
  ll ans = 0;
  vector<int>a(n);
  rep(i,0,n) cin >> a[i];
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  que.push(a[0]);
  rep(i,1,n){
    int v = que.front();
    que.pop();
    ans += v;
    que.push(a[i]);
    que.push(a[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4776
#include<stdio.h>
#include<stdlib.h>

int compare_int(const void *a,const void *b){
  return *(int*)a - *(int*)b;
}

int main(void)
{
  long int n,k,i,p;
  long int h[200001];
  scanf("%ld %ld\n",&n,&k);
  for(i=0;i<=n-1;i++){
    scanf("%ld",&h[i]);
  }
  
  p=0;
  
  if(n>k){
    qsort(h,n,sizeof(long int),compare_int);
    for(i=0;i<=n-k-1;i++){
      p=p+h[i];
    }
  }else{
    p=0;
  }
  
  printf("%ld",p);
  
  return 0;
}

Measured memory_bytes: 3324
h, w = map(int, input().split())
s = []
sh = 0
for i in range(h):
  t = input()
  sh += t.count('#')
  s.append(t)

visited = [[False for j in range(w)] for i in range(h)]

dx = [0,1]
dy = [1,0]
def dfs(x,y,cnt):
  visited[x][y] = True
  cnt += 1
  if x == h-1 and y == w-1:
    if cnt == sh:
      print ('Possible')
      exit()
    return
  for i in range(2):
    a = x+dx[i]
    b = y+dy[i]
    if a < 0 or b < 0 or a >= h or b >= w or visited[a][b] or s[a][b] == '.':
      continue
    dfs(a,b,cnt)

dfs(0,0,0)

print ('Impossible')

Measured memory_bytes: 9248
from sys import stdin, stdout, stderr

a = [0] * 50

while 1:
    n, p = map(int, stdin.readline().split())

    if n + p == 0:
        break

    wan = p
    i = 0

    while a[i] < p:
        if wan > 0:
            a[i] += 1
            wan -= 1
        else:
            wan += a[i]
            a[i] = 0

        i = (i + 1) % n

    print(i)
    a[i] = 0

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

int main(void){
	int H,W;
	cin >> H >> W;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			string s;
			cin >> s;
			if( s == "snuke" ){
				cout << (char)(j + 'A');
				cout << i+1 << endl;
			}
		}
	}

	return 0;
}

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


int main(void){
	int n,q;
	cin>>n>>q;
	vector<vector<int> > tree(n+1);
	rep(i,n-1){
		int a,b;
		cin>>a>>b;
		//cout<<a<<" "<<b<<endl;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}
	ll score[n+1];
	rep(i,n)score[i+1]=0;
	rep(i,q){
		int p,x;
		cin>>p>>x;
		//cout<<p<<" "<<x<<endl;
		score[p]+=x;
	}

	vector<int> mask(n+1);
	queue<int> que;
	
	ll ans[n+1];
	rep(i,n){
		mask[i+1] = 0;
		ans[i+1] = 0;
	}
	que.push(1);
	mask[1] = 1;
	ans[1] = score[1]; 

	while(!que.empty()){
		int id=que.front();
		//cout<<"node:"<<id<<endl<<"child is ";
		que.pop();
		rep(i,tree[id].size()){
			if(mask[tree[id][i]] == 0){
				//cout<<tree[id][i]<<" ";
				que.push(tree[id][i]);
				mask[tree[id][i]] = 1;
				score[tree[id][i]]+=score[id];
			}
		}
		//cout<<endl;
	}
	rep(i,n)cout<<score[i+1]<<endl;
	return 0;
}


Measured memory_bytes: 18760
#include<bits/stdc++.h>
using namespace std;
int main(){
	int suck;
	cin>>suck;
	if(suck<=1199)
	cout<<"ABC";
	else
	if(suck<=2799)
	cout<<"ARC";
	else
	if(suck>2799)
	cout<<"AGC";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1N(i,n) for(int i=1;i<=n;i++)
#define pd push_back
#define eb emplace_back
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
typedef unsigned long long ull ;
typedef long long ll ;
using namespace std ;


int main()
{
  int x, a ;
  cin >> x >> a ;
  
  cout << ( x < a ? 0 : 10 ) << endl ;
  
  return 0 ;
}

Measured memory_bytes: 256
var GET = (function(){
  function f(s){return new g(s);}
  function g(s){this._s=s.trim().split("\n");this._y=0;}
  g.prototype.a = function(f){
    var s = this._s, y = this._y, r;
    if(typeof s[y] === "string")s[y]=s[y].split(" ").reverse();
    r = s[y].pop();
    if(!s[y].length)this._y++;
    return f?r:+r;
  }
  g.prototype.l = function(f){
    var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);
  }
  g.prototype.m = function(n,f){
    var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));
    return f?r:r.map(a=>a.map(a=>+a));
  }
  g.prototype.r = function(n,f){
    var r = this._s.slice(this._y,this._y+=n);
    return f?r:r.map(a=>+a);
  }
  return f;
})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var t = [5,5,3], ans = 0;
  while(1){
    t = make(t);
    var f = check(t,n);
    if(f === 1)ans++;
    else if(f === -1)break;
  }
  return ans;
  function make(t){
    for(var i = 0; i < t.length; i++){
      if(t[i] === 3){t[i] = 5; break;}
      if(t[i] === 5){t[i] = 7; break;}
      t[i] = 3;
    }
    if(i === t.length)t[i] = 3;
    return t;
  }
  function check(t,n){
    if(+[...t].reverse().join("") > n)return -1;
    var a = 0;
    for(var i = 0; i < t.length; i++){
      if(t[i] === 3)a |= 4;
      else if(t[i] === 5)a |= 2;
      else if(t[i] === 7)a |= 1;
    }
    if(a === 7)return 1;
    return 0;
  }
}

Measured memory_bytes: 11040
if __name__ == "__main__":
    n = int(input())
    s = input()

    ans = 0

    for i in range(n - 2):
        if s[i] == 'A' and s[i + 1] == 'B' and s[i + 2] == 'C':
            ans += 1

    print(ans)

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

#define MAX_V 105

int main(){
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    int a[n][m];
    int ans = 0;

    REP(i, m) cin >> b[i];
    REP(i, n) REP(j, m) cin >> a[i][j];

    REP(i, n) {
        int tmp = 0;
        REP(j, m) {
            tmp += b[j] * a[i][j];
        }
        if(tmp + c > 0) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST

template <typename T>
inline T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}

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

ll nlcm(vector<ll> numbers) {
    ll res;
    res = numbers[0];
    for (ll i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N;
    cin >> N;
    vector<ll> T(N);
    for(size_t i=0;i<N; i++)
    {
        cin >> T[i];
    }

    cout << nlcm(T) << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (int &ai: a) cin >> ai;
    long long cnt = 0;
    int right = 0, sum = 0;
    for (int left = 0; left < n; left++) {
        while (right < n && (sum ^ a[right]) == (sum + a[right])) sum += a[right++];
        cnt += right - left;
        sum -= a[left];
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

#define WHOLE_OHAJIKI 32

int main(void) 
{
	int l;
	int *order;
	int i;
	int rest;

	while (scanf(" %d", &l), l != 0) {
		order = (int *) malloc(sizeof(int) * l);
		rest  = WHOLE_OHAJIKI;

		for (i = 0; i < l; i++) {
			scanf(" %d", &order[i]);
		}

		for (i = 0; rest != 0; i++) {
			rest -= (rest - 1) % 5;
			printf("%d\n", rest);
			rest -= order[i % l];

			if (rest < 0) {
				rest = 0;
			}

			printf("%d\n", rest);
		}
		free(order);
	}
	return 0;
}

Measured memory_bytes: 600
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        if (S.length()%2 == 1) {
            System.out.println("No");
            return;
        }

        boolean ans = true;
        for (int i = 0; i < S.length(); i+=2) {
            if (S.charAt(i) != 'h' || S.charAt(i+1) != 'i') {
                ans = false;
                break;
            }
        }

        System.out.println(ans ? "Yes" : "No");
    }
}


Measured memory_bytes: 22228
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

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

    vector<int> A(1);
    for (char x: S)
        if (x=='0')
            A.push_back(0);
        else
            A.back()++;

    int n = (int)A.size();
    int n1 = 0;
    for (char x: S)
        if (x=='1')
            n1++;
    K = min(K, n1);

    long long M = 998244353;
    vector<vector<long long>> T(K+1, vector<long long>(n1+1));
    T[0][0] = 1;
    for (int i=n-1; i>=0; i--)
    {
        vector<vector<long long>> P(K+1, vector<long long>(n1+1));
        P.swap(T);
        for (int j=0; j<=K; j++)
            for (int k=0; k<=K; k++)
                //if (P[j][k]>0)
                    for (int l=0; l<=n1; l++)
                    {
                        int j2 = j+max(A[i]-l, 0);
                        int k2 = k+A[i]-l;
                        if (j2<=K && 0<=k2)
                        {
                            T[j2][k2] += P[j][k];
                            T[j2][k2] %= M;
                        }
                    }
    }
    long long ans = 0;
    for (int i=0; i<=K; i++)
        ans += T[i][0];
    cout<<ans%M<<endl;
}


Measured memory_bytes: 4480
#include "bits/stdc++.h"
using namespace std;
#define fst first
#define scd second
vector<vector<pair<bool, int>>> a;
vector<bool> vis;
void calc(int ind)
{
	if(vis[ind])
	{
		return;
	}
	vis[ind] = true;
	for(int i = 0; i < a[ind].size(); ++i)
	{
		calc(a[ind][i].scd);
	}
}
int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	a.resize(n, vector<pair<bool, int>>(0));
	vis.resize(n);
	for(int i = 0, x, y, z; i < m; ++i)
	{
		scanf("%d%d%d", &x, &y, &z);
		a[x - 1].push_back(make_pair(z % 2, y - 1));
		a[y - 1].push_back(make_pair(z % 2, x - 1));
	}
	int ans = 0;
	for(int i = 0; i < n; ++i)
	{
		if(!vis[i])
		{
			calc(i);
			++ans;
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 8832
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> p;
typedef pair<p,p> P;

char mp[60][30];
int w,h;
int cal(){
  bool used[2][60][30]={};
  int dx[9]={1,1,1,1,1,2,2,2,3},dy[9]={2,1,0,-1,-2,1,0,-1,0};
  priority_queue<P,vector<P>,greater<P> > q;
  for(int i=0;i<w;i++)
    if(mp[h-1][i]=='S')q.push(P(p(0,0),p(i,h-1))),q.push(P(p(0,1),p(i,h-1)));
  while(!q.empty()){
    int s=q.top().first.first,l=q.top().first.second;
    int x=q.top().second.first,y=q.top().second.second;
    q.pop();
    if(mp[y][x]=='T')return s;
    if(used[l][y][x]||mp[y][x]=='X')continue;
    used[l][y][x]=1;
    int f=1,c=0;
    if(l)f=-1;
    if(isdigit(mp[y][x]))c=mp[y][x]-'0';
    for(int d=0;d<9;d++){
      int nx=x+f*dx[d],ny=y+f*dy[d];
      if(nx<0||w<=nx||ny<0||h<=ny)continue;
      q.push(P(p(s+c,!l),p(nx,ny)));
    }
  }
  return -1;
}

int main(){
  while(cin>>w>>h,w){
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)cin>>mp[i][j];
    cout<<cal()<<endl;
  }
  return 0;
}

Measured memory_bytes: 3104
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    // 数値の配列を作る
    const numList = input.map(x => parseInt(x, 10));
 
    // １番大きい数
    const biggestNum = numList[4];
    // 1番小さい数
    const smallestNum = numList[0];
    // k
    const k = numList[5];
    if (smallestNum + k < biggestNum) {
        console.log(':(');
    } else {
        console.log('Yay!');
    }
 
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <iomanip>
#include <sstream>

using namespace std;
using ll = long long;

// inf
constexpr ll infl = 1LL << 60;
constexpr int inf = 1 << 30;

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

    int l = 0, r = 0, cnt = 0;
    char prev = '1';
    int ans = 0;
    while (l < N) {
        for (; r < N; ++r) {
            if (prev == '1' && S[r] == '0') ++cnt;
            prev = S[r];

            if (cnt > K) break;
        }

        ans = max(ans, r - l);

        if (l < N - 1 && S[l] == '0' && S[l + 1] == '1') --cnt;
        ++l;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
n,k=map(int,input().split())


#例）n=4
#10**100+0、10**100+1、10**100+2、10**100+3、10**100+4
#組み合わせる数をkkとすると
#kk=1
#10*100+（0+1+2+3+4)
#kk=2
#2*10**100 +(1+2+3+4+5+6+7)  ※1は小さいほうの組み合わせ0+1、7は大きいほうの組み合わせ3+4
#kk=3
#3*10**100 +(3+4+5+6+7+8+9) ※3は0+1+2、9は2+3+4
#kk=4
#4*10**100 +(6+7+8+9+10) 
#kk=5
#5*10**100 +(10)

underSum=[0]
upSum=[n]
for i in range(1,n+1):
    underSum.append(underSum[-1]+i)
    upSum.append(upSum[-1]+n-i)

result=0

mod=10**9+7


for i in range(k-1,n+1):
    #print(i)
    result=(result+upSum[i]-underSum[i]+1)%mod

print(result)


Measured memory_bytes: 94908
#include "bits/stdc++.h"
 
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<VVLL> VVVLL;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORL(i,a,b) for(LL i=(a);i<(b);++i)
#define REPL(i,n)  FORL(i,0,n)
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);

 //debug func
template<typename T>
void vprint(vector<T> v) {
    for(auto x : v) {
        cerr << x << " ";
    }
    cerr << endl;
}
 
template<typename T>
void vvprint(vector<vector<T>> vv) {
    REP(i, SIZE(vv)) {
        REP(j, SIZE(vv[i])) {
            cerr << vv[i][j] << " ";
        }
        cerr << endl;
    }
}

template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}

inline double get_time_sec(void){
    return static_cast<double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count())/1000000000;
}

template<typename T>
T gcd(T a, T b) {
    if(a > b) swap(a, b);
    if(a == 0) return b;
    else return gcd(b%a, a);
}

template<typename T>
T lcm(T a, T b) {
    return (a / gcd(a, b)) * b;
}

template<typename T>
map<T, T> prime_list(T n) {
    map<T, T> ret;
    for(T i = 2; i*i <= n; i++) {
        if(n % i == 0) {
            ret[i] = 0;
            while(n % i == 0) {
                n /= i;
                ret[i]++;
            }
        }
    }
    if(n != 1) ret[n]++;
    return ret;
}

#define MOD 1000000007

LL mypow(LL a, LL n) {
    if(n == 1) return a % MOD;
    if(n % 2 == 1) return (a * mypow(a, n-1)) % MOD;
    LL t = mypow(a, n/2);
    return (t * t) % MOD; 
}

int main(void) {
    int n;
    cin >> n;
    map<string, int> m;
    REP(i, n) {
        string s;
        cin >> s;
        if(!m.count(s)) m[s] = 1;
    }
    int ans = 0;
    for(auto x : m) {
        ans++;
    }
    cout << ans << endl;
}

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

#define int long long

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 9999999999
 
using namespace std;

int32_t main(){
    int n, a, b;
    cin >> n >> a >> b;
    string A="Alice", B="Borys";

    if(a==1 && b==2){
        cout << B << endl;
        return 0;
    }

    if((b-a)%2){
        cout << B << endl;
    }
    else{
        cout << A << endl;
    }
}

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

int main(void){
  int N, A, B, x[2];
  bool ans;
  cin >> N >> A >> B;
  x[0] = N * A;
  x[1] = B;
  if(x[0] < x[1])
    ans = true;
  else
    ans = false;
  if(ans) cout << x[0] << "\n";
  else cout << x[1] << "\n";
  return 0;
}


Measured memory_bytes: 3636
use std::io;
use std::cmp;


fn main() {
    let (a, b) = {
        let i = read::<isize>();
        (i[0], i[1])
    };

    println!("{}", cmp::max(cmp::max(a + b, a - b), a * b));
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#
# 10c
#
import math


def main():
    while True:
        n = int(input())
        if n == 0:
            break
        s = list(map(int, input().split()))
        m = sum(s) / n
        aan = 0
        for i in range(n):
            aan += (s[i] - m)**2
        print(f"{math.sqrt(aan/n):.4f}")


if __name__ == '__main__':
    main()



Measured memory_bytes: 5724
///Nahid Hasan Raju
#include <bits/stdc++.h>
#define ll long long
#define MS(ARRAY,VALUE) memset(ARRAY,VALUE,sizeof(ARRAY))
#define Fin freopen("input.txt","r",stdin)

#define P(XX) cout<<XX<<endl
#define P1(XX) cerr<<"db1: "<<XX<<endl
#define P2(XX,YY) cerr<<"db2: "<<XX<<" "<<YY<<endl
#define P3(XX,YY,ZZ) cerr<<"db3: "<<XX<<" "<<YY<<" "<<ZZ<<endl
using namespace std;
ll m, n;
ll a[205],b[205],c[205],B[205];//o[205][205];


int main()
{
    int test=1, tc=0;
    int  i, j;
    #ifndef ONLINE_JUDGE
    Fin;
    test=1;
    #endif
    ll k, ans,x,y;
    //scanf("%d", &test);
    while(test--)
    {
        j=0;
        ans=0;
        k=0;
        ll p;
        cin>>x>>k>>y;

        x=abs(x);

        p=x/y;
        //if(x%y!=0)p++;
        if(p>=k)
        {
            //P1("ok1");
            ans=abs(x-(k*y));
        }
        else{
                //P1("ok");
            p=x/y;
            k-=p;
            x-=(p*y);
            //P2(x,p);
            if(k%2==0)
            {
                //P1("oo");
                ans=x;
            }
            else{
                //P1("NO");
                ans=abs(x-y);
            }
        }
        P(ans);
    }
    return 0;
}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n, k;
  cin >> n >> k;
  long double max = -1;  
  
  vector<ll> p(n);
  vector<ll> s(n+1, 0);
  rep(i, 0, n)  {
    cin >> p.at(i);
    s.at(i+1) = s.at(i) + p.at(i);
  }
  
  rep(i, 0, n-k+1) {
    if(s.at(i+k) - s.at(i) > max)
      max = s.at(i+k) - s.at(i);
  }
  
  double ans = (max +k)/2;
  
  cout << setprecision(10) << ans << "\n";

}


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

int main()
{
    int n;
    cin >> n;
    vector<int> vec(n+1);
    map<int, int> m;
    for(int i = 1; i <= n; ++i)
    {
        int t;
        cin >> t;
        vec[i] = t;
        m[i-t] += 1;
    }

    long long ans = 0;
    for(int i = 1; i <= n; ++i)
    {
        ans += m[i+vec[i]];
    }
    cout << ans << endl;
}

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

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

    ll k;
    cin>>k;
    k--;

    int fi= -1;
    for(int i=0;i<x.length();i++) {
        if(x[i] != '1') {
            fi = i;
            break;
        }
    }
    
    if(fi==-1){
        cout<<"1";
        return 0;
    }

    if(k < fi) {
        cout<<"1";
    }
    else {
        cout<<x[fi]<<"\n";
    }


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	double a_d,b_d;
	scanf("%d %d",&a,&b);
	a_d = static_cast<double>(a);
	b_d = static_cast<double>(b);
	printf("%d %d %.5f\n",a/b,a%b,a_d/b_d);
}



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

int main() {
    int n, k;
    cin >> n >> k;
    int x[n];
    for(int i = 0; i < n; i++) {
        cin >> x[i];
    }

    int q[n];
    int A = 0;
    for(int i = 0; i < n; i++) {
        q[i] = min(x[i], abs(k-x[i]));
        A += 2*q[i];
    }

    cout << A << endl;


}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
    string S;

int main(){
    ios_base::sync_with_stdio(false);
    cin>>S;
    int siz=S.size();
    REP(i,siz){
        //奇数文字列 or 一文字も消していない場合は当てはまらないためスキップ
        // siz-i = 今見ている文字列の長さ
        if( (siz-i)%2==1 || i==0 ){
            continue;
        }
        // 初めから (siz-i)/2 文字分をaとする
        // 同じく、aの後ろから(siz-i)/2 文字分をbとする
        // abcabcd siz-i=6のとき a=abc b=abc のように
        string  a=S.substr(0,((siz-i)/2)),
                  b=S.substr((siz-i)/2,(siz-i)/2);
        // a==b なら条件を満たす。
        if(a == b){
            cout<<siz-i;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
N=int(input())
dp=[[0]*N for i in range(3)]
for i in range(N):
    a,b,c=list(map(int,input().split()))
    if(i==0):
        dp[0][i]=a
        dp[1][i]=b
        dp[2][i]=c
    else:
        dp[0][i]=max(dp[1][i-1],dp[2][i-1])+a
        dp[1][i]=max(dp[0][i-1],dp[2][i-1])+b
        dp[2][i]=max(dp[0][i-1],dp[1][i-1])+c
print(max(dp[i][N-1] for i in range(3)))

Measured memory_bytes: 77444
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>

int main()
{
  int n;
  std::cin>> n;
  std::vector<std::pair<int, int>> vec;
  std::vector<int> city;
  for (int i = 0; i < n; i++)
  {
    int x, y;
    std::cin >> x>>y;
    vec.push_back(std::make_pair(x, y));
    city.push_back(i);
  }
  double sum_dist = 0;
  int count = 0;
  do{
    double dist = 0;
    for (int i = 1; i < city.size(); i++)
    {
      double dx = vec[city[i]].first - vec[city[i-1]].first;
      double dy = vec[city[i]].second - vec[city[i-1]].second;
      dist += std::sqrt(dx*dx+dy*dy);
    }
    sum_dist += dist;
    count ++;
  }while(std::next_permutation(city.begin(), city.end()));
  std::cout << std::setprecision(10)<<sum_dist/count << std::endl;
}


Measured memory_bytes: 256
def calculate(l,r):
    K = 2019

    min = r*r

    if r > l + K * 2:
        r = l + K * 2

    for i in range(l,r+1):
        for j in range(i+1,r+1):
            ret = (i*j) % K
            if ret < min:
                min = ret
                if min == 0:
                    return min

    return min

S = input().split()

L = int(S[0])
R = int(S[1])

print(calculate(L,R))




Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define f first
#define sec second
#define pb push_back
#define pf push_front
#define po pop_back
#define fast ios_base::sync_with_stdio(false)
#define vi vector<ll>
#define vii vector< pair<ll,ll> >
#define pi pair<ll,ll>
#define map map<ll,ll>
#define set set<ll>
#define tostr to_string
#define toint stoi
#define gcd __gcd


int main()
{
    fast;
    ll n,i;
    cin>>n;
    if(n%2!=0)
     cout<<0<<endl;
    else
    {
        ll ans=0;
        n=n/2;
        while(n>0)
        {
          ans+=n/5;
          n=n/5;
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())

robo_dic = {}
for i in range(N):
    X, L = map(int, input().split())
    robo_dic[X] = L

robo_list = sorted(robo_dic.keys())

max_place = robo_list[0] + robo_dic[robo_list[0]]
ans = 1
for i in range(1, len(robo_list)):
    x = robo_list[i]
    l = robo_dic[x]
    if max_place <= x - l:
        ans += 1
        max_place = x + l
    else:
        max_place = min(max_place, x + l)
print(ans)

Measured memory_bytes: 17892
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = -1001001001001001001;
    ans = max(ans, a*c);
    ans = max(ans, a*d);
    ans = max(ans, b*c);
    ans = max(ans, b*d);
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3628
X, N = map(int, input().split())
if N != 0:
  p = set(map(int, input().split()))
  for i in range(N):
    if X - i not in p:
      print(X - i)
      break
    elif X + i not in p:
      print(X + i)
      break
  else:
    print(X - i - 1)
else:
  print(X)

Measured memory_bytes: 9208
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"charmap.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0xff,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
	string s;
	cin>>s;
	if(s=="Sunny"){
		cout<<"Cloudy";
	}
	else if(s=="Cloudy"){
		cout<<"Rainy";
	}
	else{
		cout<<"Sunny";
	}
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long 
#define int ll
//#define slld(t) scanf("%lld",&t)
// #define sd(t) scanf("%d",&t)
// #define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define pdd pair<double , double>
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N    105
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
#define s3   1.73205080757          // square root 3
const  int inf = (int)1e18+10 ;
const int MAX= 100;

 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ordered_set S;

int powmod(int x , int y){
	int res = 1;
	while(y > 0){
		if(y%2==1)
			res = (res*x)%mod;
		x = (x*x)%mod;
		y/=2;
	}
	return res;
}
int mul(int x , int y){
	return (x*y)%mod;
}



signed main(){
  fast;
 
 
	 string s , t;
	 cin >> s >> t;
	 cout << t + s << endl;
 



 }

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main()
{
    int n,k;
    string s[11],rep,tmp;
    cin >> n;
    cin >> tmp;
    for(int i=1;i<=n;i++)
        s[i]=tmp[i-1];
    cin >> k;
    rep=s[k];
    for(int i=1;i<=n;i++)
        if(s[i]!=rep) s[i]="*";
    for(int i=1;i<=n;i++)
        cout << s[i];
    cout << endl;
    return 0;
}

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

int main (void){
  std::string S; std::cin >> S;

  int bw = 0, wb = 0;
  for(int i=0; i<S.size(); i++){
    if ( i % 2 == 0 ){
      if ( S[i] == '1' ) bw++;
      if ( S[i] == '0' ) wb++;
    }
    if ( i % 2 == 1 ){
      if ( S[i] == '0' ) bw++;
      if ( S[i] == '1' ) wb++;
    }
  }

  std::cout << std::min (bw, wb) << std::endl;
  return 0;
}

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

using namespace std;

#define F first
#define S second
#define MAX_N 1e5+10
#define inf 10000000

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vbl;

int main() {
  int n, k;
  cin >> n >> k;
  int h[n+1], dp[n+1];
  for (int i = 1 ; i <= n ; i++) {
    cin >> h[i];
    dp[i] = -1;
  }
  dp[1] = 0;
  for (int i = 2 ; i <= n ; i++) {
    for (int j = i-1 ; j >= i-k && j >= 1 ; j--) {
      if (dp[i] == -1 || dp[i] > dp[j]+abs(h[i]-h[j])) {
        dp[i] = dp[j]+abs(h[i]-h[j]);
      }
    }
  }

  cout << dp[n] << endl;

  return 0;
}

Measured memory_bytes: 1024
require 'prime'
loop do
    n, x = gets.split.map(&:to_i)
    break if n == 0
    a = (1..n).map { gets.to_i }.sort
    t = Array.new(x + 1, false)
    t[0] = true
    (0..x).each do |i|
        next if !t[i]
        a.pop while !a.empty? && a[-1] + i > x
        a.each do |j|
            t[i + j] = true
        end
    end
    ans = nil
    x.downto(1) do |i|
        if t[i] && Prime.prime?(i)
            ans = i
            break
        end
    end
    puts ans ? ans : 'NA'
end



Measured memory_bytes: 116344
def daydream(S: str) -> bool:
    while True:
        if S.endswith('dream'):
            S = S[:-5]
        elif S.endswith('dreamer'):
            S = S[:-7]
        elif S.endswith('erase'):
            if S[:-5].endswith('eras'):
                S = S[:-4]
            else:
                S = S[:-5]
        elif S.endswith('eraser'):
            if S[:-6].endswith('eras'):
                S = S[:-5]
            else:
                S = S[:-6]
        else:
            break

    return S == ''


if __name__ == "__main__":
    S = input()
    ans = daydream(S)
    print('YES' if ans else 'NO')


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
bool p(int N)
{
    char buf[20];
    sprintf(buf, "%d", N);
    string s = buf;
    string q(s.rbegin(), s.rend());
    return s==q;
}
int main()
{
    int A, B;
    scanf("%d%d", &A, &B);
    int cnt = 0;
    for(int i=A; i<=B; ++i)
        if(p(i)) ++ cnt;
    printf("%d\n", cnt);

}

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

int main()
{
	while (1) {
		int a, b;
		cin >> a >> b;
		if (!a&&!b)break;
		vector<int>s(a);
		for (int b = 0; b < a; b++)
		{
			int c;
			cin >> c;
			s[b] = c;
		}
		int m = 0;
		int l = 0;
		vector<int>r(b);
		for (int j = 0; j < b; j++) {
			int w;
			cin >> w;
			r[j] = w;
		}
		while (1) {
			l++;
			int d;
			d = r[l - 1];
			m += d;		
			if (m >= (a - 1)) { cout << l << endl; break; }
			m += s[m]; 
			if (m >= (a - 1)) { cout << l << endl; break; }
		}
	}
}

Measured memory_bytes: 3028
s = input()

m = []
for i in s:
  m.append(i)
n = len(s)
n1 = int((n-1)/2)
n2 = int((n+3)/2)
ans = 0

for i in range(n1):
  if m[i] != m[n-1-i]:
    print('No')
    break
  else:
    if m[i] != m[n1-1-i]:
      print('No')
      break
    else:
      if m[n2-1+i] != m[n-1-i]:
        print('No')
        break
      else:
        ans += 1
        
if ans == n1:
  print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pci pair<char,int
#define mii map<int,int>
#define mll map<long long int,long long int>
#define mci map<char,int>
#define umii unordered_map<int,int>
#define umll unordered_map<long long int,long long int>
#define umci unordered_map<char,int>
#define F first
#define S second
#define pb push_back
#define endl '\n'
#define mod 1000000007
using namespace std;
//ll visit[100001]={0};
//vector<ll> adj[1000001];

bool sortinrev(const pair<ll,ll> &a,  
               const pair<ll,ll> &b) 
{
       if(a.first!=b.first) return(a.first > b.first);
       else return (a.second<b.second);
} 
ll power(ll x,ll n,ll m)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%m;
        x=(x*x)%m;
        n=n/2;
    }
    return result%m;
}
bool isPrime(ll k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    ll i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}
 
ll bin(ll n)
{
    int di= 0;
    while(n)
    {   di=di+n%10;
        n=n/10;
        
    }
    return di;
}

int main(){
   IOS;
ll t;t=1;//cin>>t;
while(t--){
ll n;cin>>n;
ll dp[n][3];
for(ll i=0;i<n;i++){
    ll a,b,c;cin>>a>>b>>c;
    if(i==0){
        dp[i][0]=a;dp[i][1]=b;dp[i][2]=c;
    }
    else{
        dp[i][0]=a+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=b+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=c+max(dp[i-1][0],dp[i-1][1]);
    }
}

ll ans=max(dp[n-1][0],dp[n-1][1]);

    cout<<max(ans,dp[n-1][2])<<"\n";
    
}
    
    
    
    





return 0;}


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


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

int main(){
    int n;
    int i,j;
    int sum = 0;
    cin >> n;

    for(i = 1;i <= n;i += 2){
        int result = 0;
        for(j = 1;j <= i;++j){
            if(i % j == 0){
                result += 1;
            }
        }
        if(result == 8){
            sum++;
        }
    }
    cout << sum << 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;
using P = pair<int,int>;

int main(){
	int a,b;
	cin >> a >> b;
	int kuti = 1;
	int counts = 0;
	while(kuti < b){
		kuti += a -1;
		counts++;
	}
	cout << counts << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>

int hantei(int a){
    int i;
    if(a<2) return 0;
    else if(a==2) return 1;
    if(a%2==0) return 0;
    for(i=3;i*i<=a;i+=2){
        if(a%i==0)return 0;
    }
    return 1;
}

int main(){
  int i,n,a,c=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        if(hantei(a)) c++;
    }
    printf("%d\n",c);
   return 0;
}



Measured memory_bytes: 2140
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int A = Integer.parseInt(sc.next());
		int P = Integer.parseInt(sc.next());
		
		int kakera = 3 * A + P;
		
		
		System.out.println(kakera / 2);
		
	}


}



Measured memory_bytes: 24916
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();

		int x3=x2-(y2-y1);
		int y3=y2+(x2-x1);
		int x4=x3-(y3-y2);
		int y4=y3+(x3-x2);
		System.out.println(x3+" "+y3+" "+x4+" "+y4);
	}
}




Measured memory_bytes: 20948
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		char[] s = sc.next().toCharArray();
		int[] ss = new int[N];
		for(int i=0; i<N; i++)
			ss[i] = s[i]-'A';
		
		int[] t = new int[Q];
		int[] d = new int[Q];
		for(int i=0; i<Q; i++) {
			t[i] = sc.next().toCharArray()[0]-'A';
			d[i] = sc.next().equals("L") ? -1 : 1;
		}
		
		int ll = -1;
		int lr = N;
		while(ll+1 < lr) {
			int mid = (ll+lr)/2;
			if(exceedLeft(N, ss, Q, t, d, mid))
				ll = mid;
			else
				lr = mid;
		}
		int rl = -1;
		int rr = N;
		while(rl+1 < rr) {
			int mid = (rl+rr)/2;
			if(exceedRight(N, ss, Q, t, d, mid))
				rr = mid;
			else
				rl = mid;
		}
		
		System.out.println(rr-lr);
		sc.close();
	}
	
	static boolean exceedLeft(int N, int[] s, int Q, int[] t, int[] d, int p) {
		for(int i=0; i<Q; i++) {
			if(s[p] == t[i]) {
				if(d[i]==1) {
					if(p==N-1)
						return false;
					p++;
				} else {
					if(p==0)
						return true;
					p--;
				}
			}
		}
		
		return false;
	}
	static boolean exceedRight(int N, int[] s, int Q, int[] t, int[] d, int p) {
		for(int i=0; i<Q; i++) {
			if(s[p] == t[i]) {
				if(d[i]==1) {
					if(p==N-1)
						return true;
					p++;
				} else {
					if(p==0)
						return false;
					p--;
				}
			}
		}
		
		return false;
	}
}


Measured memory_bytes: 76112
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BUnevenNumbers {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        int res = 0;
        FOR(i, 1, N) {
            int c = 0;
            int n = i;
            while (n > 0) {
                n /= 10;
                c++;
            }
            if (c % 2 == 1) res++;
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BUnevenNumbers solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
//		Scanner sc2 = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		sc.nextLine();
		String[] s = new String[H+1];
		for(int i =0;i<H;i++) {
//			System.out.println(sc.nextLine());
			s[i]=sc.nextLine();
//			System.out.println(s[i]);
		}
		boolean[][] b = new boolean[H+2][W+2];
		for(int i =0;i<H;i++) {
			for(int j=0;j<W;j++) {
				if(s[i].charAt(j)=='#') {
					b[i+1][j+1]=true;
				}
			}
		}
		boolean ans =true;
		for(int i =1;i<=H;i++) {
			for(int j =1;j<=W;j++) {
				if(b[i][j]==true) {
					if(b[i-1][j]==false&&
				   b[i][j-1]==false&&
				   b[i][j+1]==false&&
				   b[i+1][j]==false) {
					ans =false;
//					System.out.println("Yes");
				}}
			}
		}
		if(ans) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		sc.close();
	}
}


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

#define gcu getchar_unlocked
int in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;}
int in() {return in(gcu());}
bool scan(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
bool scan(char &c){c=gcu();gcu();return c!=EOF;}
//bool scan(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
template <typename head, typename... tail>
bool scan(head &h, tail&&... t){return scan(h) && scan(t...);}
#define pcu putchar_unlocked
#define vo inline void out
template <typename T>
vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
vo(const char *s){while(*s)pcu(*s++);}
vo(char c){pcu(c);}
//vo(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail> vo(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T> vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef vo

int main() {
	for (int l; (l = in());) {
		int r = 0;
		for (int i = 1; i <= 12; i++) {
			int m = in(), n = in();
			if ((l -= m - n) <= 0 && !r)
				r = i;
		}
		if (r)
			out(r);
		else
			out("NA");
		out('\n');
	}
}


Measured memory_bytes: 2444
#include<iostream>
using namespace std;
int main(){
int n;
int ans=0;
std::cin >> n;;

for (int i = 0; n >= i*7; i++) {
  for (int k = 0; n >= k*4; k++) {
    if(i*7+k*4==n){ans++;break;}
    if(i*7+k*4>n){break;}
  }
}

if(ans!=0)std::cout << "Yes" << '\n';
else std::cout << "No" << '\n';
return 0;
}


Measured memory_bytes: 256