akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define ios         ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll          long long
#define sn          3007
#define bn          2000007
#define M           1000000007
#define inf         LLONG_MAX


ll a[sn][sn],r1[sn][sn],r2[sn][sn],r3[sn][sn];

int main()
{
        ll r,c,k; cin >> r >> c >> k;
        for(ll b = 1; b <= k; b++)
        {
                ll i,j,v; cin >> i >> j >> v;
                a[i][j] = v;
        }
        for(ll i = r; i > 0; i--)
        {
                for(ll j = c; j > 0; j--)
                {
                        r1[i][j] = max(a[i][j]+max(max(r2[i+1][j],r3[i+1][j]),r1[i+1][j]),r1[i][j+1]);
                        r2[i][j] = max(a[i][j]+r1[i][j+1],r2[i][j+1]);
                        r3[i][j] = max(a[i][j]+r2[i][j+1],r3[i][j+1]);
                }
        }
        cout << max(max(r1[1][1],r2[1][1]),r3[1][1]) ;
        return 0;
}

















































/*

*/


Measured memory_bytes: 285380
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
void vprint() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
template <class H, class... T> void vprint(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << '\n';
    vprint(std::forward<T>(args)...);
}
template <class T> void vprint(std::vector<T> &v) {
    for (auto &&i : v) {
        std::cout << i << '\n';
    }
}
template <class T> void mprint(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << "";
        }
    }
}

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

    int K, S;
    cin >> K >> S;
    ll ans = 0;
    K;
    REP(x, K + 1) {
        REP(y, K + 1) {
            ll z = S - x - y;
            if (0 <= z && z <= K)
                ans++;
        }
    }
    print(ans);

    return 0;
}

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

int main() {
	int c[3][3];
	int  che = 0;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			std::cin >> c[i][j];
		}
	}
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			if (c[i][j] - c[i + 1][j] == c[i][j+1] - c[i + 1][j+1] && c[i][j] - c[i][j + 1] == c[i+1][j] - c[i+1][j + 1]) {
				if (i == 1 && j == 1) {
					std::cout << "Yes" << std::endl;
				}
			}
			else {
				++che;
				std::cout << "No" << std::endl;
				break;
			}
		}
		if (che == 1) {
			break;
		}
	}
}

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

int main(void)
{
	int n, x, t;
	cin >> n >> x >> t;

	int ans = n / x;
	if (n % x) ans++;

	cout << ans * t << endl;

	return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
#include<vector>
#include<cctype>
using namespace std;

class Saikoro{//サイコロを表すクラス
	private:
	int rab[6];//ラベル
	public:
	void setrab(int rabs[6]);
	void getrab();
	int gettop();
	void N();
	void E();
	void S();
	void W();
	int getR(int ue,int mae);//右を得る関数
};

void Saikoro::setrab(int rabs[6]){
	for(int i=0;i<6;i++)rab[i]=rabs[i];
}
void Saikoro::getrab(){
	for(int i=0;i<6;i++)cout<<rab[i]<<endl;
}
void Saikoro::N(){
	int a;
	a=rab[0];rab[0]=rab[1];rab[1]=rab[5];rab[5]=rab[4];rab[4]=a;

}
void Saikoro::E(){
	int a;
	a=rab[0];rab[0]=rab[3];rab[3]=rab[5];rab[5]=rab[2];rab[2]=a;

}
void Saikoro::S(){
	int a;
	a=rab[0];rab[0]=rab[4];rab[4]=rab[5];rab[5]=rab[1];rab[1]=a;

}
void Saikoro:: W(){
int a;
a=rab[0];rab[0]=rab[2];rab[2]=rab[5];rab[5]=rab[3];rab[3]=a;
}
int Saikoro::gettop(){
	return rab[0];
}
int Saikoro::getR(int ue,int mae){
	
	if(ue==rab[0]){
		if(mae==rab[1])return rab[2];
		if(mae==rab[2])return rab[4];
		if(mae==rab[4])return rab[3];
		if(mae==rab[3])return rab[1];
}
	if(ue==rab[1]){
		if(mae==rab[5])return rab[2];
		if(mae==rab[2])return rab[0];
		if(mae==rab[0])return rab[3];
		if(mae==rab[3])return rab[5];
	}
	if(ue==rab[2]){
		if(mae==rab[4])return rab[0];
		if(mae==rab[0])return rab[1];
		if(mae==rab[1])return rab[5];
		if(mae==rab[5])return rab[4];
	
	}
	if(ue==rab[3]){
		if(mae==rab[0])return rab[4];
		if(mae==rab[4])return rab[5];
		if(mae==rab[5])return rab[1];
		if(mae==rab[1])return rab[0];
	}
	if(ue==rab[4]){
		if(mae==rab[0])return rab[2];
		if(mae==rab[2])return rab[5];
		if(mae==rab[5])return rab[3];
		if(mae==rab[3])return rab[0];
	
}
	if(ue==rab[5]){
		if(mae==rab[1])return rab[3];
		if(mae==rab[3])return rab[4];
		if(mae==rab[4])return rab[2];
		if(mae==rab[2])return rab[1];
	}
	
}
//ITP1_8Dice_1
/*int main(){
	int a[6];
	for(int i=0;i<6;i++)cin>>a[i];
	string n;
	cin>>n;
	Saikoro saikoro1;
	saikoro1.setrab(a);
	for(int i=0;i<n.size();i++){
	if(n[i]=='N')saikoro1.N();
	else if(n[i]=='S')saikoro1.S();
	else if(n[i]=='E')saikoro1.E();
	else if(n[i]=='W')saikoro1.W();
	}
	cout<<saikoro1.gettop()<<endl;
return 0;
}*/
int main(){
	int a[6];
	for(int i=0;i<6;i++)cin>>a[i];
	Saikoro saikoro1;
	saikoro1.setrab(a);
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
	int ue,mae;
	cin>>ue>>mae;
	cout<<saikoro1.getR(ue,mae)<<endl;
	}
return 0;
}

