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

using namespace std;

int main(int argc, char const *argv[])
{
    int h , w;
    char temp;
    scanf("%d %d",&h,&w);
    vector<vector<char>> mat(h,vector<char>(w,'-'));
    vector<vector<int>> dp(h+1,vector<int>(w+1,0));
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            //cin works but scanf doesnt. weird af
            cin >> temp;
            mat[i][j] = temp;
        }   
    }
    // for (int i = 0; i < h; i++)
    // {
    //     for (int j = 0; j < w; j++)
    //     {
    //         cout << mat[i][j] << " ";
    //     }   
    //     cout << endl;
    // }
    dp[1][1] = 1;
    int flag = 1;
    for (int i = 1; i <= h; i++)
    {
        if (mat[i-1][0] == '#') flag = 0;
        dp[i][1] = flag;
    }
    flag = 1;
    for (int i = 1; i <= w; i++)
    {
        if (mat[0][i-1] == '#') flag = 0;
        dp[1][i] = flag;
    }
    for (int i = 2; i <= h; i++)
    {
        for (int j = 2; j <= w; j++)
        {
            if(mat[i-2][j-1] == '.') dp[i][j]+= dp[i-1][j] %MOD;
            if(mat[i-1][j-2] == '.') dp[i][j]+= dp[i][j-1] % MOD;
        }   
    }
    // for (int i = 0; i <= h; i++)
    // {
    //     for (int j = 0; j <= w; j++)
    //     {
    //         cout << dp[i][j] << " ";
    //     }   
    //     cout << endl;
    // }
    cout << dp[h][w] %MOD;
    return 0;
}


Measured memory_bytes: 8628
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

min = 10000

def func(h):
    return t - h*0.006

for i, height in enumerate(h):
    temperature = func(height)
    diff = abs(temperature-a)
    if min > diff:
        ans = i+1
        min = diff

print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

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

    int l[N];
    REP(0, i, N) {
        cin >> l[i];
    }

    sort(l, l + N, greater<int>());

    int ans = 0;
    REP(0, i, K) {
        ans += l[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	s := getNextString(scanner)
	k := getNextInt(scanner)
	ss := make([]string, 0)
	m := map[string]int{}
	n := len(s)
	for i := 0; i < n; i++ {
		for j := 1; j <= 5 && i+j <= n; j++ {
			m[s[i:i+j]] = 1
		}
	}
	for str := range m {
		ss = append(ss, str)
	}
	sort.Strings(ss)
	fmt.Fprintln(writer, ss[k-1])
}


Measured memory_bytes: 5084
#include <iostream>
#include <algorithm>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <string>

using namespace std;

struct data_t {
    string loc;
    int score;
    int number;
};

int main()
{
    int n,m;
    cin >> n >> m;
    vector<bitset<10>> ss(m);
    for(auto& r : ss)
    {
        int k;
        cin >> k;
        for(int i = 0; i < k; ++i)
        {
            int s;
            cin >> s;
            r[s-1] = true;
        }
    }
    vector<unsigned int> ps(m);
    for(auto& p : ps) cin >> p;

    int count = 0;
    for(int state = 0; state < (1 << n); ++state)
    {
        const bitset<10> st(state);
        bool isok = true;
        for(int im = 0; im < m; ++im)
        {
            //cout << ss[im] << " & " << st << " = " << (ss[im] & st) << ':' << (ss[im] & st).count() << " <=> " << ps[im] << '\n';
            if((ss[im] & st).count() % 2 != ps[im])
            {
                isok = false;
                break;
            }
        }
        if(isok) count++;
    }
    cout << count << '\n';
    return 0;
}


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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n, x;
	cin >> n >> x;
	int ans = INF;
	int all = 0;
	FOR(i, 1, n + 1)
	{
		int tut = x + i - 1;
		if (abs(ans) > abs(tut)) ans = tut;
		all += tut;
	}

	
	cout << all - ans << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long temp = x / 11;
		if(x % 11 == 0) {
			System.out.println(temp * 2);
		}else if((temp * 11) + 6 >= x) {
			System.out.println(temp * 2 + 1);
		} else {
			System.out.println(temp * 2 + 2);
		}
	}
}


