akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

int w,h;
char p[70][20];
int n;
int id[70][20];
vector<pi> v[400];
int xsum[400];
int bottom;

int used[70][20];
int dy[]={0,1,0,-1};
int dx[]={1,0,-1,0};
void dfs(int y,int x,char c){
	used[y][x]=1;
	id[y][x]=n;
	v[n].pb(mp(y,x));
	xsum[n] += x;
	if(y==h)bottom=n;
	rep(d,4){
		int ny=y+dy[d],nx=x+dx[d];
		if(!used[ny][nx] && p[ny][nx] == c){
			dfs(ny,nx,c);
		}
	}
}

bool on(int a,int b){
	rep(i,4)rep(j,4){
		if(v[a][i].fir == v[b][j].fir-1 && v[a][i].sec == v[b][j].sec){
			return 1;
		}
	}
	return 0;
}

pi sum(int cur){
	int s=xsum[cur];
	int block=1;
	//cout<<cur<<endl;
	rep(i,n)if(i!=cur && on(i,cur)){
		pi p = sum(i);
		s += p.fir;
		block += p.sec;
	}
	return mp(s,block);
}

int f(int cur){
	int l=INF,r=-INF;
	rep(i,4){
		//cout<<i<<endl;
		int y=v[cur][i].fir,x=v[cur][i].sec;
		if(id[y+1][x] != -1 && id[y+1][x] != cur
		|| y==h){
			l = min(l,x);
			r = max(r,x);
		}
	}
	//cout<<cur<<" : "<<l<<" "<<r<<endl;
	pi p = sum(cur);
	double ave = p.fir /4. / p.sec;
	//cout<<p.fir<<" "<<p.sec<<" "<<ave<<endl;
	if(l - 0.5 + EPS <= ave && ave <= r + 0.5 - EPS)return 1;
	return 0;
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	while(cin>>w>>h && w){
		//cout<<w<<" "<<h<<endl;
		memset(p,0,sizeof(p));
		rep2(i,1,h+1)rep2(j,1,w+1){
			cin>>p[i][j];
		}
		memset(used,0,sizeof(used));
		memset(id,-1,sizeof(id));
		memset(xsum,0,sizeof(xsum));
		n=0;
		rep2(i,1,h+1)rep2(j,1,w+1)if(!used[i][j] && isdigit(p[i][j])){
			//cout<<n<<" : "<<i<<" "<<j<<endl;
			v[n].clear();
			dfs(i,j,p[i][j]);
			n++;
		}
		//cout<<"n: "<<n<<endl;
		//rep(i,n)cout<<xsum[i]<<" ";cout<<endl;
		/*cout<<"--"<<endl;
		rep2(i,1,h+1)rep2(j,1,w+1){
			cout<<id[i][j]<<(j==w?"\n":" ");
		}
		cout<<"--"<<endl;*/
		int ans=1;
		rep(i,n){
			//cout<<i<<endl;
			if(!f(i))ans=0;
		}
		cout<<(ans ? "STABLE":"UNSTABLE")<<endl;
	}
}

Measured memory_bytes: 1220
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<numeric>

#define reps(i, j, k) for (int i = (j); i < (k); i++)
#define rep(i, j) reps(i, 0, j)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int N, Y;
int _N;
int x = 0, y = 0, z = 0;

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

	// 最小の枚数を決定する
	x = Y / 10000;
	Y = Y % 10000;
	
	y = Y / 5000;
	Y = Y % 5000;
	
	z = Y / 1000;
	Y = Y % 1000;
	
	if (Y != 0) { x = -1, y = -1, z = -1; }
	else {
		while (x + y + z != N) {
			if (N - (x + y + z) >= 4 && y >= 1) {
				z += 5;
				y -= 1;
			}
			else if (N - (x + y + z) >= 1 && x >= 1) {
				y += 2;
				x -= 1;
			}
			else {
				x = -1, y = -1, z = -1;
				break;
			}
		}
	}

	cout << x << " " << y << " " << z << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<string>
#include<vector>
//#include<string>
//#include<sstream>
using namespace std;

