akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
ll a, b;

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

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

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

  cin >> a >> b;

  ll ans = lcm(a, b);

  cout << ans << endl;
}


Measured memory_bytes: 384
#include<stdio.h>

int n,A[500000],count=0;

void merge(left,mid,right){
  int n1,n2,k;
  int i=0,j=0;
  n1 = mid -left;
  n2 = right - mid;
  int L[n1+1],R[n2+1];

  for(i=0;i<n1;i++){
    L[i] = A[left+i];
  }

  for(i=0;i<n2;i++){
    R[i] = A[mid+i];
  }

  L[n1] = 2000000000;
  R[n2] = 2000000000;

  i=0;
  j=0;
  
  for(k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k] = L[i];
      i = i + 1;
      count++;
    }
    else {
      A[k] = R[j];
      j = j+1;
      count++;
    }
  }
}


int mergeSort(left, right){
  int mid;
  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(left, mid);
    mergeSort(mid, right);
    merge(left, mid, right);
  }
  return count;
}
  

int main() {

  int i,left,right,mid;

  scanf("%d",&n);

  left = 0;
  right = n;

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

  mergeSort(left,right);

  for(i=0;i<n;i++){
    if(i==0){
      printf("%d",A[i]);
    }
    else printf(" %d",A[i]);
  }

  printf("\n%d\n",count);

  return 0;
}

  

  
    

  
  

  
  
  


  
    
  
  



Measured memory_bytes: 5596
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);
const long double PI=3.14159265358979;

// Required random number generators

// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    READV(L);
    FORI(i,0,N+1)
    {
        if(i*2+(N-i)*4==L)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;

//-----------------------------------------------------------------------------------------------------------//


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}

Measured memory_bytes: 3740
// https://atcoder.jp/contests/agc023/tasks/agc023_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, total = 0, ans = 0;
    cin >> N;
    vector<int> A(N);
    unordered_map<int, int> mp;
    mp[0]++;
    for (auto &x : A) {
        cin >> x;
        total += x;
        mp[total]++;
    }
    for (auto &x : mp) {
        ans += x.second * (x.second - 1) / 2;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 10056
N = int(input())
l = list(map(int, input().split()))
c = 0
b = 0
for i in range(N):
    c += l[i] ** 2
    b += -2 * l[i]
x = -b / (2 * N)
x = round(x)
Ans = N * x ** 2 + b * x + c

print(Ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
//東日本大震災から8年です。黙祷……

int main(){
  ll N; cin >> N;
  vector<pair<ll,ll>> S(N);
  vector<pair<ll,ll>> D(N);
  ll C=0;
  for(int i=0;i<N;i++){
    cin >> S.at(i).first;
    S.at(i).second=i;
  }
  sort(S.begin(),S.end());
  for(int i=0;i<N;i++){
    int dif = S.at(i).second-i;
    if(dif%2){ //2n+1
      C++;
    }
  }
  cout << C/2;
}

Measured memory_bytes: 3328
import java.util.Scanner;

class Main {

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

        int N = scan.nextInt();
        int a ;
        int b ;
        int c ;
        int i ;

        for (i = 0; i < N; i++) {
            a = scan.nextInt();
            b = scan.nextInt();
            c = scan.nextInt();
            
            if (a * a + b * b == c * c || b * b + c * c == a * a || c * c + a * a == b * b) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }
    }
}



Measured memory_bytes: 32628
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> arr(n, 0);
    for(auto& val: arr)
        cin >> val;
    ll ans = 0;
    for(int i = 1; i < n; i++) {
        ans += min((arr[i]-arr[i-1])*a, b);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1024
u,s,e,w,n,b = map(int,input().split())
roll = input()
for i in roll:
	if i == "E":
		tmp = e
		e = u
		u = w
		w = b
		b = tmp
	elif i == "S":
		tmp = s
		s = u
		u = n
		n = b
		b = tmp
	elif i == "W":
		tmp = w
		w = u
		u = e
		e = b
		b = tmp
	elif i == "N":
		tmp = n
		n = u
		u = s
		s = b
		b = tmp

print(u)

Measured memory_bytes: 7644
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
int main()
{
	int n;
	cin >> n;
	if(n%10 == ((n/10)/10))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
} 




Measured memory_bytes: 256
using Kujikatsu002.Questions;
using Kujikatsu002.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Kujikatsu002.Questions
{
    /// <summary>
    /// https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_b
    /// </summary>
    public class QuestionB : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var hw = inputStream.ReadLongArray();
            var h = hw[0];
            var w = hw[1];

            if (h == 1 || w == 1)
            {
                yield return 1;
            }
            else
            {
                yield return (h * w + 1) / 2;
            }
        }
    }
}


