akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

const long MAX = 2000000;
const long INFTY (1<<30);

long H, A[MAX + 1];

void maxHeapify(long i){
	long l = 2 * i;
	long r = 2 * i + 1;

	long largest;
	if (l <= H && A[l] > A[i]){
		largest = l;
	}
	else {
		largest = i;
	}
	if (r <= H && A[r] > A[largest]){
		largest = r;
	}

	if (largest != i){
		swap(A[i], A[largest]);
		maxHeapify(largest);
	}
}

long extract(){
	long maxv;
	if (H < 1) return -INFTY;
	maxv = A[1];
	A[1] = A[H--];
	maxHeapify(1);
	return maxv;
}

void increaseKey(long i, long key){
	if (key < A[i]) return;
	A[i] = key;
	while (i > 1 && A[i / 2] < A[i]){
		swap(A[i], A[i / 2]);
		i /= 2;
	}
}

void insert(long key){
	H++;
	A[H] = -INFTY;
	increaseKey(H, key);
}

int main(){
	long key;
	string com;

	while (1){
		cin >> com;
		if (com[0] == 'e' && com[1] == 'n') break;
		if (com[0] == 'i'){
			cin >> key;
			insert(key);
		}
		else {
			cout << extract() << endl;
		}
	}

	return 0;
}

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

int main(){

    int n, x;
    cin >> n;

    for(int i=1; i< n+1; i++){
        x = i;
        if(x%3==0){
            cout << " " << i;
        }
        else{
            do{
                if(x%10==3){
                    cout << " " << i;
                    break;
                }
                x/=10;
            }while(x!=0);
        }
    }

    cout << endl;
    return 0;
}


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

long n_gcd(long a, long b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

long count_div(long a, long b, long n) {
    long div_a = a / n;
    long div_b = b / n;
    long s = div_b - div_a + 1;
    if (a % n != 0) {
        s -= 1;
    }
    return s;
}

int main() {
    long a, b, c, d;
    cin >> a; cin >> b; cin >> c; cin >> d;

    long div_c, div_d, div_cd;
    div_c = count_div(a, b, c);
    div_d = count_div(a, b, d);
    div_cd = count_div(a, b, c*d/n_gcd(c, d));

    long ans = (b - a + 1) - (div_c + div_d - div_cd);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define N 3
#define T 1
#define F 0

int dx[4]={0,-1,0,1};
int dy[4]={1,0,-1,0};
int limit;
int t[N][N];

void swap(int *x,int *y){
  int tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
  return ;
}

int GetHeuristic(){
  int i,j,sum = 0,x;
  for(i = 0 ; i < N ; i++){
    for(j = 0 ; j < N ; j++){
    if(t[i][j] == 0)continue;
    x = t[i][j]-1;
    sum += abs(x/N - i) + abs(x%N - j);
    }
  }
  return sum;
}

int dfs(int depth,int prev,int py,int px){
  int h = GetHeuristic();
  if(h == 0)return T;
  if(depth+h > limit)return F;
  int i;
  for(i = 0 ; i < 4 ; i++){
    if(abs(i-prev) == 2)continue;
    int tx = px + dx[i],ty = py + dy[i];
    if(tx < 0 || ty < 0 || tx >= N || ty >= N)continue;
    swap(&t[ty][tx],&t[py][px]);
    if(dfs(depth + 1,i,ty,tx))return T;
    swap(&t[ty][tx],&t[py][px]);
  }
  return F;
}

void isSolved(int py,int px){
  for(limit = 0 ; ; limit++){
    if(dfs(0,99,py,px)){
      printf("%d\n",limit);
      return ;
    }
  }
}

int main(){
  int i,j,px,py;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      scanf("%d",&t[i][j]);
      if(t[i][j]==0){
        py=i;
        px=j;
      }
    }
  }
  isSolved(py,px);
  return 0;
}



Measured memory_bytes: 2084
//Name: Programming Contest
//Level: 1
//Category: やるだけ
//Note:

/**
 * 行ごとに1の個数の総和を求める。
 *
 * オーダーは O(MN)。
 */
#include <iostream>
#include <algorithm>

using namespace std;

