akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

bool isValid( string pw ) {
  int len = pw.size();
  if( len < 6 ) { return false; }

  bool containsDigit = false;
  bool containsLarge = false;
  bool containsSmall = false;
  for( int i = 0; i < len; i++ ) {
    int c = pw[ i ];
    if( '0' <= c && c <= '9' ) {
      containsDigit = true;
    } else if( 'A' <= c && c <= 'Z' ) {
      containsLarge = true;
    } else if( 'a' <= c && c <= 'z' ) {
      containsSmall = true;
    }
  }

  return containsDigit && containsLarge && containsSmall;
}

int main() {
  string pw;
  cin >> pw;
  cout << ( isValid( pw ) ? "VALID" : "INVALID" ) << endl;
  return EXIT_SUCCESS;
}

Measured memory_bytes: 1184
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DSumOfDivisors solver = new DSumOfDivisors();
        solver.solve(1, in, out);
        out.close();
    }

    static class DSumOfDivisors {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long sum = 0;

            for (long i = 1; i <= n; i++) {
                long t = n / i;
                sum += t * (t + 1) / 2 * i;
            }

            out.println(sum);
        }

    }
}



Measured memory_bytes: 35756
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX_H 61
#define MAX_W 31
#define INF 1e9
#define Fi first
#define Se second
typedef pair<int,int> pii;
 
struct State{
    int d,lx,ly,rx,ry;
    bool f;
    State(){}
    State(int d,int lx,int ly,int rx,int ry,bool f) :
	d(d),lx(lx),ly(ly),rx(rx),ry(ry),f(f) {}
    bool operator > (const State &s)const{
	return d > s.d;
    }
};
 
int W,H;
int ps,pt;
pii S[MAX_W],T[MAX_W];
char field[MAX_H][MAX_W];
int dist[MAX_H][MAX_W][MAX_H][MAX_W][2];
 
const int dx[9] = {1,1,1,1,1,2,2,2,3};
const int dy[9] = {-2,-1,0,1,2,-1,0,1,0};
 
bool inField(int x,int y){
    return 0 <= x && x < W && 0 <= y && y < H;
}
 
int dijkstra(){
    priority_queue<State,vector<State>,greater<State> > Q;
    fill(dist[0][0][0][0],dist[0][0][0][0]+MAX_H*MAX_W*MAX_H*MAX_W*2,INF);
    for(int i = 0 ; i < ps ; i++){
	Q.push(State(0,S[i].Fi,S[i].Se,W,H,0)); 
	Q.push(State(0,W,H,S[i].Fi,S[i].Se,1));
	dist[S[i].Se][S[i].Fi][H][W][0] = 0;
	dist[H][W][S[i].Se][S[i].Fi][1] = 0;
    }
 
    while(!Q.empty()){
	State s = Q.top(); Q.pop();
	int lx = s.lx, ly = s.ly;
	int rx = s.rx, ry = s.ry;
 
	if(dist[ly][lx][ry][rx][s.f] < s.d) continue;
	for(int i = 0 ; i < pt ; i++){
	    if(lx == T[i].Fi && ly == T[i].Se ||
	       rx == T[i].Fi && ry == T[i].Se){
		return s.d;
	    }
	}
	if(s.f){
	    for(int i = 0 ; i < 9 ; i++){
		int nlx = rx - dx[i];
		int nly = ry + dy[i];
		if(!inField(nlx,nly)) continue;
		if(field[nly][nlx] == 'X') continue;
		int t = field[nly][nlx] - '0';
		if(s.d + t < dist[nly][nlx][ry][rx][0]){
		    dist[nly][nlx][ry][rx][0] = s.d + t;
		    Q.push(State(dist[nly][nlx][ry][rx][0],nlx,nly,rx,ry,0));
		}
	    }
	}else{
	    for(int i = 0 ; i < 9 ; i++){
		int nrx = lx + dx[i];
		int nry = ly + dy[i];
		if(!inField(nrx,nry)) continue;
		if(field[nry][nrx] == 'X') continue;
		int t = field[nry][nrx] - '0';
		if(s.d + t < dist[ly][lx][nry][nrx][1]){
		    dist[ly][lx][nry][nrx][1] = s.d + t;
		    Q.push(State(dist[ly][lx][nry][nrx][1],lx,ly,nrx,nry,1));
		}
	    }
	}
    }
    return -1;
}
 
int main(){
    dijkstra();
    while(cin >> W >> H, W){
	ps = pt = 0;
	for(int i = 0 ; i < H ; i++){
	    for(int j = 0 ; j < W ; j++){
		cin >> field[i][j];
		if(field[i][j] == 'S'){
		    S[ps++] = pii(j,i);
		    field[i][j] = '0';
		}else if(field[i][j] == 'T'){
		    T[pt++] = pii(j,i);
		    field[i][j] = '0';      
		}
	    }
	}
	cout << dijkstra() << endl;
    }
    return 0;
}

