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

using ll = long long int;
using pp = pair<int, int>;

const int MAX_N = 50 + 5;
const ll INF = 1LL << 62;


int n, k;
int x[MAX_N], y[MAX_N];

ll ans = INF;

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%lld %lld", &x[i], &y[i]);
  }

  vector<pp> xo = {};
  vector<pp> yo = {};

  for (int i = 0; i < n; ++i) {
    xo.push_back(make_pair(x[i], y[i]));
    yo.push_back(make_pair(x[i], y[i]));
  }

  sort(xo.begin(), xo.end(), [](const pp& a, const pp& b){return (a.first < b.first);});
  sort(yo.begin(), yo.end(), [](const pp& a, const pp& b){return (a.second < b.second);});

  for (int xli = 0; xli < n; ++xli) for (int xri = xli + 1; xri < n; ++xri) {

    ll l = xo[xli].first;
    ll r = xo[xri].first;

    deque<pp> sample = {};

    for (int i = 0; i < n; ++i) {
      if (l <= yo[i].first && yo[i].first <= r) {

        sample.push_back(yo[i]);
        if (sample.size() >= k) {
          ll t = sample.back().second;
          ll d = sample.front().second;
          ll temp = 1LL * ((r - l) * (t - d));
          ans = min(ans, temp);

          sample.pop_front();
        }
      }
    }
  }

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

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 20 + 5;
int a[maxn], b[maxn];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, res = 0, tmp;
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 0; i < n; ++i) {
		cin >> tmp;
		res += tmp;
	}
	for (int i = 1; i < n; ++i)
		cin >> b[i];
	for (int i = 1; i < n; ++i)
		if (a[i] == a[i - 1] + 1)
			res += b[a[i - 1]];
	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる





int main() {
  char c;
  cin>>c;

  string s="aiueo";
  rep(i,5){
    if(s[i]==c){
      cout << "vowel" << endl;
      return 0;
    }
  }

  cout << "consonant" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;

int main(){
    string s;
    string sub1, sub2;
    cin >> s;
    sub1 = s.substr(0, 2);
    sub2 = s.substr(2, 2);
    int fst = stoi(sub1);
    int scd = stoi(sub2);
    if(fst < 13 && fst > 0){
        if(scd < 13 && scd > 0){
            cout << "AMBIGUOUS" << endl;
        } else {
            cout << "MMYY" << endl;
        }

    } else {
        if(scd < 13 && scd > 0){
            cout << "YYMM" << endl;
        } else {
            cout << "NA" << endl;
        }
    }
    return 0;
}

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

    string a ,b ; 
    cin>>a>>b ; 
    int count = 0 ; 
    int al,bl ; 
    
    al= a.size   ( ) ; 
    bl= b.size  ( )  ;
    int minl = INT_MAX ;
	if  (al==bl  )
   {
   	  
	minl=0  ; 	 
    for  ( int i=0  ; i<al   ; i++ ) 
	 {
	 	    if  ( a[i] != b[i])
 minl++ ;

	 	
	 	
		  }	 
		    	
   	
      }

   	
   	
   	
   	
   	
   	
	
	else
	{
	
    for  ( int i=0  ; i<al-bl   ; i++ ) 
   {
   	 int index=i ; 
   	 count =0;
   	   
   	    for  ( int  j=0  ; j<bl  ; j++ ) 
{
    if  ( a[index++] != b[j])
 count++ ;
    	
   	
   	
   }
   	minl=min  ( minl ,  count ) ; 
   }

} 
  cout<<minl<<endl ; 



    return 0 ;
}




Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
int main(){
    std::vector<int> v(3, 0);
    std::cin >> v[0] >> v[1] >> v[2];
    sort(v.begin(), v.end());
    std::cout << (((v[0]+v[1]) == v[2]) ? "Yes" : "No") << std::endl;
}

Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))

DP = []

for i in range(N):
    if i == 0:
        DP.append(0)
    elif i == 1:
        DP.append(abs(h[0] - h[1]))
    else:
        one_hop = abs(h[i-1] - h[i]) + DP[i-1]
        two_hop = abs(h[i-2] - h[i]) + DP[i-2]
        if one_hop <= two_hop:
            DP.append(one_hop)
        else:
            DP.append(two_hop)

print(DP[-1])


Measured memory_bytes: 13980
var
i,j,k,m,n,g:int64;
begin
    read(m,n,k);
    j:=0;
    while 1=1 do
    begin
        g:=j*m;
        if g mod n=k then
        begin
            writeln('YES');
            exit;
        end;
        inc(j);
        if j>=1000 then break;
    end;
    writeln('NO');
end.


Measured memory_bytes: 128
import sys
input = sys.stdin.readline
import math

A, B = map(int, input().split(' '))
A_list = [i/10+A for i in range(0, 10)]
B_list = [i/10+B for i in range(0, 10)]
x, y = 0, 0
a_set = set()
b_set = set()
for a in A_list:
    a_set.add(math.ceil(a/0.08))
for b in B_list:
    b_set.add(math.ceil(b/0.1))
ans_list = list(a_set & b_set)
if len(ans_list) == 0:
    print(-1)
