akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll INF = 1e18;
int N, M;
ll d[1005];
bool Negative[1005];
struct edge {int from, to; ll cost;};
edge es[2005];

void shortest_path(int s){
  rep(i, N) d[i] = INF;
  d[s] = 0ll;
  rep(j, N-1) {
    rep(i, M) {
      edge e = es[i];
      if(d[e.from] != INF && d[e.to] > d[e.from]+e.cost){
        d[e.to] = d[e.from] + e.cost;
      }
    }
  }
}

void find_negative_loop(){
  memset(Negative, false, sizeof(Negative));
  rep(i, N){
    rep(j, M){
      edge e =es[j];
      if (d[e.from] == INF) continue;
      if (d[e.to] > d[e.from] + e.cost) {
        d[e.to] = d[e.from] + e.cost;
        Negative[e.to] = true;
      }
      if (Negative[e.from]) Negative[e.to] = true;
    }
  }
}

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

  cin >> N >> M;
  int a,b; ll c;
  rep(i,M) {
    cin >> a >> b >> c;
    a--;b--;
    edge e = {a,b,-c};
    es[i] = e;
  }
  shortest_path(0);
  find_negative_loop();
  if (Negative[N-1]) {
    cout << "inf" << "\n";
    return 0;
  }
  cout << -d[N-1] << "\n";
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define ll long long int
#define tc int t; cin>>t; while(t--)
#define fora(i,n) for(int i=0;i<n;i++)
#define forb(i,a,n) for(int i=a;i<n;i++)
#define dbg(x)    { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y)  { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define mod 1000000007
#define pb push_back
#define pii pair<int,int>
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
template<class T> T power(T N,T P){ return (P==0)?  1: N*power(N,P-1);}
void solve() {
  int n,k;
  cin>>n>>k;
  int h[n];
  fora(i,n) cin>>h[i];
  int dp[n];
  for(auto &it:dp) it=INT_MAX;
  dp[0]=0;
  for(int i=1;i<n;i++) {
      for(int j=i-1;j>=max(0,i-k);j--) {
        dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
      }
  }
  // for(auto it:dp) cout<<it<<" ";
  // cout<<"\n";
  cout<<dp[n-1];


}
int32_t main()
{
    fastio
    solve();   
    

    return 0;


}

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

const int mod = 1e9 + 7;
int n, k, fp;
long long ii;

int fi(long long i) {
	return (i * (i + 1) / 2) % mod;
}

int li(long long i) {
	return (fi(n + 1) - fi(n + 1 - i)) % mod;
}


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> k;
	for(int i = 1; i <= n + 1; ++i) {
		ii = li(i) - fi(i) + 1;
		if(ii >= mod) ii -= mod;
		if(ii < 0) ii += mod;
		if(i >= k) (fp += ii) %= mod;
	}
	cout << fp << endl;
	return 0;
}


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

int main()
{
    int N, cut;
    long long int L, prev, curr;
    bool poss=false;
    cin>>N>>L;
    for(int i=0; i<N; i++)
    {
        cin>>curr;
        if(i==0) prev=curr;
        else
        {
            if(prev+curr>=L)
            {
                cut=i;
                poss=true;
            }
        }
        prev=curr;
    }
    if(poss==false) cout<<"Impossible"<<endl;
    else
    {
        cout<<"Possible"<<endl;
        for(int i=1; i<cut; i++) cout<<i<<endl;
        for(int i=N-1; i>cut; i--) cout<<i<<endl;
        cout<<cut<<endl;
    }
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int N,M,Q;
vector<int> a,b,c,d;


int dfs(vector<int> A){
    if(A.size()==N){
        //得点計算
        int res = 0;
        rep(i,Q){
            if((A.at(b.at(i))-A.at(a.at(i)))==c.at(i)) res += d.at(i);
        }
        return res;
    }

    int prev_last = (A.empty() ? 1 : A.back());
    int ans = 0;
    for(int i = prev_last; i <= M; i++){
        A.push_back(i);
        ans = max(ans,dfs(A));
        A.pop_back();
    }
    return ans;
}

int main(){
    cin>>N>>M>>Q;
    a.resize(Q);
    b.resize(Q);
    c.resize(Q);
    d.resize(Q);
    rep(i,Q){
      cin>>a.at(i)>>b.at(i)>>c.at(i)>>d.at(i);
      --a.at(i), --b.at(i);  
    }
    vector<int> A;
    cout << dfs(A) <<endl;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
using Graph = vector<vector<int>>;



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

    string S;
    cin>>S;
    
    auto sa=suffix_array(S);

    int ans=S.size()*(S.size()+1)/2;
    for(auto v:lcp_array(S,sa)){
        ans-=v;
    }
    cout<<ans<<endl;



}


Measured memory_bytes: 15604
/*
ID: dorijan1
TASK: tu napisi ime zadatka molim te molim te ali samo ako si na usaco training
LANG: C++11
*/
#include <bits/stdc++.h>

using namespace std;

const int MOD=1000000007;
typedef long long int ll;
const ll LLINF=1ll<<60;
const char en='\n';

void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}

