akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

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

class BHomework {
 public:
  void solve(std::istream &in, std::ostream &out) {
      int n, m, x;
      in >> n >> m;

      forn(i, m) {
          in >> x;
          n -= x;
      }
      out << max(-1, n) << '\n';
  }
};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    BHomework solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    cout << setprecision(16);
    int n,k; cin >> n >> k;
    rep(i,n){
        int x; cin>>x;
    }
    int ans = (n-1)/(k-1);
    if((n-1) % (k-1) != 0) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MOD 1000000007

int Pow(int a, int b){
	int tmp = 1;
	for(; b; b >>= 1, a = 1ll * a * a % MOD)
		if(b & 1) tmp = 1ll * tmp * a % MOD;
	return tmp;
}

int B, W;
int f[211111];
int g[211111];

int pw2[211111];
int s[211111];
int inv[211111];

int C(int a, int b){
	return 1ll * s[a] * inv[b] % MOD * inv[a - b] % MOD;
}

int main(){
	scanf("%d %d", &B, &W);
	int n = B + W;
	pw2[1] = Pow(2, MOD - 2);
	for(int i = 2; i <= n; i++) pw2[i] = 1ll * pw2[i - 1] * pw2[1] % MOD;
	s[0] = 1;
	for(int i = 1; i <= n; i++) s[i] = 1ll * s[i - 1] * i % MOD;
	inv[n] = Pow(s[n], MOD - 2);
	for(int i = n - 1; i >= 0; i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % MOD;
	for(int i = 1; i <= n; i++){
		if(i <= W) f[i] = 0;
		else f[i] = (f[i - 1] + 1ll * pw2[i - 1] * C(i - 2, W - 1)) % MOD;
		if(i <= B) g[i] = 0;
		else g[i] = (g[i - 1] + 1ll * pw2[i - 1] * C(i - 2, B - 1)) % MOD;
		int ans = (f[i] + 1ll * pw2[1] * ((1 - f[i] - g[i]) % MOD + MOD)) % MOD;
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
const ll oo = 0x3f3f3f3f3f3f3f3f;

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  ll n, w;
  cin >> n >> w;
  
  ll N = n * 5000 + 100;
  vector<ll> dp(N, oo);
  dp[0] = 0;
  
  for(ll i = 0, a, b; i < n; ++i)
  {
  	cin >> a >> b;
    for(int j = N; j >= 0; --j)
      if(dp[j] != oo && j + b < N)
        dp[j + b] = min(dp[j + b], dp[j] + a);
  }
  
  for(ll i = N - 1; i >= 0; --i)
  {
  	if(dp[i] <= w)
    {
      cout << i << endl;
      return 0;
    }
  }
  
}


Measured memory_bytes: 4224
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;

int main(){
    int n,m;cin>>n>>m;
    vin h(n);
    rep(i,n)cin>>h[i];
    vin a(m),b(m);
    rep(i,m)cin>>a[i]>>b[i];
    vbo yes(n,true);
    rep(i,m){
        if(h[a[i]-1]<h[b[i]-1])yes[a[i]-1]=false;
        else if(h[a[i]-1]>h[b[i]-1])yes[b[i]-1]=false;
        else{
            yes[a[i]-1]=false;
            yes[b[i]-1]=false;
        }
    }
    int ans=0;
    rep(i,n){
        if(yes[i])ans++;
    }
    cout<<ans<<endl;
}

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

typedef long long llong;

void solve() {
  string s; cin >> s;

  llong zerofirst = 0, onefirst = 0;

  for(int i = 0; i < s.size(); ++i) {
    if((i+1)&1) { // odd
      zerofirst += (s[i]=='1') ? 1 : 0;
      onefirst  += (s[i]=='0') ? 1 : 0;
    } else { // even
      onefirst += (s[i]=='1') ? 1 : 0;
      zerofirst  += (s[i]=='0') ? 1 : 0;
    }
  }
  
  cout << min(zerofirst, onefirst);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  solve();
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define trace1(a) cout << a << 'n';
#define trace2(a, b) cout << a << ' ' << b << 'n';
#define trace3(a, b, c) cout << a << ' ' << b << ' ' << c << 'n';
#define trace4(a, b, c, d) cout << a << ' ' << b << ' ' << c << ' ' << d << 'n';
#define trace5(a, b, c, d, e) cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << 'n';
#define trace6(a, b, c, d, e, f) cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << ' ' << f << 'n';
#define range(n) for(int i = 0; i < n; i++)
#define printArr(harry, tam) range(tam) cout << harry[i] << " n"[i == tam -1];
#define maxn -2000000 //negative value to break code and force you to put right constraint
#define mod 1000000007
#define md(x) (x) % mod;
#define sc scanf
#define pr printf
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ps push
#define prt(x) cout << (#x) << " is " << (x) << endl
#define EPS 1e-9
#define INF 1000000000
#define INFd 1e9
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<double> vd;

int main(){
  ll n;
  cin>>n;
  vector<ll> a(n,INF),b(n);
  for(ll i=0;i<n-1;i++)
    cin>>b[i];
  ll s=0;
  for(ll i=0;i<n-1;i++)
  {
      a[i]=min(b[i],a[i]);
      a[i+1]=min(a[i+1],b[i]);
      s+=a[i];

  }
  s+=a[n-1];
  cout<<s;
}


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

int main(){
  int n,k;
  cin>>n>>k;
  vector<int>dp(n,INT_MAX);
  dp[0] = 0;
  vector<int>a(n,0);
  for(int i = 0; i < n; i ++)
    cin>>a[i];
  for(int i = 1; i < n; i ++)
    for(int j = (i-k)>=0?i-k:0 ; j < i; j ++)
      dp[i] = min(dp[i] , abs(a[i] - a[j]) + dp[j]);
  cout<<dp[n-1];
  return 0;
}

Measured memory_bytes: 1024
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

X=[0]*N
minus=0
ans=0
for i in range(N):
    X[i]=A[i]-B[i]
    if X[i]<0:
        ans+=1
        minus+= X[i]

X.sort(reverse=True)
if sum(X)<0:
    ans=-1
else:
    i=0
    while minus<0:
        minus+=X[i]
        i+=1
    ans+=i

print(ans)

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define allof(a) a.begin(),a.end()
#define size_of(a) (int)a.size()

typedef pair< int, int > pii;

struct Edge {
	int v, t;
	Edge(int _v, int _t) : v(_v), t(_t) {}
};

vector< vector< Edge > > edges;
bool use[22];

int dfs(int v, int p, int tt) {
	int res = tt;
	
	int e_size = size_of(edges[v]);
	for_(i,0,e_size) {
		Edge e = edges[v][i];
		if (e.v == p || !use[e.v]) continue;
		res = max(res, dfs(e.v, v, tt + e.t));
	}
	
	return res;
}

int main() {
	int N;
	
	while (cin >> N, N) {
		edges.assign(N, vector< Edge >());
		
		for_(i,0,N-1) {
			int a, b, t; cin >> a >> b >> t;
			--a; --b;
			edges[a].push_back(Edge(b, t));
			edges[b].push_back(Edge(a, t));
		}
		
		memset(use, 0, sizeof(use));
		for_(i,0,N) if (size_of(edges[i]) != 1) use[i] = true;
		use[0] = true;
		
		int mx = dfs(0, -1, 0);
		
		int ans = 0;
		
		for_(i,0,N) {
			if (!use[i]) continue;
			
			int e_size = size_of(edges[i]);
			for_(j,0,e_size) {
				Edge e = edges[i][j];
				if (!use[e.v]) continue;
				ans += e.t;
			}
		}
		
		cout << ans - mx << endl;
	}
	
	return 0;
}

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

#define reps(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) reps(v, 0, n)
#define lep(v, n) reps(v, 1, n + 1)

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }
template<typename T> void show(T& a, char del='\n', char last='\n'){ rep(i, a.size() - 1) cout << a[i] << del; cout << a[a.size() - 1] << last; }

int main()
{
  // 1分で進む角度で考える
  // 長針 1分 => 6度
  // 短針 60分 => 30度 :: 1分 => 0.5度
  rep(i, in()){
    double h, m;
    scanf("%lf:%lf", &h, &m);
    h = h * 30 + m * 0.5;
    m *= 6;
    double deg = abs(h - m);
    if (180 < deg) deg = 360.0 - deg;
    if (0 <= deg && deg < 30){
      puts("alert");
    }
    else if (90 <= deg && deg <= 180){
      puts("safe");
    }
    else {
      puts("warning");
    }
  }
  return 0;
}

Measured memory_bytes: 1196
#include<stdio.h>
#define MAX 36

void BubbleSort(char [], int [], int);
void SelectionSort(char [], int [], int, char [], int []);

int main(){
  int n, i, num1[MAX], num2[MAX];
  char c1[MAX], c2[MAX];

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    scanf(" %c%d", &c1[i], &num1[i]);
    c2[i] = c1[i];
    num2[i] = num1[i];
  }
  BubbleSort(c1, num1, n);
  SelectionSort(c2, num2, n, c1, num1);

  return 0;
}

void BubbleSort(char c[], int num[], int n){
  int i, j, flag = 1, vi;
  char vc;

  for(i = 0; i <= n - 1; i++){
    for(j = n - 1; j >= i + 1; j--){
      if(num[j] < num[j - 1]){
        vc = c[j];
        vi = num[j];
        c[j] = c[j - 1];
        num[j] = num[j - 1];
        c[j - 1] = vc;
        num[j - 1] = vi;
      }
    }
  }

  for(i = 0; i < n; i++){
    printf("%c%d", c[i], num[i]);
    if(i != n - 1)
      printf(" ");
  }
  printf("\nStable\n");
}

void SelectionSort(char c[], int num[], int n, char c1[], int num1[]){
  int i, j, minj, vi, stable = 0;
  char vc;

  for(i = 0; i <= n - 1; i++){
    minj = i;
    for(j = i; j <= n - 1; j++){
      if(num[j] < num[minj]){
        minj = j;
      }
    }
    vc = c[i];
    vi = num[i];
    c[i] = c[minj];
    num[i] =num[minj];
    c[minj] = vc;
    num[minj] = vi;
  }

  for(i = 0; i < n; i++){
    printf("%c%d", c[i], num[i]);
    if(i != n - 1)
      printf(" ");
    if(c[i] != c1[i])
      stable = 1;
  }
  if(stable == 0)
    printf("\nStable\n");
  else
    printf("\nNot stable\n");
}



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


int main() {
  string s;
  cin>>s;
  long long int sum=0;
  for(int i=0;i<s.length();i++)
  {
    sum=sum+s[i]-'0';
  }
  if(sum%9==0)
  printf("Yes\n");
  else
  printf("No");
}

Measured memory_bytes: 3844
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 200005

ll N,K;
ll A[SIZE];

//num以下の数がK以上ならtrue
bool check(ll num){

	ll sum = 0;
	ll left,right,mid,loc;

	for(ll i = 0; i < N; i++){

		if(A[i] < 0){

			left = 0,right = N-1,mid = (left+right)/2;
			loc = -1;

			while(left <= right){

				if(A[i]*A[mid] > num){

					loc = mid;
					left = mid+1;
				}else{

					right = mid-1;
				}
				mid = (left+right)/2;
			}

			sum += N-1-loc;

		}else{

			left = 0,right = N-1,mid = (left+right)/2;
			loc = -1;

			while(left <= right){

				if(A[i]*A[mid] <= num){

					loc = mid;
					left = mid+1;
				}else{

					right = mid-1;
				}
				mid = (left+right)/2;
			}

			sum += loc+1;
		}

		if(A[i]*A[i] <= num){
			sum--;
		}
	}

	sum /= 2;

	return sum >= K;
}

int main(){

	scanf("%lld %lld",&N,&K);

	for(ll i = 0; i < N; i++){

		scanf("%lld",&A[i]);
	}

	sort(A,A+N);

	ll L = -HUGE_NUM,R = HUGE_NUM,mid = (L+R)/2;
	ll ans;

	while(L <= R){

		if(check(mid)){

			ans = mid;
			R = mid-1;

		}else{

			L = mid+1;
		}
		mid = (L+R)/2;
	}

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

	return 0;
}


Measured memory_bytes: 1792
n, m = map(int, input().split())
ac = 0
pena = 0
isac = [0] * n
wa = [0] * n

for i in range(m):
    p, s = input().split()
    p = int(p)
    p -= 1
    # print(p, s)
    if (s == "AC"):
        if (isac[p] != 1):
            ac += 1
            pena += wa[p]
            isac[p] = 1
    else:
        if (isac[p] == 0):
            wa[p] += 1
    # print(ac, pena, isac[p], wa[p])

print(ac, pena)

Measured memory_bytes: 4596
var
i,N,x,T:Longint;
A:Array[0..100000]of Longint;
begin
read(N);
for i:=1 to N do begin read(x);inc(A[x]);end;
if N mod 2=1 then if A[0]=1 then T:=1 else T:=0 else T:=1;
i:=N mod 2+1;
while i<N do begin
if A[i]=2 then T:=T*2 mod 1000000007 else T:=0;
inc(i,2);
end;
writeln(T);
end.


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

int main() {
  string b;
  cin >> b;
  if (b == "A")
    cout << "T" << endl;
  else if (b == "T")
    cout << "A" << endl;
  else if (b == "C")
    cout << "G" << endl;
  else if (b == "G")
    cout << "C" << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	Scanner sc;

	Main() {
		sc = new Scanner(System.in);
	}
	
	void calc() {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = sc.nextInt();
		
		if (a*a*b <= 2*x) {
			System.out.println(Math.atan(2.0*b/a-2.0*x/a/a/a)/Math.PI*180);
		} else {
			System.out.println(Math.atan(1.0*a*b*b/2/x)/Math.PI*180);
		}
	}

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

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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;


int main() {
    int n;
    cin >> n;
    vector<int> v(2 * n);
    rep(i, 2 * n)cin >> v[i];
    sort(v.rbegin(), v.rend());
    int sum = 0;
    rep(i, n) {
        sum += v[i * 2 + 1];
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long lli;
int main()
{
	int a; cin >> a;
	unordered_map<lli, lli> M;
	lli sum = 0;
	for(int i=0; i<a; i++)
	{
		lli tmp; cin >> tmp;
		sum += tmp;
		M[tmp] ++;
	}
	int q; cin >> q;
	for(int i=0; i<q; i++)
	{
		lli x, y; cin >> x >> y;
		sum -= x * M[x];
		sum += y * M[x];
		M[y] += M[x];
		M[x] = 0;
		cout << sum << '\n';
	}
	return 0;
}

Measured memory_bytes: 7032
def counter(s):
    cnt = 0
    flag = 0
    for i in range(1, len(s)):
        if flag == 1:
            flag = 0
        else:
            if s[i] == s[i-1]:
                cnt += 1
                flag = 1
    return cnt * k

s = str(input())
k = int(input())
if len(set(s)) == 1:
    ans = len(s) * k // 2
else:
    if k == 1 or s[0] != s[-1]:
        ans = counter(s)
    else:
        l = 0
        r = 0
        for i in range(len(s)):
            if s[i] == s[0]:
                l += 1
            else:
                break
        for j in range(len(s)-1, 0, -1):
            if s[j] == s[0]:
                r += 1
            else:
                break
        ans = counter(s[l:-r])
        ans += l // 2 + r // 2 + (l + r) // 2 * (k - 1)        
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
  int a, b, c, d; cin >> a >> b >> c >> d;
  if (abs(a - c) <= d) {
    cout << "Yes" << endl;
    return 0;
  }
  if (abs(a - b) <= d && abs(b - c) <= d) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

inc = False
dec = False
val = 0
ans = 1
n = int(input())
a = list(map(int, input().split()))

for i in range(1, n):
    if inc:
        if a[i-1] > a[i]:
            ans += 1
            inc = False
    elif dec:
        if a[i-1] < a[i]:
            ans+=1
            dec =False
    else:
        if a[i-1] < a[i]:
            inc = True
        elif a[i-1] > a[i]:
            dec = True
print(ans)




Measured memory_bytes: 20380
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
#include <sstream>
#include <queue>
using namespace std;
typedef long long ll;

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

  if ((s[0] - '0') + (s[1] - '0') + (s[2] - '0') + (s[3] - '0') == 7) {
    cout << s[0] << '+' << s[1] << '+' << s[2] << '+' << s[3] << '=' << 7 << endl;
    return 0;
  }
  if ((s[0] - '0') - (s[1] - '0') - (s[2] - '0') - (s[3] - '0') == 7) {
    cout << s[0] << '-' << s[1] << '-' << s[2] << '-' << s[3] << '=' << 7 << endl;
    return 0;
  }
  if ((s[0] - '0') + (s[1] - '0') - (s[2] - '0') + (s[3] - '0') == 7) {
    cout << s[0] << '+' << s[1] << '-' << s[2] << '+' << s[3] << '=' << 7 << endl;
    return 0;
  }
  if ((s[0] - '0') + (s[1] - '0') - (s[2] - '0') - (s[3] - '0') == 7) {
    cout << s[0] << '+' << s[1] << '-' << s[2] << '-' << s[3] << '=' << 7 << endl;
    return 0;
  }
  if ((s[0] - '0') - (s[1] - '0') + (s[2] - '0') - (s[3] - '0') == 7) {
    cout << s[0] << '-' << s[1] << '+' << s[2] << '-' << s[3] << '=' << 7 << endl;
    return 0;
  }
  if ((s[0] - '0') - (s[1] - '0') - (s[2] - '0') - (s[3] - '0') == 7) {
    cout << s[0] << '-' << s[1] << '-' << s[2] << '-' << s[3] << '=' << 7 << endl;
    return 0;
  }
  if ((s[0] - '0') + (s[1] - '0') + (s[2] - '0') - (s[3] - '0') == 7) {
    cout << s[0] << '+' << s[1] << '+' << s[2] << '-' << s[3] << '=' << 7 << endl;
    return 0;
  }
  if ((s[0] - '0') - (s[1] - '0') - (s[2] - '0') + (s[3] - '0') == 7) {
    cout << s[0] << '-' << s[1] << '-' << s[2] << '+' << s[3] << '=' << 7 << endl;
    return 0;
  }
  if ((s[0] - '0') - (s[1] - '0') + (s[2] - '0') + (s[3] - '0') == 7) {
    cout << s[0] << '-' << s[1] << '+' << s[2] << '+' << s[3] << '=' << 7 << endl;
    return 0;
  }
}

Measured memory_bytes: 3116
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,m = inpl()
ab = [inpl() for i in range(n)]
cd = [inpl() for i in range(m)]
for i in ab:
    res = 0
    mmm = float('inf')
    for j,k in enumerate(cd):
        tmp = abs(i[0] - k[0]) + abs(i[1] - k[1])
        if tmp < mmm:
            mmm = tmp
            res = j+1
    print(res)



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

int abs(int a){
  if(a >= 0){
    return a;
  }
  return - a;
}
     
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> player(N, vector<int>(2));
  vector<vector<int>> checkpoint(M, vector<int>(2));
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j < 2; j++){
      cin >> player.at(i).at(j);
    }
  }
  
  for(int i = 0; i < M; i++){
    for(int j = 0; j < 2; j++){
      cin >> checkpoint.at(i).at(j);
    }
  }
  
  for(int i = 0; i < N; i++){
    int answer = 1;
    int base = abs(player.at(i).at(0) - checkpoint.at(0).at(0))
        + abs(player.at(i).at(1) - checkpoint.at(0).at(1));
    for(int j = 1; j < M; j++){
      if(base > abs(player.at(i).at(0) - checkpoint.at(j).at(0))
              + abs(player.at(i).at(1) - checkpoint.at(j).at(1))){
        base = abs(player.at(i).at(0) - checkpoint.at(j).at(0))
              + abs(player.at(i).at(1) - checkpoint.at(j).at(1));
        answer = j + 1;
      }
    }
    cout << answer << endl;
  }
  
}

