akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
int n;
vector<int> v;

void showVector( vector<int> vec ){
  for( int i = 0; i < vec.size(); i++ ) printf("%d: %d, ", i, vec.at(i));
  cout << endl;
}

bool follow( vector<int> v1 ){
  vector<int> v2;
  for(int i=0; i <  v1.size(); i++ ) v2.push_back( v1.at(i) );
  sort( v2.begin(), v2.end() );
  return v1 == v2;
}

bool dfs( int i, vector<int> l, vector<int> r ){
  if( i == 10 ){ 
    return follow(l) && follow(r);
  }

  vector<int> l2 = l;
  l2.push_back( v.at(i) );
  if( dfs( i + 1, l2, r ) ) return true;

  vector<int> r2 = r;
  r2.push_back( v.at(i) );
  if( dfs( i + 1, l, r2 ) ) return true;
  
  return false;
}

main(){
  vector<int> l, r;
  int tmp;
  cin >> n;
  for( int i=0; i < n; i++ ){
    v.clear();
    for( int j = 0; j < 10; j++ ){
      cin >> tmp;
      v.push_back( tmp );
    }
    if( dfs(0, l, r) ) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
}

Measured memory_bytes: 1216
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();

        Set<String> list = new HashSet<>();
        for (int i = 0; i < N; i++) {
            list.add(scanner.next());
        }
        System.out.println(list.stream().count());
    }
}

Measured memory_bytes: 73528
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main() {
	int N;
	cin >> N;
	int ans = N * N;
	cout << ans << endl;


	return 0;
}

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

