akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int N, M;
    cin >> N >> M;
    vector<vector<int> > G(N);
    vector<bool> used(N, false);
    rep(i, 0, M) {
        int A, B;
        cin >> A >> B;
        A--;
        B--;
        G[A].push_back(B);
        G[B].push_back(A);
    }

    int cur = 0;
    vector<int> anss;
    while (true) {
        anss.push_back(cur);
        used[cur] = true;
        int next = -1;
        for (auto e : G[cur]) {
            if (!used[e]) {
                next = e;
                break;
            }
        }
        if (next == -1) break;
        cur = next;
    }
    cur = anss[0];
    reverse(all(anss));
    while (true) {
        if(!used[cur])
        anss.push_back(cur);
        used[cur] = true;
        int next = -1;
        for (auto e : G[cur]) {
            if (!used[e]) {
                next = e;
                break;
            }
        }
        if (next == -1) break;
        cur = next;
    }


    cout << anss.size() << endl;
    rep(i, 0, anss.size()) {
        cout << anss[i] + 1;
        if (i == anss.size() - 1) {
            cout << endl;
        } else {
            cout << " ";
        }
    }


    return 0;
}


Measured memory_bytes: 6776
# https://atcoder.jp/contests/abc081/tasks/abc081_b
n = int(input())
nums = [int(i) for i in input().split()]

ans = 0
f = True
while f:
    for i in range(n):
        if nums[i] and nums[i] % 2 == 0:
            nums[i] = nums[i] // 2
        else:
            f = False
            break
    else:
        ans += 1
print(ans)

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

#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

int N;
vector<vector<pii>> v;  // pii: (x,y)

bool judge(int bit) {
  rep(i, N) {
    // person i
    if (!(bit & (1 << i))) continue;

    for (auto xy : v[i]) {
      int x = xy.first;
      int y = xy.second;
      if (y == 1 && !(bit & (1 << x))) return false;  // contradiction
      if (y == 0 && (bit & (1 << x))) return false;   // contradiction
    }
  }
  return true;
}

int main() {
  cin >> N;
  v.resize(N);
  rep(i, N) {
    int A;
    cin >> A;
    v[i].resize(A);
    rep(j, A) {
      cin >> v[i][j].first >> v[i][j].second;
      v[i][j].first--;
    }
  }

  int res = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    if (judge(bit)) {
      int cnt = 0;
      rep(i, N) {
        if (bit & (1 << i)) cnt++;
      }
      res = max(res, cnt);
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define M 1000

int solve(int,int);
int i,j,n,q;
int A[M],m[M];
int main()
{
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&A[i]);
    }
  scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d",&m[i]);
    }
  for(i=0;i<q;i++)
    {
      if(solve(0,m[i]))
	{
	  printf("yes\n");
	}
      else
	{
	  printf("no\n");
	}
    }
  return 0;
}

int solve(int i,int k)
{
  int result;
  if(k==0)
    {
      return 1;
    }
  if(i>=n)
    {
      return 0;
    }
  result=solve(i+1,k)||solve(i+1,k-A[i]);
  return result;
}



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


int main()
{
   float n,i,j=0,pro=0;


  scanf("%f",&n);
   for(i=1;i<=n;i+=2)
   {
       j++;
   }
   pro=(j/n);
   printf("%.10f",pro);



    return 0;
}



Measured memory_bytes: 1748
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


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

    yns(n == m);
    return 0;
}

Measured memory_bytes: 256
import sys
def input(itr=iter(sys.stdin.readlines())):  # pylint: disable= redefined-builtin
    return next(itr).rstrip('\n\r')
###############################################################################

import math

N = int(input())

max_sum = -math.inf
min_sum = math.inf
max_diff = -math.inf
min_diff = math.inf
for _ in range(N):
    x, y = map(int, input().split())
    max_sum = max(max_sum, x+y)
    min_sum = min(min_sum, x+y)
    max_diff = max(max_diff, x-y)
    min_diff = min(min_diff, x-y)

answer = max(max_sum - min_sum, max_diff - min_diff)
print(answer)


Measured memory_bytes: 91368
#include<stdio.h>
int main(void)
{
     int P,R,Q;
  
     scanf("%d%d%d",&P,&R,&Q);
     
     if((P+Q>=P+R)&&(P+R>=Q+R))
       printf("%d\n",Q+R);
     else if((Q+R>=P+R)&&(P+R>=P+Q))
       printf("%d\n",P+Q);
     else if((P+R>=P+Q)&&(P+Q>=Q+R))
       printf("%d\n",Q+R);
     else if((P+R>=Q+R)&&(Q+R>=P+Q))
       printf("%d\n",P+Q);
     else if((P+Q>=Q+R)&&(Q+R>=P+R))
       printf("%d\n",P+R);
     else if((Q+R>=P+Q)&&(P+Q>=P+R))
       printf("%d\n",P+R);
     
     return 0;
}
              

