akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
 string S;
  cin>>S;
  
  vector<vector<ll>>dp(S.size()+1,vector<ll>(13));
  dp[0][0]=1;//漸化式を意識する
  int tmp=1;
  rep(i,S.size()){
    if(S[S.size()-1-i]=='?'){//一の位から見ていく
      rep(j,10){//各位0~9
rep(k,13){//余り
  dp[i+1][(j*tmp+k)%13]+=dp[i][k];//i+1は１桁目から何文字、この文字列のうち余りがkであるものの数
  dp[i+1][(j*tmp+k)%13]%=mod;//i文字目までで余りがkとなるようなi+1目の文字を考える
}
      }
    }
else{
  ll j=S[S.size()-1-i]-'0';
  rep(k,13){
dp[i+1][(j*tmp+k)%13]+=dp[i][k];//上と同じ要領でi文字までであまりがkのものをi+1に引き継ぐ
    dp[i+1][(j*tmp+k)%13]%=mod;
  }
}
      
      tmp*=10;//下から桁を見ていくため
      tmp%=13;
    }
cout<<dp[S.size()][5]<<endl;
  
  }

Measured memory_bytes: 13696
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

const int mod = 1e9+7;
struct mint {
    ll x;
    mint (ll x = 0) : x((x%mod+mod)%mod) {}
    mint operator -() const {return mint(-x);}
    mint& operator +=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator -=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator *=(const mint a) {(x *= a.x) %= mod; return *this;}
    mint operator +(const mint a) const {return mint(*this) += a;}
    mint operator -(const mint a) const {return mint(*this) -= a;}
    mint operator *(const mint a) const {return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {return pow(mod-2);}
    mint operator /=(const mint a) {return *this *= a.inv();}
    mint operator /(const mint a) {return mint(*this) /= a;}
};
istream& operator >>(istream &is, const mint &a) {return is >> a.x;}
ostream& operator <<(ostream &os, const mint &a) {return os << a.x;}

mint dp[1005][4][4][4];

int main() {
    int n; cin >> n;
    dp[0][3][3][3] = 1;
    for (int len = 0; len < n; len++) {
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                for (int k = 0; k < 4; k++) {
                    for (int a = 0; a < 4; a++) {
                        if (a == 1) {
                            if (i == 2 && j == 0) continue;
                            if (i == 0 && j == 2) continue;
                            if (j == 2 && k == 0) continue;
                            if (i == 2 && k == 0) continue;
                        }
                        if (a == 2 && i == 1 && j == 0) continue;
                        dp[len+1][a][i][j] += dp[len][i][j][k];
                    }
                }
            }
        }
    }
    mint ans = 0;
    rep(i,4)rep(j,4)rep(k,4) ans += dp[n][i][j][k];
    cout << ans << endl;
}