int main(){
  int N, T;
  cin >> N >> T;
  vector<int> t(N);
  for(int i=0; i<N; i++){
    cin >> t.at(i);
  }
  int ans=T;
  for(int i=0; i<N-1; i++){
    if(t.at(i+1)-t.at(i)>T) ans+=T;
    else ans+=t.at(i+1)-t.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

typedef long long ll;

int main()
{
    string s;
    cin >> s;
    int n = (int)s.size();
    ll ans = 0;
    int cnt = (s[0] == 'A');
    for (int i = 1; i < n; ++i)
    {
        if (s[i] == 'A')
        {
            if (s[i - 1] == 'B')
                cnt = 1;
            else
                ++cnt;
        }
        else
        {
            if (s[i] == 'B' && s[i - 1] == 'B')
                cnt = 0;
            if (s[i] == 'C')
            {
                if (s[i - 1] == 'B')
                    ans += cnt;
                else
                    cnt = 0;
            }
        }
    }

    cout << ans;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
int main (void)
{
  int i,j,n,ans=0,cnt=0;
  int a,b[20],m,c;
  cin>>n>>m>>c;
  for(i=0;i<m;i++)cin>>b[i];
  for(i=0;i<n;i++)
  {
    for(j=0;j<m;j++)
    {
      cin>>a;
      ans+=(a*b[j]);
    }  
    ans+=c;
    if(ans>0)cnt++;
    ans=0;
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3604
def ascend(a, b):
    template = '{} {}'
    if a < b:
        return template.format(a, b)
        
    return template.format(b, a)

EOL = '0 0'

for line in iter(input, EOL):
  x, y = map(int, line.split())
  
  print(ascend(x, y))


Measured memory_bytes: 5616
#include <stdio.h>
int main(void){
    // Your code here!
    long long int N,x,i,j,y,c=0;
    scanf("%lld %lld",&N,&x);
    int s[N];
    for(i=0;i<N;i++){
    scanf("%d",&s[i]);
    }
    for(i=0;i<N;i++){
        for(j=i+1;j<N;j++){
            if(s[i]>s[j]){
                y=s[i];
                s[i]=s[j];
                s[j]=y;
            }
        }
    }
    for(i=0;i<N;i++){
        x=x-s[i];
        if(x>=0){
           c++; 
        }
    }
    if(x>0){
        c--;
    }
    printf("%lld",c);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pp push

using namespace std;
int main()
{
	ll a;
	cin>>a;
	ll h=a%10;
	if(h==3){
		cout<<"bon";
	}
	else if( h==0 || h==1 ||  h==6 || h==8){
		cout<<"pon";
	}
	else if(h==2 || h==4 || h==5 ||h==7 || h==9){
		cout<<"hon";
	}
}

Measured memory_bytes: 3632
N, K = map(int, input().split())

result = [0] * N

for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        result[a-1] = 1
cnt = 0
for val in result:
    if val == 0:
        cnt += 1

print(cnt)


Measured memory_bytes: 9184
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 2000000000;
using namespace std;


const int MAX_V = 100000;

class Node{
    public:
        bool isUsed;
        int prenum; //DFS????¨?????????????
        int parent; //DFS Tree???????????????
        int lowest; //min(?????????prenum, ?????????????????´????????????prenum, ??????????????????lowest)
        Node(){ this->isUsed = 0; }
};

int cnt = 1;
vector<Node> node(MAX_V);
vector<int> edge[MAX_V];
vector<pair<int, int>> bridge;

void dfs(int current, int prev){
    node[current].prenum = node[current].lowest = cnt;
    cnt++;

    node[current].isUsed = true;

    int next;
    rep(i,edge[current].size()){
        next = edge[current][i];
        if(not node[next].isUsed){
            node[next].parent = current;
            dfs(next, current);
            node[current].lowest = min(node[current].lowest, node[next].lowest);
            if(node[current].prenum < node[next].lowest){
                bridge.emplace_back(make_pair(min(current, next), max(current, next)));
            }
        }else if(next != prev){
            node[current].lowest = min(node[current].lowest, node[next].prenum);
        }
    }
}

void art_points(int v){
    dfs(0, -1); // 0 == root

    set<int> ap;
    int np = 0;
    range(i,1,v){
        int p = node[i].parent;
        if(p == 0) np++;
        else if(node[p].prenum <= node[i].lowest) ap.insert(p);
    }
    if(np > 1) ap.insert(0);
    //for(auto it:ap){ cout << it << endl; } //??¢???????????¨??????
    sort(all(bridge));
    for(auto it:bridge){ cout << it.first << ' ' << it.second << endl; } //????????¨??????

}

int main(){
    int v, e;
    cin >> v >> e;
    rep(i,e){
        int a, b;
        cin >> a >> b;
        edge[a].emplace_back(b);
        edge[b].emplace_back(a);
    }
    art_points(v);
}

Measured memory_bytes: 8340
#include<cstdio>
#include<algorithm>
#define MAXN 406
#define MOD 1000000007
using namespace std;
long long d[MAXN][MAXN];
int n,c,a[MAXN],b[MAXN];
long long ksm(long long a,int m)
{
	if(m==0) return 1;
	long long nex=ksm(a,m/2);
	nex=nex*nex%MOD;
	if(m%2==0) return nex;
	return nex*a%MOD;
}
int main()
{
	scanf("%d%d",&n,&c);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		scanf("%d",&b[i]);
	d[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=c;j++)
		{
			long long sum=0;
			for(int k=a[i];k<=b[i];k++)
				sum=(sum+ksm(1ll*k,j))%MOD;
			for(int l=j;l<=c;l++)
				d[i][l]=(d[i][l]+d[i-1][l-j]*sum)%MOD;
		}
	}
	printf("%lld",d[n][c]);
}

Measured memory_bytes: 1536
use std::fmt::{Debug, Display};
use std::io::{self, Read};
use std::str::{self, FromStr};


fn solve(s: String) -> String {
    let l = s.chars().next().unwrap();
    let n = s.len() - 2;
    let r = s.chars().last().unwrap();
    format!("{}{}{}", l, n, r)
}


fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock().bytes());
    println!("{}", solve(sc.next()));
}


struct Scanner<R: Read> {
    buf: Vec<u8>,
    bytes: io::Bytes<R>,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(bytes: io::Bytes<R>) -> Self {
        Scanner {
            buf: Vec::with_capacity(256),
            bytes: bytes,
        }
    }

    fn next<T: FromStr>(&mut self) -> T
    where
        <T as FromStr>::Err: Debug,
    {
        self.buf.clear();
        for c in self.bytes
            .by_ref()
            .map(|c| c.unwrap())
            .skip_while(|&c| c == ' ' as u8 || c == '\n' as u8)
            .take_while(|&c| !(c == ' ' as u8 || c == '\n' as u8))
        {
            self.buf.push(c);
        }
        str::from_utf8(&self.buf).unwrap().parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<A: FromStr, B: FromStr>(&mut self, n: usize) -> Vec<(A, B)>
    where
        <A as FromStr>::Err: Debug,
        <B as FromStr>::Err: Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<A: FromStr, B: FromStr, C: FromStr>(&mut self, n: usize) -> Vec<(A, B, C)>
    where
        <A as FromStr>::Err: Debug,
        <B as FromStr>::Err: Debug,
        <C as FromStr>::Err: Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        <T as FromStr>::Err: Debug,
    {
        (0..n).map(|_| self.vec(m)).collect()
    }
}


#[allow(dead_code)]
fn print_foreach<T: Display>(answer: &[T]) {
    for x in answer {
        println!("{}", x);
    }
}


#[allow(dead_code)]
fn print_yn(answer: bool, yes: &str, no: &str) {
    println!("{}", if answer { yes } else { no });
}


#[allow(dead_code)]
fn print_or<T: Display>(answer: &Option<T>, or: &T) {
    match *answer {
        Some(ref x) => println!("{}", x),
        None => println!("{}", or),
    }
}


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


int main() {
  int n;
  cin >> n;
  int ans = 0;
  rep(i,n) ans += i+1;
  cout << ans << endl; 
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
    #include <vector>
    #include <algorithm>
    #include <string>
    #include <cmath>
    #include <iomanip>
    #include <queue>
     
    long long int N;
    std::vector<long long int> A;
     
    int main() {
      std::cin >> N;
      A.push_back(1);
      for (int i = 1; i <= N; i++) {
        long long int temp;
        std::cin >> temp;
        if (temp == 0) {
          std::cout << temp << std::endl;
          return 0;
        }
        A.push_back(temp);
      }
     
      long long int ans = 1;
      for (int i = 1; i <= N; i++) {
        if (ans <= (1000000000000000000 / A[i])) {
          ans *= A[i];
        }
        else {
          std::cout << -1 << std::endl;
          return 0;
        }
      }
     
      std::cout << ans << std::endl;
     
      return 0;
    }

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

#define ll long long int 

void solve()
{
    
    string s;
    cin>>s;
    int l=s.length();
    if(s[l-1]=='s')
    {
       // s.erase(l-1, 1);
        s+="es";
    }
    else
    {
        s+='s';
    }
    cout<<s<<endl;

    
}

int main()
{
    
    solve();
    
    
    
    return 0;
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
int main() {
	int n, i, j;
	cin >> n;
	vi a(n);
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int k = 1, w = 0;
	int pre = a[0];
	for (i = 1; i < n; i++) {
		if (pre == a[i]) {
			w++;
		}
		else {
			k++;
			pre = a[i];
		}
	}
	//cout << k <<" "<< w << endl;
	k -= (w % 2);
	cout << k << endl;
	return 0;
}

Measured memory_bytes: 640
//#define LOCAL
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string>
#include<math.h>
#include<map>
#include<random>
#include<stack>
using namespace std;
using lld = long long int;
using llu = unsigned long long int;
using pii = pair<int, int>;
using pli = pair<lld, int>;
using pil = pair<int, lld>;
using pll = pair<lld, lld>;
using piii = pair<pii, pii>;
using pdii = pair<int, pii>;
int n, m;
int mark[109];
int a[100009];
vector<int> v[100009];
int main() {
	int i, j, k, l;
	int t = 1, tv = 0;
	while (t--) {
		scanf("%d %d", &n, &m);
		for (i = 0; i < n; i++) {
			scanf("%d", &a[i]);
		}
		while (m--) {
			scanf("%d %d", &i, &j);
			i--; j--;
			v[i].push_back(j);
			v[j].push_back(i);
		}
		int res = 0;
		for (i = 0; i < n; i++) {
			bool valid = true;
			for (j = 0; j < v[i].size(); j++) {
				if (a[v[i][j]] >= a[i])valid = false;
			}
			if (valid)res++;
		}
		printf("%d\n", res);
	}
}

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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  
  for(int i = 0; i < n; i++){
  	cin >> p.at(i);
  }
  
  int a = 0, b = 0;
  
  int count = n-1;
  sort(p.begin(), p.end());
  
  while(p.size() > 0){
  	a += p.at(count);
  	count--;
    p.pop_back();
  	
  if(count != -1){
  	b += p.at(count);
  	count--;
    p.pop_back();
  }
  }
  cout << a-b << endl;
}

Measured memory_bytes: 256
import bisect

if __name__ == '__main__':
    def check(mid):
        count = 0
        for i in range(n):
            position = bisect.bisect_left(a, (mid - a[i]))
            count += (n - position)
        return count < m


    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    # 左手でa[i]の手を握るとする
    # a[i]を持っているときに和がx未満になるときの右手の数字はx - a[i]未満の数字である
    # lower_bound
    # この値をNから引くことで和がx以上になるペアの個数がわかる
    # この値の合計がM未満になればそこが最大の幸福度である

    # 要するに、M個のペアを作るためには最大いくらの和を採用できるかを二分探索する

    ng = 0
    ok = 10 ** 5 * (n + 1)

    while 1 < abs(ok - ng):
        # mid -> boundとなる和。これより大きい和をもつペアをM個作れるかを判定する
        mid = (ok + ng) // 2
        c = check(mid)
        # ペアの個数がmより小さい場合は、okの範囲を下げる
        if c:
            ok = mid
        # そうでない場合はまだ余裕があるので、ngをあげる
        else:
            ng = mid

    # ここが終了した時点でngにはm個以上のペアを作るための最大のboundが入っている

    # upper_boundで左手にa[i]がある場合のng - a[i]の数を判定する
    # ansに求めた数 * a[i] + 右手に持つ幸福度の総和を足す
    # mから求めた数を引く

    ans = 0
    sum_array = [0] * (n + 1)
    # 累積和で高速化をする
    # (x + a[i]) + (x + a[i + 1) + (x + a[i + 2]).....
    #   -> (x * 個数) * (a[i] + a[i + 1] + a[i + 2])

    for i in range(n):
        sum_array[i + 1] = sum_array[i] + a[i]
    for i in range(n):
        position = bisect.bisect_right(a, ng - a[i])
        ans += (n - position) * a[i] + sum_array[n] - sum_array[position]
        m -= (n - position)

    ans += ng * m
    print(ans)


Measured memory_bytes: 56584
a = [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]
K = int(input())
print(a[K-1])


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

using namespace std;

const int N = (1<<19) , mod = 1e9 +7 , mx = 1e6 +5;

long long lc = 1LL;

int fac[mx];

long long poww(long long a ,long long  b )
{
    if(!b)
        return 1LL;
    long long ret = poww(a, b/2 );
    ret = (ret*ret)%mod;
    if(b%2)
        ret = (ret*a)%mod;
    return ret ;
}

int main()
{
    int n ;
    cin>>n;
    long long a[n+1];
    long long ans  = 0 ;
    for(int i= 0;i<n;i++)
    {
        cin>> a[i];
        int cpy = a[i];
        map<int , int> mp;
        for(int j = 2;j*j<=cpy;j++)
        {
            while(cpy%j==0)
            {
                mp[j]++;
                cpy/=j;
            }
        }
        if(cpy>1)
            mp[cpy]++;
        for(auto u : mp)
            fac[u.first] = max(fac[u.first] , u.second);
    }
    for(int i = 1;i<=1000000;i++)
    {
        lc*=poww(i, fac[i]);
        lc%=mod;
    }
    lc%=mod;
    for(int i = 0;i<n ; i++)
    {
        ans=  (ans +  (lc * poww(a[i] , mod - 2 ) )%mod)%mod;
        ans%=mod;
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 2944
#include<iostream>
#include<math.h>
using namespace std;
int func(int N) {
  if(N<10)return N;
  int top=N,bottom = N%10,p=0;
  while(top>9) {
    top /= 10;
    p++;
  }
  if(bottom == 0)return func(N-1);
  int cnt=0,i;
  if(top==bottom) {
    cnt+=3;
    cnt += 2*(N/10-pow(10.0,p-1)*top);
    for(i=0;i<p-1;i++)cnt += 2*pow(10.0,i);
  }
  else {
    if(top < bottom)p--;
    for(i=0;i<p;i++)cnt += 2*pow(10.0,i);
  }
  return cnt + func(N-1);
}
int main() {
  int N;
  cin >> N;
  cout << func(N) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

int n;
int iabs(int x) {
    return x >= 0 ? x : -x;
}
int f(int a, int b) {
    return a == (b | (a - b));
}


int main() {
    cin >> n;
    string s;
    cin >> s;
    vector<int> a(n), b(n - 1);
    for (int i = 0; i < n; ++i) {
        a[i] = (s[i] - '0') & 1;
    }
    cerr << endl;
    int cnt[3] = {};
    for (int i = 0; i < n - 1; ++i) {
        b[i] = iabs((s[i] - '0') - (s[i + 1] - '0'));
        cnt[b[i]]++;
    }
    int ans = 0;
    if (cnt[1] == 0) {
        cerr << 'a' << endl;
        for (int i = 0; i < n - 1; ++i) {
            cerr << b[i];
            ans ^= f(n - 2, i) * b[i];
        }
        cerr << endl;
    } else {
        for (int i = 0; i < n; ++i) {
            ans ^= f(n - 1, i) * a[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9220
#include <bitset>
#include <iostream>
#include <vector>

using Bitset = std::bitset<64>;

int main(void) {
    std::bitset<64> bitset{};

    int n;
    std::cin >> n;

    std::vector<Bitset> bitsets{};
    bitsets.resize(n);
    for (int i = 0; i < n; ++i) {
        int k;
        std::cin >> k;
        for (int j = 0; j < k; ++j) {
            int b;
            std::cin >> b;
            bitsets[i].set(b);
        }
    }

    int q;
    std::cin >> q;

    for (int i = 0; i < q; ++i) {
        int kind, m;
        std::cin >> kind >> m;

        switch (kind) {
            case 0:
                std::cout << bitset.test(m) << std::endl;
                break;
            case 1:
                bitset |= bitsets.at(m);
                break;
            case 2:
                bitset &= ~bitsets.at(m);
                break;
            case 3:
                bitset ^= bitsets.at(m);
                break;
            case 4:
                std::cout << (bitset | ~bitsets.at(m)).all() << std::endl;
                break;
            case 5:
                std::cout << (bitset & bitsets.at(m)).any() << std::endl;
                break;
            case 6:
                std::cout << (bitset & bitsets.at(m)).none() << std::endl;
                break;
            case 7:
                std::cout << (bitset & bitsets.at(m)).count() << std::endl;
                break;
            case 8:
                std::cout << (bitset & bitsets.at(m)).to_ullong() << std::endl;
        }
    }
}


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;

int main() {
    int a, b;
    cin >> a >> b;
    if (b == 1) {
        cout << 0 << endl;
        return 0;
    }
    int c = 1;
    int t = a;
    while (t < b) {
        t += a - 1;
        c++;
    }
    cout << c << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
{ for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{ os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{ cerr << " " << H; debug_out(T...); }
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 int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;
const double pi = acos(-1);

void solve() {
    double a, b, x;
    cin >> a >> b >> x;
    x /= a;
    cout << fixed << setprecision(10);
    if (x <= a * b / 2) {
        double d = 2 * x / b;
        cout << acos(d / hypot(b, d)) / pi * 180 << endl;
    } else {
        x = a * b - x;
        double d = 2 * x / a;
        cout << acos(a / hypot(a, d)) / pi * 180 << endl;
    }
}

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


Measured memory_bytes: 3928
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int a,b;

		Scanner sc = new Scanner(System.in);
		a = sc.nextInt();
		b = sc.nextInt();
		if(a>=6&&a<=12) {
			b = b/2;
		}else if(a<=5) {
			b = 0;
		}
		System.out.println(b);
	}
}

Measured memory_bytes: 20688
# -*- coding: utf-8 -*-
import sys
import io


def main():
    N = int( sys.stdin.readline() )

    XYU_list = []

    for _ in range(N):
        x,y,u = sys.stdin.readline().rstrip().split()
        XYU_list.append( [int(x),int(y),u] )

    
    check_UD = {}
    check_LR = {}

    check_UR = {}
    check_DL = {}
    check_UL = {}
    check_DR = {}


    for x,y,u in XYU_list:
        if (u == "U") or (u == "D"):
            check_UD.setdefault( x , [] )
            check_UD[x].append( (y,u) )
        
        if (u == "L") or (u == "R"):
            check_LR.setdefault( y , [] )
            check_LR[y].append( (x,u) )
        
        if (u == "U") or (u == "R"):
            check_UR.setdefault( (x+y) , [] )
            check_UR[ (x+y) ].append( (x,u) )

        if (u == "D") or (u == "L"):
            check_DL.setdefault( (x+y) , [] )
            check_DL[ (x+y) ].append( (x,u) )

        if (u == "U") or (u == "L"):
            check_UL.setdefault( (x-y) , [] )
            check_UL[ (x-y) ].append( (x,u) )

        if (u == "D") or (u == "R"):
            check_DR.setdefault( (x-y) , [] )
            check_DR[ (x-y) ].append( (x,u) )


    for check_dic in [check_UD, check_LR, check_UR, check_DL, check_UL, check_DR]:
        for key in check_dic:
            check_dic[key].sort()
    

    diff_min = float("inf")
    
    for arr in check_UD.values():
        for i in range(len(arr) - 1):
            if (arr[i][1] == "U") and (arr[i+1][1] == "D"):
                diff_min = min( diff_min, (arr[i+1][0] - arr[i][0]) / 2 )
    
    for arr in check_LR.values():
        for i in range(len(arr) - 1):
            if (arr[i][1] == "R") and (arr[i+1][1] == "L"):
                diff_min = min( diff_min, (arr[i+1][0] - arr[i][0]) / 2 )



    for arr in check_UR.values():
        for i in range(len(arr) - 1):
            if (arr[i][1] == "R") and (arr[i+1][1] == "U"):
                diff_min = min( diff_min, (arr[i+1][0] - arr[i][0]) )
    
    for arr in check_DL.values():
        for i in range(len(arr) - 1):
            if (arr[i][1] == "D") and (arr[i+1][1] == "L"):
                diff_min = min( diff_min, (arr[i+1][0] - arr[i][0]) )

    for arr in check_UL.values():
        for i in range(len(arr) - 1):
            if (arr[i][1] == "U") and (arr[i+1][1] == "L"):
                diff_min = min( diff_min, (arr[i+1][0] - arr[i][0]) )

    for arr in check_DR.values():
        for i in range(len(arr) - 1):
            if (arr[i][1] == "R") and (arr[i+1][1] == "D"):
                diff_min = min( diff_min, (arr[i+1][0] - arr[i][0]) )



    if diff_min != float("inf"):
        print( int(diff_min * 10) )
    else:
        print("SAFE")


if __name__ == "__main__":
    main()


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

typedef struct node {
	int val;
} node;

typedef struct {
	bool operator()(node &a, node &b) {
		return a.val < b.val;
	}
} comparison;


typedef long long int lli;

typedef pair<int, int> pii;

typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<lli> vlli;

typedef unordered_map<int, int> umapii;
typedef unordered_map<char, pii> umapcpii;
typedef unordered_map<char, int> umapci;
typedef unordered_map<char, lli> umapclli;
typedef unordered_map<lli, lli> umapllilli;
typedef unordered_map<string, int> umapsi;
typedef unordered_map<string, lli> umapslli;
typedef unordered_map<string, pii> umapspii;

typedef unordered_set<int> usti;
typedef unordered_set<char> ustc;
typedef unordered_set<string> usts;
typedef unordered_set<lli> ustlli;

typedef priority_queue<int> max_heapi;
typedef priority_queue<pii> max_heapii;
typedef priority_queue<lli> max_heaplli;
typedef priority_queue<string> max_heaps;
typedef priority_queue<vi> max_heapvi;

typedef priority_queue<int, vector<int>, greater<int> > min_heapi;
typedef priority_queue<pii, vector<pii>, greater<pii> > min_heapii;
typedef priority_queue<vi, vector<vi>, greater<vi> > min_heapvi;

typedef priority_queue<node, vector<node>, comparison> heap_node;
// change comparison struct for min_heap or max_heap for node


typedef vector<int> edgesi;
typedef vector<edgesi> graphi;

typedef vector<pii> edgespii;
typedef vector<edgespii> graphpii;


vector<vector<int> > delta4 = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
vector<vector<int> > delta8 = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}, {1, 1}, {-1, -1}, {1, -1}, {-1, 1}};


static inline string get_substr(string &a, int &st, int &en) {
	return a.substr(st, en-st+1);
}

void add_element_count_map(umapii &umap, int &a) {
	if (umap.count(a) == 0)
		umap[a] = 1;
	else
		umap[a]++;
}

// static inline convertString(pii &a) {
	// return to_string(a.first) + "_" + to_string(a.second);
// }


static inline bool check_double_equal(double &a, double &b) {
	return abs(a - b) <= 1e-6;
}

// static inline count_number_of_element_sorted_arr(vector<T> &a, T &b) {
	// return upper_bound(a.begin(), a.end(), b) - lower_bound(a.begin(), a.end(), b);
// }


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

	lli a, b, n, k, x;
	// cin>>a>>b>>n;
	cin>>k>>a>>b;
	bool ans = false;
	if (a/k == b/k)
		ans = (a % k == 0) || (b % k == 0);
	else
		ans = true;

	cout<<(ans ? "OK":"NG")<<"\n";
		return 0;
}	


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	int a = -inf, sa = 0, b = inf, sb = 0;
	rep(i, n) {
		int p;
		cin >> p;
		if (p > a) a = p, sa = i;
		if (p < b) b = p, sb = i;
	}
	cout << 2 * n - 1 << endl;
	if (abs(a) >= abs(b)) {
		rep(i, n) cout << sa + 1 << " " << i + 1 << endl;
		rep(i, n - 1) cout << i + 1 << " " << i + 2 << endl;
	} else {
		rep(i, n) cout << sb + 1 << " " << i + 1 << endl;
		rep(i, n - 1) cout << n - i << " " << n - 1 - i << endl;
	}
	return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;

    int count = 0;
    for(int i=a; i<=b; i++){// since there seems to be a problem with to_string()...
        if(i/10000 == i % 10 
        && i/1000 - i/10000*10 == (i % 100) / 10) count += 1;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
T1, T2 = map(int,input().split())
A1, A2 = map(int,input().split())
B1, B2 = map(int,input().split())

LA = T1*A1+T2*A2
LB = T1*B1+T2*B2
if LA == LB:
    print("infinity")
    exit()
elif LA < LB:
    LA, LB = LB, LA 
    A1, B1 = B1, A1
    A2, B2 = B2, A2

l = LA - LB
r = T1*B1-T1*A1 
if r < 0:
    print(0)
    exit()
else:
    # print("===")
    # print(l,r)
    if r%l==0:
        print( (r//l)*2)
    else:
        print( (r//l)*2 +1 )


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll r,g,b;
    cin >>r>>g>>b;
    if((g*10+b)%4==0){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }


    return 0;
    

}

Measured memory_bytes: 3628
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int w, h, n;
    cin >> w >> h >> n;
    vector<int> x(n), y(n);
    for(int i=0; i<n; ++i)
        cin >> x[i] >> y[i];

    int ret = 0;
    for(int i=1; i<n; ++i){
        int dx = x[i] - x[i-1];
        int dy = y[i] - y[i-1];
        if(dx * dy < 0)
            ret += abs(dx) + abs(dy);
        else
            ret += max(abs(dx), abs(dy));
    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 1200
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int M = sc.nextInt();
        int D = sc.nextInt();
        int ans = 0;
        for (int d = 1;d<=D;d++){
            int m = (d/10) * (d%10);
            if (0<m&&m<=M&&d/10>1&&d%10>1){
                ans++;
            }
        }
        System.out.printf("%d\n",ans);
    }
}

Measured memory_bytes: 22100
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

i32 min (i32 a, i32 b) {
  return a < b ? a : b;
}

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  i32 *dp = (i32 *) calloc (n + 1, sizeof (i32));
  for (i32 i = 1; i <= n; ++i) {
    dp[i] = i;
  }
  i32 p[2] = {6, 9};
  for (i32 k = 0; k < 2; ++k) {
    for (i32 i = p[k]; i <= n; i *= p[k]) {
      for (i32 j = i; j <= n; ++j) {
        dp[j] = min (dp[j], dp[j - i] + 1);
      }
    }
  }
  printf ("%" PRIi32 "\n", dp[n]);
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
string s;
int len;
string a,b;
int ans;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>s;
	len = s.size();
	int id = 1;
	a=s[0];
	while(id<len){
		int st = 1;
		b = s.substr(id,st);
		if(b==a)st++;
		if(st+id-1==s.size())ans--,st--;
		b = s.substr(id,st);

		 // cout<<a<<' '<<b<<endl;
		a=b;
		id+=st;
		ans++;
	}
	ans++;
	cout<<ans;
	return 0;	
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i < n; i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define repran(i, a,b) for (int i = a; i<b;i++)
#define all(x) (x).begin(), (x).end()
#define v(T) vector<T>
#define vv(T) vector<v(T)>
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

int main()
{
    int n;
    cin >> n;
    int k = n+1-n%2;
    vvi g(n+1);
    int m = 0;
    repran(i, 1, n){
        repran(j, i+1, n+1){
            if (i+j ==k ) continue;
            g[i].push_back(j);
            m++;
        }
    }
    cout << m << endl;
    rep(i, n) rep(j, g[i+1].size()) cout << i+1 << " " << g[i+1][j] << endl;
}

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

void swap(long *A, long i, long j) {
  long tmp;
  tmp = A[i];
  A[i] = A[j];
  A[j] = tmp;
}

void maxHeapify(long *A, long i,long H) {
  long l,r,largest;
  l = 2*i;
  r = 2*i+1;
  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,largest);
    maxHeapify(A,largest,H);
  }
}

void buildMaxHeap(long *A,long H) {
  long i;
  for(i = H/2; i > 0; i--) maxHeapify(A,i,H);
}

int main()
{
  int i,H;
  long *A;
  scanf("%d",&H);
  A = (long*)malloc(sizeof(long) * (H+1));
  for (i = 1; i <= H; i++) {
    scanf("%ld",A+i);
  }
  buildMaxHeap(A,H);
  for (i = 1; i <= H; i++) {
    printf(" %ld", A[i]);
  }
  printf("\n");


  return 0;
}

Measured memory_bytes: 4508
n,m=map(int,input().split())
ans=[]
ans_s=[]
for i in range(m):
    a,b=map(int,input().split())
    if a==1:
        ans.append(b)
    if b==n:
        ans_s.append(a)
set_ans=set(ans)
set_ansi=set(ans_s)
if list(set_ans&set_ansi):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 21836
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws Exception {
        InputStreamReader r = new InputStreamReader(System.in);
        int N = nextInt(r);
        long[] X = new long[N];
        long[] Y = new long[N];

        long max = 0;
        int type = 0; // 1:odd, 2:even
        for (int i = 0; i < N; i++) {
            long Xi = nextInt(r);
            long Yi = nextInt(r);
            X[i] = Xi;
            Y[i] = Yi;

            long abs = Math.abs(Xi) + Math.abs(Yi);
            max = abs > max ? abs : max;

            if (type == 0) {
                type = abs%2 == 1 ? 1 : 2;
            }
            if (type == 1 && abs%2 == 0 || type == 2 && abs%2 == 1) {
                type = 0;
                break;
            }
        }

        if (type == 0) {
            System.out.println(-1);
        } else {
            int[] exp = new int[1];
            setExp(exp, max);

            int m = exp[0] + type;
            System.out.println(m);

            long[] d = new long[m];
            for (int i = 0; i < m; i++) {
                if (i < exp[0]) {
                    long pow = pow(2, exp[0]-i);
                    d[i] = pow;
                } else {
                    d[i] = 1;
                }
            }

            String dm = "";
            for (int i = 0; i < exp[0]; i++) {
                dm += d[i]+" ";
            }
            dm += type == 1 ? "1" : "1 1";
            System.out.println(dm);

            for (int i = 0; i < N; i++) {
                long x = 0;
                long y = 0;
                String w = "";
                for (int j = 0; j < m; j++) {
                    long dx = X[i] - x;
                    long dy = Y[i] - y;
                    if (Math.abs(dx) > Math.abs(dy)) {
                        x += dx > 0 ? d[j] : -d[j];
                        w += dx > 0 ? "R" : "L";
                    } else {
                        y += dy > 0 ? d[j] : -d[j];
                        w += dy > 0 ? "U" : "D";
                    }
                }
                System.out.println(w);
            }
        }
    }

    public static int nextInt(InputStreamReader r) throws Exception {
        String str = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            str += (char)c;
        }
        return Integer.parseInt(str);
    }

    public static void setExp(int[] exp, long max) {
        max = max/2;
        exp[0]++;
        if (max != 1) {
            setExp(exp, max);
        }
    }

    public static long pow(int r, int i) {
        if (i == 0) {
            return 1;
        } else {
            return r * pow(r, i-1);
        }
    }
}


Measured memory_bytes: 34652
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<string>

using namespace std;

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long


int main(){
    int k,x; cin >> k >> x;
    cout << ((k*500 >= x)?"Yes":"No") << endl;
}


Measured memory_bytes: 888
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back

#define eb emplace_back
#define mod   1000000007
#define PI 2*acos(0.0)
#define all(r)(r).begin(),(r).end()
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define inf 1000000000000000000
#define N 200000
int dirx[] = {1, -1,0, 0}, diry[] = {0, 0, 1, -1};


//=============================================ASIFAZAD==============================================//

int32_t main()
{
    io;
    string s;
    cin>>s;
    int ans = 0;
    for(auto x: s)
        ans += (x -'0');
    cout<<(ans%9?"No":"Yes");
    return 0;
}

Measured memory_bytes: 3780
using System;

namespace AtCoderExamCS
{
    class Program
    {
        static void Main(string[] args)
        {
            int N;
            string[] prefixString = new string[4]
            {
                "AC x ", "WA x ", "TLE x ", "RE x "
            };

            N = int.Parse(Console.ReadLine());

            int[] S = new int[4];
            string tmp;
            for (int i = 0; i < N; i++)
            {
                tmp = Console.ReadLine();
                switch (tmp)
                {
                    case "AC":
                        S[0] += 1;
                        break;
                    case "WA":
                        S[1] += 1;
                        break;
                    case "TLE":
                        S[2] += 1;
                        break;
                    case "RE":
                        S[3] += 1;
                        break;
                }
            }

            for (int i = 0; i < S.Length; i++)
            {
                Console.Write(prefixString[i]);
                Console.WriteLine(S[i]);
            }
        }
    }
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
signed main(){
    gearup;
    ll x,a,b;
    cin >> x >> a >> b;
    x -= a;
    out(x%b);
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <string>
using namespace std;
int main(){
        stack<int> c;
        string s;
        while(cin >> s){
                if(s == "+" || s == "-" || s == "*"){
                        int x2 = c.top();
                        c.pop();
                        int x1 = c.top();
                        c.pop();
                        if(s == "+")c.push(x1+x2);
                        if(s == "-")c.push(x1-x2);
                        if(s == "*")c.push(x1*x2);
                } else {
                        c.push(stoi(s));
                }
        }
        while(!c.empty()){
                cout << c.top() << endl;
                c.pop();
        }

        return 0;
}

Measured memory_bytes: 1204
#include <string.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
// #include <unordered_map>
// #include <unordered_set>
#include <utility>
#include <vector>

#define pb push_back
#define mp make_pair
#define sqr(x) ((x) * (x))

#ifdef ONLINE_JUDGE
#define link renamelink
#define next renamenext
#define prev renameprev
#endif

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef long double ld;

inline void EnableFileIO(const string& fileName, bool local = 0) {
  if (fileName.empty()) return;
  if (local) {
    freopen((fileName + ".in").c_str(), "r", stdin);
    freopen((fileName + ".out").c_str(), "w", stdout);
    return;
  }
#ifdef ONLINE_JUDGE
  freopen((fileName + ".in").c_str(), "r", stdin);
  freopen((fileName + ".out").c_str(), "w", stdout);
#endif
}

const int INF = (1 << 30) - 1;
const LL LINF = (1LL << 61) - 1;
const double EPS = 1e-10, PI = acos(-1);
const int N = 2e5 + 100;

int n, q;
int b[N], pre[N], val[N * 2], f[N * 2];
pii s[N];
void mod(int p, int v) {
  for (val[p] = min(val[p], v); p; p >>= 1)
    val[p >> 1] = min(val[p], val[p ^ 1]);
}
int ask(int l, int r) {
  int res = INF;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l & 1) res = min(res, val[l++]);
    if (r & 1) res = min(res, val[--r]);
  }
  return res;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    pre[i] = (i ? pre[i - 1] : 0) + 1 - b[i];
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> s[i].first >> s[i].second;
    --s[i].first, --s[i].second;
  }
  sort(s, s + q);
  fill(val, val + N * 2, INF);
  fill(f, f + N * 2, INF);

  for (int i = 0, j = 0; i < n; i++) {
    f[i] = min(f[i], (i ? f[i - 1] : 0) + b[i]);
    for (; j < q; j++) {
      if (s[j].first != i) break;
      int k = s[j].second, v = min(pre[k] + (i ? f[i - 1] - pre[i - 1] : 0),
                                   ask(i, k + 1) + pre[k]);
      f[k] = min(f[k], v);
      mod(k + n, v - pre[k]);
    }
  }
  cout << f[n - 1] << endl;
  return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define rep(m,x,r) for((m)=(x);(m)<(r);(m)++)
int main(){
    int n,i,m=0;
    cin>>n;
    int a[n+1],ans[n+1];
    a[0]=-1;
    for(i=1;i<=n;i++) cin>>a[i];
    for(i=n;i>0;i--){
        if(n/i==1){//ハコが1つならそれに従う
            m+=a[i];
            ans[i]=a[i];
        }
        else if(i!=1){
            int buf=0;
            for(int j=2*i;j<=n;j+=i)buf+=ans[j];
            if(a[i]!=(buf%2)){
                ans[i]=1;
                m++;
            }
            else ans[i]=0;
        }
        else{
            if(a[i]==(m%2))ans[i]=0;//1のとき
            else{
                ans[i]=1;
                m++;
            }
        }
    }
        cout<<m<<endl;
        rep(i,1,n+1)if(ans[i])cout<<i<<" ";
    cout<<"\n";
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int H,W; cin >> H >> W;
    vector<string> a(H); rep(i,H) cin >> a[i];

    rep(i,H){
        bool del = [&](){
            for(int j=0;j<W;j++) if(a[i][j]=='#') return false;
            return true;
        }();
        if(del){
            for(int j=0;j<W;j++) a[i][j] = 'x';
        }
    }


    rep(j,W){
        bool del = [&](){
            for(int i=0;i<H;i++) if(a[i][j]=='#') return false;
            return true;
        }();
        if(del){
            for(int i=0;i<H;i++) a[i][j] = 'x';
        }
    }

    vector<string> ans;
    rep(i,H){
        string s;
        rep(j,W){
            if(a[i][j]!='x') s.push_back(a[i][j]);
        }
        if(s.size()){
            ans.push_back(s);
        }
    }

    for(auto s : ans){
        cout << s << endl;
    }
}


Measured memory_bytes: 256