bool solve() {
    int M, N;
    if(!(cin >> M >> N)) return false;

    int ans = 0;
    for(int i = 0; i < M; ++i) {
        int sum = 0;
        for(int j = 0; j < N; ++j) {
            int v;
            cin >> v;
            sum += v;
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return true;
}

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

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 1192
R, G, B, N = map(int, input().split())

ans = 0

for i in range(N + 1):
    r = R * i
    if r > N:
        break
    for j in range(N + 1):
        g = G * j
        if r + g > N:
            break
        b = N - r - g
        if b % B == 0:
            ans += 1

print(ans)


Measured memory_bytes: 9172
#! /usr/local/bin/python3
# coding: utf-8

from sys import stdin
from collections import deque

def main():
    n = int(input())
    dll = deque()

    for _ in range(n):
        line = stdin.readline().split()
        if line[0] == "insert":
            dll.appendleft(int(line[1]))
        elif line[0] == "delete":
            try:
                dll.remove(int(line[1]))
            except ValueError:
                None
        elif line[0] == "deleteFirst":
            dll.popleft()
        elif line[0] == "deleteLast":
            dll.pop()

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

main()



Measured memory_bytes: 45952
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
const int MR=1e6+10;
typedef long long LL;

int main() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(a>0 && c>0){
		c-=b;
		if(c<=0){
			printf("Yes\n");
			return 0;
		}
		a-=d;
		if(a<=0){
			printf("No\n");
			return 0;
		}		
	}
    return 0;
}

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

#define LL long long
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<LL>
#define VVL vector<vector<LL>>
#define VVVL vector<vector<vector<LL>>>
#define VB vector<bool>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

template<class T> T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> void print(T x) { std::cout << x << std::endl; }

const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy = { 0, -1, 0, 1 }, dx = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）

using namespace std;


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

    int N;
    cin >> N;
    vector<int> dp(100003, 0);
    FOR(i, 0, N) {
        int a, b;
        cin >> a >> b;
        dp[a - 1] += 1;
        dp[b] -= 1;
    }

    FOR(i, 0, dp.size() - 1) {
        dp[i + 1] += dp[i];
    }

    int ans = 0;
    FOR(i, 1, N + 1) {
        if (i <= dp[i]) {
            ans = max(ans, min(dp[i], i));
        }
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 3488
object Main{
 def main(args:Array[String]) = {
  val sc = new java.util.Scanner(System.in)
  val list = List.fill(4)(sc.nextInt).sorted
  if(List(1,4,7,9) == list){
    println("YES")
  }
  else{
   println("NO")
  }
}
}

Measured memory_bytes: 25916
package main

import "fmt"

func main() {
	var num int
	var n string
	fmt.Scanf("%s",&n)
	
	weathers := [3]string{"Sunny","Cloudy","Rainy"}
	
	for i:=0; i < len(weathers); i++ {
		if weathers[i] == n {
			num = i
			break
		}
	}
	num = (num + 1) % len(weathers)
	
	fmt.Printf("%s",weathers[num])
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n; cin >> n;
    set<string> st;
    for (int i = 0; i < n; i++) {
        string s; cin >> s;
        st.insert(s);
    }
    cout << st.size() << endl;
    return 0;
}


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

int main(){
  
  	/*long long n, k; cin >> n >> k;
    double res = 0.0;
    for(long long i=1; i<n+1; ++i){
        double tmp = 1.0;
        long long d = i;
        while (d < k) d *= 2, tmp /= 2.0;
        res += tmp;
    }
    res /= n;
    cout << fixed << setprecision(10) << res << endl;*/
  
    long long n, k; cin >> n >> k;
    double res = 0.0;
    for(long long i=1; i<n+1; ++i){
        double tmp = 1.0;
        long long d = i;
        while(d<k){d *= 2; tmp /= 2.0;}
        res += tmp;
    }
    res /= n;
    cout << fixed << setprecision(15) << res << endl;
    return 0;
}

Measured memory_bytes: 3748
#lang racket

(define (read-int n)
  (if (zero? n)
      null
      (cons (- (read) 1) (read-int (- n 1)))))

(define (solve N A)
  (let ([bukas (make-vector N 0)])
    (define (iter a)
      (if (null? a)
          bukas
         (begin (vector-set! bukas
                             (car a)
                             (+ (vector-ref bukas (car a)) 1))
                (iter (cdr a)))))
    (iter A)))
    
(define (print items sep)
  (define (iter items)
    (if (null? items)
        (newline)
        (begin
          (display (car items))
          (display sep)
          (iter (cdr items)))))
  (iter items))

(let* ([N (read)]
       [A (read-int (- N 1))])
  (print (vector->list (solve N A)) "\n"))
  


Measured memory_bytes: 108860
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
ll gcd(ll a, ll b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
  int N;
  cin >> N;
  ll ans = 1;
  REP(i, N) {
    ll T;
    cin >> T;
    ans = lcm(T, ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <set>
#include <string>
#include <vector>

int main() {
  uint32_t N = 0;
  std::cin >> N;

  std::vector<uint32_t> d(N);
  for (uint32_t i = 0; i < N; i++) std::cin >> d[i];

  std::set<uint32_t> d_unique(d.begin(), d.end());
  std::cout << d_unique.size() << std::endl;

  return 0;
}

Measured memory_bytes: 256
from collections import deque

H, W = 10, 37
ARR = [
    ".....................................",
    "...#...####...####..###...###...###..",
    "..#.#..#...#.##....#...#.#...#.#...#.",
    "..#.#..#...#.#.....#...#.#...#.#...#.",
    ".#...#.#..##.#.....#...#.#.###.#.###.",
    ".#####.####..#.....#...#..##....##...",
    ".#...#.#...#.#.....#...#.#...#.#...#.",
    ".#...#.#...#.##....#...#.#...#.#...#.",
    ".#...#.####...####..###...###...###..",
    ".....................................",
]

H, W = map(int, input().split())
ARR = []

for i in range(H):
    ARR.append(input())


def calculate(h, w, arr):
    q = deque()

    q.append((0, 0))

    dx = [0, 1, 0, -1]
    dy = [-1, 0, 1, 0]

    distance = [[0 for i in range(w)] for j in range(h)]
    distance[0][0] = 1
    while q.__len__() > 0:
        y, x = q.popleft()
        for i in range(4):
            my = y + dy[i]
            mx = x + dx[i]
            if (my >= 0) and (mx >= 0) and (my <= (h - 1)) and (mx <= (w - 1)) and (distance[my][mx] == 0) and (
                    arr[my][mx] == "."):
                distance[my][mx] = distance[y][x] + 1
                q.append((my, mx))

    mmk = 0
    for j in range(h):
        mmk += arr[j].count("#")

    if distance[h - 1][w - 1] == 0:
        print(-1)
    else:
        print(h * w - distance[h - 1][w - 1] - mmk)


calculate(H, W, ARR)


Measured memory_bytes: 9428
#include <iostream>
using namespace std;
int main(void){
    int H, W;
    while(true){
        cin >> H >> W;
        if(H==0 && W==0) break;
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                if((i%2==0 && j%2==0) || (i%2==1 && j%2==1)){
                    cout << "#";
                }
                else{
                    cout << ".";
                }
            }
            cout << endl; 
        }
        cout << endl;
    }
}



Measured memory_bytes: 3104
"use strict"
function main(arg) {
    var data = arg.trim().split("\n")[0].split(" ").map(Number)
    console.log(lcm(data[0], data[1]))
}

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

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

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
N, M = map(int, input().split())
res = 0
L_max = 0
R_min = 100000
for _ in range(M):
  L, R = map(int, input().split())
  if L_max < L: L_max = L
  if R < R_min: R_min = R
  
  
print(max(0, (R_min - L_max + 1)))

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#include <cstdlib>
using namespace std;
#define ll long long
typedef vector<vector<ll> > matrix;
#define pb push_back
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const double PI  =3.141592653589793238463;
long long MOD = 1000000007;

int stringToInteger(string x){
    int gg=0;
    stringstream geek(x);
    geek >> gg;
    return gg;
}

ll powmod(ll a,ll b,ll m)
{
    ll ans=1;
    while(b>0){ if(b%2)
        {ans*=a; ans%=m;}
         b/=2; a=a*a; a=a%m;
        }
        return ans%m;
}
ll gcd(ll a,ll b)
{

    return __gcd(a,b);
}
ll mulmod(ll a,ll b,ll m)
{  ll ans=0;
    a %=m;
    while (b>0)
    {       if(b&1) ans = (ans + a) % m;
        a = (a * 2)%m;
        b /= 2;
    }
    return ans % m;
}

ll f[2000001];



ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a;
 while(b > 0)
 	{
 		if(b%2 == 1)
 	{
 		x=(x*y);
 		if(x>MOD) x%=MOD;
 	}
 	y = (y*y);
 	if(y>MOD) y%=MOD;
 	b /= 2;
 	}
 return x;
}

/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}

bool prime[100005];
void seive()
{  memset(prime,true,sizeof(prime));
    for(int i=2;i*i<=100005;i++)
    {
         if(prime[i]==true) {
        for(int j=2*i;j<=(100005);j+=i)
           { prime[j]=false;}
           }

    }
}
bool in(float x1,float y1,float x,float y,float r )
{
    if(abs(x1-x)*abs(x1-x)+abs(y1-y)*abs(y1-y)<=r*r) return true;
    return false;
}
bool cmp(pair<int,int> &a,pair<int,int> &b)
{

        return (a.second<b.second);
}
//
//vector<vector<int> >matrix;
matrix mul(matrix A,matrix B)
{
    matrix C(3, vector<ll>(3));
    for(int i=1;i<=2;i++)
    for(int j=1;j<=2;j++)
     for(int k=1;k<=2;k++)
         C[i][j] = (C[i][j] + A[i][k] * B[k][j]);
    return C;

}
matrix pow(matrix A, int p)
{
    if (p == 1)
        return A;
    if (p % 2)
        return mul(A, pow(A, p-1));
    matrix X = pow(A, p/2);
    return mul(X, X);
}
ll fib(int N,int a,int b)
{
    vector<ll> F1(3);
    F1[1] = a;
    F1[2] = b;
    matrix T(3, vector<ll>(3));
    T[1][1] = 0, T[1][2] = 1;
    T[2][1] = -1, T[2][2] = 1;
    if (N == 1)
        return a;
    if(N==2) return b;
    T = pow(T, N-1);
    ll res = 0;
    for(int i=1;i<=2;i++)
        res = (res + T[1][i] * F1[i]+ MOD)%MOD ;
    return res;
}

//1 2 3 4 5
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

 int t =1;
 while(t--)
  {
      int n;
      cin>>n;
      vector<int>v;
      map<int,ll>mp;
      ll ans=0;
      for(int i=0;i<n;i++)
      {
          ll a;
          cin>>a;
          mp[a]++ ;
          mp[a-1]++;
          mp[a+1]++;


      }
      for(int i=0;i<=100000;i++) ans=max(ans,mp[i]);
      cout<<ans;
     // 3 0 3 0 3

  }
}


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

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; }

