akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
//#define int long long
//#define ll long long
#define int  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 300000;
int mod = 1e9 + 7;
int used[N];
pair < int, int > a[N], b[N];
vector < int > g[N];
void dfs(int v){
    used[v] = 1;
    for (auto u: g[v]){
        if (!used[u]) dfs(u);
    }
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++){
        int x;
        cin >> x;
        a[i] = {x, i};
    }
    for (int i = 1; i <= n; i++){
        int y;
        cin >> y;
        b[i] = {y, i};
    }
    int cnt = 0;
    for (int i = 1; i <= n; i++){
        if (a[i].F > b[i].F) cnt++;
    }
    if (cnt > n - 2){
        cout << "No";
        return 0;
    }
    sort(a + 1, a + n + 1);
    sort(b + 1, b + n + 1);
    int ans = 1;
    for (int i = 1; i <= n; i++) if (a[i].F > b[i].F) ans = 0;
    int c = 0;
    for (int i = 1; i < n; i++){
        if (a[i + 1].F <= b[i].F && a[i].F <= b[i + 1].F) c = 1;
    }
    if (ans && c) cout << "Yes"; else
    {
        if (ans == 0){
            cout << "No";
            return 0;
        }
        for (int i = 1; i <= n; i++){
            g[a[i].S].pb(b[i].S);
        }
        dfs(1);
        for (int i = 1; i <= n; i++){
            if (!used[i]){
                cout << "Yes";
                return 0;
            }
        }
        cout << "No";
    }

}


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

using namespace std;

#define forn for (ll i = 0; i < n; i++)
#define form for (ll j = 0; j < m; j++)
#define NO cout << "NO\n";
#define YES cout << "YES\n";
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for (ll i = a; i < b; i++)

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;

ll gcd(ll a, ll b){
    ll r;
    while (b != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}


ll *calc_z(string s){
    ll n = s.size();
    ll *z = new ll[n] {0};
    ll l = 0, r = 0;
    for (ll i = 1; i < n; i++){
        if (r >= i) z[i] = min(z[i-l], r-i+1);
        while (z[i]+i < n && s[z[i]] == s[z[i]+i]) z[i]++;
        if (i + z[i] - 1 > r){
            l = i;
            r = i+z[i]-1;
        }
    }
    return z;
}

ll find_lower(ll *a, ll n, ll v){
    ll l = -1, r = n;

    while (r>l+1){
        ll m = (l+r)/2;

        if (a[m] >= v) r = m;
        else l = m;
    }
    if (r == n) return n-1;
    if (a[r] == v) return r;
    return r == 0 ? 0 : r-1;
}

void init(){
}

int bin(int *p, int n, int x){
    int l = 0, r = n-1;
    while (r >= l){
        int m = (l+r)/2;
        if (p[m] == x) return m;
        if (p[m] > x) r = m-1;
        else l = m+1;
    }
    return -1;
}

void solve(){
    int n;
    cin >> n;
    int *a = new int[n];
    int *m = new int[ (int) 1e6+1];
    memset(m, 0, 1e6+1);
    forn{
        cin >> a[i];
        m[a[i]]++;
    }

    int c = 0;
    bool flag;

    forn{
        flag = true;
        for (int j = 2; j*j<=a[i]; j++){
            if (a[i] % j == 0){
                if (m[j] || m[a[i]/j]){
                    flag = false;
                    break;
                }
            }
        }
        if (a[i] == 1 && m[1] <= 1) c++;
        else if (m[1] == 0 && m[a[i]] == 1 && flag) c++;
    }
    cout << c << '\n';
}


int main(){
    //init();

    ios::sync_with_stdio(0);
    cin.tie(0);

    //ll t; cin >> t; while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 8288
#include<bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <functional>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    ll n;
	cin >> n;
    ll c = 0;
    ll ans=0;
  	ll k;
  	for ( k = 1; k <= sqrt(n-1); k++ ) { 
    	if ((n-1) % k == 0)c+=2;
  	}
    if(ll(sqrt(n-1))*ll(sqrt(n-1))==n-1)c--;
    ans+=c-1;
  	for( k = 1; k <= sqrt(n); k++ ) {
    	if (n % k == 0){
          ll nn=n;
          while(nn%k==0&&k!=1){
            nn/=k;
          }
          if(nn%k==1)ans++;
        }
  	}
  	ans++;
      cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define INF LLONG_MAX
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll l, r; cin >> l >> r;
    if (r - l >= 2019) {
        cout << 0 << endl;
        return 0;
    }
    ll min = INF;
    for (ll i = l; i < r; i++) {
        for (ll j = i+1; j <= r; j++)
        {
            ll num = ((i % 2019) * (j % 2019)) % 2019;
            if (num < min) min = num;
        }
        
    }
    cout << min << endl;
    
    return 0;
}

Measured memory_bytes: 256
object Main extends App {
	val Array(a, b) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
	var ans = -1
  
	for(x<-1009 to 1 by -1){
		if((x*0.08).toInt ==a  &&  (x*0.1).toInt == b){
			ans = x
		}
	}

	println(ans)
}

Measured memory_bytes: 27472
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
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 N;
long long h[100010];

// DP テーブル
long long dp[100010];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) cin >> h[i];

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 1; i < N; ++i) {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    // 答え
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 5140
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

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

  i64 answer = 1;
  for (auto it = ++S.begin(), prev_it = S.begin(); it != S.end(); prev_it = it, ++it) {
    if (*prev_it != *it) ++answer;
  }

  std::cout << answer << std::endl;
  return 0;
}

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

