akhauriyash/Code-Regression huggingface dataset:
x1, y1, x2, y2 = map(int, input().split())

a, b = x2 - x1, y2 - y1
x3 = x2 - b
y3 = y2 + a
x4 = x3 - a
y4 = y3 - b
print(x3, y3, x4, y4)


Measured memory_bytes: 2940
#!/usr/bin/env python3
s = input()
k = int(input())

i = 0
while i < len(s) - 1:
    if i == k - 1:
        print(s[i])
        exit()
    if s[i] == "1":
        i += 1
    else:
        print(s[i])
        exit()
print(s[i])


Measured memory_bytes: 9096
int main(){
	long n;
	long a[100];
	int i;

	a[0] = 2;
	a[1] = 1;

	scanf("%ld", &n);

	for(i=2; i<=n; i++){
		a[i] = a[i-1] + a[i-2];
	}

	printf("%ld\n", a[n]);

  	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool> vecbool;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<string> vecstr;
typedef vector<vecint> vec2int;
typedef vector<vecbool> vec2bool;
int dx[4]{-1, +1, 0, 0};
int dy[4]{0, 0, -1, +1};
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
int main() {
  init();
  int n, k;
  cin >> n >> k;
  vecint a(n);
  for (auto& e : a) cin >> e;
  vector<vecll> dp(n + 1, vecll(k + 1, 0));
  REP(i, n + 1) dp[i][0] = 1;
  REP(i, n) {
    REP(j, k) {
      dp[i + 1][j + 1] = dp[i][j + 1] + dp[i + 1][j];
      if (j - a[i] >= 0) {
        dp[i + 1][j + 1] -= dp[i][j - a[i]];
      }
      if (dp[i + 1][j + 1] < 0) dp[i + 1][j + 1] += MOD;
      dp[i + 1][j + 1] %= MOD;
    }
  }
  cout << dp[n][k] << endl;
}



Measured memory_bytes: 80256
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int m=sc.nextInt();
    int data[]={n+m,n-m,n*m};
    int max=n+m;

    for(int i=1;i<data.length;i++){
      // System.out.println(data[i]);
       max=Math.max(data[i],max);
    }
    System.out.println(max);

  }
}


Measured memory_bytes: 21712
#include <iostream>
#include <map>

using namespace std;

int main(){
    int n,ans = 0;
    map<char,int>m;
    cin >> n;

    for(int i = 0;i < n;i++){
        char c;
        cin >> c;
        m[c]++;
    }

    for(auto &i:m)
        if(i.second > 0)ans++;
    
    if(ans == 3)cout << "Three" << endl;
    else cout << "Four" << endl;
    

    return 0;
}

Measured memory_bytes: 256
#ifdef _LOCAL
#	include <dbg_print.h>
#else
#	define NDEBUG
#	define dprint(...)
#endif

#include <cmath>
#include <cstdio>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
#include <assert.h>
using namespace std;
typedef long long ll;

const int inf = 1<<30;