const long long INF = 1LL << 60;

int main(){
  vector<int> a(3);
  rep(i, 3) cin >> a[i];
  sort(all(a));

  int cnt = (a[2]-a[0]) + (a[2]-a[1]);
  if(cnt%2 == 1) cnt += 3;

  cout << cnt / 2 << endl;

  return 0;
}


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

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";


#define     SPEED     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	ll          long long int
#define 	pb          push_back
#define 	pii         pair<int,int>
#define 	vi          vector<int>
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	hell        1000000007
#define 	rep(i,n)    for(i=0;i<n;i++)
#define 	repe(i,a,b) for(i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search
#define 	mp          make_pair

ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2);
	if(b%2==0)
		return((c%hell)*(c%hell))%hell;
	return ((((c%hell)*(c%hell))%hell)*(a%hell))%hell;
}

/********************************************************/
ll h[100005],dp[100005],n;

ll f(ll x)
{
	if(x>n-1)
		return hell;
	if(x==n-1)
		return 0;
	if(dp[x]==-1)
	{
		dp[x]=f(x+1)+abs(h[x+1]-h[x]);
		if(x<n-2)
			dp[x]=min(dp[x],f(x+2)+abs(h[x+2]-h[x]));
	}
	// debug2(x,dp[x]);
	return dp[x];
}