Measured memory_bytes: 1160
import java.util.*;

public class Main {
		public static void main(String[] args) {
		
	   Scanner sc = new Scanner(System.in);
	   String a = sc.next();
       
       if(a.equals("SAT")) {
    	   System.out.println(1);
       }else if(a.equals("FRI")) {
    	   System.out.println(2);
       }else if(a.equals("THU")) {
    	   System.out.println(3);
       }else if(a.equals("WED")) {
    	   System.out.println(4);
       }else if(a.equals("TUE")) {
    	   System.out.println(5);
       }else if(a.equals("MON")) {
    	   System.out.println(6);
       }else {
    	   System.out.println(7);
       }
			
}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 1000000007;


int main(void){
    int A,B,T;
    cin >> A >> B >> T;
    cout << B * (T / A) << endl;
}


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

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)

int main(){
    int w, d;
    while(cin >> w >> d, w|d){
        vector<int> h(25, 0);
        int x, sum = 0;
        rep(i, w){
            cin >> x;
            h[x]++;
            sum += x;
        }
        rep(i, d){
            cin >> x;
            if(h[x])h[x]--; else sum += x;
        }
        cout << sum << '\n';
    }
    return 0;
}

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

int main(){
    int n,q;
    cin>>n;
    int* S=new int[n];
    int number;
    for(int i;i<n;++i){
        cin>>number;
        S[i]=number;
    }
    cin>>q;
    int* T=new int[q];
    for(int i=0;i<q;++i){
        cin>>number;
        T[i]=number;
    }
    int cnt=0;
    
    for(int i=0;i<q;++i){
        int left=0,right=n;
        while(left<right){
            int mid=(left+right)/2;
            if(S[mid]==T[i]){
                cnt++;
                break;
            }
            else if(S[mid]>T[i]){
                right=mid;
            }
            else if(S[mid]<T[i]){
                left=mid+1;
            }
        }
    }

    cout<<cnt<<"\n";
    delete[] T;
    delete[] S;
}

Measured memory_bytes: 3264
#include<cstdio>
#include<algorithm>
using namespace std;
struct edge{
    int v,nxt;
}e[100005];
int n,m,h[100005],cnt,in[100005],t1,t2,dp[100005],q[100005],f,r,ans;
void add(int fr,int to){
    e[++cnt].nxt=h[fr];
    e[cnt].v=to;
    h[fr]=cnt;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++){
        scanf("%d%d",&t1,&t2);
        add(t1,t2);in[t2]++;
    }
    for(int i=1;i<=n;i++) if(!in[i]) q[r++]=i;
    while(f<=r){
        int x=q[f];f++;
        for(int i=h[x];i;i=e[i].nxt){
            int y=e[i].v;
            in[y]--;
            if(!in[y]) dp[y]=dp[x]+1,q[r++]=y;
        }
    }
    for(int i=1;i<=n;i++) ans=max(ans,dp[i]);
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define Rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef int64_t intl;


intl modpow(intl a, intl n, intl p){
  intl res = 1;
  while (n > 0){
    if (n&1){res = (res * a) % p;}
	a = (a * a) % p;
    n >>= 1;
  }
  return res;
}

intl modinv(intl a, intl p){
  if (a==0){
    cout << "/0 at modinv"<<endl;
    exit(0);
  }
  if (a < 0){
    cout << "/- at modinv" <<endl;
    exit(0);
  }
  if (a==1){return 1;}
  if (a > p){return modinv(a%p, p);}

  return p - ( modinv(p%a,p) * (p/a) ) % p;
}

intl modcomb(intl n, intl k, intl p){
  if (k > n || k < 0 || n < 0){
    cout << "error at modcomb"<<endl;
    exit(0);
  }
  if (2*k > n){ k = n-k;}
  if (k ==0){return 1;}
  intl c=1;
  for (intl i = 0; i < k; i++){
    c =( c * ( (n-i) % p ) % p ) * modinv(i+1,p) % p;
  }
  return c;
}