int mod=1e9+7;
int main(){
	int n;
	scanf("%d",&n);
	long long sum,i;
	sum=1;
	for(i=1;i<=n;i++){
		sum*=i;
		sum=sum%mod;
	}
	printf("%lld\n",sum);
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
#define totori signed
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
ll dx[4]={0,1,-1,0};
ll dy[4]={1,0,0,-1};

class UnionFind{
    public:
    //親の番号を格納する。親だった場合は-(その集合のサイズ)
    vector<int> parent;

    UnionFind(int N){
        parent = vector<int>(N,-1);
    }

    int root(int A){
        if(parent[A] < 0) return A;
        return parent[A]=root(parent[A]);
    }

    int size(int A){
        return -parent[root(A)];
    }

    bool unite(int A, int B) {
        A = root(A), B = root(B);
        if(A == B) return false; 

        if(size(A) < size(B)) swap(A,B);
        parent[A] += parent[B];
        parent[B] = A;
        return true;
    }

    bool same(int A, int B){
        return root(A)==root(B);
    } 
};


totori main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    

    string s = "ACL";
    int n;
    cin>>n;
    string ans = "";
    for(int i=0;i<n;i++)ans += s;
    cout << ans << endl;
}

Measured memory_bytes: 3644
//
//  main.cpp
//  cpp_for_aoj
//
//  Created by naotoitoi on 2020/09/26.
//

#include <iostream>
using namespace std;

