akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using int64 = long long;
const int mod = (int) (1e9 + 7);

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

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

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

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int A;
  cin >> A;
  string S;
  cin >> S;
  if(A >= 3200) cout << S << endl;
  else cout << "red\n";


}

Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d %d", $n, $x);
$input = trim(fgets(STDIN));
$l_arr = explode(' ', $input);

$point_arr = [0];
for ($i = 0; $i < $n; ++$i) {
    $tmp_sum = 0;
    for ($j = 0; $j <= $i; ++$j) {
        $tmp_sum += $l_arr[$j];
    }
    $point_arr[$i + 1] = $tmp_sum;
}

$count = 0;
foreach ($point_arr as $point) {
    if ($point <= $x) {
        ++$count;
    }
}

echo $count;


Measured memory_bytes: 4732
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a[101][101], b[101][101];
    long c[101][101]={0};
    int n, m, l, i, j, k;
    
    scanf("%d%d%d", &n, &m, &l);
    
    for(i=0; i<n; i++){
        for(j=0; j<m; j++){
            scanf("%d", &a[i][j]);
        }
    }
    
    for(i=0; i<m; i++){
        for(j=0; j<l; j++){
            scanf("%d", &b[i][j]);
        }
    }
    
    for(i=0; i<n; i++){
        for(k=0; k<m; k++){
            for(j=0; j<l; j++){
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }
    
    for(i=0; i<n; i++){
        for(j=0; j<l; j++){
            printf("%ld", c[i][j]);
            
            if(l-1 == j){
                printf("\n");
            }
            else{
                printf(" ");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 768
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

template <class T>
class EdgeBase
{
public:
    int to;
    T cost;
    EdgeBase(){};
    EdgeBase(int to0, T cost0){to = to0; cost = cost0;}
};
typedef EdgeBase<int> Edge;

template<class T>
void shortestPath(const vector<vector<EdgeBase<T> > >& edges, int start, vector<T>& dist)
{
    const T INF = numeric_limits<T>::max();
    const T EPS = static_cast<T>(1.0e-10);

    dist.assign(edges.size(), INF);
    dist[start] = 0;
    priority_queue<pair<T,int>, vector<pair<T,int> >, greater<pair<T,int> > > q;
    q.push(make_pair(0, start));

    while(!q.empty()){
        pair<T, int> p = q.top();
        q.pop();
        int v = p.second;
        if(dist[v] < p.first - EPS)
            continue;
        for(unsigned i=0; i<edges[v].size(); ++i){
            EdgeBase<T> e = edges[v][i];
            if(dist[v] + e.cost < dist[e.to] - EPS){
                dist[e.to] = dist[v] + e.cost;
                q.push(make_pair(dist[e.to], e.to));
            }
        }
    }
}

int main()
{
    int n, m;
    cin >> n >> m;

    map<pair<int, int>, int> index;
    vector<vector<Edge> > edges(n);
    for(int i=0; i<n; ++i)
        index[make_pair(i+1, -1)] = i;

    for(int i=0; i<m; ++i){
        int p, q, c;
        cin >> p >> q >> c;
        if(index.find(make_pair(p, c)) == index.end()){
            index[make_pair(p, c)] = edges.size();
            edges.resize(edges.size() + 1);
        }
        if(index.find(make_pair(q, c)) == index.end()){
            index[make_pair(q, c)] = edges.size();
            edges.resize(edges.size() + 1);
        }

        int a = index[make_pair(p, c)];
        int b = index[make_pair(q, c)];
        edges[a].push_back(Edge(b, 0));
        edges[b].push_back(Edge(a, 0));

        int a2 = index[make_pair(p, -1)];
        int b2 = index[make_pair(q, -1)];
        edges[a].push_back(Edge(a2, 0));
        edges[a2].push_back(Edge(a, 1));
        edges[b].push_back(Edge(b2, 0));
        edges[b2].push_back(Edge(b, 1));
    }

    vector<int> dist;
    shortestPath(edges, index[make_pair(1, -1)], dist);

    int ans = dist[index[make_pair(n, -1)]];
    if(ans < INT_MAX)
        cout << ans << endl;
    else
        cout << -1 << endl;

    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N+1),B(N);
  for(int i=0;i<N+1;i++){
    cin >> A.at(i);
  }
  for(int i=0;i<N;i++){
    cin >> B.at(i);
  }
  long long count=0;
  for(int i=0;i<N;i++){
    int C=min(A.at(i),B.at(i));
    A.at(i)-=C;
    count+=C;
    B.at(i)-=C;
    int D=min(A.at(i+1),B.at(i));
    A.at(i+1)-=D;
    count+=D;
    B.at(i)-=D;
  }
  cout << count << endl;
}  

Measured memory_bytes: 4008
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e3+4;


int32_t main(){
	cin.tie(0)->sync_with_stdio(0);
	#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	#endif
	int n;
	cin>>n;
	cout<<(1-n);
} 



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

typedef long long ll;

int gcd(int x, int y) {
    if (y == 0) return x;
    return gcd(y, x % y);
}

int main() {
    int K;
    cin >> K;
    ll ans = 0;
    for (int a = 1; a <= K; a++) {
        for (int b = 1; b <= K; b++) {
            for (int c = 1; c <= K; c++) {
                ans += gcd(a, gcd(b, c));
            }
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <cmath>
#include <algorithm>
using namespace std;
const int N = 1e4;
const double eps = 1e-15;
const double inf = 1e10;
inline double sqr (double k) {return k * k;}
inline int sgn (double p) {
    if (fabs (p) < eps) return 0;
    if (p < 0) return -1;
    return 1;
}
struct point {
    double x, y;
    point () {}
    point (double _x, double _y) {
        x = _x, y = _y;
    }
    void input () {
        scanf ("%lf %lf", &x, &y);
    }
    bool operator == (point b) const {
        return sgn (x - b.x) == 0 && sgn (y - b.y) == 0;
    }
    point operator - (const point &b) const {
        return point (x - b.x, y - b.y);
    }
    double operator * (const point &b) const {
        return x * b.x + y * b.y;
    }
    double operator ^ (const point &b) const {
        return x * b.y - y * b.x;
    }
    double len () {
        return hypot (x, y);
    }
    double len2 () {
        return x * x + y * y;
    }
    double distance (point p) {
        return hypot (x - p.x, y - p.y);
    }
    point operator + (const point &b) const {
        return point (x + b.x, y + b.y);
    }
    point operator * (const double &b) const {
        return point (x * b, y * b);
    }
    point operator / (const double &b) const {
        return point (x / b, y / b);
    }
    double cross (point a, point b) {///叉积
        return (a - *this) ^ (b - *this);
    }
    double dot (point a, point b) {///点积
        return (a - *this) * (b - *this);
    }
    bool on_seg (point a, point b) {///点是否在线段ab上
        return sgn (cross (a, b)) == 0 && dot (a, b) <= 0;
    }
} ps[N];
///两线段是否相交
bool seg (point a, point b, point c, point d) {
    if (c.y > d.y) swap (c, d);
    if (c.on_seg (a, b)) return true;
    if (a.cross (b, d) * a.cross (b, c) < 0 && c.cross (d, b) * c.cross (d, a) < 0) return true;
    return false;
}
/// 点的投影是否在线段ab上
bool check (point p, point a, point b) {
    point x = b - a;
    double k = x.len ();
    double u = a.dot (p, b) / k;
    x = (x / k) * u;
    x = x + a;
    if (x.on_seg (a, b)) return true;
    return false;
}
int cmp (point a, point b) {
    if ((a ^ b) > 0) return true;
    return false;
}
int main () {
//    freopen ("in.txt", "r", stdin);
    int n, Q;
    cin >> n;
    for (int i = 1; i <= n; i++) ps[i].input ();
    ps[n + 1] = ps[1];
    ps[0] = ps[n];
    cin >> Q;
    while (Q --) {
        int ans = 0;
        point s, e, a, b;
        s.input ();
        e = point (inf, s.y);
        for (int i = 1; i <= n + 1; i++) if (s.on_seg (ps[i], ps[i - 1])) ans = 1;
        if (ans) {
            cout << 1 << endl;
            continue;
        }
        for (int i = 1; i <= n; i++) {
            if (seg (s, e, ps[i], ps[i - 1])) {
                if (sgn (ps[i].y - ps[i - 1].y) == 0) ans++;
//                cout << i << "*****";
                ans++;
            }

        }
//        cout << ans << endl;
        if (ans % 2 == 0) cout << 0 << endl;
        else cout << 2 << endl;
    }
    return 0;
}



Measured memory_bytes: 3316
s=int(input())
d_l=[s]
flag=0
while True:
    n=d_l[flag]
    if n%2==0:
        temp=n/2
    else:
        temp=3*n+1
    flag+=1
    if temp in d_l:
        break
    else:
        d_l.append(temp)
print(flag+1)

Measured memory_bytes: 3060
h, w, m = map(int, input().split())
col = [0]*w
row = [0]*h
ypos = []
xpos = []
bomb = []

for i in range(m):
    H, W = map(lambda x: int(x) - 1, input().split())
    col[W] += 1
    row[H] += 1
    bomb.append((H, W))

maxcol = max(col)
maxrow = max(row)

for i in range(w):
    if col[i] == maxcol:
        xpos.append(i)
for i in range(h):
    if row[i] == maxrow:
        ypos.append(i)

ans = maxcol + maxrow - 1
bomb = set(bomb) #setにすると速い

for i in ypos:
    for j in xpos:
        if (i, j) not in bomb:
            ans += 1
            print(ans)
            exit()
print(ans)

Measured memory_bytes: 90188
A, B, C = map(int, input().split())
_max = max(A, B, C)
sum = A + B + C
ans = 0
# 50回目の試行結果の判定は５１回目に実施する必要があるので51回ループ回す
for i in range(51):
    a = sum % 3
    b = sum / 3  
    #print(sum)
    if a == 0 and  b >= _max:
        print(ans)
        break
    else:
        ans += 1
        sum += 2
#print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 3e3+5;
const lli INF = 1e18;
const lli MOD = 1e9+7;

vi m;
vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	m = vi(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

lli SUM(lli a, lli b, lli mod=MOD){
	return (a+b+mod)%mod;
}
lli PROD(lli a, lli b, lli mod=MOD){
	a%=mod; b%=mod;
	return a*b % mod;
}
int dx[4]={-1,0,0,1}, dy[4]={0,1,-1,0};

// ---- コーディングはここから！ ('-')7

void solve(){
	int n; cin>>n;
	vvi v(n+1);
	fore(i,0,n-1){
		int a,b; cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	if(n==1){cout<<2<<ENDL;return;}
	vvl dp(n+1,vl(2,1));
	auto f=[&](auto f, int u, int pr)->void{
		for(auto i:v[u])if(i!=pr)f(f,i,u);
		for(auto i:v[u])if(i!=pr)dp[u][1]=PROD(dp[u][1],SUM(dp[i][0],dp[i][1]));
		for(auto i:v[u])if(i!=pr)dp[u][0]=PROD(dp[u][0],dp[i][1]);
	};
	f(f,1,1);

	cout<<SUM(dp[1][0],dp[1][1])<<ENDL;
}

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


Measured memory_bytes: 22460
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
			Scanner scan = new Scanner(System.in);
			String S = scan.next();
			char[] s = new char[3];
			s[0] = S.charAt(0);
			s[1] = S.charAt(1);
			s[2] = S.charAt(2);
			int num = 0;
			for (int i = 0; i < 3; i++) {
				if (s[i] == 'o') {
					num++;
				}
			}
			System.out.println(700 + 100 * num);
		}
	}
	


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

int main(){
    string s,t;
    cin>>s>>t;
    string ans;
    for(int i=0;i<t.size();i++){
        ans.push_back(t[i]);
    }
    for(int i=0;i<s.size();i++){
        ans.push_back(s[i]);
    }
    for(int i=0;i<ans.size();i++){
        cout<<ans[i];
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
 
int main(){
	int n,x,i,j,k,count;

	while (1) {
		cin >> n >> x;
		count=0;
		if ( n==0 && x==0 ) break;
		else {
			for(i=1;i<=n;i++){
				for(j=1;j<=n;j++){
					for(k=1;k<=n;k++){
						if ( i != j && i != k && j != k && i+j+k ==x ) count++;
					}
				}
			}
			cout << count/6 << endl;
		}
		} 
	
    return 0;
}

Measured memory_bytes: 1160
<?php

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(" ", $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }

    public function hasNext()
    {
        return $this->pointer < $this->count;
    }

    public function nextInt()
    {
        return (int)$this->next();
    }

    public function nextDouble()
    {
        return (double)$this->next();
    }
}

class out
{
    public static function printIn($str = "")
    {
        echo $str . PHP_EOL;
    }
}

$sc = new Scanner;

$N = $sc->nextInt();
$x = $sc->nextInt();
$a = [];
for ($i = 0; $i < $N; $i++) {
  $a[] = $sc->nextInt();
}
sort($a);
$sum = array_sum($a);
$count = 0;
for ($i = 0; $i < $N; $i++) {
    if ($sum === $x){
        $count = $N;
        break;
    } elseif ($sum < $x) {
        $count = $N - 1;
        break;
    }
    if ($x >= $a[$i]) {
        $x -= $a[$i];
        $count++;
    }
}


echo $count;

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

int main () {
  int N ;
  cin >> N ;
  
  int line[N] ;
  for(int i = 0 ; i < N ; i++ ) cin >> line[i] ;
  
  int ans = 0 ;
  
  bool can = true ;
  
  while(can) {
    for(int i = 0 ; i < N ; i++ ){
      if(line[i] % 2 == 0 ) {
        line[i] = line[i]/2 ;
      } else {
        can = false ;
        break ;
      }
    }
    if(!can) break ;
    ans ++ ;
  }
  cout << ans << endl ;
  
}

Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] l = new int[N];
		sc.fill(l);

		System.out.println(IntStream.of(l).sorted().skip(N - K).sum());
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;
		private StringBuilder buffer = new StringBuilder();

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			int read = skip();
			do {
				buffer.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			String text = buffer.toString();
			buffer.delete(0, buffer.length());

			return text;
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}

Measured memory_bytes: 26452
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
 
using ll = long long;
const ll INF = LLONG_MAX - 100;
ll mod = 1e9 + 7;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;

class fact {
public:
	int fmod = 1e9+7;
	vector<int> fac, inv;
	fact (int n, int Mod = 1e9+7) {
		fmod = Mod;
		fac = vector<int>(n,0);
		inv = vector<int>(n,0);
		fac[0] = 1; for (int i = 1; i < n; i++) fac[i] = fac[i-1] * i % fmod;
		for (int i = 0;i < n;i++) inv[i] = fact::POW(fac[i],fmod-2);
	}
	ll nCr(ll n, ll r) {return (fac[n] * inv[r] % fmod) * inv[n-r] % fmod;}
	ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%fmod;}a = a * a%fmod; b >>= 1;}return c;}
};
 
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%mod;}a = a * a%mod; b >>= 1;}return c;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}
bool isSqrt(ll a) {return pow(sqrt(a),2) == a ? 1 : 0;}
void YesNo(bool a) {if (a) cout << "Yes"; else cout << "No"; cout << endl;}
void yesno(bool a) {if (a) cout << "yes"; else cout << "no"; cout << endl;}
void YESNO(bool a) {if (a) cout << "YES"; else cout << "NO"; cout << endl;}

bool n1[200005];
bool n2[200005];

bool solve() {
    int n,m; cin >> n >> m;
    REP (i,m) {
        int a,b; cin >> a >> b;
        int tmp; tmp = min(a,b);
        b = max(a,b); a = tmp;
        if (a == 1) {
            n1[b-1] = true;
        } else if (b == n) {
            n2[a-1] = true;
        }
    }
    int ans = 0;
    REP (i,n) {
        if (n1[i] && n2[i]) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

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


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

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

int main() {
    ll a, b;
    cin >> a >> b;
    ll gc = gcd(a, b);
    cout << a * b / gc << endl;
    return 0;
}

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

using namespace std;
map<string, int> mp;
int N;

int main(){
    cin>>N;
    while (N--){
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include <iomanip>
#include<queue>
#include<functional>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
int main() {
	int H, A; cin >> H >> A;
	int ans = 1;
	while (H > A) {
		H=H - A;
		ans++;

	}
	cout << ans << endl;
	
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.HCPC200420
{
    class D
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            while (true)
            {
                int[] hw = ReadInts();
                int h = hw[0];
                int w = hw[1];
                if (h == 0)
                {
                    break;
                }

                bool[,] grid = new bool[h, w];
                for(int i = 0; i < h; i++)
                {
                    for(int j = 0; j < w; j++)
                    {
                        grid[i, j] = true;
                    }
                }
                int n = ReadInt();
                for (int i = 0; i < n; i++)
                {
                    int[] yx = ReadInts();
                    int y = yx[0] - 1;
                    int x = yx[1] - 1;
                    grid[y, x] = false;
                }

                long[,] dp = new long[h, w];
                dp[0, 0] = 1;
                for(int i = 1; i < h; i++)
                {
                    if (!grid[i, 0])
                    {
                        break;
                    }
                    dp[i, 0] = 1;
                }
                for(int i = 1; i < w; i++)
                {
                    if (!grid[0, i])
                    {
                        break;
                    }
                    dp[0, i] = 1;
                }
                for(int i = 1; i < h; i++)
                {
                    for(int j = 1; j < w; j++)
                    {
                        if (!grid[i, j])
                        {
                            continue;
                        }

                        dp[i, j] = dp[i - 1, j] + dp[i, j - 1];
                    }
                }

                WriteLine(dp[h - 1, w - 1]);
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



Measured memory_bytes: 15964
#include<bits/stdc++.h>
#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define per(i,n,j) for(int i=(n);i>=(j);i--)
using ll=long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF=1LL<<60;

string s,t;

int main(){
    cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),greater<char>());
    if(s<t) cout<<"Yes"<<"\n";
    else cout<<"No"<<"\n";
    return 0;
}


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

int main() {
    int N, M, X, C[13], A[13][13], answer;

    cin >> N >> M >> X;
    for (int i = 0; i < N; i++) {
        cin >> C[i];
        for (int j = 0; j < M; j++)
            cin >> A[i][j];
    }

    answer = 1e9;
    for (int mask = 0; mask < (1 << N); mask++) {
        int cnt[13], cost = 0;
        memset(cnt, 0, sizeof(cnt));

        for (int i = 0; i < N; i++) {
            if (mask & (1 << i)) {
                cost += C[i];
                for (int j = 0; j < M; j++) {
                    cnt[j] += A[i][j];
                }
            }
        }

        bool valid = true;
        for (int j = 0; j < M; j++) {
            if (cnt[j] < X)
                valid = false;
        }

        if (valid)
            answer = min(answer, cost);
    }

    if (answer < 1e9)
        cout << answer << endl;
    else
        cout << -1 << endl;
}


Measured memory_bytes: 3640
#!python3

LI = lambda: list(map(int, input().split()))

# input
N = int(input())


def prime_factor(x):
    m = {}
    i = 2
    while i ** 2 <= x:
        while x % i == 0:
            if i in m:
                m[i] += 1
            else:
                m[i] = 1
            x //= i
        i += 1
    if x != 1:
        m[x] = 1
    return m


def main():
    m = prime_factor(N)
    ans = 0
    for v in m.values():
        n = 1
        while n ** 2 + n <= 2 * v:
            n += 1
        ans += n - 1
    print(ans)


if __name__ == "__main__":
    main()


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

int main(){
string S;
  cin>>S;
  
  sort(S.begin(), S.end());
  bool ans=false;
  for(int i=0; i<S.size()-1; i++){
   if(S[i]==S[i+1]){ans=true;}
  }
  
  if(ans){cout<<"no"<<endl;}
  else{cout<<"yes"<<endl;}
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
/*#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")*/
 
using namespace std;
#define ll long long
#define ld long double
#define mp make_pair
 
typedef long double DOUBLE;
typedef complex<DOUBLE> COMPLEX;
typedef vector<DOUBLE> VD;
typedef vector<COMPLEX> VC;
 
void print(auto &a)
{
    for (auto s: a) cout<<s<<' ';
    cout<<endl;
}
 
void get(vector<auto> &a)
{
    for (int i = 0; i<a.size(); i++) cin>>a[i];
}
 
const int p = 998244353;
 
 
int mul(int a, int b) {
    return (1LL * a%p * b%p) % p;
}
 
int add(int a, int b) {
    int s = (a+b);
    s = s%p;
    if (s<0) s+=p; 
    return s;
}
 
int sub(int a, int b) {
    int s = (a-b);
    s = s%p;
    if (s<0) s+=p; 
    return s;
}
 
int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}
 
int inv(int n)
{
    return po(n, p-2);
}
 
vector<int> Z(string s)
{
int n = s.length();
vector<int> z(n);
int L = 0, R = 0;
for (int i = 1; i < n; i++) {
  if (i > R) {
    L = R = i;
    while (R < n && s[R-L] == s[R]) R++;
    z[i] = R-L; R--;
  } else {
    int k = i-L;
    if (z[k] < R-i+1) z[i] = z[k];
    else {
      L = i;
      while (R < n && s[R-L] == s[R]) R++;
      z[i] = R-L; R--;
    }
  }
}
return z;
}
 
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int h, w, n, s, t;
    cin>>h>>w>>n>>s>>t;
    string a, b;
    cin>>a>>b;
    /*cout<<h<<' '<<w<<endl;
    cout<<a<<endl<<b<<endl;*/
    int l = 1; int r = w;
    for (int i = n-1; i>=0; i--)
    {
        if (b[i]=='L')
        {
            r = min(r+1, w);
        }
        if (b[i]=='R')
        {
            l = max(1, l-1);
        }
        if (a[i]=='L')
        {
            l++;
        }
        if (a[i]=='R')
        {
            r--;
        }
        if (l>r) {cout<<"NO"; return 0;}
        //cout<<l<<' '<<r<<endl;
    }
    if (l>t||t>r) {cout<<"NO"; return 0;}
    //cout<<endl;
    l = 1; r = h;
    for (int i = n-1; i>=0; i--)
    {
        if (b[i]=='U')
        {
            r = min(r+1, h);
        }
        if (b[i]=='D')
        {
            l = max(1, l-1);
        }
        if (a[i]=='U')
        {
            l++;
        }
        if (a[i]=='D')
        {
            r--;
        }
        if (l>r) {cout<<"NO"; return 0;}
        //cout<<l<<' '<<r<<endl;
    }
    if (l>s||s>r) {cout<<"NO"; return 0;}
    
    cout<<"YES";
    
}



Measured memory_bytes: 920
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <algorithm>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

typedef string::const_iterator State;

map<char, int> mp;
int hashval(State &);
int op(State &);
int letter(State &);

class ParseError
{
};
void consume(State &begin, char expected)
{
    if (*begin == expected)
    {
        begin++;
    }
    else
    {
        cerr << "Expected '" << expected << "' but got '" << *begin << "'"
             << endl;
        cerr << "Rest string is '";
        while (*begin)
        {
            cerr << *begin++;
        }
        cerr << "'" << endl;
        throw ParseError();
    }
}
int hashval(State &begin)
{
    if (*begin == '[')
    {
        consume(begin, '[');
        int ret = op(begin);
        consume(begin, ']');
        return ret;
    }
    else
    {
        return letter(begin);
    }
}
int op(State &begin)
{
    char op = *begin;
    begin++;
    int a = hashval(begin);
    int b = hashval(begin);

    if (op == '+')
    {
        return a | b;
    }
    if (op == '*')
    {
        return a & b;
    }
    if (op == '^')
    {
        return a ^ b;
    }
}
int letter(State &begin)
{
    int ret = mp[*begin];
    begin++;
    return ret;
}

void setmap(int t)
{
    rep(i, 4)
    {
        mp['d' - i] = t % 10;
        t /= 10;
    }
}

int main()
{

    while (true)
    {
        string s;
        int t;
        cin >> s;
        if (s == ".")
            break;
        State begin = s.begin();

        cin >> t;
        setmap(t);
        int ans = 0;

        int enc = hashval(begin);
        rep(i, 9999 + 1)
        {
            begin = s.begin();
            setmap(i);
            if (hashval(begin) == enc)
                ans++;
        }
        cout << enc << " " << ans << endl;
    }
}


Measured memory_bytes: 3132
// AOJ 2266 Cache Strategy
// 2018.3.8 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define INF 0x10101010
#define MAX 10005
typedef struct { int to, rev; int cap, cost; } EDGE;
EDGE *edge[MAX]; int hi[MAX], lim[MAX];
int V;				// 頂点数
int dist[MAX], prevv[MAX], preve[MAX];

void check_lim(int a)
{
	if (hi[a] < lim[a]) return;
	if (lim[a] == 0) {
		lim[a] = 32, hi[a] = 0;
		edge[a] = malloc(sizeof(EDGE) *lim[a]);
	} else if (hi[a] == lim[a]) {
		int k = lim[a];
		if (k > 512) k = 512;
		lim[a] += k;
		edge[a] = realloc(edge[a], sizeof(EDGE) *lim[a]);
	}
}

void add_edge(int from, int to, int cap, int cost)
{
	int f, t;
	EDGE *ep;

	check_lim(from), check_lim(to);
	f = hi[from]++, t = hi[to]++;
	ep = &edge[from][f], ep->to = to, ep->cap = cap, ep->cost = cost, ep->rev = t; 
	ep = &edge[to][t], ep->to = from, ep->cap = 0, ep->cost = -cost, ep->rev = f;
}

int minCostFlow(int s, int t, int f)
{
	int i, v, d, update, ans;
	EDGE *ep;

	ans = 0;
	while (f > 0) {
		for (i = 0; i < V; i++) dist[i] = INF;
		dist[s] = 0;
		update = 1;
		while (update) {
			update = 0;
			for (v = 0; v < V; v++) {
				if (dist[v] == INF) continue;
				for (i = 0; i < hi[v]; i++) {
					ep = &edge[v][i];
					if (ep->cap > 0 && dist[ep->to] > dist[v] + ep->cost) {
						dist[ep->to] = dist[v] + ep->cost;
						prevv[ep->to] = v;
						preve[ep->to] = i;
						update = 1;
					}
				}
			}
		}
		if (dist[t] == INF) return -1;

		d = f;
        for (v = t; v != s; v = prevv[v]) {
			ep = &edge[prevv[v]][preve[v]];
			if (d > ep->cap) d = ep->cap;
		}
		f -= d;

		ans += d * dist[t];
        for (v = t; v != s; v = prevv[v]) {
			ep = &edge[prevv[v]][preve[v]];
			ep->cap -= d;
			edge[v][ep->rev].cap += d;
		}
	}
	return ans;
}

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int w[MAX], a[MAX], b[MAX], c[MAX], f[MAX];

int main()
{
	int M, N, K, i, cnt, ans;
	int as, cs;

	M = in(), N = in(), K = in();
	for (i = 1; i <= N; i++) w[i] = in();
	for (i = 1; i <= K; i++) b[i] = in();
	cnt = 0, as = 1, cs = 0; for (i = 1; i <= K; i++) {
		if (b[i] == b[i-1]) c[cs++] = b[i];
		else                a[as++] = b[i], cnt++;
	}
	for (i = 0; i < cs; i++) a[as++] = c[i];

	V = cnt+1;
	ans = 0; for (i = 1; i <= cnt; i++) {
		ans += w[a[i]];
		if (f[a[i]]) add_edge(f[a[i]], i-1, 1, -w[a[i]]);
		f[a[i]] = i;
	}
	for (i = 1; i < cnt; i++) add_edge(i, i+1, INF, 0);
    printf("%d\n", ans + minCostFlow(1, cnt, M-1));
	return 0;
}
 


Measured memory_bytes: 7308
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate nPm
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n; cin >> n;
    vector<int> a(n);
    int mean = 0;
    rep(i, n) cin >> a[i], mean += a[i];
    mean /= n;
    int ans = 0;
    rep(i, n) ans += pow(a[i]-mean, 2);
    int tmp = 0; mean += 1;
    rep(i, n) tmp += pow(a[i]-mean, 2);
    chmin(ans, tmp);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

#define INF (int)1e09

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

template <typename T> using Vec = vector<T>; // c++11
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

int main(void) {
    int n;
    int m;
    cin >> n >> m;
    Vec<Vec<int> > pers(n);
    Vec<Vec<int> > lang(m);
    for (int i = 0; i < n; i++) {
        int times;
        cin >> times;
        for (int j = 0; j < times; j++) {
            int l;
            cin >> l;
            l--;
            pers[i].push_back(l);
            lang[l].push_back(i);
        }
    }

    Vec<bool> check(n, false);
    int target = 0;
    while (1) {
        if (lang[target].size() == 0) {
            target++;
        } else {
            break;
        }
    }
    int init = lang[target].size();
    for (int i = 0; i < init; i++) {
        check[lang[target][i]] = true;
    }

    while (1) {
        bool change = false;
        for (int i = 1; i < m; i++) {
            if (lang[i].size() == 0) {
                continue;
            }

            int len = lang[i].size();
            bool exist = false;
            for (int j = 0; j < len; j++) {
                if (check[lang[i][j]] == true) {
                    exist = true;
                }
            }
            if (exist == true) {
                for (int j = 0; j < len; j++) {
                    if (check[lang[i][j]] == false) {
                        check[lang[i][j]] = true;
                        change = true;
                    }
                }
            } 
        }
        if (change == false) {
            break;
        }
    }
    bool ans = true;
    for (int i = 0; i < n; i++) {
        if (check[i] == false) {
            ans = false;
            break;
        }
    }
    if (ans == true) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }


    return 0;
}



Measured memory_bytes: 8440
#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#define _CRT_DISABLE_PERFCRIT_LOCKS
#define POPCNTI(a) __builtin_popcount(a)
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>


#include <bits/stdc++.h>
using namespace  __gnu_pbds; 
using namespace std;

 
// #ifndef _LOCAL_DEFINE
// inline int getchar_unlocked(){return _getchar_nolock();}
// inline void putchar_unlocked(char c) {_putchar_nolock(c);}
// #endif
 
typedef long long ll;  
typedef pair<int,int> pr; 
 
const ll OOl = LLONG_MAX;
const int N = 1e6+1, M = 1e6+1, OO = INT_MAX,OOmem = 0x4f4f4f4f, MOD = 1e9 + 7;

inline void WRITE_CHAR(char c)  {putchar_unlocked(c);}
 
template<typename T> 
inline bool READn (T &result) {
  int minus = 1;
  char ch;
  result=0;
  ch = (char) getchar_unlocked();
  if(ch!='-') while (!isdigit(ch) && ch!=EOF) ch= (char) getchar_unlocked(), minus = (ch == '-'? -1 : minus);
 
  if(ch==EOF) return false;
  while (isdigit(ch))  result = result*10 + (int) (ch - '0'),ch = (char) getchar_unlocked();
  
  result *= minus;
  return ch != '\n';
}
template<typename T>
inline void WRITEn(T x) {
  if (x < 0) {putchar_unlocked('-'); x = -x; }
  char writeBuffer[20], *writePtr = writeBuffer;
  do {
    *writePtr++ = (char)('0' + x % 10);
    x /= 10;
  }
  while (x);
  do  { putchar_unlocked(*--writePtr); }
  while (writePtr > writeBuffer);
}
inline bool Read_CHAR(char &c)
{
  char READ_CHARACTER = (char)getchar_unlocked();
  while ((READ_CHARACTER == '\n' || READ_CHARACTER == '\t' || READ_CHARACTER == ' ')) READ_CHARACTER = (char)getchar_unlocked();
  if(READ_CHARACTER == EOF) return false;
  c = READ_CHARACTER;
  return true;
} 
inline bool READ_CHAR_ARRAY(char (&x)[N]) {
  char READ_CHARACTER = (char)getchar_unlocked();
  while ((READ_CHARACTER == '\n' || READ_CHARACTER == '\t' || READ_CHARACTER == ' ')) READ_CHARACTER = (char)getchar_unlocked();
  if(READ_CHARACTER == EOF) return false;
  char *ptr = &x[0];
  while ((READ_CHARACTER != '\n' && READ_CHARACTER != '\t' && READ_CHARACTER != ' ' && READ_CHARACTER != EOF)) *ptr++ = READ_CHARACTER, READ_CHARACTER = (char)getchar_unlocked();
  *ptr = '\0';
  return true;
}
inline void WRITE_CHAR_ARRAY(const char *x) {
  while(*x != '\0')
    putchar_unlocked(*x++);
}
int n,k,arr[101];
int memo[N][2];
int solve(int pile=k,bool flag = 0)
{
  if(pile==0) return 1;

  int &ret = memo[pile][flag];
  if(~ret) return ret;
  
  ret = 0;
  for(int i=0;i<n;++i) if((pile-arr[i])>=0) ret = max(ret,solve(pile-arr[i],!flag)); 
  
  return ret=!ret;
}
int main()
{
  
  memset(memo,-1,sizeof memo);
  READn(n),READn(k);
  for(int i=0;i<n;++i) READn(arr[i]);
  if(!solve()) WRITE_CHAR_ARRAY("First");
  else WRITE_CHAR_ARRAY("Second");

  
  return 0;
}




Measured memory_bytes: 11776
#include<bits/stdc++.h>
using namespace std;
int main(){
   string a;
   cin>>a;
   long long ans=0;
     for(long long i=0; i<(a.length())/2; i++){
       if(a[i]!=a[a.length()-1-i]){
         ans++;
       }
     }
     cout<<ans;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int a, b; cin >> a >> b;
    if ((a + b) % 2 == 0) cout << (a + b) / 2 << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));
 
ll gcd(ll x, ll y){
	if(x<y) swap(x,y);
	if(y==0) return x;
	return gcd(y,x%y);
}
 
ll lcm(ll x, ll y){
	return (x*y/gcd(x,y));
}
 
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	int n;
	cin >> n;
	int v[n],c[n],m[n];
	REP(i,n) cin >> v[i];
	REP(i,n) cin >> c[i];
	REP(i,n) m[i]=v[i]-c[i];
	GSORT(m,n);
	int ans=0;
	REP(i,n){
		if(m[i]>0) ans+=m[i];
	}
	cout << ans << endl;

/////////////////////////////////////////////
}

Measured memory_bytes: 256
N = int(input())
a = [int(x) for x in input().split()]
for i in range(N-1,0,-1):
  if a[i]+1 == a[i-1]:
    a[i-1] -= 1
  elif a[i]+1 < a[i-1]:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 14252
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <complex>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <stack> 
#include <bitset>
#include <queue>
#include <assert.h>
#include <unordered_map>
using namespace std;

const int N = 10000010;
int primes[N / 10], a[N];
bool vis[N];
void init(int n) {
	a[1] = 1;
	int tot = 0;
	for (int i = 2; i <= n; i++) {
		if (!vis[i]) {
			primes[tot++] = i;
			a[i] = 2;
		}
		for (int j = 0; j < tot && i * primes[j] <= n; j++) {
			int x = i * primes[j];
			vis[x] = true;
			if (i % primes[j] == 0) {
				int t = 2;
				int y = i;
				while (y % primes[j] == 0) y /= primes[j], t++;
				a[x] = a[y] * t;
				break;
			} else {
				a[x] = a[i] * 2;
			}
		}
	}
}

int main()
{
	int n;
	scanf("%d", &n);
	init(n);
	long long ans = 0;
	for (int i = 1; i <= n; i++)
		ans += 1LL * i * a[i];

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


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

//ll fpow(ll b,ll p,ll mod){
//    b %=mod;
//    ll ans=1;
//    while(p){
//
//        if (p&1){
//            ans *=b;
//            ans %=mod;
//        }
//        b *=b;
//        b%=mod;
//        p >>=1;
//    }
//    return ans;
//}


int main()
{
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
        int res=0;
    for(int i=1;i<=n;++i){
        if (1<= i && i<=9) res++;
        else if (100<=i && i<=999) res++;
        else if (10000<=i && i<=99999) res++;
    }
    cout << res ;
    return 0;
}


Measured memory_bytes: 3656
def resolve():
	x1, y1, x2, y2 = map(int, input().split())
	dx = x2 - x1
	dy = y2 - y1
	x3, y3 = x2 - dy, y2 + dx
	x4, y4 = x3 - dx, y3 - dy
	print(x3, y3, x4, y4)
resolve()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;

pair<int,string> v=make_pair(19191919,"1919");
string A="123456789";
char pat[114514];
int n,cnt[10][10];

int cal(string s){
    int a[3][3],x[10],y[10],sum=0;
    r(i,3){
        r(j,3){
            int p=(s[i*3+j]-'0');
            a[i][j]=p;
            x[p]=j;
            y[p]=i;
        }
    }
    r(i,10){
        r(j,10){
            int X=abs(x[i]-x[j]);
            int Y=abs(y[i]-y[j]);
            sum += (X+Y)*cnt[i][j];
        }
    }
    return sum;
}

int main(){
    scanf("%d%s",&n,pat);
    r(i,n-1){
        cnt[pat[i]-'0'][pat[i+1]-'0']++;
    }
    do{
        v=min(v,make_pair(cal(A),A));
    }while(next_permutation(A.begin(),A.end()));

    cout<<v.second.substr(0,3)<<endl;
    cout<<v.second.substr(3,3)<<endl;
    cout<<v.second.substr(6,3)<<endl;
}


Measured memory_bytes: 3340