int main(){
  intl L,R;
  cin >> L >> R;
  intl t = R-L+1;
  if (t >= 2019){cout << 0; return 0;}
  else {
    vector<int> mods;
    int modsmin=2018;
    Rep (i,t){
      mods.push_back( (L + i)%2019 );
    }
    Rep (i,t){
      for (int j = i+1; j < t; j++){
        modsmin = min ( mods.at(i) * mods.at(j) % 2019 , modsmin);
      }
    }
    cout << modsmin;
    
  }
}
        

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,a,b;
	cin >> n >> a >> b;
	cout << min(n * a,b) << endl;
}

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,m;
    cin >> n >> m;
    if(m>=n){
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    return 0;
}

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

vector<vector<int>> g;
vector<bool> seen;
vector<int> found;

void dfs(int v){
    seen[v] = true;
    found.push_back(v);

    if(g[v].size()==0){
        return;
    }

    for(int nv: g[v]){
        if(!seen[nv]){
            dfs(nv);
            found.push_back(nv);
        }
    }
}

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

    int n;
    cin >> n;

    g.resize(n);
    seen.resize(n, false);

    rep(i, n){
        int u, k;
        cin >> u >> k;
        --u;
        rep(j, k){
            int v;
            cin >> v;
            --v;

            g[u].push_back(v);
        }
    }

    rep(i, n){
        if(!seen[i]) {
            dfs(i);
            found.push_back(i);
        }
    }
    
    vector<vector<int>> res(n, vector<int>(2, -1));
    rep(i, n){
        rep(j, found.size()){
            if(found[j]==i && res[i][0]==-1) res[i][0] = j+1;
            if(found[j]==i && res[i][0]!=-1) res[i][1] = j+1;
        }
    }

    rep(i, n) cout << i+1 << " " << res[i][0] << " " << res[i][1] << endl;

    return 0;
}


Measured memory_bytes: 3224
//
//  main.cpp
//  C - gacha
//
//  Created by Hashizo on 2020/04/26.
//  Copyright © 2020 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

int main(int argc, const char * argv[]) {
	ll ans = 1;

	
	ll n;
	cin >> n;

	vector<string> gacha(n);
	
	REP(i, n) {
		cin >> gacha[i];
	}

	SORT(gacha);
	
	REP(i, n-1) {
		if(gacha[i] != gacha[i+1]) {
			ans++;
		}
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 9548
# #の数を数えておいて、最初の.の数-最短距離
# 最短経路なので幅優先でやる
from collections import deque

h, w = map(int, input().split())
table =[]
default_dot = 0
for _ in range(h):
  line = list(input())
  default_dot+=line.count(".")
  table.append(line)

default_dot-=2  # スタートとゴール
table[0][0] = 0

cur = [0, 0]   # x, y
queue = deque()
queue.append(cur)
steps = [0, 1, 0, -1, 0]

minimum_step = 0

while True:
  if len(queue)==0:
    print(-1)
    exit()
  now = queue.popleft()
  if now[0] == w-1 and now[1] == h-1:
    minimum_step = table[now[1]][now[0]]-1
    break
  for i in range(4):
    next_y, next_x = now[1]+steps[i], now[0]+steps[i+1]
    if 0<=next_y<h and 0<=next_x<w and table[next_y][next_x] == ".":
      table[next_y][next_x] = table[now[1]][now[0]]+1
      queue.append([next_x, next_y])


print(default_dot-minimum_step)

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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int b, e;
    cin >> b >> e;
    reverse(v.begin() + b, v.begin() + e);
  }

  for (int i = 0; i < n; i++) {
    if (i == n - 1) {
      cout << v.at(i) << endl;
    } else {
      cout << v.at(i) << " ";
    }
  }
}


Measured memory_bytes: 3096
n = int(input())
p = list(map(int,input().split()))
ans = int()

for num in range(1,len(p)-1):
    p1 = p[num - 1]
    p2 = p[num]
    p3 = p[num + 1]
    
    p_list = [p1,p2,p3]
    p_list.sort()
    if p_list[1] == p2:
        ans += 1
print(ans)

Measured memory_bytes: 3064
/***************************************** 
****       Solution by SlavicG        ****
*****************************************/
 
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm> 
#include <set>
#include <utility>
#include <queue>
#include <map>
#include <assert.h>
#include <stack>
using namespace std;
#define ll long long
#define forn(i,n) for(int i=0;i<n;++i)
#define MX 10000000001
#define pow2(a) ((a)*(a))
#define pb push_back
#define vair <vector<pair<int,int>>
#define vi vector<int>
#define mp make_pair
#define pf push_front
#define all(v) v.begin(), v.end()
#define endl "\n"
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define PI   3.14159265
 int longestIncreasingSubsequenceLenghtDP(int a[],int n){
    int dp[n],ans=0;
    for(int k = 0;k<n;k++){
        dp[k] = 1;
        for(int i = 0;i<k;i++){
            if(a[i] <= a[k]){
                dp[k] = max(dp[k],dp[i] + 1);
                ans = max(dp[k],ans);
            }
        }
    }
    return ans;
 }
