akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

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

	vector<ll> a(A);
	vector<ll> b(B);
	vector<ll> x(M);
	vector<ll> y(M);
	vector<ll> c(M);

	for (size_t i = 0; i < A; i++)
	{
		cin>>a.at(i);
	}

	for (size_t i = 0; i < B; i++)
	{
		cin>>b.at(i);
	}

	ll res = INF;

	for (size_t i = 0; i < M; i++)
	{
		cin>>x.at(i)>>y.at(i)>>c.at(i);
	}

	for (size_t i = 0; i < M; i++)
	{
		res = min(res,a.at(x.at(i)-1)+b.at(y.at(i)-1)-c.at(i));
	}
	

	sort(all(a));
	sort(all(b));

	cout<<min(res,a.at(0)+b.at(0));
	
	
	
}


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

using namespace std;

int main() {
  int x[3000], y[3000];
  int i;
  for (i = 0; ; i++) {
    cin >> x[i] >> y[i];
    if (x[i] == 0 && y[i] == 0) {
      break;
    }
  }
  for (int j = 0; j < i; j++) {
    if (x[j] > y[j]) {
      swap(x[j], y[j]);
    }
  }
  for (int j = 0; j < i; j++) {
    cout << x[j] << " " << y[j] << endl;
  }
}


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

using namespace std;
using ll = long long int;
using ullong = unsigned long long;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define int ll
int INF = 1e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
typedef pair<int, int> Vec2;
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