Measured memory_bytes: 22608
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main()
{
	int N, L;
	cin >> N >> L;
	string x;
	vector<string> s;
	for (int i = 0; i < N; i++){
		cin >> x;
		s.push_back(x);
		}
	sort(s.begin(), s.end());
		for (int i = 0; i < N; i++)
			cout << s[i];
}



Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int R, G, B, N;
	cin >> R >> G >> B >> N;
	int ans = 0;
	for (int r = 0; r <= N / R; r++) {
		for (int g = 0; g <= N / G; g++) {
			if ((N - r * R - g * G) % B == 0 && N - r * R - g * G >= 0) ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;


void Main(){
    ll N;
    sll(N);
    cout << 8 - ((N - 400) / 200 ) << endl;

}

int main(){
    Main();
}

Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MOD 1000000007
//---------------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
//--------------------------------------------------------------
// [gcd]
template<class T> T gcd(T a, T b)
{if (a < b) swap(a,b);return b ? gcd(b, a % b) : a;}
template<class T> T lcm(T a, T b)
{T k=gcd(a, b);return (a/k ) * (b/k)*k;}
void Main(){
  int n; cin>>n;
  vector<vector<ll>> a(10,vl(10,0));
  rep(i,n){
    string s=to_string(i+1);
    int f=s.front()-'0';
    int b=s.back()-'0';
    a[f][b]++;
  }
  ll ans=0;
  rep(i,10) rep(j,10){
    ans+=a[i][j]*a[j][i];
  }
  cout<<ans;
} int main(int argc,char** argv)
{fastio; myio; Main();}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

ll H, W, K;

vector<string> strlist;

ll calc(ll wall) {
  ll result = 0;

  pair<ll, ll> ranges[10];

  // range計算
  ll start = 0;
  ll walli = 0;
  // cout << "wall:" << wall << endl;
  for (ll i = 0; i < (H - 1); i++) {
    bool w = (wall & (1 << i));
    // cout << "i:" << w << endl;
    if (w) {
      ranges[walli].first = start;
      ranges[walli].second = i;

      start = i + 1;
      walli += 1;
    }
  }

  ranges[walli].first = start;
  ranges[walli].second = H - 1;

  ll wall_len = walli + 1;

  // cout << "wall_len:" << wall_len << endl;

  // for (ll i = 0; i < wall_len; i++) {
  //   cout << i << ":" << ranges[i].first << "," << ranges[i].second << endl;
  // }

  // 左から
  bool impossible = false;
  ll counts[H];
  for (ll i = 0; i < H; i++) {
    counts[i] = 0;
  }
  for (ll i = 0; i < W; i++) {
    if (impossible) {
      break;
    }
    ll current_range_counts[H];
    for (ll r = 0; r < wall_len; r++) {
      ll range_count = 0;
      auto rng = ranges[r];
      for (ll j = rng.first; j <= rng.second; j++) {
        bool is_white = (strlist[j][i] == '1');
        if (is_white) {
          range_count += 1;
        }
      }
      current_range_counts[r] = range_count;
    }

    bool exceed = false;
    for (ll r = 0; r < wall_len; r++) {
      ll cur = current_range_counts[r];
      if (cur > K) {
        impossible = true;
        break;
      }

      ll total = counts[r] + cur;
      if (total > K) {
        exceed = true;
      }
    }

    if (exceed) {
      result += 1;
      for (ll r = 0; r < wall_len; r++) {
        counts[r] = current_range_counts[r];
      }
    } else {
      for (ll r = 0; r < wall_len; r++) {
        counts[r] += current_range_counts[r];
      }
    }
  }

  if (impossible) {
    return -1;
  }

  return result + (wall_len - 1);
}

int main() {
  scanf("%lld %lld %lld", &H, &W, &K);

  for (ll i = 0; i < H; i++) {
    string str;
    cin >> str;
    strlist.emplace_back(str);
  }

  // 01全組み合わせループ
  ll wall = 0;

  ll ans = W - 1 + H - 1;

  for (;;) {
    // ll m1 = wall & (1 << 0);
    // ll m2 = wall & (1 << 1);
    // cout << m1 << "," << m2 << endl;

    ll tmpAns = calc(wall);
    // cout << "tmpAns:" << tmpAns << endl;
    if (tmpAns >= 0) {
      ans = min(ans, tmpAns);
    }

    wall += 1;
    if (wall >= 1 << (H - 1)) {
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mem(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair <int,int> PAIR;
const int maxn = 2e5 + 7;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;
ll a[maxn];

int main(){	
	int n;
	ll res = 0;
	scanf("%d",&n);
	for(int i = 1;i <= n;++i) scanf("%lld",&a[i]),res ^= a[i];
	for(int i = 1;i <= n;++i) printf("%lld%c",res^a[i],i == n ?'\n' :' ');
	return 0;
}

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

// 大きな配列はここに書く
long long dp[110][100100];

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long W;
    scanf("%lld",&W);
    std::vector<long long> w(N);
    std::vector<long long> v(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&w[i]);
        scanf("%lld",&v[i]);
    }

    // 初期化
    for(long long i=0; i<110; i++){
      for(long long x=0; x<100100; x++){
	dp[i][x] = LONG_LONG_MAX/10; // Wよりも十分大きい数 (オーバーフローに注意)
      }
    }
    dp[0][0] = 0;

    // dp[i][x] = 0~i番目までの品物から価値がx以上を達成するように選んだときの、重さの総和の最小値
    // 貰うdp
    // 遷移: 品物iを1つ加えるか判定する
    // 状態(i+1,x) <- (i,x-v[i]) or (i-1,x)
    for(long long i=0; i<N; i++){
      for(long long x=0; x<100100; x++){      
	if(x-v[i] >= 0){
	  dp[i+1][x] = min(dp[i+1][x], dp[i][x-v[i]] + w[i]);
	}
      
	dp[i+1][x] = min(dp[i+1][x], dp[i][x]);

	//cout << dp[i+1][x] << endl;
      }
    }

    int ans = 0;
    for(int x=0; x<100100; x++){
      // 制約を満たすならば
      if(dp[N][x] <= W) ans = x;
    }
    cout << ans << endl;
    
    return 0;
}

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

int main(){
	int count, n;
	string moji;
	int s = 0;
	

	while(cin >> moji){

		count = moji.size();

		if(count % 2 == 0){
			n = count / 2;
		}
		else{
			n = count / 2 + 1;
		}

		bool flag = true;
		for(int i = 0; i < n; i++){
			if(flag){
				if(moji[i] == moji[count - 1]){
					count--;
					flag = true;
					continue;
				}
				else{
					flag = false;
				}
			}
			else{
				break;
			}
		}
		if(flag){
			s++;
		}
	}

	cout << s << endl;
}

Measured memory_bytes: 0
import java.util.Scanner;

/**
 * 
 */

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		String T = "";
		String W;
		String str = "";
		int count = 0;
		
		
		W = as.nextLine();
		W = W.toLowerCase();
	    
	    
	    
	    while(as.hasNext()){                  //EOF?????§??±????????????????????£?????????
	    	
	    	T = as.next();
	    	T = T.toLowerCase();
       
	    	
	    	if(T.indexOf(W) == 0 && T.lastIndexOf(W) == 0){
	    		
	    		count++;
	    		
	    	}
	    
             
        }
	    
	    str = String.valueOf(count);
	    System.out.println(str);

	}

}

Measured memory_bytes: 26200
function Main(inputs) {
  const input = inputs.split("\n");
  const n = Number(input[0].split(" ")[0]);

  const result = Array(50001)
    .fill(0)
    .map((_, i) => (Math.floor(i * 1.08)))
    .findIndex((i) => i === n);
  console.log(result === -1 ? ":(" : result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 8012
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		// 文字列の入力
		//String s = sc.next();

		int ans = (1900*m+100*(n-m))*(int)(Math.pow(2, m));

		// 出力
		System.out.println(ans);
	}
}


Measured memory_bytes: 21972
/*
        KUNAL RAUT (ZUKONIT14)  :- "DO WHAT YOU LIKE!" 
                -PICT,PUNE! :)
*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define mod 1000000007
#define mod9 1000000009
#define pi 3.1415926535
#define MAXN 1000001
#define all(v) v.begin(), v.end()
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define forci(p,n) for(ll i=p;i<(ll)n;i++)
#define bolt ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test ll t;cin>>t;while(t--)
ll zero=0;

ll gcd(ll a,ll b){    if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) {    return (a/gcd(a,b)*b);}
ll expo(ll x, ll y) {ll res=1;x=x%mod;while(y>0){if(y&1)res=(1ll*res*x)%mod;
    y=y>>1;x=(1ll*x*x)%mod;} return res;}
ll ncr(ll n,ll r){ ll res=1; if(r>n-r)r=n-r; for(ll i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res;}
bool prime(ll n){ll i;if(n==1) return false;for(i=2;i<=sqrt(n);i++){if(n%i==0)return false;}return true;}
 
/*ll spf[MAXN];
void sieve()
{
    spf[1] = 1;
    for (ll i=2; i<MAXN; i++)
        spf[i] = i;
    for (ll i=4; i<MAXN; i+=2)
        spf[i] = 2;
    for (ll i=3; i*i<MAXN; i++)
    {
        if (spf[i] == i)
        {
            for (ll j=i*i; j<MAXN; j+=i)
            if (spf[j]==j)
            spf[j] = i;
        }
    }
}
bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b)return(a.second<b.second);*/
 
//https://www.youtube.com/watch?v=k4V3Mo61fJM
 
using namespace std;

signed main()
{
    bolt;
    ll n,k;cin>>n>>k;
    ll a[n],dp[n];
    forci(0,n)
    cin>>a[i],dp[i]=INT_MAX;
    dp[0]=0;
    forci(0,n)
    {
        for(ll j=1;j<=k;j++)
        {
            if(i+j<n)
            dp[i+j]=min(dp[i+j],abs(a[i+j]-a[i])+dp[i]);
        }
    }
    cout<<dp[n-1];
    return 0;
}


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

#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define endl '\n'
// #define int long long

typedef pair<int,int> pii;
const int N = 2e3+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, m;
char a[N][N];
int hor[N][N], ver[N][N];
void xuat(int a[N][N]){
	for(int i=0; i<=n; i++){
		for(int j=0; j<=m; j++){
			cerr << a[i][j] << ' ';
		}
		cerr << endl;
	}
	cerr << "---------------------\n";
}
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n >> m;
	for(int i=1; i<=n; i++){
		for (int j=1; j<=m; j++){
			cin >> a[i][j];
		}
	}
	for(int i=1; i<=n; i++){
		for(int j=1; j<=m; j++){
			if (a[i][j] == '#') hor[i][j] = ver[i][j] = 0;
			else {
				hor[i][j] = 1 + hor[i][j-1];
				ver[i][j] = 1 + ver[i-1][j];
			}
		}
	}
	for(int i=1; i<=n; i++){
		for(int j=m-1; j>=1; j--){
			if (a[i][j] == '#') continue;
			hor[i][j] = max(hor[i][j], hor[i][j+1]);
		}
	}
	for(int j=1; j<=m; j++){
		for(int i=n-1; i>=1; i--){
			if (a[i][j] == '#') continue;
			ver[i][j] = max(ver[i][j], ver[i+1][j]);
		}
	}
	int ans = 0;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=m; j++){
			ans = max(ans, hor[i][j] + ver[i][j] - 1);
		}
	}
	cout << ans << endl;
	return 0;
}


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

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

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	vector<bool> flag(10,true);
	rep(i,k){
		int d;
		cin>>d;
		flag[d]=false;
	}
	int ans=INF;
	auto dfs=[&](auto &dfs,int d,string now)->void{
		if(d==6) return ;
		if(d){
			int m=stoi(now);
			if(m>=n){
				chmin(ans,m);
				return ;
			}
		}
		rep(i,10){
			if(flag[i]){
				char ne=i+'0';
				dfs(dfs,d+1,now+ne);
			}
		}
	};
	dfs(dfs,0,"");
	cout<<ans<<endl;
}

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

