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

ll k, a[100008];

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> k;
	rep(i, 1, k){cin >> a[i];}
	
	ll ansmin = 2;
	ll ansmax = 2;
	rrep(i, k, 1){
		ll bufmax = a[i]*(ansmax/a[i])+a[i]-1;
		ll bufmin = a[i]*((ansmin+a[i]-1)/a[i]);
		if(bufmin <= bufmax){
			ansmax = bufmax;
			ansmin = bufmin;
		}
		else{
			print(-1)
			return 0;
		}
	}
	
	cout << ansmin << " " << ansmax << endl;
	return 0;
}

Measured memory_bytes: 1024
N, M = map(int, input().split(' '))
H_ls = list(map(int, input().split(' ')))
edge = [ [] for i in range(N) ]
cnt = 0
for i in range(M):
    a,b = map(int, input().split(' '))
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)
for i in range(N):
    is_peak = True
    for j in edge[i]:
        if H_ls[i] <= H_ls[j]:
            is_peak = False
            break
    if is_peak:
        cnt += 1
print(cnt)

Measured memory_bytes: 29368
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int lim = 1e5+7;

int main(){
    int n,cap;
    cin>>n>>cap;
    vector<int> w(n+1,0),v(n+1,0);
    for(int i=1;i<=n;i++){
        cin>>w[i]>>v[i];
    }
    vector<vector<ll>> dp(n+1,vector<ll>(cap+1,0));

    for(int i=1;i<=n;i++){
        for(int j=1;j<=cap;j++){
            dp[i][j]=dp[i-1][j];
            if(j>=w[i]) dp[i][j] = max(dp[i-1][j-w[i]]+v[i], dp[i-1][j]);
        }
    }
    cout<<dp[n][cap];
    return 0;
}


Measured memory_bytes: 80256
#include <stdio.h>

int main(){
  int stack[10];
  int i = 0;
  int in;
  
  while(scanf("%d", &in) != EOF){
    if(in){ //push
      stack[i++] = in;
    }
    else{ //pop
      printf("%d\n", stack[--i]);
    }
  }

  return 0;
}

Measured memory_bytes: 600
import numpy as np
n=int(input())+2
h=np.array([0]+list(map(int, input().split()))+[0])

ans=0
while sum(h)>0:
    l=0
    for r in range(n-1):
        if h[r]==0 and h[r+1]!=0:
            l=r
        if h[r]!=0 and h[r+1]==0:
            water=min(h[l+1 : r+1])
            ans+=water
            h[l+1 : r+1]-=water
    
print(ans)


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

int main() {
  int N, K; string S; cin >> N >> K >> S;

  vector<int> v;
  if(S.at(0) == '1') v.push_back(0);

  char c = S.at(0);
  for (int i = 0; i < N; i++) {
    int cnt = 1;
    while(i + 1 < N) {
      if(S.at(i + 1) == c) {
        i++; cnt++;
      }
      else break;
    }
    v.push_back(cnt);
    if (c == '0') c = '1';
    else c = '0';
  }

  int l = v.size();
  vector<int> b(l + 1, 0);
  for (int i = 0; i < l; i++) b.at(i + 1) = b.at(i) + v.at(i);

  int ans = 0;
  for (int i = 0; i < l; i += 2) {
    if (i == 0) {
      int r = min(l, 2 * K);
      ans = b.at(r);
    } else {
      int r = min(l, i + 2 * K);
      ans = max(ans, b.at(r) - b.at(i - 1));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1272
#include<iostream>
using namespace std;
int main()
{
  int n,i,j,count=0;
  cin>>n;
  int a[n][2];
  for(i=0;i<n;i++)
  {
    for(j=0;j<2;j++)
    {
      cin>>a[i][j];
    }
  }
  for(i=0;i<n-2;i++)
  {
    if(a[i][0]==a[i][1] && a[i+1][0]==a[i+1][1] && a[i+2][0]==a[i+2][1])
    {
      count++;
    }
  }
  if(count<1)
  {
    cout<<"No";
  }
  else
  {
    cout<<"Yes";
  }
}

Measured memory_bytes: 3580
#include <vector>
#include <string>
#include <iostream>

using namespace std;

int main() {
  string s;
  cin >> s;
  int n = (int)s.size();

  if (n <= 2) {
    if (s[0] == s[1]) {
      cout << 1 << " " << 2 << endl;
    } else {
      cout << -1 << " " << -1 << endl;
    }
    return 0;
  }

  s += '1';
  int l = -1;
  int r = -1;
  for (int i = 0; i < n - 1; ++i) {
    if (s[i] == s[i + 1] || s[i] == s[i + 2]) {
      l = i + 1;
      r = l + 2;
    }
    if (l != -1) {
      cout << l << " " << r << endl;
      return 0;
    }
  }
  cout << -1 << " " << -1 << endl;
  return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
const ll MOD=1e9+7;

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

	int N;
	cin >> N;
	int a[N][N];
	FOR(i,0,N)FOR(j,0,N){
		cin>>a[i][j];
	}

	int dp[N+1][(1<<N)]={};

	dp[0][0] = 1;
	FOR(i,0,(1<<N)){
		int j = bitset<32>(i).count();
		FOR(k,0,N){
			if((i&(1<<k))==0 && a[j][k]){
				(dp[j+1][i+(1<<k)]+=dp[j][i])%=MOD;
			}
		}
	}
	cout << dp[N][(1<<N)-1] << endl;

}


Measured memory_bytes: 180480
import numpy as np

N = int(input())
A = list(map(int, input().split()))

count = 1
direction = 0
temp = A[0]
for i in range(1, N):
    diff = A[i] - temp
    if diff != 0:
        if direction == 0:
            direction = np.sign(A[i] - temp)
        else:
            if np.sign(A[i] - temp) != direction:
                count += 1
                direction = 0
    temp = A[i]

print(count)


Measured memory_bytes: 23128
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vll a(n), b(n), c(n-1);
    REP(i, n) cin >> a[i];
    REP(i, n) cin >> b[i];
    REP(i, n-1) cin >> c[i];
    ll ans = b[a[0]-1];
    rep(i, 1, n) {
        ans += b[a[i]-1];
        if (a[i-1]+1 == a[i]) ans += c[a[i-1]-1];
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * 2019/06/09
 * AtCoder Beginner Contest 129
 * 
 * B - Balance
 * 
 * @author rued97
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] Ws = new int[N];
		int sum = 0;
		for(int i = 0; i < N; i++) {
			Ws[i] = sc.nextInt();
			sum += Ws[i];
		}

		int min = Integer.MAX_VALUE;
		int S1 = 0;
		int S2 = 0;
		for(int i = 0; i < N; i++) {
			S1 += Ws[i];
			S2 = sum - S1;
			int sa = S2 - S1;
			if(sa < 0) {
				sa = sa * -1;
				i = N;
			}
			if(sa < min) {
				min = sa;
			} 
		}

		System.out.println(min);
	}
	
}

Measured memory_bytes: 23892
#include <cstdio>
#include <cstring>

const char tbl[][6] = {
  ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"
};

int main() {
  char s[1025], ans[77];
  int n;
  scanf("%d", &n);
  for (int i=0;i<n;i++) {
    scanf("%s", s);
    int ai = 0, tt = -1, ti = -1;
    for (int j=0;s[j]!='\0';j++) {
      if (s[j] == '0') {
        if (tt >= 0) {
          ans[ai++] = tbl[tt][ti];
          tt = ti = -1;
        }
      } else {
        tt = s[j]-'1';
        ti = (++ti)%strlen(tbl[tt]);
      }
    }
    ans[ai] = '\0';
    printf("%s\n", ans);
  }
  return 0;
}

Measured memory_bytes: 2608
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  map<int, int> mp;
  int low = 1e9;
  int high = 0;
  REP(i,n){
    int a;
    cin >> a;
    low = min(low,a);
    high = max(high,a);
    mp[a]++;
  }
  int ans = 0;
  FOR(i,low,high+1){
    ans = max(ans, mp[i-1]+mp[i]+mp[i+1]);
  }
  cout << ans << endl;
  return 0;
}

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