else:
    print(int(min(ans_list)))

Measured memory_bytes: 3188
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
using namespace std;

vector<ll> divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}


int main(){
  ll N; cin>>N;
  ll ans = 0;
  if(N == 1){cout<<0<<endl;return 0;}
 // cout<<divisor(N).size()<<endl;
 vector <ll> div = divisor(N);
 for(ll i=0;i<div.size();i++){
   ll m;
   m = (N/div[i] -1);
   if(m==0) continue;
  // cout<<div[i]<<"   "<<(N-div[i])/div[i]<<endl;
  if(N/m == N%m) ans += m;

 }

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



/*
int main(){
  ll N; cin>>N;
  if(N == 1){cout<<1<<endl;return 0;}

  for(ll m=1;m<=N;m++){
    ll quotient = N/m;
    ll remain = N % m;
    if(quotient == remain)
    cout<<"m: "<<m<<"  quotient: "<<quotient<<"  reamin:  "<<remain<<endl;
    //cout<< (quotient == remain)<<endl;

  }

  return 0;
}*/

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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll a,b;
  cin >> a >> b;
  cout << a%b << endl;
  return 0;
}

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>

using namespace boost::multiprecision;
*/

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define debug(aa, a) fprintf(stderr, aa, a)

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {//lcmを求める
	return number1 / gcd(number1, number2) * number2;
}

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	ll x, y;
	scanf("%lld%lld", &x, &y);
	printf("%lld\n", gcd(x, y));

	Please AC;
}



Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    if(e-a > k)cout << ":(\n";
    else cout << "Yay!" << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
N,M = map(int, input().split())
A = []
quantity = 0
price = 0

for i in range(N):
    a = list(map(int, input().split()))
    A.append(a)
A = sorted(A)
for i in range(M):
    quantity += A[i][1]
    if quantity < M:
        price += A[i][0]*A[i][1]
    else:
       price += A[i][0]*(M-(quantity-A[i][1]))
       break
print(price)

Measured memory_bytes: 28656
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef vector <int> vi;
#define REP(i,n) for(i=0;i<n;i++)

struct branch{
	int n1,n2,w;
};
bool f(branch i, branch j){
	return (i.w>j.w);
}
int main(){
	while (1){
		int n,i;
		char c;
		cin>>n;
		if(n==0)break;
		vector<int>T(n);
		REP(i,n)T[i]=i;

		branch tmp;
		int m; cin>>m;
		vector<branch>S(m);
		REP(i,m) cin>>S[i].n1>>c>>S[i].n2>>c>>S[i].w;
		sort(S.begin(),S.end(),f);

		int a=0;
		while(S.size()){
			tmp=S.back();
			S.pop_back();
			int b=T[tmp.n1],c=T[tmp.n2];
			if (b!=c){
				for(i=0;i<n;i++)
					if(T[i]==c)T[i]=b;
				a+=tmp.w/100-1;
			}
		}
		cout<<a<<endl;
	}
}

Measured memory_bytes: 1272
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<functional>

using namespace std;


int main() {
	
	int a, b;
	cin >> a >> b;
	int product = a * b;
	if (product % 2 == 0) {
		cout << "Even";
	}
	else {
		cout << "Odd";
	}
	return 0;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int a = sc.nextInt();
    	int b = sc.nextInt();
    	
    	if(a%2==0){
    		System.out.println("Even");
    	}
    	else if(b%2==0){
    		System.out.println("Even");	
    	}
    	else{
    		System.out.println("Odd");
    	}
    }
    
}

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

bool kansuu(string s)
{
	int n = s.size();
	bool flag = true;
	for (int i = 0; i < n; i++) {
		if (s[i] != s[n - 1 - i]) {
			flag = false;
			break;
		}
	}
	return flag;
}


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

	string ans = "No";
	int n = s.size();

	if (kansuu(s) == true) {
		string zenhann = s.substr(0, (n - 1) / 2);
		if (kansuu(zenhann) == true) {
			string kouhann = s.substr((n + 1) / 2, (n - 1) / 2);
			if (kansuu(kouhann) == true) {
				ans = "Yes";
			}
		}
	}

	cout << ans << endl;
}



Measured memory_bytes: 256
n, k = map(int, input().split())

H = list(map(int, input().split()))

min_money = 10**18
for i in range(2**n):
    builds = []
    num_builds = 0
    for j in range(n):
        if ((i>>j)&1):
            builds += [j]
            num_builds += 1
    
    if num_builds==k:
        current_h = 0
        money = 0
        for b in builds:
            if b>0:
                current_h = max(max(H[:b]), current_h)
            if H[b]>current_h:
                current_h = H[b]
            elif H[b]<=current_h:
                d_h = current_h - H[b] + 1
                current_h += 1
                money += d_h
            #print(current_h, H[b], d_h)
        if money<min_money:
            min_money = money
            
print(min_money)

Measured memory_bytes: 3316
def gcd(a, b):
    if (b == 0):
        return a
    return gcd(b,a%b)
n = int(input())
ans=0
for i in range(n):
    for j in range(n):
        for k in range(n):
            ans += gcd(gcd(i+1, j+1), k+1)