using ll = long long;

//constant
const ll MOD = 1e+9 + 7;
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// view vector
template<typename T> void view(T e) { std::cout << e << std::endl; }
template<typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

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

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


vector<ll> A(401);
vector<ll> B(401);
vector<vector<ll>> memo(401, vector<ll>(401));
vector<vector<bool>> done(401, vector<bool>(401));
int N;

void acm() {
	B[0] = A[0];
	FOR(i, 1, N) {
		B[i] = B[i - 1] + A[i];
	}
}

ll get(ll L, ll R) {
	ll res = B[R];
	if (L > 0) res -= B[L - 1];

	return res;
}


ll dp(int L, int R) {
	if (L == R) return 0;
	if (done[L][R]) return memo[L][R];
	done[L][R] = true;

	ll res = 1e16;
	FOR(c, L, R + 1) {
		chmin<ll>(res, dp(L, c) + dp(c + 1, R) + get(L, R));
	}
	return memo[L][R] = res;
}


int main(void) {

	cin >> N;
	REP(i, N) {
		cin >> A[i];
	}
	acm();

	ll ans = dp(0, N - 1);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

int main() {
    int n;
    string s;
    cin >> n;
    cin >> s;
    if(n % 2 == 0) {
        for(int i = 0; i < n / 2; ++i) {
            if(s[i] != s[n / 2 + i]) {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

int main(){
    string s;
    cin >>s;
    bool ans = true;
    for(int i=0;i<s.size();i++){
        if(i%2==0){
            if(s[i]=='L'){
                ans = false;
                break;
            }
        }else{
            if(s[i]=='R'){
                ans = false;
                break;
            }
        }
    }
    if(ans){
        cout << "Yes" <<endl;
    }else{
        cout << "No"<<endl;
    }
}

Measured memory_bytes: 256
import math
[a,b,c] = [int(i) for i in input().split()]

if a == b:
  l = 4*a
  r = c
else:
  if a+b < c:
  	l = 4*a*b
  	r = (c -(a+b))**2
  else:
    l = 2 * math.sqrt(a*b)
    r = c - (a + b)
    
if l < r:
  print("Yes")
else:
  print("No")

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

using namespace std;

#define ll long long

signed main() {
	int m; cin >> m;
	ll hoge = 0LL;
	while (m--) {
		int d; ll c;
		cin >> d >> c;
		hoge += d * c;
		hoge += c * 9;
	}
	cout << ((hoge - 18) / 9 + (hoge % 9 == 0 ? 0 : 1)) << endl;
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
s = gets.chomp

r = s[1..-1].count("E")
l = 0

minv = r + l

1.upto(n-1) do |i|
  r -= 1 if s[i]=='E'
  l += 1 if s[i-1]=='W'
  minv = [minv, r+l].min
end

p minv


Measured memory_bytes: 2436
n, x = gets.split(" ").map{|v|
	v.to_i
}

if (x == 1 ) or (x == 2*n-1) then
	puts "No"
	exit
elsif (n == 2) then
	puts "Yes"
	puts "1\n2\n3"
	exit
else
	puts "Yes"
	max = 2*n-1
	
	list = (1.. max).to_a.map{|v|
	v.to_i
	}
	if x > 2 then
		list.reject! {|j| j ==1 or j == 2 or j == x or j == max}
		ans = list[0, n-3] + [1, x, max, 2] + list[-n+2 , n-2]
	else
		list.reject! {|j| j ==1 or j == 2 or j == max-1 or j == max}
		ans = list[0, n-3] + [max-1, 2, 1, max] + list[-n+2 , n-2]
	end
	
	puts ans
	
end



Measured memory_bytes: 7292
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from collections import defaultdict,Counter
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col):
    data.sort(key=lambda x:x[col],reverse=False)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

# nまでの自然数が素数かどうかを表すリストを返す
# Sieve of Eratosthenes
def makePrimeChecker(n):
    isPrime = [True] * (n + 1)
    isPrime[0] = False
    isPrime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if isPrime[i]:
            for j in range(i * i, n + 1, i):
                isPrime[j] = False
    return isPrime

q = int(input())
lr = mylistinput(q)


ls = makePrimeChecker(10**5)

ls_s = [0]*(10**5)
count = 0
for i in range(len(ls_s)): 
    if i%2==0:
        pass
    else:
        if ls[i]:
            j = (i+1)//2
            if ls[j]:
                count += 1
    ls_s[i] = count
# print(ls_s[:20])

for i in range(q):
    l = lr[i][0]
    r = lr[i][1]
    ans = ls_s[r] - ls_s[l-1]
    print(ans)

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

using namespace std;

const int MAXNUM = 10000000;

int main(void){
	int N, M;
	int A[1000], B[1000], C[1000];
	int dp[100][100];

	cin >> N >> M;

	for(int i=0;i<M;i++){
		cin >> A[i] >> B[i] >> C[i];
		A[i]--, B[i]--;
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(i == j){
				dp[i][j] = 0;
			}
			else{
				dp[i][j] = MAXNUM;
			}
		}
	}
	for(int i=0;i<M;i++){
		dp[A[i]][B[i]] = C[i];
		dp[B[i]][A[i]] = C[i];
	}
	for(int k=0;k<N;k++){
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
			}
		}
	}
	int count=0;
	for(int i=0;i<M;i++){
		if(dp[A[i]][B[i]] < C[i]) count++;
	}
	cout << count << endl;
}

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

using namespace std;

#pragma GCC optimize ("-O3")

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define ld long double
#define vll vector<ll> 
#define vs vector<string>
#define vc vector<char>
#define vpll vector<pair<ll,ll>>
#define tc ll t=0;cin>>t;while(t--)
#define pb push_back
#define pop pop_back
#define all(x) (x).begin(),(x).end()
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define maxe *max_element
#define mine *min_element
#define f first
#define s second
#define vli vll::iterator 
#define mp make_pair
#define unmap unordered_map
#define unmapll unordered_map<ll,llt>
#define max_val 99999999
#define min_val -99999999
#define mod 1000000007
const ld PI = 3.141592653589793;

bool isPowerOfTwo (int x) 
{ 
  return x && (!(x&(x-1))); 
} 


int main()
{
    IOS
    #ifdef LOCAL
            freopen("C:\\Users\\Just Coding Things\\Codeforces\\input.txt","r",stdin);
            freopen("C:\\Users\\Just Coding Things\\Codeforces\\output.txt","w",stdout);
        #endif
    
	ll a,b,c,d,r1,r2,q1,q2;
	cin>>a>>b>>c>>d;
	
	q1=c/b;
	r1=c%b;
	r2=a%d;
	q2=a/d;
	if(r1>0)
	q1++;
	if(r2>0)
	q2++;
	if(q1<=q2) cout<<"Yes";
	else cout<<"No";
    return 0;
}

Measured memory_bytes: 3608
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Program
{
    public class ABC124C
    {
        static public void Main(string[] args)
        {
            var S = NextString;
            var ans1 = 0;
            var ans2 = 0;
            for (int i = 0; i < S.Length; ++i)
            {
                if (S[i] == (i % 2 == 0 ? '0' : '1')) ++ans1;
                else ++ans2;
            }

            Console.WriteLine(Math.Min(ans1, ans2));
        }

        static class Console_
        {
            private static Queue<string> param = new Queue<string>();
            public static string NextString()
            {
                if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item);
                return param.Dequeue();
            }
        }
        static int NextInt => int.Parse(Console_.NextString());
        static int[] NextIntArray(int N)
        {
            var ret = new int[N];
            for (int i = 0; i < N; ++i) ret[i] = NextInt;
            return ret;
        }
        static long NextLong => long.Parse(Console_.NextString());
        static long[] NextLongArray(int N)
        {
            var ret = new long[N];
            for (int i = 0; i < N; ++i) ret[i] = NextLong;
            return ret;
        }
        static string NextString => Console_.NextString();
        static void Rep(int count, Action<int> func)
        {
            for (int i = 0; i < count; ++i) func(i);
        }
        static void Rep(int count, Action func)
        {
            for (int i = 0; i < count; ++i) func();
        }
        static void Foreach<T>(IEnumerable<T> list, Action<T> func)
        {
            foreach (var item in list) func(item);
        }
        static void Foreach<T>(IEnumerable<T> list, Action<T, int> func)
        {
            int idx = -1;
            foreach (var item in list) func(item, ++idx);
        }
        static IEnumerable<long> Prime(long x)
        {
            if (x < 2) yield break;
            yield return 2;
            var halfx = x / 2;
            var table = new bool[halfx + 1];
            var max = (long)(Math.Sqrt(x) / 2);
            for (long i = 1; i <= max; ++i)
            {
                if (table[i]) continue;
                var add = 2 * i + 1;
                yield return add;
                for (long j = 2 * i * (i + 1); j <= halfx; j += add) table[j] = true;
            }
            for (long i = max + 1; i <= halfx; ++i) if (!table[i]) yield return 2 * i + 1;
        }
        static IEnumerable<long> Divisor(long x)
        {
            if (x < 1) yield break;
            var max = (long)Math.Sqrt(x);
            for (long i = 1; i < max; ++i)
            {
                if (x % i != 0) continue;
                yield return i;
                if (i != x / i) yield return x / i;
            }
        }
        static long GCD(long a, long b)
        {
            long tmpa = a, tmpb = b;
            while (tmpb > 0) { var tmp = tmpb; tmpb = tmpa % tmpb; tmpa = tmp; }
            return tmpa;
        }
    }
}


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

const int MAXN = 1.1e5;
int N;
int X[MAXN];
int L;

int jump[MAXN][31];

int query(int a, int b) {
	int res = 0;
	for (int i = 30; i >= 0; i--) {
		if (jump[a][i] < b) {
			res += 1 << i;
			a = jump[a][i];
		}
	}
	assert(jump[a][0] >= b);
	return res + 1;
}

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

	cin >> N;
	for (int i = 0; i < N; i++) cin >> X[i];

	cin >> L;
	for (int i = 0, j = 0; i < N; i++) {
		while (j < N && X[j] - X[i] <= L) j++;
		jump[i][0] = j-1;
	}

	for (int l = 0; l < 30; l++) {
		for (int i = 0; i < N; i++) {
			jump[i][l+1] = jump[jump[i][l]][l];
		}
	}

	int Q; cin >> Q;
	for (int q = 0; q < Q; q++) {
		int a, b; cin >> a >> b; a--, b--;
		if (a > b) swap(a, b);
		cout << query(a, b) << '\n';
	}

	return 0;
}