int main() {
	long long n, a, b;
	cin >> n >> a >> b;
	long long repeat_num = n / (a + b);
	long long remind = n % (a + b);
	long long add;
	if (remind <= a) {
		add = remind;
	}
	else {
		add = a;
	}
	long long answer = repeat_num * a + add;
	
	cout << answer << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=200050;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

int N,A[MAXN];
int L[MAXN],R[MAXN];
int LL[MAXN][2],RR[MAXN][2];

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>N;
	FOR(i,1,N)cin>>A[i];
	if(N%2==0){
		LL[1][1]=A[1];
		FOR(i,2,N){
			LL[i][i%2]=LL[i-2][i%2]+A[i];
		}
		DEC(i,N,1){
			RR[i][i%2]=RR[i+2][i%2]+A[i];
		}
		int ans=-1e18;
		FOR(i,1,N){
			ans = max(ans,LL[i][i%2]+RR[i+2][(i+2)%2]);
			if (i%2) ans = max(ans,LL[i][i%2]+RR[i+3][(i+3)%2]);
		}
		cout<<ans;
		exit(0);
	}
	int ans=0, cur=0;
	FOR(i,1,N){
		if(i%2==0) cur+=A[i];
	}
	ans=cur;
	FOR(i,1,N){
		if(i%2==0){
			L[i]=L[i-2]+A[i-1];
			L[i]-=A[i];
		}
	}
	DEC(i,N,1){
		if(i%2==0){
			R[i]=R[i+2]+A[i+1];
			R[i]-=A[i];
		}
	}
	FOR(i,2,N-1){
		if(i%2==0) L[i]=max(L[i-2],L[i]);
	}
	DEC(i,N,0){
		if(i%2==0) R[i]=max(R[i+2],R[i]);
	}
	FOR(i,0,N-1){
		if(i%2==0) ans = max(ans, cur+L[i]+R[i+2]);
	}
	cout<<ans;
}


Measured memory_bytes: 11456
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int N; cin >> N;
    priority_queue<float, vector<float>, greater<float> > q;
    repp(i,0,N) {
        float x; cin >> x;
        q.push(x);
    }

    while(q.size() > 1) {
        float a, b;
        a = q.top(); q.pop();
        b = q.top(); q.pop();
        float c = (a+b)/2;
        q.push(c);
    }
    cout << q.top() << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[100010],h[100010],tot;
map<int,int> mp;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		mp[a[i]]++;
	}
	sort(a+1,a+n+1);
	n=unique(a+1,a+n+1)-(a+1);
	for(int i=1;i<=n;i++)
	{
		if(mp[a[i]]>=2) h[++tot]=a[i];
		if(mp[a[i]]>=4) h[++tot]=a[i];
	}
	sort(h+1,h+tot+1);
	long long ans=(long long)h[tot]*h[tot-1];
	cout<<ans<<endl;
	return 0;
}
		

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

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

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

int dp[100101][2];

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i,N) cin >> A[i];
  rep(i,2) dp[0][i] = 1;
  rep(i,N-1) {
    if( A[i] == A[i+1] ) {
      dp[i+1][0] = dp[i][0];
      dp[i+1][1] = dp[i][1];
    } else if( A[i] < A[i+1] ) {
      dp[i+1][0] = dp[i][0]; // 0 <
      dp[i+1][1] = min(dp[i][0]+1,dp[i][1] + 1); // 1 >
    } else {
      dp[i+1][1] = dp[i][1]; 
      dp[i+1][0] = min(dp[i][0]+1,dp[i][1] + 1); // 1 >
    }
  }
  cout << min(dp[N-1][0],dp[N-1][1]) << endl;
  return 0;
}


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

const int32_t MAX_N = 1e5;
const int32_t INF = 2e9;