Measured memory_bytes: 768
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
//#define INF 1100000000000000000LL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int main(){
	int N;
	cin>>N;
	vint A,B,C;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		A.pb(a);
	}
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		B.pb(a);
	}
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		C.pb(a);
	}
	sort(A.begin(),A.end());
	sort(B.begin(),B.end());
	sort(C.begin(),C.end());
	vint D;
	for(int i=0;i<N;i++){
		D.pb(C.end()-upper_bound(C.begin(),C.end(),B[i]));
	}
	ll ans=0;
	ll E[SIZE]={};
	E[N-1]=D[N-1];
	for(int i=N-2;i>=0;i--){
		E[i]=(ll)D[i]+E[i+1];
	}
	for(int i=0;i<N;i++){
		int big=N,sma=-1;
		while(big-sma>1){
			int mid=(big+sma)/2;
			if(B[mid]>A[i]){
				big=mid;
			}
			else{
				sma=mid;
			}
		}
		ans+=E[big];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3320
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define FOR(i, n, m) for (ll i = (n); i < (m); ++i)
#define FORR(i, n, m) for (ll i = (m) - 1; i >= (n); --i) 
#define FORE(x, xs) for (auto &x: (xs))
#define ALL(v) v.begin(), v.end()
#define ZERO(a) memset(a,0,sizeof(a))

const int INF = 1000000009;
const int MOD = 1000000007;
const double EPS = 1e-14;
const double PI = acos(-1);

const int MAX = 120;

int N;
int A[MAX];

int abs(int x, int y) {
  if (x > y) return x-y;
  else return y-x;
}

int main() {
  cin >> N;
  int sum = 0;
  REP (i, N) {
    cin >> A[i];
    sum += A[i];
    A[i] *= N;
  }

  int ans = 0;
  int d = INF;
  REP (i, N) {
    if (abs(sum, A[i]) < d) {
      d = abs(sum, A[i]);
      ans = i;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define mii map<int,int>
#define io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main() {
	io;
	int n;
	cin>>n;
	string s;
	cin>>s;
	int ans=0;
	for(int i=0;i<n;){
	    while(s[i]==s[i+1]&&i<n-1) i++;
	    i++;
	    ans++;
	}
	cout<<ans;
	return 0;
	
}

Measured memory_bytes: 512
/*
AizuOnline A0071
Title Bombs Chain
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
int N;
char ban[8][9];
int sx,sy;
//
void explode(int y,int x)
{
  int i;

  if(x < 0 || x >= 8 || y<0 || y>=8 || ban[y][x]=='0')
    return;
  //printf("%d %d\n",y,x);
  ban[y][x]='0';
  for(i= 1;i<= 3;i++)
    { 
      explode(y,x-i);
      explode(y,x+i);
      explode(y-i,x);
      explode(y+i,x);
    }
}
void show()
{
  int i,j;
  for(i=0;i<8;i++)
    {
      for(j=0;j<8;j++)
      	printf("%c",ban[i][j]);
      printf("\n");
    }
}
main()
{
  int i,j;

  scanf("%d",&N);

  for(i=0;i<N;i++)
    {
      for(j=0;j<8;j++)
	scanf("%s",&(ban[j][0]));

      scanf("%d %d",&sx,&sy);
      explode(sy-1,sx-1);     // x,y=1BASE

      printf("Data %d:\n",i+1);
      show();

    }
return(0);
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)
#define FORR(i,n,m) for(ll i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K


int bubbleSort(int n,char cardMarks[],int cardNOs[]){
    REP(i,n){
        REP(j,n-i-1){
            if(cardNOs[j]>cardNOs[j+1]){
                swap(cardNOs[j],cardNOs[j+1]);
                swap(cardMarks[j],cardMarks[j+1]);
            }
        }
    }
    REP(i,n){
        cout << cardMarks[i] << cardNOs[i];
        if(i!=n-1){
            cout << " ";
        }
    }
    cout << endl << "Stable" << endl;
    return 0;
}

int selectSort(int n,char cardMarks[],int cardNOs[],char selected[]){
    bool isStable = 1;
    REP(i,n){
        int minNOs = i;
        FOR(j,i,n){
            if(cardNOs[minNOs]>cardNOs[j]){
                minNOs = j;
            }
        }
        swap(cardNOs[minNOs],cardNOs[i]);
        swap(cardMarks[minNOs],cardMarks[i]);

        cout << cardMarks[i] << cardNOs[i];
        if(i!=n-1){
            cout << " ";
        }
        if(isStable)isStable = cardMarks[i]==selected[i];
    }
    cout << endl;
    if(isStable){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }
    return 0;
}

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

    int cardNOs1[40];
    int cardNOs2[40];
    char cardMarks1[40];
    char cardMarks2[40];
    REP(i,n){
        char card[2];
        cin >> card;
        cardMarks1[i] = card[0];
        cardMarks2[i] = card[0];
        cardNOs1[i] = atoi(&card[1]);
        cardNOs2[i] = atoi(&card[1]);
    }
    bubbleSort(n,cardMarks1,cardNOs1);
    selectSort(n,cardMarks2,cardNOs2,cardMarks1);
    return 0;
}



Measured memory_bytes: 3224
#import pysnooper
#import os,re,sys,operator,math,heapq,string
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

s=input().rstrip()
t=input().rstrip()
cnt=0
for i in range(3):
    if s[i]==t[i]:
        cnt+=1
print(cnt)

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

int main()
{
  ll n, fx = 0;
  cin >> n;

  ll x = n;
  while (x)
  {
    fx += x % 10;
    x /= 10;
  }
  if (n % fx == 0)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3604
///
// File:  b.cpp
// Author: ymiyamoto
//
// Created on Sun Jan 14 21:04:49 2018
//
#include <bits/stdc++.h>
using namespace std;

#define rep(_n, _init, _N) for (int32_t _n = _init; _n < (int32_t)(_N); _n++)
#define rrep(_n, _N, _end) for (int32_t _n = (int32_t)(_N); _n >= _end; _n--)
#define iceil(_x, _y) (((_x) + (_y)-1) / (_y))
#define ifloor(_x, _y) ((_x) / (_y))

static const double pi = 2 * asin(1);
static const double precision = 10e-9;

int32_t main()
{
  int32_t K;
  cin >> K;

  vector<int64_t> A(K);
  rep(i, 0, K)
  {
    cin >> A[i];
  }

  int64_t num_min = 2;
  int64_t num_max = 2;
  rrep(i, K - 1, 0)
  {
    num_min = A[i] * iceil(num_min, A[i]);
    num_max = A[i] * ifloor(num_max, A[i]) + A[i] - 1;

    if (num_max< num_min || (num_min == num_max && (num_min % A[i] != 0))) {
      cout << -1 << endl;
      return 0;
    }
  }

  cout << num_min << " " << num_max << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>//大きい順
#define pqg priority_queue<int,vec,greater<int>>//小さい順
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}

ll mod=1000000007;
vecll per(200010);
ll pw(ll a,ll p){
    if(p==0)return 1;
    if(p%2==0){
        ll d=pw(a,p/2);
        return d*d%mod;
    }
    return a*pw(a,p-1)%mod;
}
void f(){
    per[0]=1;
    rep2(i,1,200009){
        per[i]=per[i-1]*i%mod;
    }
    return;
}

ll divide(ll a,ll b){
    return a*(ll)pw(b,mod-2)%mod;
}
ll comb(ll a,ll b){
    return divide(per[a],per[b]*per[a-b]%mod);
}

int main(){
    int n=in(),a=in(),b=in(),c=in();
    if(a==0){
        cout<<divide(100*n,b)<<endl;
        return 0;
    }
    if(b==0){
        cout<<divide(100*n,a)<<endl;
        return 0;
    }
    f();
    ll cnt_a=0,cnt_b=0;
    rep2(k,n,2*n-1){
        cnt_a+=k*divide(comb(k-1,n-1)*pw(a,n)%mod*pw(b,k-n)%mod,pw(100-c,k))%mod;
        cnt_a%=mod;
        cnt_b+=k*divide(comb(k-1,n-1)*pw(b,n)%mod*pw(a,k-n)%mod,pw(100-c,k))%mod;
        cnt_b%=mod;
    }
    cnt_a=divide(cnt_a*100%mod,100-c);
    cnt_b=divide(cnt_b*100%mod,100-c);
    cout<<(cnt_a+cnt_b)%mod<<endl;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

long long h[100000][3] {};
long long dp[100000][3] {};

long long rec(int i, int j) {
    if(dp[i][j] > 0) return dp[i][j];
    else {
        // cout << "i, j == " << i << ", " << j << endl;
        if(j == 0) return dp[i][j] = max(rec(i-1, 1) + h[i][0], rec(i-1, 2) + h[i][0]);
        else if(j == 1) return dp[i][j] = max(rec(i-1, 2) + h[i][1], rec(i-1, 0) + h[i][1]);
        else return dp[i][j] = max(rec(i-1, 0) + h[i][2], rec(i-1, 1) + h[i][2]);
    }
}

int main() {
    int N; cin >> N;
    for(int i = 0; i < N; ++i) for(int j = 0; j < 3; ++j) cin >> h[i][j];

    for(int i = 0; i < 3; ++i) dp[0][i] = h[0][i];

    cout << max(rec(N-1, 0), max(rec(N-1, 1), rec(N-1, 2))) << endl;
}


Measured memory_bytes: 9088
import java.io.*;
import java.util.*;
class Main
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static FastScanner sc=new FastScanner(br);
    static PrintWriter out=new PrintWriter(System.out);
	static Random rnd=new Random();
	
    public static void main(String args[]) throws Exception
    {
		char[] a=br.readLine().toCharArray();String s1="A",s2="",s3="C";
		for(int i=0;i<a.length;i++)
		{
			if(a[i]=='r')
			{
				s2=a[i+2]+"";break;
			}
		}
		out.println(s1+s2+s3);out.close();
    }
}
class FastScanner
{
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }
	
    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
	
	public String next() throws Exception {
		return nextToken().toString();
	}
	
    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}

Measured memory_bytes: 8020
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
 
#if DEBUG
    #include "debug.h"
#else
    #define debug(args...)
#endif    

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;


#define M 1000000 
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int INF = INT_MAX;
const int mod = 1e9+7;

const int N = 2e5 + 10;
inline int add(int x,int y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline int mul(int x,int y){
  x = (1LL * x * y) % mod;
  return x;
}
clock_t time_p=clock();



int32_t main(){
    fast;

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    int x;
    cin >> x;
    cout << 360 / (__gcd(360,x)) << "\n";


    time_p=clock()-time_p;
    cerr<<"\nTime Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";

    return 0;
}

Measured memory_bytes: 3804
#include<cstdio>
int main() {
	int face[6], q, i, a, b, p;
	scanf("%d%d%d%d%d%d%d", &face[0], &face[1], &face[2], &face[3], &face[4], &face[5], &q);
	for (i = 0; i < q; i++) {
		scanf("%d%d", &a, &b);
		if (a == face[0]) {
			if (b == face[1])p = 2;
			else if (b == face[2])p = 4;
			else if (b == face[4])p = 3;
			else p = 1;
		}
		else if (a == face[1]) {
			if (b == face[5])p = 2;
			else if (b == face[2])p = 0;
			else if (b == face[0])p = 3;
			else p = 5;
		}
		else if (a == face[2]) {
			if (b == face[5])p = 4;
			else if (b == face[4])p = 0;
			else if (b == face[0])p = 1;
			else p = 5;
		}
		else if (a == face[3]) {
			if (b == face[1])p = 0;
			else if (b == face[0])p = 4;
			else if (b == face[4])p = 5;
			else p = 1;
		}
		else if (a == face[4]) {
			if (b == face[0])p = 2;
			else if (b == face[2])p = 5;
			else if (b == face[5])p = 3;
			else p = 0;
		}
		else {
			if (b == face[4])p = 2;
			else if (b == face[2])p = 1;
			else if (b == face[1])p = 3;
			else p = 4;
		}
		printf("%d\n", face[p]);
	}
	return 0;
}


Measured memory_bytes: 2584
void main() {
  problem();
}

void problem() {
  const N = scan!int;
  const K = scan!int;
  auto A = scan!long(N).sort().sort!((a, b) => a.abs > b.abs).array;

  long solve() {
    if (K == N) return A.reduce!((r, a) => r.mulmod(a));
    if (A.all!(a => a < 0) && K % 2 == 1) return A[N-K..N].reduce!((r, a) => r.mulmod(a));

    auto aPlus = A.filter!(a => a >= 0).array;
    auto aMinus = A.filter!(a => a < 0).array;

    long plus, minus;
    long ans = 1;
    while(minus + plus != K) {
      auto k = plus + minus;

      if (K - k == 1 || aMinus.length - minus < 2) {
        ans = ans.mulmod(aPlus[plus++]);
        continue;
      }
      if (aPlus.length - plus < 2) {
        ans = ans.mulmod(aMinus[minus++]).mulmod(aMinus[minus++]);
        continue;
      }

      [ans, plus, minus].deb;

      auto minusTest = aMinus[minus] * aMinus[minus + 1];
      auto plusTest = aPlus[plus] * aPlus[plus + 1];

      if (minusTest >= plusTest) {
        ans = ans.mulmod(aMinus[minus++]).mulmod(aMinus[minus++]);
      } else {
        ans = ans.mulmod(aPlus[plus++]).mulmod(aPlus[plus++]);
      }
    }

    return ans;
  }

  solve().writeln;
}

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

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

enum MOD = 10^^9 + 7;
long mulmod(long a, long b) { auto m = a * b; return m < 0 ? MOD + (m % MOD) : m % MOD; }

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


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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}

	inline int tc()
	{
		int c=fetch();
		while(c<=32 && c!=EOF)c=fetch();
		return c;
	}
}
using ae86::ty;
using ae86::tc;

const int _ = 1503 , inf = 0x3f3f3f3f;

int n,val[_][_],sv[_][_]={0},xl[_][_],xr[_][_];

int main()
{
	n=ty();
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		{
			val[i][j]=tc();
			if(!isdigit(val[i][j]))val[i][j]=0;
			else val[i][j]-=48;
		}

	lint ans=0;
	for(int i=n;i>=1;i--)
		for(int j=n;j>=1;j--)
		{
			if(val[i][j])
			{
				if(val[i+1][j] && val[i][j+1])
				{
					int temp=sv[i+1][j]+sv[i][j+1],nowr=0;
					xl[j][i]=j,xr[j][i]=xr[j+1][i];
					for(int k=i+1;k<=n;k++)
					{
						if(xr[j][k]>=xl[j+1][k] && xl[j+1][k]>nowr)temp-=sv[k][xl[j+1][k]];
						nowr=max(nowr,xr[j][k]);
						xl[j][k]=min(xl[j][k],xl[j+1][k]),xr[j][k]=max(xr[j][k],xr[j+1][k]);
					}
					sv[i][j]=temp;	
				}
				else if(val[i+1][j])
				{
					xl[j][i]=xr[j][i]=j,sv[i][j]=sv[i+1][j];
				}
				else if(val[i][j+1])
				{
					for(int k=i;k<=n;k++)xl[j][k]=xl[j+1][k],xr[j][k]=xr[j+1][k];
					xl[j][i]=j,sv[i][j]=sv[i][j+1];
				}
				else xl[j][i]=xr[j][i]=j;
				ans+=1ll*sv[i][j]*val[i][j],sv[i][j]+=val[i][j];
			}
			else for(int k=i;k<=n;k++)xl[j][k]=inf,xr[j][k]=-inf;
		}

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 35584
//20/07/2019
#include<bits/stdc++.h>

using namespace std;

#define debug printf("Debug\n");
#define ll long long
#define ull unsigned long long
#define pi acos(-1.0)
#define mod 1000000007

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_freopen  freopen("in.txt", "r", stdin);
#define out_freopen freopen("out.txt", "w", stdout);




int main(){
    ll n;
    
    cin>>n;
    
    cout<<3*n*n<<endl;




    return 0;
}


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

using namespace std;

int main(){

  int n;

  cin>>n;

  for(int i=1;;i++){
    int ans=0;
    for(int j=1;j<=i;j++) if(i%j==0) ans++;
    if(ans==n){
      cout<<i<<endl;
      return 0;
    }
  }

  return 0;
}



Measured memory_bytes: 3080
import math

N = int(input())
ans = 0
Flag = True

def prime_fac(n):
  p_lis = []
  temp = n

  for i in range(2, int(math.sqrt(n)) + 1):
    if temp % i == 0:
      cnt = 0
      while temp % i == 0:
        cnt += 1
        temp //= i
      p_lis.append([i, cnt])
  
  #割り切れてなかったら残り(temp)は素数
  if temp != 1:
    p_lis.append([temp, 1])

  #素数だったら自身が1つ
  if p_lis == []:
    p_lis.append([n, 1])

  return p_lis

def f(n):
  cnt = 0
  i = 1
  temp = n - 1
  while temp >= 0:
    cnt += 1
    i += 1
    temp -= i
  return cnt

if N == 1:
  Flag = False
else:
  L = prime_fac(N)
  for P in L:
    ans += f(P[1])

if Flag:
  print(ans)
else:
  print(0) 


Measured memory_bytes: 9244
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <list>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <fstream>
#include <sstream>
#include <unordered_map>
#include <ctime>
#include <assert.h>
using namespace std;

const unsigned long long BASE = (unsigned long long)(1e9 + 7);

#define FROM_0(i, n) for(int i = 0; i < (n); i++)
#define FROM_S(i, s, e) for(int i = (s); i < (e); i++)
#define ITER_BEGIN_END(iter, vec) for(auto iter = vec.begin(); iter != vec.end(); iter++)

int main()
{
    int x;
    cin >> x;
    cout << 1 - x << endl;
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  string a,b,c,d;
  a = s.at(0);
  b = s.at(1);
  c = s.at(2);
  d = s.at(3);
  string ans = "No";
  if(a == b && c == d){
    ans = "Yes";
  }
  if(a == c && b == d){
    ans = "Yes";
  }
  if(a == d && b == c){
    ans = "Yes";
  }
  if(a == b && b == c && c == d){
    ans = "No";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
	char change[101],hikaku[101],take[101];
	int N;
	int i,j,k,pt=0;
	scanf("%s",change);
	scanf("%s",hikaku);
	N=strlen(change);
	for(i=0;i<N;i++)
	{
		for(j=i,k=0;j<N;j++,k++)take[k]=change[j];
		for(j=0;j<i;j++,k++)take[k]=change[j];
		take[k]='\0';
		if(strcmp(take,hikaku)==0){pt=1;break;}
	}
	if(pt==1)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(4100000)

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def resolve():
    # S = [x for x in sys.stdin.readline().split()][0]  # 文字列 一つ
    # N = [int(x) for x in sys.stdin.readline().split()][0]  # int 一つ
    H, W = [int(x) for x in sys.stdin.readline().split()]  # 複数int
    # h_list = [int(x) for x in sys.stdin.readline().split()]  # 複数int

    # grid = [list(sys.stdin.readline().split()[0]) for _ in range(N)]  # 文字列grid
    # v_list = [int(sys.stdin.readline().split()[0]) for _ in range(N)]
    # grid = [[int(x) for x in sys.stdin.readline().split()]
    #         for _ in range(N)]  # int grid

    logger.debug('{}'.format([]))
    if H == 1 or W == 1:
        print(1)
        return

    a = (H // 2) * (W // 2)
    b = math.ceil(H / 2) * math.ceil(W / 2)
    print(a + b)


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """4 5"""
        output = """10"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """7 3"""
        output = """11"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1000000000 1000000000"""
        output = """500000000000000000"""
        self.assertIO(input, output)


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

//ライブラリ始まり

//定数

//円周率
const double PI = 3.1415926535897932384;

//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 1000000000000000; // = 10^15

//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";

//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7

//データ構造

//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  UnionFind(int N) : UF(N) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    UF.at(rx) = ry; // xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

//関数

//ctoi
int ctoi(char c){
  if (c == '0') {
    return 0;
  }
  if (c == '1') {
    return 1;
  } 
  if (c == '2') {
    return 2;
  } 
  if (c == '3') {
    return 3;
  }
  if (c == '4') {
    return 4;
  } 
  if (c == '5') {
    return 5;
  } 
  if (c == '6') {
    return 6;
  }
  if (c == '7') {
    return 7;
  } 
  if (c == '8') {
    return 8;
  } 
  if (c == '9') {
    return 9;
  }
  return -1;  
}

//素数判定
bool PN(int x) {
  if (x <= 1) {
    return false; // 1や0,-1は素数ではない
  }
  if (x == 2) {
    return true; // √2 + 1 > 2 なので下でやると 2 ％ 2 = 0 となり判定できない
  }
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) {
      return false; // 割れたら素数じゃない
    }
  }
  return true;
}

//ライブラリ終わり

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<ll>> B(M, vector<ll>(2));
  for (int i = 0; i < M; i++) {
    cin >> B.at(i).at(0) >> B.at(i).at(1);
  }
  vector<ll> H(N, 1);
  vector<ll> K(M + 1);
  K.at(M) = 0;
  UnionFind T(N);
  for (int i = M - 1; i >= 0; i--) {
    K.at(i) = K.at(i + 1);
    if (T.same(B.at(i).at(1) - 1, B.at(i).at(0) - 1) == false) {
      K.at(i) += H.at(T.root(B.at(i).at(0) - 1)) * H.at(T.root(B.at(i).at(1) - 1));
      H.at(T.root(B.at(i).at(1) - 1)) += H.at(T.root(B.at(i).at(0) - 1));
      H.at(T.root(B.at(i).at(0) - 1)) = 0;
    }
    T.unite(B.at(i).at(0) - 1, B.at(i).at(1) - 1);
  }
  for (int i = 1; i <= M; i++) {
    cout << K.at(0) - K.at(i) << endl;
  }
}

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

int main(){
    int N, Y;
    cin >> N >> Y;
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= N - i; j++){
            if(i * 1000 + j * 5000 + (N - i - j) * 10000 == Y){
                cout << N - i - j << " " << j << " " << i << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
 int a,b,c;
  cin >> a;
  if(a==1){
    cout << "Hello World" << endl;
  }else{
    cin >> b >> c;
    cout << b+c << 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);
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    
    int ab, bc, ca;
    cin >> ab >> bc >> ca;
    cout << (ab * bc) / 2 << '\n';
    
    return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
l = list(input())

ans = 0

check =[[0]]
i = 0
while i < n:
    if l[i] == "1":
        a = i
        while i < n and l[i] == "1":
            i += 1
        check.append([a,i-1])
    i += 1
check.append([n-1])
if len(check)-k < 1:
    print(n)
    exit()
for i in range(len(check)-k):
       
    ans = max(ans,check[i+k][-1]-check[i][0]+1)
print(ans)



Measured memory_bytes: 12068
A, B, C, D, E, F = map(int, input().split())

dp = [[False for i in range(3001)] for j in range(2)]
for i in range(3001):
    if i % C == 0:
        dp[0][i] = True
for i in range(3001):
    if i % D == 0 or dp[0][i] or (i - D >= 0 and dp[1][i - D]):
        dp[1][i] = True
    
ans_sugar = 0
ans_total = 0
for i in range(31):
    for j in range(31):
        water = i * 100 * A + j * 100 * B
        if water > F:
            break
        for k in range(3000, -1, -1):
            sugar = k
            total = water + sugar
            if (water // 100) * E < sugar or F < total or not dp[1][k]:
                continue
            else:
                if (ans_sugar == 0 and ans_total == 0) or sugar * ans_total > total * ans_sugar:
                    ans_sugar = sugar
                    ans_total = total
                    break
print(ans_total, ans_sugar)

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

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    int res=0;
    int state=0;
    for(int i=0;i<n;i++){
        if(state==0){
            state=1;
            res++;
        }
        else if(state==1){
            if(a[i-1]<a[i]){
                state=2;
            }
            else if(a[i-1]>a[i]){
                state=3;
            }
        }
        else if(state==2){
            if(a[i-1]>a[i]){
                state=1;
                res++;
            }
        }
        else{
            if(a[i-1]<a[i]){
                state=1;
                res++;
            }
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    string s;
    cin>>s;
    int sm=700;
    for (int i=0;i<s.size();i++)
        if (s[i]=='o') sm+=100;
    cout<<sm<<endl;
    return 0;
} 

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b && b == c) {
    cout << 1 << endl;
  } else if(a == b || b == c || a == c) {
    cout << 2 << endl;
  } else {
    cout << 3 << endl;
  }
}

Measured memory_bytes: 256
while True:
    a, op, b = input().split()
    if op == '?':
        break
    else:
        if op == '+':
            print(int(a) + int(b))
        elif op == '-':
            print(int(a) - int(b))
        elif op == '*':
            print(int(a) * int(b))
        else:
            print(int(a) // int(b))


Measured memory_bytes: 5592
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 1001
#define INF 1410065408
#define EPS 1e-9
#define DEBUG 0
#define ll long long
#define Pll pair<ll, ll>
#define Pii pair<int, int>
 
using namespace std;
struct edge{int from, to; ll cost;};

signed main(){
    int n, m, tmp, ans = 0;
    cin >> n >> m;
    vector< map<int, int> > a(m);
    vector<int> count(m, 0);
    rep(n){
        cin >> tmp;
        a[tmp%m][tmp]++;
        count[tmp%m]++;
    }

    reppp(i, 1, (m-1)/2){
        int n_i = count[i], n_j = count[m-i];
        if(n_i > n_j){
            swap(a[i], a[m-i]);
            swap(n_i, n_j);
        }

        // 同じ数字のペア
        if(n_j - n_i >= 2)
            for(auto itr = a[m-i].begin(); itr != a[m-i].end(); ++itr){
                int dec_count = min(itr->second, n_j-n_i);
                if(dec_count % 2 == 1) dec_count--;
                if(dec_count > 0){
                    n_j -= dec_count;
                    ans += dec_count/2;
                }
            }
            //cout << ans << " ";
        
        // 合わせてmの倍数
        ans += min(n_i, n_j);
        //cout << ans << endl;
    }

    ans += count[0]/2;
    if(m % 2 == 0) ans += count[m/2]/2;
    
    cout << ans << endl;
}

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

int main()
{
    int a ,b;
    cin >> a >> b;
    int ave = 0;
if((a+b)%2==0){
     ave = (a + b) / 2;
}
else{
    ave = (a + b) / 2 +1;
}
    
    cout << ave << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <queue>
#include <set>
using namespace std;

int imax(int x, int y, int z){
  if(x >= y){
    if(x >= z) return x; // x >= y, x>=z
    else return z; // z>x>=y
  }
  else{
    if(y >= z) return y;//y>=z, y>x
    else return z; // z>y>x
  }
}

int main(){

  /* read input */
  int A, B, C;
  scanf("%d", &A);
  scanf("%d", &B);
  scanf("%d", &C);
  
  printf("%d", A+B+C+9*(imax(A, B, C)));

  return 0;
}


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

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

    int temp = 0;
    int first = K % 10;
    int result = 0;
    bool flag;

    while(true){
        int x = 7 - (temp % 10);
        if(x < 0)x += 10;
        flag = false;
        for(int i = 1; i <= 9; i++){
            if((i*first) % 10 == x){
                flag = true;
                temp += i*K;
                break;
            }
        }
        if(!flag){
            result = -1;
            break;
        }
        while(temp % 10 == 7){
            temp /= 10;
            result ++;
        }
        if(temp == 0)break;
    }

    cout << result << "\n";
    return 0;
}

Measured memory_bytes: 3664
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

int main() {
	int i, j, k;
	int a, b;

	cin >> a >> b;

	int cnt = 0;
	for (i = a; i <= b; i++) {
		string str = to_string(i);
		if (str[0] == str[4] && str[1] == str[3]) {
			cnt++;
		}
	}

	cout << cnt << endl;










	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
//
//  main.cpp

#include <iostream>
using namespace std;


int main(){	
	int check[201];
	int who[201];
	int matrix[201][3];
	int point[201];
	for(int i=0;i<201;i++){
		check[i] = 0;
		who[i] = -1;
		point[i] = 0;
		for(int j=0;j<3;j++){
			matrix[i][j] = 0;
		}
	}
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			cin >> matrix[i][j];
		}
	}
	
	for(int j=0;j<3;j++){
		for(int i=0;i<201;i++){
			check[matrix[i][j]] ++;
			who[matrix[i][j]] = i;
		}
		for(int i=0;i<201;i++){
			if(check[i] == 1){
				point[who[i]] += i;
			}
		}
		for(int i=0;i<201;i++){
			check[i] = who[i] = 0;
		}
	}
	
	for(int i=0;i<n;i++){
		cout << point[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define ll long long  
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define prec(y,x) fixed<<setprecision(y)<<x
#define inf 1e18
#define pi 3.1415926535

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int q;vector<char> frn,bac;int r=0;cin>>q;
    while(q--)
    {
        int t;
        cin>>t;
        if(t==1)
        {
            r+=1;
            r%=2;
        }
        else
        {
            int f;char c;
            cin>>f;
            cin>>c;
            if(r==1&&f==1||r==0&&f==2)
            {
                frn.pb(c);
            }
            else
            {
                bac.pb(c);
            }
            
        }
    }string s1;
    if(r==0)
    {
        
        for(int i=bac.size()-1;i>=0;i--)
        {s1+=bac[i];}
        s1+=s;cout<<endl;
        for(int i=0;i<frn.size();i++)
        {s1+=frn[i];}
    }
    else
    {
        reverse(s.begin(),s.end());
        for(int i=frn.size()-1;i>=0;i--)
        {s1+=frn[i];}
        s1+=s;cout<<endl;
        for(int i=0;i<bac.size();i++)
        {s1+=bac[i];}
    }
    cout<<s1<<endl;
    return 0;
}
//make all values ll

Measured memory_bytes: 1448
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	double x, h;
	while(cin >> x >> h && (x || h))
		cout << setprecision(10) << x * x + x * sqrt(x * x / 4 + h * h) * 2 << endl;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;
 
namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int ans = 0;
            switch(s)
            {
                case "SUN": ans = 7; break;
                case "MON": ans = 6; break;
                case "TUE": ans = 5; break;
                case "WED": ans = 4; break;
                case "THU": ans = 3; break;
                case "FRI": ans = 2; break;
                case "SAT": ans = 1; break;
            }
 
            Console.WriteLine(ans);
        }
    }
}
 


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
const lli mod=1e9+7;
void fast() {std::ios::sync_with_stdio(false);cin.tie(NULL);}
lli power(lli a,lli b){lli ans=1;while(b!=0){ if(b%2==1){ans*=a;}b/=2;a*=a;} return ans;}
lli invmod(lli a) {return pow(a,mod-2);}
#define vi vector<int>
#define vlli vector<lli>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define si(n) scanf("%d",&n)
#define sli(n) scanf("%lld",&n)
#define printi(n) printf("%d\n",n)
#define printli(n) printf("%lld\n",n)
#define all(vi) (vi.begin(),vi.end())
#define forn(i,n) for(int i=0;i<n;i++)
void print(int a[],int n){for(int i=0;i<n;i++) cout<<a[i]<<" ";}

