akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

const int N = 2005;
char board[N][N];
int val[N][N];

class UnionFind {
public:
	vector<int> data;
	UnionFind(int n) : data(n, -1) {}
	int find(int x) {
		if (data[x] < 0)return x;
		return data[x] = find(data[x]);
	}
	bool unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y)return false;
		if (data[x] > data[y])swap(x, y);
		data[x] += data[y];
		data[y] = x;
		return true;
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	int size(int x) {
		return -data[find(x)];
	}
};

int main() {
	int h, w;
	scanf("%d%d", &h, &w);
	REP(i, h)scanf("%s", board[i]);
	REP(i, w)val[0][i] = w - i;
	FOR(i, 1, h) {
		val[i][w - 1] = 1;
		bool same = (board[i - 1][w - 1] == board[i][w - 1]);
		for (int j = w - 2; j >= 0; j--) {
			if (same ^ (board[i - 1][j] == board[i][j])) {
				val[i][j] = 1;
				same = !same;
			}
			else val[i][j] = val[i][j + 1] + 1;
		}
	}
	int ans = max(h, w);
	REP(j, w) {
		UnionFind uf(h);
		vector<PII> vpii(h - 1);
		FOR(i, 1, h)vpii[i - 1] = MP(val[i][j], i);
		sort(ALL(vpii), greater<PII>());
		REP(i, h - 1) {
			if (uf.unite(vpii[i].second - 1, vpii[i].second)) {
				ans = max(ans, uf.size(vpii[i].second) * vpii[i].first);
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 19840
import sys


def main():
    input = sys.stdin.readline
    N = int(input())
    S = input().strip()
    A = S.count('R')*S.count('G')*S.count('B')
    assert 1 <= N <= 4000
    assert N == len(S)
    total = 0
    for j in range(1, N-1):
        for i in range(j):
            k = 2*j-i
            if k < len(S):
                if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                    total += 1
    print(A - total)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9148
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <math.h>
#define rep(i,a) for(int i=0; i<(a); ++i)
typedef long long ll;
using namespace std;

int main() {
  int h, w, n;
  cin >> h >> w >> n;
  vector<int> hs(h), ws(w);
  set<pair<int,int> > s;
  rep(i,n) {
    int r, c;
    cin >> r >> c;
    --r; --c;
    hs[r]++;
    ws[c]++;
    s.emplace(r,c);
  }
  int mh = 0, mw = 0;
  rep(i,h) mh = max(mh, hs[i]);
  rep(j,w) mw = max(mw, ws[j]);
  vector<int> is, js;
  rep(i,h) if (mh == hs[i]) is.push_back(i);
  rep(j,w) if (mw == ws[j]) js.push_back(j);
  int ans = mh+mw;
  for (int i : is) for (int j : js) {
    if (s.count(pair<int,int>(i,j))) continue;
    cout << ans << endl;
    return 0;
  }
  --ans;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 23456
#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;

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

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

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

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

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

void delete(int key){
  NodePointer t;
  for(t=nil->next;t->key != key && t != nil;t=t->next);
  if(t == nil) return;
  deleteNode(t);
  return;
}


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

}


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

    /*if ( com[0] == 'i' ) insert(key);
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
	else delete(key); 
      }
      }*/
  }
  
  printList();
  return 0;
}

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

int main() {
  std::size_t N;
  std::cin >> N;
  std::vector<double> v, c;
  for (std::size_t i = 0; i < N; ++i) {
    int tmp;
    std::cin >> tmp;
    v.push_back(tmp);
  }
  for (std::size_t i = 0; i < N; ++i) {
    int tmp;
    std::cin >> tmp;
    c.push_back(tmp);
  }
  
  int result = 0;
  std::size_t idx = 0;
  while(idx < N) {
    if (v[idx] > c[idx]) {
        result += v[idx] - c[idx];
    }
    idx++;
  }
  std::cout << result << std::endl;
  return 0;
}

Measured memory_bytes: 256
"use strict";

// read lines from stdin
const input = require("fs")
  .readFileSync("/dev/stdin", "utf8")
  .split("\n");

const N = parseInt(input[0], 10);
const lines = input[1].split(" ").map((x) => parseInt(x, 10)).sort((a, b) => b - a);

let longest = lines[0];

for (let i = 1; i < N; i++) {
  longest -= lines[i];
}

console.log(longest < 0 ? "Yes" : "No");


Measured memory_bytes: 21064
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1000000007;
inline void add(int &x,int y){(x+=y)>=mod?x-=mod:0;}
char s[300030];
int n,dp[300030][2][2][3],suf[300030],ans;
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);s[n+1]='1';
	dp[0][0][1][0]=1;
	suf[n+1]=suf[n+2]=1;
	for(int i=n;i;--i)suf[i]=s[i]=='?'?(suf[i+1]<<1)%mod:suf[i+1];
	for(int i=1;i<=n+1;++i)
	{
		if(s[i]!='1')
		{
			for(int j=0;j<2;++j)
				for(int k=0;k<2;++k)
					for(int l=0;l<3;++l)
						add(dp[i][j][k][(l&1)+1],dp[i-1][j][k][l]);
		}
		if(s[i]!='0')
		{
			for(int j=0;j<2;++j)
				for(int k=0;k<2;++k)
				{
					if(!j&&k==1)add(dp[i][1][k^1][0],dp[i-1][j][k][0]);
					else if(j==1&&!k)ans=(ans+1ll*dp[i-1][j][k][0]*suf[i+1])%mod;
					else add(dp[i][j][k^1][0],dp[i-1][j][k][0]);
					add(dp[i][j][k][0],dp[i-1][j][k][1]);
					add(dp[i][j][k^1][0],dp[i-1][j][k][2]);
				}
		}
	//	for(int j=0;j<3;++j)
	//		for(int k=0;k<2;++k)
	//			for(int l=0;l<3;++l)
	//				if(dp[i][j][k][l])
	//					printf("%d %d %d %d %d\n",i,j,k,l,dp[i][j][k][l]);
	//	printf("\n");
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 15744
import java.io.*;
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		InputReader in = new InputReader();
		int n = in.nextInt();
		
		int[] arr = new int[n];
		for (int i=0; i<n; i++) {
			arr[i] = in.nextInt();
		}
		Arrays.sort(arr);
		int num1 = arr[n/2 - 1];
		int num2 = arr[n/2];
		
		System.out.println(num2 - num1);
		
	}

	static class InputReader {
		public BufferedReader br;
		public StringTokenizer st;
		
		public InputReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = null;
		}
		
		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}

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

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

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

    return 0;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
     cout << fixed << setprecision(15);

    long double a, b, x; cin >> a >> b >> x;
    if((a*a*b)/2 < x) {
        ld ans =  atan(2*(b*a*a - x)/(a*a*a));
        cout << ans*180./(Pi) << '\n';
    }
    else if((a*a*b) == 2*x) {
        ld ans = (atan(b/a));
        cout << ans*180./(Pi) << '\n';
    }
    else {
        ld ans=  atan((a*b*b)/(2*x));
        cout << ans*180./(Pi) << '\n';
    }

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int n, u;
int k[110];
int a[110][110];
int b[110];
int d[110], f[110];
int t=1;