int result[1000] = {0};
int factDP(int n) 
{
   if (n >= 0) {
      result[0] = 1;
      for (int i = 1; i <= n; ++i) {
         result[i] = i * result[i - 1];
      }
      return result[n];
   }
}
bool isPrime(ll n)
{
    if(n<2) return false;
    for(ll x = 2;x*x <=n;x++)
    {
        if(n%x == 0)return false;
    }
    return true;
}
vector<int> primeFactors(int n){
    vector<int> f;
    for(int x = 2;x*x<=n;x++){
        while(n%x==0){
            f.push_back(x);
            n/=x;
        }
    }
    if(n>1)f.push_back(n);
    return f;
}
int binary_Search_Classic(int n, int arr[],int target){
	int l,r,mid;
	l=0;
	r=n-1;
	while(l<=r){
		mid= l+(r-l)/2;
		if(arr[mid] == target){
			return mid;
		}
		if(arr[mid] < target){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return -1;
	
}
vector<int> Two_PointerSumOfTwo(vector<int> arr, int target)
{
	int l = 0, r = arr.size()-1;
	vector<int> ans;
	while(l<r){
		if(arr[l] + arr[r] == target)
		{
			ans.push_back(l);
			ans.push_back(r);
			break;
		}else if(arr[l] + arr[r] > target){
			r--;
		}else{
			l++;;
		}
	}
	return ans;
}
int countDistinctCharsString(string s) {
    unordered_map<char, int> m; 
    for (int i = 0; i <(int)s.length(); i++) { 
        m[s[i]]++; 
    }
    return m.size(); 
}
int f(int x)
{
	x++;
	while(x % 10 == 0)
	{
		x  = x/10;
	}
	return x;
}
map<string,int> m;
int main()
{
	int t;
	cin >> t;
	while(t--)
	{
		string s;
		cin >> s;
		m[s]++;
	}
	cout << "AC x " << m["AC"] << endl;
	cout << "WA x " << m["WA"] << endl;
	cout << "TLE x " << m["TLE"] << endl;
	cout << "RE x " << m["RE"] << endl;
}

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

int n;
P itv[101010];

int main(){
  cin >> n;
  rep(i, n){
    int x, l;
    cin >> x >> l;
    itv[i].second = x - l;
    itv[i].first = x + l;
  }
  sort(itv, itv + n);
  
  //rep(i, n)cerr << itv[i].second << " "<< itv[i].first << endl;
  
  int res = 0;
  int pos = -1000000009;
  rep(i, n){
    if(pos <= itv[i].second){
      res++;
      pos = itv[i].first;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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 (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
const int MOD = 1000000007;

const int max_v = 3001;

ll dp[max_v][max_v][4];

int main(){
    int R,C,K; cin >> R >> C >> K;

    vector<vector<ll>> rcv(R+5, vector<ll>(C+5,0));
    rep(i,K){
        ll tr, tc, tv; cin >> tr >> tc >> tv;
        tr--;
        tc--;
        rcv[tr][tc] = tv;
    }

    rep(i,max_v){
        rep(j,max_v){
            rep(k,4){
                dp[i][j][k] = -INF;
            }
        }
    }
    dp[0][0][0] = 0;
    dp[0][0][1] = rcv[0][0];
    
    rep(i,R){
        rep(j,C){
            rep(k,4){
                dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][k]);
                dp[i+1][j][1] = max(dp[i+1][j][1], dp[i][j][k]+rcv[i+1][j]);
                dp[i][j+1][k] = max(dp[i][j+1][k], dp[i][j][k]);
                if (k+1 < 4){
                    dp[i][j+1][k+1] = max(dp[i][j+1][k+1], dp[i][j][k]+rcv[i][j+1]);
                }
            }
        }
    }
    ll ans = -1;
    rep(i,4){
        ans = max(ans, dp[R-1][C-1][i]);
    }

    cout << ans << endl;

}

Measured memory_bytes: 355372
from collections import  deque
h,w = map(int,input().split())
mp = []
for _ in range(h):
    row = list(input())
    mp.append(row)

q = deque()
dist = [[-1] * w for _ in range(h)]

for col in range(h):
    for row in range(w):
        if mp[col][row] == '#':
            q.append((col,row))
            dist[col][row] = 0
ans = 0
while q:
    now_x,now_y = q.popleft()
    ans = dist[now_x][now_y]
    for x,y in ((1,0), (0,1), (-1,0), (0,-1)):
        next_x = now_x + x
        next_y = now_y + y
        if 0 <= next_x < h and 0 <= next_y < w :
            if dist[next_x][next_y] < 0:
                q.append((next_x, next_y))
                dist[next_x][next_y] = ans + 1

print(ans)


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

using namespace std;
typedef long long ll;

const int N = 110, K = 1e5 + 5;
const ll mod = 1e9 + 7;
ll n, k, a[N], dp[N][K], pref[K];

int main()
{
	ios_base::sync_with_stdio(false);

	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++)
	{
		pref[0] = dp[i - 1][0];
		for (int j = 1; j <= k; j++)
		{
			pref[j] = (pref[j - 1] + dp[i - 1][j]) % mod;
		}
		for (int j = 0; j <= k; j++)
		{
			ll give = pref[j], x = j - a[i] - 1;
			if (x >= 0)
				give -= pref[x];
			if (give < 0)
				give += mod;
			give = give % mod;
			dp[i][j] = give;
		}
	}
	cout << dp[n][k];

	return 0;
}

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

using namespace std;

int main () {
    int N;
    cin >> N;
    vector<int> A(N);
    int one = 0;
    int two = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (one <= A[i]) {
            two = one;
            one = A[i];
        } else if (two <= A[i] && A[i] <= one) {
            two = A[i];
        }
    }
    for (int i = 0; i < N; i++) {
        if (A[i] == one) {
            cout << two << endl;
        } else {
            cout << one << endl;
        }
    }
}

Measured memory_bytes: 2432
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
  int n;
  cin >> n;
  long* a = new long[100000];
  long ans = 0;
  for(int i=0;i<n;i++) cin >> a[i];
  sort(a,a+n);
  if(n%2==0){
    for(int i=0;i<n;i++){
      if(i<n/2-1){
        ans -= a[i] * 2;
      } else if (i == n/2 -1){
        ans -= a[i];
      } else if (i == n/2){
        ans += a[i];
      } else {
        ans += a[i] * 2;
      }
    }
  } else {
    long cand = 0;
    for(int i=0;i<n;i++){
      if(i < n/2 - 1){
        ans -= a[i] * 2;
      } else if (i == n/2 || i == n/2 - 1){
        ans -= a[i];
      } else {
        ans += a[i] * 2;
      }
    }
    for(int i=0;i<n;i++){
      if(i > n/2 + 1){
        cand += a[i] * 2;
      } else if (i == n/2 || i == n/2 + 1){
        cand += a[i];
      } else {
        cand -= a[i] * 2;
      }
    }
    ans = max(ans,cand);
  }

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


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

void f(long long N)
{
    if(N==0)
        return;
    N--;
    f(N/26);
    cout << char('a'+(N%26));    
}

int main(void)
{
    long long N;
    long long x;
    cin >> N;
    f(N);
    
    cout << endl;
    return 0;
}


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

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

typedef long long ll;
typedef pair<int, int> pi;

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

    string s, t;
    cin>>s>>t;

    int cnt = 0;
    for (int i=0;i<3;++i){
        if (s[i] == t[i]) cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define forr(i,a,n) for(ll i=a;i<n;i++)
#define ford(i,a,n) for(ll i=n-1;i>=a;i--)
#define all(v) v.begin(),v.end()
#define testc  ll ts;\
               cin>>ts;\
               while(ts--)
#define arn ll n;\
            cin>>n;\
            ll a[n];\
            forr(i,0,n)cin>>a[i];\
               
#define arr(a,n) ll a[n];\
                 forr(i,0,n)cin>>a[i];\
 
#define sss <<" "<<
#define nnn <<"\n"
#define nl cout<<"\n";
#define prtitr(v) for(auto itr=v.begin(); itr!=v.end() ; itr++)cout<<*itr<<" ";
#define fitr(v) for(auto itr=v.begin(); itr!=v.end() ; itr++)
using namespace std;
ll M=1e9+7;
ll cdiv(ll a,ll b){
    return (a%b==0)?a/b:a/b+1;
}
ll myMod(ll a, ll b){
    ll r = a % b;
    return r < 0 ? r + b : r;
}
ll ModPow(ll a,ll b,ll M)
{
    if(M==1)return 0;
    a%=M;
    ll ans=1,t=1;
    while(t>0&&t<=b)
    {
        if(t&b)
        {
            ans*=a;
            ans%=M;
        }
        t<<=1;
        a*=a;
        a%=M;
    }
    return ans;
}


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    arn;
    ll sum=0;
    forr(i,0,n)sum+=a[i];
    ll prf[n+1];
    prf[0]=0;
    forr(i,1,n+1)prf[i]=prf[i-1]+a[i-1];
    ll ans=0;
    forr(i,0,n){
        ans=(ans+(a[i]*((prf[n]-prf[i+1])%M))%M)%M;
    }
    cout<<ans;
    return 0;
} 

Measured memory_bytes: 6740
/*{{{*/
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int x,y,z;
    R(x,y,z);
    swap(x,y);
    swap(x,z);
    W(x,y,z);
    return 0;
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

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

int n,q;
string s;
vector<char> t,d;

int simu(int k)
{
    int ret=0;
    for(int i = 0; i < q; i++)
    {
        int tt=t[i];
        if(s[k]==tt)
        {
            char dd = d[i];
            if(dd=='L')
            {
                k--;
                if(k<0) return -1;
            }
            else
            {
                k++;
                if(k>=n) return 1;
            }
            
        }
    }
    

    return ret;
}

int main()
{
    cin>>n>>q>>s;
    t.resize(q);
    d.resize(q);
    for(int i = 0; i < q; i++)
    {
        cin>>t[i]>>d[i];
    }
    int lans,rans;
    int l,r;

    // hidari haji wo sagasu
    l=0;
    r=n;
    while(l<r)
    {
        int mid = (l+r)/2;
        if(simu(mid)==-1)
        {
            l=mid+1;
        }
        else 
        {
            r=mid;
        }
    }
    lans=l;

    // migi haji wo sagasu
    l=0;
    r=n;
    while(l<r)
    {
        int mid = (l+r)/2;
        if(simu(mid)!=1)
        {
            l=mid+1;
        }
        else 
        {
            r=mid;
        }
    }
    rans=l;

    cout<<rans-lans<<endl;
 
    return 0;
}

Measured memory_bytes: 900
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] idx = new int[n];
		for (int i = 0; i < n; i++) {
			idx[sc.nextInt() - 1] = i;
		}

		long answer = 0;
		NavigableSet<Integer> s = new TreeSet<>();
		for (int i = n - 1; i >= 0; i--) {
			s.add(idx[i]);
			Integer l1 = s.lower(idx[i]);
			Integer r1 = s.higher(idx[i]);
			Integer r2 = r1 == null ? null : s.higher(r1);
			Integer l2 = l1 == null ? null : s.lower(l1);
			if (l1 == null && r1 == null) continue;

			int ll1 = idx[i] + 1, ll2 = 0, lr1 = n - idx[i], lr2 = 0;
			if (r1 != null) {
				lr1 = r1 - idx[i];
				lr2 = n - r1;
			}
			if (r2 != null) {
				lr2 = r2 - r1;
			}

			if (l1 != null) {
				ll1 = idx[i] - l1;
				ll2 = l1 + 1;
			}

			if (l2 != null) {
				ll2 = l1 - l2;
			}

			answer += ((long) ll1 * lr2 + ll2 * lr1) * (i + 1);

		}
		System.out.println(answer);
	}
}


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