int main()
{
	ios::sync_with_stdio(false);
	
	int h, n;
	cin >> h >> n;
	vector<int> a(n), b(n);
	for(int i=0; i<n; ++i)
	{
		cin >> a[i] >> b[i];
	}

	vector<int> d(h+1, inf);
	d[0] = 0;

	for(int i=0; i<n; ++i)
	{
		for(int j=0; j<h; ++j)
		{
			if(d[j] < inf /*&& j+a[i] <= h*/)
			{
				int jj = std::min(h, j+a[i]);
				d[jj] = std::min(d[jj], d[j] + b[i]);
			}
		}
	}

	int ans = d[h];
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# ------------------- fast io --------------------
from math import gcd, ceil

def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[i - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] = j
    return pi


def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans

def lcm(a, b): return a * b // gcd(a, b)


def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y


for _ in range(int(input()) if not True else 1):
    n = int(input())
    #n, k = map(int, input().split())
    #c, d = map(int, input().split())
    #a = list(map(int, input().split()))
    #b = list(map(int, input().split()))
    #s = input()
    if n == 1:
        print(0)
        continue

    a = [1, 27, 487]
    while len(a) <= n:
        a += [(27*a[-1]-242*a[-2]+720*a[-3])%(10**9+7)]
    print((a[-3]*2)%(10**9+7))

Measured memory_bytes: 106480
N = int(input())
print(*[11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661,
        691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381][:N])


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n, m, x;
  cin >> n >> m >> x;
  ll a, go_zero=0, go_n=0;
  rep(_, m) {
    cin >> a;
    if(a<x) go_zero++;
    else go_n++;
  }
  cout << min(go_zero, go_n) << newl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;   
int main(){
    int n;
    string s,t;
    cin>>n>>s>>t;
    for(int i=0;i<n;i++){
        int c=1;
        for(int j=0;j<n-i;j++){
            if(s[i+j]!=t[j]){
                c=0;
                break;
            }
        }
        if(c==1){
            cout<<n+i<<endl;
            return(0);
        }
    } 
    cout<<n*2<<endl;
    return 0;
}

Measured memory_bytes: 3568
#include <stdio.h>
void printIntArr(int *arr, int arrsize) {
  for (int i = 0; i < arrsize; i++) {
    if (i==arrsize-1) printf("%d", arr[i]);
    else printf("%d ", arr[i]);
  }
  printf("\n");
}
void insertionSort(int *arr,int arrsize) {
  int tmp,j;
  for (int i = 1; i < arrsize; i++) {
    tmp = arr[i];
    j = i-1;
    while (j >= 0 && arr[j] > tmp) {
      arr[j+1] = arr[j];
      j--;
    }
    arr[j+1] = tmp;
    printIntArr(arr,arrsize);
  }
}
int main() {
  int arrsize;
  scanf("%d", &arrsize);
  int arr[arrsize];
  for (int i = 0; i < arrsize; i++) scanf("%d", &arr[i]);
  printIntArr(arr,arrsize);
  insertionSort(arr,arrsize);
  return 0;
}



Measured memory_bytes: 2704
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
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(){
 string s;
  cin>>s;
  int n=s.size();
  set<char>  c;
  rep(i,0,n){
    c.insert(s[i]);
  }
  char ans='Y';
  for(char i='a';i<='z';i++){
    if(c.count(i)){
      continue;
    }
    else{
      ans=i;
      break;
    }
  }
  if(ans=='Y')cout<<"None"<<endl;
  else cout<<ans<<endl;
}



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

public class Main {
    static void printArray(int[] ans){
        for(int i=0; i<ans.length-1; i++) System.out.printf("%d ", ans[i]);
        System.out.printf("%d\n", ans[ans.length-1]);
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int X = sc.nextInt();
        int[] ans = new int[2*K-1];
        for(int i=0; i<ans.length; i++) ans[i] = X-K+1+i;
        printArray(ans);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;
    cin >> n;
    
    map<string, ll> mp;
    string s;
    for ( ll i = 0; i < n; i++ ){
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }
    
    ll ans = 0;
    for ( auto x: mp )
        ans += x.second * (x.second - 1) / 2;
    
    cout << ans << endl;
    
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 11451419194545;

int main() {
    
    ll H, W, N;
    cin >> H >> W >> N;

    ll ans1 = N / H;
    if(N % H > 0) ans1++;

    ll ans2 = N / W;
    if(N % W > 0) ans2++;

    cout << min(ans1, ans2) << endl;
}

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

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int h, w;
    cin >> h >> w;
    vector<vector<int>> c(10, vector<int>(10));
    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            cin >> c[i][j];
        }
    }

    // 各 1 <= i <= 9 から 0 への最短路
    // WF
    int INF = (1<<29);
    vector<vector<int>> dp = c;
    for(int i=0; i<10; i++){
        dp[i][i] = 0;
    }
    for(int k=0; k<10; k++){
        for(int i=0; i<10; i++){
            for(int j=0; j<10; j++){
                dp[i][j] = min(dp[i][k] + dp[k][j], dp[i][j]);
            }
        }
    }

    int ans = 0;
    for(int i=0; i<h; i++){
        for(int i=0; i<w; i++){
            int a;
            cin >> a;
            if(a != -1){
                ans += dp[a][1];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <iomanip>
using namespace std;

int n, y;

int main(){
    cin >> n >> y;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n-i; j++){
            if((y - i*10000 - j*5000)/1000 == n - i - j){
                cout << i << ' ' << j << ' ' << n-i-j << endl;
                return 0;
            }
        }
    }

    cout << "-1 -1 -1\n";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};
const ll MOD = 1000000007;

vector<ll>path[101010];
ll flg[101010];
ll ans = 1;
ll N, K;

void dfs(ll idx, ll lst1, ll lst2){
    ll tmp = K - lst1 - lst2;
    if(tmp <= 0)ans = 0;
    else ans = (ans * tmp) % MOD;
    ll cnt = 0;
    for(ll i = 0; i < path[idx].size(); i++){
        ll to = path[idx][i];
        if(flg[to])continue;
        flg[to] = 1;
        dfs(to, 1, lst1 + cnt);
        cnt++;
    }
}

int main(){

    cin >> N >> K;
    for(ll i = 1; i < N; i++){
        ll a, b;
        cin >> a >> b;
        path[a].push_back(b);
        path[b].push_back(a);
    }
    flg[1] = 1;
    dfs(1, 0, 0);
    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    int N;
    std::cin >> N;

    if(N & 1){
        N *= 2;
    }

    std::cout << N << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int k;
	cin >> k;
	map<int,int> mp;
	mp[1] = 1;
	mp[2] = 1;
	mp[3] = 1;
	mp[4] = 2;
	mp[5] = 1;
	mp[6] = 2;
	mp[7] = 1;
	mp[8] = 5;
	mp[9] = 2;
	mp[10] = 2;
	mp[11] = 1;
	mp[12] = 5;
	mp[13] = 1;
	mp[14] = 2;
	mp[15] = 1;
	mp[16] = 14;
	mp[17] = 1;
	mp[18] = 5;
	mp[19] = 1;
	mp[20] = 5;
	mp[21] = 2;
	mp[22] = 2;
	mp[23] = 1;
	mp[24] = 15;
	mp[25] = 2;
	mp[26] = 2;
	mp[27] = 5;
	mp[28] = 4;
	mp[29] = 1;
	mp[30] = 4;
	mp[31] = 1;
	mp[32] = 51;
	cout<<mp[k]<<endl;
	return 0;
} 

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

int pow2num(int n){
	int num=0;
	while(n%2==0){
		num++;
		n = n/2;
	}
	return num;
}

int main() {
	int n; cin >> n;
	int ans;
	for (int i = 0; i < n; ++i) {
		int a; cin >> a;
		ans += pow2num(a);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
import heapq

def solve(N, M, A):
    q = []
    for a in A:
        heapq.heappush(q, -a)
    for i in range(M):
        a = heapq.heappop(q)
        heapq.heappush(q, a / 2)
    return -sum([int(v) for v in q])

def main():
    N, M = map(int, input().strip().split())
    A = map(int, input().strip().split())
    print(solve(N, M, A))

if __name__ == "__main__":
    main()


Measured memory_bytes: 92824
fun main() {
    val l = readLine()!!.split(" ").map { it.toInt() }
    val x = l[0]
    val y = l[1]

    var success = false

    for (i in (0 .. x)) {
        if (2 * i + 4 * (x - i) == y) {
            success = true
            break
        }
    }

    val result = if (success) "Yes" else "No"

    print(result)

}

Measured memory_bytes: 36392
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int i;
  string text;
  bool flag=false;
  cin>>i;

  while(i>0){
    cin>>text;
    if(text=="Y"){
      flag=true;
      break;
    }
    i--;
  }

  if(flag) cout<<"Four"<<endl;
  else cout<<"Three"<<endl;
}

Measured memory_bytes: 3632
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
int n,m,k;
char str[]="RGBY";
int main(){
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			int a=((m+i+j)/k)%2,b=((m+i-j)/k)%2;
			printf("%c",str[a*2+b]);
		}
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  map<char, vector<P>> mp;
  rep(i, n) {
    ll x, y;
    char c;
    cin >> x >> y >> c;
    mp[c].push_back({x, y});
  }
  ll ans = 1e18;
  map<ll, set<ll>> ds, ls;
  for(auto p : mp['D']) ds[p.first].insert(p.second);
  for(auto p : mp['U']) {
    ll x = p.first;
    ll y = p.second;
    auto in = ds[x].lower_bound(y);
    if(in == end(ds[x])) continue;
    ll now = (*in - y) * 5;
    ans = min(ans, now);
  }
  for(auto p : mp['L']) ls[p.second].insert(p.first);
  for(auto p : mp['R']) {
    ll x = p.first;
    ll y = p.second;
    auto in = ls[y].lower_bound(x);
    if(in == end(ls[y])) continue;
    ll now = (*in - x) * 5;
    ans = min(ans, now);
  }

  map<ll, set<ll>> u, d;
  for(auto p : mp['U']) u[p.first + p.second].insert(p.first);
  for(auto p : mp['D']) d[p.first - p.second].insert(p.first);
  for(auto p : mp['R']) {
    ll x = p.first;
    ll y = p.second;
    auto in = u[x + y].lower_bound(x);
    ll now;
    if(in != end(u[x + y])) {
      now = (*in - x) * 10;
      ans = min(ans, now);
    }
    in = d[x - y].lower_bound(x);
    if(in != end(d[x - y])) {
      now = (*in - x) * 10;
      ans = min(ans, now);
    }
  }

  u.clear();
  d.clear();
  for(auto p : mp['U']) u[p.first - p.second].insert(p.first);
  for(auto p : mp['D']) d[p.first + p.second].insert(p.first);
  for(auto p : mp['L']) {
    ll x = p.first;
    ll y = p.second;
    auto in = u[x - y].upper_bound(x);
    ll now;
    if(in != begin(u[x - y])) {
      in--;
      now = (x - *in) * 10;
      ans = min(ans, now);
    }
    in = d[x + y].upper_bound(x);
    if(in != begin(d[x + y])) {
      in--;
      now = (x - *in) * 10;
      ans = min(ans, now);
    }
  }

  if(ans == 1e18)
    cout << "SAFE" << endl;
  else
    cout << ans << endl;
}

Measured memory_bytes: 61872
import java.util.Scanner;

public class Main{

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

        // input
        int people = scan.nextInt();
        final int FOODS = scan.nextInt();
        int[] value = new int[FOODS];
        for(int i = 0; i < people; i++){
            int temp = scan.nextInt();
            for(int j = 0; j < temp; j++){
                value[scan.nextInt() - 1] += 1;
            }
        }

        // search
        int count = 0;
        for(int i = 0; i < FOODS; i++){
            if(value[i] == people){
                count++;
            }
        }

        // answer
        System.out.println(count);

    }
}

Measured memory_bytes: 21840
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define sz(a)			a.size()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD1			998244353
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)
int in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
using namespace __gnu_pbds;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//find_by_order kth largest  order_of_key <
const int tam = 100010;
const int MOD = 1e9+7;
const double EPS = 1e-9;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	//freopen("qwe.txt", "r", stdin);
	//freopen("asd.txt", "w", stdout);
	int n;
	ll g, ax;
	cin>>n>>g;
	int ar[n], val[n];
	fore(i, 0, n) cin>>ar[i]>>val[i];
	int res = 10000000, can;
	for(int i = 0; i < (1<<n); i++)
	{
		ax = g;
		can = 0;
		fore(j, 0, n)
		{
			if((1<<j) & i)
			{
				can += ar[j];
				ax -= (j+1) * 100 * ar[j] + val[j];
			}
		}
		if(ax <= 0)
			res = min(res, can);
		else
		{
			fore(j, 0, n)
			{
				if(!((1<<j) & i))
				{
					if(ax <= (j+1) * 100 * ar[j] + val[j])
					{
						if(ax <= (j+1) * 100 * ar[j])
						{
							res = min((ll)res, can + ax / ((j+1) * 100) + (ax % ((j+1) * 100) > 0? 1: 0));
						}
						else
							res = min(res, can + ar[j]);
					}
				}
			}
		}
	}
	cout<<res<<'\n';
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

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