Measured memory_bytes: 13568
#include<stdio.h>
struct Card{
	char suit;
	char value;
};

void bubble(struct Card A[], int n){
	int i, j;
	struct Card t;
	for ( i = 0; i < n; i++ ){
		for ( j = n-1; j >= i+1; j-- ){
			if ( A[j].value < A[j-1].value ){
			t = A[j]; A[j] = A[j-1]; A[j-1] = t;
			}
		}
	}
}

void selection(struct Card A[], int n){
	int i, j, mini;
	struct Card t;
	for ( i = 0; i < n; i++ ){
		mini = i;
		for ( j = i; j < n; j++ ){
			if ( A[j].value < A[mini].value ) mini = j;
		}
	t = A[i]; A[i] = A[mini]; A[mini] = t;
	}
}

void print(struct Card A[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( i ) printf(" ");
    printf("%c%c", A[i].suit, A[i].value);
  }
  printf("\n");
}

int isStable(struct Card C1[], struct Card C2[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( C1[i].suit != C2[i].suit ) return 0;
  }
  return 1;
}

int main(){
	struct Card C1[101], C2[101];
	int n, i;
	char ch;

	scanf("%d\n", &n);
	for ( i = 0; i < n; i++ ){
		scanf("%c%c ", &C1[i].suit, &C1[i].value);
	}

	for ( i = 0; i < n; i++ ) {
		C2[i] = C1[i];
	}

    bubble(C1, n);
    selection(C2, n);
    
	print(C1, n);
	printf("Stable\n");
	print(C2, n);
	if ( isStable(C1, C2, n) ){
		printf("Stable\n");
	} else {
		printf("Not stable\n");
	}

  return 0;
}


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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n, d;
    cin >> n >> d;
    vector<vector<int>> a(n, vector<int>(d));
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < d; ++j){
            cin >> a[i][j];
        }
    }
    int cnt = 0;
    for(int i = 0; i < n; ++i){
        for(int j = i+1; j < n; ++j){
            ll dist = 0;
            for(int k = 0; k < d; ++k){
                dist += (a[i][k] - a[j][k])*(a[i][k] - a[j][k]);
            }
            int k;
            for(k = 0; k * k < dist; ++k);
            if((ll)k * k == dist) ++cnt;
        }
    }
    cout << cnt << "\n";
    return 0;
}

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