int main() {
    char X,Y;
    cin>>X>>Y;
    if(X>Y)cout<<">"<<endl;
    else if(X<Y) cout<<"<"<<endl;
    else cout<<"="<<endl;

}

Measured memory_bytes: 256
from math import factorial
from itertools import combinations, islice

def nCr(n, r):
    return factorial(n) // factorial(r) // factorial(n - r)

def main():
    N, K = map(int, input().split())
    A = nCr(N - 1, 2) if N > 2 else 0
    if K > A:
        print(-1)
        return
    print(N - 1 + A - K)
    for i in range(2, N + 1):
        print(1, i)
    for u, v in islice(combinations(range(2, N + 1), 2), A - K):
        print(u, v)

main()


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

int main() {
  string o, e;
  cin >> o >> e;
  string ans;

  for (int i = 0; i < min(o.size(), e.size()); i++) {
    ans.push_back(o.at(i));
    ans.push_back(e.at(i));
  }
  if (o.size() > e.size()) ans.push_back(o.at(o.size() - 1));
  if (o.size() < e.size()) ans.push_back(e.at(e.size() - 1));

  cout << ans;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a1=0,a2=0,a3=0,a4=0,dice[7],i=0;
    char cc[200];
    
    for(i = 1;i <= 6;i++){
        scanf("%d",&dice[i]);
    }
    
    scanf("%s",cc);
    
    i=0;

    while(cc[i]!='\0'){
            if(cc[i]=='E'){
            a1=dice[1];
            a2=dice[3];
            a3=dice[4];
            a4=dice[6];
            dice[1]=a3;
            dice[3]=a1;
            dice[4]=a4;
            dice[6]=a2;
        }else if(cc[i]=='N'){
            a1=dice[1];
            a2=dice[2];
            a3=dice[5];
            a4=dice[6];
            dice[1]=a2;
            dice[2]=a4;
            dice[5]=a1;
            dice[6]=a3;
        }else if(cc[i]=='S'){
            a1=dice[1];
            a2=dice[2];
            a3=dice[5];
            a4=dice[6];
            dice[1]=a3;
            dice[2]=a1;
            dice[5]=a4;
            dice[6]=a2;
        }else if(cc[i]=='W'){
            a1=dice[1];
            a2=dice[3];
            a3=dice[4];
            a4=dice[6];
            dice[1]=a2;
            dice[3]=a4;
            dice[4]=a1;
            dice[6]=a3;
        }else{
            //printf("No\n");
        }
        i++;
    }
    printf("%d\n",dice[1]);
    return 0;
}