namespace Kujikatsu002
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionB();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Kujikatsu002.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Kujikatsu002.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//
        int N, K;
        cin >> N >> K;
        vector<int> vec(N);
        int sum = 0;
        for (int i = 0; i < N; i++)
        {
                cin >> vec[i];
                sum += vec[i];
        }

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

        cout << N + (K - sum) / vec[0] << endl;

        return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>

using namespace std;

typedef long long LL;

const int N = 100010, INF = 1e9;

int main()
{
    int n, k, s;
    scanf("%d%d%d", &n, &k, &s);
    
    for(int i = 0; i < k; i ++)  printf("%d ", s);
    for(int i = k; i < n; i ++)
        if(s == INF)  printf("%d ", s - 1);
        else  printf("%d ", INF);
    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,z,w;
    cin>>n>>z>>w;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
    }
    if(n==1){
        cout<<abs(a[0]-w)<<endl;
    }else{
        ll x=abs(a[n-1]-a[n-2]),y=abs(a[n-1]-w);
        cout<<max(x,y)<<endl;
    }
}

Measured memory_bytes: 3648
n, m = map(int, input().split())
student = [list(map(int, input().split())) for _ in range(n)]
check = [list(map(int, input().split())) for _ in range(m)]

for a, b in student:
    pos = 0
    dis = 10**9
    for i, x in enumerate(check, 1):
        c, d = x
        mdis = abs(a-c) + abs(b - d)
        if mdis < dis:
            pos = i
            dis = mdis
    print(pos)


Measured memory_bytes: 9068
#include <stdio.h>
#include <stdlib.h>

struct node {
    int key;
    struct node *parent;
    struct node *left;
    struct node *right;
};
typedef struct node *NodePointer;

NodePointer root = NULL;

void initNode(NodePointer nd, NodePointer parent, int key) {
    nd->parent = parent;
    nd->key = key;
    nd->left = NULL;
    nd->right = NULL;
}

// キーを元に探し、含まれるノードを返します
// 無い場合は最後のノードを返します
// @param int key
// @return pointer
NodePointer search(int key) {
    NodePointer target = root;
    NodePointer result = NULL;

    while (target != NULL) {
        result = target;

        if (key < target->key) {
            target = target->left;
        } else if (key == target->key) {
            break;
        } else {
            target = target->right;
        }
    }
    return result;
}

void insert(int key) {
    NodePointer nd = (NodePointer)malloc(sizeof(struct node));
    NodePointer parent = NULL;

    parent = search(key);
    initNode(nd, parent, key);

    if (root == NULL) {
        root = nd;
    }
    else if (key < parent->key) {
        parent->left = nd;
    }
    else {
        parent->right = nd;
    }

}

void inorder(NodePointer n){
    if(n == NULL){
        return;
    } else {
        inorder(n->left);
        printf(" %d", n->key);
        inorder(n->right);
    }
}

void preorder(NodePointer n) {
    if(n == NULL){
        return;
    } else {
        printf(" %d", n->key);
        preorder(n->left);
        preorder(n->right);
    }
}

int main() {
    int n, input, i;
    char command[10];

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        scanf("%9s", command);

        switch (command[0]) {
            case 'i':
                scanf("%d", &input);
                insert(input);
                break;
            case 'p':
                inorder(root);
                printf("\n");
                preorder(root);
                printf("\n");
                break;
        }
    }
}


