akhauriyash/Code-Regression huggingface dataset:
// warm heart, wagging tail,and a smile just for you!
//
//                            ▒█████▒▒
//                             ██████████▒
//                             ▒████████████▒
//                            ██████████████████
//                           ████████████████████▒
//                          ▒██████████████████████▒
//                          ▒███████████████████████
//                      ▒████▒▒▒▒▒▒█████████████████▒
//                    ███▒▒▒▒▒▒██████████████████████▒▒▒
//                  ▒██▒▒███████████████████████▒▒▒▒▒██████
//                 ▒█████████████████████████▒▒▒▒▒▒█████████▒
//                 ▒█████████████████████▒▒▒▒▒▒██████████████
//                  ▒████         ████▒▒▒▒▒████         ████▒
//              ▒█████▒    ████    ▒▒▒▒███████    ████    ██████▒
//            ▒██▒▒▒▒▒    ██████    █████████    ██████    ██▒▒▒██▒
//           █████████   ████████   █████████   ████████   ▒▒▒▒█████
//          ▒█████████    ██████    ████████▒    ██████    █████████
//          ▒██████████    ████    █████▒▒▒▒▒▒    ████    ██████████
//           ████████████        ▒▒▒▒▒▒▒████████        ███████████▒
//       ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
//     ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
//   ▒▒▒▒▒▒▒▒▒██████████████                         ███████▒▒▒▒███████████
//   █████████████████████████                     ███████▒▒▒██████████████▒
//   █████████████████████████████             ███████▒▒▒██████████████████▒
//   ██████████████████████████████████████████████████████████████████████
//    ██████████████████████████████████████████████████████████████████▒
//      ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n;
  cin >> n;

  cout << n*n*n << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

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

	if(s[2] == s[3]  && s[4] == s[5]){
		cout << "Yes" << endl;
		return 0;
	}else{
		cout << "No" << endl;
	}



  return 0;
}


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

int n;
int sum=0;