int32_t a[MAX_N + 5], dp[MAX_N + 5];

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

	int32_t n;
	std::cin >> n;

	for(int32_t i = 0; i < n; i++) {
		std::cin >> a[i];
	}

	dp[0] = 0;
	for(int32_t i = 1; i < n; i++) {
		dp[i] = INF;

		if(i - 2 >= 0) {
			dp[i] = dp[i - 2] + std::abs(a[i - 2] - a[i]);
		}

		dp[i] = std::min(dp[i], dp[i - 1] + std::abs(a[i - 1] - a[i]));
	}

	std::cout << dp[n - 1] << '\n';
}



Measured memory_bytes: 1024
def int2str(i):
  t=str(i)
  if i <10:
    a="0"
    b="0"
    c=t[-1]
  elif i <100:
    a="0"
    b=t[-2]
    c=t[-1]
  else:
    a=t[-3]
    b=t[-2]
    c=t[-1]
  return a,b,c

N=int(input())
S=input()
ans=0
for i in range(1000):
  S1=[]
  S2=[]
  a,b,c=int2str(i)
  flag=0
  i1 = S.find(a)
  if i1 !=-1:
    S1=S[i1+1:]
    i2=S1.find(b)
    if i2 !=-1:
      S2=S1[i2+1:]
      i3=S2.find(c)
      if i3 !=-1:
        ans+=1
print(ans)
  
  

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <stack>
#include <queue>
#include <set>

#define mod 1000000007
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
using ll = long long;
using pii = pair<int, int>;

ll a, b, n;
ll ans = 0;

//めぐる式二分探索
ll binary_search(){
    ll ng = n+1; //[ok, ng)もしくは(ng, ok]
    ll ok = 1; //絶対解を満たす
    while(abs(ok-ng) > 1){
        ll mid = (ok+ng)/2;
        if(floor(a*mid/b)-a*floor(mid/b) >= ans) {
            ok = mid;
            ans=floor(a*mid/b)-a*floor(mid/b);
        }
        else ng = mid;
    }
    return ok;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b >> n;
    binary_search();
    cout << ans;
    return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<cstdio>
using namespace std;

int main() {
  int N;
  scanf("%d", &N);
  int odd=0;
  int four=0;
  for (int i=0 ; i<N ; i++) {
    int num;
    scanf("%d", &num);
    if (num % 2 == 1) odd++;
    else if (num % 4 == 0) four++;
  }
  if (four > odd - 1 || odd == 0) printf("Yes\n");
  else if (four + odd == N && four == odd - 1)  printf("Yes\n");
  else printf("No\n");
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main( void )
{
	bool next = false;
	int n;
	while ( cin >> n && n )
	{
		if ( next )
		{
			cout << endl;
		}
		next = true;
		vector <string> team_names(n);
		vector <int> points(n,0);
		vector <int> id(n,0);
		for ( int i = 0; i < n; i++ )
		{
			id[i] = i;
			cin >> team_names[i];
			int point;
			cin >> point;
			points[i] += point * 3;
			cin >> point;
			cin >> point;
			points[i] += point;
		}

		for ( int i = 0; i < n-1; i++ )
		{
			for ( int j = i + 1; j < n; j++ )
			{
				if ( points[i] < points[j] )
				{
					swap( points[i], points[j] );
					swap( team_names[i], team_names[j] );
					swap( id[i], id[j] );
				}
				else if ( points[i] == points[j] )
				{
					if ( id[i] > id[j] )
					{
						swap( points[i], points[j] );
						swap( team_names[i], team_names[j] );
						swap( id[i], id[j] );
					}
				}
			}
		}

		for ( int i = 0; i < n; i++ )
		{
			cout << team_names[i] << ',' << points[i] << endl;
		}

	}

	return 0;
}

Measured memory_bytes: 0
def dq(a,l,r,m,right_most)
  ret=0
  h=Hash.new(0)
  if l==r
    ret=1 if a[l]%m==0
    h[a[l]%m]=1
    return [ret,h]
  end
  mid=(l+r)/2
  l_ret,l_mod=dq(a,l,mid,m,true)
  r_ret,r_mod=dq(a,mid+1,r,m,false)
  ret=l_ret+r_ret
  l_mod.each{|k,v|
    ret+=v*r_mod[(m-k)%m]
  }

  sum=0
  if right_most
    r.downto(l){|i|
      sum+=a[i]
      sum%=m
      h[sum]+=1
    }
  else
    l.upto(r){|i|
      sum+=a[i]
      sum%=m
      h[sum]+=1
    }
  end
  [ret,h]
end

n,m,*a=gets(p).split.map(&:to_i)
ans,h=dq(a,0,n-1,m,true)

puts ans

Measured memory_bytes: 48476
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i, n) for (int i = 0; i < ((int)(n)); i++) // 0-indexed昇順

int main()
{
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N);
  rep(i, N) cin >> A.at(i);
  rep(i, N) cin >> B.at(i);
  rep(i, N) cin >> C.at(i);
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());
  /*
  rep(i, N) cout << A[i] << " "; cout << endl;
  rep(i, N) cout << B[i] << " "; cout << endl;
  rep(i, N) cout << C[i] << " "; cout << endl;
  */
  ll res = 0;
  for (int j = 0; j < N; j++) {
    if (B.at(j) <= A[0]) continue;
    auto x = lower_bound(A.begin(), A.end(), B.at(j));
    x--;
    ll n = x - A.begin() + 1;
    auto y = upper_bound(C.begin(), C.end(), B.at(j));
    if (y == C.end()) continue;
    ll m = N - (y - C.begin());
    res += n * m;
    //cout << n << endl;
    //cout << m << endl;
  }
  cout << res << endl;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
