akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define maxn 100000
#define mod 1000000007
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

int main()
{
    int d,t,s; scanf("%d%d%d",&d,&t,&s);
    puts((d<=t*s)?"Yes":"No");
    return 0;
}


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

void self(ll &a,ll b){
    a = min(a,b);
}
const ll INF = 1e18L +5;
    

int main()
{
    int n,w;
    cin>>n>>w;
    
    int weight[n],value[n],sum =0;
    for(int i=0;i<n;i++){
        cin>>weight[i]>>value[i];
        sum += value[i];
    }
    
    ll arr[sum+1];
    for(int i=0;i<sum+1;i++)
    arr[i] = INF;
    arr[0] = 0;
    
    for(int i=0;i<n;i++){
        
        for(int val = sum-value[i];val >=0;val--){
            self(arr[val + value[i]],(arr[val] + weight[i]));
        } 
    }
    ll ans = 0;
    for(int i=0;i<=sum;i++){
        if(arr[i] <= w)
        ans = max(ans,(ll) i);
    }
    cout<<ans;
    
       
}


Measured memory_bytes: 1024
from collections import deque
k = int(input())
count = 0
que = deque([1,2,3,4,5,6,7,8,9])
while que:
    q = que.popleft()
    count +=1
    if count == k:
        print(q)
        exit()
    tmp = q%10
    if tmp == 0:
        for i in range(0,2):
            nq = q*10+i
            que.append(nq)
    elif tmp == 9:
        for i in range(8,10):
            nq = q*10+i
            que.append(nq)
    else:
        for i in range(tmp-1, tmp+2):
            nq = q * 10 + i
            que.append(nq)

Measured memory_bytes: 78052
class Dice:
    def __init__(self, top, front, right, left, rear, bottom):
        self.top = top
        self.front = front
        self.right = right
        self.left = left
        self.rear = rear
        self.bottom = bottom
    def print(self):
        '''print top of dice'''
        print(self.top)
    def north(self):
        self.top, self.front, self.bottom, self.rear = \
            self.front, self.bottom, self.rear, self.top
    def south(self):
        self.top, self.front, self.bottom, self.rear = \
            self.rear, self.top, self.front, self.bottom
    def east(self):
        self.top, self.right, self.bottom, self.left = \
            self.left, self.top, self.right, self.bottom
    def west(self):
        self.top, self.right, self.bottom, self.left = \
            self.right, self.bottom, self.left, self.top

d = input().split()
dice = Dice(d[0], d[1], d[2], d[3], d[4], d[5])

commands = list(input())
for cmd in commands:
    if cmd == 'N':
        dice.north()
    elif cmd == 'S':
        dice.south()
    elif cmd == 'E':
        dice.east()
    elif cmd == 'W':
        dice.west()
    else:
        pass
dice.print()



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

using namespace std;


int main() {
    string S;
    cin >> S;

    string ans = "Good";
    if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3]) {
        ans = "Bad";
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H,K;
	while(cin>>N) {
		VI A(N);
		REP(i, N) cin>>A[i];
		ll ans=0,c=0;
		RANGE(i, 1, N) {
			if(A[i-1]<A[i]) c=0;
			else c++;
			maxUpdate(ans, c);
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;using pld=pair<ld,ld>;
const ll INF=1LL<<60;void solve();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define fi first
#define se second
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d!=0&&d>0?i<n:i>n;i+=d)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}
template<class T> void contout(const T &v){for(auto it=v.begin();it!=v.end();++it,cout<<(it!=v.end()?" ":"\n"))cout<<*it;}

void solve(){
  ll n; cin>>n;
  vector<ll> v(3);
  rep(i,n){
    ll a; cin>>a;
    v[--a]++;
  }
  auto dp=make_v(n+1,n+1,n+1,(ld)-1);
  dp[0][0][0]=0;
  function<ld(ll,ll,ll)> calc=[&](ll i,ll j,ll k){
    if(i<0||j<0||k<0) return (ld)0;
    if(dp[i][j][k]!=-1) return dp[i][j][k];
    ld s=i+j+k;
    return dp[i][j][k]=n/s+i*calc(i-1,j,k)/s+j*calc(i+1,j-1,k)/s+k*calc(i,j+1,k-1)/s;
  };

  cout<<calc(v[0],v[1],v[2])<<"\n";
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define MOD ll(1e9 + 7)
#define MAXN int(1e5 + 10)

template<typename T> inline bool smin(T &a, const T &b) { return a > b ? a = b : a; }
template<typename T> inline bool smax(T &a, const T &b) { return a < b ? a = b : a; }
inline void add(ll &l, const ll &r) { l = (l + r) % MOD; }

int n, arr[MAXN];
int mark[MAXN];

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) cin >> arr[i];
	sort(arr, arr + n, greater<int>());
	for (int i = 0; i < n; i++)
		mark[arr[i]]++;
	int D = arr[0];
	for (int i = 0; i <= D; i++) {
		int me = max(D - i, i);
		if (!mark[me])
			return cout << "Impossible\n", 0;
		mark[me]--;
	}
	for (int i = 0; i <= ((D - 1)/ 2) + 1; i++)
		if (mark[i])
			return cout << "Impossible\n", 0;
	cout << "Possible\n";
	//system("pause");
	return 0;
}

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

int n;
int k;

vector<long long int> v;

