akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


int main() {
    ll a;
    cin >> a;
    if (a % 2 == 0) {
        vector<ll> z(a);
        for (int i = 0; i < a; i++) {
            if (i % 2 == 0) {
                cin >> z.at(a / 2 + i / 2);
            }
            else cin >> z.at(a / 2 - i / 2 - 1);
        }
        for (int i = 0; i < a-1; i++) {
            cout << z.at(i) << ' ';
        }
        cout << z.at(a - 1) << endl;
    }
    else {
        vector<ll> z(a);
        cin >> z.at(a / 2);
        for (int i = 0; i < a-1; i++) {
            
            if (i % 2 == 0) {
                cin >> z.at(a / 2 + i / 2+1);
            }
            else cin >> z.at(a / 2 - i / 2 - 1);
        }
        for (int i = 0; i < a - 1; i++) {
            cout << z.at(i) << ' ';
        }
        cout << z.at(a - 1) << endl;
    }
}

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

int main(void) {
  int n; cin >> n;
  vector<string> w;
  bool flag = true;
  
  string s; cin >> s;
  w.push_back(s);
  
  for (int i=1; i<n; i++) {
    cin >> s;
    if (find(w.begin(), w.end(), s) != w.end()) {
      flag = false;
      break;
    }
    
    if (w[i-1][w[i-1].length()-1] != s[0]) {
      flag = false;
      break;
    }
    
    w.push_back(s);
  }
  
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int a[5];
int main()
{
    for(int i=1;i<=3;i++)cin>>a[i];
    sort(a+1,a+4);
    if(a[1]==5&&a[2]==5&&a[3]==7)puts("YES");
    else puts("NO");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/

const int mx=100010;
const ll mod=1e9+7;

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

vector<vector<char>> d(25, vector<char>(25,'#'));
int h,w,ans=0;

int bfs(int y, int x){
  vector<vector<int>> done(25, vector<int>(25,inf));
  queue<P> q;
  q.push({y,x});
  done[y][x] = 0;

  while(!q.empty()){
    P p = q.front(); q.pop();
    rep(i,4){
      int ny = p.F+dy[i], nx = p.S+dx[i];
      if(ny<0 || h<=ny || nx<0 || w<=nx) continue;
      if(d[ny][nx]=='#') continue;
      if(done[ny][nx]!=inf) continue;
      q.push({ny,nx});
      done[ny][nx] = done[p.F][p.S] + 1;
    }
  }
  int ret=0;
  rep(i,h)rep(j,w)if(d[i][j]=='.'){
    ret = max(ret, done[i][j]);
  }
  return ret;
}

int main(){  
  cin >> h >> w;
  rep(i,h)rep(j,w) cin >> d[i][j];
  rep(i,h)rep(j,w)if(d[i][j]=='.'){
    ans = max(ans, bfs(i,j));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for(int i=0;i<(n);++i)
#define ln '\n'
// Range Minimum Query
// abstracted

template <typename T, typename F>
struct SegmentTree {
	int n; T *dat;
	T identity; F merge;
	SegmentTree(F f, T id) : merge(f), identity(id){}
	void init(int siz){
		n = 1; while(n < siz) n <<= 1;
		dat = new T[n*2-1];
		REP(i, n*2-1) dat[i] = identity;
	}
	void set(int i, T x){
		dat[i+n-1] = x;
	}
	void build(void){
		for(int i = n-2; i >= 0; i--){
			dat[i] = merge(dat[i*2 + 1], dat[i*2 + 2]);
		}
	}
	void update(int i, T x){
		i += n-1;
		dat[i] = x;
		while(i > 0){
			i = (i-1) / 2;
			dat[i] = merge(dat[i*2 + 1], dat[i*2 + 2]);
		}
	}
	T query(int l, int r){  // [l, r)(0-indexed), 処理だけ 1-indexed で考える
		l += n, r += n;
		T res = identity;
		while(l < r){
			if(r & 1){
				--r; res = merge(res, dat[r-1]);
			}
			if(l & 1){
				res = merge(res, dat[l-1]);
				++l;
			}
			l >>= 1; r >>= 1;
		}
		return res;
	}
};

// AOJ DSL_2_A
signed main(void){
	int N, Q; cin >> N >> Q;
	auto f = [](int a, int b){ return min(a, b); };
	SegmentTree<int, decltype(f)> seg(f, (1ll<<31)-1);
	seg.init(N);
	REP(_, Q){
		int com, x, y; cin >> com >> x >> y;
		if(com) cout << seg.query(x, y+1) << ln;
		else seg.update(x, y);
	}
}


Measured memory_bytes: 5120
#include "bits/stdc++.h"
using namespace std;

int e[10][10];

int youseki(int x,int y,int dx,int dy)
{
	int height=50;
	int ret=0;
	//池の周りの高さを調べる
	for(int i=0;i<dy;i++)
	{
		for(int j=0;j<dx;j++)
		{
			if(i==0 || i==dy-1)
				height=min(height,e[y+i][x+j]);
			else if(j==0 || j==dx-1)
				height=min(height,e[y+i][x+j]);
		}
	}

	//池の中の高さを調べる
	for(int i=1;i<dy-1;i++)
	{
		for(int j=1;j<dx-1;j++)
		{
			if(height<=e[y+i][x+j])
			{
				ret=-1;
				break;
			}
			ret+=height-e[y+i][x+j];
		}
		if(ret==-1)
			break;
	}
	return ret;
}
int main()
{
	while(1)
	{
		int h,w;
		int ans=0;
		cin>>h>>w;
		if(h==0)
			break;
		
		for(int i=0;i<h;i++)
		{
			for(int j=0;j<w;j++)
				cin>>e[i][j];
		}

		for(int a=0;a<h-2;a++)
		{
			for(int b=0;b<w-2;b++)
			{
				for(int i=3;i<h-a+1;i++)
				{
					for(int j=3;j<w-b+1;j++)
						ans=max(ans,youseki(b,a,j,i));
				}
			}
		}

		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3052
n=int(input())
*a,=map(int,input().split())
cnt=0
mode=0
for i in range(n-1):
    if mode==0:
        if a[i]<a[i+1]:
            cnt+=1
            mode="inc"
        elif a[i]>a[i+1]:
            cnt+=1
            mode="dec"
    if a[i]<a[i+1]:
        if mode=="inc":
            pass
        else:
            mode=0
    elif a[i]>a[i+1]:
        if mode=="dec":
            pass
        else:
            mode=0
if mode==0:
    print(cnt+1)
else:
    print(cnt)

Measured memory_bytes: 14252
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e933
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long ll;
typedef std::pair<int,int> pii;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main() {
    ll n,m;
    cin>>n>>m;
    ll ans=0;
    if(n*2<=m){
        ans=n;
        m-=n*2;
    }else {
        ans=m/2;
        m=0;
    }
    ans+=m/4;
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 500010



int p[N];
int d[N];

void init(void) {
	f(i, N) {
		p[i] = i;
		d[i] = 1;
	}
	return;
}

long long pa(long long x) {
	if (p[x] == x)return x;
	else return p[x] = pa(p[x]);
}


void uni(long long x, long long y) {
	long long px = pa(x);
	long long py = pa(y);
	if (px == py)return;
	if (d[px] < d[py]) {
		p[px] = py;
		d[py] = max(d[py], d[px] + 1);
	}
	else {
		p[py] = px;
		d[px] = max(d[px], d[py] + 1);
	}
	return;
}

bool jud(long long x, long long y) {
	long long px = pa(x);
	long long py = pa(y);
	if (px == py)return true;
	else return false;
}



int main() {
	init();
	vector<pair<long long, pair<long long, long long> > >a;
	long long e[N];
	long long b[N];
	f(i, N) {
		e[i] = -1;
		b[i] = -1;
	}
	long long n, k, m;
	long long x, y, z;
	long long xx, yy, zz, nn, aa;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%lld %lld", &n, &m);
	f(i, m) {
		scanf("%lld %lld %lld", &x, &y, &z);
		a.push_back(make_pair(z, make_pair(x, y)));
		a.push_back(make_pair(z + 1, make_pair(x + 1, y)));
	}
	sort(a.begin(), a.end());
	xx = 0;
	yy = 1;
	zz = a[0].first;
	nn = 0;
	aa = 0;
	while (true) {

		if ((zz - a[0].first) % 2 == 0) {
			if (aa < a.size()) {
				while (a[aa].first == zz) {
					e[xx] = aa + 2;
					b[aa + 2] = xx;
					xx = aa + 2;
					aa++;
					if (aa >= a.size())break;
				}
			}
			k = 0;
			while (true) {
				k = e[k];
				if (k == -1)break;
				x = (a[k - 2].second.first + ((zz - a[k - 2].first) / 2)) % n;
				y = (a[k - 2].second.second + ((zz - a[k - 2].first) / 2)) % n;
				z = zz;
				v = jud(x, y);
				if (!v) {
					uni(x, y);
					ans += zz;
					nn++;
					if (nn + 1 == n)break;
				}
				else {
					e[b[k]] = e[k];
					if (e[k] == -1)xx = b[k];
					else b[e[k]] = b[k];

				}
			}
			if (nn + 1 == n)break;
		}
		else {
			if (aa < a.size()) {
				while (a[aa].first == zz) {
					e[yy] = aa + 2;
					b[aa + 2] = yy;
					yy = aa + 2;
					aa++;
					if (aa >= a.size())break;
				}
			}
			k = 1;
			while (true) {
				k = e[k];
				if (k == -1)break;
				x = (a[k - 2].second.first + ((zz - a[k - 2].first) / 2)) % n;
				y = (a[k - 2].second.second + ((zz - a[k - 2].first) / 2)) % n;
				z = zz;
				v = jud(x, y);
				if (!v) {
					uni(x, y);
					ans += zz;
					nn++;
					if (nn + 1 == n)break;
				}
				else {
					e[b[k]] = e[k];
					if (e[k] == -1)yy = b[k];
					else b[e[k]] = b[k];

				}
			}
			if (nn + 1 == n)break;
		}
		zz++;
		if (nn + 1 == n)break;
	}


	printf("%lld\n", ans);


	return 0;
}

Measured memory_bytes: 26348
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var factorial = 1;
            for (int i = 1; i <= N; i++) factorial *= i;
            var x = new int[N];
            var y = new int[N];
            for (int i = 0; i < N; i++)
            {
                var xy = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                x[i] = xy[0];
                y[i] = xy[1];
            }
            var sum = 0d;
            for (int i = 0; i < N; i++)
            {
                for (int j = i + 1; j < N; j++)
                {
                    sum += Math.Sqrt(Math.Pow(x[i] - x[j], 2) + Math.Pow(y[i] - y[j], 2)) * factorial / N * 2;
                }
            }
            Console.WriteLine(sum / factorial);
        }
    }
}


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

int h,w;
/*bool alone(bool c[][], int x, int y){
  bool u = false, r =false, d =false, l = false;

  if(y-1 != -1) u = c[x][y-1];
  if(x+1 !=  w) r = c[x+1][y];
  if(y+1 !=  h) d = c[x][y+1];
  if(x-1 != -1) l = c[x-1][y];

  return !(u | r | d | l);
}*/

int main(){
  cin >> h >> w;
  bool c[h][w];

  for(int i=0;i<h;i++){
    string s;
    cin >> s;
    for(int j=0;j<w;j++){
      c[i][j] = (s[j] == '#') ? true : false;
    }
  }

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(c[i][j]){
        bool u = false, r =false, d =false, l = false;
        if(j-1 != -1) l = c[i][j-1];
        if(i+1 !=  h) d = c[i+1][j];
        if(j+1 !=  w) r = c[i][j+1];
        if(i-1 != -1) u = c[i-1][j];
        if( !(u | r | d | l) ){
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int k,i,x;
    char s[100];
    scanf("%d",&k);
    scanf("%s",s);
    if(strlen(s)<=k)
        printf("%s",s);
    else if(strlen(s)>k)
       for(i=0;i<k;i++)
          printf("%c",s[i]);
    if(strlen(s)>k)
        printf("...");
    return 0;

}


Measured memory_bytes: 1684
/*
    Author: Aryan Yadav
*/
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define mod 1000000007
#define f(i, a, b) for (long long i = a; i < b; i++)
#define rep(i, a, b) for (long long i = a; i <= b; i++)
#define fm(i, a, b) for (long long i = a; i > b; i--)
#define repm(i, a, b) for (long long i = a; i >= b; i--)
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define pqmaxi priority_queue<int>
#define pqmaxl priority_queue<ll>
#define pqmini priority_queue<int, vi, greater<int>>
#define pqminl priority_queue<ll, vl, greater<ll>>
#define all(x) x.begin(), x.end()
#define test     \
    ll test;     \
    cin >> test; \
    while (test--)
#define pb(i) push_back(i)
#define mp(i, j) make_pair(i, j)
#define fast                     \
    ios::sync_with_stdio(false); \
    cin.tie(NULL)

int main()
{
    fast;
    string a, b;
    cin >> a >> b;
    string ans = a + b;
    ll num = stoll(ans, nullptr, 10);
    long double sr = sqrt(num);
    if ((sr - floor(sr)) == 0)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}

Measured memory_bytes: 3568
#include <stdio.h>
int main(void){
   int m,f,r;
   char grade;
   
   do{
       scanf("%d%d%d",&m,&f,&r);
       if(m==-1 && f==-1 && r==-1) break;
       if(m==-1 || f==-1) grade='F';
       else if(m+f>=80) grade='A';
       else if(m+f>=65 && m+f<80) grade='B';
       else if(m+f>=50 && m+f<65) grade='C';
       else if(m+f>=30 && m+f<50){
        if(r>=50) grade='C';
        else if(0<=r && r<50) grade='D';
       }
       else if(m+f<30) grade='F';
       
       printf("%c\n",grade);
   }while(1);
   
   return 0;
}

Measured memory_bytes: 600
import math

def myceil(x,n):
  return math.pow(10,-n)*math.ceil(x*math.pow(10,n))

def debt(principal,w):
  if w==1:
    return int(myceil(principal*1.05,-3))
  else:
    return int(debt(myceil(principal*1.05,-3),w-1))



w=int(input())
print(debt(100000,w))

Measured memory_bytes: 7760
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
using namespace std;
#define sci(n) scanf(“%lld”, &(n))
#define scd(n) scanf(“%Ld”, &(n))
typedef long long LL;

typedef struct _city {
	LL index;
	LL year;
	LL pref;
	LL th;
	string ans;
} city;

auto comp = [](const city& a, const city& b) {
	return a.year < b.year;
};

auto compth = [](const city& a, const city& b) {
	return a.index < b.index;
};

string makeSixdigit(LL num) {
	string s = to_string(num);
	int leftzero = 6 - s.length();
	for (int i = 0; i < leftzero; i++) {
		s = "0" + s;
	}
	return s;
}

int main(void)
{
	map<LL, LL> th;
	vector<city> v;
	LL n, m;
	scanf("%lld%lld", &n, &m);
	for (int i = 0; i < m; i++) {
		LL p, y;
		scanf("%lld%lld", &p, &y);
		city temp;
		temp.index = i+1;
		temp.pref = p;
		temp.year = y;
		temp.th = -1;
		v.push_back(temp);
	}
	sort(v.begin(), v.end(), comp);
	
	for (int i = 0; i < v.size(); i++) {
		th[v[i].pref]++;
		v[i].ans = makeSixdigit(v[i].pref) + makeSixdigit(th[v[i].pref]);
	}
	sort(v.begin(), v.end(), compth);

	for (int i = 0; i < v.size(); i++) {
		cout << v[i].ans << "\n";
	}

	return 0;
}

Measured memory_bytes: 16364
import heapq

n,m=map(int,input().split())
arr=list(map(int,input().split()))
q=[]
for i in range(n):
  heapq.heappush(q,-arr[i])
for _ in range(m):
  tmp=-heapq.heappop(q)
  heapq.heappush(q,-(tmp//2))
ans=0
for _ in range(n):
  ans+=-heapq.heappop(q)
print(ans)  

Measured memory_bytes: 14180
#include<bits/stdc++.h>
using namespace std;
int p[2000];
int main(){
  int n,k;
  cin>>n>>k;
  for(int i=0;i<n;i++)cin>>p[i];
  sort(p,p+n);
  int cnt=0;
  for(int i=0;i<k;i++){
    cnt+=p[i];
  }
  cout<<cnt<<endl;
  return 0;
}

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

int main()
{
  int N;
  cin >> N;
  
  int num = 0;
  for(int i = 1; ;i++){
    if( (1000 * i) >= N ){
      num = i;
      break;
    }
  }
  
  cout << (1000 * num) - N << endl;
}

Measured memory_bytes: 3592
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if (a > b) {
            System.out.println(0);
            return;
        }
        
        if (n == 1 && a != b) {
            System.out.println(0);
            return;
        }
        
        n--;
        n--;
        
        long min = (long)a * n;
        long max = (long)b * n;
        
        System.out.println(max - min + 1);
    }
}


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

using namespace std;

#define pb push_back
#define sz(a) ((int)a.size())
#define mp make_pair
#define fi first
#define se second

const int maxn = 1e5 + 5;

const int maxv = 1e9;

int T, tc;
int n, k;
int a[maxn];

int main() {
//	freopen("inp.txt", "r", stdin);
    
   	cin >> n >> k;
   	for (int i = 0; i < n; i++) cin >> a[i];
   	sort(a, a + n);
   	int ans = 0;
   	for (int i = 0; i < k; i++) ans += a[i];
   	
   	cout << ans;
    
    return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
int a[200100],n;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	sort(a+1,a+1+n);
	for(int i=2;i<=n;i++)
	{
		if(a[i]==a[i-1])
		{cout<<"NO";return 0;}
	}
	cout<<"YES";
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

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

    String s = sc.next();
    int s1 = Integer.parseInt(s.substring(0, 2));
    int s2 = Integer.parseInt(s.substring(2));
    String ans = "NA";

    if(1 <= s1 && s1 <= 12 && 1 <= s2 && s2 <= 12){
      ans = "AMBIGUOUS";
    } else if(1 <= s1 && s1 <= 12){
      ans = "MMYY";
    } else if(1 <= s2 && s2 <= 12){
      ans = "YYMM";
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 21716
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, L;
    cin >> N >> L;
    vi a(N);
    for (int i = 0; i < N; i++)
        cin >> a[i];
    for (int i = 0; i < N-1; i++) {
        if (a[i]+a[i+1] >= L) {
            cout << "Possible" << endl;
            for (int j = 0; j < i; j++) {
                cout << j+1 << endl;
            }
            for (int j = N-2; j >= i+1; j--) {
                cout << j+1 << endl;
            }
            cout << i+1 << endl;
            return 0;
        } 
    }
    cout << "Impossible" << endl;
    return 0;
}


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

using namespace std;
using ll = long long;

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

struct Sieve {
  vector<ll> p;

  Sieve(ll n) : p(n + 1, 1) {
    p[1] = 0;
    for (ll i = 2; i <= n; ++i) {
      if (p[i] != 1) continue;
      p[i] = i;
      for (ll j = i * i; j <= n; j += i) {
        if (p[j] == 1) p[j] = i;
      }
    }
  }

  vector<ll> factorList(ll x) {
    vector<ll> f;
    while (p[x] != 0) {
      f.push_back(p[x]);
      x /= p[x];
    }
    return f;
  }

  map<ll, ll> factor(ll x) {
    auto l = factorList(x);
    map<ll, ll> mp;
    for (auto v : l) {
      ++mp[v];
    }

    return mp;
  }
};

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

  int ans = 0;
  for (int i = 2; (ll)i * i <= n; ++i) {
    if (n % i != 0) continue;

    int p = i;
    while (n % p == 0) {
      n /= p;
      p *= i;
      ++ans;
    }

    while (n % i == 0) n /= i;
  }

  if (n != 1) ++ans;
  cout << ans << endl;

  // ll mx = sqrt(n + 1);
  // auto s = Sieve(mx);
  //
  // ll ans = 0;
  // for (ll i = 2; i <= mx; ++i) {
  //   if (s.p[i] == i) {
  //     ll cnt = 0;
  //     while (n % i == 0) {
  //       if (n == 0) break;
  //       n /= i;
  //       ++cnt;
  //     }
  //
  //     if (cnt == 0) continue;
  //
  //     int j = 1, sum = 0;
  //     while (sum <= cnt) {
  //       sum += j;
  //     }
  //     ans += j - 1;
  //
  //     for (int j = 1; j <= cnt; ++j) {
  //       if (j * (j + 1) / 2 > cnt) {
  //         ans += j;
  //         break;
  //       }
  //     }
  //   }
  // }
  //
  // if (n != 1 && ans == 0) ++ans;
  // cout << ans << endl;

  return 0;
}


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

using namespace std;

int main(){
	int n;
	cin >> n;
	map<string,int> mp;
	for(int i = 0; i < n; i++ ){
		string s; cin >> s;
		mp[s]++;
	}
	cout << "AC x " << mp["AC"] << "\n";
	cout << "WA x " << mp["WA"] << "\n";
	cout << "TLE x " << mp["TLE"] << "\n";
	cout << "RE x " << mp["RE"] << "\n";
	
	return 0;
}


Measured memory_bytes: 3632
#ABC 065 B Trained?

n = int(input())
a = [0]
for i in range(n):
    l = int(input())
    a.append(l)
k = 1
for i in range(n):
    k = a[k]
    if k == 2:
        print(i + 1)
        break
else:
    print(-1)

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

int main(void){
    int n,s=0;
    cin >> n;
    int p[n],q[n];
    for(int i=0; i<n; i++){
        cin >> p[i];
        q[i] = i + 1;
    }
    for(int i=0; i<n; i++){
        if(p[i] != q[i]) s++;
    }
    if(s == 0 or s == 2) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <functional> 
// using namespace __gnu_pbds;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MaX 300005
using namespace std;

 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1e18;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
// typedef tree<int, null_type, less<int>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//     new_data_set; 
bool isprime(ll n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}


int main()
{
    fast();
    int n;
    cin>>n;
    int x=n%1000;
    if(x==0)
    {
        cout<<0;
        exit(0);
    }
    int y=1000-(n%1000);
    cout<<y;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>

using namespace std;

using ll = long long;
using ui = unsigned int;
const ll MOD = 1000000007;
const ll INF = 9223372036854775807;


//D
int main() {
	ll N;
	scanf("%lld", &N);
	vector<ll> L(N, 0);
	for (ll i = 0; i < N; i++) {
		scanf("%lld", &L[i]);
	}

	//����sort
	std::sort(L.begin(), L.end());

	ll result = 0;

	for (ll i = 0; i <= N - 3; i++) {
		for (ll j = i + 1; j <= N - 2; j++) {
			ll th = L[i] + L[j];
			
			auto it = std::lower_bound(L.begin() + j + 1, L.end(), th);

			ll index = (ll)std::distance(L.begin(), it);

			result += max(0LL, index - j - 1);
		}
	}

	printf("%lld\n", result);

	return 0;
}


//C
/*
int main() {
	ll N;
	scanf("%lld", &N);
	char S[100010];
	scanf("%s", &S); 

	ll result = 0;

	char prev = ' ';
	for (ll i = 0; i < N; i++) {
		if (prev != S[i]) {
			result++;
		}

		prev = S[i];
	}

	printf("%lld\n", result);

}
*/

//B
/*
int main() {
	ll N;
	scanf("%lld", &N);
	vector<ll> d(N, 0);

	for (ll i = 0; i < N; i++) {
		scanf("%lld", &d[i]);
	}

	ll result = 0;

	for (ll i = 0; i < N; i++) {
		for (ll j = i + 1; j < N; j++) {
			result += d[i] * d[j];
		}
	}

	printf("%lld\n", result);

}
*/


//A
/*
int main() {
	ll A;
	scanf("%lld", &A);
	ll B;
	scanf("%lld", &B);

	ll result = 0;

	result = max(0LL, A - B * 2);

	printf("%lld\n", result);

	return 0;
}
*/


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>

using namespace std;

int main()
{
    string a,b;cin >> a >> b;
    int c,d;cin >> c >> d;
    string u;cin >> u;
    if(a == u)
        cout << max(0,c - 1) << " " << d;
    else cout << c << " " << max(0,d - 1); 
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<set>
#include<functional>
#include<iomanip>

#define LLI long long int

using namespace std;

int main(){
	int N;cin>>N;
	vector<int>A(N);
	for(int i=0;i<N;i++)cin>>A[i];
	int tmp=0;
	for(int i=0;i<N;i++){
		if(A[i]<=0){
			tmp++;
		}
	}
	LLI ans=0;
	if(tmp%2==0){
		for(int i=0;i<N;i++){
			ans+=abs(A[i]);
		}
	}else{
		int ii,minai=1000000007;
		for(int i=0;i<N;i++){
			if(abs(A[i])<minai){
				ii=i;
				minai=abs(A[i]);
			}
		}
		for(int i=0;i<N;i++){
			if(i!=ii){
				ans+=abs(A[i]);
			}else{
				ans-=abs(A[i]);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}



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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
// #define X real()
// #define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}


signed main() {
    ll X, Y, A, B, C; cin >> X >> Y >> A >> B >> C;
    vector<ll> p(A);
    vector<ll> q(B);
    vector<ll> r(C);
    REP(i, A) cin >> p[i];
    REP(i, B) cin >> q[i];
    REP(i, C) cin >> r[i];
    sort(ALL(p), greater<ll>());
    sort(ALL(q), greater<ll>());
    PQ<ll> que;
    REP(i, X) que.push(p[i]);
    REP(i, Y) que.push(q[i]);
    REP(i, C) que.push(r[i]);
    ll ans = 0;
    REP(i, X+Y) {
        ans += que.top();
        que.pop();
    }

    print(ans);

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 8816
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>

using namespace std;

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

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

    int res = 1;
    REP(i, N)
    {
        if(res * 2  > res + K)
        {
            res += K;
        }
        else
        {
            res *= 2;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    h,w = i_map()
    l = []
    for i in range(h):
        a = input()
        if "#" in a:
            l.append(a)
    l = [list(i) for i in zip(*l)]
    ans = []

    for i in l:
        if "#" in i:
            ans.append(i)

    ans = [i for i in zip(*ans)]
    for i in ans:
        print("".join(i))





if __name__=="__main__":
    main()


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

const ll INF = 1LL<<60;

int main(){
    int N;
    cin >> N;
    ll A[N][N];
    rep(i,N)rep(j,N) cin >> A[i][j];

    vector<vector<bool>>mat(N,vector<bool>(N,true));

    rep(k,N)rep(i,N)rep(j,N){
      if(A[i][j] > A[i][k] + A[k][j]){
        cout << -1 << endl;
        return 0;
      }else if(k!=i && k!=j && A[i][j] == A[i][k] + A[k][j]){
        mat[i][j] = false;
      }
    }
    ll ans = 0;

    rep(i,N) rep(j,N){
      if(!mat[i][j]) continue;
      //cout << i << j << endl;
       ans += A[i][j];
    }
    cout << ans/2 << endl;
}


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

int main()
{
	int n,m;
    cin>>n>>m;
    int arr[m];
    int sum=0;
    for(int i=0;i<m;i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    if(sum>n)
    {
        cout<<"-1"<<endl;
    }
    else
    {
        cout<<n-sum<<endl;
    }
    
	return 0;
}

Measured memory_bytes: 3672
import java.io.*;
import java.util.*;

public class Main {

    public void solve() {
        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }

        long ans = 0;
        int min = 1;
        for (int i = 0; i < n; i++) {
            int buy = 0;
            if (a[i] % min == 0) {
                buy = (a[i] - 1) / min;
            } else {
                buy = a[i] / min;
            }
            ans += buy;
            a[i] -= buy * min;
            if (a[i] == min && (buy == 0 || min == 1)) {
                min++;
            }
        }
        out.println(ans);
    }

    public void run() {
        in = new FastScanner();
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    FastScanner in;
    PrintWriter out;

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String fileName) {
            try {
                br = new BufferedReader(new FileReader(fileName));
            } catch (FileNotFoundException e) {
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


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

#define ull unsigned long long
#define ll long long

int main(){
    int n;
    cin >> n;
    for(int i=n; i>=1; --i){
        if(i && (!(i&(i-1)))){
            cout << i;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>
#include <limits>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repr(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;

using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;


const int intmax = numeric_limits<int>::max();
const ll llmax = numeric_limits<ll>::max();
const ll mod = 1e9 + 7;
const double pi = M_PI;

int calc(int tmp) {
  int result = 0;
  for(int i = 1; i * i <= tmp; i++) {
    if (tmp % i == 0) {
      result++;
      if (tmp / i != i)
        result++;
    }
  }
  return result;
}

int main()
{
  int n;
  cin >> n;
  int result = 0;
  for(int c = 1; c < n; c++) {
    int tmp = n - c;
    result += calc(tmp);
  }
  cout << result << endl;
}


Measured memory_bytes: 3624
#include<stdio.h>

int main(){
  int i, j, k, l, n;
  int p[101],m[101][101];

 scanf("%d", &n);
 for(i=1;i<=n;i++) scanf("%d %d", &p[i-1], &p[i]);

 for(i=1;i<=n;i++) m[i][i] = 0;

 for(l=2;l<=n;l++){
  for(i=1;i<=n-l+1;i++){
    j=i+l-1;
    m[i][j] = 10000000000000000;
    for(k=i;k<j;k++){
      if(m[i][j] > m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]){
          m[i][j] = m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
      }
    }
  }
 }

    printf("%d\n", m[1][n]);
      
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a[n + 5];
    memset(a, 0, sizeof a);
    for(int i = 1; i < n; i++) {
        int u;
        cin >> u;
        a[u] ++;
    }
    for(int i = 1; i <= n; i++)
        cout << a[i] << endl;
}


Measured memory_bytes: 4380
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::map;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  ui N{};
  ll T{};
  cin >> N >> T;
  vector<ll> t(N);
  boost::for_each(t, [](auto& i){ cin >> i; });

  vector<ll> res{};
  res.reserve(N);
  pair<ll, ll> pos{};
  for(ui i = 0; i < N; ++i)
  {
    if(pos.second < t[i])
    {
      res.push_back(pos.second - pos.first);
      pos.first = t[i];
    }
    chmax(pos.second, t[i] + T);
  }
  res.push_back(pos.second - pos.first);

  auto ans = boost::accumulate(res, (ll)0);
  cout << ans << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
vector<pair<int,int>> dirs = { {0,1},{1,0},{0,-1},{-1,0} };
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,m;
  cin >> n >> m;
  vector<string> vs(n);
  for(int i = 0; i < n; ++i) cin >> vs[i];
  mf_graph<int> graph(n*m+2);
  int src = n*m, sink = n*m+1;
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      if(vs[i][j] == '.'){
        int from = i*m+j;
        if((i+j)&1){
          graph.add_edge(src,from,1);
          for(auto dir : dirs){
            int x = i + dir.first, y = j + dir.second;
            if(0 <= x and x < n and 0 <= y and y < m and vs[x][y] == '.'){
              int to = x*m+y;
              graph.add_edge(from,to,1);
            }
          }
        }
        else graph.add_edge(from,sink,1);
      }
    }
  }
  int ans = graph.flow(src,sink);
  cout << ans << '\n';
  for(auto& edge : graph.edges()){
    if(edge.from != src and edge.to != sink and edge.flow == 1){
      int from = edge.from, to = edge.to;
      int x1 = from/m, y1 = from%m, x2 = to/m, y2 = to%m;
      if(x1 == x2){
        if(y1 < y2){
          vs[x1][y1] = '>';
          vs[x2][y2] = '<';
        }
        else{
          vs[x2][y2] = '>';
          vs[x1][y1] = '<';
        }
      }
      else{
        if(x1 < x2){
          vs[x1][y1] = 'v';
          vs[x2][y2] = '^';
        }
        else{
          vs[x2][y2] = 'v';
          vs[x1][y1] = '^';
        }
      }
    }
  }
  for(auto& s : vs) cout << s << '\n';
  return 0;
}

Measured memory_bytes: 5688
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
pair<int,int> p[N];
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>p[i].first;
        p[i].second = i+1;
    }
    sort(p,p+n);
    for(int i=0;i<n;i++)cout<<p[i].second<<" ";
    cout<<endl;
    return 0;
}


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

int main()
{
    int i,a[5];
    for(i=0;i<5;i++)
        cin>>a[i];
    sort(a,a+5);
    for(i=4;i>0;i--)
        cout<<a[i]<<" ";
    cout<<a[i]<<endl;
    return 0;
}

Measured memory_bytes: 1176
s=list(input())
ans="YES"
while len(s)!=0:
  if len(s)<5:
    ans="NO"
    break
  elif s[-1:-6:-1]==["m","a","e","r","d"]:
    for i in range(5):
      s.pop(-1)
  elif s[-1:-8:-1]==["r","e","m","a","e","r","d"]:
    for i in range(7):
      s.pop(-1)
  elif s[-1:-6:-1]==["e","s","a","r","e"]:
    for i in range(5):
      s.pop(-1)
  elif s[-1:-7:-1]==["r","e","s","a","r","e"]:
    for i in range(6):
      s.pop(-1)
  else:
    ans="NO"
    break
print(ans)

Measured memory_bytes: 79044
from collections import Counter
from itertools import product


N = int(input())
D = list(map(int, input().split()))
D_cnt = Counter(D)
if N >= 24 or D_cnt[0] > 0 or D_cnt[12] > 1 or any(D_cnt[i] > 2 for i in range(1, 12)):
    print(0)
    exit()
clock = [0, 24]
undet = []
if 12 in D_cnt:
    clock.append(12)
for i in range(1, 12):
    if D_cnt[i] == 2:
        clock.append(i)
        clock.append(24 - i)
    elif D_cnt[i] == 1:
        undet.append(i)

ans = 0
for rp in product([0, 1], repeat=len(undet)):
    candidate = clock[:]
    for j, is_flipped in enumerate(rp):
        candidate.append(undet[j]) if is_flipped else candidate.append(24 - undet[j])
    candidate.sort()
    ans = max(ans, min(ca - cb for cb, ca in zip(candidate, candidate[1:])))
print(ans)


Measured memory_bytes: 9472
use std::cmp::max;
use std::collections::HashMap;

fn solve(xys: Vec<(usize, usize)>, n: usize) -> usize {
    let mut m = vec![vec![]; n + 1];

    for (x, y) in xys {
        m[x].push(y);
    }

    let mut dp = vec![None; n + 1];

    fn f(x: usize, dp: &mut Vec<Option<usize>>, m: &Vec<Vec<usize>>) -> usize {
        if let Some(n) = dp[x] {
            n
        } else {
            if m[x].is_empty() {
                dp[x] = Some(0);
                0
            } else {
                let mut maxp = 0;
                for &y in m[x].iter() {
                    maxp = max(maxp, f(y, dp, m) + 1);
                }
                dp[x] = Some(maxp);
                maxp
            }
        }
    }

    let mut ans = 0;
    for x in 1..(n + 1) {
        ans = max(ans, f(x, &mut dp, &m));
    }

    ans
}

#[test]
fn solve_test() {
    assert_eq!(solve(vec![(1, 2), (1, 3), (3, 2), (2, 4), (3, 4)], 4), 3);
}

#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let (n, m) = parse_line!(usize, usize);

    let xys = (0..m)
        .map(|_| parse_line!(usize, usize))
        .collect::<Vec<_>>();
    println!("{}", solve(xys, n));
}


Measured memory_bytes: 17276
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <bitset>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	std::string str;
	std::string word;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	while(std::getline(ifs, str)){
#else
	while(std::getline(std::cin, str)){
#endif
		std::replace(str.begin(), str.end(), ',', ' ');
		std::replace(str.begin(), str.end(), '.', ' ');
		std::istringstream stream(str);
		std::vector<std::string> words;

		while(std::getline(stream, word, ' ')){
			if(word.size() >= 3 && word.size() <= 6){
				words.push_back(word);
			}
		}

		if(!words.empty()){
			std::cout << words[0];
		}
		for(int i = 1; i < words.size(); i++){
			std::cout << " " << words[i];
		}
		std::cout << std::endl;
	}


 
#if INPUT_FROM_FILE
	//fclose(fp);
#endif
    return 0;
}


Measured memory_bytes: 2996
X,Y=map(int,input().split())
if X<Y:
    X,Y=Y,X
mod=10**9+7

N=min(X,Y)
factl=[1]
for i in range(1,N+1):
    factl.append(factl[-1]*i%mod)
invl=[pow(factl[-1],mod-2,mod)]
for i in range(N,0,-1):
    invl.append(invl[-1]*i%mod)
invl.reverse()
def Comb(a,b):
    return factl[a]*invl[a-b]*invl[b]%mod

d=X-Y
if (Y-d)%3!=0 or Y-d<0:
    print(0)
    exit()
x,y=d+(Y-d)//3,(Y-d)//3

print(Comb(x+y,y))

Measured memory_bytes: 82584
#include <iostream>
#define MAX_N  101
#define MAX_W   100001
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
//dp retorna el mejor valor posible para el peso disponible y los articulos faltantes disponiles
int N;
int W;
long long  dp[MAX_N][MAX_W];
int pesos[MAX_N];
long long valores[MAX_N];
long long value(int peso_disponible,int  articulo){
	if(peso_disponible==0|| articulo==0)return 0;
	if(dp[articulo][peso_disponible]!=-1)
	return 	dp[articulo][peso_disponible];
	
	if(peso_disponible-pesos[articulo]>=0)
	return dp[articulo][peso_disponible]=max(value(peso_disponible-pesos[articulo],articulo-1)+valores[articulo],value(peso_disponible,articulo-1));
	return value(peso_disponible,articulo-1);
	}
void fillDp(){
	for(int i =0;i<MAX_N;i++)
{
	for (int j=0;j<MAX_W;j++){
		dp[i][j]=-1;
	}
	
	
	}	
}



int main(int argc, char** argv) {
	cin>>N>>W;
	for (int i =1;i<=N;i++){
	cin>>pesos[i]>>valores[i];
	
	}
	fillDp();
	
	cout<<value(W,N)<<endl;

	return 0;
}

Measured memory_bytes: 79104