/* #include<cstdio>*/
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int i = 0;
	for (int x = a; x <= b; x++){
	if (c % x == 0)i++;
	}
	cout << i << endl;

	return 0; 
}





Measured memory_bytes: 3100
import sys

BLOCK_WIDTH = 4
BLOCK_HEIGHT = 2
field = []
dx = [-1, 0, 1, 0]
dy = [0, 1, 0, -1]
w = 0
h = 0
xg = 0
yg = 0
start_color = 0

def main():
    global field, w, h, c, xg, yg, start_color
    while True:
        w, h = map(int, input().split())
        if w == 0 and h == 0:
            break
        xs, ys = map(int, input().split())
        xg, yg = map(int, input().split())
        xs -= 1
        ys -= 1
        xg -= 1
        yg -= 1
        n = int(input())
        field = [[0] * w for _ in range(h)]
        for i in range(n):
            c, d, x, y = map(int, input().split())
            arrangement(c, d, x - 1, y - 1)

        start_color = field[ys][xs]
        if dfs(xs, ys):
            print("OK")
        else:
            print("NG")


def arrangement(c, d, x, y):
    if d == 0:
        [[draw(x + j, y + i, c) for j in range(BLOCK_WIDTH)] for i in range(BLOCK_HEIGHT)]
    else:
        [[draw(x + j, y + i, c) for j in range(BLOCK_HEIGHT)] for i in range(BLOCK_WIDTH)]