import static java.lang.Integer.*;
import static java.lang.Long.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);

        int x = parseInt(in.readLine());
        if (x == 0) pw.println(1);
        else pw.println(0);
        
        pw.close();

    }
}

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

#define Omar45 ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define pb push_back
#define endl '\n'
#define mod 1000000007
#define maxN 1e5
const int inf=0x3f3f3f3f;

int main() {
	Omar45
    ll n, k, _min=inf;
    cin >> n >> k;
    ll arr[n+5];
    for (int i=0; i<n; i++)
        cin >> arr[i];
    sort (arr, arr+n, greater<int>());
    for (int i = 0; i <= n - k; i++) {
        if (arr[i] - arr[i+k-1] < _min) {
            _min = arr[i] - arr[i+k-1];
        }
    }
    cout << _min;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3

import sys

sys.setrecursionlimit(1000000)

N, M = [int(x) for x in input().split()]

# D[i][j]: Card i has a rel. with card j
D = [[] for i in range(N)]
for i in range(M):
    x, y, z = [int(x) for x in input().split()]
    x -= 1
    y -= 1
    D[x].append(y)
    D[y].append(x)

visited = [False for i in range(N)]
def dfs(n):
    for idx in D[n]:
        if not visited[idx]:
            visited[idx] = True
            dfs(idx)

cnt = 0
for n in range(N):
    if not visited[n]:
        visited[n] = True
        dfs(n)
        cnt += 1
print(cnt)


Measured memory_bytes: 110368
import java.util.*;

public class Main {
  public static void main(String[] args) {    
	Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Set<Integer> arr = new HashSet<>();
    for(int i = 0; i < n; i++) {
      arr.add(sc.nextInt());
    }
    System.out.println(arr.size());
  }
}

Measured memory_bytes: 23764
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mod 1000000007
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long lint;
typedef long long ll;
int qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
int qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e10;
const int MAX_N = 1 << 17;

int main(void) {
	lint n, q; cin >> n >> q;
	vector<pair<lint, pair<lint, lint>>> pos(n);
	for (int i = 0; i < n; i++)
	{
		lint s, t, x; cin >> s >> t >> x;
		pos[i] = mp(x, mp(s - x, t - x - 1));
	}
	sort(all(pos));
	vector<lint> tm(q);
	vector<pair<lint, lint>> ans;
	for (int i = 0; i < q; i++)
	{
		cin >> tm[i];
	}
	for (int i = 0; i < n; i++)
	{
		vector<lint>::iterator it1 = lower_bound(all(tm), pos[i].second.first);
		vector<lint>::iterator it2 = upper_bound(all(tm), pos[i].second.second);
		int j = 0;
		while (true) {
			if (it1 + j == it2) break;
			ans.pb(mp(*(it1 + j), pos[i].first));
			j++;
		}
		tm.erase(it1, it2);
		if (tm.empty()) break;
	}
	for (auto i : tm) {
		ans.pb(mp(i, -1));
	}
	sort(all(ans));
	for (auto i : ans) {
		cout << i.second << endl;
	}
	return 0;
}

Measured memory_bytes: 12528
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define per(i,r,l) for(int i=r;i>=l;i--)
#define IMAX 0x3f3f3f3f
#define LLMAX 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
typedef double db;
inline int read() {
  int x=0,f=1;
  char c=getchar();
  while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
  while(isdigit(c)){x=x*10+c-'0';c=getchar();}
  return x*f;
}
string s;

signed main() {
  cin>>s;
  rep(i,0,s.length()-1){
    if(s[i]=='7'){
      puts("Yes");
      return 0;
    }
  }
  puts("No");
  return 0;
}

Measured memory_bytes: 3612
//26
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  for(int n,m,p;cin>>n>>m>>p,n|m|p;){
    int b[7][7][7]={{{}}};
    int t=-1;
    for(int l=1;l<=p;l++){
      int x,y;
      cin>>x>>y;
      x--;
      y--;
      if(t==-1){
	int z;
	for(z=0;b[z][y][x];z++);
	b[z][y][x]=1+l%2;
	for(int i=0;i<13;i++){
	  int d[][3]={{0,0,1},{0,1,0},{1,0,0},{0,1,1},{1,0,1},{1,1,0},{0,1,-1},{1,0,-1},{1,-1,0},{1,1,1},{1,1,-1},{1,-1,1},{-1,1,1}};
	  int c=1;
	  for(int j=-1;j<=1;j+=2){
	    for(int k=1;;k++){
	      int nz=z+d[i][0]*k*j;
	      int ny=y+d[i][1]*k*j;
	      int nx=x+d[i][2]*k*j;
	      if(nz<0||ny<0||nx<0||n<=nz||n<=ny||n<=nx||b[nz][ny][nx]!=1+l%2)break;
	      c++;
	    }
	  }
	  if(c>=m){
	    t=l;
	  }
	}
      }
    }
    if(t==-1){
      cout<<"Draw"<<endl;
    }else{
      cout<<((t%2)?"Black":"White")<<' '<<t<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1168
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7

ans = 0
for i in range(61):
    n1 = sum([1 for a in A if (a>>i)&1])
    ans += (1<<i)*n1*(N-n1)
    ans %= mod
print(ans)

Measured memory_bytes: 42212
//Author : Prakhar Asaiya
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(ll i=a;i<b;++i)
#define REPN(i,a,b) for(ll i=a;i<=b;++i)
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define ll long long
#define ld long double
const int M=1e9+7;



int main()
{/*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#*/
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  
  	int h1,m1,h2,m2,k;
  	cin>>h1>>m1>>h2>>m2>>k;
  	int t1 = h1*60 + m1;
  	int t2 = h2*60 + m2;
  	int diff = t2-t1;
  	cout<<diff-k<<"\n";
  	


   return 0;
}


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

//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
typedef long long ll;


int main(){
    ll K,A,B,r=0,b=1;
    cin >> K >> A >> B;


    if (A+2>B || K<A+1) cout << K + b << endl;
    else {
        K -= A+1;
        r += B;

        r += K/2*(B-A) + (K+2)%2; 
        //r = K/(A+2)*B + K%(A+2);
        cout << r << endl;
        
    }
    
  }

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

int main()
{
    int a, b, c;

    scanf("%d %d", &a, &b);

    for(int i = 1; i <= 3; i++){
        if(a * b * i % 2 != 0){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");

    return 0;
}


Measured memory_bytes: 256
a = input()
t = list(a)
if t[len(t)-1] == "?":
    t[len(t)-1] = "D"
if t[0] == "?":
    if t[1] == "D" or t[1] == "?":
        t[0] = "P"
    else:
        t[0] = "D"
for i in range(1, len(t)-1):
    if t[i] == "?" and t[i-1] == "P":
        t[i] = "D"
    elif t[i] == "?" and t[i+1] == "D":
        t[i] = "P"
    elif t[i] == "?" and t[i+1] == "?":
        t[i] = "P"
    elif t[i] == "?":
        t[i] = "D"

answer = "".join(t)
print(answer)

Measured memory_bytes: 10976
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
  int h,w;
  cin >> h >> w;
  vector<vector<char>> v(h+2,vector<char>(w+2,'#'));
  rep(i,h){
    rep(j,w){
      cin >> v[i + 1][j + 1];
    }
  }
  rep(i,h+2){
    rep(j,w+2){
      cout << v[i][j];
    }
    cout << "\n";
  }
  
}

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

int main() {
    int K, S;
    cin >> K >> S;
    int ans = 0;
    for (int X = K; X >= 0; X--) {
        for (int Y = K; Y >= 0; Y--) {
            if (X + Y > S) continue;
            if ((S - (X + Y)) > K) continue;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int INF = 0x3f3f3f3f;
const int N = 5000;
#define ll long long
int cmp(int a,int b){
	return a>b;
}	

int main(){
	int  n;
	cin >> n;
	if(n%10 == 7 || n/10%10 ==7 || n/100==7) {
		cout <<"Yes"<<endl;
	}else{
		cout <<"No"<<endl;
	}
	return 0;
}



Measured memory_bytes: 3592
#include <iostream>
#include <vector>

#define N_MAX 100001

using namespace std;

long dist[N_MAX] = {0};

void dfs(int v);

struct edge{
    int to;
    int weight;
};

vector<edge> tree[N_MAX];


int main(){
    int N, K, Q;
    
    cin >> N;
    for(int i = 0; i < N-1; i++){
        int a, b, c;
        cin >> a >> b >> c;
        edge e1, e2;
        e1.to = b;e1.weight = c;
        e2.to = a;e2.weight = c;
        tree[a].push_back(e1);
        tree[b].push_back(e2);
    }
    for(int i = 0; i <= N; i++){
        dist[i] = -1;
    }
    
    cin >> Q >> K;
    dist[K] = 0;
    dfs(K);
    
    //cout << Q << endl;
    for(int i = 0; i < Q; i++){
        int x, y;
        cin >> x >> y;
        //cout << x << endl;
        cout << dist[x] + dist[y] << endl;
    }
}

void dfs(int v){
    //cout << v << endl;
    for(int i = 0; i < tree[v].size(); i++){
        if(dist[tree[v][i].to] == -1){
            dist[tree[v][i].to] = dist[v]+tree[v][i].weight;
            //cout << dist[v]+tree[v][i].weight << endl;
            dfs(tree[v][i].to);
        }
    }
}

Measured memory_bytes: 12800
h,w = map(int,input().split())
lst1 = [list(list(input())) for i in range(h)]

lst2 = [[0 for j in range(w)] for i in range(h)]

def search_of_height_branch(i,j):
    height = 0
    while True:
        if i >= h or lst1[i][j] == "#":
            break
        height += 1
        i += 1
    return height
        
def search_of_width_branch(i,j):
    width = 0
    while True:
        if j >= w or lst1[i][j] == "#":
            break
        width += 1
        j += 1
    return width

def search_of_height():
    flag = 0
    for i in range(w):
        flag = 0
        for j in range(h):
            if lst1[j][i] == "." and flag==0:
                point = search_of_height_branch(j,i)
                lst2[j][i] += point
                flag = 1
            elif lst1[j][i] == ".":
                lst2[j][i] += point
            else:
                flag = 0

def search_of_width():
    flag = 0
    for i in range(h):
        flag = 0
        for j in range(w):
            if lst1[i][j] == "." and flag==0:
                point = search_of_width_branch(i,j)
                lst2[i][j] += point
                flag = 1
            elif lst1[i][j] == ".":
                lst2[i][j] += point
            else:
                flag = 0

if __name__ == "__main__":
    search_of_height()
    search_of_width()
    ans = 0
    for i in range(h):
        ans = max(ans,max(lst2[i]))
    print(ans-1) #交差している点が重複して数えているので-1

Measured memory_bytes: 218376
#include<iostream>
using namespace std;
int main(){
  int a=0,b,c,d,n,h=0,jo,ko,i,p[100]={0};
  cin >> n;
  for(i=0;i<n;i++){
    a=0;
    cin >> jo >> ko;
    h=0;
    while(jo!=ko){
      if(jo == 9 && ko == 5){
	p[h]=jo;
	h++;
	break;
      }
      if(jo == 0 && ko!=0){
	p[h]=jo;
	jo++;
	h++;
	a=0;
      }
      if(jo > ko && jo <6){
	p[h]=jo;
	jo--;
	h++;
      }
      if(jo > ko && jo>=6){
	if(jo <= 9){
	  p[h]=jo;
	  jo++;
	  h++;
	}
	if(jo > 9){
	  jo=5;
	  p[h]=jo;
	  jo--;
	  h++;
	  a=1;
	}
      }
      if(jo < ko && a!=1){
	p[h]=jo;
	jo++;
	h++;
      }
      if(jo < ko && a==1){
	p[h]=jo;
	jo--;
	h++;
      }
    }
    for(d=0;d<h;d++){
      cout << p[d] << " " ;
    }
    cout << ko << endl;
  }
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    string s;
    cin >> s;
    
    int cnt = 0;
    int i = 0, j = s.size() - 1;
    while (i < j) {
        if (s[i] != s[j]) ++cnt;
        ++i, --j;
    }
    
    cout << cnt;
    
    return 0;
}

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

#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define FORW(a, b, c) for(int a = b; a >= c; --a)
#define fi first
#define se second
#define pb push_back
#define int long long

typedef pair<int, int> ii;
typedef pair<int, ii> iii;

const int N = 2e5 + 100;
const int oo = 1e18;
const int mod   = 1e9 + 7;

int n, cost, ans = oo;
int pos[N];

signed main()  {
//    freopen("test.inp", "r", stdin);
//    freopen("test.out", "w", stdout);
    ios_base::sync_with_stdio(false); cout.tie(0);
    cin >> n >> cost;
    FOR(i, 1, n) cin >> pos[i];
    FORW(i, n, 1) pos[i] += pos[i + 1];

    FOR(group, 1, n) {
        int cnt = 1, cur = 0, rig = n;
        while(rig > 0 && cur + group * cost < ans) {
            int lef = max(1ll, rig - group + 1);
            if(cnt == 1) cur = 5 * (pos[lef] - pos[rig + 1]);
            else cur += (2 * cnt + 1) * (pos[lef] - pos[rig + 1]);
            cnt += 1;
            rig = lef - 1;
        }
        ans = min(ans, cur + group * cost);
    }
    cout << ans + cost * n;
}


Measured memory_bytes: 1792
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,m = list(map(int, input().split()))
bs = [None]*m
a = [None]*m
for i in range(m):
    a[i],_ = map(int, input().split())
    c = list(map(int, input().split()))
    b = 0
    for num in c:
        b += 1<<(num-1)
    bs[i] = b
dp = [[float("inf")]*(1<<n) for _ in range(m+1)]
for i in range(m+1):
    dp[i][0] = 0
for i in range(m):
    for j in range(1<<n):
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])
        b = j | bs[i]
        dp[i+1][b] = min(dp[i+1][b], dp[i][j]+a[i])
ans = dp[m][(1<<n)-1]
if ans==float("inf"):
    ans = -1
print(ans)

Measured memory_bytes: 138872
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;


vector<int> G[1<<17];
vector<int> f(1<<17,-1);
vector<P> m(1<<17,mp(0,0));
bool ff;

P dfs(int v,int u,int l,int r,bool k){
    int ll=l,rr=r;
    if(~f[v]){
        if(f[v] < ll || rr < f[v]) ff = true;
        if(k != (f[v]&1)) ff = true;
        ll = f[v];
        rr = f[v];
    }
    for (int i = 0; i < G[v].size(); i++) {
        if(G[v][i] == u) continue;
        P p = dfs(G[v][i],v,ll-1,rr+1,k^1);
        p.sc++,p.fs--;
        if(p.sc < ll || rr < p.fs) ff = true;
        else{
            ll = max(ll,p.fs);
            rr = min(rr,p.sc);
        }
    }
    return m[v] = mp(ll,rr);
}

void dfs1(int v,int u,int s){
    if(m[v].fs <= s+1 && s+1 <= m[v].sc) f[v] = s+1;
    else if(m[v].fs <= s-1 && s-1 <= m[v].sc) f[v] = s-1;
    for (int i = 0; i < G[v].size(); i++) {
        if(G[v][i] == u) continue;
        dfs1(G[v][i],v,f[v]);
    }
}


int main(){
    int n;cin >> n;
    for (int i = 0; i < n-1; i++) {
        int a,b;cin >> a >> b;
        a--,b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    int k;cin >> k;
    P s;
    for (int i = 0; i < k; i++) {
        int v,p;cin >> v >> p;
        v--;
        f[v] = p;
        s = mp(v,p);
    }
    dfs(s.fs,-1,s.sc,s.sc,s.sc&1);
    if(ff){
        puts("No");
        return 0;
    }
    else{
        puts("Yes");
        dfs1(s.fs,-1,s.sc);
        for (int i = 0; i < n; i++) {
            cout << f[i] << endl;
        }
    }
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    string s,t,stst;
    cin >> s >> t;
    rep(i,n){
        stst += s[i];
        stst += t[i];
    }
    cout << stst << endl;
}

Measured memory_bytes: 256
public class Main {

	public void run(java.util.Scanner sc, java.io.PrintStream out) {
		for (;;) {
			final int w = sc.nextInt();
			final int h = sc.nextInt();
			if (w == 0 && h == 0) break ;
			
			final Vertex[][] m = new Vertex[w][h];
			for (int i = 0; i < w; ++i)
			for (int j = 0; j < h; ++j) {
				m[i][j] = new Vertex();
			}
			for (int i = 1; i < w; ++i) {
				if (sc.nextInt() == 0) {
					m[i-1][0].neighbor.add(m[i][0]);
					m[i][0].neighbor.add(m[i-1][0]);
				}
			}
			for (int j = 1; j < h; ++j) {
				for (int i = 0; i < w; ++i) {
					if (sc.nextInt() == 0) {
						m[i][j-1].neighbor.add(m[i][j]);
						m[i][j].neighbor.add(m[i][j-1]);
					}
				}
				for (int i = 1; i < w; ++i) {
					if (sc.nextInt() == 0) {
						m[i-1][j].neighbor.add(m[i][j]);
						m[i][j].neighbor.add(m[i-1][j]);
					}
				}
			}
			
			java.util.Queue<Vertex> lis = new java.util.LinkedList<Vertex>();
			m[0][0].visited = 1;
			lis.add(m[0][0]);
			while (!lis.isEmpty()) {
				final Vertex e = lis.remove();
				for (java.util.Iterator<Vertex> it = e.neighbor.iterator(); it.hasNext(); ) {
					final Vertex n = it.next();
					if (n.visited == 0) {
						n.visited = e.visited + 1;
						lis.add(n);
					}
				}
			}
			
			out.println(m[w - 1][h - 1].visited);
		}
	}
	
	public static void main(String[] args) {
		(new Main()).run(new java.util.Scanner(System.in), System.out);
	}
	
	private static class Vertex {
		public java.util.List<Vertex> neighbor;
		public int visited;
		public Vertex() {
			this.neighbor = new java.util.LinkedList<Vertex>();
			this.visited = 0;
		}
	}

}

Measured memory_bytes: 70864
def f(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: divisors.append(n//i)
    divisors.sort()
    return divisors
print(len([i for i in range(1,int(input())) if(i+1)%2==1 and len(f(i+1))==8]))

Measured memory_bytes: 9380
#include<stdio.h>

int main()

{
    int N,i,remain;

    scanf("%d", &N);

    for(i=0; i<3; i++){

        remain = N%10;
        N = N/10;

        if(remain == 7){
            printf("Yes\n");
            break;
        }

    }

    if(remain != 7){
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 1644
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
d = 0
c = A[0]

for i in range(N):
    d += max(0, c - B[i])
    c = max(0, A[i+1] + min(0, c - B[i]))
            
            
print(sum(A) - (d + c))

Measured memory_bytes: 19244
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef pair<int,int> P;
typedef long long ll;
const int INF = 1001001001;
const ll INFL = 1e17;
const int MOD = 1e9+7;


int main(){
    int n,m;
    cin >> n >> m;
    vector<int> s[n];
    rep(i,m){
        int a,b;
        cin >> a >> b;
        --a; --b;
        s[a].push_back(b);
        s[b].push_back(a);
    }
    vector<int> g(n);
    for(int i=0; i<n; i++) g[i] = i;
    for(int i=0; i<n; i++){
        if(g[i] != i) continue;
        queue<int> que;
        que.push(i);
        while(!que.empty()){
            int x = que.front();
            que.pop();
            for(int j=0; j<int(s[x].size()); j++){
                if(g[s[x][j]] == i) continue;
                g[s[x][j]] = i;
                que.push(s[x][j]);
            }
        }
    }
    vector<int> count(n);
    for(int i=0; i<n; i++){
        count[g[i]]++;
    }
    sort(count.begin(),count.end());
    cout << count[n-1] << endl;
    return 0;
}

Measured memory_bytes: 16268
//abc078_c.cpp
//Sat Feb 24 17:39:06 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
using namespace std;

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

	int totaltime = 0;
	int num = 2<<(m-1);
	int unittime = 1900*m+100*(n-m);

	totaltime = unittime*num;
	cout << totaltime << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <list>
#include <iomanip>

using namespace std;

#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
#define rep(i,a,n) for(Int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(Int (i)=(a); (i)<=(n); (i)++)
const int MAX_N = 1000000;
const Int MAX_N_Int = 1000000000000;

template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}

bool isPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

int Max(int a, int b, int c) {
    int temp = max(a, b);
    return max(temp, c);
}

int Min(int a, int b, int c) {
    int temp = min(a, b);
    return min(temp, c);
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}


Int fact_mod(Int n, Int mod) {
    Int f = 1; repq(i,2,n) f = f * (i % MOD) % MOD;
    return f;
}

// 繰り返し二乗法 (modの世界での累乗)
Int mod_pow(Int x, Int n, Int mod) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return res;
}

// 組み合わせ nCr を求める
Int combination_mod(Int n, Int r, Int mod) {
    if(r > n-r) r = n-r;
    if(r == 0) return 1;
    Int a = 1;
    rep(i, 0, r) a = a * ((n-i) % mod) % mod;
    Int b = mod_pow(fact_mod(r, mod), mod-2, mod);
    return (a % mod) * (b % mod) % mod;
}

int main() {
    //COMinit();
    IOS;
    prec;
    Int a,b,c,n,m,k,x,y=0,ans=1;
    string str,s="",t,u;


    string maps[30][30];
    Int h,w;
    cin>>h>>w;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin>>str;
            if(str=="snuke"){
                char qq='A'+j;
                cout<<qq<<i+1<<endl;
            }
        }
    }





    cout<<endl;
    return 0;
}




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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

const double PI = acos(-1);
#define MOD 1000000007  ///1e9+7

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) abs((a)*(b))/gcd((a),(b))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

///******************************** C o d e ********************************///

void _case(){
    string a,b;
    cin>>a>>b;
    b.pop_back();
    if(a==b) cout<<"Yes" el;
    else cout<<"No" el;
}

main()
{
    _case();

}



///Thank you.



///Brainless_Loco Terminates Here!


Measured memory_bytes: 3572
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true){
			String[] sc = stdIn.nextLine().split(" ");
			if(Integer.parseInt(sc[0])==0){
				return;
			}
			int[] card = new int[sc.length];
			for(int i=0;i<sc.length;i++){
				card[i] = Integer.parseInt(sc[i]);
				if(card[i]>10){
					card[i] = 10;
				}
				else if(card[i]==1){
					card[i] = 11;
				}
			}
			int sum = 0;
			int c11 = 0;
			for(int i=0;i<sc.length;i++){
				sum += card[i];
				if(card[i]==11){
					c11++;
				}
			}
			if(sum<=21){
				System.out.println(sum);
			}
			else if(c11<1){
				System.out.println("0");
			}
			else{
				boolean flag = true;
				for(int i=0;i<c11;i++){
					sum -= 10;
					if(sum<=21){
						System.out.println(sum);
						flag = false;
						break;
					}
				}
				if(flag){
					System.out.println("0");
				}
			}
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, m;
    cin >> n >> m;
    VVI a(m);
    REP(i,m){
        int x = in();
        REP(j,x) a[i].push_back(in() - 1);
    }
    VI p(m);
    REP(i,m) p[i] = in();

    int ans = 0;
    REP(mask,1<<n){
        bool f = true;
        REP(i,m){
            int cnt = 0;
            for (int x : a[i]){
                if ((mask >> x) & 1) cnt ^= 1;
            }
            if (cnt != p[i]) f = false;
        }
        ans += f;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fats ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
    fats;
    ll a,b,c,k;cin>>a>>b>>c>>k;
    while(b<=a && k>0)
    {
        b=b*2;
        k--;
    }
    while(c<=b && k>0)
    {
        c=c*2;
        k--;
    }
    if(c>b && b>a)cout<<"Yes";
    else cout<<"No";
    // cout<<c<<b<<a;
}

Measured memory_bytes: 3636
def check_month(month):
    return 1 <= int(month) <= 12

S = input()

ls = S[:2]
rs = S[2:]

if check_month(ls) and check_month(rs):
    print('AMBIGUOUS')
elif check_month(ls) and not check_month(rs):
    print('MMYY')
elif not check_month(ls) and check_month(rs):
    print('YYMM')
else:
    print('NA')

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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n-1; i > 0; i--)
#define FOR(i, n, m) for(int i = n; i < (int)(m); i++)
#define PRINT(x) cout << x << endl
#define ALL(v) v.begin(), v.end()
#define INF (ll)1e18
#define PI 3.14159265358979

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

ll MOD = 1000000007;

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

    vector<ll> A(N);
    REP(i, N) cin >> A[i];
    vector<vector<ll>> dp(N+1, vector<ll>(3,0));
    REP(i, N) {
        REP(j, 3) {
            if (dp[i][j] == A[i]) {
                dp[i+1][j] = dp[i][j] + 1;
                break;
            }
        }
        REP(j, 3) {
            if (dp[i+1][j] == 0) dp[i+1][j] = dp[i][j];
        }
    }
    ll ans = 1;
    REP(i, N) {
        ll cnt = 0;
        REP(j, 3) {
            if (A[i] == dp[i][j]) {
                cnt++;
            }
        }
        ans *= cnt;
        ans %= MOD;
    }
    PRINT(ans);
    return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<algorithm> 
#include<vector>
using namespace std;
int dp[100000][3];
int main()
{
	int n;
	cin>>n;
	int a[n][3];
	for(int i = 0; i < n; i++)
	cin>>a[i][0]>>a[i][1]>>a[i][2];
	dp[0][0]=a[0][0];
	dp[0][1]=a[0][1];
	dp[0][2]=a[0][2];
	for(int i =1;i < n; i++)
	{
		for(int j = 0; j < 3; j++)
		{
			if(j>0)
			{
				dp[i][j]=max(dp[i-1][j-1]+a[i][j],dp[i][j]);
			}
			if(j<2)
			{
				dp[i][j]=max(dp[i][j],dp[i-1][j+1]+a[i][j]);
			}
			if(j==0)
			{
				dp[i][j]=max(dp[i-1][j+2]+a[i][j],dp[i][j]);
			}
			if(j==2)
			{
				dp[i][j]=max(dp[i-1][j-2]+a[i][j],dp[i][j]);
			}
		}
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	return 0;
 } 

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

#define MAX_N 100
#define MAX_K 100000

int n,k;
int a[MAX_N];
int dp[2][MAX_K + 1];

int rec(int turn, int k){
    if(dp[turn][k] != -1) return dp[turn][k];
    if(k < a[0]) return dp[turn][k] = !turn;
    if(turn){
        REP(i,n){
            if(k - a[i] < 0) continue;
            if(rec(!turn, k - a[i])) return dp[turn][k] = 1;
        }
        return dp[turn][k] = 0;
    }else{
        REP(i,n){
            if(k - a[i] < 0) continue;
            if(!rec(!turn, k - a[i])) return dp[turn][k] = 0;
        }
        return dp[turn][k] = 1;
    }
}

signed main(){
    cin >> n >> k;
    REP(i,n){
        cin >> a[i];
    }
    memset(dp, -1, sizeof(dp));
    if(rec(true, k) == 1) cout << "First" << endl;
    else cout << "Second" << endl;
    return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,e) for(int (i)=s;(i)<(e);++i)
#define mrep(i,s,e) for(int (i)=s;(i)>(e);--i)
typedef long long ll;
const ll INF=1e18,MOD=1e9+7;
const int iINF=1e9;
int main(){
    int n;
    cin>>n;
    vector<int>d(n);
    for(int i=0;i<n;i++)cin>>d[i];
    sort(d.begin(),d.end());
    cout<<d[n/2]-d[n/2-1]<<endl;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<(int)(n);i++)
#define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ZERO(a) memset(a,0,sizeof(a))
#define len(a) sizeof(a)
#define ll long long
#define pii pair<int,int>
#define INF 1<<29
#define MAX 3333
using namespace std;

int x[MAX],y[MAX];

void solve(){
 int n;
 for(;;){
  cin>>n;
  if(!n) break;
  FOR(i,n) cin>>x[i]>>y[i];
  set<pii> st;
  FOR(i,n) st.insert(mp(x[i],y[i]));
  int ma=0;
  FOR(i,n){
   FORR(j,i+1,n){
    pii v(x[j]-x[i],y[j]-y[i]),p(x[i]+v.second,y[i]-v.first),q(x[j]+v.second,y[j]-v.first),r(x[i]-v.second,y[i]+v.first),s(x[j]-v.second,y[j]+v.first);
    if((st.find(p)!=st.end()&&st.find(q)!=st.end())||(st.find(r)!=st.end()&&st.find(s)!=st.end())){
     ma=max(ma,v.first*v.first+v.second*v.second);
    }
   }
  }
  cout<<ma<<endl;
 } 
}

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

Measured memory_bytes: 1360
#include<iostream>
#include<vector>
#include<string>

using pix = std::vector<std::string>;

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

    // 左上の位置(x, y)を決める
    for(int x = 0; x + M <= N; x++){
        for(int y = 0; y + M <= N; y++){
            // 探索開始
            bool flag = true;
            for(int i = 0; i < M; i++){
                for(int j = 0; j < M; j++){
                    if(A[i + x][j + y] != B[i][j]){
                        flag = false;
                        break;
                    }
                }

                if(!flag) break;
            }

            if(flag){
                std::cout << "Yes" << std::endl;
                return 0;
            }
        }
    }

    std::cout << "No" << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <climits>

using namespace std;


struct card {
    char suit;
    unsigned long num;
    int i;
};


int partition(card A[], int l, int r)
{
    card pivot = A[r - 1];
    int i, j;
    for(i = j = l; i < r - 1; i++) {
        if (A[i].num <= pivot.num) {
            card tmp = A[i];
            A[i] = A[j];
            A[j++] = tmp;
        }
    }
    A[r - 1] = A[j];
    A[j] = pivot;
    return j;
}


void quick_sort(card A[], int l, int r)
{
    if (r - l > 1) {
        int pivot_index = partition(A, l, r);
        quick_sort(A, l, pivot_index);
        quick_sort(A, pivot_index + 1, r);
    }
}

int main()
{
    int n;
    char ch;
    unsigned long v;
    card qcards[100000];

    scanf("%d", &n);
    getchar();
    for (int i = 0; i < n; i++) {
        scanf("%c", &ch);
        scanf("%lu", &v);
        getchar();

        qcards[i].suit = ch;
        qcards[i].num = v;
        qcards[i].i = i;
    }

    quick_sort(qcards, 0, n);

    int i;
    for (i = 0; i < n; i++)
        if (qcards[i - 1].num == qcards[i].num && qcards[i - 1].i > qcards[i].i)
            break;

    if (i == n)
        printf("Stable\n");
    else
        printf("Not stable\n");

    for (i = 0; i < n - 1; i++) {
        printf("%c %lu\n", qcards[i].suit, qcards[i].num);
    }
    printf("%c %lu\n", qcards[n - 1].suit, qcards[n - 1].num);
}


Measured memory_bytes: 5492
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

#define int long long
#define double long double

typedef pair<int, int> P;
typedef tuple<int, int, int> T;

template<class T> string tostr(T x) { stringstream o; o << x; return o.str(); }
template<class T> T sqr(T x) { return x*x; }
template<class T> T mypow(T x, int n) { T r = 1; while (n > 0) { if (n & 1)r = r*x; x = x*x; n >>= 1; }return r; }

int toint(string s) { int v; stringstream i(s); i >> v; return v; }
bool check(int x, int y, int w, int h) { return x >= 0 && y >= 0 && w > x && h > y; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

#define REP(i,a,b)	for(int (i) = (a);i < (b);(i)++)
#define rep(i,n)	REP(i,0,n)
#define PER(i,a,b)	for(int (i) = (a-1);i >= (b);(i)--)
#define per(i,n)	PER(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define dump(val) 	cerr << #val " = " << val << endl;
#define dum(val)	cerr << #val " = " << val;
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

const int dx[8] = { +1,+0,-1,+0,+1,+1,-1,-1 };
const int dy[8] = { +0,-1,+0,+1,-1,+1,-1,+1 };
const int mod = 1e9 + 7;
const int INF = 1e17 + 9;

signed main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	string s;
	cin >> s;

	int l = INF, r = 0;

	rep(i, s.size()) {
		if (s[i] == 'A') {
			l = min(l, i);
		}
		if (s[i] == 'Z') {
			r = max(r, i);
		}
	}

	cout << r - l + 1 << endl;

	return 0;
}

Measured memory_bytes: 720
#include <cstdio>
#include <string>
#include <iostream>

using namespace std;

int main() {
    int h, w;
    scanf("%d %d", &h, &w);
    string input[200];
    for (int i = 0; i < 2 * h; i+=2) {
        cin >> input[i];
        input[i+1] = input[i];
    }
    for (int i = 0; i < 2*h; i++) {
        cout << input[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
A, B, C, D = (int(x) for x in input().split())
MOD = 998244353
dp = [[0] * (D + 1) for _ in range(C + 1)]
dp[A][B] = 1
for i in range(A, C + 1):
    for j in range(B, D + 1):
        if i == A and j == B:
            continue
        if i > A:
            dp[i][j] += dp[i - 1][j] * j
        if j > B:
            dp[i][j] += dp[i][j - 1] * i
        if i > A and j > B:
            dp[i][j] -= dp[i - 1][j - 1] * (i - 1) * (j - 1)
        dp[i][j] %= MOD

print(dp[C][D])


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }

int main() {
    int A, B;
    cin >> A >> B;
    cout << 6 - A - B << endl;
    return (0);
}

Measured memory_bytes: 256
<?php
function isPrime( $x )
{
    if( 2 == $x ) return true;
    if( 0 == $x%2 ) return false;
    for( $i=3; $i*$i<=$x; $i++ ) {
        if( 0 == $x%$i ) { return false; }
    }
    return true;
}
	$n = trim( fgets( STDIN ) );
	$cnt = 0;
	$primes = [];
	while( $n-- ) {
		$num = trim( fgets( STDIN ) );
		if(  FALSE !== array_search( $num, $primes ) || isPrime( $num ) ) {
			array_push( $primes, $num );
			$primes = array_unique( $primes );
			$cnt++;
		}
	}
	print $cnt;
?>

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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define pli pair<long long,int>
#define pil pair<int,long long>
#define ll long long
#define el '\n'

using namespace std;

int n;
string s;

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

    cin >> s;
    n = s.length();
    for (int i=0;i<n;i++){
        if (s[i] == '?') s[i] = 'D';
    }
    cout << s << el;

    return 0;
}

Measured memory_bytes: 3736
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (unsigned int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    int A,B,C,D;
    string S,T;
int main(){
    cin>>S;
    A=700;
    for(auto x:S){
        if(x=='o')A+=100;
    }
    cout<<A;
    return 0;

}


Measured memory_bytes: 256