Measured memory_bytes: 596
/********************************************************************************
	
	Code by a weak man who named CYJian, and he hopes the code can get more points.

	Algorithm: 

 ********************************************************************************/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

//{{{ FAST IO AND SOME FUNCTIONS
const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define ra read_alpha()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline char read_alpha() { char c = ge; while(!isalpha(c) && c != EOF) c = ge; return c; }
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T> inline void chkmin(T&a, T b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T&a, T b) { a = a > b ? a : b; }
//}}}

const int MAXN = 200010;

ll res;
int f[MAXN];
int c0[MAXN];
int c1[MAXN];
int fa[MAXN];

struct Node {
	int x, c0, c1;

	Node() {}
	Node(int x):x(x) { c0 = ::c0[x], c1 = ::c1[x]; }

	friend bool operator < (Node a, Node b) {
		return 1LL * a.c0 * b.c1 < 1LL * a.c1 * b.c0;
	}
	friend bool operator > (Node a, Node b) {
		return 1LL * a.c0 * b.c1 > 1LL * a.c1 * b.c0;
	}
};

priority_queue<Node, vector<Node>, less<Node> >q;

inline int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
inline void Merge(int x, int y) {
	x = find(x), y = find(y), fa[x] = y;
	res += 1LL * c0[x] * c1[y];
	c0[y] += c0[x], c1[y] += c1[x];
}