def draw(x, y, c):
    global field
    field[y][x] = c


def dfs(x, y):
    global field

    if x == xg and y == yg:
        return True
    if start_color == 0:
        return False
    field[y][x] = 0
    for i in range(4):
        next_x = x + dx[i]
        next_y = y + dy[i]
        if next_x < 0 or next_x >= w or next_y < 0 or next_y >= h:
            continue
        if field[next_y][next_x] != start_color:
            continue
        if dfs(next_x, next_y):
            return True

    return False


if __name__ == '__main__':
    main()

Measured memory_bytes: 7868
#include "bits/stdc++.h"

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

size_t N, M;
vector<int> g[int(1e5) + 5];

vector<int64_t> dp(int(1e5) + 5, -1LL);

int64_t rec(size_t node) {
    if (~dp[node]) return dp[node];

    int64_t ret = 0;
    for (auto &elem: g[node]) {
        chmax(ret, rec(elem) + 1);
    }

    return dp[node] = ret;
}

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

    cin >> N >> M;

    for (size_t i = 0; i < M; ++i) {
        size_t x, y; cin >> x >> y;
        x--, y--;
        g[x].emplace_back(y);
    }

    int64_t res = 0;
    for (size_t node = 0; node < N; ++node) {
        chmax(res, rec(node));
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 8576
import collections
n=int(input())
s=[input() for _ in range(n)]
c=collections.Counter(s)
common=c.most_common()
value,cnt=zip(*common)
common.sort(key=lambda x:x[0])
m=max(cnt)
for cc in common:
  if cc[1]==m:
    print(cc[0])


Measured memory_bytes: 60912
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>

int main(){
   int N, M;
   std::cin >> N >> M;
   int P[M], Y[M];
   std::vector<std::vector<int> > PY(N);
   for(int i=0; i<M; ++i){
      std::cin >> P[i] >> Y[i];
      PY[P[i]-1].push_back(Y[i]);
   }
   for(int i=0; i<N; ++i)
      std::sort(PY[i].begin(), PY[i].end());

   for(int i=0; i<M; ++i){
      int index = std::lower_bound(PY[P[i]-1].begin(),PY[P[i]-1].end(),Y[i]) - PY[P[i]-1].begin();
      std::cout << std::setfill('0') << std::right << std::setw(6) << P[i];
      std::cout << std::setfill('0') << std::right << std::setw(6) << index+1;
      std::cout << std::endl;
   }

   return 0;
}


Measured memory_bytes: 7808
#include<stdio.h>

int main()
{
    int N, A;

    scanf("%d", &N);
    scanf("%d", &A);

    if((N%500)<=A){
        if(((N%500)%1)==0){
            printf("Yes");
        }
    }else{
        printf("No");
    }

    return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	double a, b, n;
	cin >> a >> b >> n;
	
	cout << floor(a * min(b - 1, n) / b) - a * floor(min(b - 1, n) / b) << endl;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
int main(){
	string S;
	cin >> S;
	string f = "", b = "";
	int which = 0;
	int Q;
	cin >> Q;
	for(int i=0;i<Q;i++){
		int T;
		cin >> T;
		if(T == 1){
			which++;
			which %= 2;
		}
		if(T == 2){
			int F;
			string C;
			cin >> F >> C;
			if((F + which) % 2 == 1)f = f + C;
			else b = b + C;
		}
	}
	reverse(f.begin(), f.end());
	S = f + S + b;
	if(which)reverse(S.begin(), S.end());
	// cout << f << endl;
	// cout << S << endl;
	// cout << b << endl;
	cout << S << endl;
}


Measured memory_bytes: 4580
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())
    a = list(map(int, readline().split()))
    a.sort(reverse=True)

    x = sum(a[::2])
    y = sum(a[1::2])

    print(x - y)


if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 45;
const int M = 17;
const ll mod = 1000000007;

int n, x, y, z;
ll dp[N][(1<<M)];

inline bool check(int mask){
	return (mask>>x)&(mask>>y)&(mask>>z)&1;
}

inline int getNext(int mask, int val){
	mask <<= val;
	mask ^= 1<<(val - 1);
	mask &= (1<<(z + 1)) - 1;
	return mask;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	cin>>n>>x>>y>>z;
	int m = x + y + z;
	y += x; z += y;
	x--; y--; z--;
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	for(int i = 1; i <= n; i++){
		for(int mask = 0; mask < (1<<m); mask++){
			if(check(mask))continue;
			for(int val = 1; val <= 10; val++){
				int nmask = getNext(mask, val);
				if(check(nmask))continue;
				dp[i][nmask] += dp[i - 1][mask];
				if(dp[i][nmask] >= mod)dp[i][nmask] -= mod;
			}
		}
	}
	ll ans = 1;
	for(int i = 1; i <= n; i++){
		(ans *= 10) %= mod;
	}
	for(int mask = 0; mask < (1<<m); mask++){
		if(!check(mask))ans += mod - dp[n][mask];
	}
	ans %= mod;
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 46336
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <unordered_map>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;
using LL = long long;

int main() {
	string s;
	cin >> s;
	reverse(s.begin(),s.end());
	while (s.size()>=5) {
		if (s.substr(0, 5) == "maerd")s = s.substr(5, s.size() - 5);
		else if (s.substr(0, 7) == "remaerd")s = s.substr(7, s.size() - 7);
		else if (s.substr(0, 5) == "esare")s = s.substr(5, s.size() - 5);
		else if (s.substr(0, 6) == "resare")s = s.substr(6, s.size() - 6);
		else break;
	}
	cout << (s.size() ? "NO" : "YES") << endl;
}

Measured memory_bytes: 512
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let m: usize = input();
    let xy: Vec<(usize, usize)> = (0..m).map(|_| (input(), input())).collect();

    let mut e = vec![vec![]; n];
    for &(x, y) in &xy {
        e[x - 1].push(y - 1);
    }

    let mut m = vec![-1; n];
    let mut ans = 0;
    for i in 0..n {
        ans = std::cmp::max(ans, dfs(i, &e, &mut m));
    }

    println!("{}", ans);
}

fn dfs(cur: usize, edge: &Vec<Vec<usize>>, m: &mut Vec<i64>) -> i64 {
    if m[cur] >= 0 {
        m[cur]
    } else {
        let mut mx = 0;
        for &next in &edge[cur] {
            mx = std::cmp::max(mx, 1 + dfs(next, edge, m));
        }

        m[cur] = mx;
        m[cur]
    }
}


Measured memory_bytes: 17276
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rea(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
/* END OF TEMPLATE */

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll x;
    cin >> x;
    ll ans;
    if((x - 1) % 11 >= 6){
        ans = (x + 10) / 11 * 2;
    }else{
        ans = (x + 10) / 11 * 2 - 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256