void dfs(int v)
{
	d[v]=t;
	t++;
	b[v]++;
	for(int l=0; l<k[v]; l++)
	{
		if(b[a[v][l]]==0)
		{
			dfs(a[v][l]);
		}
	}
	f[v]=t;
	t++;
}

int main() 
{
	cin >> n;
	for(int i=0; i<n; i++)
	{
		cin >> u;
		cin >> k[u];
		for(int j=0; j<k[u]; j++)
		{
			cin >> a[u][j];
		}
	}
	for(int v=1; v<=n; v++)
	{
		if(b[v]==0)
		{
			dfs(v);
		}
		cout << v << ' ' << d[v] << ' ' << f[v] << endl;
	}
	return 0;
}

Measured memory_bytes: 3092
# step 1: read the three digits
a, b, c = input().split()

# step 2: compute the 3-digit number
n = int(a)*100 + int(b)*10 + int(c)

# step 3: check if the 3-digit number is divisible by 4
print("YES" if n % 4 == 0 else "NO")

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = sc.nextInt();
        sc.nextLine();
        int[] d  = toArray(sc.nextLine());
        int res = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i+1; j < n; j++) {
                res += d[i]*d[j];
            }
        }
        System.out.println(res);
    }


    private static int[] toArray(String text) {
        String[] vars = text.split("\\s+");
        int[] res = new int[vars.length];
        for (int i = 0; i < vars.length; i++) {
            res[i] = Integer.valueOf(vars[i]);
        }
        return res;
    }
}


Measured memory_bytes: 21716
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#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;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

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

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>

#define pb(a) push_back(a)
#define mp make_pair