Measured memory_bytes: 25188
#include<bits/stdc++.h>
using namespace std;
// g++ Main.cpp -std=gnu++1y -O2 -I/opt/boost/gcc/include -o main && ./main

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vll = vector<vl>;
using vii = vector<vi>;
using pii = pair<int, int>;

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i, a, b) for(int (i) = a; (i) < (b);(i)++)
#define MAX(a, b) ((a > b) ? a : b)
#define MIN(a, b) ((a > b) ? b : a)

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


const int MOD = 1e9 + 7;


int main(){
  int n; cin >> n;
  if(n == 7 || n == 5 || n == 3) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define INF 1e9+7
#define roop(i,m,n) for(int i=m;i<n;i++)
#define mroop(i,m,n) for(int i=m;i<n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;

//(int)'a'は97 (int)'A'は65
//おまじない



int main() {

	int n[100] = { 0 };
	int N = 0;
	

	cin >> N;
	roop(i, 0, N) {
		cin >> n[i];
	}

	ll ans = INF;
	ll sum = 0;

	roop(i, -100, 101) {
		sum = 0;
		roop(j, 0, N) {
			sum += abs(i - n[j])*abs(i - n[j]);
		}
		ans = min(ans, sum);
	}


	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int m = scan.nextInt();
    String a = "";
    String b = "";
 
    for (int i=0;i<m;i++){
      a += n+"";
    }
 
    for (int j=0;j<n;j++){
      b += m+"";
    }
 
    if (n>=m){
      System.out.println(b);
    }
    else{
      System.out.println(a);
    }
  }
}

Measured memory_bytes: 39180
#include <bits/stdc++.h>
using namespace std;
bool s(int key,int A[],int n){
	int left=0,right=n;
	while(left<right){
		int mid = (left+right)/2;
		if(A[mid]==key) return 1;
		else if(A[mid]<key)
			left=mid+1;
		else right=mid;
	}
	return 0;
}

int main(){
	int n,q,ans=0;
	int N[100000],Q[5000];
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&N[i]);
	scanf("%d",&q);
	for(int i=0;i<q;i++){
		scanf("%d",&Q[i]);
		if(s(Q[i],N,n)) ans++;
	}
	printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3632
from math import floor
def main():
    a, b = map(int, input().split())
    for i in range(1, 1010):
        x1 = floor(i*0.08)
        x2 = floor(i*0.1)
        if x1 == a and x2 == b:
            print(i)
            return
    print('-1')
main()



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

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

  if (m % n == 0) cout << m+n <<endl;
  else cout << m-n << endl;
}


Measured memory_bytes: 256
# 2019/12/20

h,w=map(int,input().split())
snuke=[list(input().split()) for _ in range(h)]

for i in range(h):
    for j in range(w):
        if snuke[i][j]!='snuke':continue
        print(chr(j+65)+str(i+1))
        exit()

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#define ll long long
using namespace std;
const int maxn=200010;
int pre[maxn*2],last[maxn],other[2*maxn],num,col[maxn];
bool vis[maxn],flag;
ll P,I,Q;
vector<int>V;
void add(int x,int y){
	num++;
	pre[num]=last[x];
	last[x]=num;
	other[num]=y;
}
int main(){
	int n,m;
	int x,y;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		add(x,y);
		add(y,x);
	}
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			queue<int>q; 
			q.push(i);
			col[i]=0;vis[i]=1;
			flag=1;
			V.clear();
			V.push_back(i);
			while(!q.empty()){
				int t=q.front();
				q.pop();
				for(int i=last[t];i;i=pre[i]){
					int v=other[i];
					if(!vis[v]){
						q.push(v);
						V.push_back(v);
						col[v]=col[t]+1;
						vis[v]=1;
					}
					else{
						if((col[v]-col[t])%2==0)
						flag=0;
					}
				}
			}
			if(V.size()==1) I++;
			else{
				if(flag) Q++;
				else P++;
			}
      	}	
	}
	ll ans=2*I*n-I*I+P*P+2*P*Q+2*Q*Q;
	printf("%lld\n",ans); 
	return 0;
}