signed main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	FOR(i, 1, 10) {
		FOR(j, 1, 10) {
			if (i * j == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
    while(1){
        int i, j, k, n, x;
        long ans=0;
        scanf(" %d %d", &n, &x);
        if(n==0) break;
         
        for(i=1; i<=n-2; ++i){
            for(j=i+1; j<=n-1; ++j){
                for(k=j+1; k<=n; ++k){
                    if(i+j+k==x) {
                        ++ans;
                        break;
                    }
                }
            }
        }
     
        printf("%ld\n", ans);
    }
 
    return 0;
}


Measured memory_bytes: 2088
n,T=[int(i) for i in input().split()]
t=[int(i) for i in input().split()]

ans=0
for i in range(n-1):
    start=t[i]
    end=start+T
    if(end>t[i+1]):
        ans+=t[i+1]-t[i]
    else:
        ans+=T
ans+=T
print(ans)

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

int main() {
    int n;
    cin >> n;
    int ans = 0, mx = 0;
    rep(i,n) {
      int h;
      cin >> h;
      if (h >= mx) {
        ans++;
        mx = h;
      }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

double m[50000];

int main() {
    int N;
    cin >> N;
    vector<double> t, v;
    vin(t, N);
    vin(v, N);
    rep(i, 50000) {
        m[i] = 1e8;
    }
    int sum = 0;
    rep(i, N) {
        t[i] *= 2;
        for (int j = sum; j <= sum + t[i]; ++j) {
            m[j] = min(m[j], v[i]);
        }
        sum += t[i];
    }
    m[0] = m[sum] = 0;
    rep(i, sum) {
        m[i + 1] = min(m[i + 1], m[i] + 0.5);
    }
    for (int i = sum - 1; i >= 0; --i) {
        m[i] = min(m[i], m[i + 1] + 0.5);
    }
    double S = 0;
    rep(i, sum) {
        S += m[i] + m[i + 1];
    }
    printf("%.12lf\n", (S / 2.0) / 2.0);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int H, W;
    cin >> H >> W;
    auto A = make_v<char>(W, H);
    rep(y, H)
    {
        rep(x, W)
        {
            cin >> A[x][y];
        }
    }
    pair<int, int> pos = {0, 0};
    A[0][0] = '.';
    int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
    while (pos != pair<int, int>{W - 1, H - 1})
    {
        int x = pos.first, y = pos.second;
        set<int> ok;
        for (int i = 0; i < 4; i++)
        {
            int newx = x + dx[i], newy = y + dy[i];
            if (newx < W and newx >= 0 and newy < H and newy >= 0 and A[newx][newy] == '#')
            {
                if (i == 0 or i == 1)
                {
                    ok.insert(i);
                }
                else
                {
                    cout << "Impossible" << endl;
                    return 0;
                }
            }
        }
        if (ok.size() != 1)
        {
            cout << "Impossible" << endl;
            return 0;
        }
        else
        {
            int idx = *ok.begin();
            pos = {x + dx[idx], y + dy[idx]};
            A[pos.first][pos.second] = '.';
        }
    }
    rep(x,W)
    {
        rep(y,H)
        {
            if(A[x][y]=='#')
            {
            cout << "Impossible" << endl;
            return 0;
            }
        }
    }
    cout<<"Possible"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

#define MAX_H 1000
#define MAX_W 1000


int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
    int A[3][3], N;
    bool field[3][3];

    for(int i = 0 ; i < 3 ; i++){
      for(int j = 0 ; j < 3 ; j++){
        field[i][j] = false;
        cin >> A[i][j];
      }
    }
	cin >> N;
    for(int i = 0 ; i < N ; i++){
      int B;  cin >> B;
      for(int j = 0 ; j < 3; j++)
        for(int k = 0 ; k < 3 ; k++)
          if(A[j][k] == B)  field[j][k] = true;
    }

    for(int i = 0 ; i < 3 ; i++){
      bool flag = true;
      for(int j = 0 ; j < 3 ; j++)
        if(field[i][j] == false){  flag = false;  break;  }

      if(flag){  cout << "Yes" << endl;  return 0;  }
    }

    for(int i = 0 ; i < 3 ; i++){
      bool flag = true;
      for(int j = 0 ; j < 3 ; j++)
        if(field[j][i] == false){  flag = false;  break;  }

      if(flag){  cout << "Yes" << endl;  return 0;  }
    }
    
    bool flag = true;
    for(int i = 0 ; i < 3 ; i++){
      if(field[i][i] == false){  flag = false;  break;  }
    }

    if(flag){  cout << "Yes" << endl;  return 0;  }

    flag = true;
    for(int i = 0 ; i < 3 ; i++){
      if(field[i][2 - i] == false){  flag = false;  break;  }
    }

    if(flag){  cout << "Yes" << endl;  return 0;  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll N = 103000;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    998244353;
vector<ll> pd;
ll k;
deque<ll > dq;
ll arr[N];
int main()
{  fast cin>>k;
 for(ll i=0;i<N;i++)
 arr[i]=1e15;
 arr[1]=1;
 dq.push_back(1);
 while(!dq.empty())
 {
 	ll x=dq.front();
 	dq.pop_front();
 	if(arr[(x*10)%k]>arr[x%k])
 	arr[(x*10)%k]=arr[x%k],dq.push_back((x*10)%k);
 	if(arr[(x+1)%k]>arr[x]+1)
 	{
 		arr[(x+1)%k]=arr[x]+1;
 		dq.push_back((x+1)%k);
	 }
 }
 cout<<arr[0];

}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int MAXN = 2e5 + 1000;
int p[MAXN];
VI e[MAXN];
int out[MAXN];
int a[MAXN];

int mex(VI &vec) {
	sort(ALL(vec));
	if(SZ(vec) == 0 || vec[0] > 0)
		return 0;
	for(int i = 1; i < SZ(vec); i++)
		if(vec[i - 1] < vec[i] - 1)
			return vec[i - 1] + 1;
	return vec.back() + 1;
}
int v_mex(int v, bool es = false) {
	VI tmp;
	for(int u : e[v]) {
		if(es && out[u] > 0) continue;
		tmp.PB(a[u]);
	}
	return mex(tmp);
}

int main() {
	int N;
	scanf("%d", &N);
	for(int i = 1; i <= N; i++) {
		scanf("%d", &p[i]);
		e[p[i]].PB(i);
		out[p[i]]++;
	}
	VI nxt, tmp;
	for(int i = 1; i <= N; i++)
		if(out[i] == 0)
			nxt.PB(i);
	while(SZ(nxt) > 0) {
		int v = nxt.back(); nxt.pop_back();
		a[v] = v_mex(v);
		out[p[v]]--;
		if(out[p[v]] == 0)
			nxt.PB(p[v]);
	}

	int tar = 0;
	for(int i = 1; i <= N; i++)
		if(out[i] > 0) {
			tar = i;
			break;
		}
	int x;
	x = v_mex(tar, true);

	a[tar] = x;
	int v = p[tar];
	while(v != tar) {
		a[v] = v_mex(v);
		debug("a[%d] = %d\n", v, a[v]);
		v = p[v];
	}
	if(v_mex(tar) == a[tar]) {
		debug("hi 1\n");
		puts("POSSIBLE");
		return 0;
	}

	for(int i = 1; i <= N; i++)
		if(out[i] > 0 && p[i] == tar)
			a[i] = x;
	a[tar] = v_mex(tar);
	v = p[tar];
	while(v != tar) {
		a[v] = v_mex(v);
		v = p[v];
	}
	if(v_mex(tar) == a[tar]) {
		debug("hi 2\n");
		puts("POSSIBLE");
		return 0;
	}
	puts("IMPOSSIBLE");
	return 0;
}


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

struct node{
	unsigned int key;
	struct node *next;
	struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch( int key )
{
	NodePointer cur = nil->next;
	while( cur != nil && cur->key != key ) {
		cur = cur->next;
	}
	return cur;
}

void init( )
{
	nil = malloc( sizeof(struct node) );
	nil->next = nil;
	nil->prev = nil;
}

void printList( )
{
	NodePointer cur = nil->next;
	int isf = 1;
	while( cur != nil ) {
		if( isf == 0) { printf(" "); }
		printf( "%d", cur->key );
		cur = cur->next;
		isf = 0;
	}
	printf("\n");
}

void deleteNode( NodePointer t )
{
	NodePointer pt = t->prev;
	NodePointer nt = t->next;
	pt->next = nt;
	nt->prev = pt;
	free( t );
}

void deleteFirst( )
{
	NodePointer t = nil->next;
	if( t == nil ) return;
	deleteNode( t );
}

void deleteLast( )
{
	NodePointer t = nil->prev;
	if( t == nil ) return;
	deleteNode( t );
}

void delete( int key )
{
	NodePointer t = listSearch( key );
	if( t == nil ) return;
	deleteNode( t );
}

void insert( int key )
{
	NodePointer x;
	x = malloc( sizeof(struct node) );
	x->key = key;
	x->next = nil->next;
	x->next->prev = x;
	x->prev = nil;
	nil->next = x;
}


int main( int argc, char *argv[] ) 
{
	int key, n, i;
	char com[20];
	
	scanf( "%d", &n );
	init( );
	for( i = 0; i < n; i++ ) {
		scanf( "%s%d", com, &key );
		if( com[0] == 'i' ) {
			insert( key ); 
		} else if( com[0] == 'd' ) {
			if( 6 < strlen( com )  ) {
				if( com[6] == 'F' ) { 
					deleteFirst( );
				} else if( com[6] == 'L' ) {
					deleteLast( );
				}
			} else {
				delete( key );
			}
		}
	}
	printList( );
	
    return 0;
}

Measured memory_bytes: 31788
#include<stdio.h>
#include<math.h>
int main(void)
{
	int k[1000][3],ct;
	int mem;
	scanf("%d",&ct);
	for(int f1=0;f1<ct;f1++){
		scanf("%d %d %d",&k[f1][0],&k[f1][1],&k[f1][2]);
	}
	for(int f=0;f<ct;f++){
		for(int f1=0;f1<3;f1++){
			for(int f2=0;f2<3;f2++){
				if(k[f][f1]>k[f][f2]){
					mem=k[f][f1];
					k[f][f1]=k[f][f2];
					k[f][f2]=mem;
				}
			}
		}
	}
	for(int f1=0;f1<ct;f1++){
		if(pow((double)k[f1][0],2)==pow((double)k[f1][1],2)+pow((double)k[f1][2],2)){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1020
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

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

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// How to use 「map」
/*
  - 宣言
    map<{key_type}, {value_type}> salary;
  - 要素の挿入
    salary["Alice"] = 1000;
  - 要素の取得 O(logn)
    salary.at("Alice");
  - 要素の削除
    salary.erase("Alice");
  - キー検索
    salary.find("Alice"); -> true
    salary.find("Bob");   -> false
  - イテレーション
    for(auto& [key, value] : salary) {...}
 */
// -------------------------------------


// How to use 「lower_bound」, 「upper_bound」
/*
  vector<int> a = {1, 2, 3, 4, 5};
  auto iter1 = lower_bound(all(a), 3);  <- 第二引数「以上」の最小イテレータが返る
  auto iter2 = upper_bound(all(a), 3);  <- 第二引数「より大きい」最小のイテレータが返る
 */
// -------------------------------------


// How to use 「struct sort」
/*
  struct Person {
    string name;
    int age;

    Person(string _name, int _age) {
      name = _name;
      age = _age;
    }

    bool operator<(const Person &another) const {
      return age < another.age;
    }
  };

  vector<Person> people;
  people.pb(Person("Alice", 20));
  people.pb(Person("Bob", 19));
  people.pb(Person("John", 40));
  people.pb(Person("Chris", 30));
  sort(all(people));
 */
 // -------------------------------------

// -------------------------------------------------------------------------------------



int main() {
  ll n, k;

  cin >> n >> k;

  vector<ll> h(n);
  rep(i, n) {
    cin >> h[i];
  }

  sort(all(h));

  ll ans = 0;
  for (ll i = 0; i < n-k; i++) {
    ans += h[i];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1792
#include <cstdio>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)

const int N_MAX = 100000;

int N, L;
int a[N_MAX];

void solve() {
  REP(i, N - 1) {
    if (a[i] + a[i + 1] < L) continue;
    puts("Possible");
    for (int j = 1; j <= i; j++) printf("%d\n", j);
    for (int j = N - 1; j >= i + 2; j--) printf("%d\n", j);
    printf("%d\n", i + 1);
    return;
  }
  puts("Impossible");
}

void input() {
  scanf("%d%d", &N, &L);
  REP(i, N) scanf("%d", a + i);
}

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


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define repl(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    string s;
    cin >> s;
    ll res = 0;
    rep(i,s.length()-1){
        if(s[i] != s[i+1])res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cctype>
#include <utility>
#include <array>
#include <vector>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	array<vector<int>, 5> a;
	for (int H; (H = in());) {
		int s = 0, t;
		for (auto &x: a)
			x.resize(H);
		while (H--)
			for (auto &x: a)
				x[H] = in();
		do {
			t = 0;
			for (size_t i = 0; i < a[2].size(); i++) {
				int u = a[2][i], c = 1;
				auto all = [&](auto f) {
					auto each = [&](array<int, 2> b) {
						for (auto j: b)
							if (a[j][i] == u)
								f(j);
							else
								break;
					};
					each({1, 0});
					each({3, 4});
				};
				all([&c](...) {c++;});
				if (c >= 3) {
					t += u;
					a[2][i] = 0;
					all([&](int j) {a[j][i] = 0, t += u;});
				}
			}
			for (auto &x: a)
				x.erase(remove(x.begin(), x.end(), 0), x.end());
			s += t;
		} while(t);
		outl(s);
	}
}


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

using namespace std;

using ll = long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    map<string,int> m;
    string s,t;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    m[s]+=a;
    m[t]+=b;
    string u;cin>>u;
    m[u]--;
    cout << m[s] << " " << m[t] << endl;
    return 0;
}

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

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

    int sum = 0;
    int num = 0;
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        sum = 0;
        num = i;
        while (num !=0) {
            sum += num % 10;
            num /=10;
        }

        if (sum >= A && sum <= B) {
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int inf = int (1e9) + int (1e5);
const ll infl = ll (2e18) + ll (1e10);
const ui M=1E9+7;
const double eps = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);i++)
#define FOR(i,x,y) for(int i = (x) ; i < (y) ; ++i)

int main()
{
    std::ios_base::sync_with_stdio (false);
   // freopen ("in.txt", "r", stdin);
    int N;
    cin >> N;
    cout << "ABC" << N;
    return 0;
}


Measured memory_bytes: 256
import math
A,B,H,M =  (int(x) for x in input().split())
h = 360*H/12 + 30*M/60
m = 360*M/60
c = abs(h-m)
if(c > 180):
    c = 360 - c
C = A**2 + B**2 - 2*A*B*math.cos(math.radians(c))
if c != 180 and c != 0:
    print(math.sqrt(C))
elif c == 180:
    print(A+B)
else:
    print(abs(A-B))

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

typedef vector<int> vi;  
typedef pair<int,int> ii;  
typedef vector<ii> vii;  
typedef list<int> li;  
typedef unordered_map<int,int> mii;

#define int long long
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); i++)  
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rap(i,a,n) for (int i = a; i < (n); i++) 
#define rrap(i,n,a) for (int i = (n)-1; i >= a; i--) 
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807

vi a,b,c,va,vb,vc;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,aa,bb,cc;
    cin >> n;
    a.assign(n,LL_MAX);
    b.assign(n,LL_MAX);
    c.assign(n,LL_MAX);

    rep(i,n) {
        cin >> aa >> bb >> cc;
        va.push_back(aa);
        vb.push_back(bb);
        vc.push_back(cc);
    }

    a[0] = va[0];
    b[0] = vb[0];
    c[0] = vc[0];

    rap(i,1,n) {
        a[i] = max(b[i-1] + va[i], c[i-1] + va[i]);
        b[i] = max(a[i-1] + vb[i], c[i-1] + vb[i]);
        c[i] = max(a[i-1] + vc[i], b[i-1] + vc[i]);
    }

    cout << max(a[n-1],max(b[n-1],c[n-1])) << '\n';
    

    return 0;

    //compile: g++ -std=c++14 -O2 -Wall NAME.cpp -o NAME
}

Measured memory_bytes: 2924
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if(N%2==0){
			System.out.println(N/2);
		}else{
			System.out.println(N/2+1);
		}
	}
}


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

namespace _20190308_07 {
    class Program {
        static void Main(string[] args) {
            var n = int.Parse(Console.ReadLine());
            var line = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var a = GCD(line[0], line[1]);
            for (int i = 2; i < n; i++) {
                a = GCD(a, line[i]);
            }
            Console.WriteLine(a);
        }

        static long GCD(long a, long b) {
            if (a < b)
                GCD(b, a);
            while (b != 0) {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }

    }
}


Measured memory_bytes: 22368
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Data.Int
import Data.Foldable
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B

solve :: Int -> VU.Vector Int16 -> Int32
solve n hs = fst dp
 where
  -- dp[i]: minimal cost of moving from 1st to i-th place
  dp :: (Int32, Int32)
  dp = VU.foldl'
    (\(!dp1, !dp2) (!i, !v) -> if i == 0
      then (0, dp1)
      else if i == 1
        then (dp1 + abs (fromIntegral $ v - hs VU.! 0), dp1)
        else
          ( min (dp1 + abs (fromIntegral $ v - hs VU.! (i - 1)))
                (dp2 + abs (fromIntegral $ v - hs VU.! (i - 2)))
          , dp1
          )
    )
    (-1, -1)
    (VU.indexed hs)

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  n  <- (\vec -> (vec VU.! 0)) . VU.unfoldrN 1 readInt <$> B.getLine
  hs <- VU.unfoldrN n readInt <$> B.getLine
  print $ solve n hs


Measured memory_bytes: 1916
#include <bits/stdc++.h>
 
using namespace std;
const int size=123456;
typedef long long ll;
int N,A,B;
ll X[size];
ll ans;

int main(){

cin>>N>>A>>B;

for(int i=0; i<N; i++) scanf("%lld",&X[i]);
for(int i=0; i<N-1; i++){
    if(A*(X[i+1]-X[i])<=B){
        ans+=A*(X[i+1]-X[i]);
    }else{
        ans+=B;
    }
}

cout<<ans<<endl;

return 0;
 
}

Measured memory_bytes: 1024
#!/usr/bin python3
# -*- coding: utf-8 -*-

from collections import Counter

n, m = map(int, input().split())
a = [int(i)%m for i in input().split()]
for i in range(1,n):
    a[i] = (a[i] + a[i-1])%m
a = [0] + a
a = Counter(a)
ret = 0
for i, v in a.items():
    ret += v*(v-1)//2
print(ret)

Measured memory_bytes: 20892
N = int(input())
dt, dx, dy = 0, 0, 0
avilable = True
for i in range(N):
    t, x, y = map(int, input().split())
    if abs(x-dx)+abs(y-dy) > t-dt or (abs(x-dx)+abs(y-dy)) % 2 != (t-dt) % 2:
        avilable = False
    dt = t
    dx = x
    dy = y
if avilable:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9212
import java.util.Scanner;
 
public class Main {
	public void solve() {
		Scanner in = new Scanner(System.in);
		int R = in.nextInt();
		int G = in.nextInt();
		int B = in.nextInt();
		int[] RGB = new int[] {R, G, B};
		int N = in.nextInt();
		in.close();
		long count = count(N, RGB, 0);
		
		System.out.println(count);
	}
	
	public long count(int N, int[] RGB, int index) {
		if (index == 2) {
			if (N % RGB[index] == 0) {
				return 1;
			} else {
				return 0;
			}
		}
		int count = 0;
		for (int i=0; ;i++) {
			int newN = N - RGB[index] * i;
			if (newN < 0) {
				break;
			}
			count += count(newN, RGB, index+1);
		}
		return count;
	}
	
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}
 
}


Measured memory_bytes: 23892
#include <stdio.h>

int main(void)
{
  int n, q;
  scanf("%d%d", &n, &q);
  char s[n + 1];
  int ac[n + 1];
  scanf("%s", s);
  ac[1] = 0;
  for (int i = 1; i < n; i++) {
    ac[i + 1] = s[i - 1] == 'A' && s[i] == 'C' ? ac[i] + 1 : ac[i];
  }
  int l, r;
  for (int i = 0; i < q; i++) {
    scanf("%d%d", &l, &r);
    printf("%d\n", ac[r] - ac[l]);
  }
}


Measured memory_bytes: 1280
# https://atcoder.jp/contests/abc140/tasks/abc140_b
# -*- coding: utf-8 -*-

food_cnt = int(input())
food_odr = list(map(int, input().strip().split()))
food_man = list(map(int, input().strip().split()))
food_pls = list(map(int, input().strip().split()))


man_sum = 0
man_sum += food_man[0]
for i in range(1,food_cnt):
    man_sum += food_man[i]
    if (food_odr[i-1] + 1) == food_odr[i]:
        man_sum += food_pls[food_odr[i-1]-1]

print(man_sum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll     long long int
#define ull   unsigned long long int
#define mod 1000000007
using namespace std;
 
 ll btod(string v){
     ll sum=0;
     for(int i=0;i<v.size();i++){
         sum+=pow(2,i)*v[i];
     }
     return sum;
 }
  string dtob(ll a){
     string v;
     while(a){
         v.push_back(a%2+'0');
         a/=2;
     }
     return v;
 }
 
 ll find(ll a,vector<ll> &parent){
 //    cout<<parent[a];
 vector<ll> parenti = parent;
     while(parenti[a]!=a){
         parenti[a]=parenti[parenti[a]];
         a=parenti[a];
     }
     return a;
 }
 
void unioni(ll x,ll y,vector<ll>&parent){
    ll x1=find(x,parent);
    ll y1=find(y,parent);
  // cout<<x<<" "<<y<<" "<<x1<<" "<<y<<endl;  
 
    
    if(x1<y1){
        parent[y1]=x1;
    }
    else{
        parent[x1]=y1;
    }
    
    
    
}
 
 
 
long long int power(long long int x,   long long int y,   long long int m)
{
    if (y == 0)
        return 1;
    long long int p = power(x, y/2, m) % m;
    p = (p * p) % m;
 
    return (y%2 == 0)? p : (x * p) % m;
}
 
 
long long int gcd(long long int a, long long int b)
{
    if (a == 0)
        return b;
    return gcd(b%a, a);
}
ll modInverse(long long int a, long long int m)
{
     
         
             long long int t =  (power(a, m-2, m))%1000000009;
           
            return t;
    
}
 
  int recur(int n ,int a,int b,int c){
      if(n==0)return 0;
      if(n<0)return INT_MIN;
        return 1+max(recur(n-a,a,b,c),max(recur(n-b,a,b,c),recur(n-c,a,b,c))); 
  }
 
int main(){
int n;cin>>n;
if(n<=111)cout<<111;
if(n>111 && n<=222)cout<<222;
if(n>222&&n<=333)cout<<333;
if(n>333&&n<=444)cout<<444;
if(n>444&&n<=555)cout<<555;
if(n>555&&n<=666)cout<<666;
if(n>666&&n<=777)cout<<777;
if(n>777&&n<=888)cout<<888;
if(n>888&&n<=999)cout<<999;
      
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

// S
var (
	S []string
	t [][]int
	H int
	W int
)

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func printIntln(v ...int) {
	if len(v) == 0 {
		return
	}
	b := make([]byte, 0, 4096)
	for i := 0; i < len(v)-1; i++ {
		b = append(b, strconv.Itoa(v[i])...)
		b = append(b, " "...)
	}
	b = append(b, strconv.Itoa(v[len(v)-1])...)
	fmt.Println(string(b))
}

func dfs(q [][2]int) [][2]int {
	nq := make([][2]int, 0)
	for len(q) != 0 {
		h, w := q[0][0], q[0][1]
		nq = append(nq, [2]int{h, w})
		q = q[1:]
		if h-1 >= 0 && S[h-1][w] != '#' && t[h-1][w] == math.MaxInt64 {
			q = append(q, [2]int{h - 1, w})
			nq = append(nq, [2]int{h - 1, w})
			t[h-1][w] = t[h][w]
		}
		if h+1 < H && S[h+1][w] != '#' && t[h+1][w] == math.MaxInt64 {
			q = append(q, [2]int{h + 1, w})
			nq = append(nq, [2]int{h + 1, w})
			t[h+1][w] = t[h][w]
		}
		if w-1 >= 0 && S[h][w-1] != '#' && t[h][w-1] == math.MaxInt64 {
			q = append(q, [2]int{h, w - 1})
			nq = append(nq, [2]int{h, w - 1})
			t[h][w-1] = t[h][w]
		}
		if w+1 < W && S[h][w+1] != '#' && t[h][w+1] == math.MaxInt64 {
			q = append(q, [2]int{h, w + 1})
			nq = append(nq, [2]int{h, w + 1})
			t[h][w+1] = t[h][w]
		}
	}
	return nq
}

func main() {
	defer flush()

	H = readInt()
	W = readInt()
	Ch := readInt() - 1
	Cw := readInt() - 1
	Dh := readInt() - 1
	Dw := readInt() - 1
	S = make([]string, H)
	for i := 0; i < H; i++ {
		S[i] = readString()
	}

	t = make([][]int, H)
	for i := 0; i < H; i++ {
		t[i] = make([]int, W)
		for j := 0; j < W; j++ {
			t[i][j] = math.MaxInt64
		}
	}

	t[Ch][Cw] = 0
	q := make([][2]int, 0)
	q = append(q, [2]int{Ch, Cw})
	nq := dfs(q)
	if t[Dh][Dw] != math.MaxInt64 {
		println(t[Dh][Dw])
		return
	}

	for {
		q := make([][2]int, 0)
		for len(nq) != 0 {
			h, w := nq[0][0], nq[0][1]
			nq = nq[1:]
			for i := max(0, h-2); i <= min(H-1, h+2); i++ {
				for j := max(0, w-2); j <= min(W-1, w+2); j++ {
					if S[i][j] == '#' {
						continue
					}
					if t[i][j] != math.MaxInt64 {
						continue
					}
					t[i][j] = t[h][w] + 1
					q = append(q, [2]int{i, j})
				}
			}
		}
		if len(q) == 0 {
			break
		}
		nq = dfs(q)
		if t[Dh][Dw] != math.MaxInt64 {
			break
		}
	}

	for h := 0; h < H; h++ {
		//printIntln(t[h]...)
	}

	if t[Dh][Dw] == math.MaxInt64 {
		println(-1)
	} else {
		println(t[Dh][Dw])
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


Measured memory_bytes: 36848
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main(){
  string s;
  cin >> s;
  sort(ALL(s));
  bool ok = true;
  if(s[0] != s[1]) ok = false;
  if(s[2] != s[3]) ok = false;
  if(s[1] == s[2]) ok = false;

  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3532
def solve():
    N = int(input())
    A = list(map(int, input().split()))

    n_minus = 0
    mn = float('inf')
    for a in A:
        if a < 0:
            n_minus += 1
        mn = min(mn, abs(a))
    
    abs_sum = sum(map(abs, A))
    if n_minus % 2 == 0:
        print(abs_sum)
    else:
        print(abs_sum - (2 * mn))
    

if __name__ == '__main__':
    solve()

Measured memory_bytes: 64752
#include <stdio.h>

int main() {
  int i, j, H, W;

  while (1) {
    scanf("%d %d", &H, &W);
    if (H == 0 && W == 0)
      break;
    for (i = 0; i < W; i++)
      putchar('#');
    putchar('\n');
    for (i = 0; i < H - 2; i++) {
      putchar('#');
      for (j = 0; j < W - 2; j++)
        putchar('.');
      puts("#");
    }
    for (i = 0; i < W; i++)
      putchar('#');
    puts("\n");
  }

  return 0;
}

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

int a[101];

int main() {
	int n, m; cin >> n >> m;
	rep(i, n)cin >> a[i];
	for (int k = 1; k <= m; k++) {
		rep(i, n - 1) {
			if (a[i] % k > a[i + 1] % k)swap(a[i], a[i + 1]);
		}
	}
	rep(i, n) {
		cout << a[i] << endl;
	}
	return 0;
}

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

int main(){
    ll n; cin >> n;
    ll a, b; cin >> a >> b;

    ll res = b-a;   

    if(res%2LL==0){
        cout << res/2LL << endl;
    }
    else{
        if(a-1LL < n-b){
            cout << a + (b-a-1)/2LL << endl;
        }
        else{
            cout << n-b + 1 +  (b-a-1)/2LL << endl;
        }

    }
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  int a=700;
  string s;
  cin >> s;
  r(i,s.length()-2){
    if(a>abs((s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0')-753)) a=abs((s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0')-753);
  }
  cout << a << endl;
}


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


int main(){
    int n;
    int e[1000000]={0}, w[1000000]={0};
    vector<int> c;
    string s;
	cin >> n >> s;
    
    if(s[0] == 'E') e[0] = 1;
    if(s[0] == 'W') w[0] = 1;
	for(int i=1;i<n;i++){
        if(s[i] == 'E'){
            e[i] = e[i-1] + 1;
            w[i] = w[i-1];
        }else if(s[i] == 'W'){
            e[i] = e[i-1];
            w[i] = w[i-1] + 1;
        }
    }

    c.push_back(e[n-1] - e[0]);
    for(int i=1;i<n;i++){
        c.push_back(w[i-1] + (e[n-1] - e[i]));
    }

    sort(c.begin(), c.end());

    cout << c[0] << endl;

	return 0;
}

Measured memory_bytes: 10620
cnt = [0 for _ in range(100001)]
n = int(input())
a = list(map(int, input().split()))
for ai in a:
    cnt[ai] += 1
q = int(input())
s = sum(a)
for _ in range(q):
    b, c = map(int, input().split())
    s -= b * cnt[b]
    s += c * cnt[b]
    cnt[c] += cnt[b]
    cnt[b] = 0
    print(s)

Measured memory_bytes: 89832
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node{  //双方向連結リスト
  int key;
  Node *next, *prev;
};

Node *nil;  //番兵作成

Node* listSearch(int key){  //要素の探索
  Node *cur = nil->next;
  while ( cur != nil && cur->key != key ) {  //探してる要素が見つかるまで
      cur = cur->next;
  }
  return cur;
}

void init(){  //番兵の定義
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){  //リストの要素表示
  Node  *cur = nil->next;
  int isf = 0;
  while(1){
    if ( cur == nil ) break;
    if ( isf++ > 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t){  //要素の削除
  if (t == nil)return;  //tが番兵なら処理なし
  t->prev->next = t->next;
  t->next->prev = t->prev;  //削除したい要素を除いてポインタを繋ぐ
  free(t);  //メモリ解放
}

void deleteFirst(){  //リストの最初の要素削除
  deleteNode(nil->next);
}

void deleteLast(){  //リストの最後の要素削除
    deleteNode(nil->prev);
}

void deleteKey(int key){  //指定したノードの削除
    deleteNode(listSearch(key));  //検索したノードを引数に
}

void insert(int key){  //要素の挿入
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  //番兵の直後に要素を追加
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	    if ( com[6] == 'F' ) deleteFirst();
	    else if ( com[6] == 'L' ) deleteLast();
      } else {
	    deleteKey(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}


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

using namespace std;

const int maxn=1e4+10;
int a[maxn];
int b[10]={0,2,5,5,4,5,6,3,7,6};

void compare(string &a,string b)
{
    if(a=="Accept") 
	    a=b;
    else if(a.size()<b.size())
	    a=b;
    else if(a.size()==b.size())
    {
        if(a<b)
            a=b;
    }
}

int main()
{
    int m,n;
    cin>>n>>m;
    
    for(int i=0;i<m;i++)
        cin>>a[i];
        string dp[maxn];
    for(int i=0;i<maxn;i++)
        dp[i]="Accept";

    dp[0]="";
    for(int i=0;i<=n;i++)
        for(int j=0;j<m;j++)
        {
            if(dp[i]=="Accept")
                continue;
            compare(dp[i+b[a[j]]],dp[i]+char(a[j]+'0'));
        }
    cout<<dp[n];
}

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

using ll = long long;
const int INF = 1e9+7;

void solve(){
	int n;cin >> n;
	cout << (1000 - n % 1000) % 1000 << '\n';
}

int main()
{
	int t=1;
	//int t;cin >> t;
	while(t--) solve();
}	


Measured memory_bytes: 3608
#include <bits/stdc++.h>
//#define int long long

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

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    REP(i, m) cin >> a[i] >> b[i];

    map<int, bool> mp;
    REP(i, m){
        if(a[i] == 1){
            if(mp[b[i]]){
                cout << "POSSIBLE" << endl;
                return 0;
            }

            mp[b[i]] = true;
        }else if(b[i] == n){
            if(mp[a[i]]){
                cout << "POSSIBLE" << endl;
                return 0;
            }

            mp[a[i]] = true;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 11264
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;++i)
#define repi(i,n) for(ll i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define slf(n) scanf("%lf", &n);
typedef long long ll;
typedef double lf;
static const ll max_n = 100010;
static const ll mod = 1000000007;
static const ll max_value = 100000000000100;
// vector<vector<vector<ll>>> dp(max_n, vector<vector<ll>>(max_n, vector<ll>(max_n*max_n, 0)));



void Main(){
    // bool is_ok = true;
    // printf("------------- V=%lld---------\n", V);
    ll K;
    string S;
    sll(K);
    cin >> S;
    if(S.size()<=K){
        cout << S <<endl;
    }else{
        rep(i,K){
            cout << S[i];
        }
        cout << "..." <<endl;
    }



    // cout<<fixed<<setprecision(10)<<num<<endl;
    // cout << num << endl;

}

int main(){
    Main();

    return 0;

}

Measured memory_bytes: 3196
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define MAX_N 100000
vector<int> A;
vector<int> G[MAX_N];

int ans;

int min_depth(int a){
    if(G[a].size()==0) return 0;
    vector<int> M;
    for(auto to:G[a]){
        M.push_back(min_depth(to));
    }
    sort(M.begin(),M.end(),greater<int>());
    int ret = 0;
    for(int i=0;i<M.size();i++){
        ret = max(ret,M[i]+i+1);
    }
    return ret;
}

int main(){
    int N;
    cin>>N;
    for(int i=1;i<N;i++){
        int a;
        cin>>a;
        a--;
        A.push_back(a);
        G[a].push_back(i);//aがiに勝ったの意
    }
    cout<<min_depth(0)<<endl;
    return 0;
}

Measured memory_bytes: 17016
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <deque>
#include <algorithm>
#include <cmath>
#define rep(i, a, b) for(int i = a; i < b; i++)
using namespace std;
typedef long long ll;
int n, m;

int main(){
	cin >> n >> m;
	vector<int> v(n); 
	vector<int>::iterator itr;
	map<int , bool> mp;
	rep(i, 0, n){
		cin >> v[i];
		mp[v[i]] = false;
	}
	
	itr = v.end();
	itr--;
	int cnt = 0;
	while(itr+1 != v.begin() && cnt != m){
		if(mp[*itr] == true)  {
			itr--;
			continue;
		}
		cout << *itr << endl;

		mp[*itr] = true;
		cnt++;
		itr--;
	}
}

Measured memory_bytes: 6024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long

int a,b;
char z;

int main(){
  scanf("%c",&z);

  
  if(z-'a'>=0){
    printf("a\n");}
  else{
    printf("A\n");}
  
  
  //printf("%d\n",z-'A');
  
  return 0;
}


Measured memory_bytes: 1592
m, d = map(int, input().split())
if d < 20:
    print(0)
    exit(0)

cnt = 0
for month in range(1, m + 1):
    for x in range(20, d+1):
        d10 = x // 10
        d1 = x % 10
        if d10 * d1 == month and d1 != 1:
            cnt += 1
print(cnt)



Measured memory_bytes: 2940
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


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

def Base_10_to_n(i10, n, ans_list:list):
    i10 -= 1
    if(int(i10/n)):
        ans_list.append(Base_10_to_n(int(i10/n), n, ans_list))
        return str(i10%n)
    return str(i10%n)


def resolve():
    n = int(input().rstrip())
    n_list = []

    ans_list = []

    n_list.append(Base_10_to_n(n, 26, n_list))
    n26_list =[]
    for n26 in n_list:
        n26_list.append(int(n26))

    for n26 in n26_list:
        string = ord("a") + n26
        ans_list.append(chr(string))

    ans_string = ""
    for st in ans_list:
        ans_string += st
    print(ans_string.rstrip())

if __name__ == "__main__":
    resolve()



Measured memory_bytes: 61960
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<iostream>
#include<algorithm>
#define m(a,b) memset(a,b,sizeof(a));
using namespace std;
typedef long long LL;
typedef pair<int,int>PII;
const int inf = 1 << 30;
const int mod = 998244353;
map<int,int>mp;
map<int,int>steam;
map<int,int>::iterator it;
const int maxn = 1e5;
/*
struct point{
	int x,cont;
	float c;
}num[maxn+5];

bool cmp(point a,point b){
	if(a.c == b.c) return a.cont > b.cont;
	return a.c > b.c;
}
*/
LL qwe (LL x,LL y){
	LL t = 1;
	while (y){
		if (y%2!=0)
			t = t * x % mod;
		y /= 2;
		x = x * x % mod;
	}
	return t;
}
LL jc(LL x){
	LL t = 1;
	for(int i = 1;i<=x;i++){
		t*=i;
		t % mod;
	}
	return t;
}
vector<int>num[maxn+5];
int main(){
	int n,m,k;
	cin >> n >> m >> k;
	for(int i = n;i < min(n+k,m);i++){
		if(mp[i]) continue;
		cout << i << endl;
		mp[i] = 1;
	}
	for(int i = max(m-k+1,n);i<=m;i++){
		if(mp[i]) continue;
		cout << i<< endl;
		mp[i] = 1;
	}
	return 0;
}

Measured memory_bytes: 2560
<>;
for(<>){
	/ /;
	push@{$`},$'+0;
	push@{$'+0},$`
}
@_[@o=(1,$1[0])]=(1,1);
while(($g)=grep!$_[$_],@{$o[0]}){
	unshift@o,$g;
	$_[$g]=1
}
while(($g)=grep!$_[$_],@{$o[-1]}){
	push@o,$g;
	$_[$g]=1
}
print@o."\n@o\n"


Measured memory_bytes: 86272
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var str = "";
			while ((str = Console.ReadLine()) != null)
			{
				var z = str.Split(' ').Select(i => int.Parse(i)).ToArray();
				double a = z[0], b = z[1], c = z[2], d = z[3], e = z[4], f = z[5];
				double y = (a * f - c * d) / (-b * d + e * a);
				double x = (c - b * y) / a;
				Console.WriteLine("{0:F3} {1:F3}", x, y);
			}
		}
	}
}

Measured memory_bytes: 5968
from operator import itemgetter
N,M = list(map(int, input().split()))

A = list(map(int, input().split()))
A.sort(reverse=True)

X = [[0]*2 for i in range(M)]

for i in range(M):
  x,y = list(map(int, input().split()))
  X[i] = [y,x]
  
X.sort(reverse=True,key=itemgetter(0))

idA, idX = 0,0
ans=0
#print(A)
#print(X)
while N > 0:
  if idX >= M or A[idA] >= X[idX][0]:
    ans += A[idA]
    idA += 1
    N -= 1
  else:
    cnt = min(N, X[idX][1])
    ans += X[idX][0] * cnt
    idX += 1
    N -= cnt
  #print(N,ans,idA,idX)
print(ans)

Measured memory_bytes: 83480
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	string s,t;
	
	cin >>s >>t;
	sort(s.begin(),s.end());
	sort(t.rbegin(),t.rend());
	if(s<t)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

int main(){
    int n,m;
    scanf("%d %d",&n, &m);

    ll sum=0;
    while(m--){
        int a;
        scanf("%d",&a);
        sum+=a;
    }

    if(sum<n) printf("%d\n",(n-sum));
    else if(sum>n) printf("-1\n");
    else printf("0\n");
    return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

ll distL(vector <ll> &v, ll &x){
    auto it = lower_bound(all(v), x);
    if(it == v.begin()) return 100000000000;
    else return (x - *(it-1)) ;
}

ll distR(vector <ll> &v, ll &x){
    auto it = lower_bound(all(v), x);
    if(it == v.end()) return 100000000000;
    else return (*(it) - x) ;
}


ll distMin(vector <ll> &v, ll x){
    ll d1 = distL(v, x);
    ll d2 = distR(v, x);

    return min(d1, d2);
}




int main(){

    ll A, B, Q;
    cin >> A >> B >> Q;

    vector<ll> a(A);
    vector<ll> b(B);
    for(int i = 0; i < A; i++){
        cin >> a[i];
    }
    if(DEBAG) cout << "-----------" << endl;
    for(int i = 0; i < B; i++){
        cin >> b[i];
    }
    if(DEBAG) cout << "-----------" << endl;

    vector <ll> ANS(Q);
    for(int i = 0; i < Q; i++){
        ll x;
        cin >> x;

        ll d1, d2;
        ll ans = __LONG_LONG_MAX__;
        ll ans_temp ;


        // left 
        ans_temp = 0;
        d1 = distL(a, x);             
        d2 = distL(b, x);
        if(d1 < d2){
            ans_temp += d1;
            ans_temp += distMin(b, x - d1);
        }
        else{
            ans_temp += d2;
            ans_temp += distMin(a, x - d2);
        }
        ans = min(ans, ans_temp);

        // right
        ans_temp = 0;
        d1 = distR(a, x);             
        d2 = distR(b, x);
        if(d1 < d2){
            ans_temp += d1;
            ans_temp += distMin(b, x + d1);
        }
        else{
            ans_temp += d2;
            ans_temp += distMin(a, x + d2);
        }
        ans = min(ans, ans_temp);

        ANS[i] = ans;
    }

    if(DEBAG) cout << "--------" << endl;

    for(int i = 0; i < Q; i++){
        cout << ANS[i] << endl;
    }
}

Measured memory_bytes: 3712