int main() {
#ifdef LOCAL
	FILE("");
#endif
	int n = ri;
	for(int i = 2; i <= n; i++) f[i] = ri;
	for(int i = 1; i <= n; i++) fa[i] = i;
	for(int i = 1; i <= n; i++) ri ? c1[i]++ : c0[i]++;
	for(int i = 2; i <= n; i++) q.push(Node(i));
	while(!q.empty()) {
		Node x = q.top(); q.pop();
		if(x.c0 != c0[x.x] || x.c1 != c1[x.x]) continue;
		Merge(x.x, f[x.x]);
		if(find(x.x) > 1) q.push(Node(find(x.x)));
	} cout << res << endl;
	return 0;
}

Measured memory_bytes: 8308
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
#define int ll
#define INF INT_MAX/10

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];


// returns gcd(a, b)
// x, y will contain the answer for ax + by = gcd(a, b) after the execution
// if answer for ax + by = c is needed,
// check if c % gcd(a, b) == 0
// get (c / gcd(a, b)) * (x, y)

long long extGCD(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long d = extGCD(b, a%b, y, x);
  y -= a/b * x;
  return d;
}


signed main() {
  int A, B, C, D; cin >> A >> B >> C >> D;

  // cで割り切れる
  int ca = (A - 1) / C;
  int cb = B / C;
  int c = cb - ca;

  // cout << c << endl;

  int da = (A - 1) / D;
  int db = B / D;
  int d = db - da;

  // cout << d << endl;

  int s, l;
  int x = extGCD(C, D, s, l);
  int cda = (A - 1) / (C * D / x);
  int cdb = B / (C * D / x);
  int cd = cdb - cda;

  // cout << cd << endl;

  cout << B-A+1 - c - d + cd << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var S = ReadLine();
        var T = ReadLine();

        var ans = true;

        if(!(S.ToLower() == S && T.ToLower() == T))
        {
            ans = false;
        }
        else
        {
            if (!(1 <= S.Length && S.Length <= 10))
            {
                ans = false;
            }
            else
            {
                if(!(T.Substring(0, T.Length - 1) == S))
                {
                    ans = false;
                }
                else
                {
                    ans = true;
                }
            }
        }

        WriteLine(ans ? "Yes" : "No");
    }
}