int main()
{
	SPEED;
	ll k,t,c=0,i,j,m,cs=0;
	t=1;

	//cin>>t;
	string s;
	while(t--)
	{
		cin>>n;
		// n=s.length();
		// ll a[n];
		rep(i,n)
		{
			cin>>h[i];
			dp[i]=-1;
		}
		dp[0]=0;
		dp[1]=abs(h[0]-h[1]);
		repe(i,2,n)
		{
			dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]) , dp[i-2]+abs(h[i]-h[i-2]));
		}
		cout<<dp[n-1];
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>

int main()
{
    int k;
    std::cin >> k;
    if (k % 2 == 0 || k % 5 == 0)
    {
        std::cout << -1 << '\n';
        return 0;
    }
    int cur = 0, pre = 1;
    for (int i = 1; i <= k; ++i)
    {
        cur += 7 * pre;
        cur %= k;
        if (cur == 0)
        {
            std::cout << i << '\n';
            return 0;
        }
        pre *= 10;
        pre %= k;
    }
}

Measured memory_bytes: 3608
a = [int(input()) for _ in range(5)]

last_index = -1
last_t = 10
for i in range(len(a)):
    if (a[i]-1) % 10 < last_t:
        last_t = (a[i]-1) % 10
        last_index = i

total = 0
for i in range(len(a)):
    if i == last_index:
        total += a[i]
    else:
        total += a[i] if a[i] % 10 == 0 else 10 * (a[i] // 10 + 1)

print(total)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
 int a,b,c,d,e;
  cin >> a >> b >> c >> d >> e;
  cout << (c-a)*60+d-b-e << endl;
}  


Measured memory_bytes: 3636
// Problem : A - Kth Term
// Contest : Panasonic Programming Contest 2020
// URL : https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

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

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

ll pow(ll a, ll b) {
	if (b == 0) return 1;
	ll d = pow(a, b / 2);
	ll z = 1;
	if (b % 2) z = a;
	return (((d * d) % MOD) * z) % MOD;
}

int n;
vi v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n;
	cout << v[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define nn '\n'
#define YES {cout<<"YES"<<'\n'}
#define NO {cout<<"NO"<<'\n'}
#define Yes {cout<<"Yes"<<'\n'}
#define No {cout<<"No"<<'\n'}
#define yes {cout<<"yes"<<'\n'}
#define no {cout<<"no"<<'\n'}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

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

    int a,b; cin >> a >> b;
    if((a+b)/2==( (double)a + (double)b )/2.0 ){out((a+b)/2);}
    else out("IMPOSSIBLE");

    return 0;
}

Measured memory_bytes: 256
(stdin => {
  // Define Function
  const between = (min, max, n) => n >= min && n <= max
  const inRange = f => (r, pos, max) => f(r, max - r, pos)
  const messaging = pred => (t, f) => pred ? t : f
  // Declare Variable
  const inputs = stdin.toString().trim().split('\n')
  const [W, H, x, y, r] = Array.from(inputs[0].split(' '), Number)
  const message = messaging([[r, x, W], [r, y, H]]
    .every(array => inRange(between)(...array)))
 
  console.log(message('Yes', 'No'))

})(require('fs').readFileSync('/dev/stdin', 'utf8'))