int main(int argc, const char * argv[]){
    int k;
        cin >> k;
        for(int i =0;i<k;i++){
            cout << "ACL";
        }
    return 0;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    int D;
    cin >> D;
    vector<int> c(26);
    vector<vector<int>> s(D, vector<int>(26));
    rep(i, 26)
    {
        cin >> c[i];
    }
    rep(i, D)
    {
        rep(j, 26)
        {
            cin >> s[i][j];
        }
    }
    vector<int> best(D);
    rep(i, D)
    {
        best[i] = i % 26;
    }
    int best_score = -100000000;
    rep(loop, 100)
    {
        vector<int> schedule = best;
        rep(i, 10)
        {
            int aa = rand() % D;
            int bb = rand() % 26;
            schedule[aa] = bb;
        }
        int score = 0;
        vector<int> lastd(26);
        rep(i, D)
        {
            score += s[i][schedule[i]];
            lastd[schedule[i]] = i + 1;
            rep(j, 26)
            {
                score -= c[j] * (i + 1 - lastd[j]);
            }
        }

        if (score > best_score)
        {
            best = schedule;
            best_score = score;
        }
        //        cout << score << endl;
        // rep(i, D)
        // {
        //     cout << best[i] << endl;
        // }
    }
    rep(i, D)
    {
        cout << best[i] + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef struct Node* NodePointer;

typedef struct Node {
  int key;
  NodePointer next, pre;
} Node;

NodePointer head, last;

NodePointer make_node(int key) {
  NodePointer tmp = malloc(sizeof(Node));
  tmp->next = tmp->pre = NULL;
  tmp->key = key;
  return tmp;
}

void init() {
  head = malloc(sizeof(Node));
  last = malloc(sizeof(Node));
  head->next = last;
  last->pre = head;
}

void insert(NodePointer s, int key) {
  NodePointer node = make_node(key);
  NodePointer t = s->next;
  s->next = node;
  node->pre = s;
  node->next = t;
  t->pre = node;
}

void delete(NodePointer p) {
  NodePointer s = p->pre;
  NodePointer t = p->next;
  s->next = t;
  t->pre = s;
  free(p);
}

int main() {
  int N, num;
  char str[30];
  NodePointer p;
  init();
  scanf(" %d ", &N);
  while(N--) {
    scanf(" %s ", str);
    if(!strcmp(str,"insert")) {
      scanf(" %d ", &num);
      insert(head,num);
    } else if(!strcmp(str,"delete")) {
      scanf(" %d ", &num);
      for(p = head->next; p != last; p = p->next) {
        if(p->key == num) {
          delete(p);
          break;
        }
      }
    } else if(!strcmp(str,"deleteFirst")) {
      delete(head->next);
    } else if(!strcmp(str,"deleteLast")) {
      delete(last->pre);
    }
  }

  for(p = head->next; p != last; p = p->next) {
    printf(p == head->next? "%d":" %d", p->key);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 0
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define LOWER(s)    transform(ALL((s)),(s).begin(),TL<char>)
# define UPPER(s)    transform(ALL((s)),(s).begin(),TU<char>)
# define FOR(i,a,b)  for(LL i=(a);i<(b);i++)
# define RFOR(i,a,b) for(LL i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

string maze[1001];
int h, w;
int sx, sy, gx, gy;

int d[1001][1001];
int bfs() {
	queue<pair<int, int>> que;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			d[i][j] = HINF;
		}
	}
	que.push(pair<int, int>(sx, sy));
	d[sy][sx] = 0;
	while (que.size()) {
		pair<int, int> p = que.front();
		que.pop();
		for (int i = 0; i < 4; i++) {
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (0 <= nx&&nx < w && 0 <= ny&&ny < h &&maze[ny][nx] != 'X'&&d[ny][nx] == HINF) {
				que.push(pair<int, int>(nx, ny));
				d[ny][nx] = d[p.second][p.first] + 1;
			}
		}
	}
	return d[gy][gx];
}
int n;

int main() {
	cin >> h >> w >> n;
	REP(i, h)cin >> maze[i];
	LL ans = 0;
	for (int k = 1; k <= n; k++) {
		REP(i, h)REP(j, w) {
			if (k == 1) {
				if (maze[i][j] == 'S') {
					sx = j, sy = i;
				}
				if (maze[i][j] == '1') {
					gx = j, gy = i;
				}
			}
			else {
				if (maze[i][j] == (char)('0' + k - 1)) {
					sx = j, sy = i;
				}
				if (maze[i][j] == (char)('0' + k)) {
					gx = j, gy = i;
				}
			}
		}
		ans += bfs();
	}
	cout << ans << endl;
}


Measured memory_bytes: 8052
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll N;
    cin >> N;
    vec a(N - 1), b(N - 1), c(N);
    vector<vector<ll>> G(N);
    loop(i, N - 1)
    {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    loop(i, N) cin >> c[i];
    if (N == 1)
    {
        putout(0);
        return 0;
    }
    sort(all(c));
    reverse(all(c));
    vector<ll> nums(N);
    vector<ll> used(N);
    nums[a[0]] = c[0];
    nums[b[0]] = c[1];
    used[0] = true;
    loop(i, N - 2)
    {
        loop(j, N - 1)
        {
            if (used[j])
                continue;
            if (nums[a[j]] > 0 && nums[b[j]] == 0)
            {
                used[j] = true;
                nums[b[j]] = c[i + 2];
                break;
            }
            if (nums[a[j]] == 0 && nums[b[j]] > 0)
            {
                used[j] = true;
                nums[a[j]] = c[i + 2];
                break;
            }
        }
    }
    putout(Sum(c) - c[0]);
    loop(i, N)
    {
        cout << nums[i];
        if (i != N - 1)
            cout << " ";
        else
            putout("");
    }
    return 0;
}

Measured memory_bytes: 4292
Sa = str(input())
Sb = str(input())
Sc = str(input())

A = list(Sa)
B = list(Sb)
C = list(Sc)

Z = len(A) + len(B) + len(C)
turn = 'a'
for i in range(Z):
    if turn == 'a':
        if len(A) == 0:
            print('A')
            break
        else:
            turn = A[0]
            A.pop(0)
            
    elif turn == 'b':
        if len(B) == 0:
            print('B')
            break
        else:
            turn = B[0]
            B.pop(0)
        
    elif turn == 'c':
        if len(C) == 0:
            print('C')
            break
        else:
            turn = C[0]
            C.pop(0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define PAI 3.141592653589
typedef long long ll;

using namespace std;

int main() 
{
  int a, b, c;
  cin >> a >> b >> c;
  double red = c * PAI / 180;
  double cs = sqrt((a * a) + (b * b) - (2 * a * b * cos(red)));
  double h = b * sin(red);
  cout << fixed << setprecision(8) << h * a / 2 << "\n" << fixed << setprecision(7) << a + b + cs << "\n" << fixed << setprecision(8) << h << "\n";
}



Measured memory_bytes: 3460
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	double a, b, x;
	cin >> a >> b >> x;
	x /= a;
	double rad;
	if(x <= a * b / 2) rad = atan2(b * b, 2 * x);
	else rad = atan2(2 * (a * b - x), a * a);
	double ans = rad / (2 * acos(-1)) * 360;
	cout << fixed << setprecision(12) << ans << endl;
	return 0;
}

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

  int main() {
    string S,T;
    cin >> S >> T;
    int count=0;

    for(int i=0; i<3; i++){
      if(S.at(i)==T.at(i))
        count++;
    }

    cout << count << endl;
      
    }


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

const double PI = acos(-1);
const double EPS = 1e-15;
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
const ll MOD1 = 998244353;
typedef pair<int,int> P;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define mp make_pair

void print_tri(int w){
  if(w == 1){
    putchar('+');
  }else{
    print_tri((w + 1) / 3);
    putchar("0+-"[w % 3]);
  }
}

int main(){
  int w;
  scanf("%d", &w);
  print_tri(w);
  putchar('\n');
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()

using namespace std;

void execute()
{
	lint N, K;
	lint ans;
	cin >> N >> K;
	ans = K;
	for (int i = 0; i < N - 1; i++)
	{
		ans *= K - 1;
	}
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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

using namespace std;

int main() {
    string a;
    
    while(getline(cin,a)){
    
    while (1){
        if(a.find("this")!=-1 || a.find("the")!=-1 || a.find("that")!=-1){
            break;
        }
        
        for(int i=0; i<(int)a.length(); i++){
            if(a[i]==' '|| a[i]=='.'){
                
            }else if(a[i]=='z'){
                a[i]='a';
            }else{
                a[i]++;
            }
        }

    }
    cout<<a<<endl;;
    }
    
    return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
const int mod  = 1e9+7;
string grid[1001];
int dp[1001][1001];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int h,w;
  cin >> h >> w;
  h--; w--;
  for(int i=0;i<=h;i++)
    cin >> grid[i];
  for(int i=0;i<=1000;i++)
    for(int j=0;j<=1000;j++)
      dp[i][j] = 0;
  dp[h][w] = 1;

  for(int row = h;row>=0;row--) {
    for(int col=w;col>=0;col--) {
      if (grid[row][col] == '.') {
        dp[row][col] += (dp[row+1][col] + dp[row][col+1])%mod;
        // cerr << row << ' ' << col << '\n';
      }
    }
  }
  // for(int i=0;i<=h;i++) {
  //   for(int j=0;j<=w;j++) {
  //     cerr << dp[i][j] << ' ';
  //   }
  //   cerr << '\n';
  // }
  cout << dp[0][0];
  return 0;
}

Measured memory_bytes: 5248
#include<stdio.h>
int main(void){

  int a,b,c,d,e,i;
  e = 0;
  scanf("%d%d%d",&a,&b,&c);
  for(i = a;i <= b;i++){
    d = c % i;
    if(d == 0){
      e++;
    }else(e == e);
        }
  printf("%d\n",e);
  return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

template <typename T1, typename T2>
bool chmin(T1& a, const T2& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <typename T1, typename T2>
bool chmax(T1& a, const T2& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(const Args&... args) const { print(args...); }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(const T& head, const Tail&... tail) const { std::cout << head, print_rest(tail...); }
        template <class T, class... Tail>
        void print_rest(const T& head, const Tail&... tail) const { std::cout << sep << head, print_rest(tail...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    string S;
    cin >> S;
    ll sum = 0;
    for (auto c : S) {
        sum += c - '0';
    }
    prints()(sum % 9 == 0 ? "Yes" : "No");
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 3764
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cassert>

#include <unordered_set>
#include <unordered_map>
#include <random>
#include <thread>
#include <chrono>

using namespace std;

#define all(c) c.begin(), c.end()
#define repeat(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x) 
#endif

typedef complex<double> point;

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << "{";
    for(auto it = v.begin(); it != v.end(); ++it) {
        if(it != v.begin())
            os << ",";
        os << *it;
    }
    return os << "}";
}

using ll = int64_t;

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

    string s;
    cin >> s;
    int w;
    cin >> w;
    for (int i = 0; i < s.length(); i++){
        if(i % w == 0){
            cout << s[i];
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
int main(int argc,const char*argv[])
{
    int a,b,c,t;
    scanf("%d %d %d",&a,&b,&c);
    
    if(a>b){
        t=a;
        a=b;
        b=t;
    }
    if(b>c){
        t=b;
        b=c;
        c=t;
    }
    if(a>b){
        t=a;
        a=b;
        b=t;
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}

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

#define int long long
#define ci(m)     for(int i=0;i<m;i++)
#define cj(m)     for(int j=0;j<m;j++)
#define ck(m)     for(int k=0;k<m;k++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int32_t main() {
    nitin;
    int s;
    cin>>s;
    cout<<0<<" "<<0<<" ";
    cout<<1000000000<<" "<<1<<" ";
    int p;
    if(s!=1000000000000000000)
    p=(1000000000-s%1000000000);
    else
        p=0;
    int x=p;
    int y=(s+x)/1000000000;
    cout<<x<<" "<<y;
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>

using namespace std;
// using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

#define int ll
#define all(v) v.begin(), v.end()
#define len(v) (int)(v).size()
#define pii pair<int, int>
#define pb push_back
#define kek pop_back

// template<class t>
// using oset = tree<t, null_type, less<t>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template<class t1, class t2>
bool cmax(t1 &a, const t2 &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template<class t1, class t2>
bool cmin(t1 &a, const t2 &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

void UseFiles(const string &s) {
#ifndef LOCAL
	freopen((s + ".in").c_str(), "r", stdin);
	freopen((s + ".out").c_str(), "w", stdout);
#endif
}

void run();

signed main() {
	iostream::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	run();
}

void run() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(a + b + 1, c) + b << endl;
}

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

using namespace std;

using int64 = long long;

int main() {
  string S;
  int64 K;
  cin >> S >> K;
  for(int i = 0; i < S.size(); i++) {
    if(S[i] == '1') --K;
    else K = 0;
    if(K == 0) {
      cout << S[i] << endl;
      return 0;
    }
  }
}







Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()

def MIN(a, b):
    if a > b:
        return b
    else:
        return a

def main():
    N = int(input())
    yen6 = [6 ** i for i in range(1, 7) if 6 ** i <= N]
    yen9 = [9 ** i for i in range(1, 6) if 9 ** i <= N]

    if N < 6:
        print(N)
        exit()

    dp = [N] * (N + 1)
    for i in range(6):
        dp[i] = i
    for i in range(N + 1):
        for j in yen6:
            if i + j > N:
                break
            dp[i+j] = MIN(dp[i+j], dp[i] + 1)
        for j in yen9:
            if i + j > N:
                break
            dp[i+j] = MIN(dp[i+j], dp[i] + 1)
    print(dp[N])

if __name__ == '__main__':
    main()


Measured memory_bytes: 41712
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        if(a < b){
            if(b < c){
                System.out.printf("%d %d %d\n",a,b,c);
            }else{
                if(a < c){
                    System.out.printf("%d %d %d\n",a,c,b);
                }else{
                    System.out.printf("%d %d %d\n",c,a,b);
                }
            }
        }else{
            if(a < c){
                System.out.printf("%d %d %d\n",b,a,c);
            }else{
                if(b < c){
                    System.out.printf("%d %d %d\n",b,c,a);
                }else{
                    System.out.printf("%d %d %d\n",c,b,a);
                }
            }
        }
    }
}


Measured memory_bytes: 26148
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
use std::cmp::max;
fn main() {
    input!{
        n: i32,
    }
    let mut ans = 0;
    for i in 1..n + 1 {
        if i.to_string().len() % 2 == 1 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define int long long int  //comment for large arrays
#define pll pair<int,int>
#define dbl long double
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define eps 0.00000001
#define INF 10000000000000001
#define all(x) (x).begin(),(x).end()
#define LB(v,x) (lower_bound(all(v),x) - v.begin()) 
#define UB(v,x) (upper_bound(all(v),x) - v.begin())
#define size(x) (int)(x).size()
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define popb() pop_back()
#define popf() pop_front()
#define mp(x,y) make_pair((x),(y))
#define vec(dt) vector<dt>
#define vv(dt) vector<vector<dt>>
#define fastio(x) ios_base::sync_with_stdio(x); cin.tie(NULL)
#define init(v,s) memset(v,s,sizeof(v)) 
#define bug(x) cerr<<"LINE: "<<__LINE__<<" || click to see test details "<<#x<<" = "<<x<<endl
#define loop(i,s,n) for(int i=s;i<n;i++)
#define print(v) for(auto it:v) cout<<it<<" "; cout<<endl 
using namespace std;


signed main()
{
	fastio(0);
	int n;
	cin>>n;
	vec(int) dp(1<<n,0),a[n];
	loop(i,0,n) loop(j,0,n) 
	{
		int x;
		cin>>x;
		if(x==1) a[i].pb(j);
	}
	dp[0] = 1;
	loop(mask,0,(1<<n) - 1)
		for(auto j:a[__builtin_popcount(mask)])
			if((mask & (1<<j))==0)
				dp[mask + (1<<j)] = (dp[mask + (1<<j)] + dp[mask])%mod;
	cout<<dp[(1<<n)-1]<<endl;
	return 0;		
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main(){
	ll a,b,c;
	cin >> a >> b >> c;
	cout << (c-a-b>=0 && 4*a*b<(c-a-b)*(c-a-b) ? "Yes" : "No")<< endl;
	return 0;
}

Measured memory_bytes: 256
//package AtCoderRecommendations;
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 
 
	public static void main(String[] args) {  
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		boolean[] vis = new boolean[N+1];
		int ans = 0;
		int cur = 1; //Current button
		int[] a = new int[N+1];
		for (int i = 1; i <= N; i++) a[i]=I.nextInt();
		while (true) {
			if (vis[cur]) { //If infinite cycle exists
				ans=-1;
				break;
			}
			vis[cur]=true;
			cur=a[cur];
			ans++;
			if (cur==2) break;
		}
		O.pln(ans);
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
	}
}



Measured memory_bytes: 40204
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = list(input())

for i in range(k,n):
    if t[i]==t[i-k]:
        t[i]=''
ans = t.count('r')*p+t.count('s')*r+t.count('p')*s
print(ans)

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

int main()
{
	int N, T, A;
	cin >> N >> T >> A;

	vector<int> H;
	for (int i = 0; i < N; ++i) {
		int tmp;
		cin >> tmp;
		H.push_back(tmp);
	}

	double avg_temp = T - H[0] * 0.006;
	int index = 0;

	for (int i = 1; i < H.size(); ++i) {
		double curr_avg_temp = T - H[i] * 0.006;
		if (fabs(avg_temp - A) > fabs(curr_avg_temp - A)) {
			avg_temp = curr_avg_temp;
			index = i;
		}
	}

	cout << index + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm> 

using namespace std;

static const int MAX = 200000;

int main(int argc, char** argv) {
	
	int n;
	int r[MAX];
	int i;
	int maxv, minv;
	
	maxv = -2000000000;
	
	cin >> n;
	
	for (i = 0; i < n; i++)
		cin >> r[i];
		
	minv = r[0];
		
	for (i = 1; i < n; i++) {
		maxv = max(maxv, r[i] - minv);
		minv = min(minv, r[i]);
	}
	
	cout << maxv << endl;
	
	return 0;
}

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

int main() {
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  if (A+B<C+D)
    cout<<"Right"<<endl;
  if (A+B==C+D)
    cout<<"Balanced"<<endl;
  if (A+B>C+D)
    cout<<"Left"<<endl;
  
}


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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

int main()
{
	int n ;
	cin >> n ;
	vector<int> a(n);
	rep(i,n) cin >>a[i];
	ll ans = 0 ;
	rep(i,n){
		if(i == n-1){
			ans += a[i] / 2 ;
		} else {
			int low = a[i] ;
			int high = a[i+1];
			ans += low / 2 ;
			if(low % 2 == 1 && high){
				ans ++ ;
				a[i+1] -- ;
			}
		}
	}
	cout << ans << endl;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
#define _all(arg) begin(arg),end(arg)

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

using namespace std;

string conv(string s) {
	string chars = "aiueo";
	string res = "";
	res += s[0];
	rep(i,s.size()) {
		if(chars.find(s[i]) != string::npos) {
			if(i+1<s.size()) res += s[i+1];
		}
	}
	return res;
}

int main(void){
	int n;
	while(cin>>n,n) {
		vector<string> s(n);
		rep(i,n) {
			string tmp; cin>>tmp;
			s[i] = conv(tmp);
		}
		bool flag = false;
		rep(i,1,101) {
			set<string> tmp;
			for(string _s: s) {
				tmp.insert(_s.substr(0,i));
			}
			if(tmp.size() == s.size()) {
				cout << i << endl;
				flag = true;
				break;
			}
		}
		if(!flag)
			cout << -1 << endl;
	}
        
	return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000
vector<vector<int>> E;

int dfs(int now,int p){
	int odd = 0;
	for(int i=0;i<E[now].size();i++){
		int to = E[now][i];
		if(to==p)continue;
		int x = dfs(to,now);
		if(x==-1)return -1;
		odd+=x;
	}
	if(odd>1)return -1;
	return odd^1;
}


int main(){
	
	int N;
	cin>>N;
	
	E.resize(N,vector<int>());
	
	for(int i=0;i<N-1;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		E[a].push_back(b);
		E[b].push_back(a);
	}
	
	int t = dfs(0,-1);

	if(t==0)cout<<"Second"<<endl;
	else cout<<"First"<<endl;

	
	return 0;
}

Measured memory_bytes: 8792
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>

// Union Find
template<class T=int>
class UnionFind
{
    std::vector<T> p;
    std::vector<T> r;
    T find(const T x)
    {
        if(x==p[x]) return x;
        return p[x]=find(p[x]);
    }
    void unite_(T x, T y)
    {
        if(x==y) return;
        if(r[x]>r[y]) std::swap(x,y);
        else if(r[x]==r[y]) ++r[y];
        p[x]=y;
    }
public:
    explicit UnionFind(const T n):p(n),r(n,0)
    {
        for(T i=0; i<n; ++i)
            p[i]=i;
    }
    bool same(const T x, const T y)
    {
        // assert(0<=x && x<p.size())
        // assert(0<=y && y<p.size())
        return find(x)==find(y);
    }
    void unite(const T x, const T y)
    {
        // assert(0<=x && x<p.size())
        // assert(0<=y && y<p.size())
        unite_(find(x),find(y));
    }
};

// Kruskal's algorithm
template<class T, class U>
T& kruskal(T& edges, U max_v)
{
    typedef typename T::value_type Edge;
    std::sort(edges.begin(),edges.end());
    UnionFind<U> uf(max_v);
    edges.erase(
        std::remove_if(edges.begin(),edges.end(),
            [&uf](const Edge& e){
                const auto& a = std::get<1>(e);
                const auto& b = std::get<2>(e);
                if(uf.same(a,b)) return true;
                uf.unite(a,b);
                return false;
            }),
        edges.end());
    return edges;
}

int main()
{
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    for(int n,m; (std::cin >> n >> m) && n; )
    {
        typedef std::tuple<int,int,int> T;
        std::vector<T> edges(m);
        for(auto& v: edges)
        {
            int a,b,d; char c; std::cin >> a >> c >> b >> c >> d;
            v = T(d,a,b);
        }
        int c=0;
        for(auto& e: kruskal(edges, n))
            c+=std::get<0>(e)/100-1;
        std::cout << c << "\n";
    }
}

Measured memory_bytes: 1268
#include<stdio.h>
#include<stdlib.h>
#define N 1000000
int cnt=0,n,l,A[N],*S;
 
void insertionSort(int A[], int n, int m){
int i,v,j;
  for(i=m;i<n;i++){
    v=A[i];
    j=i-m;
    while(j>=0&&A[j]>v){
      A[j+m]=A[j];
      j-=m;
      cnt++;
    }
    A[j+m]=v;
  }
}
 
void Sort(int A[],int n){
  int i=0,a;
 
S=(int *)malloc(n * sizeof(int));
 
for(a=1; ; ){
if(a>n) break;
S[i]=a;
i++;
  a=3*a+1;
}
l=i;
  for(i=l-1;i>=0;i--){
    insertionSort(A,n,S[i]);
  }
}
 
 
 
int main(){
int i;
scanf("%d",&n);
for(i=0;i<n;i++) scanf("%d",&A[i]);
cnt=0;
 
Sort(A,n);
 
printf("%d\n",l);
 
for(i=l-1;i>=0;i--){
printf("%d",S[i]);
if(i) printf(" ");
}
printf("\n");
printf("%d\n",cnt);
for(i=0;i<n;i++)printf("%d\n",A[i]);
 
 free(S);
  return 0;
}



Measured memory_bytes: 5668
#include<iostream>

using namespace std;

int main() {
	int k, a, b;
	cin >> k >> a >> b;
	int i;
	int ans;
	for (i = a; i <= b; i++) {
		ans = i % k;
		if (ans == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;

	return 0;

}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i = 0;i < (n); ++i)
#define all(v) v.begin(),v.end()
#define sort(v) sort(v.begin(),v.end())
#define SORT(v) sort(v.begin(),v.end(),greater<ll>())
typedef long long ll;
typedef long double la;
using namespace std;

int fm(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    vector<int> b;
    rep(i,n){
        cin >> x[i] >> y[i];
        b.pb(i);
    }
    double sum = 0.0;
    do {
        rep(i,n-1){
            sum += sqrt((x[b[i]]-x[b[i+1]])*(x[b[i]]-x[b[i+1]])+(y[b[i]]-y[b[i+1]])*(y[b[i]]-y[b[i+1]]));
        }
    }while(next_permutation(all(b)));
    
    cout << setprecision(10) << sum/fm(n) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <algorithm>
#include <cctype>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
typedef pair<double,double> pdd;
const int inf=1<<30;
const double pi=acos(-1);
const double eps=1e-8;

struct point{
	double x,y;
	point operator+(point Gep){
		return point{x+Gep.x,y+Gep.y};
	}
	point operator-(point Gep){
		return point{x-Gep.x,y-Gep.y};
	}
	point operator*(double Gex){
		return point{x*Gex,y*Gex};
	}
	point operator/(double Gex){
		if(!Gex) return point{0,0}; 
		return point{x/Gex,y/Gex};
	}
	bool operator==(point Gep){
		return fabs(x-Gep.x)<eps&&fabs(y-Gep.y)<eps;
	}
};
class Geom{
	public:
	vector<point> Ge;
	vector<pair<point,point> > Geseg,Geline;
	void line_push(point Gex,point Gey){
		Geline.push_back(make_pair(Gex,Gey));
	}
	pdd POI(pdd Gea,pdd Geb,pdd Gec,pdd Ged){
		return pdd(3,4);
	}
	double IP(point Gex,point Gey){
		return Gex.x*Gey.x+Gex.y*Gey.y;
	}
	double LEN(point Gex){
		return sqrt(Gex.x*Gex.x+Gex.y*Gex.y);
	}
	point PRO(pair<point,point> Gea,point Gex){
		point Ge1=Gex-Gea.second,Ge2=Gea.first-Gea.second;
		return Ge2*(IP(Ge1,Ge2)/(LEN(Ge2)*LEN(Ge2)))+Gea.second;
	}
	pair<point,point> line_open(int Gex){
		return Geline[Gex];
	}
};

int q;
double x,xx,y,yy,xxx,yyy;

int main(){
	cout<<shosu(10);
	cin>>x>>y>>xx>>yy>>q;
	for(int i=0;i<q;i++){
		cin>>xxx>>yyy;
		Geom geo;
		geo.line_push(point{x,y},point{xx,yy});
		point ans=geo.PRO(geo.line_open(0),point{xxx,yyy});
		cout<<ans.x<<' '<<ans.y<<endl;
	}
}

Measured memory_bytes: 1300
N=int(input())
S=list(map(int, input().split()))
#print(S)

TOTAL=sum(S)
DD=[]
DDD=[]
for ii in range(1,N+1):
  SS=sum(S[:ii])
  SSS=abs(SS-(TOTAL-SS))
  DD.append(SS)
  DDD.append(SSS)
  
#print(DD)
#print(DDD)
print(min(DDD))

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    
    static int memo[5000][5000];
    int ans = 0;
    for(int j=n-1;j>=0;--j){
        for(int i=j-1;i>=0;--i){
            if(s[i] != s[j]){
                memo[i][j] = 0;
                continue;
            }
            if(j==n-1){
                memo[i][j] = 1;
                ans = max(ans, 1);
                continue;
            }
            memo[i][j] = 1 + memo[i+1][j+1];
            ans = max(ans, min(j-i, memo[i][j]));
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 96768
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
//constexpr long long MOD = 1000000007LL;
constexpr long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int N,M;
string S;
vector<vector<int>> G;
int seen[401010];
bool ans = 0;
void dfs(int v) {
    seen[v] = 1;
    for (auto nv : G[v]) {
        if (seen[nv]==2) continue;
        if (seen[nv]==1) {
            ans = 1;
            continue;
        }
        dfs(nv);
    }
    seen[v] = 2;
}
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    cin >> N >> M;
    cin >> S;
    G.resize(N*2);
    rep(i,M) {
        int u,v; cin >> u >> v;
        --u; --v;
        if (S[u]==S[v]) {
            G[u].emplace_back(v+N);
            G[v].emplace_back(u+N);
        } else {
            G[u+N].emplace_back(v);
            G[v+N].emplace_back(u);
        } 
    }
    rep(i,N*2) {
        if (seen[i]) continue;
        dfs(i);
    }

    cout << (ans ? "Yes" : "No") << ln;
}

Measured memory_bytes: 21328
char*p,E[200];l;M(r){for(r=T();;){if(*p==42){p++;r*=T();}else if(*p==47){p++;r/=T();}else return r;}}A(r){for(r=M();;){if(*p==43){p++;r+=M();}else if(*p==45){p++;r-=M();}else return r;}}T(r){if(*p==40){p++;r=A();p++;}else{sscanf(p,"%d%n",&r,&l);p+=l;}return r;}main(){scanf("%*d\n");for(;~scanf("%[^=]=\n",E);)printf("%d\n",A(p=E));}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
signed main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int s,g=0;
  for(int i=0;i<10;i++){
    cin>>s;
    g+=s;
  }
  cout<<g<<'\n';
  return(0);
}



Measured memory_bytes: 3128
#include <stdio.h>

int main(void) {
    int a, b, c;
    while(~scanf("%d %d", &a, &b)) {
        c = euclid(a > b ? a : b, a < b ? a : b);
        printf("%d %lld\n", c, (long long)a * b / c);
    }
    return 0;
}

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

Measured memory_bytes: 596
n=int(input())
l=[]

for i in range(n):
  t=int(input())
  l.append(t)
# print(l)

def lcm(a,b):#最小公倍数
  ori_a=a
  ori_b=b
  while b!=0:
      a,b=b,a%b
  return (ori_a*ori_b)//a
  

ans=1
for i in l:
  ans=lcm(ans,i)

print(ans)

Measured memory_bytes: 9164
#include <iostream>
#include <vector>
#include <string>

using  namespace std;

int main(){
  int N; cin>>N;
  string S; cin>>S;
  vector<int> count(N+1,0);

  for(int i=1;i<=N;i++){
    if(S[i-1]=='I'){
      count[i]=count[i-1]+1;
    }
    else if(S[i-1]=='D'){
      count[i]=count[i-1]-1;
    }
  }

  int num=0;

  for(int i=0;i<=N;i++){
    num=(num<count[i]?count[i]:num);
  }

  cout<<num<<endl;

  return 0;
}


Measured memory_bytes: 256