Measured memory_bytes: 31148
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

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

    map<int, int> ma;
    map<int, int> mb;

    for (int i = 0; i < n; i++) {
        int v;
        cin >> v;
        if (i % 2 == 0) {
            ma[v]++;
        } else {
            mb[v]++;
        }
    }

    // {count, number}
    vector<pair<int, int>> va;
    for (auto &p : ma) {
        va.push_back({p.second, p.first});
    }
    va.push_back({0, -1}); // sentinel
    sort(va.begin(), va.end());
    reverse(va.begin(), va.end());

    // {count, number}
    vector<pair<int, int>> vb;
    for (auto &p : mb) {
        vb.push_back({p.second, p.first});
    }
    vb.push_back({0, -1}); // sentinel
    sort(vb.begin(), vb.end());
    reverse(vb.begin(), vb.end());

    int ans;
    if (va[0].second != vb[0].second) {
        // input2.txt
        ans = n / 2 - va[0].first + n / 2 - vb[0].first;
    } else {
        // input3.txt, input4.txt, input5.txt, input6.txt
        ans = min(n / 2 - va[0].first + n / 2 - vb[1].first, n / 2 - va[1].first + n / 2 - vb[0].first);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6136
#include <iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<algorithm>

using namespace std;

int main() {
	int i, N;
	int count =0 ;
	cin >> N;
	if (N == 100000) {
		count = 90909;
	}
	else if (10000 <= N && N < 100000) {
		count = 910;

		for (i = 10000; i < N; ++i) {
			++count;
		}
	}
	else if (1000<=N&&N < 10000) {
		count = 909;
	}
	else if (N<1000&&N >= 100) {
		count = 10;
		for (i = 100; i < N; ++i) {
			++count;
		}
	}

	else if (N < 100 && N >= 10) {
		count = 9;
	}

	else {
		for (i = 0; i < N; ++i) {
			++count;
		}
	}
	cout << count;
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const int inf = 0x3f3f3f3f;
#define LOCAL



int main() 
{
	ios::sync_with_stdio(false);
	cout.tie(0), cin.tie(0);
	int t;
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;
    return 0;
}

Measured memory_bytes: 3624
import Data.IntMap( insertWith, empty, toList, IntMap)
import qualified Data.IntMap as IM
import Data.List( foldl')
import qualified Data.List as L
import Control.Monad( replicateM)

main = do
    n_ <- readLn::IO Int
    as_ <- replicateM n_ (readLn::IO Int)
    let
	intCounts::[Int] -> IntMap Int
	intCounts = L.foldl' (\m k->IM.insertWith (+) k 1 m) IM.empty

    print . IM.size . IM.filter odd $ intCounts as_

Measured memory_bytes: 63356
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n);
	std::vector<std::pair<int, int>> vec;
	for(int i = 0; i < n; i++) {
		int a, b; scanf("%d%d", &a, &b);
		
		vec.push_back({a, b});
	}
	int m; scanf("%d", &m);
	for(int i = 0; i < m; i++) {
		int a, b; scanf("%d%d", &a, &b);
		
		vec.push_back({a, b});
	}
	sort(begin(vec), end(vec));
	vec.erase(unique(begin(vec), end(vec)), end(vec));
	
	for(int i = 0; i < vec.size(); i++) {
		auto v = vec[i];
		std::string s = std::to_string(v.first);
		std::string t = std::to_string(v.second);
		if(t.size() == 1) t = "0" + t;
		
		printf("%s:%s", s.c_str(), t.c_str());
		if(i == (int)vec.size() - 1) printf("\n");
		else printf(" ");
	}
	return 0;
}



Measured memory_bytes: 3300
////////////////////////
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
ll gcd(ll a, ll b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * b / my::gcd(a, b); }
}  // namespace my
////////////////////////