Measured memory_bytes: 256
import sys
from collections import defaultdict
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    n=int(input())
    v=list(map(int,input().split()))
    do=defaultdict(int)
    de=defaultdict(int)
    for i,x in enumerate(v):
        if i%2:
            do[x]+=1
        else:
            de[x]+=1
    o1,e1,o2,e2=0,0,0,0
    for x in do.keys():
        if do[x]>o1:
            o2=o1
            o1=do[x]
            o1n=x
        else:
            o2=max(o2,do[x])
    for x in de.keys():
        if de[x]>e1:
            e2=e1
            e1=de[x]
            e1n=x
        else:
            e2=max(e2,de[x])
    if o1n!=e1n:
        print(n-(o1+e1))
    else:
        print(n-max(o1+e2,o2+e1))
            
            

if __name__ == '__main__':
    main()


Measured memory_bytes: 60652
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; } 
template<class T> void chmax(T &t, T f) { if (t < f) t = f; } 

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())


LL MOD = 1000000007;

int n;

void init() {
}

void input() {
	cin >> n;
}

void solve() {
    map<LL, int> m;
	FOR(i, 2, n+1){
    	int l = i;
    	for(LL j=2; j*j<=l; j++){
        	while(l%j == 0){
            	m[j]++;
            	l /= j;
        	}
    	}
    	if(l!=1) m[l]++;
	}

	LL res = 1;
	FIT(it, m) res = (res * (it->second + 1)) % MOD;
	cout <<res << endl;
}

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








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