int main()
{
    int64_t L, R;
    int64_t ans = 2018;
    cin >> L >> R;

    if(R/2019!=L/2019)
        ans = 0;
    else{
        L %= 2019;
        R %= 2019;

        if (L > R)
            swap(L, R);

        for (int i = 0; i <= R - L; i++)
        {
            for (int j = i + 1; j <= R - L; j++)
            {
                ans = min(((L + i) * (L + j)) % 2019, ans);
            }
        }     
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>
void binary(int);
int n[100000],q[50000];
int right,left,mid,s,t,count=0;


int main(){
  int i;

  scanf("%d",&s);
  for(i=0;i<s;i++) scanf("%d",&n[i]);
  scanf("%d",&t);
  for(i=0;i<t;i++) scanf("%d",&q[i]);

  for(i=0;i<t;i++) binary(q[i]);

  printf("%d\n",count);
  return 0;
}
void binary(int key){
  left=0;
  right=s;
  mid=s/2;
  while(left<right){
    if(n[mid]<key){
      left=mid+1;
      mid=(left+right)/2;
    }else if(n[mid]>key){
      right=mid;
      mid=(left+right)/2;
    }else if(n[mid]==key){
      count++;
      return;
    }
  }
}



Measured memory_bytes: 2316
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
    int n, t, sum, minv, maxv;
    for (; ;) {
        scanf("%d", &n);
        if (n == 0) break;
        sum = maxv = 0, minv = 1001;
        for (int i = 0; i < n; i++) {
            scanf("%d", &t);
            sum+=t;
            maxv = max(maxv, t);
            minv = min(minv, t);
        }
        printf("%d\n", (sum-maxv-minv)/(n-2));
    }
    return 0;
}



Measured memory_bytes: 2600
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<math.h>

using namespace std;

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

	int sum = A + B;
	int sub = A - B;
	int kak = A * B;

	if (sum > sub)
	{
		if (sum > kak)
			cout << sum << endl;
		else
			cout << kak << endl;
	}
	else
	{
		if( sub > kak )
				cout << sub << endl;
			else
				cout << kak << endl;
	}

	return 0;
}

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