print(ans)

Measured memory_bytes: 77868
#include<stdio.h>
int main()
{
	int sum,c,n;
	scanf("%d",&n);
	sum=0;c=n;
	while(n)
	{
		sum=sum+n%10;
		n=n/10;
	}
	if(c%sum==0) printf("Yes");
	else printf("No");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long  j,b,w=0,n,i,c=0;
   string s;
   cin>>s;
for(i=0;i<s.size();i++)
{
  if(s[i]=='A')
  {
    c=i;
    break;
  }
}
for(j=s.size()-1;j>=0;j--)
{
  if(s[j]=='Z')
  {
    w=j;
    break;
  }
}
cout<<w-c+1<<endl;
return 0;
}


Measured memory_bytes: 3696
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String s;
		while(null != (s=in.readLine())){
			System.out.println(getClass(Double.parseDouble(s)));
		}
	}

	private static String getClass(double weight){
		return  (weight<=48.00)?"light fly":
				(weight<=51.00)?"fly":
				(weight<=54.00)?"bantam":
				(weight<=57.00)?"feather":
				(weight<=60.00)?"light":
				(weight<=64.00)?"light welter":
				(weight<=69.00)?"welter":
				(weight<=75.00)?"light middle":
				(weight<=81.00)?"middle":
				(weight<=91.00)?"light heavy":
								"heavy";
	}
}

Measured memory_bytes: 16900
#include<bits/stdc++.h>
using namespace std;
#define min(a,b) (a)<(b)?a:b