int cn(int num){
	int r = 0;
	while (num){
		if ((num & 1)){
			r++;
		}
		num >>= 1;
	}
	return r;
}
int main(){
	cin >> n >> k;
	for (int i = 0; i < n; i++){
		int a;
		scanf("%d", &a);
		v.push_back(a);
	}
	long long int ans = LLONG_MAX;
	for (int i = 0; i < (1 << n); i++){
		int val = cn(i);
		if (val != k)continue;
		long long int mx = LLONG_MIN;
		long long int cost = 0;
		for (int j = 0; j < n; j++){
			if ((i >> j) & 1){
				if(mx>=v[j])cost += max(0LL, mx + 1LL - v[j]);
				mx++;
			}
			mx = max(mx, v[j]);
		}
		ans = min(ans, cost);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))

if N%2==1:
    if sum(A)%2==1:
        print("First")
    else:
        print("Second")
else:
    if min(A)%2==1:
        print("First")
    else:
        if sum(A)%2==0:
            print("Second")
        else:
            print("First")


Measured memory_bytes: 28344
#include <iostream>

using namespace std;

int main()
{

  int N;
  cin >> N;
  int button[N];
  bool flag[N];
  for(int i = 0; i < N; i++){
    cin >> button[i];
    flag[i] = false;
  }


  int light = 1;
  int push = 0;
  while(true){
    flag[light-1] = true;
    push++;
    light = button[light-1];
    if(light == 2){
      cout << push << "\n";
      break;
    }
    if(flag[light-1] == true){
      cout << "-1" << "\n";
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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 (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;

int T, n, m;
ll d;
vector<string> v;


int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    string s;
    cin >> s >> m;
    n = s.size();
    vector<string> vs;
    REP(i, n) vs.push_back(s.substr(i));
    sort(ALL(vs));
    vs.resize(min(m, (int)vs.size()));
    vector<string> vs2;
    for(string s : vs) {
        REPS(i, s.size()) vs2.push_back(s.substr(0, i));
    }
    sort(ALL(vs2)); UNIQUE(vs2);
    cout << vs2[m - 1] << endl;
    return 0;
}


Measured memory_bytes: 40572
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main(){
	int N, E, T;
	int res[300];
	const int INF = 1000000;
	while(cin >> N >> E >> T){
		for(int i=0;i<N;i++){
			int W; cin >> W;
			res[i] = W==1 ? 1 : INF;
		}
		vector< vector<int> > vi(E);
		for(int i=0;i<E;i++){
			int G, C, S; cin >> G >> C;
			vi[i].push_back(G-1);
			for(int j=0;j<C;j++){
				cin >> S;
				vi[i].push_back(S-1);
			}
		}
		for(int i=0;i<N;i++){
			for(int j=0;j<E;j++){
				int cur = vi[j][0];
				vector<int> num;
				for(int k=1;k<vi[j].size();k++)
					num.push_back(res[vi[j][k]]);
				sort(num.begin(), num.end(), greater<int>());
				int tmp = 0;
				for(int k=0;k<num.size();k++) tmp = max(tmp, num[k]+k);
				res[cur] = min(res[cur], tmp);
			}
		}
		cout << (res[T-1]!=INF ? res[T-1] : -1) << endl;
	}
}

Measured memory_bytes: 932
#include <bits/stdc++.h>
#define maxn 200086
using namespace std;

struct SegmentTree{
	struct Node{
		int sum, cov;
	}t[maxn << 2];
	
	#define ls(x) (x << 1)
	#define rs(x) (x << 1 | 1)
	
	inline void up(int x){
		t[x].sum = min(t[ls(x)].sum, t[rs(x)].sum); 
	}
	
	inline void cover(int x, int y){
		t[x].sum = t[x].cov = y;
	}
	
	inline void down(int x){
		if(t[x].cov != -1){
			cover(ls(x), t[x].cov), cover(rs(x), t[x].cov);
			t[x].cov = -1;
		}
	}
	
	void modify(int x, int l, int r, int ll, int rr, int d){
		if(ll <= l && r <= rr){
			cover(x, d);
			return;
		}
		down(x);
		int mid = l + r >> 1;
		if(mid >= ll) modify(ls(x), l, mid, ll, rr, d);
		if(mid < rr) modify(rs(x), mid + 1, r, ll, rr, d);
		up(x);
	}
	
	int query(int x, int l, int r, int ll, int rr){
		if(ll <= l && r <= rr) return t[x].sum;
		down(x);
		int mid = l + r >> 1, sum = 1e9;
		if(mid >= ll) sum = min(sum, query(ls(x), l, mid, ll, rr));
		if(mid < rr) sum = min(sum, query(rs(x), mid + 1, r, ll, rr));
		return sum;
	}
	
	int a[maxn];
	
	void build(int x, int l, int r){
		t[x].cov = -1;
		if(l == r){
			t[x].sum = a[l];
			return;
		}
		int mid = l + r >> 1;
		build(ls(x), l, mid), build(rs(x), mid + 1, r);
		up(x);
	}
}t[2];

int n, m;
int l, r;

int main(){
	scanf("%d%d", &n, &m);
	t[0].build(1, 1, m);
	for(int i = 1;i <= m;i++) t[1].a[i] = -i;
	t[1].build(1, 1, m);
	for(int i = 1;i <= n;i++){
		scanf("%d%d", &l, &r);
		t[0].modify(1, 1, m, l, r, 1e9);
		if(r < m){
			int x = t[0].query(1, 1, m, r + 1, r + 1);
			int y = t[1].query(1, 1, m, 1, r) + r + 1;
			if(y < x) t[0].modify(1, 1, m, r + 1, r + 1, y), t[1].modify(1, 1, m, r + 1, r + 1, y - r - 1);
		}
		t[1].modify(1, 1, m, l, r, 1e9);
		if(t[0].t[1].sum == 1e9) puts("-1");
		else printf("%d\n", t[0].t[1].sum + i);
	}
}

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

namespace Atcoder
{
    class AtCodeeeeeeeeeeeeeeeeeeeer
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            bool flug = false;
            string ans = "No";
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i]=='C')
                {
                    flug = true; 
                }
                if (flug==true && s[i] == 'F')
                {
                    ans = "Yes";
                }
            }
            Console.WriteLine(ans);
        }
    }
}


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