int main(void){
    std::string r,g,b;
    std::cin >> r >> g >> b;

    std::string s = r + g + b;
    int abc = stoi(s);

    std::cout << (abc % 4 == 0 ? "YES" : "NO");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 4005;
char arr[N] = {};
int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int len;
    while (cin >> len) {
        long long cnt = 0, ans = 0;
        for (int i = 1; i <= len; i++) {
            cin >> arr[i];
            cnt += arr[i] == 'B';
        }
        for (int i = 1; i <= len; i++)
            if (arr[i] != 'B')
                for (int j = i + 1; j <= len; j++)
                    if (arr[j] != arr[i] && arr[j] != 'B') {
                        ans += cnt;
                        if (i + i - j > 0)
                            ans -= arr[i + i - j] == 'B';
                        if ((i + j) % 2 == 0)
                            ans -= arr[(i + j) >> 1] == 'B';
                        if (j + j - i <= len)
                            ans -= arr[j + j - i] == 'B';
                    }
        cout << ans << '\n';
    }
    return 0;
}

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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

const double PI = acos(-1);
typedef pair<int, int> P;

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

int lcm(int a, int b) { return a / gcd(a, b) * b; }

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) //bit計算
{
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void)
{
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++)
    {
        if (!prime[i])
        {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i)
        {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}
vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i - 1);
            if (i * i != n)
            {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}