int main(){
	cin >> n;
	int v[n];
	int c[n];
	
	for(int i=0; i<n; ++i){
		cin >> v[i];
	}
	for(int i=0; i<n; ++i){
		cin >> c[i];
	}
	
	for(int i=0; i<n; ++i){
		if(v[i]-c[i]>0){
			sum+= v[i]-c[i];
		}
	}
	
	cout << sum;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <sstream>
using namespace std;

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

vector<string> split(const string &str, const string &delim = " ") {
	int start = 0, pos;
	vector<string> result;
	
	while ( (pos = str.find_first_of( delim, start) ) != string::npos ) {
		if (pos - start != 0)
			result.push_back( str.substr( start, pos - start) );
		start = pos + 1;
	}

	return result;
}

int main(void) {
	int N;
	cin >> N;
	cin.ignore();
	for (int i = 0; i < N; i++){
		string str;
		getline(cin, str);

		vector<string> strs = split(str, "0");
		string res = "";
		for (int i = 0; i < strs.size(); i++) {
			int index1 = strs[i][0] - '0' - 1;
			int index2 = (strs[i].size() - 1) % CHAR_SET[index1].size();
			res += CHAR_SET[index1][index2];
		}

		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 1220
import java.util.Scanner;

/**
 * Created by zhangrunfeng on 2/17/20
 */
public class Main {

    private final int M = 1046527;
    private int N;
    private Scanner sc;

    private String[] hashTable = new String[M];

    private int getCharInt(char c) {
        if (c == 'A') {
            return 1;
        } else if (c == 'C') {
            return 2;
        } else if (c == 'G') {
            return 3;
        } else if (c == 'T') {
            return 4;
        } else {
            return 0;
        }
    }

    private long getKey(String str) {
        long sum = 0, p = 1;
        for (int i = 0; i < str.length(); i++) {
            sum += p * getCharInt(str.charAt(i));
            p *= 5;
        }
        return sum;
    }

    private int h1(long key) {
        return (int) key % M;
    }

    private int h2(long key) {
        return (int)(1 + (key % (M - 1)));
    }

    public Main(Scanner sc) {
        this.sc = sc;
    }

    private boolean insert(String str) {
        long key = getKey(str);
        for (int i = 0; i < M; i++) {
            int h = (h1(key) + i * h2(key)) % M;
            if (hashTable[h] == null) {
                hashTable[h] = str;
                return true;
            } else if (hashTable[h] != null && hashTable[h].equals(str)) {
                return true;
            }
        }
        return false;
    }

    private boolean find(String str) {
        long key = getKey(str);
        for (int i = 0; i < M; i++) {
            int h = (h1(key) + i * h2(key)) % M;
            if (hashTable[h] == null) {
                return false;
            } else if (hashTable[h] != null && hashTable[h].equals(str)) {
                return true;
            }
        }
        return false;
    }

    public void hashTableProcess() {
        N = sc.nextInt();
        for (int i = 0; i < N; i++) {
            String order = sc.next();
            String str = sc.next();
            if (order.equals("insert")) {
                insert(str);
            } else if (order.equals("find")) {
                boolean res = find(str);
                if (res) {
                    System.out.println("yes");
                } else {
                    System.out.println("no");
                }
            }
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.hashTableProcess();
    }
}


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

bool isPrime(int n) {
  if (n == 2)
    return true;
  for (int div = 2; div <= (int)ceil(sqrt(n)); div++) {
    if (n % div == 0)
      return false;
  }
  return true;
}

int main(void) {
  int x;
  cin >> x;
  // The smallest prime number greater than 10^5 is 100003
  for (int n = x; n <= 100003; n++) {
    if (isPrime(n)) {
      cout << n << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define eps 1e-10
#define ll long long
using namespace std;

ll a, b, x;

int main()
{
    cin >> a >> b >> x;
    if(a*a*b >= x*2){
        double l = 0, r = (double) a, mid, s, ans = -1;
        while(r-l > eps){
            mid = (l+r)/2;
            s = mid*(double) b*a/2;
            if(s-1.0*x > eps) r = mid;
            else l = mid, ans = mid;
        }
        ans = atan((double) b/ans)*180.0/M_PI;
        printf("%.10lf", ans);
        return 0;
    }
    double V = a*a*b;
    double l = 0, r = (double)b, mid, s, ans = -1;
    while(r-l > eps){
        mid = (l+r)/2;
        s = mid*(double)a*a/2;
        if(V-s-1.0*x > eps) l = mid;
        else r = mid, ans = mid;
    }
    ans = atan((double) ans/a)*180.0/M_PI;
    printf("%.10lf", ans);

    return 0;
}


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

int main(){
    int n,d,x;
    cin >> n >> d >> x;
    vector<vector<int> > p(d+1,vector<int>(n));
    for(int i=0;i<d;i++){
        for(int j=0;j<n;j++){
            cin >> p[i][j];
        }
    }
    int ans = x;
    for(int i=0;i<d-1;i++){
        vector<int> dp(100010,0);
        dp[0] = ans;
        for(int j=0;j<n;j++){
            if(p[i][j]>p[i+1][j])continue;
            for(int k=0;k<=ans-p[i][j];k++){
                if(dp[k]!=0){
                    dp[k+p[i][j]] =max(dp[k]+p[i+1][j]-p[i][j],dp[k+p[i][j]]);
                }
            }
        }
        int zzz = ans;
        for(int i=0;i<=zzz;i++){
            ans = max(ans,dp[i]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3552
#include<iostream>
#include<algorithm>
using namespace std;
#define INF 2147483647
int tree[262144];

void update(int x,int i){
  i+=(131072-1);
  tree[i]=x;
  while(i){
    i=(i-1)/2;
    tree[i]=min(tree[i*2+1],tree[i*2+2]);
  }
}

int find(int a,int b,int n,int l,int r){
  if(r<=a  || l>=b) return INF;
  if(a<=l && r<=b) return tree[n];
  int m=(l+r)/2;
  return min(find(a,b,n*2+1,l,m),find(a,b,n*2+2,m,r));
}

int main(){
  int n,q,a,b,c;
  cin>>n>>q;
  for(int i=0;i<n;i++) update(INF,i);
  for(int i=0;i<q;i++){
    cin>>a>>b>>c;
    if(a==1){
      cout<< find(b,c+1,0,0,131072)<<endl;
    }
    else update(c,b);
  }
  return 0;
}


Measured memory_bytes: 3888
use proconio::input;

fn main() {
    input! {
        r: i64,
        g: i64,
        b: i64,
        m: i64,
    }

    // let mut solve = Solve { a, b, c, k };
    let mut ok = false;
    for i in 0..=m {
        for j in 0..=(m - i) {
            for k in 0..=(m - i - j) {
                let r = r * 2i64.pow(i as u32);
                let g = g * 2i64.pow(j as u32);
                let b = b * 2i64.pow(k as u32);

                if g > r && b > g {
                    ok = true;
                    // dbg!(i, j, k, r, g, b);
                }
            }
        }
    }

    if ok {
        println!("Yes");
    } else {
        println!("No");
    }
}

// struct Solve {
//     a: i64,
//     b: i64,
//     c: i64,
//     k: i64,
// }

// impl Solve {
//     fn dfs() {

//     }
// }


Measured memory_bytes: 2188
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	lint n,a,b;
	cin>>n>>a>>b;
	if(abs(a-b)%2==1){
		cout<<min({n-a,n-b,a-1,b-1})+1+(abs(a-b)-1)/2<<endl;
	}else{
		cout<<abs(a-b)/2<<endl;
	}
}

Measured memory_bytes: 256
n=int(input())
list=[]
for i in range(n):
    s, p=input().split()
    list.append([s, int(p), i+1])
list.sort(key=lambda x:x[1], reverse=True)
list.sort(key=lambda x:x[0])

for i in range(n):
    print(list[i][2])


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

int main(){
        double N, M, S = 0;
        vector<double> A;
        cin >> N >> M;
        for(int i = 0; i < N; i++){
                int t;
                cin >> t;
                S += t;
                A.push_back(t);
        }
        sort(A.begin(), A.end());
        reverse(A.begin(), A.end());

        double L = S / (4 * M);
        for(int i = 0; i < M; i++){
                if( L > A[i]){
                        cout << "No" << endl;
                        return 0;
                }
        }
        cout << "Yes" << endl;
        return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

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

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

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

int main()
{
    start();
    int n;
    cin>>n;
    if (n==1)
    {
        cout<<1;
        return 0;
    }
    int m=-1;
    for (int i=2;i*i<=n;i++)
    {
        for (int j=2;pow(i, j)<=n;j++)
        {
            // cout<<i<<" "<<j<<" "<<pow(i, j)<<"\n";
            m=max(m, (int)pow(i, j));
        }
    }
    cout<<m;
    return 0;
}

Measured memory_bytes: 4048
N=gets.to_i
HONESTS={}
UNKINDS={}
(1..N).each do |n|
    honests = [n]
    unkinds = []
    a=gets.to_i
    a.times do
        x,y=gets.chomp.split(" ").map(&:to_i)
        if y == 1
            honests.push(x)
        else
            unkinds.push(x)
        end
    end
    HONESTS[n] = honests
    UNKINDS[n] = unkinds
end
ret = 0
(0..(2**N-1)).each do |bits|
    honests = []
    unkinds = []
    (1..N).each do |n|
        if bits % 2 == 0
            honests.push(n)
        else
            unkinds.push(n)
        end
        bits/=2
    end
    r = honests.length
    next if r <= ret
    all_honests = honests.map {|h| HONESTS[h] }.flatten.uniq
    all_unkinds = honests.map {|u| UNKINDS[u] }.flatten.uniq
    if (all_honests & all_unkinds).empty? && all_honests.length == honests.length
        ret = r
    end
end
puts ret


Measured memory_bytes: 15956
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列


    if N>=30:
        print('Yes')
    else:
        print('No')



if __name__ == "__main__":
    main()


Measured memory_bytes: 77424
#include <stdio.h>

int main (void) {
  int n, i, ans;
  int p[20];

  scanf ("%d", &n);

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

  for (i = 1; i < n-1; i++) {
    if (p[i] > p[i-1] && p[i] < p[i+1]) {
      ans++;
    } else if (p[i] < p[i-1] && p[i] > p[i+1]) {
      ans++;
    }
  }

  printf ("%d", ans);
  
}

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

int main() {
  int N, M, X; // N冊の参考書、M個のアルゴリズム、理解度X
  cin >> N >> M >> X;
  vector<vector<int>> A(N, vector<int>(M));
  vector<int> kingaku(N);
  for (int i = 0; i < N; i++) {
    cin >> kingaku[i];
    for (int j = 0; j < M; j++) {
      cin >> A.at(i).at(j);
    }
  }
  int resultSmall = -1;
  for (int tmp = 0; tmp < (1 << 12); tmp++) {
    bitset<12> s(tmp);
    int count = 0;
    vector<int> rikaido(M, 0);
    //if (s.test(N)) break;

    for (int i = 0; i < N; i++) {
      if (s.test(i)) {
        count += kingaku[i];

        for (int j = 0; j < M; j++) {
          rikaido[j] += A.at(i).at(j);
        }
      }
    }
    bool flag = true;

    for (int i = 0; i < M; i++) {
      if (rikaido[i] < X) {
        flag = false;
        break;
      }
    }
    if (flag) {
      if (resultSmall == -1) {
        resultSmall = count;
      } else {
        resultSmall = min(resultSmall, count);
      }
    }
  }
  cout << resultSmall << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
const long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//constexpr ll P = 1e9 + 7;
	//constexpr ll P = 998244353;

	ll x;
	cin >> x;
	if (x >= 30) Yes();
	else No();
}

Measured memory_bytes: 3648
n = int(input())


def divisor(num):
    cnt = 0
    for i in range(1, num + 1):
        if num % i == 0:
            cnt += 1
    return cnt

divcnt = 0
for i in range(1, n + 1, 2):
    if divisor(i) == 8:
        divcnt += 1

print(divcnt)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;

ll n, a, ans, M=1e9+7, s[100005]={0,1};

ll pow(ll p, ll q) {
	ll re=1;
	for(; q; q>>=1) {
		if(q&1) re = re * p % M;
		p = p * p % M;
	}
	return re;
}

int main() {
	ll i;
	cin >> n;
	for(i=2; i<=n; i++) s[i] = (s[i-1] + pow(i, M-2)) % M;
	for(i=1; i<=n; i++) {
		scanf("%lld", &a);
		ans += a * ((s[i] + s[n-i+1] - 1 + M) % M) % M;
	}
	for(i=1; i<=n; i++) (ans *= i) %= M;
	cout << ans;
	return 0;
}

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

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

  int h,w;
  cin>>h>>w;
  char s[h][w];
  string ss;
  for(int i=0; i<h; ++i){
    cin>>ss;
    for(int j=0; j<w; ++j){
      s[i][j] = ss[j];
    }
  }

  bool isis_ok = true;
  for(int i=0; i<h; ++i){
    for(int j=0; j<w; ++j){

      if( s[i][j] == '#'){
        bool is_ok = false;
        if( i-1 >= 0 and s[i-1][j] == '#'){ is_ok = true;}
        if( i+1 <h   and s[i+1][j] == '#'){ is_ok = true;}
        if( j-1 >= 0 and s[i][j-1] == '#'){ is_ok = true;}
        if( j+1 <w   and s[i][j+1] == '#'){ is_ok = true;}
        if( is_ok == false){
          isis_ok = false;
          break;
        }
      }
    }
  }
  if( isis_ok == true){cout<<"Yes\n"; }
  else { cout<<"No\n"; }
  return 0;
}


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

int p[10000];

int root( int n ) {
	if ( p[n] != n )
		p[n] = root( p[n] );
	return p[n];
}

void unit( int x, int y ) {
	p[root( y )] = root( x );
}

void same( int x, int y ) {
	if ( root( x ) == root( y ) )
		cout << 1 << endl;
	else
		cout << 0 << endl;
}

int main() {
	int n, q, com, x, y;
	cin >> n >> q;
	for ( int i = 0; i < n; i++ )
		p[i] = i;
	for ( int i = 0; i < q; i++ ) {
		cin >> com >> x >> y;
		if ( com == 0 )
			unit( x, y );
		else
			same( x, y );
	}
}

Measured memory_bytes: 1200
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int n, s, c;
int main() {
	cin >> n;
	c = n;
	while (c) s += c % 10, c /= 10;
	cout << (n % s == 0 ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;

    set<int> st;
    reps(i, 1, 10){
        reps(j, 1, 10){
            st.insert(i*j);
        }
    }

    if(st.find(n) == st.end()){
        cout << "No";
    }
    else{
        cout << "Yes";
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    long long A{}, B{}, C{}, K{};
    cin >> A >> B >> C >> K;
    long long sum{};
    if (K > A){
       sum += A;
        K -= A;
        if(K > B){
            K -= B;
            sum -= K;
        }
    }else{
        sum += K;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3156
import sys
from sys import stdin
def I():
    return stdin.readline().rstrip()
def MI():
    return map(int,stdin.readline().rstrip().split())
def LI():
    return list(map(int,stdin.readline().rstrip().split()))
#main part
k=int(I())
s='ACL'
ans=''
for i in range(k):
    ans=ans+s
print(ans)
                

Measured memory_bytes: 9148
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};


//combination mod prime
//https://marycore.jp/prog/cpp/member-initializer-list/ メンバ初期化子

struct combination{
    vector<mint> fact, ifact;
    //メンバ初期化指定子
    combination(int n):fact(n+1),ifact(n+1){
        fact[0]=1;
        for(int i=1; i<=n; i++) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for(int i=n; i>=1; i--) ifact[i-1] = ifact[i]*i;
    }
    //関数呼び出し時の定義
    mint operator()(int n, int k) {
        if (k<0 || k>n) return 0;
        return fact[n]*ifact[n-k]*ifact[k];
    }
};
int main(){
    int n,k; cin >> n >> k;
    int mx0 = min(k,n-1);
    mint ans = 0;
    combination c(n+5);
    rep(i,mx0+1){
        ans += c(n,i) * c(n-1,i);
    }

    cout << ans.x << endl;

    return 0;
}

Measured memory_bytes: 3328
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long ll;

int read() {
	char ch;
	for(ch=getchar();ch<'0'||ch>'9';ch=getchar());
	int x=ch-'0';
	for(ch=getchar();ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

const int N=1e5+5,Mo=1e9+7;

int n,a[N],inv[N],ans;

int main() {
	n=read();
	fo(i,1,n) a[i]=read();
	inv[1]=1;fo(i,2,n) inv[i]=(ll)(Mo-Mo/i)*inv[Mo%i]%Mo;
	fo(i,2,n) (inv[i]+=inv[i-1])%=Mo;
	fo(i,1,n) {
		int res=inv[i];(res+=inv[n-i+1]-1)%=Mo;
		(ans+=(ll)res*a[i]%Mo)%=Mo;
	}
	fo(i,1,n) ans=(ll)ans*i%Mo;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 896
#include<stdio.h>

int main(void){
	
	int H,W;
	int h,w;
	
	while(1){
		scanf( "%d %d",&H, &W );
		
		if( H == 0 && W == 0 ){
			break;
		}
		
		for(h=0; h<H; h++){
			for(w=0; w<W; w++ ){
				
				if( (h+w)%2 == 0 ){
					printf("#");
				}
				else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2048
c[];main(n,m,i){for(;scanf("%d%d",&m,&n)*m;puts("")){int q[1024]={i=0},t=1,p=m;for(;n--;)for(*c=!scanf("%s",c+3),++i%3||strcat(c,"Fizz"),i%5||strcat(c,"Buzz"),*c||sprintf(c,"%d",i),strcmp(c+3,c)&&p>1&&(q[t]=p--);q[t=t%m+1];);for(t=i=0;m--;q[++i]||(t=printf(" %d"+!t,i)));}}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define ALL(v) v.begin(), v.end()
const int INF = 1e9;
const int MAX = 510000;
const int MOD = 1000000007;
using namespace std;
typedef long long ll;

/*C++になってるか認したほうがよくない？WOWWOW*/
/*DP使ったほうがよくない？？WOWWOW*/

int main(){
    int N; cin>>N;
    set<string> S;
    string x;
    for(int i=0; i<N; i++){
        cin>>x;
        S.insert(x);
    }
    cout<<S.size()<<endl;
}

Measured memory_bytes: 19260
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    ll N;
    cin >> N;
    V<ll> sum(N + 1, 0);
    for(ll i = 1; i <= N; i++) {
        ll W;
        cin >> W;
        sum[i] = sum[i - 1] + W;
    }

    ll ans = 5e15;
    for(ll i = 1; i < N; i++) {
        ll a = sum[i];
        ll b = sum[N] - sum[i];
        chmin(ans, (ll)abs(a - b));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    from sys import stdin, stdout

    def read():
        return stdin.readline().rstrip('\n')

    def read_array(sep=None, maxsplit=-1):
        return read().split(sep, maxsplit)

    def read_int():
        return int(read())

    def read_int_array(sep=None, maxsplit=-1):
        return [int(a) for a in read_array(sep, maxsplit)]

    def write(*args, **kwargs):
        sep = kwargs.get('sep', ' ')
        end = kwargs.get('end', '\n')
        stdout.write(sep.join(str(a) for a in args) + end)

    def write_array(array, **kwargs):
        sep = kwargs.get('sep', ' ')
        end = kwargs.get('end', '\n')
        stdout.write(sep.join(str(a) for a in array) + end)

    a, b = read_int_array()
    if a >= 13:
        write(b)
    elif a >= 6:
        write(b // 2)
    else:
        write(0)

main()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define LL long long
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

int main()
{
	fastio
	LL n, k, ans=0, i, s=0, ns=0;
	cin>>n>>k;
	string a;
	cin>>a;
	for(i=0; i<n-1; i++){
		if(a[i]==a[i+1])
			s++;
		if(a[i]!=a[i+1])
			ns++;
	}
	ans = s + min(ns, 2*k);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 512
n = int(input())
music = []
for i in range(n):
    s, t = input().split()
    t = int(t)
    music.append([s, t])
x = input()

ans = 0
time = False
for i in range(n):
    if time:
        ans += music[i][1]
    if music[i][0] == x:
        time = True

print(ans)


Measured memory_bytes: 3060
import collections

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

bc = [map(int, input().split()) for _ in range(Q)]
b, c= [list(i) for i in zip(*bc)]

count = collections.Counter(A)
# count.append([0] * 10)
sumA = sum(A)

for iter in range(Q):
    sumA += count[b[iter]]*(c[iter]- b[iter])
    count[c[iter]] += count[b[iter]] 
    count[b[iter]] = 0
    print(sumA)

Measured memory_bytes: 75216
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n,x,y ;
	cin >> n >> x >> y ;
	vvll g(n,vll(n,0)) ;
	for(ll i=0;i<n;i++){
		for(ll j=i+1;j<n;j++){
			g.at(i).at(j) = min(j-i,sa(i,x-1)+sa(j,y-1)+1) ;
		}
	}
	vll ans(n,0) ;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			ans.at(g.at(i).at(j))++ ;
		}
	}
	for(int i=1;i<=n-1;i++){
		cout << ans.at(i) << endl ;
	}
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    vint a(n);
    vint cnt(1e5+10,0);
    rep(i,n){
        cin >> a[i];
        cnt[a[i]]++; cnt[a[i]+1]++;
        if(a[i]>0) cnt[a[i]-1]++;
    }
    cout<<MAX(cnt)<<endl;
}

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

using namespace std;

using ll = long long;

constexpr ll INF = 1e16;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, K;
    cin >> n >> K;
    vector<ll> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    vector< vector<ll> > dp(n + 1, vector<ll>(K + 1, INF));
    dp[0][0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = K; j >= 0; j--) {
            for (int k = min(i, j); k >= 0; k--) {
                ll tmp = dp[i - k][j - k];
                tmp += max(h[i] - (i - k == 0 ? 0 : h[i - k - 1]), 0LL);
                dp[i + 1][j] = min(dp[i + 1][j], tmp);
            }
        }
    }

    ll ans = INF;
    for (int i = 0; i <= n; i++) {
        int rest = n - i;
        for (int j = 0; j <= K - rest; j++) {
            ans = min(ans, dp[i][j]);
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define PB push_back
#define MP(x,y) make_pair(x,y)
#define F first
#define S second
#define ALL(x) x.begin(),x.end()
using namespace std;

typedef double DB;
typedef long double LDB;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<int,DB> pid;
typedef pair<DB,int> pdi;
typedef pair<DB,DB> pdd;

template<typename T>
inline bool getmin(T& a,const T& b) {return b < a? (a=b,true):false;}
template<typename T>
inline bool getmax(T& a,const T& b) {return b > a? (a=b,true):false;}
template<typename T>
inline bool inrange(const T& x,const T& L,const T& R) {return L<=x && x<=R;}

const int maxn=100000+5;
vector<int> disc;
int num[maxn];
int main()
{
    int N,ans=0,badodd=0,badeven=0;
    scanf("%d",&N);
    for(int i=0;i<N;i++)
    {
        scanf("%d",num+i);
        disc.PB(num[i]);
    }
    sort(ALL(disc));
    for(int i=0;i<N;i++)
    {
        num[i]=lower_bound(ALL(disc),num[i])-disc.begin();
        if((num[i]&1)^(i&1))
        {
            if(num[i]&1) badodd++;
            else badeven++;
        }
    }
    assert(badodd==badeven);
    printf("%d\n",badodd);
}


Measured memory_bytes: 1148
N = int(input())
raw_list = [list(input().split()) for _ in range(N)]
#print(raw_list)
copylist = raw_list[:]
a=sorted(copylist,key=lambda x:int(x[1]),reverse=True) # 点でソート
#print(a)
b=sorted(a, key=lambda x:x[0]) #　所在地でソート
#print(b)

for mise in b:
    #print(mise)
    print(raw_list.index(mise)+1)



Measured memory_bytes: 3060
/*
author: diradon
04-Apr-20
17:47:00
*/

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

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

    ll d, n, k, l;
    cin >> n >> k;
    n = n % k;
    cout << min(n, abs(n-k)) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int                 long long   
#define double              long double
#define endl                "\n"
#define pb                  push_back
#define PI                  3.1415926535897932384626433832795l
#define F                   first
#define S                   second
#define mp                  make_pair
#define f(i,n)              for(int i=0;i<n;i++)
#define fastio              ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)              (v).begin(),(v).end()
#define rall(v)             (v).rbegin(),(v).rend()
#define gcd(a,b)            __gcd((a),(b))
#define fill(a,value)       memset(a,value,sizeof(a));
#define minn(v)             *min_element(v.begin(), v.end());
#define maxx(v)             *max_element(v.begin(), v.end());
#define print(x)            cout<<(x)<<endl;
#define sum(v)+x            accumulate(v.begin(), v.end(),x);
#define debug(x)            cout<<#x<<'='<<(x)<<endl;
typedef pair<int,int> pii;  
typedef vector<int> vi;

signed main() 
{
    fastio;
    cout << fixed << setprecision(12);
    int a,b;
    cin>>a>>b;
    if(abs(a-b)%2)print("IMPOSSIBLE")
    else
    {
        print(max(a,b)-abs(a-b)/2);
    }
    return 0;
}

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

#define INF 1001001001
int a[12][12];

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    rep(i, n) {
        cin >> c[i];
        rep(j, m) cin >> a[i][j];
    }

    int min_cost = INF;
    rep(b, 1<<n) {
        int cost = 0;
        vector<int> aa(m);

        rep(i, n) {
            if (b>>i & 1) {
                cost += c[i];

                rep(j, m) {
                    aa[j] += a[i][j];
                }
            }
        }

        bool pass = true;
        rep(k, m) {
            if (aa[k] < x) pass = false;
        }

        if (pass) {
            //cout << "b:" << b << " cost:" << cost << endl;
            min_cost = min(min_cost, cost);
        }
    }

    if (min_cost == INF) cout << -1 << endl;
    else cout << min_cost << endl;
}

Measured memory_bytes: 3616
#include<iostream>
using namespace std;
long long n,a,b[1000000];
int main(){
    cin>>n;
    for(int i=1;i<=n-1;i++){
        cin>>a;
        b[a]++;
    }
    for(int i=1;i<=n;i++){
        cout<<b[i]<<"\n";
    }
}

Measured memory_bytes: 4748
#include <stdio.h>

int main(void){
  char str[101];
  int i, n, n_h, cnt=0;

  scanf("%s", str);
  i=0;
  while(str[i]!='\0'){
    i++;
  }
  n = i;
  if(n%2==0){
    n_h = n/2;
  }else{
    n_h = (n-1)/2;
  }

  for(i=0; i<n_h; i++){
    if(str[i] != str[(n-1)-i]){
      cnt += 1;
    }
  }
  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	int a[3]; cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[0] + a[1] << endl;


	return 0;
}

Measured memory_bytes: 256
from collections import deque

di = [-1,0,1,0]
dj = [0,-1,0,1]

H,W = map(int, input().split())
si,sj = map(int, input().split())
ti,tj = map(int, input().split())
si -= 1
sj -= 1
ti -= 1
tj -= 1
s = list()
for i in range(H):
  s.append(input())

inf = 10**9
dist = [[inf] * W for i in range(H)]
q = deque()
q.appendleft([si,sj])
dist[si][sj] = 0
while(len(q) > 0):
  tmp = q.popleft()
  i = tmp[0]
  j = tmp[1]
  d = dist[i][j]
  for v in range(4):
    ni = i + di[v]
    nj = j + dj[v]
    if (ni < 0) or (ni >= H) or (nj < 0) or (nj >= W):
      continue
    if s[ni][nj] == "#":
      continue
    if dist[ni][nj] <= d:
      continue
    q.appendleft([ni,nj])
    dist[ni][nj] = d
    
  for ei in range(-2,3,1):
    for ej in range(-2,3,1):
      ni = i + ei
      nj = j + ej
      if (ni < 0) or (ni >= H) or (nj < 0) or (nj >= W):
        continue
      if s[ni][nj] == "#":
        continue
      if dist[ni][nj] <= d+1:
        continue
      q.append([ni,nj])
      dist[ni][nj] = d+1
      
ans = dist[ti][tj]
if ans == inf:
  ans = -1
print(ans)

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N; cin >> N;
    vi X(N); REP(i, N) cin >> X[i];
    vi Y(X);
    sort(ALL(X));

    REP(i, N)
    {
        int median = X[N/2-1];
        if(Y[i] <= median) median = X[N/2];
        cout << median << endl;
    }
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 3840
""" B
    https://atcoder.jp/contests/aising2020/tasks/aising2020_b
"""
import sys
import math
from functools import reduce
from bisect import bisect_left

def readString():
    return sys.stdin.readline()

def readInteger():
    return int(readString())

def readStringSet(n):
    return sys.stdin.readline().split(" ")[:n]

def readIntegerSet(n):
    return list(map(int, readStringSet(n)))

def readIntegerMatrix(n, m):
    return reduce(lambda acc, _: acc + [readIntegerSet(m)], range(0, n), [])

def main(N, a):
    count = 0
    for i in range(0, N):
        if (i+1)%2==1 and a[i]%2==1:
            count += 1
    return count

if __name__ == "__main__":
    _N = readInteger()
    _a = readIntegerSet(_N)

    print(main(_N, _a))

Measured memory_bytes: 9568
/*
 * written by Yaqi Zhang (zhang623@wisc.edu)
 * University of Wisconsin-Madison
 * 2020
 */
#include <bits/stdc++.h>

#define INF 0x3f3f3f3f

using namespace std;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    int L, R;
    cin >> L >> R;
    for(int i = 1; i < m; ++i) {
        int nxt_L, nxt_R;
        cin >> nxt_L >> nxt_R;
        if (L > nxt_R || nxt_L > R) {
            cout << 0 << endl;
            return 0;
        }
        L = max(L, nxt_L);
        R = min(R, nxt_R);
    }
    cout << R - L + 1 << endl;
    return 0;
    
}



Measured memory_bytes: 256
// In god we trust
 
#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>
#include <pthread.h>
#include <omp.h>
 
#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define Q queue
#define Qi Q<int>
#define INF 1000000000 
#define LINF 1000000000000000000
#define int long long
#define _USE_MATH_DEFINES
using namespace std;
using namespace std::chrono;


int mod_power(int x, int y, int mod){
  int ans = 1;
  x %= mod;
  while(y){
    if (y & 1)
      ans *= x, ans %= mod;
    y /= 2;
    x = (x * x) % mod;
  }
  return ans;
}

int mod_inverse(int n, int mod){
  return mod_power(n, mod - 2, mod);
}

int mod_ncr(int n, int r, int mod){
  if (r == 0 or r == n)
    return 1;
  int fact = 1;
  for (int i = 1; i <= r; i++)
    fact *= i, fact %= mod;
  int ans = 1;
  for (int i = n; i > n - r; i--)
    ans *= i, ans %= mod;
  ans *= mod_inverse(fact, mod), ans %= mod;
  return ans;
}

unordered_map<int, int> factor(int n){
  int cnt = 0;
  unordered_map<int, int> m;
  int nn = n;
  while (!(nn & 1))
    cnt++, nn /= 2;
  if(cnt)
    m[2] = cnt;
  for (int i = 3; i <= sqrt(n); i++){
    cnt = 0;
    while(nn % i == 0)
      nn /= i, cnt++;
    if (cnt)
      m[i] = cnt;
  }
  if (nn > 2)
    m[nn] = 1;
  
  return m;
}

const int MAXN = 50;
bool m[50][50];
Vi g[2500];

int bfs(int s){
  bool visit[2500];
  int dist[2500];
  for (int i = 0; i < 2500; i++)
    visit[i] = false;
  visit[s] = true;
  dist[s] = 0;
  list<int> q;
  int max_ = 0;
  q.push_back(s);
  while(!q.empty()){;
    int v = q.front();
    q.pop_front();
    for (auto item: g[v])
      if (not visit[item])
	q.pb(item), visit[item] = true, dist[item] = dist[v] + 1, max_ = max(max_, dist[item]);
  }
  return max_;
}

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

  int h, w;
  char c;
  cin >> h >> w;
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++){
      cin >> c;
      if (c == '.')
	m[i][j] = 1;
    }
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++)
      if (m[i][j])
	for (int ii = i - 1; ii <= i + 1; ii++)
	  for (int jj = j - 1; jj <= j + 1; jj++)
	    if (ii >= 0 and ii < h and jj >= 0 and jj < w and m[ii][jj] and abs(ii - i) + abs(jj - j) == 1)
	      g[i * MAXN + j].pb(ii * MAXN + jj);

  int ans = 0;
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++)
      ans = max(ans, bfs(i * MAXN + j));
    
  cout << ans << endl;
	     
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=3e2+10;
int a[N][N],b[N],c[N],d[N];
int main()
{
    //freopen("abbreviation.in","r",stdin);
    //freopen("abbreviation.out","w",stdout);
    int n,m,i,j;
    cin>>n>>m;
    for(i=0;i<n;i++)
        for(j=0;j<m;j++)scanf("%d",&a[i][j]);
    memset(b,0,sizeof b);
    memset(d,0,sizeof d);
    int ans=INFINITY;
    for(i=0;i<m;i++)
    {
        memset(c,0,sizeof c);
        int m=0,p=1;
        for(j=0;j<n;j++)if(m<++c[a[j][b[j]]])p=a[j][b[j]],m=c[a[j][b[j]]];
        d[p]=1;
        ans=min(ans,m);
        for(j=0;j<n;j++)
            while(d[a[j][b[j]]])b[j]++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 640