Measured memory_bytes: 5344
#include<bits/stdc++.h>
using namespace std;
int n,a,b,m;
vector<int>v[501];
bool used[501];
void dfs(int x){
  used[x]=1;
  for(int i=0;i<v[x].size();i++){
    if(!used[v[x][i]])dfs(v[x][i]);
  }
}
main(){
  cin>>n>>m;
  for(int i=0;i<m;i++){
    cin>>a>>b;
    v[a].push_back(b);
  }
  int sum=0,aa=0;
  for(int i=1;i<=n;i++){
    if(!used[i])dfs(i),aa++;
  }
  for(int i=1;i<=n;i++)
    sum+=v[i].size()-1;
  cout<<sum+aa<<endl;
}

Measured memory_bytes: 3180
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))

from collections import Counter
c=Counter(d)
for i in range(m):
    if c[t[i]]==0:
        print("NO")
        exit()
    else:
        c[t[i]]-=1

print("YES")


Measured memory_bytes: 127572
#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;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 100001;
static const ll MOD = 1000000007;

//--global--//



//----------//

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//
    
    int a, b, c;
    cin >> a >> b >> c;
    if(a + b + c >= 22){
        cout << "bust";

    }
    else{
        cout << "win";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    map<int,int>freq;
    while (k--){
        int di;
        cin>>di;
        while (di--){
            int x;
            cin>>x;
            freq[x]++;
        }
    }
    int ans = 0;
    for (int i = 1;i<=n;i++){
        if (freq[i]==0)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3664
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)

def main():
    n = int(input().strip())
    dp = [0] * (n+1)
    # coins = [0] + [6**i for i in range(8)] + [9 ** i for i in range(1, 7)]
    for i in range(1, n+1):
        dp[i] = 10**10

    for b in (6, 9):
        p = 0
        while b**p <= n:
            for i in range(n+1):
                if b**p <= i:
                    dp[i] = min(dp[i], dp[i-b**p]+1)
            p += 1
    print(dp[n])
if __name__ == '__main__':
    main()


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

int main()
{
  int N;

  cin >> N;

  vector<int> X(N);

  for (int i = 0; i < N; i++)
  {
    cin >> X.at(i);
  }

  int min = *min_element(X.begin(), X.end());
  int max = *max_element(X.begin(), X.end());

  // int P = (min + max) / 2;
  int P;

  int sum = 0;
  long int sumMin = 99999999999999999;

  for (int i = min; i <= max; i++)
  {
    for (int j = 0; j < N; j++)
    {
      sum += (X.at(j) - i) * (X.at(j) - i);
    }
    if (sumMin > sum)
    {
      sumMin = sum;
    }
    sum = 0;
  }

  cout << sumMin << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<ll, ll>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int T; cin >> T;
    vector<bool> ans;
    rep(t, T) {
        int N; cin >> N;
        vector<ll> A(N);
        vector<ll> dp;
        rep(i, N) cin >> A[i];
        string S; cin >> S;
        rnr(i, N - 1, 0) {
            ll v = A[i];
            for(auto x : dp) {
                v = min(v, x ^ v);
                //重複しているbitを省く
                //もしA[i]がdpに含まれるならv = 0
            }
            //v not equal 0 -> A_i do not include in dp
            if(v) {
                if(S[i] == '1') {
                    ans.pb(1);
                    break;
                }
                dp.pb(v);
            }
        }
        if(ans.size() < t + 1) ans.pb(0);
    }
    rep(i, T)
        cout << ans[i] << endl;
}


Measured memory_bytes: 3568
#include <stdio.h>

int main(void)
{
	int n;
	int p;
	int prev;
	int i;
	int flag;
	
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		
		p = -1;
		flag = 0;
		for (i = 0; i < n; i++){
			prev = p;
			scanf("%d", &p);
			
			if (prev + 1 != p){
				if (prev == -1){
					printf("%d", p);
				}
				else {
					if (flag != 0){
						printf("-%d %d", prev, p);
						flag = 0;
					}
					else {
						printf(" %d", p);
					}
				}
			}
			else {
				flag = 1;
			}
		}
//printf("<%d -> %d>", prev, p);
		if (prev + 1 == p){
			if (prev == -1){
				printf("%d", p);
			}
			else {
				printf("-%d", p);
			}
		}
//		else {
//			if (prev != -1){
//				printf(" %d", p);
//			}
//		}
		
		printf("\n");
	}
	return (0);
}

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