int main(){

    int n;
    cin>>n;
    
    cout<<"ABC"<<n<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int i,j,n,prime[20000],twin,twins[20000];

int main(){
	for(i=2;i<10005;i++){prime[i]=1;}
	for(i=2;i<=10000;i++){
		if(prime[i]==1){
			for(j=i*i;j<=10000;j+=i)prime[j]=0;
			if(prime[i-2]==1)twin=i;
		}
		twins[i]=twin;
	}
	while(scanf("%d",&n)*n){
		printf("%d %d\n",twins[n]-2,twins[n]);
	}
	return 0;
}

Measured memory_bytes: 680
#include <iostream>
#include <cstdio>
#include <cstring>
#define lowbit(x) (x&-x)
using namespace std;
const int MAXN = 100005;
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll t,e,n,d[MAXN];
ll c[MAXN],f[MAXN];
inline void update(int x,ll v)
{
	for(;x<=n;x+=lowbit(x))
		c[x]=min(c[x],v);
}
inline ll query(int x)
{
	ll ret=INF;
	for(;x;x-=lowbit(x))
		ret=min(ret,c[x]);
	return min(ret,(ll)-2*d[1]);
}
int main()
{
	scanf("%lld%lld%lld",&n,&e,&t);
	for(int i=1;i<=n;++i)scanf("%lld",d+i);
	int p=0;
	memset(f,0x3f,sizeof(f));
	f[0]=0;
	for(int i=1;i<=n;++i){
		while(2*(d[i]-d[p+1])>=t)++p;
		if(p>0)f[i]=min(f[i],query(p-1)+2*d[i]);
		f[i]=min(f[i],f[p]+t);
		update(i,f[i]-2*d[i+1]);
	}
	cout<<f[n]+e<<endl;
	return 0;
}


Measured memory_bytes: 2560
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	std::string N;
	std::cin >> N;
	if (N[1] == N[2] && (N[0] == N[1] || N[2] == N[3]))
		std::cout << "Yes\n";
	else
		std::cout << "No\n";
}


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

