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

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

using namespace std;

void solve(ll W, ll a, ll b){
	ll hoge = abs(a - b);
	if (hoge - W < 0) cout << 0;
	else cout << hoge - W;

}

int main(){
    // 提出時は削除 //////////////////////////////
//	FILE* fp_in = freopen("/Users/kokinakamura/git/ToolsForAtCoder/workspace/abc056/B/in_B_1.txt", "r", stdin);
    ////////////////////////////////////////////

	ll W;
	ll b;
	ll a;
	scanf("%lld",&W);
	scanf("%lld",&a);
	scanf("%lld",&b);
	solve(W, a, b);

    // 提出時は削除 //////////////////////////////
//    fclose(fp_in);
    ////////////////////////////////////////////
	return 0;
}


Measured memory_bytes: 256
a1j=list(map(int,input().split()))
a2j=list(map(int,input().split()))
a3j=list(map(int,input().split()))
n = int(input())

for i in range(n):
    b = int(input())
    if b in a1j:
        a1j[a1j.index(b)] = 0
    if b in a2j:
        a2j[a2j.index(b)] = 0
    if b in a3j:
        a3j[a3j.index(b)] = 0

ans = "No"

if a1j[0] == 0:
    if a1j[1] == 0 and a1j[2] == 0:
        ans = "Yes"
    if a2j[1] == 0 and a3j[2] == 0:
        ans = "Yes"
    if a2j[0] == 0 and a3j[0] == 0:
        ans = "Yes"
if a1j[1] == 0:
    if a2j[1] == 0 and a3j[1] == 0:
        ans = "Yes"
if a1j[2] == 0:
    if a2j[2] == 0 and a3j[2] == 0:
        ans = "Yes"
    if a2j[1] == 0 and a3j[0] == 0:
        ans = "Yes"
if a2j[0] == 0:
    if a2j[1] == 0 and a2j[2] == 0:
        ans = "Yes"
if a3j[0] == 0:
    if a3j[1] == 0 and a3j[2] == 0:
        ans = "Yes"

print(ans)

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