template<class T> inline T isqrt(T k) {T r = sqrt(k) + 1; while (r * r > k) r--; return r;}
template<class T> inline T icbrt(T k) {T r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}

const int maxn = 200000 + 10;
int n, d, x;
long double sum[maxn];

void solve() {
	FOR(i, 1, maxn) {
		sum[i] = sum[i - 1] + 1.0 / (i + 1);
	}
	cin >> n >> d >> x;
	long long cur = d;
	long double ans = 0.0;
	FOR(i, 0, 2 * n) {
		int k = n - i / 2 - 1;
		ans += cur * sum[k] * 0.25;
		k = i / 2;
		ans += cur * sum[k] * 0.25;
		ans += 0.5 * cur;
		cur += x;
	}
	cout << prec(9) << ans << "\n";
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
	solve();
#ifdef _LOCAL_
	//printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
#define PI 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170
int main()
{
    double r,C1;
    scanf("%lf", &r);
    C1 = 2*PI*r;    //圆周长
    printf("%.20lf\n", C1);
    return 0;
}

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

using namespace std;

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

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

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

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

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

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, T, c, t;
	cin>>n>>T;
	int ans=1333;
	REP(i, n){
		cin>>c>>t;
		if(t<=T){
			ans=min(ans, c);
		}
	}
	if(ans!=1333){
		cout<<ans<<'\n';
	}
	else{
		cout<<"TLE"<<'\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long cal;
main()
{
	int t,p;
    scanf("%d%d",&t,&p);
    if(p==0)
    {
        cal=t;
        cal*=t;
        printf("%lld",cal);
        return 0;
    }
    for(int i = p+1;i <= t;i++)
    {
        for(int j = p,co=1;j <= t;j+=i,co++)
        {
            cal+=min(co*i,t+1)-j;
        }
    }
    printf("%lld",cal);
}


Measured memory_bytes: 256
import sys
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
n, m = [int(i) for i in sys.stdin.readline().split()]
graph = [[0 for i in range(n)] for j in range(n)]
for i in range(m):
    a, b, c = [int(i) for i in sys.stdin.readline().split()]
    a -= 1
    b -= 1
    graph[a][b] = c
    graph[b][a] = c
new_graph = csgraph_from_dense(graph)
res = floyd_warshall(new_graph)
cnt = 0
for i in range(n):
    for j in range(i, n):
        if graph[i][j] > 0 and graph[i][j] != res[i][j]:
            cnt += 1
print(cnt)

Measured memory_bytes: 17336
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math


N = int(input())
An = list(map(int, sys.stdin.readline().rstrip().split()))

ans = 0
mn = 10**9
minus = 0
for a in An:
  mn = min(mn, abs(a))
  ans += abs(a)
  if a < 0:
    minus += 1

if minus%2 == 0:
  print(ans)
else:
  print(ans-mn*2)



Measured memory_bytes: 64752
n,m = map(int,input().split())
ab = [[int(i) for i in input().split()]for _ in range(n)]
ab.sort()
ans = 0
for i in ab:
  if i[1]>=m:
    ans+=m*i[0]
    print(ans)
    exit()
  else:
    ans+=i[1]*i[0]
    m-=i[1]


Measured memory_bytes: 21604
#include <bits/stdc++.h>
using namespace std;
int N;
int P[105], Q[105], R[105], B[105];
int dfs(int v)
{
    int a = 1, b = 1, x, y, div;
    if(~R[v]) a = dfs(R[v]);
    if(~B[v]) b = dfs(B[v]);
    x = b * Q[v], y = a * P[v];
    div = __gcd(x, y);
    return (x / div * a + y / div * b);
}
int main()
{
    while(cin >> N, N) {
        int cnt[105] = {};
        for(int i = 0; i < N; i++) {
            int div;
            cin >> P[i] >> Q[i] >> R[i] >> B[i]; R[i]--, B[i]--;
            if(~R[i]) cnt[R[i]]++;
            if(~B[i]) cnt[B[i]]++;
        }
        for(int i = 0; i < N; i++) {
            if(cnt[i] <= 0) cout << dfs(i) << endl;
        }
    }
    return (0);
}


Measured memory_bytes: 3080
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod =1e+9+7;

int main(){
    string a,b,c;
    cin>>a>>b>>c;
    cout<<a[0]<<b[0]<<c[0]<<endl;
}





























































































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

int main() {
	string a,b,c;
  	cin>>a>>b>>c;
  	cout<<char(a[0]-32)<<char(b[0]-32)<<char(c[0]-32)<<endl;
}	

Measured memory_bytes: 3560
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])

