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

#define lli long long int
#define mpr make_pair
#define pr pair<lli,lli>
#define pb push_back
#define vl vector<lli>
#define mp map<lli,lli>
#define all(x) x.begin(),x.end()
#define FOR(i,n) for(lli i=0;i<(lli)n;i++)
#define FOR1(i,j,n) for(lli i=j;i<(lli)n;i++)
#define mod 1000000007

lli power(lli x,lli n,lli m)
{
	lli res=1;
	while(n>0)
	{
		if(n&1) res=(res*x)%m;
		x=(x*x)%m;
		n=n>>1;
	}
	return res;
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli n,r=0;
    cin>>n;
    vl v(n);
    for(lli i=0;i<n;i++)
    {
		cin>>v[i];
		r^=v[i];
	}
	for(lli i=0;i<n;i++)
	cout<<(r^v[i])<<" ";
	cout<<endl;
	
	
	
	
return 0;
}


Measured memory_bytes: 4776
#include<stdio.h>
#include<stdlib.h>

int h,w;

void dikstla(int **map,int **sumc,int y,int x,int sum);

int main(void){
  int i,j;
  char **route,c;
  int **cicada,**cmap,num;
  scanf("%d %d",&h,&w);
  route=(char **)calloc(h,sizeof(char *));
  cicada=(int **)calloc(h,sizeof(int *));
  cmap=(int **)calloc(h,sizeof(int*));
  for(i=0;i<h;i++){
    *(route+i)=(char *)calloc(w+1,sizeof(char)); 
    *(cicada+i)=(int *)calloc(w,sizeof(int));
    *(cmap+i)=(int *)calloc(w,sizeof(int));
  }
  for(i=0;i<h;i++){
    scanf("%s",*(route+i));
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      c=*(*(route+i)+j);
      //putchar(c);
      *(*(cicada+i)+j)=c-'0';
    }  
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      *(*(cmap+i)+j)=9999;
    }
  }
  dikstla(cicada,cmap,0,0,0);
  printf("%u\n",*(*(cmap+h-1)+w-1));
  for(i=0;i<h;i++){
    free(*(route+i));
    free(*(cicada+i));
    free(*(cmap+i));
  }
  free(route);
  free(cicada);
  free(cmap);
  return 0;
}

  void dikstla(int **map,int **sumc,int y,int x,int sum){
  int res=0,p,q;
  res=sum+*(*(map+y)+x);
  if(*(*(sumc+y)+x)>res){
    *(*(sumc+y)+x)=res;
    if(y<h-1) dikstla(map,sumc,y+1,x,*(*(sumc+y)+x));
    if(x<w-1) dikstla(map,sumc,y,x+1,*(*(sumc+y)+x));
  }
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(void){
    string s;
    cin>>s;
    if((s[0]==s[1])&&(s[1]==s[2])&&(s[0]==s[2]))
    {
        cout<<"Yes"<<endl;
    }
    else if((s[1]==s[2])&&(s[2]==s[3])&&(s[1]==s[3]))
    {
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }
}


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

using namespace std;

int main()
{
    int x,y;  cin >> x >> y;
    for(int i = 0;i<=x;i++){
        int left = x - i;
        if(i * 2 + left * 4 == y)  return cout << "Yes" , 0;

    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 3644
#include<stdio.h>
#include<string.h>
int main(void)
{
	int HIT=0,OUT=0,POINT=0,a,b,c=0;
	char EVENT[8];	
	for(;;)
	{
		scanf("%d",&a);
		for(b=0;;b++)
		{
			scanf("%s",&EVENT);
			if(strcmp(EVENT,"OUT")==0)
				OUT++;
			if(strcmp(EVENT,"HIT")==0)
				if(HIT==3)
					POINT++;
				else
					HIT++;
			if(strcmp(EVENT,"HOMERUN")==0)
			{
				POINT+=HIT+1;
				HIT=0;
			}
			if(OUT==3)
			{
				printf("%d\n",POINT);
				POINT=OUT=HIT=0;
				c++;
				if(c==a)
					return 0;
			}
		}
	}
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cctype>
#include <vector>
#include <numeric>
#include<string>
#include <map>
#include <chrono>
#include <cstdlib>
#include <ctime>

using namespace std;

#define ll long long
#define rep(cnt,a,n) for(ll cnt=a;cnt<n+a;cnt++) //aから始めてn回ループ
#define vector2(type,name,a,b) vector<vector<type>> name(a, vector<type>(b))
#define PI 3.141592653589793



int main() {
    int n;
    cin >> n;
    if (n % 1000==0) {
        cout << 0 << endl;
        return 0;
    }
    cout << 1000- n % 1000 << endl;

    return 0;
}


Measured memory_bytes: 3620
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------


//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    int ans=0;int now=0;
    while(1){
        if(now==a[now]-1){
            cout<<-1<<endl;
            return 0;
        }
        now=a[now]-1;
        ans++;
        if(ans==1e6){
            cout<<-1<<endl;
            return 0;
        }
        if(now==1)
            break;
    }
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC freopen("input.txt" , "r", stdin); freopen("output.txt" , "w", stdout) 
#define MOD (ll)1e9+7; //change it for other mods
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

ll powmod(ll a,ll b)
{
   ll res = 1;
   while(b > 0) {
      if(b & 1) res = (res * a) % MOD;
      a = (a*a)%MOD;
      b = b >> 1; 
  }
  return res % MOD;
}

void solve()
{
    ll x1,x2,x3;
    cin >> x1 >> x2 >> x3;
    cout << x3 << " " << x1 << " " << x2 << "\n";
}

int main()
{
    // FAST_IO;
    // #ifndef ONLINE_JUDGE 
    //   OC;
    // #endif
    ll t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c[30],e,f=0,g=0;
	vector<int> d[30];
	cin>>a>>b;
	for(int i=0;i<a;i++){
		cin>>c[i];
		for(int j=0;j<c[i];j++){
			cin>>e;
			d[i].push_back(e);
		}
	}
	for(int i=1;i<=b;i++){
		for(int j=0;j<a;j++){
			if(find(d[j].begin(),d[j].end(),i)==d[j].end()){
				g++;
			}
		}
		if(g==0){
			f++;
		}
		g=0;
	}
	cout<<f<<endl;
	return 0;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

vector<int> v[26];

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	string s; read(s);
	
	rep(i, 0, 26) v[i].push_back(-1);
	rep(i, 0, sz(s)) v[s[i] - 'a'].push_back(i);
	rep(i, 0, 26) v[i].push_back(sz(s));

	int ans = 0x3f3f3f3f;

	rep(i, 0, 26) {
		int lans = 0;
		rep(j, 0, sz(v[i]) - 1)
			chmax(lans, v[i][j + 1] - v[i][j]);
		chmin(ans, lans - 1);
	}

	die(ans);
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

class SegTreeMin {
public:
    int n;
    vector< int > node;

    SegTreeMin(vector< int > v) {
        int sz = v.size();
        n = 1;
        while( n < sz ) n <<= 1;
        node.resize(2 * n - 1, INF);

        for( int i = 0; i < sz; ++i ) {
                node[i + n - 1] = v[i];

        }
        for( int i = n - 2; i >= 0; --i ) {
            node[i] = max(node[2 * i + 1], node[2 * i + 2]);

        }
    }

    void Update(int x, int val) {
        x += n - 1;
        node[x] = val;
        while( x > 0 ) {
            x = (x - 1) >> 1;
            node[x] = max(node[2 * x + 1], node[2 * x + 2]);

        }
    }

    int Query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if( r < 0 ) {
            r = n;

        }

        if( r <= a || b <= l ) {
            return MIN;

        }
        if( a <= l && r <= b ) {
            return node[k];

        }

        int vl = Query(a, b, 2 * k + 1, l, (l + r) / 2);
        int vr = Query(a, b, 2 * k + 2, (l + r) / 2, r);
        return max(vl, vr);

    }

};

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

    int N, K;
    cin >> N >> K;

    vector<int> se(300001);
    SegTreeMin sg(se);
    vector<int> v(N);
    for(int i = 0; i < N; ++i) {
        cin >> v[i];
    }

    for(int i = 0; i < N; ++i) {
        int t = sg.Query(max(0, v[i] - K), min(300001, v[i] + K + 1));
        sg.Update(v[i], t + 1);
    }

    cout << sg.Query(0, 300001) << endl;

    return 0;
}



Measured memory_bytes: 9812
//@author :  |< U $ |-|
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<algorithm>
#include<list>
#include<cstring>
#include<unordered_map>
#define ll long long
// #define pb push_back
// #define pop pop_back
#define in(i,n) for(i=0;i<n;i++)
#define pi pair<long long ,long long>
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inm1(b)  memset(b,-1,sizeof(b))
#define in0(b) memset(b,0,sizeof(b))
#define ininf(b) memset(b,1000000001,sizeof(b))

#define inf 10000000001
#define d1(a) cout<<a<<" "<<endl
#define d2(a,b) cout<<a<<" "<<b<<endl
#define d3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define TakeInput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
using namespace std;
ll MOD = 1e9+7;
ll vis[1000001];
vector<ll> adj[1000001];

void dfs(ll v,ll &count ){
    vis[v] = 1;
    count++;
    for(auto &i : adj[v]){
        if(!vis[i]){
            dfs(i,count);
        }
    }
}


int main(){
    jaldi
    #ifndef ONLINE_JUDGE
    TakeInput
    #endif

    ll i,j,k,n,m;
    ll t;
    
    cin>>n>>m;
    

    for(i=0;i<m;i++){
        ll x,y;
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);

    }
    in0(vis);
    ll maxi =0 ;

    for(i=0;i<n;i++){
        if(!vis[i]){
            ll count =0 ;
            dfs(i,count);
            maxi = max(maxi,count);
        }
    }
    cout<<maxi;

    
}


Measured memory_bytes: 50524
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	long long int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		long long int MAX = 0;
		for (long long int i = 1; i < n; i++) {
			for (long long int j = i; j < n; j++) {
				if (i*i*i+j*j*j <= n*n*n) {
					MAX = max(MAX, i*i*i+j*j*j);
				} else {
					break;
				}
			}
			if (i*i*i*2 >= n*n*n) {
				break;
			}
		}
		cout << n*n*n-MAX << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//











int main() {

    int a, b;
    cin >> a >> b;

    if (a <= b) {
        out(a);
    }else out(a - 1);



    return 0;
}






Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
    long long n, nub, a, b, a1, b1;
    cin >> n >> a >> b;
    a1 = a;
    b1 = b;
    for (int i = 1;; i++) {
        if (i % 2 == 1) {
            a = a - b;
        }
        else {
            b = a + b;
        }
        if (a == a1 && b == b1) {
            nub = i;
            break;
        }
    }
    for (int j = 0; j < n % nub; j++) {
        if (j % 2 == 0) {
            a1 = a1 - b1;
        }
        else {
            b1 = a1 + b1;
        }
    }
    cout << a1 << " " << b1 << endl;
}


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

int main() {
  long long a, b, c, k;
  cin >> a >> b >> c >> k;
  
  long long ans;
  if (k % 2 == 0) ans = a - b;
  else ans = b - a;
    
  if (ans > pow(10, 18)) {
    cout << "Unfair" << endl;
    exit(0);
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	int n=s.size();
	int inf=1000000000,ans=inf;
	rep(i,n-1){
		if(s.at(i)!=s.at(i+1)){
			ans=min(ans,max(i+1,n-i-1));
		}
	}
	if(ans==inf) cout << n << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  string S; cin >> S;
  int a=0, b=0, c=0;
  for(char C : S) {
    if(C == 'a') a++;
    else if(C == 'b') b++;
    else c++;
  }

  if(abs(a-b) <= 1 && abs(b-c) <= 1 && abs(c-a) <= 1) cout << "YES" << endl;
  else cout << "NO" << endl;
  
}

Measured memory_bytes: 3708
n = int(input())
eat_lst = list(map(int,input().split()))
manzoku_lst = list(map(int,input().split()))
tuika_lst = list(map(int,input().split()))

res = sum(manzoku_lst)
#eat_lstの並びを確認し、iの次にi+1を食べていたらtuika_lstの値を加算

for i in range(n-1):
    if eat_lst[i] + 1 == eat_lst[i+1]:
        res = tuika_lst[eat_lst[i]-1] + res
print(res)


Measured memory_bytes: 3060
n = int(input())
a = [int(i) for i in input().split()]
flag = True
for i in range(n):
  if a[i] % 2 == 0:
    if a[i] % 3 != 0 and a[i] % 5 != 0:
      flag = False

if flag == True:
  print("APPROVED")
else:
  print("DENIED")


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main(){
		int x,y;
	
	while(1){
		cin>>x>>y;
		if(x==0&&y==0)break;
	
	
	if
	(x<=y)
	{
		cout<<x<<" "<<y<<endl;
	}
	else
	{
		cout<<y<<" "<<x<<endl;
	}
	}
		return 0;

}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int main()
{
	int N, K, ans = 1;
	cin >> N >> K;

	rep(i, N) ans = min(ans * 2, ans + K);
	cout << ans << endl;
	return 0;
}

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

const ll MAXN = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, ans=0, tmp=0;
vector<ll> A, B;
queue<ll> Q;

signed main(){
    cin >> N;
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        A.push_back(a);
    }
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        B.push_back(a);
    }
    for(int i=0;i<N;i++) {
        tmp = B[(N+i-1)%N];
        tmp += B[(i+1)%N];
        if(B[i]>=tmp) {
            Q.push(i);
        }
    }
    while(!Q.empty()) {
        ll u = Q.front();
        Q.pop();
        tmp = B[(N+u-1)%N];
        tmp += B[(u+1)%N];
        ans += (B[u]-A[u])/tmp;
        B[u] -= tmp*((B[u]-A[u])/tmp);
        if(B[(N+u-1)%N]>=B[(N+u-2)%N]+B[u]) {
            Q.push((N+u-1)%N);
        }
        if(B[(u+1)%N]>=B[(u+2)%N]+B[u]) {
            Q.push((u+1)%N);
        }
    }
    for(int i=0;i<N;i++) {
        //cout << A[i] << " " << B[i] << endl;
        if(A[i]!=B[i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    vector<int> a(n);
    int ikeep;
    for(int in=0;in<n;in++) {
        cin >> a.at(in);
        if(a.at(in)==1) ikeep = in;
    }

    int ans = 0;
    ans = (n-1+k-2)/(k-1);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
from collections import deque

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

E = [[] for _ in range(N + 1)]
for a, b in zip(*[iter(AB)] * 2):
    E[a].append(b)
    E[b].append(a)

def get_dist(src):
    Q = deque([src])
    dist = [0] * (N + 1)
    while Q:
        v =  Q.popleft()
        for u in E[v]:
            if dist[u] == 0:
                Q.append(u)
                dist[u] = dist[v] + 1
    return dist[1:]

F = get_dist(1)
S = get_dist(N)

fennec = sum(1 if f <= s else -1 for f, s in zip(F, S))

if fennec > 0:
    print("Fennec")
else:
    print("Snuke")


Measured memory_bytes: 31724
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int V = Integer.parseInt(sc.next());
        int E = Integer.parseInt(sc.next());
        List<List<Integer>> graph = new ArrayList<>();
        for(int i = 0; i < V; i++){
            graph.add(new ArrayList<>());
        }
        for(int i = 0; i < E; i++){
            int s = Integer.parseInt(sc.next());
            int t = Integer.parseInt(sc.next());
            graph.get(s).add(t);
            graph.get(t).add(s);
        }
        
        ArrayDeque<Integer> stack = new ArrayDeque<>();
        int[] prenum = new int[V];
        int[] parent = new int[V];
        int[] lowest = new int[V];
        int timer = 1;
        int root = 0;
        prenum[root] = timer;
        parent[root] = -1;
        lowest[root] = timer;
        timer++;
        stack.push(root);
        
        while(!stack.isEmpty()){
            int u = stack.peek();
            int v = -1;
            for (Integer i : graph.get(u)) {
                if(prenum[i] == 0){
                    v = i;
                    break;
                }
            }
            if(v != -1){
                prenum[v] = timer;
                parent[v] = u;
                lowest[v] = timer;
                timer++;
                stack.push(v);
            }else{
                u = stack.pop();
                for (Integer i : graph.get(u)) {
                    if(i != parent[u]){
                        lowest[u] = Math.min(lowest[u], prenum[i]);
                    }
                }
                if(parent[u] != -1){
                    int p = parent[u];
                    lowest[p] = Math.min(lowest[p], lowest[u]);
                }
            }
        }
        
        Set<Integer> ap = new TreeSet<>();
        int np = 0;
        for(int i = 1; i < V; i++){
            int p = parent[i];
            if(p == root){
                np++;
            }else if(prenum[p] <= lowest[i]){
                ap.add(p);
            }
        }
        if(np > 1) ap.add(root);
        
        StringBuilder sb = new StringBuilder();
        ap.forEach((i) -> {
            sb.append(i).append(System.lineSeparator());
        });
        System.out.print(sb);
    }
}


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

#define fst first
#define snd second
#define mp make_pair
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define per(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()

template <typename T1, typename T2>
bool umin(T1 &x, const T2 &y) {return (x>y ? (x=y,true):false);}
template <typename T1, typename T2>
bool umax(T1 &x, const T2 &y) {return (x<y ? (x=y,true):false);}

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

const int N = (int)1e6+3;
const int INF = (int)1e9+17;
const ll mod = (ll)1e9+7;
const ll LLINF = (ll)1e18+17;
const ld pi = (ld)acos(-1.0);


int n, m;


int main()
{
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    cin >> n;
    int prev = 0;
    ll res = 0;
    rep(i, 0, n) {
        int cur;
        cin >> cur;
        res += min(prev, cur);
        cur -= min(prev, cur);
        res += cur / 2;
        prev = cur % 2;
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
let rec digit_sum x =
  if x <= 0 then 0 else x mod 10 + digit_sum (x/10)

let rec iter a b min n =
  let sum = digit_sum a + digit_sum b in
  if a < n/2 then min
  else if sum < min  then
    iter (a - 1) (b + 1)  sum n
  else
    iter (a - 1) (b + 1)  min n
  ;;
let () =
  let n = Scanf.scanf "%d" (fun x -> x) in
  let min = iter (n - 1) 1 100000 n in
  print_endline (string_of_int min)


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define vpipii vector<pipii>
#define vpiipi vector<piipi>
#define pb push_back
#define pob pop_back
#define pii pair<int,int>
#define pipii pair<int,pii>
#define piipi pair<pii,int>
#define pld pair<long double,long double>
#define mod 1000000007
// #define mod 1000000009
// #define mod 163577857 
// #define mod 998244353
#define rep(i,n) for (int i = 0; i < n; i++)
#define repp(i,a,b) for(int i = a ; i<b ; i++)
#define reppr(i,a,b) for(int i = a-1 ; i>=b ; i--)
#define repr(i,n) for (int i = n - 1; i >= 0; i--)
#define ff first
#define ss second
#define pc putchar_unlocked
#define gc getchar_unlocked
#define inf 9223372036854775807
#define infn -9223372036854775807
#define pi 3.14159265358979323846
#define eps 0.0000000001
#define sp << " " <<
#define setprec(x) cout << fixed << setprecision(x);
#define REVERSE(a) reverse(all(a));
#define SORT(a) sort(all(a));
#define all(n) n.begin(),n.end()

//GCD and LCM
    int gcd (int a, int b) { return b ? gcd (b, a % b) : a; }
    int lcm (int a, int b) { return a / gcd(a, b) * b; }
 
//Modular Exponentiation
    int powmod(int x,int y) 
    { 
        if (y == 0) return 1; 
        int p = powmod(x, y/2) % mod; 
        p = (p * p) % mod;   
        return (y%2 == 0)? p : (x * p) % mod; 
    }
 
//Modular Inverse
    int inverse(int a) 
    { 
       return powmod(a,mod-2); 
    }

//Binomial Coefficients
    const int limbin = 500001;
    int fact[limbin], factinv[limbin] , coefficientflag = 0;
    void Util_nCr()
    {
        fact[0] = 1 , factinv[0] = 1;
        repp(i,1,limbin)
        {
            fact[i] = (fact[i-1] * i)%mod;
            factinv[i] = (factinv[i-1] * inverse(i))%mod;
        }
    }
    int nCr(int n , int r)
    {
        if(!coefficientflag) coefficientflag = 1 , Util_nCr();
        if(n<r) return 0;             
        return ((fact[n] * inverse(fact[n-r]) % mod * inverse(fact[r]))%mod) ;
    }

void solve();
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    // cin >> t; 
    rep(i,t)
    {
        // cout << "Case #" << i+1 << ": ";
        solve();
    }
}

int test[502][502];
void solve()
{ 
    int n, m, a, b, ans = 0; cin >> n >> m >> a >> b;
    int ka = a * b - 2;
    for (int h = 1; h <= n; h++) {
        for (int i = 1; i <= m; i++) {
            if (h % a == 0 && i % b == 0) { 
                test[h][i] = 0 - (mod - 7); ans -= mod - 7;
            }
            else if ((h - 1) % a == 0 && (i - 1) % b == 0) {
                test[h][i] = mod - 8 - ka; ans += mod - 8 - ka;
            }
            else { test[h][i] = 1; ans += 1; }
        }
    }
    if (ans > 0) {
        cout << "Yes\n";
        for (int h = 1; h <= n; h++) {
            cout << test[h][1];
            for (int i = 2; i <= m; i++) {
                cout << ' ' << test[h][i];
            }
            cout << endl;
        }
    }
    else
        cout << "No\n";
}

Measured memory_bytes: 5616
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
    ll n,s = 0;
    cin >> n;
    for (ll i = 1; i <= n; i++)
    {
        ll p = n / i;
        s += i * p * (p+1)/2;
    }
    cout << s << endl;
}


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

#define ll long long int
#define vi vector<int>
#define vc vector<char>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define pb push_back
#define el '\n'
#define N 1000000007
#define re return
#define PI 3.14159265
#define take(a,n) for(int i=0;i<(n);i++) cin>>(a)[i]
#define out(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" ";
#define all(a) (a).begin(),(a).end()
#define forup(i,n) for(int (i)=0;i<(n);(i)++)
#define ford(i,n) for(int (i)=(n)-1;i>=0;(i)--)
using namespace std;


ll poww(ll a,ll b)
{
  ll ans=1;
  for(int i=1;i<=b;i++)
  {
    ans*=a;
  }
  return ans;
}


int max(int a,int b,int c)
{
  if(a>=b && a>=c) return a;
  if(b>=a && b>=c) return b;
  return c;
}


int main()
{
  cout<<fixed<<setprecision(6);
  string s;
  int n;
  cin>>n;
  priority_queue<double,vector<double>,greater<double>> q;
  forup(i,n) {int t;cin>>t;q.push(t);}

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


}


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


int main() {
	
	int N;
	cin >> N;
	vector<vector<int>> a(2, vector<int>(N));
	for(auto &i : a){
		for(auto &j : i) cin >> j;
	}
	int summax = 0;
	for(int i=0; i<N; i++){
		int sum = 0;
		for(int j=0; j<N; j++){
			if(j<=i) sum += a.at(0).at(j);
			if(j>=i) sum += a.at(1).at(j);
		}
		summax = max(sum, summax);
	}
	cout << summax << endl;
	
	
	return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

vector<ll> f(string s) {
  vector<ll> v(26,0);
  for(auto c: s){
    v[c-'a']++;
  }
  return v;
}

signed main() {
  ll N,ans=0;
  cin>>N;
  map<vector<ll>, ll> mp;
  rep(i,N){
    string s;
    cin>>s;
    auto x = f(s);
    ans+=mp[x];
    mp[x]++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 29952
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;

void main() {
    int n, m;
    int[] a;

    scan(n, m);
    a = readln.split.to!(int[]);

    int t = 2 * (n - 1 - m);

    if (t > n) {
        writeln("Impossible");
        return;
    }

    int[][] adj = new int[][](n, 0);

    foreach (i ; 0 .. m) {
        int xi, yi;
        scan(xi, yi);
        adj[xi] ~= yi;
        adj[yi] ~= xi;
    }

    auto v = new bool[](n);

    int dfs(int i) {
        int res = i;
        v[i] = 1;

        foreach (j ; adj[i]) {
            if (!v[j]) {
                int mj = dfs(j);
                if (a[res] > a[mj]) {
                    res = mj;
                }
            }
        }

        return res;
    }

    auto used = new bool[](n);
    long ans;

    foreach (i ; 0 .. n) {
        if (t <= 0) break;
        if (!v[i]) {
            int mi = dfs(i);
            used[mi] = 1;
            ans += a[mi];
            t--;
        }
    }

    auto zan = new int[](0);

    foreach (i ; 0 .. n) {
        if (!used[i]) zan ~= a[i];
    }

    zan.sort();

    foreach (i ; 0 .. t) {
        ans += zan[i];
    }

    writeln(ans);
}




void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 12604
A, B, C, X, Y = map(int, input().split())
ans = 0
if 2 * C < A + B:
    ans += min(X, Y) * 2 * C
    if X >= Y:
        ans += (X - Y) * min(A, 2 * C)
    else:
        ans += (Y - X) * min(B, 2 * C)
else:
    ans = X * A + Y * B
print(ans)


Measured memory_bytes: 9084
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace AtCoderABC113
{
    class City
    {
        public int num;
        public long id;
        public City(int n, long i)
        {
            num = n;
            id = i;
        }
    }
    class Program
    {
        public static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            int M = int.Parse(s[1]);
            List<City>[] P = new List<City>[N];
            for (int i = 0; i < N; i++) P[i] = new List<City>();
            for (int i = 0; i < M; i++)
            {
                s = Console.ReadLine().Split(' ');
                int p = int.Parse(s[0]);
                int y = int.Parse(s[1]);
                P[p - 1].Add(new City(i + 1, (long)y));
            }
            List<City> reslist = new List<City>();
            for (int i = 0; i < N; i++)
            {
                P[i] = P[i].OrderBy(x => x.id).ToList();
                for (int j = 0; j < P[i].Count; j++)
                {
                    P[i][j].id = (long)(i + 1) * 1000000 + j + 1;
                    reslist.Add(P[i][j]);
                }
            }
            reslist = reslist.OrderBy(x => x.num).ToList();
            for (int i = 0; i < M; i++)
            {
                Console.WriteLine(Convert.ToString(reslist[i].id, 10).PadLeft(12, '0'));
            }
        }
    }
}

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

#define ll long long

const int Nmax = 2e5 + 10;
int n, k, A[Nmax];

bool check(int x) {
  ll cnt = 0;
  for (int i = 0; i < n; ++i) {
    cnt += (A[i] + x - 1) / x - 1;
  }
  return cnt > k;
}

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

  cin >> n >> k;
  for (int i = 0; i < n; ++i)
    cin >> A[i];
  int l = 1, r = 1e9;
  while (l < r) {
    int mid = (l + r) >> 1;
    if (check(mid))
      l = mid + 1;
    else
      r = mid;
  }
  cout << l << endl;
  
  return 0;
}


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

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

using namespace std;
typedef long long unsigned int ll;

int main() {
  int H, W;
  cin >> H >> W;
  vector<string>  as;
  string a;
  for (int i = 0; i < H; ++i) {
    cin >> a;
    as.push_back(a);
  }

  vector<bool> col(H, false);
  vector<bool> row(W, false);

  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (as[i][j] == '#') {
	col[i] = true;
	row[j] = true;
      }
    }
  }

  for (int i = 0; i < H; ++i) {
    if (col[i]) {
      for (int j = 0; j < W; ++j) {
	if (row[j]) {
	  cout << as[i][j];
	}
      }
      cout << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#define ll long long
using namespace std;
const int maxn=500010,mod=1e9+7;
int n,m,x,y,z;
char s[maxn];
void read(int &k)
{
	int f=1;k=0;char c=getchar();
	while(c<'0'||c>'9')c=='-'&&(f=-1),c=getchar();
	while(c<='9'&&c>='0')k=k*10+c-'0',c=getchar();
	k*=f;
}
int main()
{
	scanf("%s",s+1);
	for(int i=1;i<=3;i++)
	if(s[i]!=s[3-i+1])return printf("No"),0;
	printf("Yes");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
using namespace std;
inline int read(){
	int v=0,f=1;
	char c=getchar();
	while (c<'0' || c>'9'){
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9'){
		v=v*10+c-'0';
		c=getchar();
	}
	return v*f;
}
int main(){
	LL N,A,B;
	cin>>N>>A>>B;
	if ((B-A)%2==0){
		printf("%lld\n",(B-A)/2);
		return 0;
	}
	LL T1=A+(B-A-1)/2;
	LL T2=(N-B+1)+(B-A-1)/2;
	printf("%lld\n",min(T1,T2));
	return 0;
}

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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m , q;

int a[N];
int b[N];
int c[N];
int d[N];

ll ans = 0;

vi v;

void fuck() {

    ll tmp = 0;
    for(int i = 1 ; i <= q ; i ++) {
            if(v[b[i]] - v[a[i]] == c[i]) {
                    tmp += 1ll * d[i];
            }
    }

    ans = max(ans , tmp);
}

void go(int i , int last) {
    if(i == n) {
            fuck();
            return;
    }

    for(int j = last ; j <= m ; j ++) {
            v.push_back(j);
            go(i + 1 , j);
            v.pop_back();
    }
}

void solve(int testCase){

    scanf("%d %d %d" , &n , &m , &q);

    for(int i = 1 ; i <= q ; i ++) {
            scanf("%d %d %d %d" , &a[i] , &b[i] , &c[i] , &d[i]);
    }

    v.push_back(0);

    go(0 , 1);
    printf("%lld\n" , ans);

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 3840
import sys
from collections import deque
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
s = [[_ for _ in S()] for _ in range(N)]

root = [[] for _ in range(N+1)]
for i in range(N):
  for j in range(N):
    if s[i][j] == "1":
      root[i + 1].append(j + 1)
      root[j + 1].append(i + 1)
      s[j][i] = "0"
#print(root)

ans = -1
for i in range(1, N+1):
  Vnum = [-1 for _ in range(N+1)]
  Vnum[i] = 1

  queue = deque([i])
  while queue:
    #print(queue)
    x = queue.popleft()
    for j in root[x]:
      if Vnum[j] == -1:
        Vnum[j] = Vnum[x] +1
        queue.append(j)
      else:
        if Vnum[j] == Vnum[x] or abs(Vnum[j] - Vnum[x]) > 1:
          break
    else:
      continue
    break
  else:
    ans = max(ans, max(Vnum))

print(ans)

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

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rbf(i, v) for (auto& (i) : (v))
#define All(x) (x).begin(),(x).end()
#define cAll(x) (x).cbegin(),(x).cend()
#define COL(x) cout << x << endl
#define CO(x) cout << x
//#define int long long

template<typename T> inline constexpr auto square(T x) { return (x) * (x); }

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

const int MOD = 1000000007;
const int INF = INT_MAX;

signed main()
{
	string S, T;
	cin >> S;
	cin >> T;

	int ans = 0;

	rep(i, 3) {
		if (S[i] == T[i]) ans++;
	}

	COL(ans);

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
    char c;
    while((c = getchar())!= EOF){
        if(isupper(c)){
            printf("%c", tolower(c));
        }else if(islower(c)){
            printf("%c", toupper(c));
        }else printf("%c", c);
    }
return 0;
}



Measured memory_bytes: 2052
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		
		if(a < 1200){
			System.out.println("ABC");
		}else{
			System.out.println("ARC");
		}
	}
}


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

using namespace std;

typedef long long ll;

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

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t;
    cin >> t;
    while (t--) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        if (b > d || a < b) {
            cout << "No\n";
        } else {
            ll x = a;
            if (x > c) {
                ll k = (x - c + b - 1) / b;
                x -= k * b;
            }
            if (x >= 0) {
                ll e = gcd(b, d);
                ll k = (c + 1 - x + e - 1) / e;
                x += k * e;
            }
            if (x < 0 || x > c && x < b) {
                cout << "No\n";
            } else {
                cout << "Yes\n";
            }
        }
    }
    return 0;
}


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

int main() {
    int t = 1;
    while(t--) {
        int n, x, T;
        cin>>n>>x>>T;
        cout<<T * (n/x) + ((n%x) ? T : 0)<<endl; 
    }
    return 0;
}

Measured memory_bytes: 3636
#import re
import sys
#import heapq
#import bisect
#from collections import deque
#import math

def main():
    k = int(input())
    s = input()
    if len(s) <= k:
        print(s)
    else:
        print(s[:k]+"...")
        
    
    


    
if __name__ == '__main__':
    main()


Measured memory_bytes: 61800
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int64_t dp[4097][1001];

constexpr auto inf = std::numeric_limits<int64_t>::max();

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int64_t> pat(m, 0);
    vector<int64_t> cost(m);

    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        cost[i] = a;

        for (int j = 0; j < b; j++)
        {
            int c;
            cin >> c;
            pat[i] |= (1 << (c - 1));
        }
    }

    int64_t accum_pat = 0;
    for (auto& p : pat)
    {
        accum_pat |= p;
    }
    if (accum_pat != (1 << n) - 1)
    {
        cout << -1 << endl;
    }
    else
    {
        for (int i = 0; i < (1 << n); i++)
        {
            for (int j = 0; j <= m; j++)
            {
                dp[i][j] = inf;
            }
        }
        dp[0][0] = 0;

        for (int64_t i = 1; i <= m; i++)
        {
            for (int64_t bm = 0; bm < (1 << n); bm++)
            {
                dp[bm][i] = min(dp[bm][i], dp[bm][i - 1]);
                if (dp[bm][i - 1] < inf)
                {
                    dp[bm | pat[i - 1]][i] = min(dp[bm | pat[i - 1]][i], dp[bm][i - 1] + cost[i - 1]);
                }
            }
        }
        cout << dp[(1 << n) - 1][m] << endl;
    }
}


Measured memory_bytes: 32256
// abc083-b
object Main extends App {
  val Array(n,a,b) = io.StdIn.readLine.split(" ").map(_.toInt)

  def str2digit_sum(str: String): Int = 
    str.map(_.asDigit).sum

  val filtered = (1 to n).filter { i =>
  val sum = str2digit_sum(i.toString)
  a <= sum && sum <= b
  }

  println(filtered.sum)
}

Measured memory_bytes: 55244
#include<stdio.h>
#include<string.h>
int main(){
	int a,b=0,i;
	char d[1001];
	scanf("%s",d);
	a=strlen(d);
	for(i=0;i<a;i++){
		b=d[i]-3;
		if(b<'A')b=b+26;
		d[i]=b;
	}
	printf("%s\n",d);
	return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void test_case()
{
	ll n,x,t;
	ll tmp1;
	cin>> n >> x >> t;
	tmp1 = n/x;
	if(n%x != 0)
		tmp1++;
	cout<<tmp1*t;
}

int main(){
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	int T = 1;
	// cin>>T;
	while(T--)
		test_case();

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    string s;
    cin >> s;

    if (n % 2) {
        cout << "No" << endl;
        return 0;
    }
    REP(i, n / 2) {
        if (s[i] != s[i + n / 2]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl;
#define INF 1ll<<60;
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; }

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

int main(){
    ll n, d; cin >> n >> d;

    ll cnt = 0;
    rep(i, n){
        ll x, y; cin >> x >> y;
        ll v=x*x+y*y;
        if(v<=(d*d)){
            cnt++;
        }
    }
    out(cnt);
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std ;
 
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;
 
const ll MOD = 998244353, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;
 
int dp[3005][3005] ;
string s, t ;
 
int check(int posN, int posM)
{
    if (posN == 0 or posM == 0)   return 0 ;
    if (dp[posN][posM] != -1)   return dp[posN][posM] ;
    if (s[posN - 1] == t[posM - 1]) {
        dp[posN][posM] = 1 + check(posN - 1, posM - 1) ;
    }
    else {
        dp[posN][posM] = max(check(posN - 1, posM), check(posN, posM - 1)) ;
    }
    return dp[posN][posM] ;
}
 
void print(int posN, int posM, int lcs)
{
    if (posN == 0 or posM == 0) return ;
    if (s[posN - 1] == t[posM - 1] and dp[posN][posM] == lcs) {
        print(posN - 1, posM - 1, lcs - 1) ;
        cout << s[posN - 1] ;
    }
    else {
        if (dp[posN - 1][posM] > dp[posN][posM - 1])  print(posN - 1, posM, lcs) ;
        else    print(posN, posM - 1, lcs) ;
    }
    return ;
}
 
int main()
{
    memset(dp, -1, sizeof dp) ;
    cin >> s >> t ;
    int n = s.size(), m = t.size(), x ;
    x = check(n, m) ;
    print(n, m, x) ;
 
    return 0 ;
}

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

# define ll long long

int ar[100000][3];
int dp[100000][3];
int main()
{
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin >> ar[i][j];
        }
    }
    dp[0][0]=ar[0][0];
    dp[0][1]=ar[0][1];
    dp[0][2]=ar[0][2];

    for(int day=1;day<n;day++){
        dp[day][0] = ar[day][0] + max ( dp[day-1][1] , dp[day-1][2]);
        dp[day][1] = ar[day][1] + max ( dp[day-1][0] , dp[day-1][2]);
        dp[day][2] = ar[day][2] + max ( dp[day-1][1] , dp[day-1][0]);
    }
    int jawab = max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
    cout << jawab << endl;

}


Measured memory_bytes: 5948