int main(){
  CIN(n,x);

  if(x<2||x>2*n-2){Yes(0);return 0;}
  Yes(1);
  //xがn以下な場合を考える
  if(x<=n){
    set<int,greater<int>> set_;FOR(i,1,n*2)set_.insert(i);
    for(int i=n*2-1;i>n;i--){SCOUT(i);set_.erase(i);}
    SCOUT(x);SCOUT(x-1);set_.erase(x);set_.erase(x-1);
    FOREACH(xx,set_){if(set_.size()==1)COUT(xx);else SCOUT(xx);}
  }
  else{
    S set_;FOR(i,1,n*2)set_.insert(i);
    stack<int> que;FOR(i,1,n){que.push(i);set_.erase(i);}
    que.push(x);que.push(x+1);set_.erase(x);set_.erase(x+1);
    FOREACH(xx,set_)que.push(xx);
    while(que.size()!=1){SCOUT(que.top());que.pop();}
    COUT(que.top());
  }

  /*
  vector<V> v(n,V(2*n-1));iota(ALL(v[0]),1);
  REP(i,n)v[i].resize(2*(n-i)-1);
  auto med = [&](int a,int b,int c){V h={a,b,c};sort(ALL(h));return h[1];};
  map<int,V> set_;
  do{
    FOR(i,1,n)
      REP(j,2*(n-i)-1)
        v[i][j]=med(v[i-1][j],v[i-1][j+1],v[i-1][j+2]);
    set_[v[n-1][0]]=v[0];
  }while(next_permutation(ALL(v[0])));
  FOREACH(xx,set_){cout<<xx.first<<" : ";VECCOUT(xx.second);}
  */


  return 0;
}



Measured memory_bytes: 10880
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N = 555;
typedef pair<int , int> pii;
#define mp make_pair
#define fi first
#define se second

int n , mod;
int cnt[N] , dp[2][N];
pii a[N];

template <typename T> inline void chkmin(T &x , T y) { x = min(x , y); }
template <typename T> inline void chkmax(T &x , T y) { x = max(x , y); }
template <typename T> inline void read(T &x)
{
   T f = 1; x = 0;
   char c = getchar();
   for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
   for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + c - '0';
   x *= f;
}
inline void add(int &x , int y) {
	x += y;
	while (x >= mod) x -= mod;
}
inline int solve(int k) {
	memset(dp , 0 , sizeof(dp));
	dp[0][0] = 1;
	for (int i = 0; i < 2 * n; ++i) {
		int now = i & 1 , nxt = now ^ 1;
		memset(dp[nxt] , 0 , sizeof(dp[nxt]));
		for (int j = 0; j <= k; ++j) {
			if (a[i].se == -1) {
				int b = a[i].fi - cnt[i] - j;
				if (b > 0) dp[nxt][j] = (dp[nxt][j] + 1ll * dp[now][j] * b % mod) % mod;
			}  else {
				int b = a[i].se - (i + (k - j) + cnt[2 * n] - cnt[i]);
				if (b > 0) dp[nxt][j] = (dp[nxt][j] + 1ll * dp[now][j] * b % mod) % mod;
				b = a[i].fi - cnt[i] - j;
				if (b > 0 && j < k) dp[nxt][j + 1] = (dp[nxt][j + 1] + 1ll * dp[now][j] * b % mod) % mod;
			}
		} 
	}
	return dp[0][k];
}