int main(){
    ll a,b;
    cin >> a >> b;
    ll x,y;
    if((a/2)%2){
        if(a%2)x=(a-1)^1;
        else x=1;
    }else{
        if(a%2)x=(a-1)^0;
        else x=0;
    }
    if(((b+1)/2)%2){
        if((b+1)%2)y=b^1;
        else y=1;
    }else{
        if((b+1)%2)y=b^0;
        else y=0;
    }

    cout << (x^y) << endl;
}

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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

#define ALL(a) a.begin(),a.end()

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}


void solve(){
  int N, K;
  cin >> N >> K;

  int p[200000+5] = {};

  rep(i, N){
    cin >> p[i];
  }

  ll u[200000+5] = {};
  ll sum = 0;
  rep(i, K){
    sum += p[i];
  }

  rep(i, N - K + 1){
    u[i] = sum;
    sum -= p[i];
    sum += p[i+K];
  }

  cout << fixed << setprecision(10) << (*max_element(u, u+N-K+1) + K) / 2.0 << endl;
}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  solve();
  return 0;
}

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

namespace abc150_c
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = GetInt();
            var P = string.Join("", GetStrList());
            var Q = string.Join("", GetStrList());

            var p = Permutation.Enumerate<int>(Enumerable.Range(1, N), N, false).Select(x => string.Join("", x)).OrderBy(x => x).ToList();

            Console.WriteLine(Math.Abs(p.IndexOf(P) - p.IndexOf(Q)));
        }

        public static string GetStr() => Console.ReadLine();
        public static int GetInt() => int.Parse(Console.ReadLine());
        public static long GetLong() => long.Parse(Console.ReadLine());
        public static double GetDouble() => double.Parse(Console.ReadLine());
        public static decimal GetDecimal() => decimal.Parse(Console.ReadLine());

        public static List<string> GetStrList() => Console.ReadLine().Split(' ').ToList();
        public static List<int> GetIntList() => Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
        public static List<long> GetLongList() => Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
        public static List<double> GetDoubleList() => Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToList();
        public static List<decimal> GetDecimalList() => Console.ReadLine().Split(' ').Select(x => decimal.Parse(x)).ToList();

        /// <summary>
        /// 順列生成クラス
        /// </summary>
        public static class Permutation
        {
            /// <summary>
            /// 順列生成
            /// </summary>
            /// <typeparam name="T"></typeparam>
            /// <param name="items">選択対象</param>
            /// <param name="k">選択数</param>
            /// <param name="withRepetition">重複を許すかフラグ</param>
            /// <returns></returns>
            public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k, bool withRepetition)
            {
                if (k == 1)
                {
                    foreach (var item in items)
                    {
                        yield return new T[] { item };
                    }
                    yield break;
                }
                foreach (var item in items)
                {
                    var leftside = new T[] { item };
                    var unused = withRepetition ? items : items.Except(leftside);
                    foreach (var rightside in Enumerate(unused, k - 1, withRepetition))
                    {
                        yield return leftside.Concat(rightside).ToArray();
                    }
                }
            }

            internal static IEnumerable<object[]> Enumerate(string v1, int v2)
            {
                throw new NotImplementedException();
            }
        }

    }
}