void print(vector<int> array)
{
  for(int i=0;i<array.size()-1;i++){
    cout<<array[i]<<" ";
  }
  cout<<array[array.size()-1]<<endl;
}
vector<int> Exaustive(vector<int>& array)
{
  //print(array);
  int n=array.size();
  if(n==1){
    return array;
  }else if(n==2){
    int app=array[0]+array[1];
    array.push_back(app);
    //cout<<"app;"<<endl;
    //print(array);
    return array;
  }else{
    int half=n/2;
    vector<int> left(0);
    vector<int> right(0);
    for(int i=0;i<half;i++){
      left.push_back(array[i]);
    }
    for(int i=half;i<n;i++){
      right.push_back(array[i]);
    }
    left=Exaustive(left);
    right=Exaustive(right);

    vector<int>app(0);
    for(int i=0;i<right.size();i++){
      for(int j=0;j<left.size();j++){
	int x=right[i]+left[j];
	app.push_back(x);
      }
    }
    for(int i=0;i<right.size();i++){
      app.push_back(right[i]);
    }
    for(int i=0;i<left.size();i++){
      app.push_back(left[i]);
    }
    //cout<<"app;"<<endl;
    //print(app);
    return app; 
  }
}
int main()
{
  int n,m,judge;
  cin>>n;
  vector<int> list(n);
  for(int i=0;i<n;i++){
    cin>>list[i];
  }
  cin>>m;
  vector<int> ms(m);
  for(int i=0;i<m;i++){
    cin>>ms[i];
  }

  list=Exaustive(list);

  for(int j=0;j<ms.size();j++){
    judge=0;
    for(int i=0;i<list.size();i++){
      if(ms[j]==list[i]){
	cout<<"yes"<<endl;
	judge=1;
	break;
      }
    }
    if(judge==0) cout<<"no"<<endl;
  }
  return 0;
}