Measured memory_bytes: 17188
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
string NEXT(string S){
  if(S=="7")return "33";
  int N=S.size();
  if(S.at(N-1)=='7')return NEXT(S.substr(0,N-1))+"3";
  S.at(N-1)+=2;
  return S;
}
bool OK(string S){
  int i;bool x=0,y=0,z=0;
  REP(i,S.size()){
    if(S.at(i)=='3')x=1;
    if(S.at(i)=='5')y=1;
    if(S.at(i)=='7')z=1;
  }
  return x&&y&&z;
}
signed main(){
  int N,ans=0;cin>>N;string S="357";
  while(S.size()<10&&stoi(S)<=N){
    ans++;S=NEXT(S);
    while(!OK(S))S=NEXT(S);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    	cin.tie(0);
        ios::sync_with_stdio(0);
    	int x,a,b;
    	cin>>x>>a>>b;
    	if(abs(x-a)<abs(x-b))cout<<'A';
    	else 
    		cout<<'B';
 	return 0;
}


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

int main() {
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(M);
    for (int i = 0; i < M; i++) {
        cin >> B[i];
    }
    int cnt = 0;
    vector<vector<int>> A(N, vector<int>(M));
    for (int i = 0; i < N; i++) {
        int sum = 0;
        for (int j = 0; j < M; j++) {
            cin >> A[i][j];
            sum += A[i][j] * B[j];
        }
        if (sum + C > 0) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  N=I()
  a=[I() for _ in range(N)]

  for x in a:
    if x%2!=0:
      return 'first'

  return 'second'

# main()
print(main())


Measured memory_bytes: 14676
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    int n; cin >> n;
    vector<int> v(n); rep(i,n) cin >> v[i];
    int ans=0;
    rep(i,n-1){
        if(v[i] ==v[i+1]){
            v[i+1] = -1;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
	int N, K, Q; cin >> N >> K >> Q;
	vector<int>Quiz(N, K);
	for (int i = 0; i < Q; i++) {
		int C; cin >> C;
		Quiz.at(C - 1)++;
	}

	for (int i = 0; i < N; i++) {
		Quiz.at(i) -= Q;
		if (Quiz.at(i) <= 0) cout << "No" << endl;
		else cout << "Yes" << endl;
	}
}

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

int main(){
    long long x;
    cin>>x;
    long long answer;
    long double frac=ceil((double)x/11);
    answer=2*((frac));
    if(answer/2*11-5>=x){
        answer=answer-1;
    }
    cout<<answer<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b,c,j=0;
    scanf("%d %d %d",&a,&b,&c);
    for(int i=a;i<=b;i++){
        if(c%i==0) j++;
    }
    printf("%d\n",j);
    return 0;
}


Measured memory_bytes: 2756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll H, W;
    cin >> H >> W;
    VS s(H);
    rep(i, 0, H) cin >> s[i];
    rep(h, 0, H){
        rep(w, 0, W){
            if(s[h][w] == '.') continue;
            bool tf = false;
            rep(i, 0, 4){
                ll nh = h + d1[i];
                ll nw = w + d2[i];
                if(nh < 0 || nw < 0 || nh >= H || nw >= W) continue;
                if(s[nh][nw] == '#') tf = true;
            }
            if(!tf){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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


int h[1<<17], dp[1<<17];

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n, k;
  cin >> n >> k;
  cin >> h[0];
  for (int i = 1; i < n; ++i) {
    cin >> h[i];
    dp[i] = INT_MAX;
    for (int j = max(0, i - k); j < i; ++j) {
      dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]));
    }
  }
  cout << dp[n - 1] << '\n';
}


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

using namespace std;
#define ll long long

//bool pos[1000010] , pos2[1000010];

ll fact[1000006] , mod=1e9 + 7;

void calcFac(ll n)
{
    fact[0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) % mod;
    }
}


int main()
{
    calcFac(1000000);
    ll n,m;
    cin >> n >> m;
    if (n<m) swap(n,m);

    if (m < n-1) return cout << "0\n" , 0;
    if (m==n-1)
    {
        ll ans = ((fact[n]%mod)*(fact[m]%mod) )%mod;
        return cout << ans << "\n" , 0;
    }
    else
    {
        ll tmp = (2*fact[n])%mod;
        ll ans = ((fact[n]%mod) * (tmp%mod))%mod;
        return cout << ans << "\n" , 0;
    }
    return 0;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int arr[n][3];
    for(int i=0;i<n;i++) cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    int dp[n][3];
    memset(dp,0,sizeof(dp));
    dp[0][0]=arr[0][0],dp[0][1]=arr[0][1],dp[0][2]=arr[0][2];
    for(int i=1;i<n;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(j!=k){
                    dp[i][k]=max(dp[i][k],dp[i-1][j]+arr[i][k]);
                }
            }
        }
    }
    int ans=0;
    ans=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const double PI = acos(-1);  

int main(){
  int n, m; cin >> n >> m;
  priority_queue<ll> que;
  for(int i=0; i<n; i++){
    ll x; cin >> x;
    que.push(x);
  }

  for(int i=0; i<m; i++){
    ll x = que.top();
    que.pop();
    que.push(x/2);
  }
  
  ll sum=0;
  while(!que.empty()){
    sum += que.top();
    que.pop();
  }
  cout << sum << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define ll long long int
#define f(i,a,n) for(i=a;i<n;i++)
#define fast() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define test() ll tc;cin>>tc;while(tc--)

using namespace std;

const int MAXV = 1e5 + 10;
const int MAXN = 1e3 + 10;
const ll INF = 1e13;


/*ll fact(ll n);

ll comb(ll n, ll r)
{
    return fact(n) / (fact(r) * fact(n - r));
}

ll fact(ll n)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
        res = ((res%mod * i%mod)%mod)%mod;
    return res;
}


ll power(ll x, ll y)
{
    ll temp;
    if( y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;
}

*/



int main()
{
        fast();
        string s,w;
        cin>>s>>w;
        ll s1=s.size();
        ll s2=w.size();
        ll dp[s1+1][s2+1];

        for(ll i=0;i<=s1;i++)
        {
            for(ll j=0;j<=s2;j++)
            {
                    if(i==0||j==0)
                    {
                        dp[i][j]=0;
                    }
                    else if(s[i-1]==w[j-1])
                    {
                        dp[i][j]=dp[i-1][j-1]+1;
                    }
                    else{
                        dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
                    }
            }
        }

        ll index=dp[s1][s2];

        char lcs[index+1];
        lcs[index]='\0';
        ll i=s1,j=s2;
        while(i>0 && j>0)
        {
            if(s[i-1]==w[j-1])
            {
                lcs[index-1]=s[i-1];
                i--;j--;index--;
            }

            else if(dp[i-1][j]>dp[i][j-1])
            {
                i--;
            }
            else{
                j--;
            }
        }
        cout<<lcs;

        return 0;
}


Measured memory_bytes: 70656
import java.util.Scanner;

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

    int H = scanner.nextInt();
    int W = scanner.nextInt();
    int[][] A = new int[H + 1][W + 1];
    int[][] B = new int[H + 1][W + 1];
    for (int i = 1; i <= H; i++) for (int j = 1; j <= W; j++) A[i][j] = scanner.nextInt();
    for (int i = 1; i <= H; i++) for (int j = 1; j <= W; j++) B[i][j] = scanner.nextInt();

    int M = 6400;
    boolean[][][] dp = new boolean[H + 1][W + 1][M + 1];
    dp[1][0][0] = true;
    dp[0][1][0] = true;
    for (int i = 1; i <= H; i++) {
      for (int j = 1; j <= W; j++) {
        int d = Math.abs(A[i][j] - B[i][j]);
        for (int k = 0; k <= M; k++) {
          int e = Math.abs(k - d);
          dp[i][j][e] |= dp[i - 1][j][k];
          dp[i][j][e] |= dp[i][j - 1][k];
          if (k + d <= M) {
            dp[i][j][k + d] |= dp[i - 1][j][k];
            dp[i][j][k + d] |= dp[i][j - 1][k];
          }
        }
      }
    }
    for (int i = 0; i <= M; i++) {
      if (dp[H][W][i]) {
        System.out.println(i);
        return;
      }
    }
  }
}


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

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

  vector<int> b(n), w(n);
  if (s[0] == '#')
    b[0] = 1;
  else
    w[0] = 1;
  for (int i = 1; i < s.size(); ++i) {
    if (s[i] == '#')
      b[i] = b[i - 1] + 1, w[i] = w[i - 1];
    else
      b[i] = b[i - 1], w[i] = w[i - 1] + 1;
  }

  int sum_w = w.back();
  int ans = sum_w;
  for (int i = 0; i < s.size(); ++i) {
    ans = min(ans, b[i] + sum_w - w[i]);
  }
  cout << ans << endl;
}

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