Measured memory_bytes: 1732
import java.util.*;
public class Main{
  public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n=sc.nextInt();
      int m=sc.nextInt();
      Map<Integer, Integer>map = new HashMap<>();
      List<int[]> intList = new ArrayList<>();
      for(int i=0; i<n; i++){
        int ki = sc.nextInt();
        int[] array = new int[ki];
        	for(int j=0; j<ki; j++){
              array[j] = sc.nextInt();
            }
        intList.add(array);
      }
      for(int i=1; i<=m; i++){
        map.put(i, 0);
      }
      for(int[] array: intList){
        for(int i: array){
          int j = map.get(i) + 1;
          map.put(i, j);
        }
      }
    int count = 0;
      for(int i=1; i<=m; i++){
        if(map.get(i) == n){
          count++;
        }
      }
      System.out.println(count);
  }
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  long long n,i,j,k,x,ret = 0;
  cin >> n >> x;
  long long a[n],dp[n][n];
  for(i=0;i<n;i++){
    cin >> a[i];
    dp[0][i]=a[i];
    ret+=a[i];
    for(j=1;j<n;j++)dp[j][i]=1e18;
  }
  for(i=1;i<n;i++){//魔法を唱える回数
    for(j=0;j<n;j++){//欲しいスライムの種類
      dp[i][j]=min(dp[i-1][j],a[(n+j-i)%n]);
    }
    long long sum=0;
    for(j=0;j<n;j++)sum+=dp[i][j];
    //cout << dp[i][0] << endl;
    ret = min(sum+x*i,ret);
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 31488
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rrep(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll n; cin >> n;
  vector<ll> a(n), b(n);
  rep(i,n) cin >> a[i] >> b[i];
  
  vector<ll> sa = a; vector<ll> sb = b;
  sort(all(sa)); sort(all(sb),greater<ll>());
  
  if(n&1){
	  cout << sb[n/2] - sa[n/2] + 1 << endl;
  }else{
      ll ma = sa[n/2 - 1] + sa[n/2];
      ll mb = sb[n/2 - 1] + sb[n/2];
      cout << mb - ma + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 9460
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned int ui;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
#define All(v) (v).begin(),(v).end()
#define Rep(i,n) for(int i = 0; i < (int)n; i++)
#define Reps(i,n) for(int i = 1; i <= (int)n; i++)
#define For(i,m,n) for(int i = m; i < n; i++)
#define Fors(i,m,n) for(int i = m; i <= n; i++)
#define Inf 2e9
#define F first
#define S second
#define pb push_back
#define mp make_pair
struct speed{speed(){cin.tie(); ios::sync_with_stdio(false); cout << fixed << setprecision(18);}}speed;

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

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

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


int main (){
    int n,m;
    cin >> n >> m;
    vector<bool> b(n+1,true);
    vector<ll> cnt(n+1,1);
    Rep(i,m){
        int tmp;
        cin >> tmp;
        b[tmp] = false;
    }
    cnt[0] = 1;
    cnt[1] = (b[1] == true)? 1 : 0;
    Fors(i,2,n){
        cnt[i] = (b[i] == true)? (cnt[i-1]+cnt[i-2])%1000000007 : 0;
    }
    cout << cnt[n] << "\n";
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int compare_int(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}

int main(){
    int n, k, sum=0, p[1000]={0};

    scanf("%d %d", &n, &k);
    for(int i=0; i<n; i++){ scanf("%d", &p[i]); }
    qsort( p, n, sizeof(int), compare_int );

    for(int i=0; i<k; i++){ sum += p[i]; }
    printf("%d\n", sum);

    return 0;
}

Measured memory_bytes: 1740
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 30
#define MAX_D 400

    /*
    いろいろ
    int x = rand()%100;
    double x = (double)rand()/RAND_MAX;
    mt19937 get_rand_mt;
    shuffle(vec.begin(), vec.end(), get_rand_mt);
    int dx[4] = {-1, 0, 1, 0};
    int dy[4] = {0, -1, 0, 1};
    char cc[4] = {'U','L','D','R'};
    */

int D;
int c[MAX_N];
int s[MAX_D][MAX_N];
int ma;
int ans[MAX_D];

int calc(){
    int las[26] = {};
    int res = 0;
    rep(i,D){
        res += s[i][ans[i]];
        las[ans[i]] = i+1;
        rep(j,26){
            res -= (i + 1 - las[j]) * c[j];
        }
    }
    return res;
}


int main() {
    srand((unsigned) time(NULL));
    clock_t start,end;
	start = clock();


    string fileNameIfs = "input_1.txt";
    const char* cstrIfs = fileNameIfs.c_str();
    ifstream ifs(cstrIfs);
    if(!ifs.is_open()){ // 標準入力する
        cin >> D;
        rep(i,26)cin >> c[i];
        rep(i,D)rep(j,26)cin >> s[i][j];
        rep(i,D){
            cin >> ans[i];
            ans[i]--;
        }
    }else{ // ファイル入力する
        ifs >> D;
        rep(i,26)ifs >> c[i];
        rep(i,D)rep(j,26)ifs >> s[i][j];
    }    
    
    /*
    rep(i,D){
        int max_s = -1;
        int arg = -1;
        rep(j,26){
            if(s[i][j] > max_s){
                max_s = s[i][j];
                arg = j;
            }
        }
        ans[i] = arg;
    }
    */
    ma = calc();

    int M;
    cin >> M;
    rep(i,M){
        int d, q;
        cin >> d >> q;
        d--;
        q--;
        ans[d] = q;
        int tmp = calc();
        cout << tmp << endl;
    }

    /*
    start = clock();
    while(true){
        int x = rand()%D;
        int y = rand()%26;

        int keep = ans[x];
        ans[x] = y;

        int tmp = calc();

        if(tmp >= ma){
            ma = tmp;
        }else{
            ans[x] = keep;
        }

        end = clock();
        if((double)(end-start)/CLOCKS_PER_SEC > 1.7)break;
    }


    rep(i,D){
        cout << ans[i] + 1 << endl;
    }

    string fileName = "sample_out1.txt";
    const char* cstr = fileName.c_str();
    ofstream ofs(cstr);
    rep(i,D){
        ofs << ans[i] + 1 << endl;
    }
    ofs.close();
    */
    return 0;
}
 
 


Measured memory_bytes: 3600
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>

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

using namespace std;
typedef long long int ll;
const ll INF = 1000000000000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

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

int main()
{
    int n;
    int a[200000];
    cin >> n;
    map<int, int> mp;
    rep(i, n) {
        cin >> a[i];
        mp[a[i]]++;
    }

    int ans = 0;
    rep(i, n) {
        bool is_ok = true;
        vector<int> div = CalcDivisor(a[i]);
        rep(j, div.size()) {
            if (j == div.size() - 1) {
                if (mp[div[j]] > 1) {
                    is_ok = false;
                }
            }
            else if (mp[div[j]]) {
                is_ok = false;
            }
        }
        if (is_ok) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 33108
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};

int main(){
	char s[101];
	int mini=INF;
	cin>>s;
	for(int i=0;i<26;i++){
		char ss[101];
		strcpy(ss,s);
		char target='a'+i;
		for(int count=0;1;count++){
			bool flag=0;
			for(int j=0;j<strlen(ss);j++){
				if(ss[j]!=target)
					flag=1;
			}
			if(flag==0){
				mini=min(count,mini);
				break;
			}
			char tt[101];
			for(int j=0;j<strlen(ss)-1;j++){
				if(ss[j]==target || ss[j+1]==target){
					tt[j]=target;
				}
				else{
					tt[j]='@';
				}
			}
			tt[strlen(ss)-1]='\0';
			strcpy(ss,tt);
		}
	}
	cout<<mini<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
inline void ask(string str){
	cout<<"? "<<str<<endl;
}
inline bool check(){
	char ch;
	cin>>ch;
	return ch=='Y';
}
inline void print_ans(string ans){
	cout<<"! "<<ans<<endl;
}
int main(){
	int l=1,r=12;
	while(r-l>1){
		int mid=(l+r)>>1;
		string str="1";
		for(int i=2;i<=mid;i++)
			str+='0';
		ask(str);
		if(check()) l=mid;
		else r=mid;
	}
	int len=l;
	if(len>10){
		l=1,r=12;
		while(l!=r){
			int mid=(l+r)>>1;
			string str;
			for(int i=1;i<=mid;i++)
				str+='9';
			ask(str);
			if(check()) r=mid;
			else l=mid+1;
		}
		len=r;
	}
	string ans;
	for(int i=1;i<=len;i++){
		if(i<len){
			l=i==1?1:0,r=10;
			while(r-l>1){
				int mid=(l+r)>>1;
				ask(ans+(char)('0'+mid));
				if(check()) l=mid;
				else r=mid;
			}
			ans+=(char)(l+'0');
		}else{
			l=i==1?1:0,r=9;
			while(l!=r){
				int mid=(l+r)>>1;
				ask(ans+(char)('0'+mid)+('0'));
				if(check()) r=mid;
				else l=mid+1;
			}
			ans+=(char)(r+'0');
		}
	}
	print_ans(ans);
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;

int main(){
	int h,w,n;
	cin >> h >> w >> n;
	vector<vector<char> > input(h+2, vector<char>(w+2, '.'));
	for(int i=h; i>=1; i--){
		for(int j=1; j<=w; j++){
			cin >> input[i][j];
		}
	}
	
	bool yes=false;
	for(int i=1; i<=h; i++){
		for(int j=1; j<=w-1; j++){
			//swap
			vector<vector<char> > field = input;
			char tmp = field[i][j];
			field[i][j] = field[i][j+1];
			field[i][j+1] = tmp;			
			bool nochange=false;
			while(!nochange){
				nochange = true;
				//fall
				for(int x=1; x<=w; x++){
					int fall=-1;
					for(int y=1; y<=h; y++){
						if(field[y][x]=='.' && fall==-1){
							fall=y;
						}
						if(field[y][x]!='.' && fall!=-1){
							field[fall][x]=field[y][x];
							field[y][x]='.';
							fall++;
						}
					}
				}
				
				//erase
				vector<vector<bool> > erase(h+2, vector<bool>(w+2,false));
				for(int y=1; y<=h; y++){
					char before='.';
					int seq=0;
					for(int x=1; x<=w+1; x++){
						if(field[y][x]==before){
							seq++;
						}else{
							if(seq>=n && before!='.'){
								for(int s=1; s<=seq; s++){
									erase[y][x-s] = true;
								}
							}
							before=field[y][x];
							seq=1;
						}
					}
				}
				for(int x=1; x<=w; x++){
					char before='.';
					int seq=0;
					for(int y=1; y<=h+1; y++){
						if(field[y][x]==before){
							seq++;
						}else{
							if(seq>=n && before!='.'){
								for(int s=1; s<=seq; s++){
									erase[y-s][x] = true;
								}
							}
							before=field[y][x];
							seq=1;
						}
					}
				}
				for(int y=1; y<=h; y++){
					for(int x=1; x<=w; x++){
						if(erase[y][x]){
							field[y][x]='.';
							nochange=false;
						}
					}
				}
			}
			
			bool end=true;
			for(int y=1; y<=h; y++){
				for(int x=1; x<=w; x++){
					if(field[y][x]!='.'){
						end=false;
						y=h;
						break;
					}
				}
			}
			if(end){
				yes=true;
				i=h;
				break;
			}
		}
	}
	
	if(yes){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 3144
a = []
for _ in range(3):
    n = input().split()
    for i in range(len(n)):
        a.append(n[i])

ans = [0 for _ in range(9)]

n = int(input())
for i in range(n):
    b = input()
    if b in a:
        ans[a.index(b)] = 1

if ((ans[0] and ans[1] and ans[2]) or
    (ans[3] and ans[4] and ans[5]) or
    (ans[6] and ans[7] and ans[8]) or
    (ans[0] and ans[3] and ans[6]) or
    (ans[1] and ans[4] and ans[7]) or
    (ans[2] and ans[5] and ans[8]) or
    (ans[0] and ans[4] and ans[8]) or
    (ans[6] and ans[4] and ans[2])):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  int i,j;
  int ans=10000;
  for(i=0;i<s.size()-t.size()+1;i++){
    int x=0;
    for(j=0;j<t.size();j++){
      if(s[i+j]!=t[j]){
        x++;
      }
    }
    ans=min(ans,x);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#!/usr/bin/ruby
#encoding: utf-8

def calcDigitSums(nstr)
  ns = nstr.size
  sum = 0
  (0..ns-1).each do |i|
    sum += nstr[i].to_i
  end
  return sum
end

nstr = gets.chomp

if nstr.to_i % calcDigitSums(nstr) == 0
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t % mod;
    } else {
        return modpow(m, n - 1) * m % mod;
    }
}
long long power(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }
void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
ll nCkmod(ll n, ll k) {
    ll denomi = 1;
    for (int i = n; i > n - k; i--) {
        denomi *= i;
        denomi %= mod;
    }
    ll numera = 1;
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}
int k;
vector<vector<ll>> graph;
vector<ll> ans;
map<P, ll> number;
void dfs(ll cur, ll parent, ll cpc) {
    int color = 1;
    REP(i, graph[cur].size()) {
        if (parent != graph[cur][i]) {
            if (cpc == color) {
                color++;
            }
            ans[number[{cur, graph[cur][i]}]] = color;
            dfs(graph[cur][i], cur, color);
            color++;
        }
    }
}
int main() {
    string s;
    ll n;
    cin >> n;
    int d;
    s = to_string(n);
    d = s.size();
    if (d == 1) {
        cout << n << endl;
        return 0;
    }
    ll sum = 0;
    ll cnt[10][10] = {0};
    ll now = d;
    rep(k, 2, d) {
        rep(i, 1, 10) {
            rep(j, 1, 10) { cnt[i][j] += power(10, (k - 2)); }
        }
    }
    rep(i, 1, 10) { cnt[i][i] ++; }
    REP(l, d - 1) {
        rep(i, 0, s[l] - '0') {
            if (l > 0) {
                rep(j, 1, 10) { cnt[s[0] - '0'][j] += power(10, (d - l - 2)); }
                continue;
            }
			if(i==0)continue; 
            rep(j, 1, 10) { cnt[i][j] += power(10, (d - l - 2)); }
        }
    }
    rep(i, 1, s[d - 1] - '0' + 1) { cnt[s[0] - '0'][i]++; }
    rep(i, 1, 10) {
        rep(j, 1, 10) { sum += cnt[i][j] * cnt[j][i]; }
    }
    cout << sum << endl;
}

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

typedef long long int ll;
typedef long double ld;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define MOD (ll)(1e9 + 7)
#define vi vector<int>
#define vii vector<vector<int> >
#define vl vector<ll>
#define vll vector<vector<ll> >
#define vc(T, nm) vector<T> nm
#define pb push_back
#define popb pop_back
#define si set<int>
#define sl set<ll>
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define ins insert
#define ers erase
#define endl "\n"
#define mul(a, b) ((a % MOD) * (b % MOD)) % MOD
#define adr(a, b) ((a % MOD) + (b % MOD)) % MOD
#define FORA(x, s, e, inc) for(ll x = s; x != e; x += inc)
#define ROFA(x, s, e, inc) for(ll x = s; x != e; x -= inc)
#define FOR(x, s, e) FORA(x, s, e, 1)
#define ROF(x, s, e) ROFA(x, s, e, 1)
#define loop(x, n) FOR(x, 0, n)
#define rd1(t, a) 					t a; cin >> a;
#define rd2(t, a, b) 				rd1(t, a); rd1(t, b); 
#define rd3(t, a, b, c) 			rd2(t, a, b); rd1(t, c);
#define rd4(t, a, b, c, d) 			rd3(t, a, b, c); rd1(t, d);
#define rd5(t, a, b, c, d, e) 		rd4(t, a, b, c, d); rd1(t, e);
#define rd6(t, a, b, c, d, e, f) 	rd5(t, a, b, c, d, e); rd1(t, f);
#define rdA(t, nm, len)				t nm[len]; loop(i, len) {cin >> nm[i];}
#ifdef DEBUG
	#define deb(v) cout << endl << #v << ": " << v << endl
	#define db1(v) cout << endl << #v << ": " << "[ "; for(auto x: v) {cout << x << " ";}; cout << "]" << endl;
	#define db2(v) cout << endl << #v << ": " << endl; for(auto r: v) {cout << "[ "; for(auto x: r) {cout << x << " ";}; cout << "]" << endl;};
	#define dbl cout << "-------------------------------" << endl
#else
	#define deb(v)
	#define db1(v)
	#define db2(v)
	#define dbl
#endif

ll DP[100004][104];

ll slv(vll &A, ll W, ll idx) {
    if(idx == A.size())
        return 0;
    
    if(DP[W][idx] != -1)
        return DP[W][idx];
    
    ll mxv = 0;
    mxv = max(mxv, slv(A, W, idx + 1));
    if(A[idx][0] <= W)
        mxv = max(mxv, A[idx][1] + slv(A, W - A[idx][0], idx + 1));
    
    DP[W][idx] = mxv;
    return mxv;
}

void solve() {
    memset(DP, -1, sizeof(DP));
    rd2(ll, N, W);
    vll A(N, vl(2));
    FOR(i, 0, N) {
        cin >> A[i][0] >> A[i][1];
    }
    
    cout << slv(A, W, 0);
}

int main() {
	
	fastio;

	ll t = 1;

    while(t--) {
        solve();
    }
    
	return 0;
}

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

int main(){
  ll n; cin>>n;
  vector<ll> a(n),b(n+1);
  for(int i=0; i<n; i++) {
    cin>>a[i];
    b[a[i]]++;
  }
  ll sum=0;
  for(int i=1; i<n+1; i++) {
    sum += b[i]*(b[i]-1)/2;
  }
  for(int i=0; i<n; i++) {
    ll res = sum;
    res -= b[a[i]]*(b[a[i]]-1)/2;
    b[a[i]]--;
    res += b[a[i]]*(b[a[i]]-1)/2;
    cout<<res<<endl;
    b[a[i]]++;
  }
}

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

main() {
  int N, M; cin >> N >> M;
  vector<int> tree(N, 0);
  for (int i = 0; i < M; i++) {
    int a, b; cin >> a >> b;
    if (a != 0) tree[a]++;
    if (b != 0) tree[b]++;
  }
  bool ans = true;
  for (int i = 1; i < N; i++) {
    if (tree[i] % 2) ans = false;
  }
  cout << ( (ans) ? "YES" : "NO" ) << endl;
}


Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


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

class DColoringEdgesOnTree {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        vector<vector<int>> ab(n);
        map<pair<int,int>,int> m;
        vector<pair<int,int>> e(n-1);
        rep(i,n-1){
            in >> e[i].first >> e[i].second;
            e[i].first--;e[i].second--;
            ab[e[i].first].push_back(e[i].second);
            ab[e[i].second].push_back(e[i].first);
        }
        int ma=0;
        rep(i,n){
            ma=max(ma,(int)ab[i].size());
        }
        vector<bool> f(n,true);
        f[0]=false;
        deque<pair<int,int>> q;
        q.push_back({0,-1});
        while(!q.empty()){
            int node = q.front().first;
            int c=q.front().second;
            q.pop_front();
            for(int i=0;i<ab[node].size();i++){
                if(f[ab[node][i]]){
                    f[ab[node][i]]=false;
                    c++;
                    c%=ma;
                    m[{ab[node][i],node}]=c;
                    q.push_back({ab[node][i],c});
                }
            }
        }
        out << ma << endl;
        rep(i,n-1){
            if(m.find({e[i].first,e[i].second})!=m.end()){
                out << m[{e[i].first,e[i].second}]+1 << endl;
            }else{
                out << m[{e[i].second,e[i].first}]+1 << endl;
            }
        }
	}
};


int main() {
	DColoringEdgesOnTree solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 13184
# ABC075B

import numpy as np

h, w = map(int, input().split())
board = np.reshape(np.array(np.repeat("@", (h+2)*(w+2))), (h+2, w+2))
for i in range(h):
    s = input()
    board[i+1, 1:w+1] = np.array(list(s))
for i in range(1, h+1):
    count = np.zeros(w, dtype=str)
    for j in range(1, w+1):
        if board[i,j] == '.':
            count[j-1] = str(\
                (board[i-1, j-1] == "#") + (board[i-1, j] == "#") + (board[i-1, j+1] == "#") +\
                (board[i  , j-1] == "#") + (board[i  , j] == "#") + (board[i  , j+1] == "#") +\
                (board[i+1, j-1] == "#") + (board[i+1, j] == "#") + (board[i+1, j+1] == "#"))
        elif board[i, j] == "#":
            count[j-1] = "#"
    print(''.join(count))


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

int main()
{
    int a,b,c;
    while(~scanf("%d%d%d",&a,&b,&c))
    {
        int s=0,m;
        m=max(a,max(b,c));
        while(1)
        {
            s=m*3-a-b-c;
            m++;
            if(s%2==0) {printf("%d\n",s/2);break;}
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int N, A[2000]; ll K;
int main() {
  scanf("%d %ld", &N, &K);
  for(int i = 0; i < N; ++i) scanf("%d", &A[i]);
  ll localT = 0LL, localL = 0LL;
  for(int l = 0; l < N-1; ++l) {
    for(int r = l; r < N; ++r) {
      if(A[l] > A[r]) ++localT;
      if(A[l] != A[r]) ++localL;
    }
  }
  ll sum = localT*K%MOD;
  if(K%2 == 0) sum += (K/2*(K-1))%MOD*localL;
  else sum += ((K-1)/2*(K-2)+K-1)%MOD*localL;
  printf("%ld\n", sum%MOD);
}

Measured memory_bytes: 128
n,q = map(int,input().split())
a = list(map(int,input().split()))
query = [int(input()) for i in range(q)]

a = sorted(a)
ruiseki = [0]*(n+1)
for i in range(n):
    ruiseki[i+1] = ruiseki[i] + a[i]
    
ruiseki2 = [0]*(n+1)
if n % 2 == 1:
    for i in range(n):
        if i % 2 == 0:
            ruiseki2[i+1] = ruiseki2[i] + a[i]
        else:
            ruiseki2[i+1] = ruiseki2[i]

if n % 2 == 0:
    for i in range(n):
        if i % 2 == 1:
            ruiseki2[i+1] = ruiseki2[i] + a[i]
        else:
            ruiseki2[i+1] = ruiseki2[i]

def solve(mid, num):
    r = -((-mid) // 2)
    l = mid
    r_pos = n - r
    l_pos = n - l
    if abs(a[l_pos] - num) <= abs(a[r_pos] - num):
        return True
    else:
        return False

for i in range(q):
    num = query[i]
    ok = 1
    ng = n + 1 
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if solve(mid, num):
            ok = mid
        else:
            ng = mid
    ans = 0
    ans += ruiseki[n] - ruiseki[n-(ok+1)//2]
    nokori = n - ok
    ans += ruiseki2[nokori]
    print(ans)

Measured memory_bytes: 76412
a = raw_input()
b = raw_input()
a = list(a)
b = list(b)
n = len(a)
m = len(b)
z = ''
for i in range(n - m + 1):
	flag = True
	for j in range(m):
		if a[i + j] != b[j] and a[i + j] != '?':
			flag = False
	if not flag:
		continue
	c = a[::]
	for j in range(m):
		c[i + j] = b[j]
	for i in range(n):
		if c[i] == '?':
			c[i] = 'a'
	if z == '':
		z = c
	else:
		z = min(z, c)
if z == '':
	print 'UNRESTORABLE'
else:
	print ''.join(z)

Measured memory_bytes: 2696
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<queue>
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 pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 15;
char cn[cm], * ci = cn, ct;
inline int getint() {
	int A = 0;
	while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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

	fread_unlocked(cn, 1, cm, stdin);
	int N = getint(), K = getint(), Q = getint();
	ll A[2002];
	int LR[2002];
	rep1(i, N) A[i] = ((ll)getint() << 16) + i;
	rep(i, N + 2) LR[i] = -1;

	priority_queue<int> q;
	priority_queue<int, vector<int>, greater<int>> q2[2002];
	int q3[2002];
	rep1(i, N) q3[i] = i;
	int kotae = 1e9;
	int saishou = 2e9;
	sort(A + 1, A + N + 1);
	const int m = (1 << 16) - 1;

	for (int i = N; i >= 1; i--) {
		int a = A[i] >> 16;
		int k = A[i] & m;

		int l = (LR[k - 1] == -1) ? k : LR[k - 1];
		int r = (LR[k + 1] == -1) ? k : LR[k + 1];
		LR[l] = r;
		LR[r] = l;

		if (k + k < l + r) swap(q3[l], q3[k + 1]);

		auto L = q2 + q3[l];
		auto R = q2 + q3[k + 1];

		while ((*R).size()) {
			int tmp = (*R).top();
			(*L).push(tmp);
			(*R).pop();
		}
		(*L).push(a);
		while ((*L).size() >= K) {
			int tmp = (*L).top();
			q.push(tmp);
			(*L).pop();
		}
		while (q.size() >= Q) {
			int tmp = q.top();
			chmin(saishou, tmp);
			q.pop();
		}
		chmin(kotae, saishou - a);
	}

	printf("%d", kotae);

	Would you please return 0;
}

Measured memory_bytes: 384
// Tazoe

#include <iostream>
using namespace std;

void eratos(bool prime[], int n)
{
	for(int i=0; i<n; i++){
		prime[i] = false;
	}

	for(int i=0; 7*i<n; i++){
		if(7*i+1<n)
			prime[7*i+1] = true;
		if(7*i+6<n)
			prime[7*i+6] = true;
	}

	if(n>=2)
		prime[1] = false;

	for(int i=2; i<n; i++){
		if(!prime[i])
			continue;

		for(int j=i+i; j<n; j+=i){
			prime[j] = false;
		}
	}
}

int main()
{
	bool P[300000];
	eratos(P, 300000);

	while(true){
		int n;
		cin >> n;

		if(n==1)
			break;

		cout << n << ':';

		for(int i=2; i<=n; i++){
			if(!P[i])
				continue;

			if(n%i!=0)
				continue;

			cout << ' ' << i;
		}

		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1156
#include <stdio.h>

int main(void)
{
    int i, x, no;
    no = 1;
    for (i = 1; i <= 10000; i++)
    {
        scanf("%d", &x);
        if (x == 0)
        {
            break;
        }
        printf("Case %d: %d\n", no++, x);
    }
    return 0;
}


Measured memory_bytes: 2568
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var a = new int[m];
        for (int i = 0; i < n; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            var t = int.Parse(line[0]);
            for (int j = 0; j < t; j++)
                a[int.Parse(line[j + 1]) - 1]++; 
        }
        var ans = a.Count(x => x == n);
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
typedef long long ll;

int memo[1500000];

int main()
{
    int n,m;
    while(cin >> n >> m) {
        if(n == 0 && m == 0) break;
        
        vector<int> H(n),W(m);
        rep(i,n) cin >> H[i];
        rep(i,m) cin >> W[i];

        vector<int> v;
        rep(i,n) {
            int sum = 0;
            REP(j,i,n) {
                sum += H[j];
                v.push_back(sum);
            }
        }

        vector<int> t;
        rep(i,m) {
            int sum = 0;
            REP(j,i,m) {
                sum += W[j];
                t.push_back(sum);
            }
        }

        memset(memo,0,sizeof(memo));
        rep(i,t.size()) {
            memo[t[i]]++;
        }

        int ans = 0;
        rep(i,v.size()) {
            ans += memo[v[i]];
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 27264
/*
 * ITP1_1_D.c
 *
 *  Created on: 2017/05/11
 *      Author: sl2-user
 */
#include<stdio.h>

int main(void){

	int data[10];
	int top[3];
	int temp=0,i;
	for(i=0;i<10;i++){scanf("%d",&data[i]);}
	top[0]=data[0];
	for(i=1;i<10;i++){
		if(top[0]<data[i]){top[2]=top[1];top[1]=top[0];top[0]=data[i];}
		else if(top[1]<data[i]){top[2]=top[1];top[1]=data[i];}
		else if(top[2]<data[i]){top[2]=data[i];}
	}
	printf("%d\n",top[0]);
	printf("%d\n",top[1]);
	printf("%d\n",top[2]);

	return 0;
}

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

int main(){
  int a[50]={1,4,8,9,16,25,27,32,36,49,64,81,100,121,125,128,144,169,196,216,225,243,256,289,324,343,361,400,441,484,512,529,576,625,676,729,784,841,900,961,1000};
  int x;
  cin >> x;
  int ans=0;
  int i=0;
  while(a[i] <= x && i<41){
    ans = a[i];
    i++;
  }
  cout << ans << endl;
}


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

using i64 = int64_t;
template <class T> using Vec = std::vector<T>;
template <class K, class V> using UM = std::unordered_map<K, V>;

using namespace std;

namespace std {
template <>
struct hash<pair<int, int>> {
    size_t operator()(pair<int,int> p) const noexcept {
        return (size_t(p.first) << 18) | (size_t(p.second));
    }
};
}

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

    int n, k, s, t;
    cin >> n >> k >> s >> t;

    Vec<int> as(n);
    for (auto &a : as) cin >> a;

    if ((s & t) != s || (s | t) != t) {
        cout << 0;
        return 0;
    }

    auto invalid = [&](int a) {
        return s != (s & a) || t != (t | a);
    };
    as.erase(remove_if(as.begin(), as.end(), invalid), as.end());

    n = as.size();

    Vec<UM<pair<int, int>, i64>> by_andor(k + 19);
    by_andor[0][{t, s}] = 1;

    for (auto &lvl : by_andor) lvl.reserve(1 << 18);
    int aand, oor;

    for (int i = 0; i < as.size(); ++i) {
        int a = as[i];

        for (int j = min(i, k - 1); j >= 0; --j) {
            auto &next = by_andor[j + 1];

            for (auto &[key, value] : by_andor[j]) {
                tie(aand, oor) = key;
                next[{aand & a, oor | a}] += value;
            }
        }
    }

    i64 ans = 0;
    for (int i = 0; i <= k; ++i) ans += by_andor[i][{s, t}];
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 226800
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int cal(int x1,int y1, int x2, int y2, vector<vector<int>> &grid){
	return grid[y2][x2]-grid[y2][x1]-grid[y1][x2]+grid[y1][x1];
}

int main(){
	int n,k; cin>>n>>k;
	int x,y;
	char c;
	vector<vector<int>> grid(2*k+5,vector<int>(2*k+5,0));
	for(int i=0;i<n;i++){
		cin >> x >> y >> c;
		if(c=='W') x+=k;
		x%=2*k;
		y%=2*k;
		++grid[y+1][x+1];
	}

	int k2=2*k;
	for(int i=1;i<=k2;i++){
		for(int j=1;j<=k2;j++){
			grid[i][j]+=grid[i][j-1];
		}
	}
	for(int i=1;i<=k2;i++){
		for(int j=1;j<=k2;j++){
			grid[i][j]+=grid[i-1][j];
		}
	}
	int ans=0;
	for(int y=1;y<=k2;y++){
		for(int x=1;x<=k2;x++){
			int x1=0,x2=max(0,x-k),x3=x,x4=min(k2,x+k),x5=k2;
			int y1=0,y2=max(0,y-k),y3=y,y4=min(k2,y+k),y5=k2;
			int cnt=cal(x1,y1,x2,y2,grid)+cal(x3,y1,x4,y2,grid)+
					cal(x2,y2,x3,y3,grid)+cal(x4,y2,x5,y3,grid)+
					cal(x1,y3,x2,y4,grid)+cal(x3,y3,x4,y4,grid)+
					cal(x2,y4,x3,y5,grid)+cal(x4,y4,x5,y5,grid);
			ans=max(ans,cnt);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 16000
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long n, k;
long h[100005];
long ans = LINF;

int main(){
    scanf("%ld%ld", &n, &k);
    for(int i = 0; i < n; i++){
        scanf("%ld", h+i);
    }
    std::sort(h, h+n);
    for(int i = 0; i + k - 1 < n; i++){
        ans = std::min(ans, h[i+k-1] - h[i]);
    }
    printf("%ld\n", ans);
}


Measured memory_bytes: 1024
n = gets.to_i
s = gets.chomp

a_ord = "a".ord
z = 1 << (n-1).bit_length

st = Array.new(z << 1, 0)
s.each_char.with_index(z) {|c,i| st[i] = 1 << c.ord - a_ord}
(z-1).downto(1) {|i| st[i] = st[2 * i] | st[2 * i + 1]}

def calc(st, i, j, k, s, t)
    if s <= j && k <= t
        st[i]
    elsif k < s || t < j
        0
    else
        calc(st, 2*i, j, (j+k)/2, s, t) | calc(st, 2*i+1, (j+k)/2+1, k, s, t)
    end
end

gets.to_i.times do
    a, b, c = gets.split
    b = b.to_i

    if a == "1"
        c = 1 << c.ord - a_ord
        next if st[z + b - 1] == c
        st[z + b - 1] = c
        i = (z + b - 1) / 2
        while i != 0
            st[i] = st[2 * i] | st[2 * i + 1]
            i = i / 2
        end
    else
        x = calc(st, 1, 1, z, b, c.to_i)
        y = 0
        while x != 0
            y += 1
            x &= x - 1
        end
        puts y
    end
end

Measured memory_bytes: 11156
#include <bits/stdc++.h>
using namespace std;
#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 fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 1;
//---------------------------------//

ll mod_pow(ll x, ll n, ll mod) {
	if (n == 0) return 1;
	ll res = mod_pow(x * x % mod, n / 2, mod);
	if (n & 1) res = res * x % mod;
	
	return res;
}

vector<ll> fact, inv;
void fact_inv(int n, ll mod) {
	fact.resize(n + 1);
	inv.resize(n + 1);
	
	fact[0] = 1;
	FOR(i, 1, n + 1) fact[i] = fact[i - 1] * i % mod;
	inv[n] = mod_pow(fact[n], mod - 2, mod);
	for (int i = n; i > 0; i--) inv[i - 1] = inv[i] * i % mod;
}

ll ncr(ll n, ll r, ll mod) {
	if (n < r || r < 0 || n < 0) return 0;
	return fact[n] * inv[r] % mod * inv[n - r] % mod;
}

int N, K;

int main() {
	cin >> N >> K;
	
	fact_inv(5000, MOD);
	int B = K, R = N - K;
	
	FOR(i, 1, K + 1) {
		ll ans = ncr(i + R-(i-1), i, MOD);
		ans *= ncr(i-1 + B-i, i-1, MOD);
		ans %= MOD;
		printf("%lld\n", ans);
	}
	
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int n,i,sum = 0,k,j;
   double m,res = 0.0,mm,cnt = 0.0;
   cin>>n>>k;
   int a[n];
   for(i = 0;i < n;i++)
    cin>>a[i];

   vector<double>v;
   for(i = 0;i < n;i++)
   {
       mm = a[i];
       m = ((mm/2.0)*(mm+1))/mm;
     v.push_back(m);

   }
////   for(i = 0;i < v.size();i++)
////    cout<<v[i]<< " ";
//   sort(v.begin(),v.end());
//   for(i = v.size()-1;i > n - k;i--)
//    res+=v[i];

   for(i = 0;i < k;i++)
    res += v[i];

    cnt = max(res,cnt);

    for(i = k,j = 0;i < n;i++,j++)
    {

        res = res + v[i] - v[j];
        cnt = max(res,cnt);
    }
   cout<<fixed<<setprecision(12)<<cnt<<endl;
   return 0;
}


Measured memory_bytes: 4212
#include<iostream>

using namespace std;

int main(){
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;

	if (x >= r&&W >= x + r){
		if (y >= r&&H >= y + r){
			cout << "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3076
/*******************************
Author:Morning_Glory
LANG:C++
Created Time:2019年09月01日 星期日 20时19分43秒
*******************************/
#include <cstdio>
#include <fstream>
#include <algorithm>
using namespace std;
const int maxn = 100005;
//{{{cin
struct IO{
	template<typename T>
	IO & operator>>(T&res){
		res=0;
		bool flag=false;
		char ch;
		while((ch=getchar())>'9'||ch<'0')	 flag|=ch=='-';
		while(ch>='0'&&ch<='9') res=(res<<1)+(res<<3)+(ch^'0'),ch=getchar();
		if (flag)	 res=~res+1;
		return *this;
	}
}cin;
//}}}
int n,ans;
int a[maxn],f[maxn];
int main()
{
	cin>>n;
	for (int i=1;i<=n;++i)	cin>>a[i];
	for (int i=1;i<=n;++i){
		f[i]=1;
		if (i!=1&&a[i]<=a[i-1])	f[i]+=f[i-1];
		ans=max(ans,f[i]);
	}
	printf("%d\n",ans-1);
	return 0;
}


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

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

  rep(i, s.size()) {
    if ((i + 1) % 2 == 0) {
      if (s[i] == 'R') {
        cout << "No" << endl;
        return 0;
      }
    } else {
      if (s[i] == 'L') {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;
  return 0;
}

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

using namespace std;
using   ll=long long;

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define pll				pair<int , int>
#define endl            "\n"

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			998244353

ll mod_pow(ll a,ll b,ll m)
{
    ll res = 1;
    while(b)
    {
        if(b&1)
        {
        	res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

ll mod_inverse(int a , int m)
{
	return mod_pow(a , m - 2 , m);
}

const int maxn = 1e5 + 5;

vector < vector<int> > a(maxn);

int vis[maxn];

void dfs(int u) {
	vis[u] = 1;
	
	for(auto v : a[u]) {
		if(!vis[v]) {
			dfs(v);
		}
	}
}

void solve() {
	int n , m;
	
	cin >> n >> m;
	
	for(int i = 0; i < m; ++i) {
		int x , y;
		
		cin >> x >> y;
		
		a[x].pb(y);
		a[y].pb(x);
	}
	
	int tot = 0;
	
	for(int i = 1; i <= n; ++i) {
		if(!vis[i]) {
			tot++;
			dfs(i);
		}
	}
	
	cout << tot - 1;
}

signed main() {
	fast;
   
    int t = 1;

	//cin >> t;

    while(t--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 9652
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)

using namespace std;



int main()
{
	int A[3],c;
	rep(i, 3) {
		cin >> A[i];
	}
	
	c = abs(A[1] - A[0]);
	c += abs(A[2] - A[1]);
	int ans = c;
	c = abs(A[2] - A[0]);
	c += abs(A[1] - A[2]);
	if (c < ans)ans = c;
	c = abs(A[2] - A[1]);
	c += abs(A[0] - A[2]);
	if (c < ans)ans = c;

	c = abs(A[0] - A[1]);
	c += abs(A[2] - A[0]);
	if (c < ans)ans = c;

	c = abs(A[1] - A[2]);
	c += abs(A[0] - A[1]);
	if (c < ans)ans = c;
	c = abs(A[0] - A[2]);
	c += abs(A[1] - A[0]);
	if (c < ans)ans = c;

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

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

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    int a[n], b[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    int ans = 0;
    for (int i = n - 1; i >= 0; i--) {
        a[i] += ans;
        ans += ((a[i] + b[i] - 1) / b[i]) * b[i] - a[i];
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define B bitset<500>
using namespace std;
int n,m;
int x[200000],y[200000];
bool die[500];
B a[500];
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
        scanf("%d%d",&x[i],&y[i]);
    for(int i=1;i<=n;i++)
    {
        a[i][i]=1;
        for(int j=m;j;j--)
        if(a[i][x[j]] && a[i][y[j]])
        {
            die[i]=1;
            break;
        }
        else
        if(a[i][x[j]])
            a[i][y[j]]=1;
        else
        if(a[i][y[j]])
            a[i][x[j]]=1;
    }
    int ans=0;
    for(int i=1;i<n;i++)
    if(!die[i])
        for(int j=i+1;j<=n;j++)
        if(!die[j] && (a[i]&a[j]).none())
            ++ans;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1024