import heapq
from math import ceil

def main():
    n, h = map(int, input().split())
    q = []
    for i in range(n):
        a, b = map(int, input().split())
        heapq.heappush(q, (-a, 0))
        heapq.heappush(q, (-b, 1))

    times = 0
    while True:
        dhp, limit = heapq.heappop(q)
        if limit == 0:
            times += ceil(h / abs(dhp))
            break
        else:
            h += dhp
            times += 1
            if h <= 0:
                break

    print(times)


if __name__ == "__main__":
    main()


Measured memory_bytes: 23816
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define pb push_back
#define ll long long
#define fi first
#define se second
#define ii  pair<int, int>
#define vi  vector <int>
#define vii vector <pair <int, int > >
#define all(cont)  cont.begin(), cont.end()
#define EPS 1e-9
#define MOD 1000000007
#define range 
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")


int main(){

   // freopen("input.txt","r",stdin);
    IOS;
    clock_t clk = clock();
    int a, b; cin >> a>> b;
    if(a >= 10 || b >= 10) cout << -1;
    else cout << a* b ;

    cerr << endl << setprecision(10) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
	string a = "AKIHABARA";
	string b = "KIHBR";
	string s;
	cin >> s;

	int p = 0;
	

	for (int i = 0; i < a.size(); i++) {
		if (s[p] == a[i]) {
			p++;
		}
		if (p == s.size()) {
			break;
		}
	}

	if (p == s.size()) {
		p = 0;
		for (int i = 0; i < s.size(); i++) {
			if (b[p] == s[i]) {
				p++;
			}
			if (p == b.size()) {
				break;
			}
		}
		if (p == b.size()) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}else{
		cout << "NO" << endl;
	}

	return 0;
}

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

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

    vector<int> a(n);

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

int c=a.at(0)+k-a.at(n-1);
  rep(i,n-1){
c=max(c,a.at(i+1)-a.at(i));

  }

  cout<<k-c<<endl;

}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INF = 1000000007;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};


ll dp[100050];
int main(){
  memset(dp,0,sizeof(dp));
  int N,K;
  cin >> N >> K;
  vector<int> h(N+1);
  for(int i=1; i<=N; i++){
    cin >> h[i];
  }
  for(int i=2; i<=N; i++){
    for(int k=1; k<=K; k++){
      if(i-k<=0){
        break;
      }
      if(k == 1){
        dp[i] = dp[i-1]+abs(h[i]-h[i-1]);
      }else{
        dp[i] = min(dp[i],dp[i-k] + abs(h[i]-h[i-k]));
      }
    }
  }
  cout << dp[N] << endl;
  return 0;
}


Measured memory_bytes: 1408