for i in range(8):
    output = []
    for j in range(3):
        if ((i >> j) & 1) == 1:
            output.append('+')
        else:
            output.append('-')
    ans = 0
    ansstr = ''
    for i in range(4):
        if i == 0:
            ans += int(s[i])
            ansstr += s[i]
        elif output[i-1] == '+':
            ans += int(s[i])
            ansstr += output[i-1]
            ansstr += s[i]
        else:
            ans -= int(s[i])
            ansstr += output[i-1]
            ansstr += s[i]
    if ans == 7:
        print(ansstr+'=7')
        exit()


Measured memory_bytes: 3064
import math

NN = 202020
MOD = 10**9+7
# MOD = 998244353
INF = float("inf")

n = int(input())
s = 0
for i in range(1, n+1):
    for j in range(i, n+1):
        for k in range(j, n+1):
            tmp = math.gcd(i, j)
            a = math.gcd(tmp, k)
            if i == j == k:
                s += a
            elif i == j or j == k or k == j:
                s += 3*a
            else:
                s += 6*a

print(s)

Measured memory_bytes: 67880
import java.util.*;
public class Main {
  
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int sx = sc.nextInt();
		int sy = sc.nextInt();
		int tx = sc.nextInt();
      	int ty = sc.nextInt();
      
      	// 答えをここに入れていくよ
      	List<String> ansList = new ArrayList<>(); 

      	// xの変化量
      	int xd = tx - sx;
      	// yの変化量
      	int yd = ty - sy;
      
      	// 1往復目＿行き
      	// xd回右へ
      	ansList.addAll(createFilledList(xd, "R"));
      	// yd回上へ
      	ansList.addAll(createFilledList(yd, "U"));
      
      	// 1往復目＿帰り
      	// xd回左へ
      	ansList.addAll(createFilledList(xd, "L"));
      	// yd回下へ
      	ansList.addAll(createFilledList(yd, "D"));
      
      	// 2往復目＿行き
      	// 1回迂回して下へ
      	ansList.add("D");
      	// xd+1回右へ
      	ansList.addAll(createFilledList(xd + 1, "R"));
      	// yd+1回上へ
      	ansList.addAll(createFilledList(yd + 1, "U"));
      	// ゴールするため左へ
      	ansList.add("L");
      
      	// 2往復目＿帰り
      	// 1回迂回して上へ
      	ansList.add("U");
      	// xd+1回左へ
      	ansList.addAll(createFilledList(xd + 1, "L"));
      	// yd+1回下へ
      	ansList.addAll(createFilledList(yd + 1, "D"));
      	// ゴールするため右へ
      	ansList.add("R");
      
      	// Listを文字列連結する
      	String ans = String.join("", ansList);
      
      	// 答え
		System.out.println(ans);
		sc.close();
	}
    private static List<String> createFilledList(int length, String c) {
    	String[] temp = new String[length];
      	Arrays.fill(temp, c);
      	return Arrays.asList(temp);
    }
}

Measured memory_bytes: 22100
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
const int Q=1505;
char a[Q][Q];
int f[Q][Q],l[Q][Q],r[Q][Q];
int n;
int Ok(int x,int y)
{return (x<=n)&(y<=n)&(a[x][y]!='#');}
int main()
{
    ll als=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%s",a[i]+1);
    for(int i=n;i;--i)
        for(int j=n;j;--j){
            if(!Ok(i,j)){
                l[i][j]=n+1,r[i][j]=-1;
                continue;
            }
            int D=Ok(i+1,j),R=Ok(i,j+1);
            int val=a[i][j]-'0';
            if(!(D|R)){
                f[i][j]=val;
                l[i][j]=r[i][j]=j;
                for(int k=i+1;k<=n;k++)
                    l[k][j]=n+1,r[k][j]=0;
            }
            else if(D&R){
                int tmp=f[i+1][j]+f[i][j+1]+val;
                for(int k=i+1,mxr=0,lv,rv;k<=n;k++){
                    lv=l[k][j+1],rv=r[k][j+1];
                    if(lv>mxr&&lv<=r[k][j])tmp-=f[k][lv];
                    mxr=max(mxr,r[k][j]);
                    l[k][j]=min(l[k][j],lv);
                    r[k][j]=max(r[k][j],rv);
                }
                f[i][j]=tmp;
                l[i][j]=j;
                r[i][j]=r[i][j+1];
            }
            else if(D){
                f[i][j]=f[i+1][j]+val;
                l[i][j]=r[i][j]=j;
            }
            else{
                f[i][j]=f[i][j+1]+val;
                for(int k=i;k<=n;k++)
                    l[k][j]=l[k][j+1],r[k][j]=r[k][j+1];
                l[i][j]=j;
            }
            als+=1LL*val*(f[i][j]-val);
        }
    printf("%lld\n",als);
    return 0;
}