int numofbits4(int bits)
{
    int num;

    num = (bits >> 1) & 03333333333;
    num = bits - num - ((num >> 1) & 03333333333);
    num = ((num + (num >> 3)) & 0707070707) % 077;

    return num;
}

int N, M, Q, ans;
vector<int> a, b, c, d;
void dfs(vector<int> A)
{
    if (A.size() == N + 1)
    {
        int now = 0;
        rep(i, Q)
        {
            if (A[b[i]] - A[a[i]] == c[i])
                now += d[i];
        }
        ans = max(ans, now);
        return;
    }
    A.push_back(A.back());
    while (A.back() <= M)
    {
        dfs(A);
        A.back()++;
    }
}
vector<tuple<int, int, int>> wh;

int main()
{
    /*
    int N;
    cin >> N;
    rep(i, N)
    {
        int w, h, area;
        cin >> w >> h;
        area = w * h;
        wh.emplace_back(area, max(w, h), min(w, h));
    }
    sort(wh.begin(), wh.end());
    for (auto x : wh)
    {
        cout << get<0>(x) << " " << get<1>(x) << " " << get<2>(x) << endl;
    }
    */
    int R;
    cin >> R;
    cout << 2 * R * PI << endl;
}

Measured memory_bytes: 3800
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <stdbool.h>
int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    int ans=b/a;
    if (ans>c) printf("%d",c);
    else printf("%d",ans);
    return 0;
}

Measured memory_bytes: 1736
import math

def plot(x,y):
    print(f'{x:.8f} {y:.8f}')

def Koch(n,x1,y1,x2,y2):
    if n == 0:
        plot(x1,y1)
        return
    sx = (2*x1+x2)/3
    sy = (2*y1+y2)/3
    tx = (x1+2*x2)/3
    ty = (y1+2*y2)/3
    ux = (tx-sx)*(1/2)-(ty-sy)*(math.sqrt(3)/2)+sx
    uy = (tx-sx)*(math.sqrt(3)/2)+(ty-sy)*(1/2)+sy
    Koch(n-1,x1,y1, sx,sy)
    Koch(n-1,sx,sy, ux,uy)
    Koch(n-1,ux,uy, tx,ty)
    Koch(n-1,tx,ty, x2,y2)
    
n=int(input()) 
Koch(n,0,0, 100,0)
plot(100,0)


Measured memory_bytes: 5752
#include <stdio.h>
#include <algorithm>
using namespace std;

int main()
{
    char s[4][2]={'S','S','S','W','W','S','W','W'},a[100005],b[100005];
    int n,i,k,flag;
    scanf("%d",&n);
    scanf("%s",a);
    for(k=0;k<4;k++)
    {   flag=0;
        b[0]=s[k][0],b[1]=s[k][1];
        char temp;
        if(a[0]=='o'&&b[0]=='S')temp=b[1];
        else if(a[0]=='x'&&b[0]=='S')
        {
            if(b[1]=='S')temp='W';
            else temp='S';
        }
        else if(a[0]=='x'&&b[0]=='W')temp=b[1];
        else if(a[0]=='o'&&b[0]=='W')
        {
         if(b[1]=='W')temp='S';
         else temp='W';
        }
        for(i=1;i<n;i++)
        {
          if(a[i]=='o'&&b[i]=='S')b[i+1]=b[i-1];
        else if(a[i]=='x'&&b[i]=='S')
        {
            if(b[i-1]=='S')b[i+1]='W';
            else b[i+1]='S';
        }
        else if(a[i]=='x'&&b[i]=='W')b[i+1]=b[i-1];
        else if(a[i]=='o'&&b[i]=='W')
        {
         if(b[i-1]=='W')b[i+1]='S';
         else b[i+1]='W';
        }
        }
        if(b[n]==b[0]&&temp==b[n-1])
        {
            flag=1;
            break;
        }
    }
    b[n]='\0';
    if(flag)printf("%s\n",b);
    else printf("-1\n");
    return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;

 
const ll INF = 1e12;
const ll N =(2e3+5); // TODO : change value as per problem
const ll MOD = 1e9+7;

vector<int> adj[N];

int dis[N][N];
int s;
void dfs(int u,int p,int h){
    dis[s][u] = h;
    for(auto v:adj[u]) if(v != p){
    	dfs(v,u,h+1);
    }
}

void solve(){
    int n,m;
    cin >> n >> m; 
    for(int i = 2;i <= n;i++){
        int u,v;
        cin >> u >> v;
        adj[u].pb(v);
        adj[v].pb(u);
    }  
    for(int i =1;i<=n;i++){
    	s = i;
    	dfs(i,0,0);
    }
    int ans = 0;
    if(m%2==0){
    	int cnt = 0;
    	for(int i = 1;i <= n;i++){
    		cnt =0;
    		for(int j = 1;j<=n;j++){
    			if(dis[i][j] <= (m >> 1ll))
    				cnt++;
    		}
    		ans = max(ans,cnt);
    	}
    }
    else{
    	for(int i = 1;i<=n;i++){
    		for(auto j:adj[i]){
    			int cnt =0;
    			for(int k = 1;k<=n;k++){
    				if(min(dis[i][k],dis[j][k]) <= (m>>1ll))
    					cnt++;
    			}
    			ans =max(ans,cnt);
    		}
    	}
    }
    cout << n-ans << endl;
   

}
signed main(){
 
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
     // freopen(".in","r",stdin);freopen(".out","w",stdout);
    
     ll tt=1;   
     // cin >> tt;
    while(tt--){    
        solve();
    }    
}

Measured memory_bytes: 35080
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

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

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template<class T> void corner(bool flg, T hoge) {
	if (flg) {
		cout << hoge << endl;
		exit(0);
	}
	else return;
}

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
	o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}