Measured memory_bytes: 26300
#include <bits/stdc++.h>
using namespace std;
int main(){

    string a,b,c;
    int d,i;
    cin >> a >> b;

    c = a + b;
    d = std::atoi(c.c_str());

    for(i = 4; i < 100100; i++){
        if(d == i * i){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define iinf (3000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int n,k;
int recur(int x,int y){
	if(y==n){
		return x;
	}
	return min(recur(x+k,y+1),recur(x*2,y+1));
}
int main(){
	std::ios::sync_with_stdio(false);
	//int n,k;
	cin>>n>>k;
	cout<<recur(1,0);
}

Measured memory_bytes: 256
def main():
    import sys

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

    n = int(input())
    i = 1
    ans = 13
    while i*i <=n:
        if n%i == 0:
            tmp = max(len(str(i)), len(str(n//i)))
            ans = min(tmp, ans)
        i +=1 
    print(ans)
        
    
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9192
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            List<List<int>> lC = new List<List<int>>();
            for (int i = 0; i < 3; i++)
            {
                string[] sS = Console.ReadLine().Trim().Split(' ');
                List<int> lstT = new List<int>();
                for (int j = 0; j < 3; j++)
                {
                    lstT.Add(int.Parse(sS[j]));
                }
                lC.Add(lstT);
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "No";
            int b1 = 0, b2 = 0, b3 = 0;
            Boolean bOK = false;
            for (int a1 = 0; a1 <= lC[0][0]; a1++)
            {
                b1 = lC[0][0] - a1;
                b2 = lC[0][1] - a1;
                b3 = lC[0][2] - a1;
                for (int a2 = 0; a2 <= lC[1][0]; a2++)
                {
                    if (lC[1][0] == a2 + b1 &&
                        lC[1][1] == a2 + b2 &&
                        lC[1][2] == a2 + b3)
                    {
                        for (int a3 = 0; a3 <= lC[2][0]; a3++)
                        {
                            if (lC[2][0] == a3 + b1 &&
                                lC[2][1] == a3 + b2 &&
                                lC[2][2] == a3 + b3)
                            {
                                bOK = true;
                                break;
                            }
                        }
                    }
                    if (bOK) { break; }
                }
                if (bOK) { break; }
            }
            if (bOK) { sOut = "Yes"; }

            // 出力
            Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

    ll A, B, N;
    cin >> A >> B >> N;
    ll x = min(B - 1, N);
    cout << A * x / B << endl;

    return 0;
}

Measured memory_bytes: 3584
M(int*a,int*b){return*a-*b;}n,T[9999][2];j,m,s;main(i){for(;~scanf("%d",&n);qsort(T,n,8,M),n&&printf("%d\n%d\n%d\n",1[*T],T[1][1],T[n-2][1]))for(i=n;i--;)for(scanf("%d",T[i]+1),*T[i]=0,j=4;j--;*T[i]+=m*60+s)scanf("%d%d",&m,&s);}

Measured memory_bytes: 0
#include <stdio.h>
#define N 101

int main() {
  int n, u, k, v, i, j;
  int A[N][N];

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

  for(i = 1; i <= n; i++) {
    scanf("%d", &u);
    scanf("%d", &k);
    for(j = 1; j <= k; j++) {
      scanf("%d", &v);
      A[u][v] = 1;
    }
  }

  for(i = 1; i <= n; i++) {
    for(j = 1; j <= n; j++) {
      if(j > 1) printf(" ");
      printf("%d", A[i][j]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 636
/**********************************************************************/
/********                                                      ********/
/********                     Writer:孙~~                      ********/
/********                       Lang:C++                       ********/
/********                     Status:Unknow                    ********/
/********                                                      ********/
/**********************************************************************/
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cstring>
#include <cmath>
//#include<bits/stdc++.h>
using namespace std;

const int INF=0x3f3f3f3f;
const int day[]={-1,31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
	int a,b;
	cin>>a>>b;
	int ans=0;
	for(int i=1;i<=a;i++){
		int max_day=(i==a)?b:day[i];
		for(int j=1;j<=max_day;j++) if(i==j) ans++;
	}
	cout<<ans<<endl;
	return 0;
}




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

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  for (auto &e : s) cin >> e;

  vector<vector<int>> r(h, vector<int>(w));
  for (int i = 0, k = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') {
        k++;
        r[i][j] = k;
      }
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 1; j < w; j++) {
      if (r[i][j] == 0) r[i][j] = r[i][j - 1];
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = w - 2; j >= 0; j--) {
      if (r[i][j] == 0) r[i][j] = r[i][j + 1];
    }
  }
  for (int i = 1; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (r[i][j] == 0) r[i][j] = r[i - 1][j];
    }
  }
  for (int i = h - 2; i >= 0; i--) {
    for (int j = 0; j < w; j++) {
      if (r[i][j] == 0) r[i][j] = r[i + 1][j];
    }
  }

  for (const auto &ri : r) {
    for (const auto &rij : ri) cout << rij << ' ';
    cout << endl;
  }
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int h,w,q;
string s,t;
vi a,b,c[4];

int f(int x,int y,int X,int Y,bool fx=1,bool fy=1){
	int I=a[x],J=b[y];
	bool bx=0,by=0;
	if(I==1&&Y<=y||I==3&&y<=Y) bx=1;
	if(J==0&&X<=x||J==2&&x<=X) by=1;
	if(bx&&by){
		if(I==a[X]||J==b[Y]) return abs(x-X)+abs(y-Y);
		auto ix=lower_bound(c[I].begin(),c[I].end(),X);
		auto iy=lower_bound(c[J].begin(),c[J].end(),Y);
		if(J==0) ix--;
		if(I==1) iy--;
		int tx=(0<=*ix&&*ix<h?abs(*ix-x)+abs(*ix-X)+abs(y-Y):inf);
		int ty=(0<=*iy&&*iy<w?abs(*iy-y)+abs(*iy-Y)+abs(x-X):inf);
		return min(tx,ty);
	}
	auto ix=lower_bound(c[(I+2)%4].begin(),c[(I+2)%4].end(),x);
	auto iy=lower_bound(c[(J+2)%4].begin(),c[(J+2)%4].end(),y);
	if(J==0) ix--;
	if(I==1) iy--;
	int tx=(fx&&0<=*ix&&*ix<h?f(*ix,y,X,Y,0,1)+abs(*ix-x):inf);
	int ty=(fy&&0<=*iy&&*iy<w?f(x,*iy,X,Y,1,0)+abs(*iy-y):inf);
	return min(tx,ty);
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>h>>w>>q>>s>>t;
	a=vi(h,1);
	b=vi(w);
	for(int i=0;i<4;i++) c[i].push_back(-1);
	for(int i=0;i<h;i++){
		if(s[i]=='E') a[i]=3;
		c[a[i]].push_back(i);
	}
	for(int i=0;i<w;i++){
		if(t[i]=='S') b[i]=2;
		c[b[i]].push_back(i);
	}
	for(int i=0;i<4;i++) c[i].push_back(inf);
	for(int i=0;i<q;i++){
		int x,y,X,Y;
		cin>>x>>y>>X>>Y;
		int res=f(x-1,y-1,X-1,Y-1);
		cout<<(res>=inf?-1:res)<<endl;
	}
}

Measured memory_bytes: 3596
N = int(input())
A = list(map(int, input().split()))

MOD = 10 ** 9 + 7

ans = 0
for i in range(60):
    n = sum([(a >> i) & 1 for a in A])
    ans = (ans + n * (N - n) * (2 ** i)) % MOD

print(ans)

Measured memory_bytes: 138168