const int inf = (1 << 28);

struct Network {
    struct Arc {
        int to, cap, cost, rev;

        Arc() {}
        Arc(int to, int cap, int cost, int rev) :
            to(to), cap(cap), cost(cost), rev(rev) {}
    };

    int n;
    vector<vector<Arc>> graph;

    Network(int n = 0) : n(n), graph(n) {}

    void addArc(int from, int to, int cap) {
        graph[from].emplace_back(to, cap, 0, graph[to].size());
        graph[to].emplace_back(from, 0, 0, graph[from].size() - 1);
    }

    int findBlockingFlow(vector<pair<int, int>>& hist, int s, int t) {
        vector<int> dist(n, inf), limit(n, inf);
        fill(hist.begin(), hist.end(), make_pair(-1, -1));

        queue<int> que;
        dist[s] = 0;
        que.push(s);

        bool flag = false;

        while (!que.empty() and !flag) {
            int u = que.front(); que.pop();

            for (int i = 0; i < graph[u].size(); i++) {
                const Arc& arc = graph[u][i];

                if (dist[arc.to] > dist[u] + 1 and arc.cap > 0) {
                    dist[arc.to] = dist[u] + 1;
                    hist[arc.to] = {u, i};
                    limit[arc.to] = min(limit[u], arc.cap);
                    que.push(arc.to);

                    if (arc.to == t) {
                        flag = true;
                        break;
                    }
                }
            }
        }
        return flag ? limit[t] : 0;
    }