int main(){
  int a, b;
  cin >> a >> b;
  if(a % 2 == 1 && b % 2 == 1){
    cout << "Odd" << endl;
  }
  else{
    cout << "Even" << endl;
  }
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  ll a, b, c;
  cin >> a >> b >> c;
  ll x = a % b;
  bool ans = false;
  for (ll i = 1; i <= b; i++){
    if(x*i%b==c){
      ans = true;
    }
  }
  if(ans){
    print("YES");
  }
  else{
    print("NO");
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
    int k, s;
    cin >> k >> s;

    int ans = 0;
    for (int x = 0; x <= k; x++)
    {
        for (int y = 0; y <= k; y++) {
            int z = s - x - y;
            if (z >= 0 && z <= k) {
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
X = input()
N = len(X)

c = 0
uppun = 0
for i, x in enumerate(X):
    if x == 'S':
        uppun += 1
    if x == 'T':
        c += 1
        if uppun > 0:
            uppun -= 1
    if c == N//2:
        ans = N - (i+1-c - uppun)*2
        break

print(ans)

Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()

int main()
{
    int n;
    cin >> n;
    vector<int> w(n);
    rep(i, n) cin >> w[i];
    int sum = accumulate(all(w), 0);
    int ans = 1000;
    rep(i, n)
    {
        int s1 = 0;
        rep(j, i) s1 += w[j];
        int s2 = sum - s1;
        if (abs(s1 - s2) < ans)
            ans = abs(s1 - s2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int infint = 1e9;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)1e5 + 7;
int n, dp1[MAXN], dp2[MAXN];
vector<int> G[MAXN];
void dfs(int v, int p)
{
	int sm = 0;
	for (auto u : G[v])
		if(u != p)
		{
			dfs(u, v);
			dp2[v] += max(dp1[u], dp2[u]);
			sm += max(dp1[u], dp2[u]);
		}
	int mx = 0;
	for (auto u : G[v])
		if(u != p)
			mx = max(mx, 1 + dp2[u] + sm - max(dp1[u], dp2[u]));
	dp1[v] = mx;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n - 1; i++)
	{
		int u, v;
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(1, -1);
	int match = max(dp1[1], dp2[1]);
	if(match == n / 2 && n % 2 == 0)
		return cout << "Second", 0;
	cout << "First";
}

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

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto a = RD;
	auto b = RD;

	writeln((a+b)/2 + (a+b)%2);
	stdout.flush();
	debug readln();
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int a , b, c, d, e, f, x;
  while(1)
    {
      scanf("%d", &x);
      if( x == 0 )break;
      a = (1000 - x) / 500;
      b = (1000 - (x+a*500))/100;
      c = (1000 - (x+a*500+b*100)) / 50;
      d = (1000 - (x+a*500+b*100+c*50)) / 10;
      e = (1000 - (x+a*500+b*100+c*50+d*10)) / 5 ;
      f = (1000 - (x+a*500+b*100+c*50+d*10+e*5)) / 1;
   
      printf("%d\n",a+b+c+d+e+f);
    }
  return 0;
}

Measured memory_bytes: 600
#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;
#define MAX_H 1000
#define MAX_W 1000

ll dp[MAX_H + 1][MAX_W + 1] = {};

signed main(){
    int h,w;
    cin >> h >> w;
    char a[h][w];
    REP(i,h){
        REP(j,w){
            cin >> a[i][j];
        }
    }
    dp[0][0] = 1;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            dp[i][j] %= MOD;
            if(a[i + 1][j] == '.'){
                dp[i + 1][j] += dp[i][j];
            }
            if(a[i][j + 1] == '.'){
                dp[i][j + 1] += dp[i][j];
            }
        }
    }
    cout << dp[h - 1][w - 1] << endl;
} 

Measured memory_bytes: 9088
#!/usr/bin/env python3

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

ans = 0 
if n>=3 and m>=3:
    ans = n*m - ((n+m)*2-4)

elif n == 2 or m == 2:
    ans = 0 
elif n == 1 and m == 1:
    ans = 1 
else:
    ans = max(n, m)-2

print(ans)


Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define LL long long 
using namespace std;
LL A[5], N;
int main()
{
#ifndef ONLINE_JUGDE
	//freopen("A.in", "r", stdin);
	//freopen("A.out", "w", stdout);
#endif
	for (int i = 1; i <= 4; ++i)
		scanf("%lld", &A[i]);
	scanf("%lld", &N);
	for (int i = 2; i <= 4; ++i)
		A[i] = min(A[i], A[i-1] * 2);
	LL Ans1 =N * A[3];
	LL Ans2 =N / 2 * A[4] + (N % 2) * A[3];
	if (A[3] * 2< A[4])
		printf("%lld\n",Ans1);
	else
		printf("%lld\n",Ans2);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define pb push_back
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll n, a, b;
	cin >> n >> a >> b;
	ll c = a + b;
	cout << (n / c) * a + min(n % c, a) << "\n";
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace abc178_b
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(" ").Select(long.Parse).ToArray();
            var a = line[0];
            var b = line[1];
            var c = line[2];
            var d = line[3];

            var ab = new long[] { a, 0, b };
            var cd = new long[] { c, 0, d };

            long m = long.MinValue;

            foreach (long x in ab)
            {
                if (x == 0 && 0 < a * b)
                {
                    continue;
                }
                foreach (long y in cd)
                {
                    if (y == 0 && 0 < c * d)
                    {
                        continue;
                    }
                    m = Math.Max(m, x * y);
                }
            }

            Console.WriteLine(m);

        }
    }
}


Measured memory_bytes: 28176
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ((int)(x).size())

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

int main() {
  ll N, sum = 0;
  cin >> N;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  FOR(i, 1, N) {
    if (A[i] < A[i-1]) {
      sum += A[i-1] - A[i];
      A[i] = A[i-1];
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3996
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = 3.141592654;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw				"\n"
int main(void)
{
	CIN;
	ll tc,l,k,sum=0,x=0,y,z=0,m=1,n=0,ans=0,cnt=0;
	string s;
	cin>>s;
	n=s.size();
	map<char,int>mp;
	map<char,int>::iterator it;	
	while(n--){

		mp[s[n]]++;
	}
	for(it=mp.begin();it!=mp.end();it++){
		if((it->second)%2==1 )return cout<<"No",0;
		//cout<<it->second<<nw;
	}
	cout<<"Yes";
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back


signed main(){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    
    int ans = 0;
    
    int buf = 0;
    priority_queue<int> pq;
    rep(i,n)pq.push(v[i]);
    
    while(pq.top()+buf>n-1){
        int t = pq.top();
        pq.pop();
        
        int div = max<ll>(0,(t+buf)/n);
        ans += div;
        buf+=div;
        pq.push(t-div*(n+1));
    }
    
    cout<<ans<<endl;
    
}

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

// 0-indexed
template <class T>
struct SegmentTree {
  // a,b,c: T, e:T(unit)
  // abc = (ab)c = a(bc)
  // ae = ea = a
  typedef function<T(T, T)> F;
  int n;
  F f;
  T unit;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(int newn, F f, T t) : f(f), unit(t) {
    init(newn);
  }
  SegmentTree(vector<T> v, F f, T t) : f(f), unit(t) {
    int _n = v.size();
    init(v.size());
    for(int i = 0; i < _n; ++i) dat[n + i] = v[i];
    for(int i = n - 1; i; --i)
      dat[i] = f(dat[i << 1], dat[(i << 1) | 1]);
  }
  void init(int newn) {
    n = 1;
    while(n < newn) n <<= 1;
    dat.assign(n << 1, unit);
  }

  // "go up" process
  void update(int k, T newdata) {
    dat[k += n] = newdata;
    while(k >>= 1) {
      dat[k] = f(dat[k << 1], dat[(k << 1) | 1]);
    }
  }
  // [a,b)
  T query(int a, int b) {
    T vl = unit, vr = unit;
    for(int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) {
      if(l & 1) vl = f(vl, dat[l++]);
      if(r & 1) vr = f(dat[--r], vr);
    }
    return f(vl, vr);
  }
};

long long n, q;
string s;
SegmentTree<bool> seg[26];

int main() {
  cin >> n >> s >> q;
  // prepair
  auto f = [](bool l, bool r) { return l | r; };
  for(int i = 0; i < 26; ++i)
    seg[i] = SegmentTree<bool>(n, f, 0);
  for(int i = 0; i < n; ++i) seg[s[i] - 'a'].update(i, 1);
  // query
  for(int i = 0; i < q; ++i) {
    int p;
    cin >> p;
    if(p == 1) {
      int k;
      char c;
      cin >> k >> c;
      seg[s[k - 1] - 'a'].update(k - 1, 0);
      seg[c - 'a'].update(k - 1, 1);
      s[k - 1] = c;
    }
    else {
      int l, r, cnt = 0;
      cin >> l >> r;
      for(int j = 0; j < 26; ++j)
        if(seg[j].query(l - 1, r)) ++cnt;
      cout << cnt << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 4100
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
typedef double D;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
//typedef pair<int, int> P;

/** Problem1188 : Hierarchical Democracy **/
string s; int pos;

int factor()
{
	if (isdigit(s[pos])) {
		int res=0;
		while (isdigit(s[pos])) {
			res*=10;
			res+=s[pos]-'0';
			pos++;
		}
		return (res+1)/2;
	} else if (s[pos] == '[') {
		pos++;
		int res=0;
		
		priority_queue<int, vector<int>, greater<int> > Q;
		while (s[pos]!=']') {
			Q.push(factor());
		}
		pos++;
		
		int n = (int)Q.size();
		rep(i, (n+1)/2) {
			res += Q.top();
			Q.pop();
		}
		
		return res;
	}
}

int main()
{
	int n;
	cin>>n;
	rep(i, n) {
		pos = 0;
		cin>>s;
		cout << factor() << endl;
	}
}

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

using namespace std;

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

#ifndef ONLINE_JUDGE
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#else
#define dbg(x)
#endif

#define X first
#define Y second
ll solve(string &s, int mask){
    int n = (int)s.size();
    ll res = 0;
    ll cur = (int)s[0] - '0';
    for (int i = 0; i < n-1; i++){
        if (mask & (1 << i)){
            res += cur;
            cur = (int)s[i+1] - '0';
        } else {
            cur = cur * 10;
            cur += (int)s[i+1] - '0';
        }
    }
    res += cur;
    return res;
}

int main(){
    std::ios_base::sync_with_stdio(false); cin.tie(0);
    string s; cin >> s;
    int n = (int)s.size();
    ll res = 0;
    for (int mask = 0; mask < (1 << (n-1)); mask++){
        res += solve(s, mask);
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	ll A[3];
	cin >> A[0] >> A[1] >> A[2];
	sort(A, A + 3);
	if (A[0] % 2 == 0 || A[1] % 2 == 0 || A[2] % 2 == 0) {
		cout << 0 << endl;
	}
	else {
		cout << A[0] * A[1] << endl;
	}
}

Measured memory_bytes: 256
from collections import defaultdict
def main():
    S = list(map(int,list(input())))
    N = len(S)
    M = [0] * (N + 1)
    ten = 1
    for i in range(N-1,-1,-1):
        M[i] = (S[i] * ten + M[i+1]) % 2019
        ten *= 10
        ten %= 2019

    d = defaultdict(int)

    for m in M:
        d[m] += 1
    ans = 0
    for i, j in d.items():
        ans += j * (j - 1) // 2
    
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 89768
#include <cstdio>
#include <cstring>

int main()
{
  char s[100001];
  scanf("%s", s);
  int l = strlen(s);
  for (int i = 0; i < l; i += 2)
  {
    printf("%c", s[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	map<string, vector<pair<int, int> > > mp;
	int n;cin>>n;
	for(int i = 0; i < n;++i){
		int x;string s;cin>>s>>x;
		mp[s].push_back({x, i});
	}
	for(auto &x : mp){
		sort(x.second.begin(), x.second.end(), greater<pair<int, int>>());
		for(auto y : x.second){
			cout<<y.second + 1<<endl;
		}
	}
	return 0;
}



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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b, c;
    int x;
    int maior;
    cin >> a >> b >> c >> x;
    for (int i = 0; i < x; ++i){
    	maior = max(a,max(b,c));
    	if(a == maior)
    		a*=2;
    	else if(b == maior)
    		b*=2;
    	else
    		c*=2; 
    }
    cout << a+b+c << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        String t = sc.next();
        int a = sc.nextInt();
        int b = sc.nextInt();
        String u = sc.next();

        if(s.equals(u)){
            a--;
        }else{
            b--;
        }

        System.out.println(a +" " + b);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=2e5+5;

int n, ans=0;
int a[N];
stack<pair<int, int> > st;
int l[N], r[N];

int32_t main()
{
	IOS;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		while(st.size() && st.top().first>a[i])
			st.pop();
		if(!st.size())
			l[i]=1;
		else
			l[i]=st.top().second+1;
		st.push({a[i], i});
	}
	while(st.size())
		st.pop();
	for(int i=n;i>=1;i--)
	{
		while(st.size() && st.top().first>a[i])
			st.pop();
		if(!st.size())
			r[i]=n;
		else
			r[i]=st.top().second-1;
		st.push({a[i], i});
	}
	for(int i=1;i<=n;i++)
		ans+=a[i] * (i-l[i]+1)*(r[i]-i+1);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define pli pair<ll, int>
// #define int long long

#define INF 1e+9
#define MAX_V 100008

vector<pair<ll, int>> factrized(ll num){
  vector<pair<ll, int>>  res;
 
  for(ll i = 2; i * i <= num; i++){
    if(num % i)continue;
    res.emplace_back(i, 0);
    while(num % i == 0){
      num /= i;
      res.back().second++;
    }
  }
  if(num != 1) res.emplace_back(num, 1);
  return res;
}

int main(){
    int x[5];
    int ans = -1;
    for (int i=0; i<5; i++){
        int c;
        cin >> c;
        if (c == 0){
            ans = i+1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3592
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
	"unsafe"
)

func main() {
	N := sc.nextInt()
	if N%2 == 0 {
		fmt.Println((float64(N) / float64(2)) / float64(N))
	} else {
		fmt.Println(math.Ceil(float64(N)/float64(2)) / float64(N))
	}

}

var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}
func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}
func (s *scanner) resetCur() {
	s.cur = 0
}
func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}
func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}
func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur],
		64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i],
			64)
	}
	s.resetCur()
	return res
}
func digits(x int) int {
	return len(strconv.Itoa(x))
}
func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}
func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}
func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}
func abs(x int) int {
	return int(math.Abs(float64(x)))
}
func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}
func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}

// Pair a
type Pair struct {
	first  int
	second int
}

// Queue a
type Queue struct {
	v []Pair
}

// Push for queue
func (q *Queue) Push(v Pair) {
	q.v = append(q.v, v)
}

// Pop for queue
func (q *Queue) Pop() Pair {
	r := q.v[0]
	q.v = q.v[1:]
	return r
}

// Front for queue
func (q Queue) Front() Pair {
	return q.v[0]
}

// Empty return true if empty
func (q Queue) Empty() bool {
	return len(q.v) == 0
}


Measured memory_bytes: 640
def main():
  K = int(input())
  A, B = map(int, input().split())
  n_A = A // K
  n_B = B // K
  if n_B > n_A:
    print('OK')
  elif n_B == n_A and B % K ==0:
    print('OK')
  elif n_B == n_A and A % K ==0:
    print('OK')
  else:
    print('NG')

main()

Measured memory_bytes: 61684
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <LL,LL>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,m,par[100010],num[100010],x,y;
vector <LL> ans;
vector <pii> in;

LL FIND(LL pos)
{
	if(par[pos]!=pos) par[pos]=FIND(par[pos]);
	return par[pos];
}

pii UNION(LL pos1,LL pos2)
{
	//cout<<pos1<<' '<<pos2<<endl;
	LL ret1=num[FIND(pos1)],ret2=num[FIND(pos2)];
	if(FIND(pos1)==FIND(pos2)) ret1=0;
	//cout<<FIND(pos1)<<' '<<FIND(pos2)<<endl;
	else
	{
	num[FIND(pos2)]=num[FIND(pos2)]+num[FIND(pos1)];
	par[FIND(pos1)]=FIND(pos2);
	}
	//cout<<FIND(pos1)<<' '<<FIND(pos2)<<' '<<num[FIND(pos1)]<<' '<<num[FIND(pos2)]<<endl;
	return {ret1,ret2};
}

int main()
{
	cin>>n>>m;
	rep(i,100005) par[i]=i,num[i]=1;
	rep(i,m)
	{
		cin>>x>>y;
		in.pb({x,y});
	}
	//cout<<endl;
	LL res=n*(n-1)/2;
	ans.pb(res);
	reverse(in.begin(),in.end());
	rep(i,in.size()-1)
	{
		pii t=UNION(in[i].fi,in[i].se);
		res-=t.fi*t.se;
		//cout<<t.fi<<' '<<t.se<<endl<<endl;
		ans.pb(res);
	}
	for(int i=m-1;i>=0;i--) cout<<ans[i]<<' ';
	cout<<endl;
	rt0;
}

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

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define repf(i, f, l) for(int i = f; i < (int)l; ++i)
#define repit(it, t) for(__typeof((t).begin()) it = (t).begin(); it != (t).end(); it++)
#define endl "\n"
#define pb emplace_back
#define lb lower_bound
#define int long long
#define ul unsigned long
#define ull unsigned long long
#define ll long long
#define INF 1000000007
#define MOD 1000000007
#define fs first
#define sd second
#define DBG0(x) { cout << #x << ": " << x << "\t"; }
#define DBG(x) {DBG0(x); cout << endl;}
#define DBG2(x, y) {DBG0(x); DBG(y);}
#define DBG3(x, y, z) {DBG0(x); DBG2(y, z);}
#define DBG4(w, x, y, z) {DBG0(w); DBG3(x, y, z);}

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ul> vul;
typedef vector<ull> vull;
typedef vector<bool> vbl;
typedef pair<int, int> pii;

int choose(int n, int k) {
    int min = (k - 1) * k / 2;
    int max = (n - k + 1 + n) * k / 2;
    int ans = max - min + 1;
    return ans;
}

signed main(void){
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int ans = 0;
    for (int i = k; i <= n + 1; ++i) {
        ans += choose(n, i);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3652
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

vector<vector<vector<ll> > > vec(4, vector<vector<ll> >(3, vector<ll>(10, 0)));

void solve() {
  ll n, m;
  cin >> n >> m;
  vector<vector<ll> > mat(n, vector<ll>(m, 0));
  rep (i, n) rep (j, m) cin >> mat[i][j];
  vector<ll> vec(m, 0);
  rep (i, m) cin >> vec[i];
  vector<ll> ans(n, 0);
  rep (i, n) rep (j, m) {
    ans[i] += mat[i][j] * vec[j];
  }
  rep (i, n) cout << ans[i] << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}



Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vd x(n),y(n);
	rep(i,n)cin>>x[i]>>y[i];
	ll ans=0;
	rep(i,10000){
		double cy=sin(2*PI*(i/10000.0));
		double cx=cos(2*PI*(i/10000.0));
		ll tx=0,ty=0;
		rep(j,n){
			if((cx*x[j]+cy*y[j])>0){
				tx+=x[j];
				ty+=y[j];
			}
		}
		//puta(cy,cx,(tx*tx+ty*ty));
		chmax(ans,(tx*tx+ty*ty));
	}
	fcout(11)<<sqrt(ans)<<endl;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF (long long) 1e18//1234567890987654321
#define INF 1234567890
#define pb push_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN 300006
#define MAXK 26
#define MAXX 15000006
#define ll long long int
#define ld long double
#define rep0(kk, l1, l2)for(ll kk = l1; kk < l2; kk++)
#define rep1(kk, l1, l2)for(ll kk = l1; kk <= l2; kk++)
#define foritr(itr, A) for(set<ll>::iterator itr = A.begin(); itr != A.end(); itr++)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ii++)
#define cr(x) cerr << #x << " = " << x << "\n";
#define crA(x, A) cerr << #x << " = " << A[x] << "\n";
#define spacing if(db)cout << " ";
#define mmst(x, v) memset((x), v, sizeof ((x)));
#define bg(ms) (*ms.begin())
#define ed(ms) (*prev(ms.end(), 1))
#define addedge(a, b, c, v) v[(a)].pb(pi((b), (c))); v[(b)].pb(pi((a), (c)))
#define ph push
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n, dp[10006*3];
struct item{
	ll w, s, v;
	bool operator < (const item &e) const{
		return s+w > e.s+e.w;
	}
} A[1006];
int main()
{
	cin >> n;
	FOR(i,0,n) cin >> A[i].w >> A[i].s >> A[i].v;
	sort(A, A+n);
	for(ll i = 0; i < n; i++)
	{
		ll w = A[i].w, s = A[i].s, v = A[i].v;
		// cout << s << ' ' << w << ' ' << v << '\n';
		for(ll i = 0; i <= s; i ++)
		{
			dp[i] = max(dp[i], dp[i+w] + v);
		}
	}
	cout << *max_element(dp, dp+10006) << '\n';
}


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

using Value = long long int;
const Value INI = 0;


namespace perseg {

	struct persistent_lazy_segtree {
		Value val;
		Value lazy;
		int l, r;
		vector < shared_ptr<persistent_lazy_segtree>>chs;
		persistent_lazy_segtree(const int size_) :val(INI), lazy(INI), l(0), r(size_), chs(2, nullptr) {

		}
		persistent_lazy_segtree(const int l_,const int r_):val(INI),lazy(INI),l(l_),r(r_),chs(2,nullptr) {

		}
		persistent_lazy_segtree(const shared_ptr<persistent_lazy_segtree>&tree_) :val(tree_->val), lazy(tree_->lazy), l(tree_->l), r(tree_->r),chs(tree_->chs) {
		}
		Value add_val(const Value&l, const Value&r) {
			return l + r;
		}
		Value add_lazy(const Value&l, const Value&r) {
			return l + r;
		}
		Value ltov(const Value&la) {
			return la*(r - l);
		}
		shared_ptr<persistent_lazy_segtree>getch(const int num) {
			if (chs[num] == nullptr) {
				const int m = (l + r) / 2;
				if (!num) {
					chs[0] = make_shared<persistent_lazy_segtree>(l, m);
				}
				else {
					chs[1] = make_shared<persistent_lazy_segtree>(m,r);
				}
			}
			return chs[num];
		}
		void push() {
			if (lazy!=INI) {
				val += ltov(lazy);
				if (l + 1 != r) {
					const int m = (l + r);
					chs[0] = make_shared<persistent_lazy_segtree>(getch(0));
					chs[0]->lazy = chs[0]->add_lazy(chs[0]->lazy, lazy);
					chs[1] = make_shared<persistent_lazy_segtree>(getch(1));
					chs[1]->lazy = chs[1]->add_lazy(chs[1]->lazy, lazy);
				}
				lazy = INI;
			}
		}
		Value query(int a, int b) {
			if (r <= a or b <= l)return 0;
			else if (a<=l&&r<=b) {
				return val + ltov(lazy);
			}
			else {
				push();
				const int m = (l + r) / 2;
				const Value lval=getch(0)->query(a, b);
				const Value rval=getch(1)->query(a, b);
				return add_val(lval, rval);
			}
		}
		void update(int a,int b,int k) {
			if (r <= a or b <= l)return;
			else if (a<=l && r<=b)lazy += k;
			else {
				push();
				const int m = (l + r) / 2;
				getch(0)->update(a, b, k);
				getch(1)->update(a, b, k);
				val = chs[0]->val + chs[0]->ltov(chs[0]->lazy) + chs[1]->val + chs[1]->ltov(chs[1]->lazy);
			}
		}
	};
}

struct query {
	int l;
	int r;
	int v;
};
using namespace perseg;

int main() {
	int N, Q; cin >> N >> Q;
	persistent_lazy_segtree seg(1<<17);
	while (Q--) {
		int a; cin >> a;
		if (a) {
			int i; cin >> i;
			i--;
			Value ans = seg.query(i, i + 1);
			cout << ans << endl;
		}
		else {
			int s, t, x; cin >> s >> t >> x;
			s--;
			seg.update(s, t, x);
		}
	}

	return 0;
}

Measured memory_bytes: 26372
/*Author - Shubham Gupta (@shubham107)*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;		typedef vector<int> vi;
typedef vector<vl> vvl;	  	typedef vector<vi> vvi;
typedef pair<ll, ll> pll;	typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF	ll(1e18)
#ifdef SHUBHAM107
#include "../code-pieces/trace.h"
#else
#define trace(args...)
#endif

ll modpow(ll a, ll b, ll m = MOD) {
	a %= m; ll res = 1; while (b) {if (b & 1)res = res * a % m; a = a * a % m; b >>= 1;}
	return res;
}
ll bpow(ll a, ll b) {ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a) {return modpow(a, MOD - 2, MOD);}
void graph(vvi &adj, int m) {int x, y; forn(i, m) {cin >> x >> y; adj[x - 1].pb(y - 1); adj[y - 1].pb(x - 1);}}

const int mxN = 2e5 + 5;
void solve() {
	int k, a, b;
	cin >> k >> a >> b;
	forse(i, a, b+1){
		if(i % k == 0){
			cout << "OK";
			return;
		}
	}
	cout << "NG";
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef SHUBHAM107
	freopen("inp.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("err.txt", "w", stderr);
#endif
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
}


Measured memory_bytes: 3600
#include <iostream>
using namespace std;
int main() {
    int r;
    cin>>r;
    if(400<=r&&r<=599)
        cout<<8;
    if(600<=r&&r<=799)
    cout<<7;
    if(800<=r&&r<=999)
    cout<<6;
    if(1000<=r&&r<=1199)
    cout<<5;
    if(1200<=r&&r<=1399)
    cout<<4;
    if(1400<=r&&r<=1599)
    cout<<3;
    if(1600<=r&&r<=1799)
    cout<<2;
    if(1800<=r&&r<=1999)
    cout<<1;
  
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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

		vector<ll> num(K, 0);
		for (int i = 1; i <= N; i++) num[i%K]++;

		ll res = 0;
		for (int a = 0; a < K; a++) {
				int b = (K - a) % K;
				int c = (K - a) % K;
				if ((b + c) % K != 0) continue;
				res += num[a] * num[b] * num[c];
		}

		cout << res << endl;
		return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
using namespace std;
int gcd(int a, int b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}
int main() {
  int n;
  cin >> n;
  int ans=lcm(2,n);
  cout << ans << endl;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void) {
	int n, a[10000], i, cnt=0;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if (a[i] % 2 == 0) {
			while (a[i] % 2 == 0) {
				a[i] = a[i] / 2;
				cnt++;
			}
		}
	}
	printf("%d\n", cnt);
}

Measured memory_bytes: 256
//author: zekigurbuz (Zeki Gurbuz) 2020
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;

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

#define mp make_pair
#define pb push_back
#define lb lower_bound
#define all(x) begin(x),end(x)

const int N = 1e5 + 10;
const int M = 1e9 + 7;

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

template<class T>void ckmin(T&a,T b){a=min(a,b);}
template<class T>void ckmax(T&a,T b){a=max(a,b);}

void precomp() {

}

ll a, b, n;

ll f(ll x) {
	return (a * x) / b - a * (x / b);
}

void solve() {
	cin >> a >> b >> n;
	cout << f(min(b-1,n));
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	precomp();
	int t = 1; // cin >> t;
	for (int i = 1; i <= t; ++i) {
		solve();
	}
	return 0;
}



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

int main(void){
	int ans=-1;
	char c, a=0;
	while((c=getchar())!=10){
		ans += (c!=a);
		a=c;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.first << ", " << p.second << ")";
}
 
template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
	out << "{";
	for(auto it = a.begin(); it != a.end(); it = next(it))
		out << (it != a.begin() ? ", " : "") << *it;
	return out << "}";
}
 
void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
	cerr << a << ", ";
	dump(x...);
}
 
#ifdef DEBUG
#  define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
#  define debug(...) false
#endif

#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
template<class T> int size(T && a) { return a.size(); }
template<class T> int sz(T && a) { return a.size(); }
 
using LL = long long;
using PII = pair<int, int>;


/*
 * Opis: Struktura do działań modulo
 * Czas: O(1), dzielenie O(\log mod)
 * Użycie: Ustaw modulo w ostatniej linii. Jeśli modulo nie jest const, usuń pierwszy wiersz i zadeklaruj mod
 */

int mod;
struct mi {
	int val;
	mi() { val = 0; }
	mi(const LL& v) {
		val = (-mod <= v && v <= mod) ? v : v % mod;
		if(val < 0) val += mod;
	}

	friend ostream& operator<<(ostream &os, const mi &a) {
		return os << a.val;
	}
	friend istream& operator>>(istream &is, mi &a) {
		return is >> a.val;
	}

	friend bool operator==(const mi &a, const mi &b) {
		return a.val == b.val;
	}
	friend bool operator!=(const mi &a, const mi &b) {
		return !(a == b);
	}
	friend bool operator<(const mi &a, const mi &b) {
		return a.val < b.val;
	}
	friend bool operator<=(const mi &a, const mi &b) {
		return a.val <= b.val;
	}

	mi operator-() const { return mi(-val); }
	mi& operator+=(const mi &m) {
		if((val += m.val) >= mod) val -= mod;
		return *this;
	}
	mi& operator-=(const mi &m) {
		if((val -= m.val) < 0) val += mod;
		return *this;
	}
	mi& operator*=(const mi &m) {
		val = (LL) val * m.val % mod;
		return *this;
	}
	friend mi qpow(mi a, LL n) {
		if(n == 0) return 1;
		if(n % 2 == 1) return qpow(a, n - 1) * a;
		return qpow(a * a, n / 2);
	}
	friend mi inv(const mi &a) {
		assert(a != 0); return qpow(a, mod - 2);
	}
	mi& operator /=(const mi &m) { 
		return (*this) *= inv(m); 
	}

	friend mi operator+(mi a, const mi &b) { return a += b; }
	friend mi operator-(mi a, const mi &b) { return a -= b; }
	friend mi operator*(mi a, const mi &b) { return a *= b; }
	friend mi operator/(mi a, const mi &b) { return a /= b; }
};

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

	int n, m;
	cin >> n >> mod;
	m = n - 1;

	vector<mi> dp(n);
	dp[0] = 1;
	REP(i, n - 1) {
		vector<mi> nxt(n);
		int q = (i <= m / 2 ? i : m - i) + 1;
		debug(i, q);
		REP(j, n) nxt[j] = dp[j] + (j >= q ? nxt[j - q] : 0);
		dp = nxt;
	}

	mi ans = 0;
	REP(i, n) ans += (n - i) * dp[i];
	cout << ans << "\n";
}


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

int main(){
    int n,m;
    cin >> n >> m;
    int a[n];
    for(int i=0; i<n; i++) cin >> a[i];
    int sum=0;
    int cnt=0;
    for(int i=0; i<n; i++) sum += a[i];
    for(int i=0; i<n; i++){
        if(a[i]*4*m >= sum) cnt++;
    }
    if(cnt >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var x, y, z, w int
	fmt.Scan(&x, &y, &z)
	for w = 1; ; w++ {
		if z+(y+z)*w <= x && x < z+(y+z)*(w+1) {
			break
		}
	}
	fmt.Println(w)
}


Measured memory_bytes: 512
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n,a,b=map(int,input().split())
    if(a+b>n+1):
        print(-1)
        return
    if(a*b<n):
        print(-1)
        return

    ans=list(range(b,0,-1))
    now=b
    d=a*b-n
    for _ in range(a-1):
        k=min(d,b-1)
        d-=k
        next=now+(b-k)
        for i in range(next,now,-1):
            ans.append(i)
        now=next

    print(*ans)
resolve()

Measured memory_bytes: 67568
import java.util.*;
 
class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int c[] = new int[n-1];
        int s[] = new int[n-1];
        int f[] = new int[n-1];
        for(int i=0; i<n-1; i++){
            c[i] = sc.nextInt();
            s[i] = sc.nextInt();
            f[i] = sc.nextInt();
        }
        for(int i=0; i<n; i++){
            int t = 0;
            for(int j=i; j<n-1; j++){
                if(t<s[j]) t=s[j];
                else if(t%f[j] == 0) ;
                else t = t+f[j] - t%f[j];
                t+=c[j];
            }
            System.out.println(t);
        }
        
    }
}

Measured memory_bytes: 26924
#include <bits/stdc++.h>
using namespace std;
int main() {
  bool kaibun = true;
  string S;
  cin >> S;
  int a = S.size();
  int b = a/2;
  for (int i = 0; i < b; i++) {
    if (S.at(i) != S.at(a-1-i)) {
      kaibun = false;
      cout << "No" << endl;
      break;
    }
  }
  if (kaibun == true) {
    int c = b/2;
    for (int j = 0; j < c; j++) {
      if (S.at(j) != S.at(b-1-j)) {
        kaibun = false;
        cout << "No" << endl;
        break;
      }
    }
  }
  if (kaibun == true) {
    cout << "Yes" << endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>

#define DIV 1000000007
using namespace std;
using ll = long long;

int main() {
	int N, L;
	cin >> N >> L;

	vector<string> s(N);
	for (int i = 0; i < N; i++)
		cin >> s[i];

	sort(s.begin(), s.end());
	for (int i = 0; i < N; i++)
		cout << s[i];
	cout << endl;
}


Measured memory_bytes: 384
/*s1190073  Rina Sato
  File name: prog6a.c
  This is a counting sort program.
*/

#include <stdio.h>
int A[2000001],B[2000001];

int main(void){ 
  int i,k=0,j,n,C[10001];
  
  scanf("%d",&n);
  for(j = 1 ; j <= n ; j++){
    scanf("%d",&A[j]);
  }
  for(j = 1 ; j <= n ; j++){
    if(A[j] > k){   
      k = A[j];
    }
  }
  
  for(i = 0 ; i <= k ; i++){
    C[i] = 0;
  }
  for(j = 1 ; j <= n ; j++){
    C[A[j]] = C[A[j]] + 1;
  }
  
  for(i = 0 ; i <= k ; i++){
    C[i] = C[i] + C[i-1];
  }
  
  for(j = n ; j >= 1 ; j--){
    B[C[A[j]]] = A[j];
    C[A[j]] = C[A[j]] - 1;
  }
  for(j = 1 ; j <= n ; j++){
    printf("%d",B[j]);
    if(j <= n-1){
      printf(" ");
    }
  }
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 15000
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

struct UNION_FIND
{
	int n;
	vector<int>parent, height, Sum;
	UNION_FIND() { ; }
	UNION_FIND(int s)
	{
		n = s;
		parent.resize(n), height.resize(n, 1), Sum.resize(n, 1);
		for (int i = 0; i<n; i++) parent[i] = i;
	}
	int find(int u)
	{
		if (u == parent[u]) return u;
		return find(parent[u]);
	}
	void merge(int u, int v)
	{
		u = find(u), v = find(v);
		if (u == v) return;
		if (height[u]>height[v]) swap(u, v);
		parent[u] = v;
		Sum[v] += Sum[u];
		if (height[u] == height[v]) height[v]++;
	}
	int getSum(int u)
	{
		return Sum[find(u)];
	}
};
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int N, M;
	cin >> N >> M;
	UNION_FIND uf(N + 1);
	while (M--)
	{
		int u, v;
		cin >> u >> v;
		uf.merge(u, v);
	}
	int maxN = 0;
	for (int i = 1; i <= N; i++)maxN = max(maxN, uf.getSum(i));
	cout << maxN;
}

Measured memory_bytes: 5572
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//typedef vector<ll> vec;
//typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

const ll MAX_N=100;

ll x,a,b,c;

int main(){
  cin>>a>>b>>c>>x;
  ll ans=0;
  for(ll i=0;i<=a;i++){
    for(ll j=0;j<=b;j++){
      for(ll k=0;k<=c;k++){
        if((500*i+100*j+50*k)==x)ans++;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
while true
    a = gets.split().map {|x| x.to_i}
    if a[0]==0 and a[1]==0 then
        break
    end

    deck = []
    for i in 1..a[0] do
        deck << i
    end
    for i in 1..a[1] do
        spam = gets.split().map {|x| x.to_i}
        tmp = deck.slice!((-spam[0]-spam[1]+1)..-spam[0]) 
        deck = deck + tmp
    end
    puts deck[deck.length-1]
end

Measured memory_bytes: 6148
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    long long a[n],b[n];
    typedef pair<long long,long long> p;
    vector<p> c(n);
    for(int i = 0;i < n;i++){
        cin >> c[i].first >> c[i].second;
    }
    sort(c.begin(),c.end(),[](const p& x,const p& y){return x.first < y.first;});

    long long  num = 0;
    long long  ans = 0;

    for(long long i = 0;i < n;i++){
        if(num + c[i].second < m){
            num +=c[i].second;
            ans += c[i].second * c[i].first;
        }else {
            ans += (m-num) * c[i].first;
            num = m;
        }
        if(num == m) break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792