int main()	{
	
	read(n); read(mod);
	for (int i = 0; i < 2 * n; ++i) {
		int x = 0;
		while (i * i + x * x < n * n) ++x;
		int y = x;
		while (y < 2 * n && i * i + y * y <= 4 * n * n) ++y;
		if (x == 0) a[i] = mp(y , -1);
		else a[i] = mp(x , y);
	}
	sort(a , a + 2 * n);
	for (int i = 0; i < 2 * n; ++i) {
		cnt[i + 1] = cnt[i];
		if (a[i].se == -1) ++cnt[i + 1];
	}
	int ans = 0;
	for (int k = 0; k <= n; ++k) {
		int val = solve(k);
		if (k & 1) ans = (ans - val + mod) % mod;
		else ans = (ans + val) % mod;
	}	
	printf("%lld\n" , ans);
	
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
using namespace std;
int N;
int pret,prex,prey,t,x,y;
int ans=1;
int main(){
    scanf("%d",&N);
    pret=0;prex=prey=0;
    for(int i=0;i<N;i++){
        scanf("%d%d%d",&t,&x,&y);
        //cout<<t<<" "<<x<<" "<<y<<endl;
        int time = t - pret;
        int needtime = abs(prex-x) + abs(prey-y);
       // cout<<"time："<<time<<endl<<"needtime:"<<needtime<<endl;
        if(ans&&time>=needtime&&((time-needtime)%2==0))ans=1;
        else {ans=0;}
       // cout<<"ans:"<<ans<<endl;
        pret=t;prex=x;prey=y;
}
    if(ans)printf("Yes");
    else printf("No");
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main
{
  static class FastScanner
  {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    String next() {
      while(!st.hasMoreTokens()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {}
      }
      return st.nextToken();
    }
    
    int nextInt() {
      return Integer.parseInt(next());
    }
    
    long nextLong() {
      return Long.parseLong(next());
    }
    
  }
  
  public static void main(String[] args) {
    FastScanner fs = new FastScanner();
    int N = fs.nextInt();
    long[][] arr = new long[N][3];
    for(int i = 0; i < N; ++i) {
      for(int j = 0; j < 3; ++j) {
        arr[i][j] = fs.nextLong();
      }
    }
    PrintWriter out = new PrintWriter(System.out);
    out.println(solve(arr));
    out.close();
  }
  
  public static long solve(long[][] arr) {
    int N = arr.length;
    long[] a = new long[N];
    long[] b = new long[N];
    long[] c = new long[N];
    a[0] = arr[0][0]; b[0] = arr[0][1]; c[0] = arr[0][2];
    for(int i = 1; i < N; ++i) {
      a[i] = arr[i][0] + Math.max(b[i-1], c[i-1]);
      b[i] = arr[i][1] + Math.max(a[i-1], c[i-1]);
      c[i] = arr[i][2] + Math.max(b[i-1], a[i-1]);
    }
    return Math.max(Math.max(a[N-1], b[N-1]), c[N-1]);
  }
  

}

Measured memory_bytes: 60972
import java.util.*;

class Main {
    final Scanner sc = new Scanner(System.in);

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

    private void run() {
        int n = sc.nextInt();
        Set<Long> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            long a = sc.nextInt();
            if (set.contains(a)) {
                System.out.println("NO");
                return;
            }
            set.add(a);
        }
        System.out.println("YES");
    }
}


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

void solve(long long A, long long B)
{
    cout << (((A >= 1 && A <= 9) && (B >= 1 && B <= 9)) ? (A * B) : -1) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>

using namespace std;

string tolower(string &s) {
	string t;
	for (int i = 0;i < s.length();i++) {
		t += tolower(s[i]);
	}
	return t;

}

int main(){
	string w, t;
	int cnt = 0;
	cin >> w;
	w = tolower(w);
	while (1) {
		cin >> t;
		if (t == "END_OF_TEXT") break;
		if (w == tolower(t)) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int c4 = 0;
  int c2 = 0;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    if (x % 4 == 0) c4 += 1;
    else if (x % 2 == 0) c2 += 1;
  }
  int L = c4 * 2 + c2;
  if (L >= N || (c2 == 0 && L == N-1 && N % 2 != 0)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<string>
#include<vector>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> S[N];
    for(int i=0; i<N; i++){
        string s;
        cin >>s;
        for(int j = 0;j <N; j++){
            if(s[j] == '1'){
                S[i].push_back(j);
            }
        }
    }

    int ans = -1;

    for(int i =0; i<N; i++){
        queue<pair<int, int > > q;
        int r[N]; for(int j=0; j<N; j++) r[j] = 201;
        bool used[N]; for(int j =0 ; j<N;j++) used[j] =false;


        q.push({i, 1});
        bool ok = true;
        int rk;
        used[i] = true;;

        while(!q.empty()){
            auto v = q.front(); q.pop();
            int vn = v.first;
            rk = v.second;
            for(int j : S[vn]){
                
                if(r[j] == rk){
                    ok = false;
                    break;
                }
                else if(!used[j]){
                    q.push({j, rk + 1});
                    r[j] = rk + 1;
                    used[j] = true;
                }
                
            }
            if(!ok) break;
        }

        if(ok) ans = max(ans, rk);
        else break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
S = input()
i = 0
n = len(S)
while i <= n-5:
    if S[i:i+5] == "dream":
        i += 5
        if S[i:i+2] == "er" and S[i:i+5] != "erase":
            i += 2
    elif S[i:i+5] == "erase":
        i += 5
        if S[i:i+1] == "r":
            i += 1
    else:
        break
if i != len(S):
    print("NO")
else:
    print("YES")

Measured memory_bytes: 9232
from collections import namedtuple

sword = namedtuple('sw', ('wield', 'throw'))


def main() -> None:
    n, h = map(int, input().split())
    cnt = 0

    swords = []
    for i in range(n):
        a, b = map(int, input().split())
        swords.append(sword(wield=a, throw=b))

    swords.sort(key=lambda x: x.throw, reverse=True)
    swords.sort(key=lambda x: x.wield)
    main_sword = swords.pop()
    swords.sort(key=lambda x: x.throw)

    while h > 0:
        cnt += 1
        if main_sword.throw >= h:
            h -= main_sword.throw
        elif len(swords) > 0 and main_sword.wield < swords[-1].throw:
            h -= swords.pop().throw
        else:
            h -= main_sword.throw
            cnt += 1 + (h - 1) // main_sword.wield
            break

    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 72408
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)

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

	int n; cin >> n;
	vector<pair<ll, ll>> p;
	rep(i, 0, n) {
		ll a, b; cin >> a >> b;
		p.emplace_back(b, a);
	}
	sort(p.begin(), p.end());

	ll now = 0;
	rep(i, 0, n) {
		now += p[i].second;
		if (now > p[i].first) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}


Measured memory_bytes: 7384
N,x = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a)
count = 0
while(x >= 0):
  if(count == N):
    break
  tmp = a.pop(0)
  if(x >= tmp):
    x = x - tmp
    count += 1
  else:
    break
if(count == N and x != 0):
  count -= 1
print(str(count))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  int ans=0;
  rep(i,N-2){
    if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C') ans++;
  }
  cout<<ans<<endl;
}

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

using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
const ll MOD=1000000007;

int main(){
	ll N,K; cin>>N>>K;
	vector<ll> A(N);
	rep(i,N) cin>>A[i];
	ll cnt=0,cnt2=0;

	//1つの転倒数
	rep(i,N-1){
		FOR(j,i+1,N){
			if(A[i]>A[j]) cnt++;
		}
	}

	//またがる転倒数
	rep(i,N)rep(j,N){
		if(A[i]>A[j]) cnt2++;
	}

	cout<<((cnt*K)%MOD+(cnt2*((K*(K-1)/2)%MOD))%MOD)%MOD;
}

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

#define rep(i,s,e) for (int i = s; i < e; ++i)
using namespace std;

int main()
{
	string a, b; cin >> a >> b;

	int c = stoi(a + b);

	bool OK = false;
	rep(i, 1, 100100) {
		if (c == i * i) {
			OK = true;
			break;
		}
	}
	cout << (OK ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class name
{

    static void Main()
    {


        int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();

        if (s[0] >= 30)
        {

            Console.WriteLine("Yes");

        }

        else
        {
            Console.WriteLine("No");

        }





    }






}

Measured memory_bytes: 28284
/*
	Solved!
	Time: 05:23:26 PM
	Date: 05-04-2020
*/
#include <bits/stdc++.h>
using namespace std;
 
typedef unsigned long long  ll;
typedef vector<int>         vi;
typedef vector<ll>          vll;

#define ff                  first
#define sf                  scanf
#define pf                  printf
#define ss                  second
#define ppb                 pop_back
#define pb                  push_back
#define MP                  make_pair
#define MAXN                5000005
#define MOD                 100000007
#define inf                 0x3f3f3f3f
#define PI                  (2.0*acos(0.0))
#define INF                 0x3f3f3f3f3f3f3f3f
#define rev(v)              reverse(all(v))
#define all(v)              v.begin(), v.end()
#define __lcm(x, y)         (x * y) / __gcd(x, y)
#define FOR(i, x, y)        for(int i = x; i < y; i++)
#define RFOR(i, x, y)       for(int i = x; i >= y; i--)
#define MEM(arr, val)       memset(arr, val, sizeof(arr));
#define unq(v)              (v).resize(unique(all(v)) - v.begin())
#define READ()              freopen("input.txt", "r", stdin)
#define WRITE()             freopen("output.txt", "w", stdout)
#define si(n)               scanf("%d", &n)
#define sl(n)               scanf("%lld", &n)
#define sii(a, b)           scanf("%d %d", &a, &b)
#define sll(a, b)           scanf("%lld %lld", &a, &b)
#define siii(a, b, c)       scanf("%d %d %d", &a, &b, &c)
#define slll(a, b, c)       scanf("%lld %lld %lld", &a, &b, &c)
#define siiii(a, b, c, d)   scanf("%d %d %d %d", &a, &b, &c, &d)
#define sllll(a, b, c, d)   scanf("%lld %lld %lld %lld", &a, &b, &c, &d)
#define vout(v)             for(int i = 0; i < v.size(); i++) {cout << v[i]; if(i < v.size() - 1) cout << ' '; else cout << endl;}

int main(){
    /*#ifndef ONLINE_JUDGE
        double start = clock(); READ(); WRITE();
    #endif*/
        string s; cin >> s;
        int ans = 1;
        if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) ans = 0;
        puts(ans ? "Good" : "Bad");

    /*#ifndef ONLINE_JUDGE
        printf("\n>>Runtime: %.10fs\n", (double)(clock() - start) / CLOCKS_PER_SEC);
    #endif*/

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <stdio.h>
using namespace std;
#define ll long long
string a;
map<char, ll> m;
ll choose(ll a){
	if (a == 1) return 0;
	return a*(a - 1)/2;
}
int main(){
	cin >> a;
	for (int i = 0; i < a.length(); i++){
		if (m.find(a[i]) == m.end()){
			m[a[i]] = 1;
		} else {
			m[a[i]] = m[a[i]] + 1;
		}
	}
	ll answer = choose((long long)a.length());
	for (map<char, ll>::iterator it = m.begin(); it != m.end(); it++){
		answer -= choose(it -> second);
	}
	printf("%lld\n", answer+1);
	
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include <stdexcept>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
typedef long long ll;
int ceil(int a,int b){// a以上でbの倍数の最小値を出力//
    return (a+b-1)/b*b;
}

//シフト演算　(1<<k) 2のk乗

int stoii(string s){//stoi関数の代用 文字列を数値として読み取りint型に変換//
    return atoi(s.c_str());
}
int main (void){
    string s;
    s="t";
    vector<int> v(32,0);
    vector<int> c(300000,500);
    int j=0;

    while(s!="#"){
        cin>>s;
        if(s=="#") break;
        rep(i,s.size()){
                if(s[i]=='y'||s[i]=='u'||s[i]=='o'||
                s[i]=='i'||s[i]=='p'||s[i]=='h'||s[i]=='j'
                ||s[i]=='k'||s[i]=='l'||s[i]=='n'||s[i]=='m'
                ){
                    v[i]=1;
                }    
                else{
                    v[i]=0;
                }    
        }
        int cnt=0;
        rep(i,s.size()-1){
            if(v[i]!=v[i+1]) cnt++;
        }
        c[j]=cnt;
        j++;
    }
    int f=0;
    while(f!=j){
        cout<<c[f]<<endl;
        f++;
    } 
}


Measured memory_bytes: 3728
#define _USE_MATH_DEFINES

#include <bits/stdc++.h> 
  
using namespace std;
  
#define $(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl '\n'
#define x first
#define y second    
#define int long long
#define double long double       
#define vec vector            
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double> 
#define beg begin
  
#ifdef LOCAL
    #define dbg(x) cerr << #x << " = " << x << endl;
#else 
    #define dbg(x)
#endif 
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);                                       
    freopen("output.txt", "w", stdout);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(6);    
    solve();   
    return 0;
}

const int INF = 1e18;

void solve() {
    int n, a, b;
    cin >> n >> a >> b;
    if (a % 2 == b % 2) {
        cout << (b - a) / 2 << endl;
    }
    else {
        int pa = a, pb = b;
        int t = (n - b + 1), ans = INF;
        if (a + t == n) {
            ans = t;
        }
        else {
            a += t;
            t += (n - a) / 2;
            ans = t;
        }
        a = pa, b = pb;
        t = (a - 1 + 1);
        dbg(t)
        if (b - t == 1) {
            ans = min(ans, t);
        }
        else {
            b -= t;
            t += (b - 1) / 2;
            ans = min(t, ans);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,d;
    cin >> n >> d;
    int ans = 0;
    while(n>0){
        n-=d*2+1;
        ans++;
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        char[] s = sc.next().toCharArray();
        for (int i = 0; i < s.length; i++) {
            if (i < s.length - 1) {
                if (s[i] == s[i + 1]) {
                    System.out.println((i + 1) + " " + (i + 2));
                    return;
                }
                if (i < s.length - 2) {
                    if (s[i] == s[i + 2]) {
                        System.out.println((i + 1) + " " + (i + 3));
                        return;
                    }
                }
            }
        }
        System.out.println("-1 -1");
    }

}


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

using namespace __gnu_pbds;
using namespace std;

#define setbits(x) __builtin_popcountll(x)
#define zerobits(x) __builtin_ctzll(x)
#define deb(x) cout << #x << " -> " << x << "\n"

template<class T> bool uin(T a, T b) { return a > b ? (a == b, true) : false; }
template<class T> bool uax(T a, T b) { return a < b ? (a == b, true) : false; }

#ifdef LOCAL_DEFINE
	mt19937 rng(228);
#else 
	mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ll MOD = 1000000007;
const ll INF = 1e18;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	int x;
	cin >> x;
	if (x >= 400 && x <= 599) cout << "8" << "\n";	
	if (x >= 600 && x <= 799) cout << "7" << "\n";	
	if (x >= 800 && x <= 999) cout << "6" << "\n";	
	if (x >= 1000 && x <= 1199) cout << "5" << "\n";	
	if (x >= 1200 && x <= 1399) cout << "4" << "\n";	
	if (x >= 1400 && x <= 1599) cout << "3" << "\n";	
	if (x >= 1600 && x <= 1799) cout << "2" << "\n";	
	if (x >= 1800 && x <= 1999) cout << "1" << "\n";	
	return 0;
}


Measured memory_bytes: 3656
import sys
sys.setrecursionlimit(10 ** 7)

h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]

seen = [[0] * w for _ in range(h)]

dxdy = [(-1, 0), (1, 0), (0, -1), (0, 1)]

global ans
def dfs(x, y):
    seen[y][x] = 1
    a, b = 1, 0
    for dx, dy in dxdy:
        nx = x + dx
        ny = y + dy
        if 0 <= nx < w and 0 <= ny < h and not seen[ny][nx] and s[y][x] != s[ny][nx]:
            p = dfs(nx, ny)
            a += p[1]
            b += p[0]
    
    return (a, b)

ans = 0
for i in range(h):
    for j in range(w):
        if not seen[i][j]:
            p = dfs(j, i)
            ans += p[0] * p[1]
print(ans)


Measured memory_bytes: 157704
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <map>
#include <set>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;

int main() {
    cout.setf(ios::fixed, ios::floatfield);
    cout.setf(ios::showpoint);
    cout.precision(12);
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    long long a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    if(2 * c > a + b) {
        long long res = x * a + y * b;
        cout << res << endl;
        return 0;
    }

    long long done = min(x, y);
    long long res = done * 2 * c;
    x -= done;
    y -= done;

    res += x * min(a, 2 * c);
    res += y * min(b, 2 * c);

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define rep(i, o) for (ll i = 0; i < (o);i++)
#define rep_s(i, o) for (int i = 1; i <= (o);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }


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

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

int main() {
    ll n, m; cin >> n >> m;
    
    vector<ll> a(m+2), b(m+2);
    map<ll, ll> islands_ships; 
    rep(i, m) {
        cin >> a[i] >> b[i];
        (islands_ships[b[i]] == n) ? islands_ships[b[i]] 
                                   : islands_ships[a[i]] = b[i];
    }

    rep(i, m) {
        if (islands_ships[b[i]] == n) islands_ships[a[i]] = b[i];
    }

    string ans = (islands_ships[islands_ships[1]] == n) ? "POSSIBLE" : "IMPOSSIBLE";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 18800
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    Cins(string, n, s);
    Sort(s);
    Unique(s);
    Cout(s.size());
}


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

using st_t = set<int>;
using vs = vector<st_t>;

int main()
{
    ios_base::sync_with_stdio(0);

    int n, m; cin >> n >> m;

    vs v(n + 1);

    for(int i = 0; i < m; i++)
    {
        int a, b; cin >> a >> b;

        v[a].insert(b);
        v[b].insert(a);
    }

    for(auto x : v[1]) if(v[x].count(n))
    {
        cout << "POSSIBLE" << endl;
        return 0;
    }

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

Measured memory_bytes: 28416
#include <bits/stdc++.h>
#define db(x) cout << (x) << '\n';
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pii;
typedef pair<double,ll> pdi;
typedef pair<string,ll> psi;
typedef pair<ll,string> pls;
typedef pair<string,string> pss;
typedef pair<ll,pii> pip;
typedef pair<pii,pii> ppp;
#define MAXN 200005

int a[MAXN],res[MAXN],mk[MAXN];
vector<int> lis,g[MAXN];

void dfs(int u)
{
    mk[u]=1;
    int p=lower_bound(all(lis),a[u])-lis.begin();
    int ant=-1;
    if(p<lis.size())
    {
        ant=lis[p];
        lis[p]=a[u];
    }
    else
        lis.push_back(a[u]);
    res[u]=lis.size();

    for(auto v : g[u])
        if(!mk[v])
            dfs(v);

    if(ant==-1)
        lis.pop_back();
    else
        lis[p]=ant;
}

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

    int n,u,v;
    cin >> n;
    for(int i=0;i<n;i++)
        cin >> a[i];
    for(int i=0;i<n-1;i++)
    {
        cin >> u >> v;
        u--,v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    dfs(0);

    for(int i=0;i<n;i++)
        db(res[i])

    return 0;
}
/**
10
1 2 5 3 4 6 7 3 2 4
1 2
2 3
3 4
4 5
3 6
6 7
1 8
8 9
9 10
**/


Measured memory_bytes: 25524
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, pair<int, int>>> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
int INFM =100000000;
ll MOD  = 1000000007;
 

 
 
int main(){
    string s;
    stack<int> st;
    int a, b;
    while(cin >> s){
        if(s[0] == '+'){
            b = st.top(); st.pop();
            a = st.top(); st.pop();
            st.push(a + b);
        }else if(s[0] == '-'){
            b = st.top(); st.pop();
            a = st.top(); st.pop();
            st.push(a - b);
        }else if(s[0] == '*'){
            b = st.top(); st.pop();
            a = st.top(); st.pop();
            st.push(a * b);        
        }else{
            st.push(atoi(s.c_str()));
        }
    }
    cout << st.top() << endl;
  return 0;
}


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

long long n, b, r;

int main( int argc, char *argv[] )
{
    long long ret;
    long long ret1;

    scanf( "%lld%lld%lld", &n, &b, &r );

    if( b == 0 ) {
        puts( "0" );
        exit( 0 );
    }

    ret = n / (b + r );
    ret *= b;

    ret1 = n % ( b + r);
    if( ret1 >= b ) ret += b;
    else            ret += ret1;

    printf( "%lld\n", ret );
}


Measured memory_bytes: 128
line = readlines
len = line.length
i = 0

while i < len
    line[i] = line[i].chomp
    i += 1
end

N = line[0].to_i
S = line[1]

if N % 2 == 1 then
  print "No"
else
  half_point = N / 2
  s1 = S[0..half_point - 1]
  s2 = S[half_point..N-1]
  if s1 == s2 then
    print "Yes"
  else
    print "No"
  end
end

Measured memory_bytes: 1788
n, a, b = map(int, input().split())
mod = (10 ** 9) + 7

ans = pow(2, n, mod) - 1
an = 1
for i in range(n - a + 1, n + 1):
    an *= i
    an %= mod
for i in range(1, a + 1):
    an *= pow(i, mod - 2, mod)
    an %= mod
bn = 1
for i in range(n - b + 1, n + 1):
    bn *= i
    bn %= mod
for i in range(1, b + 1):
    bn *= pow(i, mod - 2, mod)
    bn %= mod

ans -= (an + bn)
print(ans % mod)


Measured memory_bytes: 3064
// AUTHOR: ROSHAN SRIVASTAVA
// WEBSITE: https://www.youtube.com/channel/UC6uQdd7kLLOdlHSVklhV7Cw

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

int n; 

int main(){

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    cin >> n;
    vector <ll> a(n);
    for(int i =0 ; i < n; i++) 
        cin >> a[i];

    ll sum = 0;
    ll ans = 0;

    for(int i = n - 2; i >= 0; i--) {
        sum += a[i + 1];
        sum %= mod;
        ans += ((sum * a[i]) % mod);
        ans %= mod;
    }


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

Measured memory_bytes: 4840
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int n = sc.nextInt();
		int p[] = new int[n];

		int min = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			p[i] = sc.nextInt();
		}

		int ans = 0;
		for (int i = 101; -101 <= i; i--) {
			boolean con = false;
			for (int j = 0; j < n; j++) {
				if (i == p[j]) con = true;
			}
			if (con) continue;
			if (Math.abs(x - i) <= min) {
				min = Math.abs(x - i);
				ans = i;
			}
		}

		System.out.println(ans);

		sc.close();
	}

}


Measured memory_bytes: 36012
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // メインプログラムここから
    vector<ll> v;
    ll n;
    ll ans=0;
    
    cin >> n;
    
    v.resize(2*n);
    
    rep(i,2*n){
        cin >> v[i];
    }
    
    sort(v.begin(),v.end());
    
    rep(i,n){
        ans += min(v[2*i],v[2*i+1]);
    }
    
    cout << ans << endl;
            
    // ここまで
}


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

#define file(s) freopen(s".in","r",stdin), freopen(s".out","w",stdout)

#define Grt ch=getchar()
#define DeBug(x) std::cout<<#x<<'='<<x<<std::endl

const int MaxN=1e5+10, MaxM=1<<15+10, inf=0x3f3f3f3f;

namespace IO
{
	char buf[1<<15], *fs, *ft;
	inline char getc() { return ft==fs && (ft=(fs=buf)+fread(buf, 1, 1<<15, stdin), ft==fs) ? 0 : *fs++; }
	template <typename T> inline void read(T &x)
	{
		x=0;
		T f=1, Grt;
		while (!isdigit(ch) && ch^'-') Grt;
		if (ch=='-') f=-1, Grt;
		while (isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48), Grt;
		x*=f;
	}

	template <typename T, typename... Args>
	inline void read(T &x, Args &...args) { read(x); read(args...); }

	char Out[1<<24], *fe=Out;
	inline void flush() { fwrite(Out, 1, fe-Out, stdout); fe=Out; }
	template <typename T> inline void write(T x, char str)
	{
		if (!x) *fe++=48;
		if (x<0) *fe++='-', x=-x;
		T num=0, ch[20];
		while (x) ch[++num]=x%10+48, x/=10;
		while (num) *fe++=ch[num--];
		*fe++=str;
	}
}

using IO::read;
using IO::write;

template <typename T> inline bool chkMin(T &a, const T &b) { return a>b ? (a=b, true) : false; }
template <typename T> inline bool chkMax(T &a, const T &b) { return a<b ? (a=b, true) : false; }
template <typename T> inline T min(T a, T b) { return a<b ? a : b; }
template <typename T> inline T max(T a, T b) { return a>b ? a : b; }

int n, ans, state;
int v[MaxN], cnt[20], f[MaxM];
inline int dp(int s)
{
	if (!s) return 0;
	if (f[s]<inf) return f[s];
	for (int i=0; i<=15; ++i) if (s&(1<<i))
		for (int j=0; j<=15; ++j) if (i^j && (s&(1<<j)))
		{
			int x=i^j, y=s^(1<<i)^(1<<j)^(1<<x);
			if (s&(1<<x)) chkMin(f[s], dp(y)+2);
			else chkMin(f[s], dp(y)+1);
		}
	return f[s];
}

int main()
{
	read(n);
	for (int i=1, x, y, z; i< n; ++i) read(x, y, z), ++x, ++y, v[x]^=z, v[y]^=z;
	for (int i=1; i<=n; ++i) ++cnt[v[i]];
	for (int i=1; i<=15; ++i) ans+=(cnt[i]>>1), state+=(cnt[i]&1)*(1<<i);
	memset(f, 0x3f, sizeof(f));
	write(ans+dp(state), '\n');
	IO::flush();
	return 0;
}

Measured memory_bytes: 133504