Measured memory_bytes: 25180
#include<stdio.h>
#include<string.h>
int main()
{
	char s[200001],t[200001];
	int a,b,c,i,j;
	scanf("%s %s",s,t);
	a=strlen(s);
	c=0;
	b=0;
	for(i=0;i<a;i++){
		c++;
	}
	for(i=0;i<a;i++){
		if(s[i]==t[i]) b++;
	}
	printf("%d\n",c-b);
	return 0;
}


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

int main() {
    int N, T;
    cin >> N >> T;
    vector<int> v(N);
    for (int& x : v) cin >> x;

    int ans = T; // 最後に押した人は必ず+Tされる
    for (int i = 0; i < N-1; i++) {
        ans += min(v[i+1] - v[i],  T);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
H = int(input())

n = 0
while True:
    if 2 ** n <= H < 2 ** (n+1):
        break
    n += 1
if n == 0:
    ans = 1
else:
    ans = 1
    for i in range(1, n+1):
        ans += 2**i

print(ans)

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

int main(){
  string A, B, C;
  cin >> A >> B >> C;
  if(A.at(A.size()-1)==B.at(0) && B.at(B.size()-1)==C.at(0)) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;

int main() {
    int N;
    cin >> N;
    bool flag = false;
    for(int i = 1; i <= 9; ++i) {
        if(N % i == 0 && N / i <= 9) {
            flag = true;
        }
    }
    cout << (flag ? "Yes" : "No") << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(a, n) for (int a=0; a<n; a++)
#define F(a, n) for (int a=1; a<=n; a++)
using namespace std;

struct node{
	vector<int> nei;
	vector<int> children;
	int sg, par=-1;
};
node A[100005];
int n, x, y;
void orient(int nd){
	for (auto x: A[nd].nei) if (x!=A[nd].par){
		A[nd].children.push_back(x);
		A[x].par = nd;
		orient(x);
	}
}

void sg(int nd){
	int ret = 0;
	for (auto x: A[nd].children){
		sg(x);
		ret ^= A[x].sg;
	}
	ret++;
	A[nd].sg = ret;
	return;
}
int main() {
	cin>>n;
	f(i, n-1){
		cin>>x>>y;
		A[x].nei.push_back(y);
		A[y].nei.push_back(x);
	}
	orient(1);
	sg(1);
	cout<<(A[1].sg == 1 ? "Bob" : "Alice") <<endl;
}

Measured memory_bytes: 18176
#include<bits/stdc++.h>
using namespace std;
int n,k,t[255],ans;
bool b[100005];
char a[100005],win[255];
int main()
{
	scanf("%d%d%d%d%d%s",&n,&k,&t['r'],&t['s'],&t['p'],a);
	win['r']='p',win['s']='r',win['p']='s';
	for(int i=0;i<n;i++){
		if(i<k) ans+=t[win[a[i]]],b[i]=1;
		else if(!b[i-k]||win[a[i-k]]!=win[a[i]]) ans+=t[win[a[i]]],b[i]=1;
	}
	printf("%d\n",ans);
}

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

using namespace std;

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

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

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

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

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

//const ll mod = 1e10;
typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

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

    queue<ll> q;
    vector<ll> ans;

    auto add = [&](ll s) {
        q.push(s);
        ans.push_back(s);
    };

    rep(i, 10) if (i > 0) add(i);

    while (ans.size() < k) {
        ll t = q.front();
        q.pop();

        ll m = t % 10;
        if (m != 0) add(t * 10 + m - 1);
        add(t * 10 + m);
        if (m != 9) add(t * 10 + m + 1);;
    }

    cout << ans[k - 1] << endl;

}


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

#define MAX_N 500

using namespace std;

typedef long long lint;

lint a[MAX_N + 1][MAX_N + 1];

int n;

int k;
int v[(MAX_N << 1) + 1];

const int dl[] = {-1, 1, 0, 0};
const int dc[] = {0, 0, 1, -1};

set <int> diff;

int diagST[(MAX_N << 1) + 1];
int diagDR[(MAX_N << 1) + 1];

bool p[7920];

void readFile()
{
    cin >> n;
}

void ciur()
{
    int n = 7919;

    int i, j;
    for(i = 4; i <= n; i += 2)
        p[i] = 1;

    for(i = 3; i * i <= n; i += 2)
    {
        if(p[i] == 0)
        {
            for(j = i * i; j <= n; j += (i * 2))
                p[j] = 1;
        }
    }

    v[++ k] = 2;
    for(i = 3; i <= n; i += 2)
    {
        if(p[i] == 0)
            v[++ k] = i;
    }
}

void getDiags()
{
    int cr = 1;
    for(int st = n; st >= 1; st -= 2)
        diagST[st] = v[cr ++];

    for(int st = n + 2; st <= (n << 1); st += 2)
        diagST[st] = v[cr ++];

    for(int dr = 1; dr <= (n << 1); dr += 2)
        diagDR[dr] = v[cr ++];
}

void getBlacks()
{
    int i, j;
    for(i = 1; i <= n; i ++)
    {
        for(j = 1; j <= n; j ++)
        {
            if(((i + j) & 1) == 0)
            {
               // cout << "PE " << i << " " << j << " PUNEM " << diagST[n + i - j] << " sI " << diagDR[i + j - 1] << "\n";
                a[i][j] = diagST[n + i - j] * diagDR[i + j - 1];
            }
        }
    }
}

void getWhites()
{
    for(int i = 1; i <= n; i ++)
    {
        for(int j = 1; j <= n; j ++)
        {
            if(a[i][j] == 0)
            {
                diff.clear();
                for(int dir = 0; dir < 4; dir ++)
                {
                    int nl = i + dl[dir];
                    int nc = j + dc[dir];
                    if(nl >= 1 && nl <= n && nc >= 1 && nc <= n)
                    {
                        diff.insert(diagST[n + nl - nc]);
                        diff.insert(diagDR[nl + nc - 1]);
                    }
                }

                lint rez = 1;
                for(auto u : diff)
                    rez = rez * u;

                a[i][j] = rez + 1;
            }
        }
    }
}

void solve()
{
    ciur();

    getDiags();

    getBlacks();

    getWhites();
}

void printFile()
{
    for(int i = 1; i <= n; i ++)
    {
        for(int j = 1; j <= n; j ++)
            cout << a[i][j] << " ";
        cout << "\n";
    }
}

int main()
{
    readFile();
  
  	if(n == 2)
   {
      cout << "4 7\n23 10\n";
      return 0;
    }

    solve();

    printFile();

    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll k;
    cin >> k;
    ll p = k / 50;
    ll q = k % 50;
    vll a(50, 49 + p);
    rep(i, 50) {
        if (i < q) a[i] += 51 - q;
        else a[i] -= q;
    }
    cout << 50 << endl;
    rep(i, sz(a)) {
        if (i != 0) cout << " ";
        cout << a[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
public:
  ll *fac,*finv,*inv;
  Comb(){
    fac = new ll[1000001];
    finv = new ll[1000001];
    inv = new ll[1000001];
    fac[0] = 1;
    for(int i=1;i<1000001;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000001;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000001;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  int n,p;
  string s;
  cin >> n >> p >> s;
  if(10%p == 0){
    ll ans = 0;
    for(int i=0;i<n;i++){
      int temp = s[i]-'0';
      if(temp%p == 0) ans += (i+1);
    }
    cout << ans << endl;
    return 0;
  }

  unordered_map<ll,ll> table;
  ll now = 0;
  ll seq[n];
  ll mul = 1;
  for(int i=n-1;i>=0;i--){
    int temp = s[i]-'0';
    temp *= mul;
    temp %= p;
    now += temp;
    now %= p;
    seq[i] = now;
    mul *= 10;
    mul %= p;
  }
  table[0] = 1;
  ll ans = 0;
  for(int i=0;i<n;i++){
    table[seq[i]]++;
  }

  for (int i=0;i<n;i++){
    ans += table[seq[i]]-1;
    table[seq[i]]--;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2436
import std.stdio;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.random;
import std.regex;
import std.typecons;

int E;
bool input() {
    scanf("%d\n", &E);
    return E != 0;
}

void solve() {
    int ans = int.max;
    for (int z = 0; z <= 100; z++) {
        for (int y = 0; y <= 1000; y++) {
            int x = E - (z * z * z) - (y * y);
            if (x < 0) continue;
            ans = min(ans, x + y + z);
        }
    }
    writeln(ans);
}

void main() {
    while (input) solve;
}

Measured memory_bytes: 1060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const ll MOD=1e9+7;
#define endl '\n'
#define F first
#define S second
#define pb push_back
const double PI = 3.141592653589793238460;
  void c_p_c()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
    #endif
}
mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());
long long int binpow(long long int a, long long int b) {
    long long int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}


void solve()
{
  int n,m;cin>>n>>m;
  char s[n+1][m+1];
  int dp[n+1][m+1];
  memset(dp,0,sizeof(dp));
  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<=m;j++)
    {
      cin>>s[i][j];
    }
  }
  int flag=0,flag2=0;
  for(int i=1;i<=n;i++)
  {
    if(s[i][1]=='#')
    {
      flag=1;

    
    }
    if(flag==1)
      dp[i][1]=0;
    else
      dp[i][1]=1;


  }
  for(int i=1;i<=m;i++)
  {
    if(s[1][i]=='#')
    {
      flag2=1;
      
    }
    if(flag2==1)
      dp[1][i]=0;
    else
      dp[1][i]=1;
    

  }

 



    for(int i=2;i<=n;i++)
  {
    for(int j=2;j<=m;j++)
    {
      if(s[i][j]=='.')
        dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
      else
        dp[i][j]=0;
      
    }
  }
  cout<<dp[n][m]%MOD;


  

}



int  main()
{
  c_p_c();
  int t=1;
  while(t--)
  {
    solve();
  }


 

  return 0;

}

Measured memory_bytes: 8500
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
  int d;
  scanf("%d",&d);
  if(d==25)puts("Christmas");
  if(d==24)puts("Christmas Eve");
  if(d==23)puts("Christmas Eve Eve");
  if(d==22)puts("Christmas Eve Eve Eve");
  return 0;
}

Measured memory_bytes: 128
def main():

    K = int(input())
    if 7 % K == 0: return 1
    r = 7 % K
    for i in range(2, 1000000):
        r = (r * 10 + 7) % K
        if r == 0:
            return i
    return -1




if __name__ == '__main__':
    print(main())


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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

//#define int long long
#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    char g[n][m] = {};
    rep(i, n)rep(j, m) cin >> g[i][j];
    int ans = INF;
    rep2(i, 1, n + 1)rep2(j, i + 1, n + 1) {
        int cnt = 0;
        if (j == n) continue;
        rep(y, i)rep(x, m) if (g[y][x] != 'W') cnt++;
        rep2(y, i, j)rep(x, m) if (g[y][x] != 'B') cnt++;
        rep2(y, j, n)rep(x, m) if (g[y][x] != 'R') cnt++;
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3144
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    a = f()
    a = sorted(a, reverse = True)

    b = a[0] - a[1] #xiao
    c = a[0] - a[2] #da


    if (c-b)%2 == 0:
        print((c-b)//2 + b)
    else:
        print((c-b-1)//2 + b+2)




solve()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  int n, k; cin >> n >> k;
  double ans = 0;
  REPI (i, 1, n + 1) {
    int x = i;
    double acc = 1 / double(n);
    while (x < k) {
      acc *= 0.5;
      x *= 2;
    }
    dump(i, acc);
    ans += acc;
  }
  cout << setprecision(10);
  cout << ans << endl;
}


Measured memory_bytes: 256
main :: IO ()
main = do
  getLine :: IO String
  as <- map read . words <$> getLine :: IO [Integer]
  let
    l = length . filter (< 0) $ as
    as' = map abs $ as
    s' = sum as'
    m = minimum as'
    s = if even l then s' else s' - 2 * m
  print s


Measured memory_bytes: 39548