int main() {
  int a, b;
  cin >> a >> b;
  cout << a * b << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int H[N];
  for (int i = 0; i < N; i++) cin >> H[i];
  int cnt[N];
  cnt[N - 1] = 0;
  for (int i = N - 2; i >= 0; i--)
    cnt[i] = H[i] < H[i + 1] ? 0 : cnt[i + 1] + 1;
  int ans = 0;
  for (int i = 0; i < N; i++) ans = max(ans, cnt[i]);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 4400
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <cassert>
#include <iterator>
#include <complex>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(x, y) memset((x),(y),sizeof(x))
const LL INF = 1e9 + 7;
const int N = 1e2 + 10;
LL a[N][N];
void init()
{
	for (int i = 0; i < N; i++) a[i][0] = a[i][i] = 1;
	for (int i = 2; i < N; i++)
	{
		for (int j = 1; j < i; j++)
		{
			a[i][j] = a[i - 1][j] + a[i - 1][j - 1];
		}
	}
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	init();
	int n;
	cin >> n;
	vector<LL> v(n);
	int l, r;
	cin >> l >> r;
	for (auto &x : v) cin >> x;
	sort(v.rbegin(), v.rend());
	l--, r--;
	int x = 0, y = 0;
	LL sum = 0;
	for (int i = 0; i <= l; i++)
	{
		if (v[i] == v[l]) x++;
		sum += v[i];
	}
	for (int i = l + 1; i < n; i++) if (v[i] == v[l]) y++;
	printf("%.6f\n", sum*1.0 / (l+1));
	LL ans = a[x + y][x];
	if (v[0] == v[l])
	{
		ans = 0;
		int tot = 0;
		for (int i = 0; i < n; i++) if (v[i] == v[0]) tot++;
		for (int i = l + 1; i <= min(tot, r + 1); i++) ans += a[tot][i];
	}
	cout << ans << endl;

	return 0;
}

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

int main(){
  vector<int> a(3,0); cin>>a[0]>>a[1]>>a[2];
  sort(a.begin(),a.end());
  int ans = a[1]-a[0]+a[2]-a[1];
  cout<< ans <<endl;
}

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

using namespace std;

#define pii pair<int, int>
#define fi first
#define se second
#define REP(i, a, n) for (register int i = a, _n = n; i <= _n; ++i)
#define DREP(i, a, n) for (register int i = a, _n = n; i >= _n; --i)
#define FOR(i, a, n) for (register int i = a, _n = n; i < _n; ++i)
#define EREP(i, a) for (register int i = first[a]; i; i = edge[i].nxt)
#define debug(x) cout << #x << " = " << x << endl

char IO;
inline int rd () {
	int res = 0;
	while ((IO = getchar()) && (IO < '0' || IO > '9'));
	while (IO >= '0' && IO <= '9') 
		res = (res << 1) + (res << 3) + (IO ^ 48), IO = getchar();
	return res;
}

long long a;

int main () {
	cin >> a;
	cout << 3 * a * a << endl;
	return 0;
}


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

int main(){
	// sengen
	string s;
	// nyuryoku
	cin >> s;
	int n = s.size();
	// keisan
	string left = s.substr(0,(n-1)/2);
	string right = s.substr((n+1)/2,(n-1)/2);
	if(n == 3){
		if(s[0] == s[2]){
			cout << "Yes";
		}else{
			cout << "No";
		}
	}else{
		string revl = left;
		string revr = right;
		reverse(left.begin(),left.end());
		reverse(right.begin(),right.end());
		if(left == revl && right == revr && left == revr){
			cout << "Yes";
		}else{
			cout << "No";
		}
	}
	// syutsuryoku
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello
{
    public static void Main()
    {
        //入力を保持する
        var NK = Console.ReadLine().Split().Select(e => int.Parse(e)).ToArray();
        //すぬけ君の数
        var N = NK[0];
        //お菓子の種類
        var K = NK[1];
        var candyFlgs = new bool[N + 1];
        //K種のお菓子分入力を受ける
        for(var n = 0;n < K; n++)
        {
            //お菓子を持っている人数分ループを実施する
            var loop = int.Parse(Console.ReadLine());
            //お菓子を持っている個人の配列を保持する
            var people = Console.ReadLine().Split().Select(e => int.Parse(e)).ToArray();
            for( var l = 0; l < loop; l++)
            {
                //お菓子を持っているすぬけ君をtrueとする
                candyFlgs[people[l]] = true;
            }
        }
        var ans =0;
        for(var indx = 1;indx < candyFlgs.Length;indx++)
        {
            if(candyFlgs[indx] == false)
            {
                ans++;
            }
        }
        Console.WriteLine(ans);
    }
}



Measured memory_bytes: 28392
#include <iostream>

using namespace std;
int main() {
  string s;
  cin >> s;
  s += "$";
  int ans = 0, cnt = 0;
  char c = '#';
  for (char i : s) {
    if (i == c)
      cnt++;
    else {
      if (c == 'R')
        ans = max(ans, cnt);
      c = i;
      cnt = 1;
    }
  }
  cout << ans;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>
#include <limits.h>

int subsum[101][101];

int main(void)
{
  int n, x, y, x1, y1, x2, y2;
  int max = INT_MIN;  /* 最大値を覚えておく変数 */

  /* 配列データの初期化 */
  memset(subsum,0,sizeof(subsum));

  /* 入力データの読み込み */
  scanf("%d", &n);
  for(y=1; y<=n; y++){
	for(x=1; x<=n; x++){
	  int m;
	  scanf("%d", &m);
	  subsum[y][x] = m + subsum[y-1][x] + subsum[y][x-1] - subsum[y-1][x-1];
	}
  }

  /* 部分行列を全探索 */
  for(y1=0; y1<n; y1++){
	for(x1=0; x1<n; x1++){
	  for(y2=y1+1; y2<=n; y2++){
		for(x2=x1+1; x2<=n; x2++){
		  int s = subsum[y2][x2] - subsum[y1][x2] - subsum[y2][x1] + subsum[y1][x1];
		  if(max < s) max = s;
		}
	  }
	}
  }

  /* 答えを表示 */
  printf("%d\n", max);

  return 0;
}

Measured memory_bytes: 648
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


inf = 10 ** 18
mod = 10 ** 9 + 7

D = ir()
c = lr()
d = [0 for i in range(26)]
s = [lr() for i in range(D)]

for k in range(1,D+1):
    now = -1
    pre = -inf
    for i in range(26):
        total = s[k-1][i]
        sumc = 0
        for j in range(26):
            if j != i:
                sumc += c[j]*(k-d[j])
        total-=sumc
        if total > pre:
            pre = total
            now = i
    print(now+1)
    d[now] = k

Measured memory_bytes: 74320
import collections

n = int(input())

v = list(map(int,input().split()))

v1 = v[::2]

v2 = v[1::2]
        
if len(set(v))==1:
    print(n//2)
else:
    maxv1 = collections.Counter(v1).most_common()

    maxv2 = collections.Counter(v2).most_common()


    if maxv1[0][0] == maxv2[0][0]:    
        ans1 = (len(v1) - maxv1[0][1]) + (len(v2) - maxv2[1][1])
        ans2 = (len(v1) - maxv1[1][1]) + (len(v2) - maxv2[0][1])
        print(min(ans1, ans2))
    else:
        ans = (len(v1) - maxv1[0][1]) + (len(v2) - maxv2[0][1])
        print(ans)

Measured memory_bytes: 21084
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef uint64_t ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    ll n, k;
    cin >> n >> k;
    int pw = 0;
    double acc = 0;
    for(ll i = n; i>= 1; i--) {
        while (i * (1ull << pw) < k) {
            pw += 1;
        }
        acc += double(1.0) / double((1ull << pw));
    }
    acc /= double(n);
    cout << fixed << setprecision(15) << acc << endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
typedef long long ll;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 1000006;

int q[N];
bool c[N];

void solv()
{
    int qq;
    scanf("%d", &qq);
    while (qq--)
    {
        int x;
        scanf("%d", &x);
        ++q[x];
    }
    int ans = 0;
    for (int i = 1; i < N; ++i)
    {
        if (q[i] == 0)
            continue;
        if (q[i] > 1)
            c[i] = true;
        for (int j = i + i; j < N; j += i)
            c[j] = true;
        if (!c[i])
            ++ans;
    }
    printf("%d\n", ans);
}

int main()
{
    #ifdef SOMETHING
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif // SOMETHING
    //ios_base::sync_with_stdio(false), cin.tie(0);
    solv();
    return 0;
}

//while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}


Measured memory_bytes: 8692
import sys

# N: コマ数
# M: 地点数

N,M,*X = map(int, open(0).read().split())

# コマ数が地点数以上の場合、各地点にコマを配置できる
# よって 0 回の移動で目的を達成できる
if N >= M:
    print(0)
    sys.exit()

X.sort()

D = sorted(abs(X[i+1] - X[i]) for i in range(M-1))

print(sum(D[:M-N]))

Measured memory_bytes: 20008
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;

typedef signed long long ll;

int main()
{
	
	string n;
	cin >> n;
	if (n[0] >= n[1] && n[0] >= n[2]) {
		n[1] = n[0];
		n[2] = n[0];
	}
	else {
		n[0]++;
		n[1] = n[0];
		n[2] = n[0];
	}
	int num = atoi(n.c_str());
	cout << num << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  string N;
  cin >> N;
  int count = 0;
  rep(i,4)
  {
    if(N[i]=='+')
    {
      count ++;
    }
    else
    {
      count --;
    }
    
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pp pop_back
#define PI 3.14159265358979323846
using namespace std;

//  
int main(){
    long double a, b, h ,m;
    cin>> a >> b >> h >> m;
    h = h*5.0 + 5.0*m/60.0;
    long double ang = abs(h - m);
    if(ang > 30) ang = 60 - ang;
    ang = 6.0*ang;
    long double ans;
    long double coseno = cos(ang*PI/180.0);
    ans = sqrt(a*a + b*b - 2.0*a*b*coseno);
    cout<< setprecision(15) << ans << "\n";
    
}


Measured memory_bytes: 4100
#include <stdio.h>

typedef long long ll;

int main() {

	ll X,Y;

	scanf("%lld %lld",&X,&Y);


	ll A=X;
	int ans=0;
	while(1){
		if(A>Y){break;}
		A*=2ll;
		ans++;
	}
	printf("%d\n",ans);

	return 0;
}

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


#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

ll mod = 1e9 + 7ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll inf = 1ll << 60;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> check(50, -1);
    bool flag = false;
    int ans = 0;
    if(m == 0){
        if(n == 1) cout << 0 << endl;
        else if(n == 2) cout << 10 << endl;
        else if(n == 3) cout << 100 << endl;
        return 0;
    } else {
        rp(i, 0, m){
            int s, c;
            cin >> s >> c;
            if(n != 1 and s == 1 and c == 0) flag = true;
            else if(check.at(s) >= 0 and check.at(s) != c) flag = true;
            else if(check.at(s) >= 0 and check.at(s) == c) continue;
            else {
                check.at(s) = c;
                rp(i, 0, n-s) c *= 10;
                ans += c;
            }
        }
        if(check.at(1) == -1){
            int c = 1;
            rp(i, 0, n-1) c *= 10;
            ans += c;
        }
        if(flag){
            cout << -1 << endl;
            return 0;
        }
        cout << ans << endl;
        return 0;
    }


}






Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  cout << fixed << setprecision(15);
  ll n,m,d; cin >> n >> m>> d;
  if(d==0){
    cout << (double)(m-1)/n << endl;
  }
  else{
    cout << (double)(m-1)*2*(n-d)/(n*n) << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vs = vector<string>;
template <typename T>
using ost = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
#define forn(i,n) for(int i=0; i<int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ff first
#define ss second

int main() {
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vi cnt(n, 1);
    vi red(n);
    red[0] = 1;
    while (m--) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        red[y] |= red[x];
        red[x] &= cnt[x]>1;
        cnt[x]--;
        cnt[y]++;
    }
    int tot = accumulate(all(red), 0);
    cout << tot << '\n';
}


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

#define MAX_N 100000

using namespace std;

int main(void)
{
    int N;
    int A[3][MAX_N];
    cin >> N;
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < N; j++) {
            cin >> A[i][j];
        }
        sort(A[i], A[i] + N);
    }
    long long d[MAX_N + 1]; // d[i] is the number of (j, k) s.t. i <= j and A[1][j] < A[2][k]
    d[N] = 0;
    for (int i = N - 1; i >= 0; i--) {
        d[i] = d[i + 1] + ((A[2] + N) - upper_bound(A[2], A[2] + N, A[1][i]));
        // cout << "d[" << i << "] = " << d[i] << endl;
    }
    long long answer = 0;
    for (int i = 0; i < N; i++) {
        int j = upper_bound(A[1], A[1] + N, A[0][i]) - A[1];
        answer += d[j];
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
using namespace std;
typedef pair<int, int> P;
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++) {
            cin >> A[i][j];
            A[i][j]--;
        }
    }
    queue<P> q;
    vector<int> cnt(N, 0);
    vector<int> used(N, 0);
    auto check = [&](int i){
        if(cnt[i] == N - 1) return;
        int j = A[i][cnt[i]];
        if(cnt[j] == N - 1) return;
        if(A[j][cnt[j]] != i) return;
        if(i > j) swap(i, j);
        used[j] = 1;
        used[i] = 1;
        q.push(P(i, j));
    };
    for(int i = 0; i < N; i++){
        if(used[i] == 1) continue;
        check(i);
    }
    int day = 0;
    while(!q.empty()){
        day++;
        used.assign(N, 0);
        queue<P> que;
        while(!q.empty()){
            P v = q.front();
            que.push(v);
            q.pop();
            int i = v.first, j = v.second;
            cnt[i]++;
            cnt[j]++;
        }
        while(!que.empty()){
            P v = que.front();
            que.pop();
            int i = v.first, j = v.second;
            if(used[i] == 1 && used[j] == 0) {
                check(j);
            }
            else if(used[i] == 0 && used[j] == 1){
                check(i);
            }
            else if(used[i] == 0 && used[j] == 0){
                check(i);
                check(j);
            }
        }
    }
    for(int i = 0; i < N; i++){
        if(cnt[i] != N - 1){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << day << endl;
}


Measured memory_bytes: 7600
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""
import sys
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


def main():
    N = si()
    n = str(N)
    for i in range(3):
        if n[i] == '7':
            print('Yes')
            sys.exit()
    print('No')


if __name__ == '__main__':
    main()


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

int main(){
  int N;
  cin>>N;
  char c;
  bool flag=false;
  for(int i=0;i<N;i++){
    cin>>c;
    if(c=='Y') flag=true;
  }
  if(flag) cout<<"Four"<<endl;
  else cout<<"Three"<<endl;
}


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

int main() {
    long long int n,i,ans=0;
    cin>>n;
    long long int a[n];
    map<long long int,long long int>mp;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    mp[0+a[0]]++;
    for(i=1;i<n;i++)
    {
        if(mp.find(i-a[i])!=mp.end())
        ans+=mp[i-a[i]];
        mp[i+a[i]]++;
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 17644
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	string s;
	cin >> s;
	string ans;
	REP(i,s.length()){
		if(i % 2 == 0) ans.push_back(s[i]);
	}
	cout << ans << endl;
}

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

#define int long long int
#define ff first
#define ss second
#define pb push_back


int bexp(int a, int b)
{
	int res = 1;

	while (b)
	{
		if (b & 1) res = (res * a);

		a = (a * a); 
		b >>= 1;
	}
	return res;
}

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

#define N 100010
#define MOD 1000000007

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(10);

	
	int n, k;
	cin >> n >> k;
	int a[n];
	double ans = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}

	for (int i = 0; i < k; ++i)
	{
		ans += (a[i] + 1.0) / 2;
	}

	double m = ans;
	for (int i = k; i < n; ++i)
	{
		m = m - (a[i - k] + 1.0) / 2;
		m += (a[i] + 1.0)/2;
		ans = max(ans, m);
	}
	cout << fixed << ans << "\n";
	return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;

int main()
{
    int i,n,value;
    char c;
    char b[99999];


    cin>>n;
    cin>>b;
    for(i=0; b[i]!='\0'; i++)
    {
        if(n==0)
            printf("%c",b[i]);
        else if(b[i]+n>90)
        {
            printf("%c",64+(b[i]+n-90));
        }
        else
            printf("%c",b[i]+n);





    }



}


Measured memory_bytes: 256
n = int(input())
c = [0, 0, 0, 0]

for i in range(n):
    s = input()
    if s == 'AC':
        c[0] += 1
    elif s == 'WA':
        c[1] += 1
    elif s == 'TLE':
        c[2] += 1
    elif s == 'RE':
        c[3] += 1

print('AC x ' + str(c[0]))
print('WA x ' + str(c[1]))
print('TLE x ' + str(c[2]))
print('RE x ' + str(c[3]))


Measured memory_bytes: 9200
N, M = map(int, input().split())
 
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

if N < 2 and M < 2:
  a = 0
elif N < 2:
  a = cmb(M,2)
elif M < 2:
  a = cmb(N,2)
elif N > 1 and M > 1:
  a = cmb(N,2) + cmb(M,2)

print(int(a))


Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int m, n;
	while (cin >> n >> m&&n != 0 && m != 0) {
		int a = n%m, b = (n - a) / m, d = 0, e[1000], sum = 0;
		string c, h = "";
		getline(cin, c);
		getline(cin, c);
		c += " ";
		for (int i = 0; i < c.length(); i++) {
			if (c[i] == ' ') {
				e[d] = atoi(h.c_str());
				h = "";
				d++;
			}
			else
				h += c[i];
		}
		sort(e, e + n);
		d = 0;
		for (int i = 0; i < a; i++) {
			sum += e[i];
			d++;
		}
		for (int i = 0; i < b; i++) {
			for (int j = 0; j < m; j++) {
				if (j != 0) {
					sum += e[i*m + j+a];
				}
			}
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define all(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
const int mod = 1e9+7;

int main() {
    int n, T;
    cin >> n >> T;
    int t[n+1];
    rep(i, n) {
        cin >> t[i];
    }
    t[n] = t[n-1] + T;
    ll ans = 0;
    rep(i, n) {
        ans += min(T, t[i+1] - t[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4360
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int mod = 1e9 + 7;
int main()
{
	SPEED
	int h, n;
	cin >> h >> n;
	
	int temp, s = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> temp;
		s+=temp;
	}

	if (s>=h)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
using namespace std;

struct BipartiteMatching {
	int V;
	vector<vector<bool> > G;
	vector<int> match;
	vector<bool> used;

	BipartiteMatching(int v) {
		V = v;
		G = vector<vector<bool> >(v, vector<bool>(v));
		match = vector<int>(v);
		used = vector<bool>(v);
	}

	void add_edge(int v, int u) {
		G[v][u] = G[u][v] = true;
	}

	bool dfs(int v) {
		used[v] = true;
		for(int i = 0; i < V; i++) {
			if(!G[v][i]) continue;
			int u = i, w = match[u];
			if(w < 0 || (!used[w] && dfs(w))) {
				match[v] = u;
				match[u] = v;
				return true;
			}
		}
		return false;
	}

	int calc() {
		int res = 0;
		fill(match.begin(), match.end(), -1);
		for(int v = 0; v < V; v++) {
			if(match[v] < 0) {
				fill(used.begin(), used.end(), false);
				if(dfs(v)) {
					res++;
				}
			}
		}
		return res;
	}
};

double tx[100];
double ty[100];
double tv[100];
double bx[100];
double by[100];

double d(double x1, double y1, double x2, double y2) {
	x1 -= x2, y1 -= y2;
	return sqrt(x1 * x1 + y1 * y1);
}

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

	int N, M;
	while(cin >> N >> M, N | M) {
		for(int i = 0; i < N; i++) {
			cin >> tx[i] >> ty[i] >> tv[i];
		}
		for(int i = 0; i < M; i++) {
			cin >> bx[i] >> by[i];
		}
		BipartiteMatching bp(N + M);
		double ng = 0, ok = 1e8;
		for(int lopp = 0; lopp < 200; lopp++) {
			double m = (ng + ok) / 2;

			for(int i = 0; i < N; i++) {
				for(int j = 0; j < M; j++) {
					double dist = d(tx[i], ty[i], bx[j], by[j]);
					bp.G[i][N + j] = bp.G[N + j][i] = (dist / tv[i] <= m);
				}
			}

			if(bp.calc() == M) {
				ok = m;
			}
			else {
				ng = m;
			}
		}

		if(abs(ok) < 1e-8) {
			cout << 0 << endl;
		}
		else {
			cout << setprecision(20) << ok << endl;
		}
	}
}

Measured memory_bytes: 3256
#include <iostream>

using namespace std;

using ll = long long;

int main() {
  int n;
  cin >> n;
  
  ll ans = 0ll;
  for (int i = 1; i <= n; i++) {
    ll x = n / i;
    ans += (x * (x + 1) / 2) * i;
  }
  
  cout << ans << '\n';
  return 0;
}


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

ll c[60][60],n,m;

inline ll rd()
{
	ll x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

int main()
{
	n=rd();m=rd();
	if (m>n) { puts("0");return 0; }
	printf("%lld\n",n-m+1);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;
 
/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
	    Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        System.out.println((1000-t%1000)%1000);
    }
}

Measured memory_bytes: 35808
#include <bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
using namespace std;

const int N = 305;

int i, j, k, a[N][N], n, p[N], x, y;
long long dist[N][N], rs;
vector<pair<long long, pair<int, int>>> v;

int pfind(int x) { return p[x] == x ? x : p[x] = pfind(p[x]); }

void punite(int x, int y) { p[pfind(x)] = pfind(y); }

void wtf() {
    for(i = 1; i <= n; ++i) {
      dist[i][x] = dist[x][i] = min(dist[x][i], dist[x][y] + dist[y][i]);
      dist[i][y] = dist[y][i] = min(dist[y][i], dist[y][x] + dist[x][i]);
    }
    for(i = 1; i <= n; ++i) {
      dist[i][x] = dist[x][i] = min(dist[x][i], dist[x][y] + dist[y][i]);
      dist[i][y] = dist[y][i] = min(dist[y][i], dist[y][x] + dist[x][i]);
    }

    for(i = 1; i <= n; ++i)
      for(j = 1; j <= n; ++j)
        dist[i][j] = min(dist[i][j], dist[i][x] + dist[x][j]);

    for(i = 1; i <= n; ++i)
      for(j = 1; j <= n; ++j)
        dist[i][j] = min(dist[i][j], dist[i][y] + dist[y][j]);
}

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

  cin >> n;
  for(i = 1; i <= n; ++i)
    for(j = 1; j <= n; ++j)
      cin >> a[i][j], dist[i][j] = a[i][j];

  for(k = 1; k <= n; ++k)
    for(i = 1; i <= n; ++i)
      for(j = 1; j <= n; ++j)
        if(i != j && j != k && k != i)
          dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

  for(i = 1; i <= n; ++i)
    for(j = 1; j <= n; ++j) {
      if(a[i][j] != dist[i][j])
        return cout << "-1\n", 0;
      if(j > i) v.push_back(mp(a[i][j], mp(i, j)));
    }

  sort(v.begin(), v.end());

  for(i = 1; i <= n; ++i) p[i] = i;

  for(i = 1; i <= n; ++i)
    for(j = 1; j <= n; ++j)
      dist[i][j] = (i == j ? 0 : 1e18 + 69);

  for(auto it : v) {
    if(dist[it.se.fi][it.se.se] == it.fi) continue;

    rs += it.fi;
    dist[it.se.fi][it.se.se] = dist[it.se.se][it.se.fi] = it.fi;
    x = it.se.fi;
    y = it.se.se;
    if(x > y) swap(x, y);
    wtf(); wtf(); wtf(); wtf(); wtf();
  }

  cout << rs << '\n';

  return 0;
}

Measured memory_bytes: 2552
#include <stdio.h>
int main(){
    int num;
    scanf("%d", &num);
    int count = 0;
    if(num % 2 == 1){//jika panjang str tdk bisa dibagi 2, maka langsung return 0
        printf("No\n");
        return 0;
    }
    char str[num];
    scanf("%s", str);
    for(int i = 0; str[i] != '\0'; i++){
        if(str[i] == str[(num / 2) + i]){//kasus jika ada 6 huruf
            count++;//untuk mengecek huruf pertama dan ke empat sama gak
        }
    }
    if(count == num / 2){//jika counter == panjang str / 2
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

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

typedef pair<int,int> P;
const int INF = 500000000;

int main(){
    string s;
    cin >> s;
    if (s.find("7") != string::npos){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }
}


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

int main() {
  int64_t N, D;
  cin >> N >> D;
  int64_t x, y;
  int count = 0;
  for (int i = 0; i < N; i++){
    cin >> x >> y;
    if(x * x + y * y <= D * D){
      count++;
    }
  }
  cout << count << endl;
}



Measured memory_bytes: 3548
#include <stdio.h>

int main(){
    char op;
    int a, b;
    
    while(scanf("%d %c %d", &a, &op, &b), op != '?'){
        
        switch(op){
        case '+':
            printf("%d\n", a + b);
            break;
        
        case '-':
            printf("%d\n", a - b);
            break;
        
        case '*':
            printf("%d\n", a * b);
            break;
        
        case '/':
            printf("%d\n", a / b);
            break;
        }
    }
    
    return 0;
}
 

 



Measured memory_bytes: 2712
#include<cstdio>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
int main(){
    int n;
    while(scanf("%d",&n),n){
        set<int>S;
        for(int i=1;i<n;i++)S.insert((i*i)%n);
        int cnt[10000]={0};
        vector<int>V;
        for(set<int>::iterator it=S.begin();it!=S.end();it++)V.push_back(*it);
        for(int i=0;i<V.size();i++){
            for(int j=0;j<V.size();j++){
                if(i==j)continue;
                int a=V[i],b=V[j];
                int val=a-b;
                if(val<0)val+=n;
                if(val>(n-1)/2)val=n-val;
                cnt[val]++;
            }
        }
        for(int i=1;i<=(n-1)/2;i++)printf("%d\n",cnt[i]);
    }
    return 0;
}

Measured memory_bytes: 1372
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define ar array<int,2>
#define inf 1000000000000000000 
int mod=1e9+7;
int min(int a,int b){return (a<b)?a:b;}
int max(int a,int b){return (a>b)?a:b;}
int fp(int a,int b){if(b==0) return 1;int x=fp(a,b/2);x=(x*x)%mod;if(b&1) x=(x*a)%mod;return x;}


const int N=2e5+5;



void solve()
{
  
  int x,k,d;
  cin>>x>>k>>d;

  if(x<0)
    x*=-1;

 int y=min(k,x/d);
 x-=d*y;
    //cout<<x<<" ";
 k-=y;
 k&=1;
 if(k)
    x-=d;
 cout<<abs(x);

}

signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
 srand(time(0));
 int t;
 t=1;
 for(int i=1;i<=t;i++)
 {
   solve();
 }


}

Measured memory_bytes: 3616
#include <iostream>
using namespace std;
#define MAX 25
#define NIL -1

struct Node {
    // parentはrootの判別に必要
    int parent, left, right;
};

Node T[MAX];
int D[MAX]; // 各ノードの深さ
int H[MAX]; // 各ノードの高さ
int S[MAX]; // 各ノードの兄弟
int n;

// idを根とする木の高さを返す
int setHeight(int id) {
    int lh = 0;
    int rh = 0;
    if (T[id].left != NIL) lh = setHeight(T[id].left) + 1;
    if (T[id].right != NIL) rh = setHeight(T[id].right) + 1;
    H[id] = max(lh, rh); // idが葉のとき高さ0になる
    return H[id];
}

void setDepth(int id, int d) {
    if (id != NIL) {
        D[id] = d;
        setDepth(T[id].left, d + 1);
        setDepth(T[id].right, d + 1);
    }
}

void initialize() {
    for (int i = 0; i < n; i++) {
        T[i].parent = NIL;
        T[i].left = NIL;
        T[i].right = NIL;
        S[i] = NIL;
    }
}

void print(int id) {
    int deg = (T[id].left != NIL) + (T[id].right != NIL);
    cout << "node " << id << ": ";
    cout << "parent = " << T[id].parent << ", ";
    cout << "sibling = " << S[id] << ", ";
    cout << "degree = " << deg << ", ";
    cout << "depth = " << D[id] << ", ";
    cout << "height = " << H[id] << ", ";
    if (T[id].parent == NIL) cout << "root" << endl;
    else if (deg == 0) cout << "leaf" << endl;
    else cout << "internal node" << endl;
}

int main() {
    int i, l, r, id, root;
    cin >> n;
    initialize();
    for (i = 0; i < n; i++) {
        cin >> id >> l >> r;
        T[id].left = l;
        T[id].right = r;
        if (l != NIL) {
            T[l].parent = id;
            S[l] = r;
        }
        if (r != NIL) {
            T[r].parent = id;
            S[r] = l;
        }
    }

    // rootを探す
    for (i = 0; i < n; i++) {
        if (T[i].parent == NIL) {
            root = i;   
            break;
        }
    }

    setDepth(root, 0);
    setHeight(root);

    for (i = 0; i < n; i++) print(i);

    return 0;
}



Measured memory_bytes: 3104
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]


s=input()
# ans=700
print(700+100*Counter(s)["o"])

Measured memory_bytes: 9660
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();
		int A = sc.nextInt();
		sc.close();

		if (X<A) System.out.println(0);
		else System.out.println(10);

	}

}

Measured memory_bytes: 27024
#include<bits/stdc++.h>
using namespace std;
#define mods 1000000007
#define pb push_back
#define mp make_pair
#define st first
#define nd second
typedef long long int lint;
typedef unsigned long long int ulint;

string s;
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	cin>>s;
	if(s=="SUN") cout<<7;
	if(s=="MON") cout<<6;
	if(s=="TUE") cout<<5;
	if(s=="WED") cout<<4;
	if(s=="THU") cout<<3;
	if(s=="FRI") cout<<2;
	if(s=="SAT") cout<<1;
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		int ans = 0;
		for (int i = 0; i < S.length(); i++) {
			char[] first = S.substring(0, i + 1).toCharArray();
			char[] last = S.substring(i + 1, S.length()).toCharArray();
			int[] alpha_f = new int[26];
			int[] alpha_l = new int[26];
			for (int j = 0; j < first.length; j++) {
				alpha_f[first[j] - 'a']++;
			}
			for (int j = 0; j < last.length; j++) {
				alpha_l[last[j] - 'a']++;
			}
			int count = 0;
			for (int j = 0; j < 26; j++) {
				if (alpha_f[j] > 0 && alpha_l[j] > 0) {
					count++;
				}
			}
			ans = Math.max(ans, count);

		}
		System.out.println(ans);
		sc.close();
	}
}

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

typedef long long ll;
typedef pair<int,int> P;
ll const INF = 1LL<<40;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int n;
vector<vector<int>> a;
vector<ll> all,dp;

ll rec1(int s) {
    if (all[s] > -INF) return all[s];
    all[s] = 0;
    for (int i = 0;i < n;++i) if ((s>>i)&1) {
        all[s] += rec1(s^(1<<i));
        for (int j = i;j < n;++j) if ((s>>j)&1) all[s] += a[i][j];
        break;
    }
    return all[s];
}

ll rec2(int s) {
    if (dp[s] > -INF) return dp[s];
    ll ret = all[s];
    for (int i = s;;i = (i-1)&s) {
        if (i == 0) break;
        if (i == s) continue;
        ret = max(ret,rec2(i)+rec2(s^i));
    }
    return dp[s] = ret;
}

int main() {
    cin >> n;
    a = vector<vector<int>>(n,vector<int>(n));
    for (int i = 0;i < n;++i) for (int j = 0;j < n;++j) cin >> a[i][j];
    all.resize(1<<n,-INF);
    dp.resize(1<<n,-INF);
    for (int i = 0;i < (1<<n);++i) if (all[i] == -INF) all[i] = rec1(i);
    cout << rec2((1<<n)-1) << endl;
    return 0;
}

Measured memory_bytes: 1280
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

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

    ll n, a, b; cin>>n>>a>>b;

    ll ans = n / (a + b) * a;
    ans += min(a, (n % (a + b)));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    int s, w;
    cin >> s >> w;
    if (s > w)
        cout << "safe";
    else
        cout << "unsafe";
}


Measured memory_bytes: 3644
arr = []
while true
  input = gets.chomp.split(" ")
  x = input[0].to_i
  y = input[1].to_i
  break if x == 0 && y == 0
  if x > y
    arr += ["#{y} #{x}"]
  else
    arr += ["#{x} #{y}"]
  end
end
arr.each{|answer|
  puts answer
}

Measured memory_bytes: 23948