Measured memory_bytes: 29056
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; ++i)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define SCAN(x) cin >> x
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define PB push_back
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef complex<long double> P;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> Point;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1ll << 60;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

#ifdef WIN32
#define dump(x) cerr << #x << " = " << (x) << "\n"
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n"
#else
#define dump(x)
#define debug(x)
#endif

template<class T> ostream &operator<<( ostream &os, vector<T> &v ) {
  for ( int i = 0; i < v.size(); i++ ) {
    if ( i ) os << " ";
    os << v[ i ];
  }
  return os;
}

int main() {
  ios::sync_with_stdio( false );
  cin.tie( 0 );
  int n, m;
  while ( cin >> n >> m && n && m ) {
    VI p( n );
    for ( int i = 0; i < n; i++ ) {
      cin >> p[ i ];
    }
    p.push_back( 0 );
    SORT( p );
    set<int> two_selected;
    for ( int i = 0; i < n + 1; i++ ) {
      for ( int j = i; j < n + 1; j++ ) {
        two_selected.insert( p[ i ] + p[ j ] );
      }
    }
    int ans = 0;
    for ( set<int>::iterator it = two_selected.begin(); it != two_selected.end(); ++it ) {
      set<int>::iterator it2 = two_selected.upper_bound( m - *it );
      if ( it2 != two_selected.begin() ) {
        --it2;
        ans = max( ans, *it + *it2 );
      }
    }
    PRINT( ans );
  }
  return 0;
}

Measured memory_bytes: 24476
#include <iostream>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;

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

