akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<cmath>
#include<cctype>
#include<iomanip>
#include<iostream>
#include<map>
#include <queue>
#include<string>
#include<vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define out(x) cout << x << endl;
#define each(e, v) for (auto&& e : v)
#define clamp(v,lo,hi) min(max(v,lo),hi)
#define debug(i) cout<<"point :"<< i << endl;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define all(a) a.begin(),a.end()
typedef long long LL;
typedef vector<int> vint;
typedef vector<long> vl;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef map<string, int> mapstri;
typedef map<int, int> mapii;
typedef std::pair<int, int> pairii;

int main () {
    LL n;
    cin >> n;
    LL ans = 0;
    for (int i = 1; i < n + 1; ++i) {
        if (i % 3 != 0  && i % 5 != 0) {
            ans += i;
        }
    }
    out(ans)
    return 0;
}

Measured memory_bytes: 3192
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>

auto& in = std::cin;
auto& out = std::cout;

int32_t N;
int32_t A[110001];
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	for (size_t i = 0; i < N; i++)
	{
		int a;
		in >> a; A[a]++;
	}

	int32_t max = 0;
	for (int32_t  i = 1; i < 100010; i++)
	{
		max = std::max(max, A[i - 1] + A[i] + A[i + 1]);
	}
	out << max << endl;

	return 0;
}
#endif


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

typedef long long LL;