    int findMaximumFlow(int s, int t) {
        vector<pair<int, int>> hist(n, {-1, -1});
        int sumFlow = 0, flow;

        while (flow = findBlockingFlow(hist, s, t), flow > 0) {
            int u = t;
            while (hist[u].first >= 0) {
                Arc& arc = graph[hist[u].first][hist[u].second];

                arc.cap -= flow;
                graph[arc.to][arc.rev].cap += flow;
                u = hist[u].first;
            }
            sumFlow += flow;
        }
        return sumFlow;
    }

    int findMinimumCut(int s, int t) {
        return findMaximumFlow(s, t);
    }
};

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

    int n, m;
    cin >> n >> m;

    Network network(n);
    for (int i = 0; i < m; i++) {
        int u, v, c;
        cin >> u >> v >> c;
        network.addArc(u, v, c);
    }
    cout << network.findMaximumFlow(0, n - 1) << endl;

    return 0;
}


Measured memory_bytes: 3240
import sys

n, k = tuple(map(int, input().split()))

lower_p = 0
w_list = []
for _ in range(n):
    w = int(sys.stdin.readline())
    lower_p = w if w > lower_p else lower_p
    w_list.append(w)
    
def get_possible_n(p):
    """最大積載重量を p としたときに、所与のトラック台数 k で処理可能な荷物の数

    所与の荷物数 n のうち、いくつ処理可能かを返す。荷物の重量と順序に依存し、
    （弱い）単調増加関数である。これが返す最大値は n である。
    """
    pos_n = 0
    for _ in range(k):
        acc_w = 0
        while pos_n < n:
            if acc_w + w_list[pos_n] <= p:
                acc_w += w_list[pos_n]
                pos_n += 1
            else:
                break
        else:
            break
    return pos_n

# upper_p は、get_possible_n(upper_p) が確実に n を返すことが保証される値。
upper_p = lower_p * n // k + lower_p

def b_search(lower_p, upper_p):
    while lower_p < upper_p:
        mid_p = (lower_p + upper_p) // 2
        if get_possible_n(mid_p) < n:
            lower_p = mid_p + 1
        else:
            upper_p = mid_p
    return lower_p

print(b_search(lower_p, upper_p))



Measured memory_bytes: 9560
N = int(input())
A = [int(i) for i in input().split()]
count_minus = 0
min_abs = 10 ** 9 + 1
sum_abs = 0
for i in range(N):
  if A[i] < 0:
    count_minus += 1
  min_abs = min(min_abs, abs(A[i]))
  sum_abs += abs(A[i])
if count_minus % 2 == 0:
  print(sum_abs)
else:
  print(sum_abs - min_abs * 2)

Measured memory_bytes: 14224
if __name__ == '__main__':

    n = int(input())
    a = [int(i) for i in input().split() if int(i) % 2 == 0]

    result = "APPROVED"
    for i in a:
        if i % 3 == 0 or i % 5 == 0:
            continue
        else:
            result = "DENIED"
            break
    print(result)


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int x,a,b;
  cin>>x>>a>>b;
  x-=a;
  while(x>=b)x-=b;
  cout<<x<<endl;
  return 0;
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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; }



i64 n, a,b;
void solve(){
	cin >> n >> a >> b;
	
	if(a > b){
		cout << 0 << endl;
		return;
	}
	if(n == 1){
		if(a < b) cout << 0 << endl;
		else cout << 1 << endl;
		return;
	}
	cout << (b-a)*(n-2) + 1 << endl;
}

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


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

int main() {

  string s;

  while(cin >> s) {
    
    int joi = 0;
  for(int i=0;i<s.size()-2;i++) 
    if(s[i] == 'J' && s[i+1] == 'O' && s[i+2] == 'I') joi++;
  
  int ioi = 0;
  for(int i=0;i<s.size()-2;i++)
    if(s[i] == 'I' && s[i+1] == 'O' && s[i+2] == 'I') ioi++;

  cout << joi <<endl;
  cout << ioi << endl;
  }

  return 0;

}