Measured memory_bytes: 11192
#include <bits/stdc++.h>
using namespace std;
int main (){
	string S;
	cin >> S;
	int s = (int)S.size();
	bool judge  = true;
	bool existC = false;
	for (int i = 0; i < s; ++i)
	{
		if(i == 0 && S[i] != 'A'){
			judge = false;
		}
		if((i == 1 || i == s-1) && !('a' <= S[i] && S[i] <= 'z')){
			judge = false;
		}
		if(1 < i && i < s-1){
			if(S[i] == 'C'){
				if(existC){
					judge = false;
				}else{
					existC =true;
				}
			}else if(!('a' <= S[i] && S[i] <= 'z')){
				judge = false;
			}
		}
		
	}
    if(!existC)judge = false;
	if(judge){
		cout << "AC" << endl;
	}else{
		cout << "WA" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define X first
#define Y second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ini(x, y) memset(x, y, sizeof(x))
#define endl '\n'
#define fastio cin.sync_with_stdio(false); cin.tie(nullptr)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;
const int dx[] = { -1, 0, 1, 0, -1, 1, 1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

int main() {
	fastio;
	string S;
	cin >> S;

	if (S[2] == S[3] && S[4] == S[5]) cout << "Yes";
	else cout << "No";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int h,w;
    while(1){
        cin >> h >> w;
        if(h == 0 && w ==0) break;
        else{
            for(int y=1;y<=h;y++){
                for(int x=1;x<=w;x++){
                    if((x+y)%2==0) cout << "#";
                    else cout << ".";
                }
                cout <<endl;
            }
            cout <<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1152
from collections import deque

k = int(input())
q = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])

cnt = 0
while q:
    curr = q.popleft()
    cnt += 1
    if cnt == k:
        break
    if curr % 10 == 9:
        q.append(curr * 10 + curr % 10 - 1)
        q.append(curr * 10 + curr % 10)
    elif curr % 10 == 0:
        q.append(curr * 10 + curr % 10)
        q.append(curr * 10 + curr % 10 + 1)
    else:
        q.append(curr * 10 + curr % 10 - 1)
        q.append(curr * 10 + curr % 10)
        q.append(curr * 10 + curr % 10 + 1)

print(curr)

Measured memory_bytes: 18724
#include<bits/stdc++.h>
#define ll long long
using namespace std;
void solve()
{
    int n,k,mn=0;
    cin>>n>>k;
    int arr[n+5];
    for(int i=0;i<n;++i){
        cin>>arr[i];
    }
    sort(arr,arr+n);
    for(int i=0;i<k;++i){
        mn+=arr[i];
    }
    cout<<mn;

}

int main()
{
    int x,t;  solve();

}




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

#define rep(i, n) for(int (i) = 0; i < (n); ++(i))

typedef long long ll;
const ll MOD = 1e9 + 7;

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

  int ans = 0;
  rep(i, N - 2) {
    if(S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {
      ++ans;
    }
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int x,y;
    while(1){
        scanf("%d %d",&x,&y);
        if(x==0&&y==0) break;
        if(x>y){
            printf("%d %d\n",y,x);
        }
        else printf("%d %d\n",x,y);
    }
}

Measured memory_bytes: 1804
#include <stdio.h>
int main(void) 
{
	int n, m, i, j;
	int A[100][100] = {0};
	int B[100] = {0};
	int C[100] = {0};
	
	scanf("%d %d", &n, &m);
	for(i = 0; i < n; i++) {
    		for(j = 0; j < m; j++) {
    			scanf("%d", &A[i][j]);
    		}
	}
	for(j = 0; j < m; j++) {
		scanf("%d", &B[j]);
	}

	for(i = 0; i < n; i++) {
    		for(j = 0; j < m; j++) {
    			C[i] += A[i][j] * B[j];
    		}
    		printf("%d\n", C[i]);
	}
	return 0;
}



Measured memory_bytes: 2140
a,b = map(int,input().split())
p = 1
while True:
    temp1 = int(p * 0.08)
    temp2 = int(p * 0.1)
    if temp1==a and temp2==b:
        print(p)
        break
    p+=1
    if p>1000000:
        print(-1)
        break

Measured memory_bytes: 2940
#include<stdio.h>
int main(){
	int s[9000],n,m,t,f,i;
	while(scanf("%d%d",&n,&m),n)
		for(i=t=f=1;i<=n+m;i++){
			scanf("%d",&s[i]);
			if(i>n)
				if(t+=s[t+=s[i]],t>=n&f==1)
					printf("%d\n",i-n,f=0);
			
		}
}

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

int main(){
    int array[10000];
    int cnum=0;
    while(1){
        cnum += 1;
        cin >> array[cnum];
        if(array[cnum] == 0) break;
    }
    for(int i = 1;i < cnum;i++){
        cout << "Case " << i << ": " << array[i] << "\n";
    }
}


Measured memory_bytes: 2952
#include <iostream>

using namespace std;

int n, k;
int c[10];

bool ok(int x) {
    while (x) {
        if (c[x%10]) return false;
        x /= 10;
    }
    return true;
}

int main() {
    cin >> n >> k;
    for (int i = 1; i <= k; i++) {
        int x;
        cin >> x;
        c[x] = 1;
    }
    while (true) {
        if (ok(n)) {
            cout << n << "\n";
            return 0;
        }
        n++;
    }
}

Measured memory_bytes: 256
/*Lucky_Glass*/
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e5;
int n;
vector<int> lnk[N+5];
int DFS(int u,int pre){
	int ret=0;
	for(auto v : lnk[u]){
		if(v==pre) continue;
		ret+=DFS(v,u);
	}
	if(ret>=2) return ret;
	return ret^1;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int u,v;scanf("%d%d",&u,&v);
		lnk[u].push_back(v);
		lnk[v].push_back(u);
	}
	printf("%s\n",DFS(1,0)?"First":"Second");
	return 0;
}

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

int main()
{
  int A, B, C, D;

  cin >> A >> B >> C >> D;

  int turn = 0;

  while (A > 0 && C > 0)
  {
    if (turn % 2 == 0)
    {
      C -= B;
    }
    else
    {
      A -= D;
    }
    turn++;
  }

  if (A > C)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


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

int main() {
    int c, n;
    cin >> c >> n;
    c--;

    int sym = 0, ans = 0;
    vector< vector< bool > > s(n, vector< bool > (n));
    vector< vector< char > > mas(n, vector< char >(n));
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            cin >> mas[i][j];
        }
    }

    for(int i = 0; i < n / 2; i++) {
        for(int j = 0; j < n / 2; j++) {
            if(!(mas[i][j] == mas[i][n - 1 - j] && mas[i][j] == mas[n - 1 - i][j] && mas[i][j] == mas[n - 1 - i][n - 1 - j])) {
                sym++;
                s[i][j] = false;
            } else {
                s[i][j] = true;
            }

        }
    }

    if(!sym) ans++;

    while(c--) {
        int d;
        cin >> d;
        while(d--) {
            int r, c; cin >> r >> c;
            r--, c--;
            mas[r][c] = (mas[r][c] == '0' ? '1' : '0');
            if(r >= n / 2) r = n - 1 - r;
            if(c >= n / 2) c = n - 1 - c;

            if(mas[r][c] == mas[r][n - 1 - c] && mas[r][c] == mas[n - 1 - r][c] && mas[r][c] == mas[n - 1 - r][n - 1 - c] && !s[r][c]) {
                sym--;
                s[r][c] = true;
            } else if(s[r][c]) {
                s[r][c] = false;
                sym++;
            }

        }
        if(!sym) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4224
#include<iostream>
using namespace std;
int main(){
int A,B,C,D;
cin>>A>>B>>C>>D;
if(A+B>C+D){
    cout<<"Left";
}
else if (A+B<C+D){
    cout<<"Right";
}
else if(A+B==C+D){
    cout<<"Balanced";
}
return 0 ;
}

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

const int maxn=2e5+100;
const double pi=acos(-1);

const double Dec=5*pi-20.0;
const double Add=10*pi-20.0;

int n,m,t[maxn*3],Ans,mn[maxn];
double Sum;

struct Point{
	int x,y;
	bool operator < (const Point &p) const {return x==p.x?y<p.y:x<p.x;}
}S,T,P[maxn];

void init()
{
	int i;
	scanf("%d%d",&S.x,&S.y);
	scanf("%d%d",&T.x,&T.y);
	scanf("%d",&n);
	for (i=1;i<=n;i++)
		scanf("%d%d",&P[i].x,&P[i].y);

	if (S.x>T.x)
	{
		S.x=100000000-S.x;
		T.x=100000000-T.x;
		for (i=1;i<=n;i++)
			P[i].x=100000000-P[i].x;
	}
	if (S.y>T.y)
	{
		S.y=100000000-S.y;
		T.y=100000000-T.y;
		for (i=1;i<=n;i++)
			P[i].y=100000000-P[i].y;
	}
	m=0;
	for (i=1;i<=n;i++)
		if (S.x<=P[i].x&&P[i].x<=T.x&&S.y<=P[i].y&&P[i].y<=T.y) P[++m]=P[i];
	n=m;
	Sum=((double)T.x-S.x+T.y-S.y)*100;

	/*
	m=0;
	t[++m]=S.y-1; t[++m]=S.y; t[++m]=S.y+1;
	t[++m]=T.y-1; t[++m]=T.y; t[++m]=T.y+1;
	for (i=1;i<=n;i++)
	{
		t[++m]=P[i].x-1;
		t[++m]=P[i].x;
		t[++m]=P[i].x+1;
	}
	sort(t+1,t+m+1);
	m=unique(t+1,t+m+1)-t-1;
	S.x=lower_bound(t+1,t+m+1,S.x)-t;
	T.x=lower_bound(t+1,t+m+1,T.x)-t;
	for (i=1;i<=n;i++)
		P[i].x=lower_bound(t+1,t+m+1,P[i].x)-t;

	m=0;
	t[++m]=S.y-1; t[++m]=S.y; t[++m]=S.y+1;
	t[++m]=T.y-1; t[++m]=T.y; t[++m]=T.y+1;
	for (i=1;i<=n;i++)
	{
		t[++m]=P[i].y-1;
		t[++m]=P[i].y;
		t[++m]=P[i].y+1;
	}
	sort(t+1,t+m+1);
	m=unique(t+1,t+m+1)-t-1;
	S.y=lower_bound(t+1,t+m+1,S.y)-t;
	T.y=lower_bound(t+1,t+m+1,T.y)-t;
	for (i=1;i<=n;i++)
		P[i].y=lower_bound(t+1,t+m+1,P[i].y)-t;
	*/

	if (T.x-S.x>T.y-S.y)
	{
		swap(S.x,S.y);
		swap(T.x,T.y);
		for (i=1;i<=n;i++)
			swap(P[i].x,P[i].y);
	}
}

void solve(int x)
{
	if (!Ans) {mn[++Ans]=x; return;}
	int L=1,R=Ans,mid;
	while (L<=R)
	{
		mid=(L+R)>>1;
		if (mn[mid]<x) L=mid+1;
		else R=mid-1;
	}
	if (L>Ans) mn[++Ans]=x;
	else mn[L]=min(mn[L],x);
}

int main()
{
#ifdef h10
	freopen("C.in","r",stdin);
	freopen("C.out","w",stdout);
#endif
	int i;
	init();
	if (S.x==T.x)
	{
		printf("%.15lf\n",Sum+Add*n);
//		printf("%.15lf + %.15lfd * %d\n",Sum,Add,n);
		return 0;
	}

	if (!n)
	{
		printf("%.15lf\n",Sum);
		return 0;
	}
	sort(P+1,P+n+1);
	for (i=1;i<=n;i++)
		if (i==1||P[i].x!=P[i-1].x) solve(P[i].y);

//	for (i=1;i<=n;i++)
//		printf("%d %d\n",P[i].x,P[i].y);

//	printf("Ans=%d\n",Ans);

//	printf("%.15lf\n",Sum);
	Sum+=Dec*Ans;
//	printf("%.15lf\n",Sum);
	if (Ans==T.x-S.x+1) Sum+=Add-Dec;

	printf("%.15lf\n",Sum);

}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define mp make_pair
const ll MOD=1e9+7;
using namespace std;

ll gcd(ll a, ll b) {
  if(a==0) return b;
  if(a>b) return gcd(a%b, b);
  else return gcd(b%a, a);
}

int main(){
  ll A,B,C;
  cin >> A >> B >> C;

  if(A%2==0 && B%2==0 && C%2==0){
    if(A==B && B==C){
      cout << -1 << endl;
      return 0;
    }else{
      ll ans = 0;
      while(1){
        if(A%2==0 && B%2==0 && C%2==0){
          ll a = A/2;
          ll b = B/2;
          ll c = C/2;
          A = b+c;
          B = a+c;
          C = a+b;
          ans++;
          continue;
        }
        break;
      }
      cout << ans << endl;
    }
  }else{
    cout << 0 << endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include <stdio.h>


int main(){
    int i;
    int x, y, z;

    scanf("%d", &i);

    x = i / 3600;
    y = (i % 3600) / 60;
    z = i % 3600 % 60;

    printf("%d:%d:%d\n", x, y, z);

    return 0;
}


Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
int main(){
    int m, f, b;
    cin>>m>>f>>b;
    if(m>=b){
        cout<<"0"<<endl;
    }else if(m<b&&m+f>=b){
        cout<<b-m<<endl;
    }else{
        cout<<"NA"<<endl;
    }
}


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


int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << c << " " << a << " " << b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main() {
  ll n,m;
  cin >> n >> m;
  vector<P> v[n];
  for(int i=0; i<m; i++) {
    int x,y,z;
    cin >> x >> y >> z;
    x--,y--;
    v[x].push_back(P(y,z));
    v[y].push_back(P(x,z));
  }
  ll v0,A,B,C;
  cin >> v0 >> A >> B >> C;
  ll d[n][50];
  for(int i=0; i<n; i++)for(int j=0; j<C; j++) d[i][j]=1LL<<59;
  d[0][v0]=0;
  priority_queue<PP,vector<PP>,greater<PP> > que;
  que.push(PP(0,P(0,v0)));
  while(!que.empty()) {
    PP p=que.top();que.pop();
    ll x=p.second.first,t=p.second.second,c=p.first;
    if(d[x][t]<c) continue;
    for(int i=0; i<v[x].size(); i++) {
      ll y=v[x][i].first,cc=v[x][i].second;
      ll s=(A*t+B)%C;
      if(d[y][s]<=d[x][t]+cc*t) continue;
      d[y][s]=d[x][t]+cc*t;
      que.push(PP(d[y][s],P(y,s)));
    }
  }
  for(int i=0; i<n-1; i++)for(int j=0; j<C; j++)d[i][j]=1LL<<59;
  for(int i=0; i<C; i++) que.push(PP(d[n-1][i],P(n-1,i)));
  while(!que.empty()) {
    PP p=que.top();que.pop();
    ll x=p.second.first,t=p.second.second,c=p.first;
    if(d[x][t]<c) continue;
    for(int i=0; i<v[x].size(); i++) {
      ll y=v[x][i].first,cc=v[x][i].second;
      ll s=(A*t+B)%C;
      if(d[y][s]<=d[x][t]+cc*t) continue;
      d[y][s]=d[x][t]+cc*t;
      que.push(PP(d[y][s],P(y,s)));
    }
  }
  ll ans=1LL<<59;
  for(int i=0; i<C; i++) ans=min(ans,d[0][i]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6212
n, k = map(int, input().split())
numbers = [i for i in range(n+1)]
min = [0] * (n+1)
for i in range(n):
    min[i+1] = min[i] + numbers[i+1]
max = [0] * (n+1)
max[0] = numbers[n]
for i in range(n):
    max[i+1] = max[i] + numbers[n-i-1]
 
ans = 0
for i in range(k-1,n+1):
    ans += max[i] - min[i] + 1
 
print(ans % (10**9+7))

Measured memory_bytes: 38380
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	int n;
	cin >> n;
	rep(i, 1, 10) {
		rep(j, 1, 10) {
			if (i*j == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void testsort(int a[], int l, int r);

int main(void)
{
  char arr[5];
  int n;
  int a[100] = {0};
  int alice=0, bob=0;

  fgets(arr, sizeof(arr), stdin);
  sscanf(arr, "%d", &n);

  for (int i=0; i < n; i++) {scanf("%d", &a[i]);}
  testsort(a, 0, n);
  for (int i=0; i < n; i++) {

    if (i%2 == 0) {
      alice += a[i];
    } else {
      bob += a[i];
    }
  }
     

      printf("%d\n", alice-bob);

    

    return 0;
  }

//ソート大きい順に並べる
void testsort(int a[], int l, int r)
{
  for (int i = l+1; i < r; i++) {
    for (int j = i; j > l; j--) {
      if (a[j] > a[j-1]) { int t = a[j]; a[j] = a[j-1]; a[j-1] = t;}
    }
  }
}




Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
typedef long long ll;
using namespace std;
#define int long long

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

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

//互除法
ll gcd(ll a, ll b) {
	if (a < b) {
		return gcd(b, a);
	}
	else if (a%b) {
		return gcd(b, a%b);
	}
	else {
		return b;
	}
}

//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b; // Be careful not to overflow

}


//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor(int n) {
	map<int, int> res; // map[i]:=ｎを素因数分解したときiは何乗か。
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n] = 1;
	return res;
}

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

	int N;
	int T;
	int ans = 1LL;

	cin >> N;

	for (int i = 0; i < N; i++)
	{
		cin >> T;
		ans = lcm(ans, T);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
rootList = [-1 for i in range(n)]
 
def getRoot(x):
    r = rootList[x]
    if r < 0:
        rootList[x] = x
    elif r != x:
        rootList[x] = getRoot(r)
    return rootList[x]
 
 
def setSameRoot(x, y):
    x = getRoot(x)
    y = getRoot(y)
    if x != y:
        rootList[x] = rootList[y] = min(x, y)
 
for i in range(m):
    s, t = map(int, input().split())
    setSameRoot(s, t)
q = int(input())
for i in range(q):
    s, t = map(int, input().split())
    print("yes" if getRoot(s) == getRoot(t) else "no")

Measured memory_bytes: 7012
use std::io;
use std::str::FromStr;
use std::cmp::min;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_vec() -> Vec<i64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}


fn main() {
    let n: i64 = input();
    let x_vec = input_vec();
    let mut ans = std::i64::MAX;
    for i in 0..100 {
        let mut sum = 0;
        for x in &x_vec {
            sum += (i - x) * (i - x);
        }
        ans = min(ans, sum);
    }


    println!("{}", ans);
}


Measured memory_bytes: 2116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef pair<int,pi> pii;
typedef double dl;
#define mp make_pair
#define pb push_back
#define f first
#define s second
ll MOD = 1e9+7;
#define lb lower_bound
#define ub upper_bound
#define INF 1000000000
#define ALL(x) x.begin(),x.end()
priority_queue<pi, vector<pi>, greater<pi> > pq;
ll dist[100100], d[100100];
ll rep[100100], r[100100],a,b,w,N,M,S,T;
vpi adjList[100100];
vector<pii> edgeList;

void dijkstra(int start){
	memset(dist, -1, sizeof(dist));
	dist[start] = 0;
  rep[start] =1;
	pq.push(mp(0, start));
  while (!pq.empty()) {
    pi cur = pq.top();
    pq.pop();
    ll x = cur.s, d = cur.f;
    if (d > dist[x]) continue;
    for (auto it : adjList[x]) {
      ll nx = it.f, nd = d+it.s;
      if (dist[nx] != -1 && dist[nx] < nd) continue;
      if (dist[nx] != -1 && dist[nx] == nd){
        rep[nx] += rep[x];
        rep[nx] %= MOD;
        continue;
      }
      dist[nx] = nd;
      rep[nx] = rep[x];
      pq.push(mp(nd, nx));
    }
  }
}

int main(){
  // freopen("input.txt","r",stdin);
  cin>>N>>M>>S>>T;
  for (int i=0;i<M;++i){
    cin>>a>>b>>w;
    adjList[a].pb(mp(b,w));
    adjList[b].pb(mp(a,w));
    edgeList.pb(mp(w,mp(a,b)));
  }
  dijkstra(S);
  swap(dist,d);
  swap(rep,r);
  dijkstra(T);
  // for (int i=1;i<=N;++i)cout<<d[i] << ' '<<dist[i]<<' '<<r[i] << ' '<<rep[i]<<'\n';
  ll res = rep[S]*r[T]%MOD;
  ll op  = dist[S];
  assert(op == d[T]);
  // cout<<op<<'\n';
  // cout<<res<<'n';
  for (auto i : edgeList){ // Intersect on a edge
    a = i.s.f;
    b = i.s.s;
    if (d[a] > d[b]) swap(a,b);
    if (d[b] - d[a] != i.f)continue;
    if (dist[a] - dist[b] != i.f)continue;
    if (dist[a] + d[b] - i.f != op)continue;
    if (abs (dist[b] - d[a]) >= i.f)continue;
    // cout<<a<<' '<<b<<'\n';
    ll t = (r[a] * rep[b]) % MOD;
    t = (t * t) % MOD;
    res -= t;
    // cout<<a<<' '<<b<<' '<<t<<'\n';
    if(res<0)res += MOD;
  }
  // cout<<res<<'n';
  for (int i=1;i<=N;++i){ // Intersect on a node
    if (dist[i] == d[i] && 2*d[i] == op){
      ll t = (r[i] * rep[i]) %MOD;
      t = (t * t) %MOD;
      res -= t;
      // cout<<i<<' '<<t<<'\n';
      if(res<0)res += MOD;
    }
  }
  cout<<res%MOD;
}

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

int main() {
	int n;
	cin >> n;
	int ok = 0;
	
	for(int i = 1; i < 10; i++) {
		for(int j = 1; j < 10; j++){
			if(i*j == n) {
				ok = 1;
				cout << "Yes";
				goto here;
			}
		}
	}
	here: 
	if(!ok) cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順


int main(){
	int r;
	cin >>r;
	cout << r*r << endl;

  return 0;
}


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int inf = 1e9;

int h, w, c;
int cnt;
int ans;

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

bool inside(int x, int y) {
    return 0 <= x && x < h && 0 <= y && y < w;
}

void change(VV &b, const int oc, const int nc, const int i, const int j) {
    if (nc == oc) return;
    if (!inside(i, j)) return;
    if (b[i][j] != oc) return;
    // cout << i << " " << j << endl;
    b[i][j] = nc;
    cnt++;
    rep(k, 4) {
        change(b, oc, nc, i + dx[k], j + dy[k]);
    }
}

// void dfs(VV b, int nc, int step) {
//     cout << nc << " " << step << endl;
//     change(b, b[0][0], nc, 0, 0);
//     if (step == 5) {
//         if (b[0][0] == c) {
//             cnt = 0;
//             change(b, b[0][0], -1, 0, 0);
//             ans = max(ans, cnt);
//         }
//         return;
//     }
//     rep2(nc, 1, 6 + 1) {
//         if (nc == b[0][0]) continue;
//         dfs(b, nc, step + 1);
//     }
// }

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

    while (cin >> h >> w >> c, h) {
        VV a(h, V(w));
        rep(i, h) rep(j, w) cin >> a[i][j];

        int ans = -1;
        // dfs(a, a[0][0], 0);

        rep(s, pow(6, 4)) {
            // cout << s << endl;
            VV b = a;
            int perm = s;
            rep(step, 4) {
                cnt = 0;
                change(b, b[0][0], (perm % 6) + 1, 0, 0);
                perm /= 6;
            }
            cnt = 0;
            change(b, b[0][0], c, 0, 0);

            cnt = 0;
            change(b, b[0][0], 10, 0, 0);
            ans = max(ans, cnt);
        }

        cout << ans << endl;
    }
}

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

const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main()
{
    string s;
    cin >> s;
    int flag = 0;
    if(s[0] != 'A') flag = 1;
    int cnt = 0;
    for(int i = 2; i < s.size()-1; i++){
        if(s[i] == 'C') cnt++;

    }
    int cnt2 = 0;
    for(int i = 0; i < s.size(); i++){
        if('A' <= s[i] && s[i] <= 'Z') cnt2++;
    }
    cout << ((flag || cnt != 1 || cnt2 != 2) ? "WA" : "AC") << endl; 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int s,w;
	cin>>s>>w;
	if(w>=s) cout<<"unsafe"<<endl;
	else cout<<"safe"<<endl;
	return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a+b >= c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}



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

int main()
{
    ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

    string num;

    cin >> num;

    ll sum = 0;

    ll len = num.length();

    for(ll i=0; i<len; i++)
    {
        sum = ((sum*10) + (num[i] - '0')) % 9;
    }

    if(sum == 0)
    {
        cout << "Yes";
    }

    else
    {
        cout << "No";
    }


}


Measured memory_bytes: 3748
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

int main(){
    int n;
    cin >> n;
    if(n%2==0){
        cout<<n/2-1<<endl;
    }else{
        cout<<n/2<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int[] h = new int[n];
		int[] cost = new int[n];
		
		for(int i = 0; i < h.length; i++) {
			h[i] = scan.nextInt();
		}
		
		for(int i = 0; i < h.length; i++) {
			if(i == 0) {
				cost[i] = 0;
			}else if(i == 1) {
				cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1];
			}else {
				cost[i] = Math.abs(h[i] - h[i-2]) + cost[i-2];
				if(cost[i] > Math.abs(h[i] - h[i-1]) + cost[i-1]) {
					cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1];
				}
			}
		}
		
		scan.close();
		/*
		 * for(int i = 0; i < cost.length;i++) { System.out.println(cost[i]); }
		 */
		
		System.out.println(cost[cost.length-1]);
		
	}

}


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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

void solve() {
  string S;
  int Q;
  cin >> S >> Q;
  string head = "";
  string tail = "";
  int R = 0;
  for (int i = 0; i < Q; i++) {
    int T;
    cin >> T;
    if (T == 1) {
      R++;
      swap(head, tail);
    } else {
      int F;
      char C;
      cin >> F >> C;
      if (F == 1) {
        head = head + C;
      } else {
        tail = tail + C;
      }
    }
  }
  reverse(all(head));
  if (R % 2 == 1) {
    reverse(all(S));
    cout << head + S + tail << endl;
  } else {
    cout << head + S + tail << endl;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cout << fixed << setprecision(12);

  solve();

  return 0;
}


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

using namespace std;
const int mod = 1e9 + 7;
const long long INF = 1e18;
#define PI 3.141592653589793
#define REP(i, n) for(long long i = 0;i < n;i++)
long long H,W,K,N,D,X,T;


int main()
{
  string S;
  cin>>S;
  int ans=0;
  REP(i,S.size()){
    ans+=S[i]-'0';
  }
  if(ans%9==0){
    cout<<"Yes";
  }
  else cout<<"No";
  return 0;
}




Measured memory_bytes: 3672
#include <iostream>
#include <vector>

const long long MOD = 1000000007;

int main() {
    int N, K;
    std::cin >> N >> K;

    auto pow = [](long long a, int n) {
        long long res = 1;
        for (; n; n >>= 1) {
            if (n & 1)
                res = res * a % MOD;
            a = a * a % MOD;
        }
        return res;
    };

    std::vector<long long> table(N + 1), inv_table(N + 1);
    table[0] = 1;
    for (int i = 1; i <= N; i++)
        table[i] = table[i - 1] * i % MOD;
    inv_table[N] = pow(table[N], MOD - 2);
    for (int i = N; i > 0; i--)
        inv_table[i - 1] = inv_table[i] * i % MOD;

    auto comb = [&table, &inv_table](int n, int r) {
        if (n < r)
            return 0LL;
        long long tmp = inv_table[n - r] * inv_table[r] % MOD;
        return table[n] * tmp % MOD;
    };

    for (int i = 1; i <= K; i++) {
        int ans = comb(N - K + 1, i) * comb(K - 1, i - 1) % MOD;
        std::cout << ans << "\n";
    }
}

Measured memory_bytes: 256
n, x = map(int, input().split())
a = list(map(int, input().split()))
result = 0
if a[0] > x:
    result += (a[0] - x)
    a[0] = x
for i in range(1, n):
    box2 = a[i-1] + a[i]
    if x < box2:
        result += box2 - x
        a[i] -= box2 - x
print(result)

Measured memory_bytes: 14720
# coding: utf-8

# In[133]:


n,m = map(int, input().split())

data = []
for i in range(m):
    p,y = map(int, input().split())
    data.append([p, y, i])


# In[134]:


data.sort(key= lambda x: x[1])
data.sort()


# In[135]:


num = 1

for i in range(m):
    if i == 0:
        data[i][1] = num
        num += 1
    else:
        if data[i][0] == data[i-1][0]:
            data[i][1] = num
            num += 1
        else:
            data[i][1] = 1
            num = 2


# In[136]:


data.sort(key= lambda x: x[2])


# In[137]:


for i in range(m):
    p = str(data[i][0]).zfill(6)
    num = str(data[i][1]).zfill(6)
    print(p+num)



Measured memory_bytes: 24544