int main(){
  LL a,b,v,w,t;
  scanf("%lld%lld%lld%lld%lld",&a,&v,&b,&w,&t);
  puts((v-w)*t>=abs(a-b)?"YES":"NO");
  return 0;
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

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

	string s;
	cin >> s;
	
	vector<char> v;

	char a = 'A';
	char z = 'Z';
	rep(i, s.length()){
		// cout << a + 0 << " " << z + 0 << " " << s[i] + n << endl;

		if(s[i] + n <= z){
			v.push_back(s[i] + n);
		}
		else{
			v.push_back((s[i] + n) - (z - a) - 1);
		}
	}

	for(auto i : v) cout << i;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
typedef long long ll;
const int mod = 1e9 + 7;
int main() {

    ll n, k;
    cin >> n >> k;

    vector<pair<int ,ll>> v;
    rep(i, n){
        int a;
        ll b;
        cin >> a >> b;
        v.emplace_back(a, b);
    }

    sort(v.begin(), v.end());

    for(int i=0; i<n; i++){
        k -= v[i].second;
        if(k <= 0){
            cout << v[i].first << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 2420
from itertools import combinations

def f(n,x):
	is3 = [sum(c)==x for c in combinations(range(1,n+1),3)]
	return sum(is3)

data = []
while True:
	temp = [int(s) for s in input().split(' ')]
	if temp == [0,0]:
		break
	else:
		data.append(temp)

ans = [f(n,x) for n,x in data]
[print(a) for a in ans]

Measured memory_bytes: 8976
import sys
import numpy as np


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


def main():
    N = int(input())
    A = []
    B = []
    for i in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
    A = np.array(list(reversed(A)))
    B = np.array(list(reversed(B)))
    ans = 0
    for i in range(N):
        a = A[i] + ans
        b = B[i]
        if a % b > 0:
            btn = b - (a % b)
        else:
            btn = a % b
        ans += btn
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 21652
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    long X=gl();
	    long Y=gl();

        //System.out.println(sb.toString());
        if (X%Y==0) {
        	System.out.print("-1");
        }else{
        	long c=1;
        	while(true) {
        		if (((X*c) %Y) != 0) {
        			System.out.print(X*c);
        			return;
        		}
        		c++;
        	}
        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
}

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

int main(){
	int n;
	cin >> n;
	vector<int>l(n * 2);
	for (int i = 0;i < n * 2;i++) {
		cin >> l[i];
	}
	sort(l.begin(), l.end());
	int ans = 0;
	for (int i = 0;i < n * 2;i += 2) {
		ans += l[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define repi(i, n) for (int i = 0; i < (int)(n); i++)
#define repd(i, n) for (int i = (int)(n); i >= 0; i--)

int main()
{
    int N;
    cin >> N;
    vector<int> A(N + 1);
    vector<int> B(N);
    repi(i, N + 1)
    {
        cin >> A[i];
    }
    repi(i, N)
    {
        cin >> B[i];
    }
    long E = 0;
    repi(i, N)
    {
        E += min(A[i], B[i]);
        B[i] -= min(A[i], B[i]);

        E += min(A[i + 1], B[i]);
        A[i + 1] -= min(A[i + 1], B[i]);
    }
    cout << E << endl;
    return 0;
}

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> a(H, vector<char>(W));
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> a.at(i).at(j);
        }
    }
    int row = H;
    int col = W;
    vector<int> memorow;
    vector<int> memocol;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(j == W - 1 && a.at(i).at(j) == '.'){
                memorow.push_back(i);
                row--;
            }
            if(a.at(i).at(j) == '#'){
                break;
            }
        }
    }
    for(int i = 0; i < W; i++){
        for(int j = 0; j < H; j++){
            if(j == H - 1 && a.at(j).at(i) == '.'){
                memocol.push_back(i);
                col--;
            }
            if(a.at(j).at(i) == '#'){
                break;
            }
        }
    }
    int MR = memorow.size();
    int MC = memocol.size();
    vector<vector<char>> revised(row, vector<char>(col));
    int x = 0;
    int y = 0;
    for(int i = 0; i < H; i++){
        bool flag1 = false;
        for(int k1 = 0; k1 < MR; k1++){
            if(i == memorow.at(k1)){
                flag1 = true;
                break;
            }
        }
        if(flag1){
            continue;
        }
        y = 0;
        for(int j = 0; j < W; j++){
            bool flag2 = false;
            for(int k2 = 0; k2 < MC; k2++){
                if(j == memocol.at(k2)){
                    flag2 = true;
                    break;
                }
            }
            if(flag2){
                continue;
            }
            revised.at(x).at(y) = a.at(i).at(j);
            cout << revised.at(x).at(y);
            y++;
        }
        x++;
        cout << endl;
    }
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int n, a[200001];
int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        scanf("%d", &a[i]);
    sort(a, a + n);
    int ma = a[n - 1], z = (ma + 1) / 2, i;
    for (i = 0; i < n; ++i){
        if (a[i] <= z && a[i + 1] > z) break;
    }
    if (z - a[i] > a[i + 1] - z) printf("%d %d\n", ma, a[i + 1]);
    else printf("%d %d\n", ma, a[i]);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
const long long MOD = 1e9+7;
using namespace std;
#define ll long long
#define ar array

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

	string s;
	cin >> s;
	int ans = 0;

	for (int i = 0; i < 6; i++) {
		if (s[i]=='1') ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3624
N = int(input())
D, X = list(map(int, input().split()))
A = [int(input()) for _ in range(N)]
result = X
for n in range(N):
    if D % A[n] == 0:
        result += (D // A[n])
    else:
        result += (D // A[n]) + 1
print(result)


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

namespace ABC064
{
    class B
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            int max = a.Max();
            int min = a.Min();

            Console.WriteLine(max - min);
        }
    }
}

Measured memory_bytes: 11348
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<climits> //INT_MIN/MAX
using namespace std;

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

#define FOR(i,s,e) for(ll (i)=(s);(i)<(e);(i)++)
#define FORR(i,s,e) for(ll (i)=(s);(i)>(e);(i)--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define mp make_pair
#define pb push_back
const ll MOD = 1000000007;
const int INF = 1e9;
const ll LINF = 1e16;
const double PI = acos(-1.0);
int dx[8] = { 0,0,1,-1,1,1,-1,-1 };
int dy[8] = { 1,-1,0,0,1,-1,1,-1 };

/* ----- xtimex  Problem: ARC070 B / Link: http://arc070.contest.atcoder.jp/tasks/arc070_b ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

ll N, K;
map<ll, ll> m[2];

ll a[5000];
ll ans = 0LL;

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

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

	sort(a, a + N);
	reverse(a, a + N);
	FOR(i, 0, N) {
		ll tmp = 0;
		FOR(j, 0, N) {
			if (i == j)continue;
			if (tmp + a[j] < K) {
				tmp += a[j];
			}
		}
		if (tmp + a[i] >= K) {
			ans++;
		}
	}
	//m[0][0] = 0;
	//m[1][0] = 0;
	//cout << "afdf11" << endl;

	//int qq;
	//FOR(i, 0, N) {
	//	ll p = a[i];
	//	qq = i % 2;
	//	auto it = m[qq].begin();
	//	debug(m[qq].size());
	//	debug(qq);



	//	FOR(z, 0, m[qq].size()) { // !?
 //			m[(qq + 1) % 2][(*it).first] = (*it).first;
	//		m[(qq + 1) % 2][(*it).first + p] = (*it).first + p;
	//		it++;
	//	}

	//}
	//FOR(i, 0, N) {

	//	FOR(x, K - a[i], K) {
	//		if (m[(N) % 2].count(x) != 0 && m[(N) % 2].count(x + a[i]) != 0 && x + a[i] >= K) {
	//			ans++;
	//			break;
	//		}

	//	}


	//}

	cout << N - ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
    string a,b,c;
    char now;
    cin >> a >> b >> c;
    int na=0,nb=-1,nc=-1;
    now = a.at(0);
    while(true){
        if(now == 'a') na++;
        else if(now == 'b') nb++;
        else nc++;
        if(na == a.size()){
            cout << "A" << endl;
            return 0;
        }
        else if(nb == b.size()){
            cout << "B" << endl;
            return 0;
        }
        else if(nc == c.size()){
            cout << "C" << endl;
            return 0;
        }
        if(now=='a') now = a.at(na);
        else if(now=='b') now = b.at(nb);
        else now = c.at(nc);
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
using namespace std;

int main(){
  string str;
  getline(cin, str);
  for(int i=0;i<str.size();i++){
    if(str[i] >= 'a' && str[i] <= 'z')
      cout << (char)toupper(str[i]);
    else if(str[i] >= 'A' && str[i] <= 'Z')
      cout << (char)tolower(str[i]);
    else
      cout << str[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1176
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> bool max_self(T & a, const T & b){ 
  return b > a ? a = b, true : false; 
}
template<class T> bool min_self(T & a, const T & b){ 
  return b < a ? a = b, true : false;    
}
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);

int N, ben[70];
LL k, answer = 0LL, value = 0LL, num[(int)1e5 + 7];
bool lesser = false;

int main(){
  FAST_IO
  cin >> N >> k;
  for(int rep = 0; rep < N; ++rep) cin >> num[rep];

  for(int pos = 60; pos >= 0; --pos){
    for(int idx = 0; idx < N; ++idx){
      if((num[idx] & (1LL << pos))) ben[pos]--;
      else ben[pos]++;
    }
  }

  for(int pos = 60; pos >= 0; --pos){
    if(ben[pos] >= 0){
      if(k & (1LL << pos)){
        answer |= (1LL << pos);
      }else if(lesser) answer |= (1LL << pos);
    }else{
      if(k & (1LL << pos)) lesser = true;
      answer |= (0LL << pos);
    }
  }

  for(int idx = 0; idx < N; ++idx){
    value += answer ^ num[idx];
  }

  cout << value << '\n';
  return 0;
}


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

#define maxn 200000
int check[maxn]= {0};
int prime[maxn]= {0};
int main() {
	int N;
	cin>>N;
	if(N==2)
	{
		cout<<2;
		return 0;
	}

	int n=200000, cnt = 0;

	int num=0;
	memset(check,0,sizeof(check));
	for(int i=2; i<=n; i++) {
		if(check[i]==0)
			prime[num++]=i;
		for(int j=i+i; j<=n; j+=i) { //素数的倍数全部标记
			check[j]=1;
		}
	}
	for(int i=0; i<num; i++)
		if(N<=prime[i]) {
			cout<<prime[i];
			break;
		}
	//埃筛法
	return 0;
}

Measured memory_bytes: 1152
/*
https://t.me/unstoppabIesoIvemachinechannel
*/
#pragma ARCENIY_KIRILLOV_POVELITEL_KROKODILOV
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC pop_options
//#pragma GCC target("popcnt")
//#pragma GCC target("sse4")
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(),a.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i > -1; i--)
#define rer(i, x, n) for (int i = x; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef long double ld;















signed main(){
	int a, b;
  	cin >> a >> b;
  cout << max(0, a - b -b);




}


Measured memory_bytes: 256
object MainKt {
  @JvmStatic fun main(args:Array<String>) {
    val (N,M) = readLine()!!.split(" ").map(String::toInt)
    val connection= (1..M).map {
      val(a,b)=readLine()!!.split(" ").map(String::toInt)
      Pair(a,b)
    }
  
    (1..N).map {
    
        connection.filter { pair->
          val (a,b)=pair
          a==it || b==it
        }.size
    }.forEach(::println)

  }
}

Measured memory_bytes: 36108
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int h,w;
int fie[401][401];
bool used[401][401];
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
ll cntb=0;
ll cntw=0;

void dfs(int x,int y){
    if(fie[y][x]==1)cntb++;
    else cntw++;
    used[y][x]=true;
    for(int i=0;i<4;i++){
        int nx=x+dx[i];
        int ny=y+dy[i];
        if(nx<0 || nx>=w || ny<0 || ny>=h)continue;
        if(!used[ny][nx] && fie[ny][nx]!=fie[y][x]){
            dfs(nx,ny);
        }
    }
}

int main(void){
    scanf("%d%d",&h,&w);
    for(int i=0;i<h;i++){
        string s;
        cin >> s;
        for(int j=0;j<w;j++){
            if(s[j]=='#'){
                fie[i][j]=1;
            }
        }
    }
    ll ans=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(!used[i][j]){
                cntb=0;
                cntw=0;
                dfs(j,i);
                ans+=cntb*cntw;
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

int main(){
  int n;
  cin >> n;
  int max_x = 0;
  int ans = INF;

  vector<int>x(n);
  for(int i=0;i<n;i++){
    cin >> x[i];
    max_x = max(max_x,x[i]);
  }
  for(int i=1;i<=max_x;i++){
    int tmp_1=0;
    int tmp_2=0;
    for(int j=0;j<n;j++){
      tmp_1 += (x[j]-i)*(x[j]-i);
      tmp_2 += (x[j]-(max_x-i))*(x[j]-(max_x-i));
    }
    ans = min(ans,tmp_1);
  }
  cout<< ans <<endl;
}


Measured memory_bytes: 256
// DPL1_A
#include <bits/stdc++.h>
#define endl "\n"
#define _GLIBCXX_DEBUG //配列外参照エラー表示,gcc依存
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ipair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
namespace you {
    std::string to_string(char val) {
        return std::string(1, val);
        // return std::string{val};
        // you::to_string(char)
    }
}

vector<int> coin(25);
int max_=pow(10,6);
vector<vector<int>> dp(25,vector<int>(50010,max_));
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++) cin>>coin[i];
    for(int i=0;i<=m;i++) dp[i][0]=0;
    for(int i=1;i<=m;i++){
        for(int j=1;j<=n;j++){
            if(0<=j-coin[i]) dp[i][j]=min(dp[i-1][j],dp[i][j-coin[i]]+1);
            else dp[i][j]=min(dp[i][j],dp[i-1][j]);
        }
    }
    cout<<dp[m][n]<<endl;
    return 0;
}


Measured memory_bytes: 7788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	if(n==3 || n==5 || n==7) cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

// @@ !! LIM(f:updMaxMin)
// --> f:updMaxMin
// ---- inserted function updMaxMin from util.cc
template<typename T>
bool updMax(T& tmax, const T& x) {
  if (x > tmax) { tmax = x; return true;  }
  else          {           return false; }
}
template<typename T>
bool updMin(T& tmin, const T& x) {
  if (x < tmin) { tmin = x; return true;  }
  else          {           return false; }
}
// ---- end updMaxMin
// @@ !! LIM  -- end mark --

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll H, N; cin >> H >> N;
  vector<ll> A(N), B(N);
  for (ll i = 0; i < N; i++) cin >> A[i] >> B[i];

  ll big = 1e12;
  vector cur(H + 1, big);
  cur[0] = 0;
  for (ll i = 0; i < N; i++) {
    for (ll h = 0; h < H; h++) {
      ll g = min(h + A[i], H);
      updMin(cur[g], cur[h] + B[i]);
    }
  }
  cout << cur[H] << endl;

  return 0;
}



Measured memory_bytes: 3728
N=int(input())

a=list(map(int,input().split()))
suma=0
for i in range(N):
  suma+=a[i]
meana=suma/N

tikai=101
for i in range(N):
  if abs(meana-a[i])<tikai:
    tikai=abs(meana-a[i])
    answer=i
print(answer)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 200005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
const int mod = 998244353;

int main(){
	string s,t;
	cin >> s >> t;
	vector<int>v[26];
	for(int i = 0 ; i < s.size() ; i++){
		v[s[i]-'a'].pb(i);
	}
	for(int i = 0 ; i < t.size() ; i++){
		if(v[t[i]-'a'].size()==0){
			cout << -1 << endl;
			exit(0);
		}
	}
	int r=0;
	int cur=-1;
	for(int i = 0 ; i < t.size() ; i++){
		int nxt = t[i]-'a';
		if(upper_bound(v[nxt].begin(),v[nxt].end(),cur)==v[nxt].end()){
			r++;
			cur = v[nxt][0];
		}
		else{
			cur = *upper_bound(v[nxt].begin(),v[nxt].end(),cur);
		}
	}
	cout<<(ll)r*(ll)s.size()+cur+1<<'\n';
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl


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

    int ans = 1;
    rep(i, N) {
        if (ans <= K) {
            ans = ans * 2;
        } else {
            ans += K;
        }
    }

    print(ans);
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
string i_t_s(int x){
	string t="";
	while(x){
		t+=x%10+'0';
		x/=10;
	}
	reverse(all(t));
	re t;
}
int s_t_i(string t){
	int x=0;
	rep(i,sz(t)){
		x=x*10+(t[i]-'0');
	}
	re x;
}
bool f[200001];
int n,m;
map<pair<int,int>,bool> mp;
vi v[200001];
int cnt;
void dfs(int x){
	f[x]=true;
	cnt++;
	rep(i,sz(v[x])){
		if(f[v[x][i]])
		continue;
		dfs(v[x][i]);
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>m;
	rep(i,m){
		int x,y;
		cin>>x>>y;
		x--,y--;
		if(mp[m_p(min(x,y),max(x,y))])
		continue;
		mp[m_p(min(x,y),max(x,y))]=true;
		v[x].pb(y);
		v[y].pb(x);
	}
	int mx=0;
	rep(i,n){
		if(f[i])
		continue;
		cnt=0;
		dfs(i);
		mx=max(mx,cnt);
	}
	cout<<mx;
	re 0;
}


Measured memory_bytes: 33532
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll ch[200001];
int main() {
	ll n,m;
	cin>>n>>m;
	bool ans=false;
	for(ll i=0;i<m;i++){
		ll x,y;
		cin>>x>>y;
		x--;y--;
		if(x==0||y==0||x==n-1||y==n-1){
			ch[x]++;
			ch[y]++;
		}
	}
	for(ll i=1;i<n-1;i++){
		if(ch[i]==2){
			ans=true;
		}
	}
	cout << (ans?"POSSIBLE":"IMPOSSIBLE");
	// your code goes here
	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
 
int main() {
        int n, k;
        scanf("%d%d", &n, &k);
        map<int, int> cnt;
        for (int i = 0; i < n; i ++) {
                int a;
                scanf("%d", &a);
                cnt[a] ++;
        }
        vector<int> res;
        for (auto c : cnt) res.push_back(c.second);
        int d = max(0, (int) res.size() - k);
        sort(res.begin(), res.end());
        int ans = 0;
        for (int i = 0; i < d; i ++) ans += res[i];
        printf("%d\n", ans);
        return 0;
}


Measured memory_bytes: 10748
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  int ans = 1;
  while(1){
    ans *= 2;
    if(ans > N){
      ans /= 2;
      break;
    }
  }
  cout << ans << endl;

  return 0;
}


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

string dir = "NESW";
int dx[4] = { 0, 1, 0,-1};
int dy[4] = { 1, 0,-1, 0};

int n;
vector<pair<int, int> > jewels;
bool isGotten[20] = {false};

void getJewel(int x, int y, int &cnt){
    for(int i = 0; i < n; i++){
        if(!isGotten[i] && x == jewels[i].first && y == jewels[i].second){
            isGotten[i] = true;
            cnt++;
        }
    }
}

int main(int argc, const char * argv[]) {
    while(1){
        cin >> n;
        if(!n) break;
        
        jewels.clear();
        for(int i = 0; i < n; i++){
            int x, y; cin >> x >> y;
            jewels.push_back(make_pair(x, y));
            isGotten[i] = false;
        }
        
        int m; cin >> m;
        int cnt = 0;
        pair<int, int> pos = make_pair(10, 10);
        for(int i = 0; i < m; i++){
            char d_char; int r; cin >> d_char >> r;
            int d_id = dir.find(d_char);
            while(r){
                getJewel(pos.first, pos.second, cnt);
                pos.first += dx[d_id];
                pos.second += dy[d_id];
                r--;
            }
            getJewel(pos.first, pos.second, cnt);
        }
        
        if(cnt == n) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 1196
#include <stdio.h>

typedef long long int64;

int gc(int a, int b) 
{
    int tmp, r;
    if (a < b) {
        tmp = a;
        a = b;
        b = tmp;
    }
    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int gcd(int a, int b, int c) 
{
    return gc(a, gc(b, c));
}

int main()
{
    int k;
    scanf("%d", &k);
    int64 a = 0;

    for (int i = 1; i != k + 1; i++)
    {
        for (int j = 1; j != k + 1; j++)
        {
            for (int l = 1; l != k + 1; l++)
            {
                a += gcd(i, j, l);
            }
        }
    }

    printf("%lld", a);
    return 0;
}

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

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<string> S(N);
    rep (i, N)
        cin >> S[i];

    mf_graph<int> mf(N * M + 2);
    int s = N * M, t = N * M + 1;
    rep (i, N) {
        rep (j, M) {
            if ((i + j) % 2) {
                mf.add_edge(s, i * M + j, 1);
            } else {
                mf.add_edge(i * M + j, t, 1);
            }
        }
    }
    rep (i, N) {
        rep (j, M) {
            if ((i + j) % 2 == 0)
                continue;
            if (S[i][j] == '#')
                continue;
            if (i && S[i - 1][j] == '.')
                mf.add_edge(i * M + j, (i - 1) * M + j, 1);
            if (j && S[i][j - 1] == '.')
                mf.add_edge(i * M + j, i * M + j - 1, 1);
            if (i + 1 < N && S[i + 1][j] == '.')
                mf.add_edge(i * M + j, (i + 1) * M + j, 1);
            if (j + 1 < M && S[i][j + 1] == '.')
                mf.add_edge(i * M + j, i * M + j + 1, 1);
        }
    }
    cout << mf.flow(s, t) << endl;

    auto edges = mf.edges();
    for (auto e : edges) {
        if (e.from == s || e.to == t || e.flow == 0)
            continue;
        int fi = e.from / M, fj = e.from % M, ti = e.to / M, tj = e.to % M;
        if (fi + 1 == ti) {
            S[fi][fj] = 'v';
            S[ti][tj] = '^';
        } else if (fi - 1 == ti) {
            S[fi][fj] = '^';
            S[ti][tj] = 'v';
        } else if (fj + 1 == tj) {
            S[fi][fj] = '>';
            S[ti][tj] = '<';
        } else {
            S[fi][fj] = '<';
            S[ti][tj] = '>';
        }
    }
    rep (i, N)
        cout << S[i] << endl;
}

Measured memory_bytes: 5700
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

class ModCalc
{
    LLONG m_mod = MOD;
    vector<LLONG> m_fac;
    vector<LLONG> m_ifac;

public:
    ModCalc(const LLONG mod)
    {
        m_mod = mod;
    }

    // Combinationを計算したいときの前処理：O(max)
    ModCalc(const int max, const LLONG mod)
    {
        m_mod = mod;
        m_fac = vector<LLONG>(max + 1);
        m_ifac = vector<LLONG>(max + 1);
        m_fac[0] = m_ifac[0] = 1;
        for (int i = 0; i < max; ++i)
        {
            m_fac[i + 1] = m_fac[i] * (i + 1) % mod;    // n! (mod M)
            m_ifac[i + 1] = m_ifac[i] * ModPow(i + 1, mod - 2) % mod;   // k!^(M-2) (mod M)
        }
    }

    const LLONG ModAdd(LLONG a, LLONG b) const
    {
        return (a + b) % m_mod;
    }

    const LLONG ModSubtract(LLONG a, LLONG b) const
    {
        LLONG diff = a - b;
        return diff >= 0 ? diff : diff + m_mod;
    }

    const LLONG ModMulti(LLONG a, LLONG b) const
    {
        LLONG prod = a * b % m_mod;
        return prod >= 0 ? prod : prod + m_mod;
    }

    const LLONG ModDiv(LLONG a, LLONG b) const
    {
        LLONG c = m_mod, u = 1, v = 0;
        while (c)
        {
            LLONG t = b / c;
            b -= t * c; swap(b, c);
            u -= t * v; swap(u, v);
        }
        u %= m_mod;
        if (u < 0) u += m_mod;
        return (a % m_mod) * u % m_mod;
    }

    const LLONG ModPow(LLONG x, LLONG n) const
    {
        LLONG ret = 1;
        while (n != 0)
        {
            if (n & 1) ret = ret * x % m_mod;
            x = x * x % m_mod;
            n = n >> 1;
        }
        return ret;
    }

    const LLONG ModComb(LLONG n, LLONG r) const
    {
        if (n == 0 && r == 0) return 1;
        if (n < r || n < 0) return 0;
        LLONG tmp = m_ifac[n - r] * m_ifac[r] % m_mod;
        return tmp * m_fac[n] % m_mod;
    }
};

int main()
{
    string s; cin >> s; // |S| <= 2*1e5
    int N = s.length();
    vector<int> rems(N + 1);
    int rem = 0;
    ModCalc mod(2019);
    for (int i = 1; i <= N; ++i)
    {
        int v = static_cast<int>(s[N - i] - '0');
        rem += mod.ModMulti(v, mod.ModPow(10, i - 1));
        rem %= 2019;
        rems[i] = rem;
    }
    map<int, int> rem2NumMap;
    for (const int rem : rems)
    {
        ++rem2NumMap[rem];
    }
    int ans = 0;
    for (const auto &kvp : rem2NumMap)
    {
        int num = kvp.second;
        ans += num * (num - 1) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4380
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

ll gcd(ll a, ll b) {
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll factorial(ll x) {
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }
	if (n == r) { return 1; }

	if (r > n / 2) { r = n / 2; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

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

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

	// 素数である
	return true;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) {
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

int main() {
	ll a,b,x; cin>>a>>b>>x;
	ll ans=b/x-a/x;
	if(a%x==0) ++ans;
	cout<<ans<<endl;
}


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

int main() {
    int d;
    cin >> d;
    if(d == 25) cout << "Christmas" << endl;
    else if(d == 24) cout << "Christmas Eve" << endl;
    else if(d == 23) cout << "Christmas Eve Eve" << endl;
    else cout << "Christmas Eve Eve Eve" << endl;
}

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

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return y;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


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

  int ans = 0;
  rep(i,m){
    if(mp[i+1] == n) ans ++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
table = Hash::new
n = gets.to_i()
while(n!=0)
  str=""
  table.clear
  n.times do
    a = gets.split(" ")
    table[a[0].strip] = a[1].strip
  end
  m = gets.to_i()
  m.times do
   c = gets.chomp.strip
   if(table[c]!=nil)
     c = table[c]
   end
   str.concat(c)
  end
  puts str
  n = gets.to_i()
end

Measured memory_bytes: 6208
#include<iostream>

using namespace std;

int main(){
  long long n,m; cin >> n >> m;
  if(n == 1){
    if(m == 1) cout << 1 << endl;
    else cout << m-2 << endl;
  }
  else if(m == 1){
    cout << n-2 << endl;
  }
  else cout << n*m - 2*(n-2) - 2*(m-2) - 4 << endl;
}


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


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


int main()
{
	int x, y, z,N;
	cin >> N;
	int m, n;
	int sam = 0;
	for (x = 1; x < N + 1; x++) {
		for (y = 1; y < N + 1; y++) {
			for (z = 1; z < N + 1; z++) {
				m = gcd(x, y);
				sam += gcd(m, z);
			}
		}
	}
	cout << sam;

}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int N;

long long int A[100005];

long long int D[100005], W[100005], V[100005];
long long int INF = 999999999999999;

int main(void) {

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

	int sign = 0;
	D[0] = 1 - A[0];  if (D[0] < 0) { sign = -1; }

	for (int k = 1; k <= N; k++) {
		D[k] = D[k - 1] * 2 - A[k]; if (D[k] < 0) { sign = -1; break; }
		if (D[k] > INF) { D[k] = INF; }
	}

	for (int k = N; k >= 0; k--) {
		W[k] = min(V[k+1], D[k]);
		V[k] = W[k] + A[k];
	}
	long long int ans = 0;

	for (int k = 0; k <= N; k++) {
		ans += V[k];
	}

	if (sign == -1) { cout << -1 << endl; }
	else { cout << ans << endl; }

	return 0;
}

Measured memory_bytes: 6292
from queue import Queue
from sys import stdin, stdout

def check(arr):
    a = int(''.join(str(each) for each in arr))
    if a < 10:
        return True
    for i in range(1,len(arr)):
        if abs(arr[i] - arr[i - 1]) > 1:
            return False
    return True

arr = [0] * 10

arr[9] = 1
k = 0
limit = int(stdin.readline().strip())

for aa in range(0, 10):
    if aa == 0:
        brange = range(0, 10)
    else:
        brange = range(max(0, aa - 1), min(10, aa + 2))
    for bb in brange:
        if aa+bb == 0:
            crange = range(0, 10)
        else:
            crange = range(max(0, bb - 1), min(10, bb + 2))
        for cc in crange:
            if aa+bb+cc == 0:
                drange = range(0, 10)
            else:
                drange = range(max(0, cc - 1), min(10, cc + 2))
            for dd in drange:
                if aa+bb+cc+dd == 0:
                    erange = range(0, 10)
                else:
                    erange = range(max(0, dd - 1), min(10, dd + 2))
                for ee in erange:
                    if aa+bb+cc+dd+ee == 0:
                        frange = range(0, 10)
                    else:
                        frange = range(max(0, ee - 1), min(10, ee + 2))
                    for ff in frange:
                        if aa+bb+cc+dd+ee+ff == 0:
                            grange = range(0, 10)
                        else:
                            grange = range(max(0, ff - 1), min(10, ff + 2))
                        for gg in grange:
                            if aa+bb+cc+dd+ee+ff+gg == 0:
                                hrange = range(0, 10)
                            else:
                                hrange = range(max(0, gg - 1), min(10, gg + 2))
                            for hh in hrange:
                                if aa+bb+cc+dd+ee+ff+gg+hh == 0:
                                    irange = range(0, 10)
                                else:
                                    irange = range(max(0, hh - 1), min(10, hh + 2))
                                for ii in irange:
                                    if aa+bb+cc+dd+ee+ff+gg+hh+ii == 0:
                                        jrange = range(0, 10)
                                    else:
                                        jrange = range(max(0, ii - 1), min(10, ii + 2))
                                    for jj in jrange:
                                        k += 1
                                        # arr = [aa, bb, cc, dd, ee, ff, gg, hh, ii, jj]
                                        # num = int(''.join(str(each) for each in arr))
                                        # stdout.writelines("%d," % num)
                                        if k > limit:
                                            arr = [aa, bb, cc, dd, ee, ff, gg, hh, ii, jj]
                                            num = int(''.join(str(each) for each in arr))
                                            stdout.writelines("%d\n" % num)
                                            exit(0)


Measured memory_bytes: 61416
def main():
    import sys
    input = sys.stdin.readline

    H, W, D = map(int, input().split())
    A = [[int(x) for x in input().split()] for _ in range(H)]

    B = [[] for _ in range(D)]

    C = [None] * (H * W)
    for r, row in enumerate(A):
        for c, cell in enumerate(row):
            C[cell - 1] = r, c

    for x in range(H * W):
        r = x % D
        if B[r]:
            cr, cc = C[x]
            pr, pc = C[x - D]
            cost = abs(cr - pr) + abs(cc - pc)
            B[r].append(B[r][-1] + cost)

        else:
            B[r].append(0)

    ans = []
    Q = int(input())
    for _ in range(Q):
        L, R = (int(x) - 1 for x in input().split())
        r = R % D
        ql, qr = L // D, R // D

        ans.append(B[r][qr] - B[r][ql])

    print(*ans, sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 27352
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <queue>
#include <iostream>
#include <cmath>

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
typedef long long ll;
using namespace std;

const string YES = "Yes";
const string NO = "No";

void solve(long long X){
    if(X >= 30) { 
        cout << YES << endl;
    } else { 
        cout << NO << endl;
    }
    return;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
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 ll = long long;
using P = pair<ll, ll>;
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; }

vector<ll> ans(100, 0);
vector<ll> A(100100, 0);
vector<ll> B(100100, 0);
ll h, w, n;
set<P> bz, ccc;

void make(ll y, ll x) {
    for(int i = 0; i < 3; ++i) {
        for(int j = 0; j < 3; ++j) {
            int ny = y-i; int nx = x-j;
            if(ny >= 0 && ny < h-2 && nx >= 0 && nx < w-2) {
                bz.insert({ny, nx});
            }
        }
    }
}

int main() {
    cin >> h >> w >> n;
    for(int i = 0; i < n; ++i) {
        cin >> A.at(i) >> B.at(i);
        A.at(i)--; B.at(i)--;
        ccc.insert({A.at(i), B.at(i)});
        make(A.at(i), B.at(i));
    }

    ll white = (h-2)*(w-2);
    for(auto p : bz) {
        ll yy = p.first, xx = p.second;
        int cnt = 0;
        for(ll i = yy; i < yy+3; ++i) {
            for(ll j = xx; j < xx+3; ++j) {
                if(ccc.find({i, j}) != ccc.end()) cnt++;
            }
        }
        if(cnt) white--;
        ans.at(cnt)++;
    }

    ans[0] = white;
    for(int i = 0; i <= 9; ++i) {
        cout << ans.at(i) << endl;
    }
}

Measured memory_bytes: 64256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
//--
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<cstdio>
#include<cstring>
#include<sstream>
#define X first
#define Y second
#define pb push_back

using namespace std;

int n,y,m,d,sum,days;

int main(){
  scanf("%d",&n);
  while(n--){
    scanf("%d %d %d",&y,&m,&d);
    sum=0;
    for(;y<1000;y++){
      for(;m<=10;m++){
        days=19+(y%3==0 || m%2==1);
        for(;d<=days;d++){
          sum++;
        }
        d=1;
      }
      m=1;
    }
    printf("%d\n",sum);
  }
  return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e,n,ans = 0;
  string s,ss,sss;
  cin>>a>>b;
  if(a <= b)cout<<"unsafe"<<endl;
  else cout<<"safe"<<endl;
  return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		int n=scn.nextInt();
		int q=scn.nextInt();
		String str=scn.next();
		int []arr=new int[str.length()];
		int ac=0;
		arr[0]=0;
		for(int i=1;i<str.length();i++) {
			if(str.charAt(i-1)=='A'&&str.charAt(i)=='C') {
				ac++;
			}
			arr[i]=ac;
		}
		
		for(int i=0;i<q;i++) {
			int l=scn.nextInt();
			int r=scn.nextInt();
			System.out.println(arr[r-1]-arr[l-1]);
		}
		
	}

}


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

int main() {
    const int MOD = 1000000007;
    int n, k;
    cin >> n >> k;
    long long ans = 0;
    for (long long i = k; i <= n+1; i++) {
        ans += i*(n-i+1) + 1;
    }
    cout << ans%MOD << endl;
    return 0;
}

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

#define int long long
#define rep(i,a,n) for(int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(),(x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort((c).begin(), (c).end(), greater<int>());
#define fi first
#define se second
#define INF (1e9)

typedef pair<int,int> P;
typedef vector<int> vi;

int a,b;

signed main() {
  cin>>a>>b;

int ans;
  if(a%2==0) {
    if(b%2==0) {
      int ctn=(b-a)/2;
      if(ctn%2==0) {
        ans=b;
      }else{
        ans=b^1;
      }
    }else{
      int ctn=(b-a+1)/2;
      if(ctn%2==0) {
        ans=0;
      }else{
        ans=1;
      }
    }
  }else{
    if(b%2==0) {
      int ctn=(b-a-1)/2;
      ans=a^b;
      if(ctn%2==0) {
        ans^=0;
      }else{
        ans^=1;
      }
    }else{
      int ctn=(b-a)/2;
      ans=a;
      if(ctn%2==0) {
        ans^=0;
      }else{
        ans^=1;
      }
    }
  }

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

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

struct Node { int key; Node* le, * ri, * p; };
Node* root, * NIL;
void insert(int k) {
	Node* y = NIL, * x = root;
	Node* z;
	z = new(Node);
	z->key = k;
	z->le = NIL, z->ri = NIL;
	while (x != NIL) {
		y = x;
		if (z->key < x->key) x = x->le;
		else x = x->ri;
	}
	z->p = y;
	if (y == NIL) root = z;
	else {
		if (z->key < y->key) y->le = z;
		else y->ri = z;
	}
}
bool find(int k) {
	Node* x = root;
	while (x != NIL) {
		if (x->key > k) x = x->le;
		else if (x->key == k) return true;
		else x = x->ri;
	}
	return false;
}
void preorder(Node* u) {
	if (u != NIL) {
		printf(" %d", u->key);
		preorder(u->le);
		preorder(u->ri);
	}
}
void inorder(Node* u) {
	if (u != NIL) {
		inorder(u->le);
		printf(" %d", u->key);
		inorder(u->ri);
	}
}

int main() {
	int n, i, k;
	string com;
	cin >> n;
	while (n--) {
		cin >> com;
		if (com == "insert") cin >> k, insert(k);
		else if (com == "print") inorder(root), cout << endl, preorder(root), cout << endl;
		else if (com == "find") {
			cin >> k;
			if (find(k)) cout << "yes" << endl;
			else cout << "no" << endl;
		}
	}
}


Measured memory_bytes: 21956