Measured memory_bytes: 1196
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	Scanner sc = new Scanner(System.in);

	int INF = 1 << 28;
	double EPS = 1e-9;

	LinkedList<R>[] lists;
	int n,m,r,q;
	
	@SuppressWarnings("unchecked")
	void run() {
		for(;;){
			n=sc.nextInt(); //pc
			m=sc.nextInt(); // student
			if((n|m)==0){
				break;
			}
			r=sc.nextInt();
			R[] rs=new R[n];
			lists=new LinkedList[m]; // st
			for(int i=0;i<m;i++){
				lists[i]=new LinkedList<R>();
			}
			for(int i=0;i<r;i++){
				int t=sc.nextInt();
				int p=sc.nextInt()-1;
				int s=sc.nextInt()-1;
				int log=sc.nextInt();
				if(log==1){
					rs[p]=new R(p,t);
					lists[s].add(rs[p]);
				}else{
					rs[p].end=t;
				}
			}
			/*
			for(int i=0;i<m;i++){
				debug(i);
				for(R r:lists[i]){
					debug(r.pc,r.start,r.end);
				}
			}
			*/
			
			q=sc.nextInt();
			for(int i=0;i<q;i++){
				int start=sc.nextInt();
				int end=sc.nextInt();
				int student=sc.nextInt()-1;
				solve(start,end,student);
			}
		}
	}

	void solve(int start,int end,int student) {
		int s=0,p=-INF;
		for(R r:lists[student]){
			int left=max(r.start,start);
			int right=min(r.end,end);
			s+=max(0,right-max(p,left));
			p=max(p,right);
		}
		//debug(s);
		println(""+s);
	}
	
	class R{
		int pc;
		int start, end;
		R(int pc,int start){
			this.pc=pc;
			this.start=start;
		}
	}
	
	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s) {
		System.out.print(s);
	}

	void println(String s) {
		System.out.println(s);
	}

	public static void main(String[] args) {
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 16000
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    string s; cin >> s;
    ll size = s.size();

    vector<ll> MOD(2019,0);
    ll num=0,cur=1;
    MOD[num]++; //何もないときは余りが0
    for(ll i=0;i<size;i++){
        num = (num + (s[size-i-1]-'0') *cur) %2019;
        MOD[num]++;
        cur = (cur * 10) %2019;
    }

    ll ans = 0;
    for(int i=0;i<2019;i++){
        ans += MOD[i]*(MOD[i]-1)/2;
    }

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


Measured memory_bytes: 3736
#include <iostream>
#include <map>

using namespace std;

const int MAXN=200111;

int N, K;
int A[MAXN];

struct Node{
	int p, v;
	Node(){}
	Node(int _p, int _v){p=_p;v=_v;}
};

Node St[MAXN];
int Top;

bool Push(int p){
	if(!p)	return false;
	while(Top>0 && St[Top].p>p)	--Top;
	if(St[Top].p==p)	++St[Top].v;
	else	St[++Top]=Node(p, 1);
	if(St[Top].v==K){
		p=St[Top].p;
		--Top;
		return Push(p-1);
	}
	return true;
}

bool Test(int k){
	
	K=k;
	Top=0;
	
	bool ret=true;
	
	for(int i=2;i<=N && ret;++i){
		if(A[i]<=A[i-1]){
			ret&=Push(A[i]);
		}
	}
	
	return ret;
}

int main(){
	ios_base::sync_with_stdio(false);
	
	cin >> N;
	
	for(int i=1;i<=N;++i)	cin >> A[i];
	
	int Left=1, Right=N, Mid;
	while(Left<Right){
		Mid=(Left+Right)>>1;
		if(Test(Mid))	Right=Mid;
		else	Left=Mid+1;
	}
	Mid=(Left+Right)>>1;
	
	cout << Mid << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define maxn 200010
#define ll long long
struct arr
{
	ll x;
	int y,t;
}b[maxn]={0};
int a[maxn],cnt[maxn]={0},n,i;
ll ans=0,s=0;
int cmp1(const void *a,const void *b)
{
	if ((*(arr *)a).x>(*(arr *)b).x) return 1;
		else return -1;
}
int cmp2(const void *a,const void *b)
{
	return (*(arr *)a).t-(*(arr *)b).t;
}
int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		b[i].x=b[i-1].x+(ll)a[i];
		b[i].t=i;
	}
	qsort(b+1,n,sizeof(b[0]),cmp1);
	b[1].y=1;
	for (i=2;i<=n;i++)
		if (b[i].x==b[i-1].x) b[i].y=b[i-1].y;
			else b[i].y=b[i-1].y+1;
	qsort(b+1,n,sizeof(b[0]),cmp2);
	for (i=1;i<=n;i++)
	{
		ans+=(ll)cnt[b[i].y];
		if (b[i].x==0LL) ans++;
		cnt[b[i].y]++;
	}
	printf("%lld",ans);
	return 0;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, a, b, t);
  out(t / a * b);
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define rep(i,l,r)for(int i=(l);i<(r);i++)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    int s,w;
    cin >> s >> w;
    if(s <= w)cout << "unsafe\n";
    else cout << "safe\n";
    return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 200'009;

char s[N];
int f[N];

int main() {
  int n, m, d;
  scanf("%d%d%d%s", &n, &m, &d, s);
  f[n] = 0;
  for (int i = n - 1; i >= 0; --i) {
    f[i] = f[i + 1];
    if (s[i] == 'o') {
      f[i] = max(f[i], f[min(n, i + d + 1)] + 1);
    }
  }
  int cnt = 0;
  int ne = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'x') {
      continue;
    }
    if (cnt + f[max(i + 1, ne)] < m) {
      printf("%d\n", i + 1);
    }
    if (i >= ne) {
      ++cnt;
      ne = min(n, i + d + 1);
    }
  }
}


Measured memory_bytes: 2432
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                                         

using namespace std;
#define ll long long

int main(){
  string S;
  cin >> S;
  int ret = 700;
  for(int i=0; i<3; i++){
    if(S[i] == 'o'){
      ret += 100;
    }
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256