ll raand()
{
   return rand()*RAND_MAX+rand();
}

ll sti(string a)
{
	ll k=0;
	for (int i=0;i<a.size();++i)
	{
		k*=10;
		k+=a[i]-'0';
	}
	return k;
}

string its(ll k)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%10)+'0');
		k/=10;
	}
	reverse(a.begin(),a.end());
	return a;
}

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

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

ll mult(ll a,ll b)
{
	return (a*b)%MOD;
}

ll pot(ll n,ll k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

ll divide(ll a,ll b)
{
	return mult(a,pot(b,MOD-2));
}

ll sub(ll a,ll b)
{
	return (a-b+MOD)%MOD;
}

ll add(ll a,ll b)
{
	return (a+b)%MOD;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

int n;
ll dp[200001];
int h[200001];

ll dp1(int i)
{
	if (i==0)
	{
		if (h[i]!=0)
		{
			cout<<-1<<endl;
			exit(0);
		}
		else
		{
			return dp[i]=0;
		}
	}
	if (h[i]>h[i-1]+1)
	{
		cout<<-1<<endl;
		exit(0);
	}
	if (h[i]==h[i-1]+1) return dp[i]=dp1(i-1)+1;
	else return dp[i]=dp1(i-1)+h[i];
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin>>n;
	for (int i=0;i<n;++i) cin>>h[i];
	cout<<dp1(n-1)<<endl;
}



Measured memory_bytes: 5760
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
template<typename T> inline void add(T& a, T b) { a += b; if (a >= MOD) a -= MOD; }
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  long double r;
  cin >> r;
  long double ans = r * (long double)2 * 3.14159265358979323846;
  cout << std::fixed << std::setprecision(20) << ans << endl;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
int main () {
  char c;
  cin >> c;
  string ans = "consonant";
  string A = "aiueo";
  for(char a: A) {
    if(a == c) {
      ans = "vowel";
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<iomanip>
using namespace std;
static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;
 
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
 
class Point{
	public:
		double x, y;
 
		Point(double x = 0, double y = 0): x(x), y(y) {}
 
		Point operator + (Point p){ return Point(x + p.x, y + p.y);}
		Point operator - (Point p){ return Point(x - p.x, y - p.y);}
		Point operator * (double a){ return Point(a * x, a * y);}
		Point operator / (double a){ return Point(x / a, y / a);}
 
		double abs(){ return sqrt(norm());}
		double norm(){ return x * x + y * y;}
 
		bool operator < (const Point &p) const{
			return x != p.x ? x < p.x : y < p.y;
		}
 
		bool operator == (const Point &p) const{
			return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
		}
};
typedef Point Vector;
typedef vector<Point> Polygon;
double dot(Vector a, Vector b){
	return a.x * b.x + a.y * b.y;
}
double cross(Vector a, Vector b){
	return a.x * b.y - a.y * b.x;
}
int ccw(Point p0, Point p1, Point p2){
	Vector a = p1 - p0;
	Vector b = p2 - p0;
	if(cross(a, b) > EPS) return COUNTER_CLOCKWISE;
	if(cross(a, b) < -EPS) return CLOCKWISE;
	if(dot(a, b) < -EPS) return ONLINE_BACK;
	if(a.norm() < b.norm()) return ONLINE_FRONT;
 
	return ON_SEGMENT;
}

int main(){
	int n;
	cin >> n;
	Polygon p(n);
	for(int i = 0; i < n; i++) cin >> p[i].x >> p[i].y;
	for(int i = 0; i < n; i++){
		int num = ccw(p[(i + 1) % n], p[i], p[(i + 2) % n]);
		if(num == COUNTER_CLOCKWISE){
			cout << 0 << endl;
			return 0;
		}
	}
	cout << 1 << endl;
	return 0;
}



Measured memory_bytes: 3232
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

vector<bool> used;
vector<vector<bool> > map(51, vector<bool>(51, false));

void search(int s, int n){
	if(used[s]) return;
	used[s] = true;
	for(int i=1; i<=n; i++){
		if(map[s][i]){
			search(i, n);
		}
	}
}

int main(){
	int n,m;
	cin >> n >> m;
	
	vector<int> a(m),b(m);
	for(int i=0; i<m; i++){
		cin >> a[i] >> b[i];
		map[a[i]][b[i]] = map[b[i]][a[i]] = true;
	}
	
	int count = 0;
	for(int i=0; i<m; i++){
		vector<bool> u(n+1, false);
		used = u;
		map[a[i]][b[i]] = map[b[i]][a[i]] = false;
		bool bridge = false;
		search(1,n);
		for(int j=1; j<=n; j++){
			if(!used[j]) bridge = true;
		}
		if(bridge){
			count++;
		}
		map[a[i]][b[i]] = map[b[i]][a[i]] = true;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
//#define int long long
#define all(vec) vec.begin(), vec.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl
#define isEven(t) t % 2 == 0

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

//各位の和を返す
int GetDigitsSum(int num)
{
	int N = 0;
	while (num > 0)
	{
		N += num % 10;
		num /= 10;
	}
	return N;
}

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

	int N, A, B;
	cin>>N>>A>>B;
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if(A<=GetDigitsSum(i)&&GetDigitsSum(i)<=B){
			ans += i;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
function Main(input) {
	input = input.trim();
	input = input.split("\n");

	var shurui = input[0];
	var ryori = input[1].split(" ");
	var manzoku = input[2].split(" ");
	var manzoku_plus = input[3].split(" ");

	var manzoku_sum = 0;
	var ryori_order = 0;
	var ryori_order_back = 0;
	for (var i = 0; i < ryori.length; i++) {

		ryori_order = Number(ryori[i]);
		manzoku_sum += Number(manzoku[ryori_order - 1]);

		if (i > 0 && ryori_order_back + 1 == ryori_order) {
			manzoku_sum += Number(manzoku_plus[ryori_order_back - 1]);
		}
		ryori_order_back = ryori_order;
		
	}

	console.log(manzoku_sum);
	
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<stdio.h>

static const int N = 1000;

int gcd(int x, int y){
  return y?gcd(y,x%y):x;
}

int main(){
  int a, b;

  scanf("%d %d", &a, &b);
  printf("%d\n", gcd(a,b));

  return 0;
}

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

int main() {

  int d;
  int t;
  int s;

  cin >> d;
  cin >> t;
  cin >> s;

  int c = t*s ;

  if (c < d) {
    cout << "No";
  }

 else{cout << "Yes";}

    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
int main(){
  int n, S[10000], q, T[500], i, j, cnt = 0;

  scanf("%d", &n);
  for(i = 0; i < n; i++)
    scanf("%d", &S[i]);

  scanf("%d", &q);
  for(j = 0; j < q; j++)
    scanf("%d", &T[j]);



  for(i = 0; i < q; i++)
    for(j = 0; j < n; j++)
      if(T[i] == S[j])   {
    cnt++;
    break;
      }

  printf("%d\n", cnt);
  return 0;
}

Measured memory_bytes: 2756
N,K,Q = map(int,input().split())
A = [int(input()) for x in range(Q)]
ans = [K - Q] * N


for j in range(Q):
  ans[A[j] - 1] += 1
  
for i in range(N):
  print('Yes' if ans[i] > 0 else 'No')

Measured memory_bytes: 10472
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <algorithm> 
#include <set>
#include <sstream>
#include <bit>
#include <bitset>
#include <iomanip>
#include <queue>
typedef long long int ll;
using namespace std;
int main() {
	int A, B; cin >> A >> B;
	int temp = 0;
	int tax1, tax2;
	while (true) {
		tax1 = (int)temp * 0.08;
		tax2 = (int)temp * 0.1;
		if (tax1 == A && tax2 == B) {
			cout << temp << endl;
			break;
		}
		if (temp > 1000) {
			cout << "-1" << endl;
			break;
		}
		temp++;
	}
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    char S[1331];
    Scs(S);
    int n  = 0;
    for( int i = 0; S[i]; i++ ) {
        if( S[i] != '/' ){
            n *= 10;
            n += S[i]-'0';
        }
    }

    printf (n>20190430 ? "TBD\n" : "Heisei\n");

    return 0;
}



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

long long a[100000] = {};

int aaa(const void *x, const void *y)
{
	long*X = (long *)x;
	long*Y = (long *)y;
	if (*X > *Y) return 1;
	if (*X < *Y) return -1;
	return 0;
}

int main()
{
	long n,i;
	long long ans = 0;
	int j = 1;
	scanf("%ld", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%lld", &a[i]);
	}
	qsort(a, n, sizeof(long long), aaa);
	for (i = 0; i < n; i++)
	{
		if (a[i] == a[i + 1])
		{
			j++;
		}
		else
		{
			if (j % 2 != 0)
			{
				ans++;
			}
			j = 1;
		}
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 1788
A=int(input())
B=int(input())
C=int(input())
X=int(input())

count=0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i+100*j+50*k==X:
                count+=1
            else:
                pass
print(count)
                



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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    int n = s.size(), m = t.size();
    int st = -1;
    for(int i=0; i+m-1<n; i++) {
        int idx = i;
        bool valid = true;
        for(int j=0; j<m; j++) {
            if(s[idx] == t[j] || s[idx] == '?') {
                idx++;
            } else {
                valid = false;
                break;
            }
        }
        if(valid) {
            st = i;
        }
    }
    if(st == -1) {
        cout<<"UNRESTORABLE\n";
        return 0;
    }

    string tmp = "";
    for(int i=0; i<n; i++) {
        if(i == st) {
            tmp += t;
            i+=m-1;
        } else {
            if(s[i] != '?') tmp += s[i];
            else tmp += 'a';
        }
    }
    cout<<tmp<<"\n";
    return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		int N=in.nextInt();
		while(N-->0)
		{
			int m=in.nextInt();
			int n=in.nextInt();
			Ginko gi=new Ginko(m, n);
			
			boolean flg=true;
			for(int i=0;i<150;i++)
			{
				for(int j=0;j<150;j++)
				{
					if(i*i+j*j>gi.m*gi.m+gi.n*gi.n || i*i+j*j==0)
						continue;
					
					if(check(i, j, gi)||check(i, -j, gi)||check(-i, j, gi)||check(-i, -j, gi))
					{
						flg=false;
						break;
					}
				}
				if(!flg)
					break;
			}
			System.out.println(flg ? "P":"C");
		}
	}
	static boolean check(int m, int n, Ginko in)
	{
		if(m==1&&n==0||
			m==0&&n==1||
			m==-1&&n==0||
			m==0&&n==-1||
			m==in.m&&n==in.n||
			m==-in.n&&n==in.m||
			m==-in.m&&n==-in.n||
			m==in.n&&n==-in.m)
			return false;
		int a=m*in.m+n*in.n;
		int b=m*in.n-n*in.m;
		int mn=m*m+n*n;
		
		if(a%mn==0&&b%mn==0)
			return true;
		else
			return false;
	}
}

class Ginko
{
	int m;
	int n;
	Ginko(int m, int n)
	{
		this.m=m;
		this.n=n;
	}
}

Measured memory_bytes: 18812
//
//  main.cpp
//  TTTTT
//
//  Created by cfhaiteeh on 2018/4/14.
//  Copyright © 2018 cfhaiteeh. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#define INF 1e9+10
#define  LL long long
using namespace std;
const int maxn=123456;
int ai[maxn];
int n;
void init(){
    for(int i=1;i<=n;i++)scanf("%d",&ai[i]);
}
int a,b;
bool vis[maxn];
void play(){
    int MAX=-1;
    memset(vis,0,sizeof(vis));
    int index=-1;
    for(int i=1;i<=n;i++){
        if(ai[i]>MAX){
            MAX=ai[i];
            index=i;
        }
    }
    vis[index]=1;
    int mid1=MAX/2;
    int MIN=INF;
    int T=0;
    for(int i=1;i<=n;i++){
        if(vis[i])continue;
        if(MIN>abs(ai[i]-mid1)){
            MIN=abs(ai[i]-mid1);
            T=ai[i];
        }
    }
    if(MAX%2==0){
        a=MAX;
        b=T;
        return;
    }
    mid1=MAX/2+1;
    int T2=0;
    int MIN2=INF;
    for(int i=1;i<=n;i++){
        if(vis[i])continue;
        if(MIN2>abs(ai[i]-mid1)){
            MIN2=abs(ai[i]-mid1);
            T2=ai[i];
        }
    }
    if(MIN<MIN2){
        a=MAX;
        b=T;
    }
    else{
        a=MAX;
        b=T2;
    }
    
}
void pri(){
    printf("%d %d\n",a,b);
}
int main() {
    // insert code here...
    while(scanf("%d",&n)!=EOF){
        init();
        play();
        pri();
    }
    return 0;
}


Measured memory_bytes: 768
#include <stdio.h>

int main()
{
    int n;
    char s[101] = {0};

    if(scanf("%d", &n) != 1){
        return 0;
    }
    if(scanf("%s", s) != 1){
        return 0;
    }
    
    int red = 0;
    for(int i = 0; i < n ; i++){
        if(s[i] == 'R'){
            red++;
        } 
    }

    printf("%s\n", red > n - red ? "Yes" : "No");

    return 0;
}




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

int main() {
  int max = 0, sum = 0, price, n;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> price;
    sum += price;
    if(max < price) max = price;
  }
  sum -= max / 2;
  cout << sum;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n; cin >> n;
  string last; cin >> last;
  unordered_set<string> s;
  s.insert(last);
  bool w = true;
  for (int i = 1; i < n; ++i) {
    string cur; cin >> cur;
    if (s.find(cur) != s.end()) {
      w = false;
    }
    if (cur[0] != last[last.length()-1]) w = false;
    s.insert(cur);
    last = cur;
  }
  cout << (w ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    n=abs(n)
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return set(divisors)

def main():
  n,m=map(int,input().split())
  x=list(map(int,input().split()))
  s=make_divisors(x[0]-m)
  news=[]
  for i in range(1,n):
    d=x[i]-x[i-1]
    news=[]
    for j in s:
      if d%j==0:
        news.append(j)
    s=set(news)
  print(max(s))
  
main()

Measured memory_bytes: 14480
using System;
using System.Linq;
using System.Collections.Generic;
class Addition
{
    static void Main()
    {
        Console.ReadLine();
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int oddcount = a.Count(x => x % 2 == 1);
        if (oddcount % 2 == 0)
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }
    }
}

Measured memory_bytes: 21728
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
ll D;
ll c[26];
ll s[366][26];
ll t[366];

//スコア計算
ll score(ll days){
	ll ans=0;
	ll last[26];
	rep(i,26)last[i]=0;
	for(ll d=1;d<=days;d++){
		ans+=s[d][t[d]];
		last[t[d]]=d;
		rep(i,26){
			ans-=c[i]*(d-last[i]);
		}
	}
	return ans;
}

ll whole_score;
ll score_typ[26];
void recalc(ll i){
	ll ans=0;
	ll last=0;
	for(ll d=1;d<=D;d++){
		if(t[d]==i){
			ans+=s[d][i];
			last=d;
		}
		ans-=c[i]*(d-last);
	}
	whole_score-=score_typ[i];
	score_typ[i]=ans;
	whole_score+=score_typ[i];
}
void change(ll d,ll q){
	ll b=t[d];
	t[d]=q;
	recalc(b);
	recalc(q);
}
void init_score(){
	whole_score=0;
	rep(i,26){
		score_typ[i]=0;
		recalc(i);
	}
}

//貪欲法
void greedy(){
	for(ll d=1;d<=D;d++){
		ll ma=-1e17,pt=0;
		rep(i,26){
			t[d]=i;
			ll res=score(d);
			if(ma<res){
				ma=res;
				pt=i;
			}
		}
		t[d]=pt;
	}
}

//局所探索_改
void local_search(){
	rep(u,50000){//日付を一つ選んで、コンテストを変更
		ll d=rand()%D+1;
		ll q=rand()%26;
		ll b=t[d];
		ll bef_score=whole_score;
		change(d,q);
		ll aft_score=whole_score;
		if(bef_score>aft_score){
			change(d,b);
		}
	}
	rep(u,50000){//日付を二つ選んで、コンテストをswap
		ll bef_score=whole_score;
		ll d1,d2;
		do{
			d1=rand()%D+1;
			d2=rand()%D+1;
		}while(d1==d2);
		ll p=t[d1],q=t[d2];
		change(d1,q);
		change(d2,p);
		ll aft_score=whole_score;
		if(bef_score>aft_score){
			change(d1,p);
			change(d2,q);
		}
	}
}


int main(){
	cin>>D;
	rep(i,26)cin>>c[i];
	for(ll d=1;d<=D;d++)rep(j,26)cin>>s[d][j];
	greedy();
	init_score();
	local_search();
	for(ll d=1;d<=D;d++){
		cout<<t[d]+1<<"\n";
	}
}


Measured memory_bytes: 3716
n = input()
keta = len(n)
N = int(n)
#print(keta)                                                                   
k = 0

if keta == 1:
    k = N
elif keta % 2 == 0:
    for i in range(keta):
        if (i+1) % 2 == 0:
            continue
        k += 9*(10**i)
    #print(int(n[0]))                                                          
else:
    for i in range(keta-1):
#        print("i = {}".format(i+1))                                           
        if (i+1) % 2 == 0:
            continue
        k += 9*(10**i)
#        print(k)                                                              
    minus = (10**(keta-1))
 #   print(minus)                                                              
    k += (N-minus+1)
print(k)



Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    long long n;
    long long k;
    long long q;

    long long* a;
    long long* ans;
    
 

    cin >> n;
    cin >> k;
    cin >> q;
    a = new long long[q];
    ans = new long long[n];

    for (long long i = 0; i < q; i++) {
        cin >> a[i];
    }
    for (long long i = 0; i < n; i++) {
        ans[i]=0;
    }


    for (long long i = 0; i < q; i++) {
        ans[a[i]-1]++;
    }
    for (long long i = 0; i < n; i++) {
        if (q - ans[i] >= (long long)k) {
            cout << "No" << endl;
        }
        else {
            cout << "Yes" << endl;
        }
    }

    delete[] a;
    delete[] ans;
    return 0;
}

Measured memory_bytes: 2176
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define d(...) 2;
#endif

#define int long long int

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define eps 1e-10

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();
const int N=1e6+10;
int f[N];

int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif 

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j;

	int n,q;
	cin>>n;
	vector<int>a(n);

	int sum=0;



	for(i=0;i<n;i++)
	{
		cin>>a[i];
		f[a[i]]++;
		sum+=a[i];
	}

	cin>>q;

	while(q--)
	{
		cin>>i>>j;
		sum-=f[i]*i;
		d(sum);
		f[j]+=f[i];
		sum+=f[i]*j;
		f[i]=0;

		cout<<sum<<endl;
	}
	

}

Measured memory_bytes: 4732
import sys

# import bisect
# import numpy as np
from collections import deque
# map(int, sys.stdin.read().split())
# import heapq
# import bisect
# import math

from collections import Counter


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    A = []
    for i in range(N):
        S = input()
        A.append(S)
    c = Counter(A)
    maxc = max(c, key=c.get)
    maxc = max(c.values())
    aa = []
    for key, val in c.items():
        if val ==maxc:
            aa.append(key)
    aa.sort()
    print("\n".join(aa))

if __name__ == "__main__":
    main()


Measured memory_bytes: 38788
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main()
{
  int H, N, A = 0;
  
  cin >> H;
  cin >> N;
  
  int bufA;
  for(int i=0; i < N; i++)
  {
    cin >> bufA;
    A += bufA;
  }
  
  if((H - A) <= 0 )
    cout << "Yes";
  else
    cout << "No";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    cout << s.substr(0, 3) << newl;
}

Measured memory_bytes: 3652
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int D = scan.nextInt();
        int count = 0;
        for(int i = 0; i < N; i++){
            int x = scan.nextInt();
            int y = scan.nextInt();
            double d = (Math.pow(x, 2) + Math.pow(y, 2));
            if(Math.pow(D, 2) >= d) count++;
        }
        System.out.println(count);
    }
}


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

#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;

#define CINT cpp_int 

int main() {
	int n; cin >> n; CINT a, b; 
	CINT REF = pow(CINT(10), 80);
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		if (a + b >= REF) cout << "overflow" << endl;
		else cout << a + b << endl;
	}
	return 0;
}


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

using namespace std;

int main()
{
    int N,X;
    while(cin>>N>>X)
    {
        int i,L[105];
        for(i=0;i<N;i++)
            cin>>L[i];
        int D[1000]={0};
        for(i=1;i<=N;i++)
            D[i]=D[i-1]+L[i-1];
            int sum=0;
        for(i=0;i<N+1;i++)
        {
            if(D[i]<=X)
                sum++;
        }
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoderPractice
{
    class OneQuadrillionAndOneDalmatians
    {
        static void Main(string[] args)
        {
            ulong n = ulong.Parse(Console.ReadLine());
            n -= 1;
            string name = "";
            char[] az = new char[]
            {
                'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
            };
            while(n > 25)
            {
                name += az[n % 26];
                n /= 26;
                n--;
                //Console.WriteLine(n);
            }
            name += az[n];
            Console.WriteLine(string.Concat(name.Reverse()));
        }
    }
}


Measured memory_bytes: 28148
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const int Inf = 1e9;
const ll INF = 9223372036854775807;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int dp[100010][4];
int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    vector<int> b(N);
    vector<int> c(N);
    for(int i = 0;i < N;i++) {
        int A,B,C;
        cin >> A >> B >> C;
        a.at(i) = A;
        b.at(i) = B;
        c.at(i) = C;
    }
    dp[0][0] = 0;
    dp[0][1] = 0;
    dp[0][2] = 0;
    dp[0][3] = 0;
    for(int i = 0;i < N;i++) {
        dp[i + 1][1] = max(dp[i][2],dp[i][3]) + a.at(i);
        dp[i + 1][2] = max(dp[i][1],dp[i][3]) + b.at(i);
        dp[i + 1][3] = max(dp[i][1],dp[i][2]) + c.at(i);
    }
    cout << max(dp[N][1],max(dp[N][2],dp[N][3])) << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> num(N);
  int counter = 0;
  
  for(int i = 0; i < N; i++) {
    cin >> num.at(i);
  }
  
  while(true) {
    bool odd = false;
    
    for(int i = 0; i < N; i++) {
      if(num.at(i) % 2 != 0) {
        odd = true;
      }
    }
    
    if(odd) break;
    
    for(int i = 0; i < N; i++) {
      num.at(i) /= 2;
    }
    counter++;
  }
  cout << counter << endl;
}

Measured memory_bytes: 256
N = int(input())
a_list = []
for i in range(N):
    a_list.append(int(input()))

first = 0
second = 0
for a in a_list:
    if a >= first:
        second = first
        first = a
    else:
        if a>= second:
            second = a

for a in a_list:
    if a == first:
        print(second)
    else:
        print(first)

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

#include <set>
#include <map>
#include <iomanip>

using namespace std;

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

using ll = long long;

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

	string S;
	cin >> S;

	rep(i, S.size())
	{
		S[i] = (S[i] - 'A' + N) % 26 + 'A';
	}

	cout << S << endl;

	return 0;
}

Measured memory_bytes: 256
from collections import Counter, deque, defaultdict
n, k = map(int, input().split())
A = list(map(int, input().split()))
t = defaultdict(int)
for x in A:
    t[x]+=1
B = list(t.values())
B.sort()
if(len(B)<=k):
    print(0)
    exit()

ans = sum(B[:len(B)-k])
print(ans)


Measured memory_bytes: 35300
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

N = int(input())
A = list(map(int, input().split()))

# 全部の数値の最小公倍数-1が、f(x)のxなのでは？
from fractions import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

l = 1
for a in A:
    l = lcm(l, a)

l -= 1

ans = 0
for a in A:
    ans += (l % a)

print(ans)

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

using namespace std;


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

    vector<int> a(n+1, 0);
    for(int i = 1; i <= n; i++){
        cin >>a[i];
    }

    vector<int> ball;
    vector<int> current(n+1, 0);
    vector<vector<int> > utuwa(n+1, vector<int>());
    for(int i = 1; i <= n; i++){
        for(int j = i; j <= n; j += i){
            utuwa[j].push_back(i);
        }
    }

    for(int i = n; i > 0; i--){
        if(current[i] % 2 != a[i]){
            ball.push_back(i);
            for(int j = 0; j < utuwa[i].size(); j++){
                current[utuwa[i][j]]++;
            }
        }
    }

    sort(ball.begin(), ball.end());
    printf("%d\n", ball.size());
    bool first = true;
    for(int i = 0; i < ball.size(); i++){
        if(first){
            first = false;
            printf("%d", ball[i]);
        }else{
            printf(" %d", ball[i]);
        }
    }
    if(ball.size() > 0){
        printf("\n");
    }

    return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N)cin >> A[i];
    ll M = 0,dai = 0;
    rep(i,N){
        if(A[i]<M)dai += M - A[i];
        M = max(M,A[i]);
    }
    cout << dai << endl;

}

Measured memory_bytes: 4756
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
A = list(map(int, input().split()))

cnt = 0
for i, a in enu(A):
    if (i+1)%2 == 1 and a%2 == 1:
        cnt += 1
print(cnt)


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

int H,W;
int F[53][53] = {{0}};
int dx[8] = {-1,-1,-1,1,1,1,0,0}, dy[8] = {1,0,-1,1,0,-1,1,-1};
char S[53][53];
int main(){
	cin >> H >> W;
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			cin >> S[i][j];
			if(S[i][j]=='#'){
				for(int k=0;k<8;k++){
					F[i+dx[k]][j+dy[k]]++;
				}
			}
		}
	}
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			if(S[i][j]=='#') cout << S[i][j];
			else cout << F[i][j];
			if(j==W) cout << endl;
		}
	}
}