int main() {
	int x,y;
	cin >> x >> y;
	int ans = gcd(x, y);
	cout << ans << endl;
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 998244353;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll a,b,t;

int main(){
  cin >> a >> b >> t;
  cout << b*(t/a) << endl;

}


Measured memory_bytes: 256
/*Program from Luvwgyx*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=1e5+10;
struct node{int to,nxt;}e[maxn<<1];
int n,m,tot,head[maxn];
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void print(int x){
    if(x<0)putchar('-'),x=-x;
    if(x>9)print(x/10);
    putchar(x%10+'0');
}
void write(int x){print(x);puts("");}
void add(int u,int v){e[++tot].to=v;e[tot].nxt=head[u];head[u]=tot;}
namespace lty{
    int dep[maxn],ans[maxn],cnt[2];
    void dfs(int x,int fa,int Dep){
        dep[x]=Dep;ans[x]=Dep%2==1?-1:1;cnt[Dep%2]++;
        for(int i=head[x],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
            if(v!=fa)dfs(v,x,Dep+1),ans[x]+=ans[v];
    }
    void solve(){
        dfs(1,0,1);
        if(cnt[0]!=cnt[1]){puts("-1");return ;}
        int ret=0;
        for(int i=1;i<=n;i++)ret+=abs(ans[i]);
        write(ret);
    }
}
namespace wyx{
    int S,T,ans,top,size[maxn],val[maxn],s[maxn];bool flag=0;
    void dfs1(int x,int fa){
        for(int i=head[x],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
            if(v!=fa){
                if(size[v]){if(size[x]==size[v])flag=1;S=x;T=v;}
                else {size[v]=-size[x];dfs1(v,x);}
            }
    }
    void dfs2(int x,int fa){
        for(int i=head[x],v=e[i].to;i;i=e[i].nxt,v=e[i].to){
            if(v==fa||(x==S&&v==T)||(x==T&&v==S))continue;
            dfs2(v,x);size[x]+=size[v];val[x]+=val[v];
        }
    }
    void solve(){
        size[1]=1;dfs1(1,0);int ret=0;
        for(int i=1;i<=n;i++)ret+=size[i];
        if(flag){
            if(ret&1){puts("-1");return ;}
            ans+=abs(ret>>1);
            size[S]-=ret>>1;size[T]-=ret>>1;
        }else {
            if(ret){puts("-1");return ;}
            val[S]=1;val[T]=-1;
        }dfs2(1,0);
        for(int i=1;i<=n;i++){
            if(val[i])s[++top]=val[i]*size[i];
            else ans+=abs(size[i]);
        }s[++top]=0;sort(s+1,s+top+1);
        int mid=s[(top+1)>>1];
        for(int i=1;i<=top;i++)ans+=abs(s[i]-mid);
        write(ans);
    }
}
int main(){
    n=read();m=read();
    for(int i=1,u,v;i<=m;i++)u=read(),v=read(),add(u,v),add(v,u);
    if(m==n-1)lty::solve();
    else wyx::solve();
    return 0;
}


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

int main(){
#ifndef ONLINE_JUDGE
	freopen("C:\\Users\\User\\Documents\\input.txt","r",stdin);
#endif
	int T,i,j;
	int n,wt;
	cin>>n>>wt;
	vector<ll> w(n+1),v(n+1);
	for(i=1;i<=n;++i){
	    scanf("%lld %lld",&w[i],&v[i]);
	}
	vector<ll> dp(wt+1,0); 
	
	for(i=1;i<=n;++i){
	    for(j=wt-w[i];j>=0;--j){
	       dp[j+w[i]]=max(dp[j+w[i]],dp[j]+v[i]);
	    }
	}
	ll res=0;
	for(i=0;i<=wt;++i){
	    res=max(dp[i],res);
	}
	printf("%lld\n",res);

		
	return 0;
}

Measured memory_bytes: 4076
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
#include <limits>
#include <type_traits>
typedef unsigned long long ull;
typedef long long ll;
#define __TRUE "Yes"
#define __FALSE "No"
#define cout(x) cout << (x) << endl
#define MAX 101
using namespace std;

int oneC(string S) {
  int count=0;
  for(int i=0;i<S.size();i++) {
    if(S[i] == '1') count++;
    else {
      break;
    }
  }
  return count;
}

int main() {
  string S;
  int k;
  cin >> S >> k;
  int one = oneC(S);
  if(one == 0) {
    cout << S[0] << endl;
  } else {
    if(k <= one) {
      cout << 1 << endl;
    } else {
      cout << S[one] << endl;
    }
  }
  return 0;
}

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

ll modPow(ll a, ll n, ll mod) {
    ll res  = 1;
    for (ll i = 0; i < n; ++i) {
        res *= a;
        res %= mod;
    }
    return res;
}

int main() 
{
    const ll mod = 1e9 + 7;
    ll N;
    cin >> N;
    ll x1 = modPow(10, N, mod);
    ll x2 = 2 * modPow(9, N, mod);
    ll x3 = modPow(8, N, mod);
    ll res = (x1 - x2 + x3 + 2 * mod) % mod;
    cout << res << endl;
}

Measured memory_bytes: 3588
n=int(input())
s=input()
l=list(s)
newcome=[]
alp=[chr(ord('A') + i) for i in range(26)]
for i in l:
  a=alp.index(i)
  if (a+n)<26:
    t=alp[a+n]
  else:
    t=alp[a+n-26]
  newcome.append(t)
print("".join(newcome))

Measured memory_bytes: 3188
from collections import defaultdict
import sys
input=sys.stdin.readline


def solve():
    N, X, Y = map(int, input().split())
    d = defaultdict(list)
    for i in range(1, N):
        d[i].append(i+1)
        d[i+1].append(i)
    d[X].append(Y)
    d[Y].append(X)
    ans = [0]*N

    for i in range(1, N+1):
        dist = [-1]*(N+1)
        dist[i] = 0
        q = [i]

        while q:
            s = q.pop()
            for t in d[s]:
                if dist[t]==-1 or dist[t] > dist[s]+1:
                    dist[t] = dist[s]+1
                    q.append(t)
        for j in range(i+1, N+1):
            ans[dist[j]] += 1

    for i in range(1, N):
        print(ans[i])


if __name__ == "__main__":
    solve()


Measured memory_bytes: 46940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}
ll modpow(long long a, long long n, long long mod2) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod2;
        a = a * a % mod2;
        n >>= 1;
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    if(s.size() %2 == 1){
        cout << "No" << endl;
        return 0;
    }
    string tmp,tmp2;
    for (int i = 0; i < s.size()/2; ++i) {
        tmp += s[i];
    }
    for (int i = s.size()/2; i < s.size(); ++i) {
        tmp2 += s[i];
    }
    if(tmp == tmp2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>m>>v;
  cout<<(n-m)%v<<endl;

}

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


Measured memory_bytes: 892
import java.util.Scanner;

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

		if(time*a<b) {
			System.out.println(time*a);
		}else {
			System.out.println(b);
		}
	}
}


Measured memory_bytes: 23380
//	-*- mode: C++ -*-
//	Queue
//		There are n processes in a queue. Each process has namei and timei. The round-robin scheduling handles the processes in order. A round-robin scheduler gives each process a quantum (a time slot) and interrupts the process if it is not completed by then. The process is resumed and moved to the end of the queue, then the scheduler handles the next process in the queue.
//
//		For example, we have the following queue with the quantum of 100ms.
//
//		A(150) - B(80) - C(200) - D(200)
//		First, process A is handled for 100ms, then the process is moved to the end of the queue with the remaining time (50ms).
//
//		B(80) - C(200) - D(200) - A(50)
//		Next, process B is handled for 80ms. The process is completed with the time stamp of 180ms and removed from the queue.
//
//		C(200) - D(200) - A(50)
//		Your task is to write a program which simulates the round-robin scheduling.
//	Input
//		n q
//		name1 time1
//		name2 time2
//		...
//		namen timen
//		In the first line the number of processes n and the quantum q are given separated by a single space.
//
//		In the following n lines, names and times for the n processes are given. namei and timei are separated by a single space.
//
//	Output
//		For each process, prints its name and the time the process finished in order.
//
//	Constraints
//		1 ≤ n ≤ 100000
//		1 ≤ q ≤ 1000
//		1 ≤ timei ≤ 50000
//		1 ≤ length of namei ≤ 10
//		1 ≤ Sum of timei ≤ 1000000
//	Sample Input 1
//		5 100
//		p1 150
//		p2 80
//		p3 200
//		p4 350
//		p5 20
//	Sample Output 1
//		p2 180
//		p5 400
//		p1 450
//		p3 550
//		p4 800

#include <iostream>
#include <queue>
#include <utility>

int	main(int	argc,
		 char*	argv[])
{
	typedef  std::pair<std::string, unsigned int>	process;

	std::queue<process>	R	{};

	unsigned int	n	{0};
	unsigned int	q	{0};

	std::cin >> n >> q;

	for(unsigned int i = 0; i < n; i++){
		std::string		name	{};
		unsigned int	time	{0};

		std::cin >> name >> time;

		R.push(std::make_pair(name, time));
	}

	unsigned int	totalTime	{0};

	while(!R.empty()){
		process	p	= R.front();
		R.pop();

		if(p.second > q){
			p.second	-= q;
			totalTime	+= q;
			R.push(p);
		}
		else{
			totalTime	+= p.second;

			std::cout << p.first << ' ' << totalTime << '\n';
		}
	}

    return 0;
}



Measured memory_bytes: 6188
#include <bits/stdc++.h>     // [PRIMES]               1777 ~2^10.80  
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(ll)(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

vl vals;
vl weights;
ll N, W;

vvl dp;

ll f(ll i, ll val){
    if(val < 0) return 0;
    if(dp[i][val] != -1) return dp[i][val];
    if(val == 0){
        dp[i][val] = 0;
        return 0;
    }
    if(i == 0){
        if(vals[0] >= val){
            ll res = weights[0];
            dp[i][val] = weights[i];
            return res;
        } else {
            dp[i][val] = oo;
            return oo;
        }
    }
    ll base = f(i-1, val);
    ll take = f(i-1, val-vals[i]) + weights[i];
    ll res = min(base, take);
    dp[i][val] = res;
    return res;
}

int main(){
    cin >> N >> W;
    ll valsu = 0;
    FOR(hjkl,0,N){
        ll a,b;
        cin >> a >> b;
        weights.pb(a);
        vals.pb(b);
        valsu += b;
    }
    dp.resize(N, vl(valsu+1, -1));
    ll best = 0;
    FOR(i,1,valsu+1){
        if(f(N-1, i) <= W) best = i;
    }
    cout << best << endl;
} //cin.tie(0) bei schnellem Wechseln




Measured memory_bytes: 79488
// https://atcoder.jp/contests/abc085/tasks/abc085_b

#include <bits/stdc++.h>

using namespace std;

#define ll long long 
#define REP1(i,n) for(ll i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define radrad(a)  180.0 * a / M_PI
#define pow(x) x*x
static const int MAX = 1000010;
static const ll INFTY = 1e12;
static const ll NUMMAX = 1000000007;
static const ll MOD = 1000000007;
#define LOOP 10000000
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 入力
int H, W;
vector<string> field;
int result = 100;
int dfs_res = 0;

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 N;
    cin >> N;
    vector<int> d(N);
    set<int> mochi;

    REP(i, N){
        cin >> d[i];
        mochi.insert(d[i]);
    }
    cout << mochi.size() << endl;


 
    return 0;
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/




Measured memory_bytes: 256