akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

lli n, k;

int main(void){
    cin >> n >> k;
    vector<lli> a(n);
    rep(i, n) cin >> a[i];
    if(find(a.begin(), a.end(), k) != a.end()){
        cout << "POSSIBLE" << endl;
        return 0;
    }
    if(*max_element(a.begin(), a.end()) < k){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    lli g = 0;
    rep(i, n) g = __gcd(g, a[i]);
    if(k%g == 0){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}


Measured memory_bytes: 3928
#include<stdio.h>
#include<math.h>

int prime( int );

int main( void ){
	int n, i, count;
	
	scanf("%d", &n);
	
	int a[n];
	
	for( i = 0; i < n; i++ ){
		scanf("%d", &a[i] );
	}
	
	count = 0;
	for( i = 0; i < n; i++ ){
		count = count + prime(a[i]);
	}
	
	printf("%d\n", count );
	
	return 0;
}

int prime( int p ){
	int i;
	
	if( p == 2 ){
		return 1;
	}
	
	if( p < 2 || p % 2 == 0 ){
		return 0;
	}
	
	i = 3;
	while( sqrt(p) >= i ){
		if( p % i == 0 ){
			return 0;
		}
		i = i + 2;
	}
	
	return 1;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;



int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	
	ini(n);
	ini(n1);
	ini(x);
	ini(x1);
	FOR(i,1,100000){
		if(i%2){x-=n1;if(x<=0){out("Yes");return 0;}}
		else {
			n-=x1;
			if(n<=0){
				out("No");
				return 0;
			}
		}
	}
















	return 0;
}



Measured memory_bytes: 3652
def g(A,l,m,r):
 global c
 L,R=A[l:m]+[1e9],A[m:r]+[1e9]
 i=j=0
 for k in range(l,r):
  if L[i]<R[j]:A[k]=L[i];i+=1
  else:A[k]=R[j];j+=1
  c+=1
def s(A,l,r):
 if l+1<r:
  m=(l+r)//2
  s(A,l,m);s(A,m,r)
  g(A,l,m,r)
c=0
n=int(input())
A=list(map(int,input().split()))
s(A,0,n)
print(*A)
print(c)


Measured memory_bytes: 61656
#include <algorithm>
#include <iostream>
#include <vector>
#include <unordered_map>

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

#define INF 1000000000

using namespace std;

class UnionFind {
    public:
        UnionFind(int n) : data_(n, -1) {}

        int find(int x) {
            if (data_[x] < 0) return x;
            return data_[x] = find(data_[x]);
        }

        void unite(int x, int y) {
            x = find(x);
            y = find(y);

            if (x == y) return;

            // merge technique
            if (data_[y] < data_[x]) {
                swap(x, y);
            }

            // assert data_[x] <= data_[y]
            data_[x] += data_[y];
            data_[y] = x;
        }

        int size(int x) {
            return -data_[find(x)];
        }

        bool same(int x, int y) {
            return find(x) == find(y);
        }

        // data_[i] <  0 (=>) data_[i] is size of connected part.
        // data_[i] >= 0 (=>) data_[i] is parent of i.
        std::vector<int> data_;
};


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

    std::vector<std::vector<int>> friends(N);
    std::vector<std::vector<int>> blocks(N);

    UnionFind uf(N);

    REP(i, M) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;

        friends[a].push_back(b);
        friends[b].push_back(a);

        uf.unite(a, b);
    }

    REP(i, K) {
        int c, d;
        cin >> c >> d;
        c--;
        d--;

        blocks[c].push_back(d);
        blocks[d].push_back(c);
    }

    REP(i, N) {
        int count = uf.size(i);
        count -= friends[i].size();

        for (auto b : blocks[i]) {
            if (uf.same(i, b)) count--;
        }

        count--;

        cout << count << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 12152
#include<stdio.h>
#include<stdlib.h>
#include<iostream>

using namespace std; 
typedef long long ll; 
ll a[100005],k;

bool check1(ll x)
{	
	for(int i=0;i<k;i++)
		{	
			x=x-x%a[i];
		}
	
	return x<2;
	
}


bool check2(ll x)
{
	for(int i=0;i<k;i++)
		{	
			x=x-x%a[i];
		}
	return x<=2;
}

int main()
{	
	while(~scanf("%lld",&k))
	{
		for(int i=0;i<k;i++)
			scanf("%lld",&a[i]);
		
		
		if(a[k-1]>2)
		{
			printf("-1\n");
			continue;
			
		}
		
		
		ll l=0,r=1e18+1,mid,ans;
		while(l<=r)
		{	mid=(l+r)/2;
			if(check1(mid)) {ans=mid,l=mid+1;}
			else r=mid-1;
			
		}
		ll x1=ans+1;
		
		
		l=ans,r=1e18+1;
		while(l<=r)
		{	mid=(l+r)/2;
			if(check2(mid)) ans=mid,l=mid+1;
			else r=mid-1;
			
		}
		if(x1>ans) printf("-1\n");
		else printf("%lld %lld\n",x1,ans);
	}
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
#define vecmin(A) *min_element(A.begin(),A.end())
#define vecmax(A) *max_element(A.begin(),A.end())
typedef long long ll;

int main(){
  int n;
  cin >> n;
  cout << n*(n+1)/2 << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.*;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main
{
	public static void main (String[] arg)throws IOException
	{
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String ln ="";
		int i=0;
		int[] a = new int [100];
		while((ln=input.readLine()) != null){
			
			if(Integer.parseInt(ln) ==0 ){
				i--;
				System.out.println(a[i]);
			}else{
				a[i] = Integer.parseInt(ln);
				i++;
			}
		}
	}
}

Measured memory_bytes: 16864
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;


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

    int N, W; cin >> N >> W;
    vi v(N), w(N);
    REP(i, N) cin >> v[i] >> w[i];

    vll dp(W + 1, -1);
    dp[0] = 0;

    REP(i, N) {
        REVREP(j, W) {
            if (dp[j] > -1 && j + w[i] <= W) dp[j + w[i]] = max(dp[j] + v[i], dp[j + w[i]]);
        }
    }

    ll ans = 0;
    REP(i, W + 1) ans = max(ans, dp[i]);
    print(ans);

}


Measured memory_bytes: 3284
def main():
	n = int(input())
	X=list(map(int, input().split()))
	wa = 10000000000000000
	for i in range(min(X),max(X)+1):
		dmy_wa = sum(list(map(lambda x:(x-i)**2, X)))
		if dmy_wa < wa:
			wa=dmy_wa
	print(wa)
main()

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;
int mod2=998244353;

signed main(){
  int n,k;
  cin>>n>>k;
  vector<int> a(n+n+2,0);
  for(int i=0;i<n;i++)cin>>a[i];
  vector<int> dp(n+n+2,1e9);
  dp[0]=0;
  for(int i=0;i<n;i++){
    for(int j=1;j<=k;j++){
      dp[i+j]=min(dp[i+j],dp[i]+abs(a[i]-a[i+j]));
    }
  }
  cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main()
{
  // 縦横サイズ取得
  int H, W;
  cin >> H >> W;
  // グリッド作成, 各マスの文字列を取得
  char grid[H][W];
  for(int i = 0; i < H; ++i)
  {
    for(int j = 0; j < W; ++j)
    {
      cin >> grid[i][j];
    }
  }
  bool ans = true;
  for(int i = 0; (i < H) && ans; ++i)
  {
    for(int j = 0; (j < W) && ans; ++j)
    {
      if(grid[i][j] == '#')
      {
        // #マスの周囲4マスが塗れるマスでなければ失敗
        if((grid[i - 1][j] != '#') && (grid[i + 1][j] != '#') && (grid[i][j - 1] != '#') && (grid[i][j + 1] != '#'))
        {
          ans = false;
        }
      }
    }
  }
  if(ans)
  {
    cout << "Yes";
  }
  else 
  {
    cout << "No";
  }
}

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

int main() 
{
 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);
 cout.tie(nullptr);
 int d, t, s;
 cin >> d >> t >> s;
 cout << (d <= t * s ? "Yes\n" : "No\n");
 return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin>>N;
    int flag = N %10;
    if(flag==3) cout<<"bon"<<endl;
    else if(flag == 0 || flag == 1|| flag==6|| flag == 8) cout<<"pon"<<endl;
    else cout<<"hon"<<endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stdlib.h>
#include <math.h>

using namespace std;


int main() {
	long N, X;
	cin >> N >> X;
	long L = N;
	long a = N - X, b = X;
	while (a != 0 && b != 0) {
		if (a == b) {
			L += a;
			break;
		}
		if (a < b) {
			long n = b / a;
			long r = b % a;
			if (r == 0) {
				L += (n * 2 - 1) * a;
				break;
			}
			L += n * 2 * a;
			b = r;
		}
		else {
			long n = a / b;
			long r = a % b;
			if (r == 0) {
				L += (n * 2 - 1) * b;
				break;
			}
			L += n * 2 * b;
			a = r;
		}
	}
	cout << L;
	cin >> N;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  long long D;
  cin >> N >> D;
  
  long long x[N],y[N];
  int count=0;
  for(int i=0;i<N;i++){
    cin >> x[N] >> y[N];
    if(x[N]*x[N]+y[N]*y[N]<=D*D) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 3596
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int N = S.length();
    String case1 = S.substring(0, N/2);
    String case2 = S.substring((N+3)/2-1, N);
    if(case1.equals(case2)){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}
  

Measured memory_bytes: 35712
import sys
import math
import itertools as it
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    a = I()
    print(a+a**2+a**3)

Measured memory_bytes: 9200
#include<stdio.h>
int main(){
  int a,b,c=10;
  scanf("%d %d",&a,&b);
  while(b/c>0){c*=10;}
  a*=c;
  a+=b;
  b=0;
  for(int i=1; i<=a; i++){
    if(i*i==a){b=1;break;}
  }
  printf(b?"Yes":"No");
  return 0;}

Measured memory_bytes: 128
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextLineArray() []int {
	sc.Scan()
	arr := strings.Split(sc.Text(), " ")
	ret := []int{}
	for _, v := range arr {
		i, _ := strconv.Atoi(v)
		ret = append(ret, i)
	}
	return ret
}

func output(arr []int) {
	str := ""
	for i := 0; i < len(arr); i++ {
		str += fmt.Sprintf("%d", arr[i])
		if i != len(arr) - 1 {
			str += " "
		}
	}
	fmt.Println(str)
}

func main() {
	n := nextLine()
	a := nextLineArray()

	cnt := 0
	flg := true
	for flg {
		flg = false
		for i := n - 1; i > 0; i-- {
			if a[i] < a[i-1] {
				tmp := a[i]
				a[i] = a[i-1]
				a[i-1] = tmp
				flg = true
				cnt++
			}
		}
	}
	output(a)
	fmt.Println(cnt)
}



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

using u64 = std::uint64_t;
constexpr u64 inf = std::numeric_limits<u64>::max();

#define REP(i, n) for (u64 i = 0; i < (n); ++i)

namespace io {
  constexpr int is = 1 << 17;
  char ib[is], *ip = ib + is, it;
  inline char getc() {
    if (ip == ib + is) { read(STDIN_FILENO, ib, is); ip = ib; }
    return *ip++;
  }
  inline u64 scan() {
    u64 r = 0;
    if (ip + 16 > ib + is) while ((it = getc()) & 16) r = r * 10 + it - '0';
    else while ((it = *ip++) & 16) r = r * 10 + it - '0';
    return r;
  }
  constexpr int os = 1 << 17;
  char ob[os], *op = ob, ot;
  inline void putc(const char c) {
    *op++ = c;
    if (op == ob + os) { write(STDOUT_FILENO, ob, os); op = ob; }
  }
  /* x shoud be greater than or equal to zero */
  inline void print(u64 x) {
    char d[20];
    int i = 0;
    while (true) {
      d[i] = x % 10 + 48;
      x /= 10;
      ++i;
      if (x <= 0) break;
    }
    while (i--) {
      putc(d[i]);
    }
  }
  inline void flush() {
    write(STDOUT_FILENO, ob, op - ob);
  }
}

using P = pair<u64, u64>;

u64 collect(const vector<vector<u64>> &G, const vector<u64> &H, u64 u, u64 v, u64 p) {
  if (u == v) return 0;
  for (auto e : G[u]) {
    u64 t = H[e] ^ u;
    if (t == p) continue;
    u64 s = collect(G, H, t, v, u);
    if (s != inf) {
      return s | (1ULL << e);
    }
  }
  return inf;
}

void search(u64 &ans, u64 n, u64 j, u64 m, u64 parity, u64 mask, vector<u64> &paths) {
  if (j < m) {
    search(ans, n, j + 1, m, parity, mask, paths);
    search(ans, n, j + 1, m, parity ^ 1, mask | paths[j], paths);
  } else {
    if (parity) {
      ans -= 1ULL << (n - 1 - __builtin_popcountll(mask));
    } else {
      ans += 1ULL << (n - 1 - __builtin_popcountll(mask));
    }
  }
}

signed main() {
  u64 n = io::scan();
  auto G = vector<vector<u64>>(n);
  auto H = vector<u64>(n);
  REP(i, n - 1) {
    u64 a = io::scan() - 1;
    u64 b = io::scan() - 1;
    G[a].push_back(i);
    G[b].push_back(i);
    H[i] = a ^ b;
  }
  u64 m = io::scan();
  auto paths = vector<u64>(m);
  REP(j, m) {
    u64 u = io::scan() - 1;
    u64 v = io::scan() - 1;
    paths[j] = collect(G, H, u, v, -1);
  }
  u64 ans = 0;
  search(ans, n, 0, m, 0, 0, paths);
  io::print(ans);
  io::flush();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define MOD 1000000007
#define int long long
int MAX(int C,int D){
  if(C>D) swap(C,D);
  while(1){if(D%C==0){return C; break;} //前提
           int X=C;
           C=D%C;
           D=X;
  }
}
int MIN(int C,int D){
  return C*D/MAX(C,D);
}
//Librury
signed main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  A--;
  int ans=B/C+B/D-B/MIN(C,D)-(A/C+A/D-A/MIN(C,D));
  cout<<B-A-ans<<endl;
}

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

//ll sum[200001];

vector<ll> ruiseki(vector<ll> sum, vector<int> p, int N) {
  sum.at(0) = p.at(0);
  int i = 1;
  while (i < N) {
    sum.at(i) = sum.at(i - 1) + p.at(i);
    i++;
  }
  return sum; 
}

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> p(N);
  for (int i = 0; i < N; i++) cin >> p.at(i);
  
  vector<ll> sum(N);
  sum = ruiseki(sum, p, N);
  priority_queue<ll> ans;
  
  ans.push(sum.at(K - 1));
  for (int j = K; j < N; j++) {
    ll tmp = sum.at(j) - sum.at(j - K);
    ans.push(tmp);
  }
  
  double ain = (double)ans.top();
  double output = ain / 2.0 + 0.5 * (double)K;
  cout << setprecision(8) << output << endl;
  
  return 0;
}



Measured memory_bytes: 6228
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

#define pb push_back
#define mp make_pair
#define mod 1000000007

vector<int> g[1<<20];
vector<int> v(1<<20, INT_MIN);

int main() {
    int n,x,y,k;
    cin>>n;
    for(int i=1;i<n;i++) {
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }

    priority_queue<pii, vector<pii>, greater<pii> > pq;

    cin>>k;
    while(k--) {
        cin>>x>>y;
        v[x] = y;
        pq.push(mp(y, x));
    }

    while(not pq.empty()) {
        pii t = pq.top();
        pq.pop();
        for(int u : g[t.second]) {
            if(v[u] == INT_MIN) {
                v[u] = t.first + 1;
                pq.push(mp(v[u], u));
            }
        }
    }

    for(int i=1;i<=n;i++) {
        for(int u : g[i]) {
            if(abs(v[i]-v[u]) != 1) {
                cout<<"No";
                return 0;
            }
        }
    }

    cout<<"Yes"<<endl;
    for(int i=1;i<=n;i++) cout<<v[i]<<endl;

    return 0;
}



Measured memory_bytes: 33780
//#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define boost ios::sync_with_stdio(0); cin.tie(0)

#define fi first
#define se second

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;

const int N = 1e6 + 5;
const ll INF = 9e18;

/***************************************************************************/

ll X[N];

int main() {

	boost;
	int n, k; cin>>n>>k;
	for(int i=1; i<=n; i++) {
		cin>>X[i];
	}

	ll ans = INF;

	for(int i=k; i<=n; i++) {
		ll a = X[i-k+1], b = X[i];
		ans = min(ans, b - a + min(abs(a), abs(b)));
	}

	cout<<ans<<"\n";

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	int N,A[2][110],max=0;
	cin>>N;
	A[0][0]=0;
	A[1][0]=0;
	REP(i,2)
		FOR(j,1,N+1) 
			cin>>A[i][j];

	REP(i,2)
		FOR(j,1,N+1)
			A[i][j]+=A[i][j-1];


	FOR(j,1,N+1)
		chmax(max,A[0][j]+A[1][N]-A[1][j-1]);

	print(max);	
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int N = sc.nextInt();
			int Q = sc.nextInt();
			if (N + Q == 0)
				break;
			E[] e = new E[N];
			for (int i = 0; i < N; i++) {
				String s =sc.next();
				int len = sc.nextInt();
				int end= sc.nextInt();
				e[i]=new E(s,len,end);
			}
			l:for (int i = 0; i < Q; i++) {
				int y = sc.nextInt();
				for(E era:e){
					if(era.end-era.len < y && y <= era.end){
						System.out.println(era.name+" "+(y-era.end+era.len));
						continue l;
					}
				}
				System.out.println("Unknown");
			}
		}
	}
	static class E{
		String name;
		int len;
		int end;
		public E(String name, int len, int start) {
			super();
			this.name = name;
			this.len = len;
			this.end = start;
		}
		
	}
}

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


int main() {
  int n;
  cin >> n;
  map<int,int> mp;
  rep(i,n) {
    int x; cin >> x;
    mp[x]++;
  }
  int ans = mp.size();
  if(mp.size()%2==0) ans--;
  cout << ans << endl;
  return 0;
}

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

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

#define INF (1<<24)

int f[30][30],W,H;

int dfs(int x, int y, int c, bool gf)
{
	if(gf) return c;
	if(c>=10) return INF;

	int ret=INF;
	for(int i=0; i<4; i++)
	{
		int tx=x, ty=y;
		bool gf=false;
		while(1)
		{
			tx+=dx[i], ty+=dy[i];
			if(tx<0||ty<0||tx>=W||ty>=H) break;
			if(f[tx][ty]==3) gf=1;
			if(f[tx][ty]==1) break;
		}

		if(gf)
		{
			ret=min(ret, dfs(tx,ty,c+1,gf));
		}
		else
		{
			if(tx<0||ty<0||tx>=W||ty>=H) continue;
			if(x==tx-dx[i]&&y==ty-dy[i]) continue;
			f[tx][ty]=0;
			tx-=dx[i], ty-=dy[i];

			ret=min(ret, dfs(tx,ty,c+1,gf));

			tx+=dx[i], ty+=dy[i];

			f[tx][ty]=1;
		}
	}

	return ret;
}

int main()
{

	while(cin >> W >> H, (W||H))
	{
		int sx,sy;
		for(int i=0; i<H; i++)
		for(int j=0; j<W; j++)
		{
			cin >> f[j][i];
			if(f[j][i]==2)
			{
				sx=j;
				sy=i;
			}
		}

		int ret=dfs(sx,sy,0,0);
		cout << (ret==INF?-1:ret) << endl;
	}
}

Measured memory_bytes: 872
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
k = I()
s = S()

if len(s) <= k:
    print(s)
else:
    ss = s[0:k]
    print(ss+'...')

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

int main() {
    int n; scanf("%d", &n);
    string s = "";
    ll x = 2;
    int i = 0;
    if (n == 0) {
        puts("0");
        return 0;
    }
    while (n != 0) {
        if (n % x != 0) {
            s = "1" + s;
            n -= (x / 2) * (i % 2 == 0 ? 1 : -1);
        } else {
            s = "0" + s;
        }
        x *= 2;
        i++;
    }
    cout << s << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

static int N = 100;

int main(){
	int n,i,j,k,l,min;
	int r[N+1],c[N+1],m[N+1][N+1];

	scanf("%d",&n);

	for(i = 1; i <= n; i++){
		scanf("%d%d",&r[i],&c[i]);
	}

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

	for(l = 2; l <= n; l++){
		for(i = 1; i<=n-l+1;i++){
			j = i + l - 1;
			m[i][j] = 10000000;
			for(k = i ; k <= j-1; k++){
				min = m[i][k] + m[k+1][j] + r[i]*c[k]*c[j];
				if(m[i][j] > min)m[i][j] = min;
			}
		}
	}
	printf("%d\n",m[1][n]);

	return 0;
}



Measured memory_bytes: 2084
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define loop(n) for (int i = 0; i < n; i++)
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
#define ll long long int
using namespace std;

int main() {
	string s;
	cin >> s;
	cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define ENDL "\n"
#define PRINT(x) cout << (x) << ENDL

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
inline void out(int n) {printf("%d\n", n);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};



class UnionFind{
    public:
        UnionFind(int N) : parent(N), rank(N){
            for(int i = 0; i < N; i++){
                parent[i] = i;
                rank[i] = 1;
            }
        }

        int find(int n){
            if(parent[n] == n){
                return n;
            }
            return parent[n] = find(parent[n]);
        }

        void merge(int m, int n){
            int root_x = find(m);
            int root_y = find(n);
            if(root_x == root_y){
                return;
            }
            if(rank[root_x] < rank[root_y]){
                parent[root_x] = root_y;
            }else if(rank[root_x] > rank[root_y]){
                parent[root_y] = root_x;
            }else{
                parent[root_y] = root_x;
                rank[root_x]++;
            }
        }

        bool equivalent(int x, int y){
            return find(x) == find(y);
        }

    private:
        vector<int> parent;
        vector<int> rank;

};

int N, M;
int p[100000];

signed main(){
    in(N); in(M);
    REP(i, N) in(p[i]);
    int x, y, cnt = 0;
    UnionFind uf(N + 1);
    REP(i, M){
        in(x); in(y);
        uf.merge(x, y);
    }
    REP(i, N){
        if(uf.equivalent(i + 1, p[i])) cnt++;
    }
    PRINT(cnt);
}

Measured memory_bytes: 1408
s=input()#sは奇数
answer="Yes"
len=len(s)
for i in range(int((len-1)/2)):
    if s[i]!=s[len-i-1]:
        answer="No"
for j in range(int((len-1)//4)):
    if s[j]!=s[int((len-1)/2-j-1)]:
        answer="No"
    if s[int((len+1)/2+j)]!=s[len-j-1]:
        answer="No"
print(answer)

Measured memory_bytes: 3064
#人数
N = input()
#合宿D日、最後に残ったチョコX
D,X = input().split()
A = []
for i in range(int(N)):
    A.append(input())
x  = int(N)
for a in A:
    x += int((int(D)-1)/int(a))
    #print("---"+D+"/"+a+"=",int(int(D)/int(a)))
print(x+int(X))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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







Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
template<class Type> class UnionFind
{
  public:
    vector<Type> data;
    UnionFind(int sz) { data.assign(sz, -1); }
    bool unite(Type x, Type 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);
    }
    Type find(Type k) {
        if (data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }
    Type size(Type k) { return (-data[find(k)]); }
};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k, l; cin >> n >> k >> l;
    UnionFind<int> A(n), B(n);
    for(int i = 0; i < k; i++)
    {
        int p, q; cin >> p >> q;
        p--, q--;
        A.unite(p, q);
    }
    for(int i = 0; i < l; i++)
    {
        int r, s; cin >> r >> s;
        r--, s--;
        B.unite(r, s);
    }
    map<pair<int, int>, int> mp;
    for(int u = 0; u < n; u++)
    {
        mp[make_pair(A.find(u), B.find(u))]++;
    }
    for(int u = 0; u < n; u++)
    {
        if(u) cout << " ";
        cout << mp[make_pair(A.find(u), B.find(u))];
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 13568
N,K = map(int,input().split())
h = [int(input()) for i in range(N)]
h.sort()
mi=10**9+1
for i in range(N-K+1):
    if(mi>h[i+K-1]-h[i]):
        mi = h[i+K-1]-h[i]
print(mi)

Measured memory_bytes: 7488
#include <iostream>
#include <algorithm>
using namespace std;
int d[9];
int main( void )
{
  ios::sync_with_stdio(false);
  int N, a;
  cin >> N;
  for( int i=0; i<N; i++ ){
    cin >> a;
    if( a >= 3200 ) d[8]++;
    else d[a/400]++;
  }
  int ret = 0;
  for( int i=0; i<8; i++ ){
    if( d[i] ) ret++;
  }
  if( ret == 0 ){
    cout << 1 << ' ' << d[8] << endl;
  } else {
    cout << ret << ' ' << ret + d[8] << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN=100010;
const int INF=1<<30;
int N,M,K,A[MAXN],B[MAXN];
int main()
{
	int Ans=INF;
	cin>>N>>M>>K;
	for (int i=1;i<=N;++i) scanf("%d",&A[i]);
	for (int i=1;i<=M;++i) scanf("%d",&B[i]);
	for (int i=1;i<=K;++i)
	{
		int c,x,y;
		scanf("%d%d%d",&x,&y,&c);
		Ans=min(Ans,A[x]+B[y]-c);
	}
	sort(A+1,A+1+N);
	sort(B+1,B+1+M);
	Ans=min(Ans,A[1]+B[1]);
	cout<<Ans<<endl;
	return 0;
}

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

int main()
{
  int x, y;
  cin >> x;
  cin >> y;
  string res = "No";
  for (int i = 0; i < x + 1; i++)
  {
    int j = x - i;
    if ( 2*i + 4*j == y)
      res = "Yes";
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3040
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long X=1000000000+7;
const string d="dream";
const string e="erase";

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a+b>=c) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
/*
ЗАПУСКАЕМ 
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░ 
 */
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>


using namespace std;
template<typename T1, typename T2> inline void chkmin(T1 &a, T2 b) {if (a > b) a = b;}
template<typename T1, typename T2> inline void chkmax(T1 &a, T2 b) {if (a < b) a = b;}
#define files(FILENAME) read(FILENAME); write(FILENAME)
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define left left228
#define right right228
#define y1 y1228
#define mp make_pair
#define pb push_back
#define y2 y2228
#define rank rank228
using ll = long long;
using ld = long double;
const string FILENAME = "input";




int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	//read(FILENAME);
	ll a, b, v, w, t;
	cin >> a >> v >> b >> w >> t;
	if (v <= w) {
		cout << "NO\n";
		return 0;
	}
	if (abs(a - b) <=  (v - w) * t) {
		cout << "YES\n";
	} else {
		cout << "NO\n";
	}
	return 0; 	
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, n) for (int i = (a); i < (n); ++i)
using namespace std;
using ll = long long;
using uint = unsigned int;
const ll mod = (ll)1e9 + 7;

int main() {
  int n, x, t;
  cin >> n >> x >> t;
  cout << (int)ceil((double)n / x) * t << endl;
  return 0;
}


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

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define inf (1<<30)-1
#define INF (1LL<<62)-1
#define MOD 1000000007LL
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define PI acos(-1)
#define MEM(x,y) memset(x,y,sizeof (x))
#define debug cout<<"A"<<'\n'
#define REP(i,a,b) for (int i=(a); i<=(b); i++)
#define PER(i,a,b) for (int i=(a); i>=(b); i--)
#define REPL(i,a,b) for (LL i=(a); i<=(b); i++)
#define PERL(i,a,b) for (LL i=(a); i>=(b); i--)
#define print(x) cout<<x<<'\n'
#define itrALL(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define UNIQUE(X) X.erase( unique( X.begin(), X.end() ), X.end() )


typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int>PII;
typedef pair<LL,LL>PLL;
typedef vector<int> VI;
typedef vector<LL> VL;


// Order Statistic Tree

/* Special functions:

        find_by_order(k) --> returns iterator to the kth largest element counting from 0
        order_of_key(val) --> returns the number of items in a set that are strictly smaller than our item
*/

typedef tree<
PII,
null_type,
less<PII>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

template <class T> inline T bigmod(T p,T e,T M)
{
    T ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}

template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}
template <class T, class X> inline bool getbit(T a, X i) { T t=1; return ((a&(t<<i))>0);}
template <class T, class X> inline T setbit(T a, X i) { T t=1;return (a|(t<<i)); }
template <class T, class X> inline T resetbit(T a, X i) { T t=1;return (a&(~(t<<i)));}

/*end of header*/

LL x,y,z,n;

struct data
{
    LL a,b,c,ind;
}arr[100009];

bool gssort(data p, data q)
{
    return p.a+q.b>p.b+q.a;
}

multiset<LL,greater<LL> >ss,sg,g;
multiset<LL>s;
int main()
{
    scanf("%lld %lld %lld",&x,&y,&z);
    n=x+y+z;
    REP(i,1,n)scanf("%lld %lld %lld",&arr[i].a,&arr[i].b,&arr[i].c);
    sort(arr+1,arr+n+1,gssort);
    LL ans=0;
    REP(i,1,x){ans+=arr[i].a;sg.insert(arr[i].c-arr[i].a);}
    REP(i,x+1,n)
    {
        ss.insert(arr[i].c-arr[i].b);
        ans+=arr[i].b;
    }
    int cntr=0;
    itrALL(ss,it)
    {
        ans+=*it;
        cntr++;
        s.insert(*it);
        if(cntr==z)break;
    }

    LL now=ans;
    REP(i,x+1,x+z)
    {
        auto it=s.find(arr[i].c-arr[i].b);
        if(it!=s.end())
        {
            s.erase(it);
            now+=(arr[i].b-arr[i].c);
        }
        else
        {
            auto it2=s.begin();
            LL temp=*it2;
            now-=temp;
            s.erase(it2);
        }
        now+=(arr[i].a-arr[i].b);
        sg.insert(arr[i].c-arr[i].a);
        auto it3=sg.begin();
        now+=*it3;
        sg.erase(it3);
        ans=max(ans,now);
    }
    print(ans);
    return 0;
}



Measured memory_bytes: 11136
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        
        long[] a = new long[N];

        int x4 = 0;
        int ki = 0;
        for(int i=0; i<N; i++) {
            a[i] = Long.parseLong(sc.next());
            if(a[i] % 4 == 0) {
                x4++;
            }else if(a[i] % 2 == 0) {
                continue;
            }else {
                ki++;
            }
        }
        if(x4 >= ki) System.out.println("Yes");
        else if(x4 == N/2 && ki == N/2+1) System.out.println("Yes");
        else System.out.println("No");
        
        
    }
}


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

typedef pair<int,int> ii;

int main() {
	
	int n, duracion, deadline;
	priority_queue<ii,vector<ii>,greater<ii>> pq;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> duracion >> deadline;
		pq.push(ii(deadline, duracion));
	}
	int time = 0;
	while (!pq.empty()) {
		if (time + pq.top().second > pq.top().first) {
			cout << "No\n";
			return 0;
		}
		time += pq.top().second;
		pq.pop();
	}
	cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <climits>
#include <utility>
#include <numeric>
typedef long long ll;
using namespace std;

int main(int argc, char *argv[]) {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll max = a*c;

  if(a*c>max) max = a*c;
  if(a*d>max) max = a*d;
  if(b*c>max) max = b*c;
  if(b*d>max) max = b*d;

  cout << max << endl;

  return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>

#define INF 1 << 30
#define MOD 1000000007
#define PI 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }

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

int main() { 
        int h, w;
        cin >> h >> w;
        string s[10];
        int cnt = 0;
        rep (i, h) {
                cin >> s[i];
                rep (j, s[i].size()) {
                        if (s[i][j] == '#') ++ cnt;
                }
        }
        if (cnt + 1 == w + h) D("Possible");
        else D("Impossible");
        return 0;
}



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

int main(void){
  int a,b,ans = 0;
  cin >> a >> b;
  for(int i=0;i<2;i++){
  	if(a>b){
   	  ans += a;
      a--;
    } else {
      ans += b;
      b--;
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
# D

n = int(input())
c_l = input()

ans = 0
l = 0
r = n
while True:
    _l = c_l.find("W", l, n-1)
    _r = c_l.rfind("R", 0, r)
    if _l >= _r or _l == -1 or _r == -1:
        break
    ans += 1
    l = _l + 1
    r = _r

print(ans)



Measured memory_bytes: 9476
(defvar N (read))
(defvar M (read))

(defvar lst (loop repeat N collect (read)))

(if (>= (count-if (lambda (x)
                  (>= x (/ (apply #'+ lst) (* 4 M))))
                  lst)
        M) 

    (princ "Yes")
    (princ "No"))

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

int main(void)
{
  int w, n, i;
  int x[30];
  int a, b;

  cin >> w >> n;
  for(i = 1; i <= w; i++){
    x[i - 1] = i;
  }
  for(i = 0; i < n; i++){
    scanf("%d,%d", &a, &b);
    swap(x[a - 1], x[b - 1]);
  }
  for(i = 0; i < w; i++){
    cout << x[i] << endl;
  }

  return 0;

}

Measured memory_bytes: 1240
dict = {}
q = int(input())
for i in range(q):
    query, *val = input().split(' ')
    if query == '0':
        dict[val[0]] = int(val[1])
    elif query == '1':
        print(dict.get(val[0], 0))
    else:
        if val[0] in dict:
            dict.pop(val[0])


Measured memory_bytes: 37516
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

vll ok(100001, -1);
vvl G = VV(100001, 0, 0, ll);

int main(int argc, char const *argv[]) {
  ll n, m;std::cin >> n >> m;
  re(i, m){
    ll a, b;scanf("%lld %lld", &a, &b);
    G[a].push_back(b);
    G[b].push_back(a);
  }
  deque<vll> q;
  q.push_back(vll{1, -1});
  while(!q.empty()){
    vll tmp = q.front();q.pop_front();
    ll now = tmp[0], par = tmp[1];
    if(ok[now]!=-1) continue;
    ok[now] = par;
    for(auto to:G[now]){
      if(ok[to]!=-1) continue;
      q.push_back(vll{to, now});
    }
  }

  std::cout << "Yes" << '\n';
  for(int i=2;i<=n;i++) std::cout << ok[i] << '\n';
  return 0;
}


Measured memory_bytes: 22260
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K,num;
  num=1;
  cin>>N;
  cin>>K;
  for(int i=0;i<N;i++){
    if(num*2<num+K){
      num=num*2;
    }else{
      num=num+K;
    }  
  }  
  cout<<num<<endl;
}

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

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

int main() {
    int h, a;
    scanf("%d %d", &h, &a);
    printf("%d", h / a + (h % a == 0 ? 0 : 1));
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  	
  	long long a,b;
  	cin >> a >> b;
  	if (a>=1 && b>=1 && a<=9 && b<=9){
      cout << a*b;
    }
  	else {
      cout << -1;
    }
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;cin>>s;
    for(int i=0; i<s.size(); i++)cout<<"x";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))


int main(){
	ll N;
	cin >> N;
	ll cnt[10][10]={};
	FOR(i,1,N+1){
		ll x = i%10;
		ll y = i;
		while(y>=10){
			y /= 10;
		}
		cnt[y][x]++;
	}
	ll ans = 0;
	FOR(i,1,10){
		FOR(j,1,10){
			ans += cnt[i][j]*cnt[j][i];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<complex>
using namespace std;
typedef long long LL;
#define sqr(x) ((x)*(x))
#define mp make_pair
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
int n,t,x,y,tt,xx,yy;
signed main() {
	n=read();
	for (int i=1; i<=n; i++) {
		tt=read();
		xx=read();
		yy=read();
		if (abs(xx-x)+abs(yy-y)>tt-t||((abs(xx-x)+abs(yy-y))&1)!=((tt-t)&1)) {
			puts("No"); return 0;
		}
		t=tt;x=xx;y=yy;
	}
	puts("Yes");
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string str;
vector<int> vec[2];
int dp[2][16001];

int main(void){
	cin >> str;
	int x,y;
	scanf("%d%d",&x,&y);
	int cnt=0;
	int n=str.size();
	int flag=0;
	bool fl=false;
	for(int i=0;i<n;i++){
		if(str[i]=='F')cnt++;
		else{
			if(!fl){
				fl=true;
				x-=cnt;
				flag=1;
				cnt=0;
				continue;
			}
			if(cnt>0){
				//printf("%d %d\n",flag,cnt);
				vec[flag].push_back(cnt);
			}
			flag=1-flag;
			cnt=0;
		}
	}
	if(!fl){
		x-=cnt;
		cnt=0;
		if(x!=0){
			printf("No\n");
			return 0;
		}
	}
	if(cnt>0){
		vec[flag].push_back(cnt);
	}
	//printf("%d %d\n",x,y);
	dp[0][8000]=1;
	int now=1,prev=0;
	for(int i=0;i<(int)vec[0].size();i++){
		//printf("%d\n",vec[0][i]);
		for(int j=0;j<=16000;j++){
			if(dp[prev][j]==1){
				dp[now][j+vec[0][i]]=1;
				dp[now][j-vec[0][i]]=1;
			}
		}
		swap(now,prev);
		memset(dp[now],0,sizeof(dp[now]));
	}
	if(dp[prev][8000+x]==0){
		printf("No\n");
		return 0;
	}
	memset(dp[prev],0,sizeof(dp[prev]));
	dp[prev][8000]=1;
	for(int i=0;i<(int)vec[1].size();i++){
		for(int j=0;j<=16000;j++){
			if(dp[prev][j]==1){
				dp[now][j+vec[1][i]]=1;
				dp[now][j-vec[1][i]]=1;
			}
		}
		swap(now,prev);
		memset(dp[now],0,sizeof(dp[now]));
	}
	if(dp[prev][8000+y]==0){
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	return 0;
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define CEIL(n, m) ceil(n/pow(10.0, m))*pow(10.0, m)
#define FLOOR(n, m) floor(n/pow(10.0, m))*pow(10.0, m)
#define ROUND(n, m) round(n/pow(10.0, m))*pow(10.0, m)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define llong long long
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

void solve()
{
  int a, b;
  cin >> a >> b;
  if (a > 8 || b > 8)
  {
    cout << ":(" << endl;
  } else
  {
    cout << "Yay!" << endl;
  }
}

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


Measured memory_bytes: 256