template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {
	o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;
}

template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {
	o << "{" << obj.first << ", " << obj.second << "}"; return o;
}

template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print(void) {
	cout << endl;
}

template <class Head> void print(Head&& head) {
	cout << head;
	print();
}

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
	cout << head << " ";
	print(forward<Tail>(tail)...);
}

void YN(bool flg) {
	cout << ((flg) ? "YES" : "NO") << endl;
}

void Yn(bool flg) {
	cout << ((flg) ? "Yes" : "No") << endl;
}

void yn(bool flg) {
	cout << ((flg) ? "yes" : "no") << endl;
}

int main() {

	int L,sum; cin >> L;
	V<int> u, v, w;
	for(int i = 1; i < 20; ++i) {
		u.push_back(i);
		v.push_back(i+1);
		w.push_back(0);	
	}
	
	for (int i = 20; 0 <= i; --i) {
		if(L&(1 << i)){
			for (int j = i; 1 <= j; --j){
				u.push_back(20-j);
				v.push_back(20-(j-1));
				w.push_back(1<<(j-1));			
			}
			sum = (1 << i);
			L = L^(1 << i);
			break;
		}
	}

	for (int i = 20; 0 <= i; --i) {
		if (L&(1 << i)) {
			u.push_back(1);
			v.push_back(20-i);
			w.push_back(sum);
			sum += (1 << i);
		}
	}
	cout << 20 << " " << u.size() << endl;
	REP(i,u.size()){
		cout << u[i] << " " << v[i] << " " << w[i] << endl;
	}
	
	return 0;
}



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

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