#define ll long long
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define inf 1e17
#define N 100010
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;

ll result(ll a, ll b, ll p){
    ll ans=1;
    if(b==(-1))
        b=p-2;
    while(b){
        if(b&1){
            ans=(ans*a)%p;
        }
        a=(a*a)%p;
        b>>=1;
    }
    return ans;
}

ll T,n,m;

int main(){
    if(fopen("input.txt", "r"))
    freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll a, b , c, k;
    cin >> a >> b >> c >> k;
    ll d = a+b;
    if(k<=a)
        cout << k;
    else if(k<=(a+b))
        cout << a;
    else{
        ll d = k - (a+b);
        cout << a - d;
    }
    
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

int H, W;
vector<string> S(30);

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

int bfs(int x, int y) {
    vector<vector<int>> dis(H, vector<int>(W, -1));
    queue<P> que;
    que.push({x, y});
    dis[y][x] = 0;
    while (!que.empty()) {
        int sx = que.front().first, sy = que.front().second;
        que.pop();
        rep(i, 4) {
            int tx = sx + dx[i], ty = sy + dy[i];
            if (tx < 0 || tx >= W || ty < 0 || ty >= H || dis[ty][tx] != -1 || S[ty][tx] == '#') continue;
            dis[ty][tx] = dis[sy][sx] + 1;
            que.push({tx, ty});
        }
    }

    int res = 0;
    rep(i, H) {
        rep(j, W) {
            chmax(res, dis[i][j]);
        }
    }

    return res;
}
int main()
{
    cin >> H >> W;
    rep(i, H) cin >> S[i];

    int ans = 0;
    rep(i, H) {
        rep(j, W) {
            if (S[i][j] == '#') continue;
            chmax(ans, bfs(j, i));
        }
    }

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

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please


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

	int N;
	cin >> N;

	co(48-N);

	Would you please return 0;
}

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

using namespace std;

int main(){
	int n;
	cin >> n;
	map<string, int> hash;
	int cnt = 0;
	for (int i = 0; i < n; i++){
		string st;
		cin >> st;
		if (!hash[st]){
			hash[st] = 1;
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if (ceil((double)A/D) >= ceil((double)C/B)){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3600
n = int(input())
a = list(map(int, input().split()))
ans1 = sum([a[i] for i in range(0, n, 2) if a[i] > 0])
ans2 = sum([a[i] for i in range(1, n, 2) if a[i] > 0])
if max(ans1, ans2) == 0:
	print(max(a))
	print(n-1)
	i_max = a.index(max(a))
	print(*list(range(n, i_max+1, -1)), sep="\n")
	if i_max:
		print(*[1 for _ in range(i_max)], sep="\n")

elif ans1 >= ans2:
	print(ans1)
	op = []
	left = 0
	while a[left] <= 0:
		left += 2

	right = True
	in_seg = False
	for i in range(n-1, -1, -1):
		if right:
			if i%2 == 1 or a[i] <= 0:
				op.append(i+1)
			else:
				right = False
		elif i < left:
			op += [1] * (i+1)
			break
		else:
			if in_seg == False and i%2 == 1:
				in_seg = True
				seg_right = i
			elif i%2 == 0 and a[i] > 0:
				in_seg = False
				op += list(range((i+seg_right+3)//2, i+1, -1))

	print(len(op))
	print(*op, sep="\n")

else:
	print(ans2)
	op = []
	left = 1
	while a[left] <= 0:
		left += 2

	right = True
	in_seg = False
	for i in range(n-1, -1, -1):
		if right:
			if i%2 == 0 or a[i] <= 0:
				op.append(i+1)
			else:
				right = False
		elif i < left:
			op += [1] * (i+1)
			break
		else:
			if in_seg == False and i%2 == 0:
				in_seg = True
				seg_right = i
			elif i%2 == 1 and a[i] > 0:
				in_seg = False
				op += list(range((i+seg_right+3)//2, i+1, -1))

	print(len(op))
	print(*op, sep="\n")

Measured memory_bytes: 3316
#include<algorithm>/*{{{*/
#include<cctype>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<vector>
using namespace std;
typedef long long lld;
typedef long double lf;
typedef unsigned long long uld;
typedef pair<int,int> pii;
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
namespace RA{
    int r(int p){return 1ll*rand()*rand()%p;}
    int r(int L,int R){return r(R-L+1)+L;}
}
namespace IO{
    char nc(){ static char bf[100000],*p1=bf,*p2=bf; return p1==p2&&(p2=(p1=bf)+ fread(bf,1,100000,stdin),p1==p2)?EOF:*p1++; }
    int rd(){ int res=0; char c=getchar(); while(!isdigit(c))c=getchar(); while(isdigit(c))res=res*10+c-'0',c=getchar(); return res; }
}/*}}}*/
/******************heading******************/
const int N=1e5+5;

int n;
int p[N],pos[N];
long long ans;

bool vis[N<<2];
void assign(int p,int u=1,int l=1,int r=n){
    //printf("assign(%d,%d,%d,%d)\n",p,u,l,r);
    if(l==r)return vis[u]=1,void();
    int mid=(l+r)>>1;
    if(p<=mid)assign(p,u<<1,l,mid);
    else assign(p,u<<1|1,mid+1,r);
    vis[u]=vis[u<<1]|vis[u<<1|1];
}
int ql(int L,int R,int u=1,int l=1,int r=n){
    if(R<l||r<L)return n+1;
    if(L>R)return n+1;
    if(!vis[u])return n+1;
    //printf("ql(%d,%d,%d,%d,%d)\n",L,R,u,l,r);
    if(l==r)return l;
    int mid=(l+r)>>1;
    int t=ql(L,R,u<<1,l,mid);
    if(t!=n+1)return t;
    return ql(L,R,u<<1|1,mid+1,r);
}
int qr(int L,int R,int u=1,int l=1,int r=n){
    if(R<l||r<L)return 0;
    if(L>R)return 0;
    //printf("qr(%d,%d,%d,%d,%d)\n",L,R,u,l,r);
    if(!vis[u])return 0;
    if(l==r)return l;
    int mid=(l+r)>>1;
    int t=qr(L,R,u<<1|1,mid+1,r);
    if(t)return t;
    return qr(L,R,u<<1,l,mid);
}

void calc(int po){
    //printf("\033[31mcalc(p[%d]=%d)\033[0m\n",po,p[po]);
    int l1=qr(1,po),l2=qr(1,l1-1);
    int r1=ql(po,n),r2=ql(r1+1,n);
    //printf("l2=%d,l1=%d,r1=%d,r2=%d\n",l2,l1,r1,r2);
    //printf("ans=%lld\n",ans);
    if(l1!=0){
        int x=l1-l2,y=r1-po;
        ans+=1ll*x*y*p[po];
    }
    if(r1!=n+1){
        int x=po-l1,y=r2-r1;
        ans+=1ll*x*y*p[po];
    }
    //printf("ans=%lld\n",ans);
}
int main(){
    scanf("%d",&n);
    FOR(i,1,n)scanf("%d",&p[i]),pos[p[i]]=i;
    ROF(i,n,1){
        calc(pos[i]);
        //merge
        assign(pos[i]);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>

using namespace std;

int main() {
    long long x;
    cin >> x;

    long long left = 0, right = 2 * x;
    while (left < right) {
        long long mid = left + (right - left) / 2;

        if (mid * (mid + 1) >= 2 * x && right == mid) {
            break;
        } else if (mid * (mid + 1) >= 2 * x) {
            right = mid;
        } else {
            left = mid + 1;
        }
    }

    cout << left << endl;
}


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

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int N;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i++) {
        cin >> d[i];
    }
    int sum = 0;
    for (int i = 0; i < N -1; i++) {
        for (int j = i + 1; j < N; j++) {
            sum += d[i] * d[j];
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int a,b;
  cin>>a>>b;
  if(b%a==0) cout<<a+b<<endl;
  else cout<<b-a<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
int N, M, Q;
ll ans = 0;
vector<ll> a(50), b(50), c(50), d(50);

void dfs(vector<int> &A) {
    if (A.size() == N) {
        ll sum = 0;
        rep(i, Q) {
            if (A[b[i]] - A[a[i]] == c[i])
                sum += d[i];
        }
        ans = max(ans, sum);
        return;
    }

    int prev_i = (A.empty() ? 1 : A.back());
    for (int i = prev_i; i <= M; i++) {
        A.push_back(i);
        dfs(A);
        A.pop_back();
    }
}

int main() {
    cin >> N >> M >> Q;
    a.resize(Q), b.resize(Q), c.resize(Q), d.resize(Q);
    rep(i, Q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
    }
    vector<int> A;
    dfs(A);
    cout << ans << endl;
}

Measured memory_bytes: 3628
import math

while True:
    try:
        C1=list(map(int,input().split()))
        C2=list(map(int,input().split()))
        
        d = math.sqrt(math.pow(C2[0]-C1[0],2)+math.pow(C2[1]-C1[1],2))
        if(d > C1[2]+C2[2]):
            print("4")
        elif(d == C1[2]+C2[2]):
            print("3")
        elif(math.fabs(C1[2]-C2[2]) < d and d < C1[2]+C2[2]):
            print("2")
        elif(d == math.fabs(C1[2]-C2[2])):
            print("1")
        elif(d < math.fabs(C1[2]-C2[2])):
            print("0")
    except:
        break;



Measured memory_bytes: 5676
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <set>
#include <climits>

using namespace std;

const int N = 4;
const int N2 = 16;

static const int dx[4] = {0, -1, 0, 1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'r', 'u', 'l', 'd'}; 


struct Node
{
	vector<int> puzzle;
	int space;
	int md;
};

class Npuzzle
{
private:
	Node s_node;
	int limit;
	vector<vector<int> > md;
	vector<int> path;
	int ans;
public:
	Npuzzle() {
		s_node = Node();
		vector<int> in;
		for (int i = 0; i < N2; ++i)
		{
			int tmp;
			cin >> tmp;
			if(tmp == 0) {
				tmp = N2;
				s_node.space = i;
			}
			in.push_back(tmp);
		}
		s_node.puzzle = in;
		set_md();
		s_node.md = get_md_sum(s_node.puzzle);
	}

	int get_md_sum(const vector<int>& puzzle) {
		int sum = 0;
		for (int i = 0; i < N2; ++i)
		{
			if(puzzle[i] == N2) continue;
			sum += md[i][puzzle[i]-1];
		}
		return sum;
	}

	void set_md() {
		md = vector<vector<int> >(N2, vector<int>(N2, 0));
		for (int i = 0; i < N2; ++i)
		{
			for (int j = 0; j < N2; ++j)
			{
				md[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
			}
		}
	}

	bool dfs(Node cur_n, int depth, int pre) {
		if(cur_n.md == 0 ) {
			ans = depth;
			return true;
		}
		if(depth + cur_n.md > limit) return false;
		int s_x = cur_n.space / N;
		int s_y = cur_n.space % N;
		for (int i = 0; i < 4; ++i)
		{
			Node new_n = cur_n;
			int new_x = s_x + dx[i];
			int new_y = s_y + dy[i];
			if(new_x < 0  || new_y < 0 || new_x >= N || new_y >= N) continue; 
			if(max(pre, i) - min(pre, i) == 2) continue;

			new_n.md -= md[new_x * N + new_y][new_n.puzzle[new_x * N + new_y] - 1];
			new_n.md += md[s_x * N + s_y][new_n.puzzle[new_x * N + new_y] - 1];
			swap(new_n.puzzle[new_x * N + new_y], new_n.puzzle[s_x * N + s_y]);
			new_n.space = new_x * N + new_y;
			// assert(get_md_sum(new_n.puzzle) == new_n.md);
			// return dfs(new_n, depth+1, i);
			if(dfs(new_n, depth + 1, i)){
				path[depth] = i;
				return true;
			}
		}
		return false;
	}

	void ida_star() {
		for (limit = s_node.md; limit < 1000; ++limit)
		{
			path.resize(limit);
			if(dfs(s_node, 0, -10)) {
				cout << limit << endl;
				// string str = "";
				// for (int i = 0; i < limit; ++i)
				// {
				// 	str += dir[path[i]];
				// }
				// cout << str << endl;
				return;
			}
		}
	}

	void exec() {
		ida_star();
	}
};


int main() {
	Npuzzle np = Npuzzle();
	np.exec(); 
}

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

int main(){
    string s; cin >> s;
    int N=s.size();
    int K; cin >> K;
    long long dp[N+1][2][101]={};
    dp[0][0][0]=1;
    for(int i=0;i<N;i++){
        for(int j=0;j<=K;j++){
            dp[i+1][1][j]+=dp[i][1][j];
            if(s[i]=='0') dp[i+1][0][j]+=dp[i][0][j];
            if(s[i]!='0') dp[i+1][1][j]+=dp[i][0][j];
            for(int h=1;h<=9;h++){
                if(j+1<=K&&s[i]==(h+'0')){
                    dp[i+1][0][j+1]+=dp[i][0][j];
                }
                if(j+1<=K){
                    dp[i+1][1][j+1]+=dp[i][1][j];
                    if('0'+h<s[i]) dp[i+1][1][j+1]+=dp[i][0][j];
                }
            }
        }
    }
    cout << dp[N][0][K]+dp[N][1][K] << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;
int main(){

  int n,m,l;

  cin >> n>>m>>l;

  int a[m][n];
  int b[l][m];
  long c[l][n];
  memset(a,0,(n*m)*sizeof(int));
  memset(b,0,(m*l)*sizeof(int));
  memset(c,0,(l*n)*sizeof(long));


  for(int j=0;j<n;j++){
    for(int i=0;i<m;i++){
      cin >> a[i][j];
    }
  }
  for(int j=0;j<m;j++){
    for(int i=0;i<l;i++){
      cin >> b[i][j];
    }
  }

  for(int j=0;j<n;j++){
    for(int i=0;i<l;i++){
      long sum = 0;
      for(int k=0;k<m;k++){
        sum += a[k][j] * b[i][k];
      }
      c[i][j] = sum;
    }
  }

  for(int j=0;j<n;j++){
    for(int i=0;i<l;i++){
      cout << c[i][j] ;
      if(i == l-1) cout << endl;
      else cout << " ";
    }
  }



  
}




Measured memory_bytes: 3228
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun May  3 21:06:05 JST 2020
 **/

signed main() {
    Int x;
    std::cin >> x;
    REP(a, -1000, 1000) {
        REP(b, -1000, 1000) {
            if (a * a * a * a * a - b * b * b * b * b == x) {
                std::cout << a << " " << b << std::endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3636
num = 0
table = {}
for _ in range(3):
    row = map(int, input().split())
    for r in row:
        table[r] = num
        num += 1

N = int(input())

bingo = set()
for _ in range(N):
    b = int(input())
    if b in table:
        bingo.add(table[b])

atari = [
    {0,1,2},
    {3,4,5},
    {6,7,8},
    {0,3,6},
    {1,4,7},
    {2,5,8},
    {0,4,8},
    {2,4,6}
]

for a in atari:
    if a <= bingo:
        print('Yes')
        break
else:
    print('No')


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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    map<char,int> m;
    m['a'] = 0;
    m['b'] = 0;
    m['c'] = 0;
    string s;
    cin >> s;
    for (int i = 0; i < 3; i++){
        m[s[i]]++;
    }
    int n = 0;
    for (char i = 'a'; i <= 'c'; i++){
        if (m[i] == 1) n++;
    }
    if (n == 3){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }



    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<ll>a(n,0);
	repp(i,0,n) {
		cin >> a[i];
		a[i] -= i+1;
	}
	sort(a.begin(), a.end());
	ll ans;
	if (n % 2 == 1)ans = a[(n - 1) / 2];
	else ans = (a[n / 2] + a[n / 2 - 1]) / 2;
	ll sum = 0;
	repp(i, 0, n ) {
		sum += abs(a[i] - ans);
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
string mp[111];
int N,M;
int a[111],b[111];
int main(){
  cin>>N>>M;
  for(int i=0;i<N;i++)
    cin>>mp[i];
  for(int i=0;i<N;i++){
    int f=0;
    for(int j=0;j<M;j++){
      if(mp[i][j]=='#')f=1;
    }
    if(!f){
      a[i]=1;
    }
  }
  for(int i=0;i<M;i++){
    int f=0;
    for(int j=0;j<N;j++){
      if(mp[j][i]=='#')f=1;
    }
    if(!f){
      b[i]=1;
    }
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++)
      if(!a[i]&&!b[j])
        putchar(mp[i][j]);
    if(!a[i])puts("");
  }
}

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

using namespace std;

int main(void){
    int n;
    cin>>n;
    bool negativeodd=0;
    int64_t a[n];
    int64_t sum=0,min=1000000000;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        if(a[i]<0){
            negativeodd=!negativeodd;
            a[i]*=-1;
        }
        sum+=a[i];
        if(min>a[i])min=a[i];
    }
    if(negativeodd){
        cout<<(sum-2*min)<<endl;
    }else{
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int N,M,L;
int P[301][301];
pair<int,int>D[301][301];
vector<pair<int,int> >G[301];
main()
{
	cin>>N>>M>>L;
	for(int i=0;i<M;i++)
	{
		int a,b,c;cin>>a>>b>>c;
		G[a].push_back(make_pair(b,c));
		G[b].push_back(make_pair(a,c));
	}
	for(int k=1;k<=N;k++)
	{
		for(int i=1;i<=N;i++)
		{
			P[k][i]=-1;
			D[k][i]=make_pair(1e9,0);
		}
		P[k][k]=k;
		D[k][k]=make_pair(0,L);
		priority_queue<pair<pair<int,int>,int> >Q;
		Q.push(make_pair(make_pair(0,L),k));
		while(!Q.empty())
		{
			int u=Q.top().second;
			int cnt=-Q.top().first.first;
			int now=Q.top().first.second;
			Q.pop();
			if(D[k][u].first<cnt||D[k][u].first==cnt&&D[k][u].second>now)continue;
			for(pair<int,int>p:G[u])
			{
				int v=p.first;
				int nxtc=cnt;
				int nxtnow;
				if(now>=p.second)nxtnow=now-p.second;
				else if(L>=p.second)nxtnow=L-p.second,nxtc++;
				else continue;
				if(D[k][v].first>nxtc||D[k][v].first==nxtc&&D[k][v].second<nxtnow)
				{
					D[k][v]=make_pair(nxtc,nxtnow);
					Q.push(make_pair(make_pair(-nxtc,nxtnow),v));
				}
			}
		}
	}
	int Q;
	cin>>Q;
	for(;Q--;)
	{
		int s,t;cin>>s>>t;
		int ans=D[s][t].first;
		if(ans<1e9)cout<<ans<<endl;
		else cout<<-1<<endl;
	}
}

Measured memory_bytes: 3332
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int res = 0;
  int n = int(s.size());
  for (int i = 0; i < n/2; i++) {
    if(s[i] != s[n-1-i]) res++;
  }
  cout << res << endl;
}


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

int n;
long long a[100005];
int main()
{
	std::cin >> n;
	for (int i = 0; i < n; ++i)
		std::cin >> a[i];

	std::sort(a, a + n);

	auto end = a[n - 1];
	auto right = std::distance(a, std::lower_bound(a, a + n, end / 2));
	if (right == n - 1)
		--right;
	long long left = 0;
	if (right != 0)
		left = right - 1;

	std::cout << end << " " << (a[left] > end - a[right] ? a[left] : a[right]) << std::endl;
	return 0;
}


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

int main() {
    vector<string> d(8);
    for (auto& i : d) cin >> i;

    cout << 90 << endl;
    for (int i = 0; i < 8; i++) {
        for (int j = 0; j < 8; j++) {
            cout << d[7-j][i];
        }
        cout << endl;
    }

    cout << 180 << endl;
    for (int i = 0; i < 8; i++) {
        for (int j = 0; j < 8; j++) {
            cout << d[7 - i][7 - j];
        }
        cout << endl;
    }

    cout << 270 << endl;
    for (int i = 0; i < 8; i++) {
        for (int j = 0; j < 8; j++) {
            cout << d[j][7-i];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3072
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

		var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
			long M = inputArray[1];

			var inputInfo = new List<Tuple<long, long>>();

			for (int i = 0; i < M; i++) {
				var inp = retreiveLongArray();
				var ken = inp[0];
				var year = inp[1];
				var tp = new Tuple<long, long>(ken, year);
				inputInfo.Add(tp);
			}


			var YearDic = new Dictionary<long, List<long>>();

			for (int i = 0; i < M; i++) {
				var tp = inputInfo[i];
				var ken = tp.Item1;
				var year = tp.Item2;

				if (YearDic.ContainsKey(ken)) {
					YearDic[ken].Add(year);
				}
				else {
					var newList = new List<long> { year };
					YearDic.Add(ken, newList);
				}
			}

			//何年に生まれた市は、その件で何番目なのかを記録する 同じ年にうまれる市はないため
			var yearNum = new Dictionary<long, long>();

			foreach (var item in YearDic) {

				var cityList = item.Value.OrderBy(x =>x).ToList();

				for (int i = 0; i < cityList.Count; i++) {
					yearNum.Add(cityList[i], i + 1);
				}
			}

			for (int i = 0; i < M; i++) {
				var tp = inputInfo[i];
				var ken = tp.Item1;
				var year = tp.Item2;
				var kenStr = String.Format("{0:000000}", ken);
				var setsuritsu = yearNum[year];
				var setsuStr = String.Format("{0:000000}", setsuritsu);
				Console.WriteLine(kenStr + setsuStr);
			}

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 43936
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;
bool isset(ll n, ll k) 
{ 
    if ((n >> (k)) & 1) 
        return true;
    return false;
}
signed main()
{
    fast;
  
    ll n,m,i,j,y,z,k,ans=0;
    cin>>n>>m>>k;
    char mat[n+2][m+2];
    for(i=0;i<n;i++)
    {
    	for(j=0;j<m;j++) cin>>mat[i][j];
    }
    for(i=0;i<(1<<n);i++)
    {
    	for(j=0;j<(1<<m);j++)
    	{
    		ll ro[n+2] = {0};
    		ll co[m+2] = {0};
    		for(z=0;z<n;z++)
    		{
    			if(isset(i,z)) ro[z]++;
    		}
    		for(z=0;z<m;z++)
    		{
    			if(isset(j,z)) co[z]++;
    		}
    		ll cn=0;
    		for(z=0;z<n;z++)
    		{
    			for(y=0;y<m;y++)
    			{
    				if(!ro[z] and !co[y] and mat[z][y]=='#') cn++;
    			}
    		}
    		if(cn==k) ans++;
    	}
    }
    cout<<ans;
}

Measured memory_bytes: 3644
N,M = map(int,input().split())
A = []
for i in range(N):
    A.append(list(map(int,input().split())))
use = [0 for i in range(30)]
for i in range(N):
    j = 0
    for j in range(30):
        if (j+1) in A[i][1:]:
            use[j]+=1
print(use.count(N))

Measured memory_bytes: 3060