Measured memory_bytes: 256
from sys import stdin
import math
import fractions
from collections import deque

INF = 10 ** 10

N, K = [int(x) for x in stdin.readline().rstrip().split()]
h = [int(x) for x in stdin.readline().rstrip().split()]

# add dummy
h = h + [INF, INF, INF]

# 足場iにいるときの最小コスト
dp = [INF] * (N+10)
dp[0] = 0

for i in range(N):
    for j in range(i+1, i+K+1):
        if j > N-1:
            break
        dp[j] = min(dp[j], abs(h[i] - h[j])+dp[i])

print(dp[N-1])

Measured memory_bytes: 79028
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int x = sc.nextInt();
        for (int i = x - k + 1; i < x + k - 1; i++) {
            System.out.print(i + " ");
        }
        System.out.println(x + k - 1);
    }
}


Measured memory_bytes: 23252
k=int(input())
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[k-1])


Measured memory_bytes: 2940
n,y = map(int,input().split())
for i in range(n+1):
    for j in range(n-i+1):
        if i*10000 + j*5000 + (n-i-j)*1000 == y:
            print(i,j,n-i-j)
            exit()
print("-1 -1 -1")


Measured memory_bytes: 2940
import sys
N,M=map(int,input().split())
A=[list(map(int,input().split())) for i in range(N)]
A=sorted(A,key=lambda x:x[0])
cost=0
num=0
for i in range(N):
    if num+A[i][1]>M:
        print(cost+A[i][0]*(M-num))
        sys.exit()
    else:
        cost+=A[i][0]*A[i][1]
        num+=A[i][1]