int main() {
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int> cx(n), cy(m);
	rep(i, n) cin >> cx[i];
	rep(i, m) cin >> cy[i];

	sort(cx.begin(), cx.end());
	sort(cy.begin(), cy.end());
	if (cx.back() < cy.front() && (cx.back() < y && x < cy.front()))
		cout << "No War" << endl;
	else
		cout << "War" << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Combinatorial - Edit Distance (Levenshtein Distance)
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_E&lang=jp

"""
import sys


def solve(word1, word2):
    n, m = len(word1), len(word2)
    dp = [[0] * (m + 1) for _ in range(n + 1)]
    for i in range(n + 1):
        dp[i][0] = i
    for j in range(m + 1):
        dp[0][j] = j

    for i in range(1, n + 1):
        for j in range(1, m + 1):
            cost = 0 if word1[i - 1] == word2[j - 1] else 1
            dp[i][j] = min(dp[i - 1][j] + 1,         # insertion
                           dp[i][j - 1] + 1,         # deletion
                           dp[i - 1][j - 1] + cost)  # replacement
    return dp[n][m]


def main(args):
    s1 = input()
    s2 = input()
    ans = solve(s1, s2)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])



Measured memory_bytes: 43092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, m, a, b, p, root, ans[100008];

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n >> m;
	vector<ll> edge[n+1];
	set<ll> redge[n+1];
	rep(i, 1, n-1+m){
		cin >> a >> b;
		edge[a].push_back(b);
		redge[b].insert(a);
	}
	
	rep(i, 1, n){if(redge[i].size() == 0){p = i;}}
	ans[p] = 0;
	
	queue<ll> q;
	q.push(p);
	while(!q.empty()){
		ll at = q.front();
		q.pop();
		for(ll i = 0; i < edge[at].size(); i++){
			ll nx = edge[at][i];
			if(redge[nx].size() > 1){
				redge[nx].erase(at);
			}
			else{
				q.push(nx);
				ans[nx] = at;
			}
		}
	}
	
	rep(i, 1, n){
		print(ans[i])
	}
	return 0;
}

Measured memory_bytes: 16512
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;

using namespace std;

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

    vector<ll> h(n);

    for (auto &i: h)
        cin >> i;

    ll ans(0);
    ll c(0);
    for (ll i=n-1; i>=1; i--)
    {
        //cout << h[i] << ' ' << h[i-1] <<  ' ';

        if (h[i-1] >= h[i])
        {
            c++;
        }
        else
        {
            ans = max(c, ans);
            c = 0;
        }
    }

    ans = max(c, ans);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
const int MAXN = (1 << 20);

int n;
int a[MAXN];

void read()
{
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> a[i];
}

void stop()
{
	cout << "Impossible" << endl;
	exit(0);
}

int cnt[MAXN];

void solve()
{
	sort(a, a + n);

	for(int i = 0; i < n; i++)
		cnt[a[i]]++;

	for(int i = 0; i < n; i++)
		if(cnt[a[i] - 1] == 0 && a[i] != a[0])
			stop();

	if(cnt[a[0]] > 2)
		stop();

	if(a[n - 1] > 2 * a[0])
		stop();

	if(cnt[a[0]] == 1)
	{
		int mn_cnt = MAXN;
		for(int v = a[0] + 1; v <= a[n - 1]; v++)
			mn_cnt = min(mn_cnt, cnt[v]);

		if(mn_cnt <= 1) stop();
		if(a[0] * 2 != a[n - 1]) stop();
	}
	else
	{
		int mn_cnt = MAXN;
		for(int v = a[0]; v <= a[n - 1]; v++)
			mn_cnt = min(mn_cnt, cnt[v]);

		if(mn_cnt <= 1) stop();
		if(a[0] * 2 - 1 != a[n - 1]) stop();
	}

	cout << "Possible" << endl;
}

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

	read();
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN 105
#define N 100
using namespace std;
inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while (ch<'0'||ch>'9'){
        if (ch=='-') f=-1;
        ch=getchar();
    }
    while (ch>='0'&&ch<='9'){
        x=(x<<3)+(x<<1)+(ch^'0');
        ch=getchar();
    }
    return x*f;
}
int d[MAXN][MAXN],f[MAXN][MAXN];
int main(){
	// freopen("AT3877.out","w",stdout);
	int A=read(),B=read();
	for (register int i=1;i<=A;++i){
		for (register int j=1;j<=B;++j){
			d[i][j]=read();
		}
	}
	for (register int i=0;i<=N;++i){
		for (register int j=0;j<=N;++j){
			//f[i][j]=0;//构造f[i][j]
			for (register int x=1;x<=A;++x){
				for (register int y=1;y<=B;++y){
					f[i][j]=max(f[i][j],d[x][y]-i*x-j*y);
				}
			}
			// printf("%d ",f[i][j]);
		}
		// puts("");
	}
	for (register int x=1;x<=A;++x){
		for (register int y=1;y<=B;++y){
			int ans=0x7fffffff;
			for (register int i=0;i<=N;++i){
				for (register int j=0;j<=N;++j){
					ans=min(ans,f[i][j]+i*x+j*y);
				}
			}
			//printf("%d %d\n",ans,d[x][y]);
			if (ans!=d[x][y]) {
				puts("Impossible");
				return 0;
			}
		}
	}
	puts("Possible");;;;
	printf("%d %d\n",N*2+2,N+N+(N+1)*(N+1));
	for (register int i=1;i<=N;++i){
		printf("%d %d X\n",i,i+1);
	}
	for (register int i=N+2;i<(N+1)*2;++i){//反着搞
		printf("%d %d Y\n",i,i+1);
	}
	for (register int i=0;i<=N;++i){
		for (register int j=0;j<=N;++j){
			printf("%d %d %d\n",i+1,202-j,f[i][j]);
		}
	}
	printf("%d %d\n",1,(N+1)*2);
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;

int main(){
	int counter[26];
	for(int i = 0; i < 26; i++){
		counter[i] = 0;
	}
	char inChar;
	int offset = 'a' - 'A';
	while(scanf("%[\n]\n",&inChar)!=EOF){
		cin >> inChar;
		if(inChar == EOF) break;
		if(inChar >= 'A' && inChar <= 'Z'){
			inChar += offset;
		}		
		if(inChar >= 'a' && inChar <= 'z'){
			counter[inChar - 'a']++;
		}
	}
	for(int i = 0; i < 26; i++){
		cout << (char)(i + 'a') << " : " << counter[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std ;
	#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	#define lli long long int
	#define ulli unsigned long long int
	#define ff first
	#define ss second
	#define mp make_pair
	#define pb push_back
	#define pf pop_front()
	#define lb lower_bound
	#define ub upper_bound
	#define bs binary_search
	#define loop(i,a,b) for(lli i=a;i<b;i++)
	#define loopi(i,a,b) for(int i=a;i<b;i++)
	#define all(v) v.begin(), v.end()
	#define mod 1000000007
	#define inf 100000000000000000
	#define lld long double
	#define pll pair<long long int,long long int>
	#define pii pair<int,int>
	#define vll vector<lli>
	#define vii vector<int>
	#define endl '\n'
	#define setp(k, x) fixed << setprecision(k) << (x)
	#define deb(x) cerr << #x << ": " << x << " " << endl;
	#define debug(x) cout << "m here-" <<#x<<" ..."<<"\n";
	#define printa(a,n) for(lli i=0;i<n;i++) cout<<a[i]<<" "; cout<<"\n";
  #define printv(a) for(lli i=0;i<a.size();i++) cout<<a[i]<<" "; cout<<"\n";
	bool sortcol( const vector<lli>& v1, const vector<lli>& v2 ) //sort on basis of column //use- sort(vect.begin(), vect.end(),sortcol);
      { return v1[1] < v2[1]; }//[] o based indexing in column
	bool sortpair(const pair<lli, lli> &a, const pair<lli, lli> &b)
			{return a.second < b.second;}


int main ()
{
	// fastio
 	// lli  t;
 	// cin>>t;
 	// while(t--)
 	{
		lli n,i,d,a,b,c,j,k,sum=0;
    double r;
    cin>>r;
    cout<<2*(3.14159)*r<<"\n";

 	}
}


Measured memory_bytes: 3772
import itertools
from bisect import bisect_left,bisect
import sys

n,K=map(int,input().split())
A=list(map(int,input().split()))

A_max=max(A)
lst=[[] for i in range(A_max+1)]
flag=[0]*(A_max+1)
for i in range(n):
    lst[A[i]].append(i)

flag=[0]*n
data=[]
i=0
while flag[i]==0:
    flag[i]=1
    a=A[i]
    b=bisect(lst[a],i)
    if b==len(lst[a]):
        data.append(i)
        i=lst[a][0]+1
    else:
        i=lst[a][b]+1
    if i==n:
        data.append(n)
        i=0

#大丈夫
if not data:
    print()
    sys.exit()
s=len(data)
zzz=data[(K-1)%s]
i=zzz
d=[]
while i<n:
    a=A[i]
    b=bisect(lst[a],i)
    if b<len(lst[a]):
        d.append([i,lst[a][b]])
        i=lst[a][b]+1
        continue
    else:
        i+=1


if d:
    ans=A[zzz:d[0][0]]
    for j in range(len(d)-1):
        ans=list(itertools.chain(ans,A[d[j][1]+1:d[j+1][0]]))
    ans=list(itertools.chain(ans,A[d[-1][1]+1:]))
    print(*ans)
else:
    print(*A[zzz:])

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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);


  int a;string s;cin>>a>>s;
  if(a>=3200)cout<<s<<endl;
  else puts("red");
  
  return 0;
}


Measured memory_bytes: 3600
#include <stdio.h>

#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

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

int counter(int x) {
    if (x == 0) {
        return 0;
    } else {
        return counter(x >> 1) + (x & 1);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    int A[20];
    int x[20][20];
    int y[20][20];
    cin >> N;

    for (int i = 1; i <= N; i++) {
        cin >> A[i];
        for (int j = 1; j <= A[i]; j++) {
            cin >> x[i][j] >> y[i][j];
        }
    }
    //----------

    int ans = 0;
    for (int bits = 1; bits < (1 << N); bits++) { //[正直者、嘘つき]をbit全探索
        bool ok = true;
        for (int i = 1; i <= N; i++) { //人数ぶんだけループ
            if (!(bits & (1 << (i - 1)))) { //該当する人(=i番目の人)が正直者と仮定している場合だけを考える
                continue;
            }
            for (int j = 1; j <= A[i]; j++) { //証言を全て確認
                if (((bits >> (x[i][j] - 1)) & 1) ^ y[i][j]) { //矛盾があるかを1bit目で判定
                    ok = false;
                }
            }
        }
        if (ok) {
            ans = max(ans, counter(bits));
        }
        debug(ans);
    }
    debug(ans);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
const int MAX_E=200000;
struct UnionFind{
    vi data;
    UnionFind(int size):data(size,-1){}
    bool unite(int x,int y){
        x=root(x);y=root(y);
        if(x!=y){
            if(data[y]<data[x])swap(x,y);
            data[x]+=data[y];data[y]=x;
        }
        return x!=y;
    }
    bool find(int x,int y){
        return root(x)==root(y);
    }
    int root(int x){
        return data[x]<0?x:data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};
struct edge{int u,v,cost;};
bool comp(const edge& e1,const edge& e2){
    return e1.cost<e2.cost;
}
edge es[MAX_E];
int V,E;
int kruskal(){
    sort(es,es+E,comp);
    UnionFind uf(V);
    int res=0;
    REP(i,E){
        edge e=es[i];
        if(!uf.find(e.u,e.v)){
            uf.unite(e.u,e.v);
            res+=e.cost;
        }
    }
    return res;
}
int main(){
    cin>>V;
    vp a(V),b(V);
    REP(i,V){
        cin>>a[i].fi>>b[i].fi;
        a[i].se=i;
        b[i].se=i;
    }
    sort(all(a));
    sort(all(b));
    REP(i,V-1){
        edge e;
        e.u=a[i].se;
        e.v=a[i+1].se;
        e.cost=a[i+1].fi-a[i].fi;
        es[E++]=e;
    }
    REP(i,V-1){
        edge e;
        e.u=b[i].se;
        e.v=b[i+1].se;
        e.cost=b[i+1].fi-b[i].fi;
        es[E++]=e;
    }
    cout<<kruskal()<<endl;
    return 0;
}

Measured memory_bytes: 5116