/*int minm(int H[], int pos, int N)
{
  if(pos==N-1)
  {
    return Min[pos]=0;
  }
  if(Min[pos]!=-1)
  {
    return Min[pos];
  }
  if(pos==N-2)
  {
    return Min[pos]=( diff(H[pos],H[N-1]) );
  }
    return Min[pos]=min( ( diff(H[pos],H[pos+1])+minm(H,pos+1,N) ),  ( diff(H[pos],H[pos+2])+minm(H,pos+2,N) ) );         
}*/
int main()
{
  
  /*for(int i=0;i<100004;i++)
  {
    Min[i]=-1;
  }*/
  
    int N;
  cin>>N;
  int H[N];
  int Min[N];
  for(int i=0;i<N;i++)
  {
    cin>>H[i];
    Min[i]=0;
  }
  
  //int ans=minm(H,0,N);
  for(int i=N-1;i>=0;--i)
{
	if(i==N-1)
		Min[i]=0;
	else if(i==N-2)
		Min[i]=abs(H[i]-H[N-1]);
	else
		Min[i]=min( (abs(H[i]-H[i+1])+Min[i+1]) , (abs(H[i]-H[i+2])+Min[i+2]) );
}
  cout<<Min[0];
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef pair<int,int> pi;

int n;
pi a[100005];

int lx[400005], ly[400005];

int solve(){
    memset(lx,0x3f,sizeof(lx));
    memset(ly,0x3f,sizeof(ly));
    int maxv1 = 0, maxv2 = 0;
    for (int i=0; i<n; i++) {
        maxv1 = max(maxv1,a[i].first);
        maxv2 = max(maxv2,a[i].second);
    }
    for (int i=0; i<n; i++) {
        lx[a[i].first] = min(lx[a[i].first],a[i].second);
        ly[a[i].second] = min(ly[a[i].second],a[i].first);
    }
    for (int i=400000; i>=0; i--) {
        lx[i] = min(lx[i],lx[i+1]);
        ly[i] = min(ly[i],ly[i+1]);
    }
    int s = 0, e = 400000;
    while (s != e) {
        int m = (s+e)/2;
        int xl = 1e9, yl = 1e9, xh = -1e9, yh = -1e9;
        for (int j=0; j<n; j++) {
            if(a[j].first > m || a[j].second > m){
                xl = min(xl,a[j].first);
                xh = max(xh,a[j].first);
                yl = min(yl,a[j].second);
                yh = max(yh,a[j].second);
            }
        }
        if(yh - yl <= m && xh - xl <= m) e = m;
        else s = m+1;
    }
    return s;
}

int main(){
    scanf("%d",&n);
    int minv1 = 1e9, minv2 = 1e9, maxv1 = 0, maxv2 = 0;
    for (int i=0; i<n; i++) {
        int x,y;
        scanf("%d %d",&x,&y);
        a[i] = pi(x+y,x-y);
        maxv1 = max(maxv1,x+y);
        maxv2 = max(maxv2,x-y);
        minv1 = min(minv1,x+y);
        minv2 = min(minv2,x-y);
    }
    maxv1 -= minv1;
    maxv2 -= minv2;
    for (int i=0; i<n; i++) {
        a[i].first -= minv1;
        a[i].second -= minv2;
    }
    int ret = solve();
    for (int i=0; i<n; i++) {
        a[i].first = maxv1 - a[i].first;
    }
    ret = min(ret,solve());
    printf("%d\n",ret);
}

Measured memory_bytes: 4940
#pragma region template
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a) \
    REP(i, (a).size()) { cout << (a[i]) << (i == (a).size() - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
    ll X;
    cin >> X;
    ll ans = 1000 * (X / 500) + 5 * ((X % 500) / 5);
    OUT(ans);
}
#pragma endregion template

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

int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    if(n%2 == 1){
        cout << "No" << endl;
        return 0;
    }
    n /= 2;
    for(int i=0;i<n;++i){
        if(s[i] != s[n+i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
s=list(input())
rc=0
lc=0
v=[0]*len(s)
for i in range(len(s)-1):
    if s[i]=='R' and s[i+1]=='L':
        rc+=1
        v[i]+=-(-rc//2)
        v[i+1]+=rc//2
        j=i
        rc=0
    elif s[i]=='R' and s[i+1]=='R':
        rc+=1
    elif s[i]=='L' and s[i+1]=='R':
        lc+=1
        v[j]+=lc//2
        v[j+1]+=-(-lc//2)
        lc=0
    else:
        lc+=1
lc+=1
v[j]+=lc//2
v[j+1]+=-(-lc//2)
ans =' '
for x in v:
    ans+=str(x)
    ans+=' '
print(ans)

Measured memory_bytes: 5292
// #include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0; i<n; i++)

int main() {
    int x[5];
    rep(i, 5) {
        cin >> x[i];
        if (x[i] == 0) cout << i+1 << endl;
    }

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF (1LL<<25)     //33554432
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

vector<string> split(const string &str, char sep)
{
  vector<string> v;
  auto first = str.begin();
  while( first != str.end() ) {
    auto last = first;
    while( last != str.end() && *last != sep ) ++last;
    v.push_back(std::string(first, last));
    if( last != str.end() ) ++last;
    first = last;
  }
  return v;
}

signed main(void)
{
  string s;

  int ii = 0, d[105][105];
  REP(i, 105) REP(j, 105) d[i][j] = -1;
  while(cin >> s) {
    vector<string> v = split(s, ',');
    REP(i, v.size()) {
      d[ii][i] = stoi(v[i]);
    }
    ii++;
  }
  ii--;
  int num = (ii+1)/2;
  /*REP(i, ii+1) {
    REP(j, num+1) {
      cout << d[i][j] << " ";
    }
    cout << endl;
  }*/

  int dp[105][105];
  REP(i, 105) REP(j, 105) dp[i][j] = -1;
  dp[0][0] = d[0][0];

  FOR(i, 1, num+1) {
    REP(j, i+1) {
      //cout << j << " ";
      if(j > 0) {
        dp[i][j] = max(dp[i][j], d[i][j] + max(dp[i-1][j-1], dp[i-1][j]));
      }
      else {
        dp[i][j] = max(dp[i][j], d[i][j] + dp[i-1][j]);
      }
      //cout << dp[i][j] << " ";
    }
    //cout << endl;
  }
  FOR(i, num+1, ii+1) {
    REP(j, 2*num-i+1) {
      //cout << j << " ";
      dp[i][j] = max(dp[i][j], d[i][j] + max(dp[i-1][j], dp[i-1][j+1]));
      //cout << dp[i][j] << " ";
    }
    //cout << endl;
  }

  cout << dp[ii][0] << endl;

  return 0;
}

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

int main() {
	char s[5];  bool f[3] = { false };
	for (int i = 0; i < 3; i++) {
		cin >> s[i];
		if (s[i] == 'a') f[0] = true;
		if (s[i] == 'b') f[1] = true;
		if (s[i] == 'c') f[2] = true;
	}
	if (f[0] == true && f[1] == true && f[2] == true) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
// Problem : C - Make a Rectangle
// Contest : AtCoder - AtCoder Beginner Contest 071
// URL : https://atcoder.jp/contests/abc071/tasks/arc081_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
map<int,int,greater<int>> mp;
int n;cin>>n;
for(int i=0;i<n;i++)
{
	int x;cin>>x;
	mp[x]++;
}
int s1=-1,s2=-1;
for(pii p:mp)
{
	int x=p.se;
	if(s1==-1 and x>=2)
	s1=p.f,x-=2;
	if(s2==-1 and x>=2)
	s2=p.f;
}
if(s1==-1 or s2==-1)
cout<<0;
else
cout<<s1*s2;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 9836
b=[]
n=int(input())
a=list(map(int,input().split()))
for i in a:
  if i %2==0:
    b.append(i)
cnt=0
for i in b:
  if i%3==0 or i%5==0:
    cnt+=1
if cnt==len(b):
  print("APPROVED")
else:
  print("DENIED")


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;


int comb(int n, int r){
    int num = 1;
    FOR(i, 1, r){
        num = num * (n - i + 1)/i;
    }

    return num; 
}

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

    int ans = comb(N, 2) + comb(M, 2);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3508
# Problem C - Same Integers

# input
A, B, C = map(int, input().split())

# initialization
num_count = 0
not_finished = True
ans_list = [A, B, C]

# count
while not_finished:
    if ans_list[0]==ans_list[1] and ans_list[1]==ans_list[2]:
        not_finished=False
        break
    ans_list = sorted(ans_list)
    if len(set(ans_list))==3:
        ans_list[0] += 1
        ans_list[1] += 1
        num_count += 1
    elif ans_list[1]==ans_list[2]:
        ans_list[0] += 2
        num_count += 1
    elif ans_list[0]==ans_list[1]:
        ans_list[0] += 1
        ans_list[1] += 1
        num_count += 1

# output
print(num_count)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <numeric>
#include <utility>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <stack>
#include <functional>
#include <ctime>
#include <queue>
#include <string>
#include <map>
#include <sstream>
#define MAX_U   10
#define MIN_U   0
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define form(i,a,b) for(int i=(a);i<(b);i++)
#define sz(x) ((int)(x).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<char> vc;
typedef vector<string> vs;
typedef queue<int> qi;
const int INF=numeric_limits<int>::infinity();
void printa(){cout<<"\n";}
template<class T, class... A>void printa(const T&first,const A&... rest){cout<<first;printa(rest...);}
template<class... A>void printa(const A&... rest){printa(rest...);}
void prints(){cout<<" ";}
template<class T, class... A>void prints(const T&first,const A&... rest){cout<<first;prints(rest...);}
template<class... A>void prints(const A&... rest){prints(rest...);}
/*int factorial(int x){int f=1;for(int i=1;i<x+1;i++)f=f*i;return f;}
int sigma(int x){int s;for(int i=1;i<x+1;i++)s=s+i;return s;}
int middle(int x){if(x%2==0)return x/2;else return x/2+1;}
double heron(int a,int b,int c){double s;s=(a+b+c)/2;return sqrt(s*(s-a)*(s-b)*(s-c));}
double trapezium(int a,int b,int h){return (a+b)*h/2;}
double triangle(int a,int h){return a*h/2;}
void sorm(vector<int> vec){sort(vec.begin(),vec.end());}
void sorg(vector<int> vec){sort(vec.begin(),vec.end(),greater<int>());}
int cmp( const void *p, const void *q ) {if( ＊(double＊)p > ＊(double＊)q ) return 1;if( ＊(double＊)p < ＊(double＊)q ) return -1;return 0;}
*/
int main(void){
   cin.tie(0);
   ios::sync_with_stdio(false);
   //unsigned long a,b,c,d,e;
   int ad,bd;
   //unsigned long f=0;
   //string st,tt,nt;
   //vi ad,bd,cd,dd;
   //vi A,W,B;
   //int X=0;
   //vs as,bs,cs,ds;
   //a=0;
   cin>>ad>>bd;
   printa(ad-bd+1);
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef unsigned long long ll;
const int maxn = 100005;

int a[maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n;
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  if(n==2){
    cout<<a[1]-a[0]<<endl;
    cout<<a[1]<<" "<<a[0]<<endl;
    return 0;
  }
  if(a[0]>=0){
    int ret = 0;
    for(int i=1;i<n;i++)ret+=a[i];
    ret-=a[0];
    cout<<ret<<endl;
    int cur = a[0];
    for(int i=1;i<n-1;i++){
      cout<<cur<<" "<<a[i]<<endl;
      cur-=a[i];
    }
    cout<<a[n-1]<<" "<<cur<<endl;
    return 0;
  }
  if(a[n-1]<0||a[n-2]<0){
    int ret = 0;
    for(int i=0;i<n-1;i++)ret-=a[i];
    ret+=a[n-1];
    cout<<ret<<endl;
    int cur = a[n-1];
    for(int i=0;i<n-1;i++){
      cout<<cur<<" "<<a[i]<<endl;
      cur-=a[i];
    }
    return 0;
  }
  int ret = 0;
  int pos = -1;
  for(int i=n-1;i>=0;i--){
    if(a[i]>=0){
      ret+=a[i];
      pos =i;
    }
    else ret-=a[i];
  }
  cout<<ret<<endl;
  int cur = a[0];
  for(int i=pos;i<n-1;i++){
    cout<<cur<<" "<<a[i]<<endl;
    cur-=a[i];
  }
  cout<<a[n-1]<<" "<<cur<<endl;
  cur = a[n-1]-cur;
  for(int i=1;i<pos;i++){
    cout<<cur<<" "<<a[i]<<endl;
    cur-=a[i];
  }
  return 0;
}

Measured memory_bytes: 2304
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1e5+4;
const int MOD=998244353;
int n,d[N];
int cnt[N],tot;
int fpow(int a,int b,int m) {
	int ret=1;
	while (b) {
		if (b&1) ret=1ll*ret*a%m;
		b>>=1,a=1ll*a*a%m;
	}
	return ret;
}
int main() {
	scanf("%d",&n);
	for (register int i=1;i<=n;++i) {
		scanf("%d",&d[i]);
		tot=max(tot,d[i]);
		++cnt[d[i]];
	}
	if (cnt[0]^1||d[1]^0) {
		puts("0");
		return 0;
	}
	int ans=1;
	for (int i=1;i<=tot;++i) {
		int x=cnt[i-1],y=cnt[i];
		ans=1ll*ans*fpow(x,y,MOD)%MOD;
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

int N,K;
vector<int> G[100001];
int ans = 0;
bool used[100001];

int dfs(int v,int prev) {
  int depth = 0;

  for(int i = 0; i < G[v].size(); i++) {
    int u = G[v][i];
    if(u != prev) {
      depth = max(depth,dfs(u,v));
    }
  }

  if(depth == K - 1 && prev != 0) {
    ans++;
    return 0;
  }
  return depth + 1;

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

  for(int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if(i > 0) {
    a--;
    G[a].push_back(i);
    }
    else {
      if(i != a-1) ans++;
    }
  }

  dfs(0,0);

  cout << ans <<endl;
}


Measured memory_bytes: 11904
#include <vector>
#include <iostream>
#include <limits>
#include <queue>
#include <utility>

using namespace std;


struct edge {
    int src;
    int dst;
    int weight;

    edge(int src, int dst, int w) : src(src), dst(dst), weight(w) {}
};

bool operator < (const edge &a, const edge &b) {
  return a.weight > b.weight;
}


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

    vector<vector<edge>> G(n);
    for (int i = 0; i < n; ++i) {
        int u, k;
        cin >> u >> k;

        for (int j = 0; j < k; ++j) {
            int v, c;
            cin >> v >> c;
            G[u].emplace_back(u, v, c);
        }
    }

    // Dijkstra's algorithm (with pritority queue)
    vector<int> d(n, numeric_limits<int>::max());
    vector<bool> visited(n, false);
    priority_queue<edge> Q;

    Q.emplace(-1, 0, 0);
    d[0] = 0;
    while (!Q.empty()) {
        auto e = Q.top(); Q.pop();
        visited[e.dst] = true;
        if (d[e.dst] < e.weight)
            continue;

        for (auto& x : G[e.dst]) {
            if (visited[x.dst])
                continue;
            int w = x.weight + d[e.dst];
            if (w < d[x.dst]) {
                d[x.dst] = w;
                Q.emplace(e.dst, x.dst, w);
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        cout << i << " " << d[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 9852
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll p; 
int main() {
	cin>>p;
	ll x,y;
	for(x=sqrt(p);x>=1;x--) {
		if(p%x==0) break;
	}
	y=p/x;
	cout<<(x-1)+(y-1)<<endl;
    return 0;
}


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

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

const int INF = 1000000007;
const ll INFLL = 1000000000000000007;

#define st first
#define nd second
#define pb push_back
#define _boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

// ***************************** CODE ***************************** //

const int MAX = 1 << 21;
const int mod = 1e9 + 7;

bool can[22][22];
int dp[MAX + 7];

int sum(int x)
{
    int shift = 0;
    int res = 0;
    while((1<<shift) <= x)
    {
        if(((1 << shift) & x))
            res++;
        shift++;
    }
    return res;
}

void add(int& a, int b)
{
    a += b;
    if(a >= mod)
        a -= mod;
}

int main() {
    _boost;

    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            cin >> can[i][j];

    dp[0] = 1;

    for(int mask = 0; mask < (1 << n)-1; mask++)
    {
        for(int w = 0; w < n; w++)
        {
            int m = sum(mask);
            if(can[m][w] && !(mask & (1 << w)))
            {
                int mask2 = mask ^ (1 << w);
                add(dp[mask2], dp[mask]);
            }
        }
    }

    cout << dp[(1<<n)-1];

    return 0;
}


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

int main ()
{
    int n;
    while (cin >> n, n) {
        int res = 0;
        for (int i = 1; i * i <= n; i++) {
            int s1 = i * i;
            if (s1 == n) { res++; break;}
            for (int j = i; j * j + s1 <= n; j++) {
                int s2 = j * j;
                if (s1 + s2 == n) { res++; break;}
                for (int k = j; s1 + s2 + k * k <= n; k++) {
                    int s3 = k * k;
                    if (s1 + s2 + s3 == n) { res++; break;}
                    for (int l = k; s1 + s2 + s3 + l * l <= n; l++) {
                        int s4 = l * l;
                        if (s1 + s2 + s3 + s4 == n) { res++; break;}
                    }
                }
            }
        }

        cout << res << endl;
    }


    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
int gcd(int x,int y){
    if(y==0)return x;

    return gcd(y,x%y);
}
int lcm(int x,int y){
    return x*y/gcd(x,y);
}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){

    int a,b;
    cin>>a>>b;

    if(a>0){
        cout<<"Positive"<<endl;
    }else{
        if(b>=0){
            cout<<"Zero"<<endl;
        }else{
            //a,bとも負
            if(abs(b-(a-1))%2==1){
                cout<<"Negative"<<endl;
            }else{
                cout<<"Positive"<<endl;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
from collections import Counter, deque

N = int(input())

uvw = [list(map(int, input().split())) for _ in range(N-1)]

udict ={}
uvdict = {}
lst = []
ans = [-1]*(N+1)
for u, v, w in uvw:
    if u in udict:udict[u].append(v)
    else:udict[u] =[v]
    if v in udict:udict[v].append(u)
    else:udict[v] =[u]
    lst.append(u)
    lst.append(v)
    uvdict[(u,v)] = w
cnt = Counter(lst)

cnt_max = cnt.most_common()[0][0]
nxt = deque()
nxt.append(cnt_max)
passed = [0]*(N+1)

d = [0]*(N+1)

while nxt!=deque([]):
    l1 = nxt.popleft()
    for l2 in udict[l1]:
        if passed[l2]==1:continue
        d[l2] = d[l1] + uvdict[min(l1, l2), max(l1, l2)]
        
        nxt.append(l2)
    passed[l1]=1
for i in d[1:]:
    print(i%2)


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

#define MAXINF 1000000005
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define repc(it, x) for(auto it = (x).begin(); it != (x).end(); ++it)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rrepc(it, x) for(auto it = (x).rbegin(); it != (x).rend(); ++it)
#define all(x) (x).begin(), (x).end()
#define P pair<int, int>

const int MX = 2005;
bool d[3][3][MX];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<string> s(3);
    rep(i, 3) cin >> s[i];
    int ans = MX*3;
    sort(all(s));
    do {
        rep(i,3)rep(j,3)rep(k,s[i].size()) {
            if(i > j) continue;
            bool isOk = true;
            for(int ni = k; ni < s[i].size(); ni++) {
                int nj = ni-k;
                if(nj >= s[j].size()) break;
                if(s[i][ni]=='?' || s[j][nj]=='?') continue;
                if(s[i][ni]!=s[j][nj]) isOk = false;
            }
            d[i][j][k] = isOk;
        }
        auto f = [&](int i, int j, int k) {
            if(k >= s[i].size()) return true;
            return d[i][j][k];
        };
        rep(x, MX) rep(y, MX) {
            if(!f(0,1,x)) continue;
            if(!f(1,2,y)) continue;
            if(!f(0,2,x+y)) continue;
            int now = 0;
            now = max<int>(now, s[0].size());
            now = max<int>(now, x+s[1].size());
            now = max<int>(now, x+y+s[2].size());
            ans = min(ans, now);
        }
    } while (next_permutation(s.begin(), s.end()));
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main(void) {
  int n;
  cin >> n;
  vector <tuple<int, int, bool>> red, blue;
  for(int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    red.push_back(tuple<int, int, bool> (y, x, false));
  }
  for(int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    blue.push_back(tuple<int, int, bool> (x, y, false));
  }
  
  sort(red.rbegin(), red.rend());
  sort(blue.begin(), blue.end());
  
  int ans = 0;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++) {
      if(   get<1>(red[j]) < get<0>(blue[i])
	 && get<0>(red[j]) < get<1>(blue[i])
	    && !get<2>(red[j])) {
	red[j] = make_tuple(get<0>(red[j]), get<1>(red[j]), true);
	ans++;
	break;
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 384
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,k,c = map(int,input().split())
s = input()

if n == 1:
  print(1)
  exit()

dp1 = [0] * (n+1)
dp2 = [0] * (n+1)
# dp[i] = (選択したなかで一番左側のindex,選択した個数)
now = 10 ** 7;count = 0
for i in range(n-1,-1,-1):
  if s[i] == "o" and i + c < now:
    count += 1; now = i
    dp1[i] = (i,count)
  elif i == n-1:dp1[i] = (inf,0)
  else:
    dp1[i] = dp1[i+1]

now = - 10 ** 7;count = 0
for i in range(n):
  if s[i] == "o" and now + c < i:
    count += 1; now = i
    dp2[i] = (i,count)
  elif i == 0:dp2[i] = (-inf,0)
  else:
    dp2[i] = dp2[i-1]

# dp1:右から　　dp2:左から
if dp1[1][1] < k:print(1)
for i in range(1,n-1):
  index0,count0 = dp1[i+1]
  if index0 - c >= 0:
    count0 += dp2[min(index0-c,i-1)][1]
  if count0 < k:
    print(i+1)
if dp2[n-2][1] < k:print(n)
# print(dp2)


Measured memory_bytes: 68524
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { -1, 0, 0, 1 };
const ll dy[4] = { 0, -1, 1, 0 };
const ll INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
struct Accelerate_Cin {
	Accelerate_Cin() {
		cin.tie(0);
		ios::sync_with_stdio(0);
		cout << fixed << setprecision(20);
	};
};
///////////////////////////////////////


int main() {
	int N, M; cin >> N >> M;
	int a[1010], b[1010];
	int c[1010][13];
	int dp[1 << 12];
	REP(i,(1<<12))dp[i] = INF;
	dp[0] = 0;
	for (int i = 0; i < M; ++i) {
		cin >> a[i] >> b[i];
		int x = 0;
		for (int j = 0; j < b[i]; ++j) {
			cin >> c[i][j];
			x += (1 << (c[i][j]-1));
		}
		for (int bit = 0; bit < (1 << N); ++bit) {
			dp[bit|x] = min(dp[bit|x], dp[bit] + a[i]);
		}
	}
	if (dp[(1 << N) - 1] == INF)cout << -1 << endl;
	else cout << dp[(1 << N) - 1] << endl;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
const ll mod = 1e9+7;
#define INFL 0x3f3f3f3f3f3f3f3fLL
 
//-------------------------<MATH>-------------------------------------------------------//
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll base,ll pow){ll ans = 1;
   while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans%mod;}
   base *= base;base%=mod;pow/=2;}return ans;}
ll inv(ll x){return expo(x,mod-2);}
ll mult_mod(ll a , ll b){a = a%mod; b = b%mod;
ll c = (a * b)%mod;
//cout << a << " " << b << endl;
return c;}
ll add_mod(ll a , ll b){a = (a + mod)%mod;b = (b + mod)%mod;ll c = (a + b)%mod;return c;}
ll fac[(int)(5e5 + 5)] , inv_fac[(int)(5e5 + 5)];
void precomp_factorial(int M){fac[0] = 1;for(int i = 1 ; i <= M ; i++) fac[i] = mult_mod(i , fac[i - 1]);
    inv_fac[M] = inv(fac[M]);for(int i = M - 1 ; i >= 0 ; i--) inv_fac[i] = mult_mod(i + 1 , inv_fac[i + 1]);}
ll nCk(ll n , ll k){ll ans = fac[n];ans = mult_mod(ans , inv_fac[n - k]);ans = mult_mod(ans , inv_fac[k]);return ans;}
int lo[(int)(1e3 + 6)];
void sieve(int M){for(int i = 2 ; i < M ; i++){ if(lo[i]) continue; for(int j = i ; j < M ; j += i)lo[j] = i;}}
int max_expo_prime_n_fac(ll N , int prime){int ress = 0;while(N){ress += (N/prime);N /= prime;}return ress;}
//-------------------------</MATH>-------------------------------------------------------//
 
//-------------------------<STRING>-------------------------------------------------------//
string get_prefix(string x , int MAX){return x.substr(0 , min((int)x.size() , MAX));}
string get_suffix(string x,int MAX){int dn=1;for(int i=x.size()-1;i>=0;i--){if(dn==MAX)return x.substr(i);dn++;}return x;}
string convert_to_binary(int x,int len) {string ans=""; while(x){if(x&1){ans='1'+ans;}
    else{ans ='0'+ans;}x/=2;}int k = ans.size();while(k < len){ans = '0' + ans;k++;}return ans;}
//-------------------------</STRING>-------------------------------------------------------//
 
ull llrand() {ull r = 0;for(int i = 0; i < 5; ++i){r = (r << 15)|(rand() & 0x7FFF);}return r & 0xFFFFFFFFFFFFFFFFULL;}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};
 
const int SZ = 2345678;
 
 
 int main(){
   int n, k;
   cin >> n >> k;
   vector <int> vec(n);
   for(int i = 0; i < n; i++) cin >> vec[i];
   for(int i = k; i < n; i++){
       if(vec[i] > vec[i-k]) cout << "Yes" << endl;
       else cout << "No" << endl;
   }

 }


Measured memory_bytes: 4052
#include <iostream>
#include <stdio.h>
#include <string>

#define MAX_N 50
#define MAX_M 50

using namespace std;

string A[MAX_N]{};
string B[MAX_M]{};

int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  for (int i = 0; i < M; ++i) {
    cin >> B[i];
  }

  for (int i = 0; i <= N - M; ++i) {
    for (int j = 0; j <= N - M; ++j) {
      bool found = true;
      for (int _i = 0; _i < M; ++_i) {
        for (int _j = 0; _j < M; ++_j) {
          if (A[i + _i][j + _j] != B[_i][_j]) {
            found = false;
            break;
          }
        }
        if (!found) {
          break;
        }
      }
      if (found) {
        printf("Yes\n");
        return 0;
      }
    }
  }
  printf("No\n");
}

Measured memory_bytes: 3612
A,B,M = map(int, input().split())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
L = [[int(l) for l in input().split()] for _ in range(M)]

ans = 10**15
for l in L:
    ans = min(ans, A[l[0]-1]+B[l[1]-1]-l[2])
ans = min(ans, min(A)+min(B))
print(ans)

Measured memory_bytes: 32224
N = input()
import itertools
for p in itertools.product([0, 1], repeat=3):
  res = int(N[0])
  for i in range(3):
    if p[i]==0:
      res += int(N[i+1])
    else:
      res -= int(N[i+1])
  if res==7:
    bit = p
    break

oper = ['+','-']
ans = N[0]
for i in range(3):
  ans += oper[bit[i]]
  ans += N[i+1]
ans += '=7'
print(ans)

Measured memory_bytes: 38384
from math import atan2, degrees
from itertools import permutations

N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
px = py = 0
ans = float("inf")
for t in permutations(XY):
    a = 0
    deg = 0
    for x, y in t + ([0, 0],):
        d = degrees(atan2(y-py, x-px))
        delta = deg - d
        if delta < 0: delta += 360
        if delta > 180: delta = 360 - delta
        a += delta

        px, py = x, y
        deg = d
    ans = min(a, ans)
print(ans)



Measured memory_bytes: 5792
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = ReadLine();

            int ans = 1000;

            for(int i = 0; i < a.Length - 2; i++)
            {
                string s = a[i].ToString();
                s += a[i + 1]; s += a[i + 2];
                int s_int = int.Parse(s);

                int abs = Math.Abs(753 - s_int);

                ans = Math.Min(abs, ans);
            }
            WriteLine(ans);
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}



Measured memory_bytes: 11220