print(cost)

Measured memory_bytes: 29436
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
#define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >>(x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define says(x) cout<<(x)<<(' ');
#define sas cout<<(' ');
#define sayR(x) cout<<fixed<<setprecision(10)<<(x);
#define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=1000000007;
ll INF=100000000000001;
vector<ll> value; // ノードの値を持つ配列
ll N;             // 葉の数
 
void update(ll i, ll x) {
    // i 番目の葉の値を x に変える
    i += N - 1; // i 番目の葉のノード番号
    value[i] = x;
    while (i > 0) {
        i = (i - 1) / 2; // ノード i の親ノードの番号に変える
        value[i] = min(value[i * 2 + 1],
                       value[i * 2 + 2]); // 左右の子の min を計算しなおす
    }
}
 
ll query(ll a, ll b, ll k, ll l, ll r) {
    // [a, b) の区間に対するクエリについて
    // ノード k （区間 [l, r) 担当）が答える
    if (r <= a || b <= l) return INF; // 区間が被らない場合は INF を返す
    if (a <= l && r <= b)
        return value[k]; // ノード k の担当範囲がクエリ区間 [a, b)
                         // に完全に含まれる
    else {
        ll c1 = query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子に値を聞く
        ll c2 = query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子に値を聞く
        return min(c1, c2); // 左右の子の値の min を取る
    }
}
signed main(){
    llin(n);
    vllin(a,n);
    ll r=0;
    ll b=0;
    ll g=0;
    ll k=1;
    FOR(i,0,n-1){
        k=(k*((r==a[i])+(b==a[i])+(g==a[i])))%MOD;
        if(r==a[i]) r++;
        else if(b==a[i]) b++;
        else if(g==a[i]) g++;
    }
    sal(k)
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;
typedef vector< int > vi;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< ll > vll;
// #define DEBUG_MODE
#ifdef DEBUG_MODE
	#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
	#define debug(...)
#endif

char s[100010];
int main () { 
#ifdef DEBUG_MODE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%s", s);
	int n = strlen(s);
	int a1 = 0, a2 = 0;
	
	for (int i = 0; i < n; i++) {
		if (i & 1) { if (s[i] == '1') a1++; }
		else { if (s[i] == '0') a1++; }
	}

	for (int i = 0; i < n; i++) {
		if (i & 1) { if (s[i] == '0') a2++; }
		else { if(s[i] == '1') a2++; }
	}
	printf("%d\n", min(a1, a2));

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}

int main(){
    ios::sync_with_stdio(false);
    int a,b; cin >> a >> b;
    int n=b-a;
    int height[1000]={};
    for(int i=1;i<1000;i++){
        height[i]+=height[i-1]+i;
    }
    cout << height[n]-b << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

int main(){
	IO_STREAM;
	string S;	cin>>S;
	rep(i,0,S.size()){
		if(S[i]=='1') S[i]='9';
		else if(S[i]=='9') S[i]='1';
	}
	cout<<S<<endl;
	return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define int int64_t
using namespace std;

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

    double pi = 3.1415926535897;
    int r;
    cin >> r;
    cout << fixed << setprecision(2) << (2*pi*r) << "\n";

    return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
typedef long long ll;

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

	ll q, ans = 0;cin >> q;
	priority_queue<ll> small;
	priority_queue<ll, vector<ll>, greater<ll>> large;
	REP(_, q){
		ll type;cin >> type;
		if(type == 1){
			ll a, b;cin >> a >> b;
			ans += b;
			small.push(a);
			large.push(a);
			ll aa = small.top();small.pop();
			ll bb = large.top();large.pop();
			if(aa > bb){
				ans += aa - bb;
				swap(aa, bb);
			}
			small.push(aa);
			large.push(bb);
		}
		else {
			cout << small.top() << " " << ans << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 4588
#include <iostream>
#include <string>
using namespace std;
int main() {
    string s, t;
    cin >> s >> t;
    int sl=s.length();
    for(int i=0; i<sl; i++) {
        s = s[sl-1] + s.substr(0, sl-1);
        if(s==t) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define MAX_NUMBER_OF_CARD	100
#define WORD_LENGTH_MAX	10

int main()
{
    int n, m;
    char blue[MAX_NUMBER_OF_CARD][WORD_LENGTH_MAX + 1];
    char red[MAX_NUMBER_OF_CARD][WORD_LENGTH_MAX + 1];

    bool need_add;
    char words[MAX_NUMBER_OF_CARD][WORD_LENGTH_MAX + 1];
    int number_of_words = 0;

    int score;
    int high_score = -100;
    
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
	scanf("%s", blue[i]);
    }
    scanf("%d", &m);
    for (int i = 0; i < m; i++)
    {
	scanf("%s", red[i]);
    }

    for (int i = 0; i < n; i++)
    {
	need_add = true;
	for (int j = 0; j <= number_of_words; j++)
	{
	    if (strcmp(blue[i], words[j]) == 0)
	    {
		need_add = false;
		break;
	    }
	}
	if (need_add)
	{
	    strcpy(words[number_of_words], blue[i]);
	    number_of_words++;
	}
    }

    for (int i = 0; i < m; i++)
    {
	need_add = true;
	for (int j = 0; j <= number_of_words; j++)
	{
	    if (strcmp(red[i], words[j]) == 0)
	    {
		need_add = false;
		break;
	    }
	}
	if (need_add)
	{
	    strcpy(words[number_of_words], red[i]);
	    number_of_words++;
	}
    }
    
    for (int i = 0; i < number_of_words; i++)
    {
	score = 0;
	for (int j = 0; j < n; j++)
	{
	    if (strcmp(words[i], blue[j]) == 0)
	    {
		score++;
	    }
	}

	for (int j = 0; j < m; j++)
	{
	    if (strcmp(words[i], red[j]) == 0)
	    {
		score--;
	    }
	}

	if (score > high_score)
	{
	    high_score = score;
	}
    }

    if (high_score < 0)
    {
	high_score = 0;
    }
    printf("%d\n", high_score);

    return 0;
}


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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> R(N,0);

  for(int i=0 ; i < M ; i++){
    int a,b;
    cin >> a >> b;
    R.at(a-1)++;
    R.at(b-1)++;
  }

  for(int i=0 ; i<N ; i++)
    cout << R.at(i) << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var nw = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var wv = new int[nw[0]][];
        for (var i = 0; i < nw[0]; i++)
            wv[i] = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var dp = new long[nw[0] + 1,nw[1] + 1];
        for (var i = 0; i <= nw[0]; i++)
            dp[i,0] = 0;
        for (var i = 0; i <= nw[1]; i++)
            dp[0, i] = 0;

        for(var i = 1; i <= nw[0]; i++)
        {
            for(var j = 1; j <= nw[1]; j++)
            {
                if (wv[i - 1][0] <= j)
                {
                    dp[i, j] = Max(dp[i - 1, j], wv[i - 1][1] + dp[i - 1, j - wv[i - 1][0]]);
                }
                else
                    dp[i,j] = dp[i-1,j];
            }
        }
        var max = 0L;
        for (var i = 0; i <= nw[1]; i++)
            max = Max(max, dp[nw[0],i]);
        WriteLine(max);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int n; cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(to_string(i).size() & 1) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3748