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


#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int N = 2e5 + 10;


using namespace std;

int main()
{



	IOS;

	int n;

	cin >> n;

	int a[n];

	ll result = 1e9;


	loop(i, n)
	{
		cin >> a[i];
	}


	sort(a, a + n);


	for (int i = a[0]; i <= a[n - 1]; i++)
	{

		int ans = 0;
		for (int j = 0; j < n; j++)
		{
			ans += (a[j] - i) * (a[j] - i);
		}

		if (ans < result)
		{
			result = ans;
		}
	}

	cout << result;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt(),m=sc.nextInt();
		
		boolean[] list = new boolean[n];
		for(int i=0;i<n;i++)list[i]=true;
		
		for(int i=0;i<m;i++) {
			int l=sc.nextInt(),r=sc.nextInt();
			
			for(int j=0;j<l-1;j++) {
				list[j]=false;
			}
			for(int j=r;j<n;j++) {
				list[j]=false;
			}
			
		}
		
		int ans=0;
		for(int i=0;i<n;i++) {
			if(list[i]) {
				ans++;
				//System.out.println(i);
			}
		}
		System.out.println(ans);
		
	}

}


Measured memory_bytes: 66164
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (upper_bound(A.begin(), A.end(), A[i]) - lower_bound(A.begin(), A.end(), A[i]) > 1) {
            continue;
        }
        vector<int> v;
        for (int j = 1; j*j <= A[i]; j++) {
            if (A[i] % j == 0) {
                v.push_back(j);
                if (A[i] != j*j) {
                    v.push_back(A[i]/j);
                }
            }
        }
        sort(v.begin(), v.end());
        v.pop_back();
        bool f = 1;
        for (auto x: v) {
            if (upper_bound(A.begin(), A.end(), x)-lower_bound(A.begin(), A.end(), x) >= 1) {
                f = 0;
                break;
            }
        }
        if (f) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4012
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
const int mod = 1e9 + 7;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
const double phi = (1 + sqrt(5)) / 2;
const double phi_ = (1 - sqrt(5)) / 2;
ll fib(ll n){
    double res = pow(phi, n+1) - pow(phi_, n+1);
    return res / sqrt(5);
}
ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}
ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}
string to_bin_string(ll n){
    stringstream ss;
    ss << bitset<8>(n); //任意の桁数<m>
    string s = ss.str();
    return s;
}
vi prime(int n){
    vi p;
    REP(i,2,n+1){
        if(i == 2){
            p.push_back(i);
            continue;
        }
        bool ok = false;
        REP(j,2,sqrt(i)+1)if(i % j == 0){
            ok = true;
            break;
        }
        if(!ok)p.push_back(i);
    }  
    return p;
}
vi prime_factor(int n){
    vi p = prime(n);
    vi f;
    rep(i,p.size())if(n % p[i] == 0)f.push_back(p[i]);
    return f;
}
map<int, int> p_cnt;
int main()
{
    int n; cin >> n;
    REP(i,2,n+1){
        vi f = prime_factor(i);
        int k = i;
        rep(j,f.size()){
            while(k % f[j] == 0){
                k /= f[j];
                p_cnt[f[j]]++;
            }
        }
    }
    ll ans = 1;
    for(map<int, int>::iterator it = p_cnt.begin(); it != p_cnt.end(); it++){
        //cout << it->first << " " << it->second << endl;
        ans *= (it->second + 1);
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<cctype>
#include<queue>
#include<cstdio>
#include<cmath>
#include<sstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<ctime>
#include<cstdlib>
#include<map>
#include<utility>
#include<iomanip>
#include<set>
#include<stack>
//#include<Windows.h>
using namespace std;
typedef long long ll;typedef pair<int,int> pii;
typedef pair<ll,ll> pll;typedef vector<string> vss;
typedef vector<int> vii;typedef vector<pii> vpi;
typedef vector<ll> vll;typedef vector<pll> vpl;typedef long double ld;
typedef unsigned long long ul;typedef queue<int> qii;typedef queue<pii> qpi;
ll x,y,t;
int main()
{
// 	freopen("","r",stdin);
// 	freopen("","w",stdout);
	cin>>x>>y;
	while(x<=y){
		if(y-x>=x) {x*=2;t++;}
		else {cout<<t+1<<'\n';return 0;}
	}
	cout<<t<<'\n';
	return 0;
}


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

using namespace std;
typedef long long ll;

const int INF = 1e9;
const int N = 1e5;

int a[N + 5], b[N + 5];

int main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n,m,l; cin >> n >> m >> l;
	int ans = 0;
	int mini = INF;
	for(int i=1; i<=n; i++) cin >> a[i], mini = min(mini, a[i]);
	ans += mini;
	mini = INF;
	for(int i=1; i<=m; i++) cin >> b[i], mini = min(mini, b[i]);
	ans += mini;
	for(int i=0; i<l; i++) {
		int x,y,c; cin >> x >> y >> c;
		ans = min(ans, a[x] + b[y] - c);
	}
	cout << ans << endl;
	return 0;
}

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

namespace ABC124
{
    class B
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] h = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int ans = 0;
            for (int i = 0; i < n; i++)
            {
                bool b = true;
                for (int j = 0; j < i; j++)
                {
                    b &= (h[j] <= h[i]);
                }
                if (b) { ans++; }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(void)
{
    int a, b, c;

    cin >> a >> b >> c;
    cout << (a + b + c >= 22 ? "bust" : "win") << endl;

    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <string.h>
#include <bitset>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head




int sg(int x, int k) {
	if (k>x) return 0;
	if (x%k==0) return x/k;
	int a = x/k+1, b = x%k;
	return sg(x-(b+a-1)/a*a,k);
}

int main() {
	int n;
	scanf("%d", &n);
	int ans = 0;
	REP(i,1,n) {
		int a, k;
		scanf("%d%d", &a, &k);
		ans ^= sg(a,k);
	}
	puts(ans?"Takahashi":"Aoki");
}









Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int min=0;
		int max=0;
		for(int i = 0;i<n;i++) {
			a[i]=sc.nextInt();
		}
		Arrays.sort(a);
		System.out.println(a[n-1]-a[0]);
	}
}


Measured memory_bytes: 35996
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	hs := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&hs[i])
	}

	mm := make(map[int]bool)
	var a, b int
	for i := 0; i < m; i++ {
		fmt.Scan(&a, &b)
		a--
		b--

		if hs[a] <= hs[b] {
			mm[a] = true
		}
		if hs[a] >= hs[b] {
			mm[b] = true
		}
	}

	ans := 0
	for i := 0; i < n; i++ {
		if !mm[i] {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 8660
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

ostream& operator <<(ostream& out, const pair<int, int>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const set<T>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

const int N = 2e4 + 10;
int dp[N];

int main() {
  int m, n;
  scanf("%d%d", &m, &n);
  fill(dp, dp + N, INF);
  dp[0] = 0;
  for (int i = 0; i < n; ++i) {
    int A, B;
    scanf("%d%d", &A, &B);
    for (int j = 0; j + A < N; ++j) {
      dp[j + A] = min(dp[j + A], dp[j] + B);
    }
  }
  int ret = INF;
  for (int i = m; i < N; ++i) {
    ret = min(ret, dp[i]);
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<stack>
#include<algorithm>
#include<queue>
#include<cmath>
#include<numeric>
#include<map>
#include<set>
#include<vector>
#include<list>
#include<iomanip>
#include<functional>
#include<bitset>

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

using namespace std;
typedef long long ll;

int main(){
    int n,i=0,res=0;
    cin>>n;
    ll a[100000];
    rep(i,n) cin>>a[i];
    sort(a,a+n);
    while(i<n){
        int cc = a[i],f=0;
        while(i<n&&a[i]==cc) f++,i++;
        res += f%2;
    }
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 1024
<?php
define("MOD", 10**9+7);
fscanf(STDIN, "%d%d", $N, $M);

for($j = 2; $j <= $M; $j++){
    if($M%$j == 0){
        @$map[$j]++;
        $M/=$j;
        $j--;
    }
}
$product = 1;
foreach($map as $prime => $count){
    $product *= nCm($count + $N - 1, $count);
    $product %= MOD;
}
echo $product;

//足し算
function addm($a, $b){
    return ($a + $b) % MOD;
}
//引き算
function subm($a, $b){
    return ($a + MOD - $b) % MOD;
}
//掛け算
function mulm($a, $b){
    return ($a * $b) % MOD;
}
//割り算
function divm($a, $b){
    return mulm($a, powerm($b, MOD - 2));
}
//累乗
function powerm($a, $b){
    if($b == 0)return 1;
    if($b & 1)return (powerm($a, $b>>1)**2 % MOD) * $a % MOD;
    return powerm($a, $b>>1)**2 % MOD;
}
//階乗
function factorialm($a){
    if($a == 0)return 1;
    return factorialm($a - 1) * $a % MOD;
}
//順列
function nPm($n, $m){
    if($m == 0)return 1;
    return nPm($n, $m - 1) * ($n - $m + 1) % MOD;
}
//組み合わせ
function nCm($n, $m){
    $m = min($m, $n-$m);
    return divm(nPm($n, $m), factorialm($m));
}

Measured memory_bytes: 4604
import bisect

def main():
    n = int(input())
    s = bytearray(input().encode())
    q = int(input())

    alpha = [ord('a')+i for i in range(26)]
    alpha_map = {c: [] for c in alpha}
    for i, c in enumerate(s):
        bisect.insort(alpha_map[c], i+1)

    for _ in range(q):
        t, a, b = [p for p in input().split()]
        t = int(t)
        a = int(a)
        if t == 1:
            char = s[a-1]
            b = ord(b)
            if char == b:
                continue
            src_lst = alpha_map[char]
            dst_lst = alpha_map[b]
            idx = bisect.bisect_left(src_lst, a)
            if idx < len(src_lst):
                src_lst.pop(idx)
            bisect.insort(dst_lst, a)
            s[a-1] = b
        else:
            b = int(b)
            cnt = 0
            for _, lst in alpha_map.items():
                idx = bisect.bisect_left(lst, a)
                if idx < len(lst) and lst[idx] <= b:
                    cnt +=1
            print(cnt)
main()



Measured memory_bytes: 24988
#include <bits/stdc++.h>
#define err(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

using namespace std;

typedef long long ll;

int main() {
	string s;
	cin >> s;
	
	for (char c = 'a'; c <= 'z'; c++) {
		if ((int)s.find(c) == -1) return 0 * printf("%c\n", c);
	}
	puts("None");
	return 0;
}

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

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl '\n'
typedef long long ll;
typedef unsigned long long ull;
#define f(i,start,end) for(i=start;i<=end;i++)
#define min_heap priority_queue<int, vector<int>, greater<int> >
#define max_heap priority_queue<int>

bool isPrime(int n)
{
    for(int i=2; i*i<=n; i++)
    {
        if(n%i==0) return false;
    }
    return true;
} //returns true if prime!

bool b[200001];
int dp[200001];

int main()
{
    fast;
//int t=0,tc=0; cin >> tc; f(t,1,tc) //testcases
    {
        int i=0, j=0;
        int n; ull k;
        cin >> n >> k;
        int a[n];
        f(i, 1, n) cin >> a[i];
        j=1; i=1; b[1] = 1; dp[0] = 1;
        
        while(!b[ a[j] ] && k)
        {
             j = a[j];
            b[j] = 1; dp[i] = j;
            k--;
            i++;
        }
        if(k==0){ cout << j; return 0; }
        
        k--;
        j = a[j];
        
        int track = 0;
        for(; track<=n; track++)
        {
            if(dp[track]==j){ break; }
        }
        i -= track; // cycle length
        
        k %= i;
        cout << dp[track+k];
    }
    return 0;
}
    

Measured memory_bytes: 5184
def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)

def solve(a, b, c, d):
    if a < b or d < b:
        return False
    if b < c:
        return True

    g = gcd(b, d)
    return (b + a % g - g) <= c

T, *L = map(int, open(0).read().split())

for t in zip(*[iter(L)] * 4):
    print(("No", "Yes")[solve(*t)])


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;

bool f(int n){
  string s = "";
  while(n){
    char temp = n%10 - '0';
    s += temp;
    n /= 10;
  }
  string t = s;
  reverse(s.begin(), s.end());
  return t == s;
}

int main(){
  int a,b; cin >> a >> b;
  int ans = 0;
  for(int i = a; i <= b; i++){
    if(f(i)) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
X, Y = list(map(int, input().split()))

flag = -1
A = 0
i = 2
if X%Y != 0:
   while A <= 1e18:
      A = i * X
      i = i + 1
      if A%Y != 0:
         flag = 1
         print(A)
         break

if flag == -1:
   print(-1)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long int ll;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

int main() {
  ll l;
  cin >> l;
  double ans = (double)l * l * l / 27;
  printf("%.10f\n", ans);
  return 0;
}

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

int solve(char arr[][1001],int h,int w)
{
    int dp[h+1][w+1];
    dp[h][w]=1;
    for(int i=h;i>=1;i--)
    {
        for(int j=w;j>=1;j--)
        {
            if(i==h && j==w)
            {
                continue;
            }
            else
            {
                if(arr[i][j]=='#')
                {
                    dp[i][j]=0;
                }
                else
                {
                    dp[i][j]= ( ((i==h)?0:(dp[i+1][j]))%p + ((j==w)?0:dp[i][j+1])%p )%p;
                }
            }
        }
    }
    return dp[1][1];
}

int main()
{
    int h,w;
    cin>>h>>w;
    char arr[1001][1001];
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            cin>>arr[i][j];
        }
    }
    cout<<solve(arr,h,w);
    return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;

struct my {
    ll a, b;
} x[maxn];

bool cmp(my& a, my& b)
{
    return a.a < b.a;
}

int main()
{
    ll a, b;
    cin >> a >> b;
    if (a > b)
        swap(a, b);
    ll ans = 0;
    if (b % 4 == 0) {
        ans = b;
    } else if (b % 4 == 1) {
        ans = 1;
    } else if (b % 4 == 2) {
        ans = b + 1;
    } else {
        ans = 0;
    }
    if ((a - 1) % 4 == 0) {
        ans ^= (a - 1);
    } else if ((a - 1) % 4 == 1) {
        ans ^= 1;
    } else if ((a - 1) % 4 == 2) {
        ans ^= (a - 1) + 1;
    } else {
        ans ^= 0;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
char ca[100005];
int main(){
	bool s=true;
	cin>>ca;
	int n=strlen(ca);
	if((ca[0]==ca[n-1] && n%2==1) || (ca[0]!=ca[n-1] && n%2==0))s=false;
	if(s)cout<<"First"<<endl;
	else cout<<"Second"<<endl;
	return 0;
}


Measured memory_bytes: 384
N, M = map(int, input().split())

step = [0 for _ in range(N + 2)]
step[1] = 1

for _ in range(M):
  i = int(input()) + 1
  step[i] = -1

for i in range(2, N + 2):
  if step[i] == -1:
    step[i] = 0
  else:
    step[i] = step[i - 2] + step[i - 1]

print (step[-1] % 1000000007)


Measured memory_bytes: 460056
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}



int main(){
	int n;
	cin >> n;
	
	int x = 800 * n;
	int y = n / 15 * 200;
	cout << x - y << endl;
	return 0;
}



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

using namespace std ;

int a , b ;

int main ()
{
    cin >> a >> b ;
    char c [ a * b ] ;
    int d [ a ] , e [ b ] , cnt1 = 0 , cnt2 = 0 ;
    for ( int i = 0 ; i < a * b ; ++ i ){
        cin >> c [ i ] ;
    }
    for ( int i = 0 ; i < a ; ++ i ){
        for ( int j = 0 ; j < b ; ++ j ){
            if ( c [ b * i + j ] == '#' ){
                d [ cnt1 ] = i ;
                cnt1 ++ ;
                break ;
            }
        }
    }
    for ( int j = 0 ; j < b ; ++ j ){
        for ( int i = 0 ; i < a ; ++ i ){
            if ( c [ b * i + j ] == '#' ){
                e [ cnt2 ] = j ;
                cnt2 ++ ;
                break ;
            }
        }
    }
    for ( int i = 0 ; i < cnt1 ; ++ i ){
        for ( int j = 0 ; j < cnt2 ; ++ j ){
            cout << c [ b * d [ i ] + e [ j ] ] ;
        }
        cout << endl ;
    }
}


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

typedef long long ll;

int main() {
    ll n, m;
    while( cin >> n >> m ) {
        if( m <= 2 * n ) {
            cout << m / 2 << endl;
        }
        else {
            ll temp = m - 2 * n;
            cout << n + temp / 4 << endl;
        }
    }
    return 0;
}

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

int main() {
	int H, W, N, a;
	cin >> H >> W >> N;
	unordered_map<int, int> b;
	for (int i = 1; i <= N; ++i) {
		cin >> a;
		b[i] = a;
	}
	queue<pair<int, int>> c;
	for (unordered_map<int, int>::iterator i = b.begin(); i != b.end(); ++i) c.push(*i);
	vector<vector<int>> ans(H, vector<int>(W));
	for (int i = 0; i < H; ++i) {
		if (i % 2) {
			for (int j = 0; j < W; ++j) {
				--c.front().second;
				ans[i][j] = c.front().first;
				if (!c.front().second) c.pop();
			}
		}
		else {
			for (int j = W - 1; j >= 0; --j) {
				--c.front().second;
				ans[i][j] = c.front().first;
				if (!c.front().second) c.pop();
			}
		}
	}
	for (vector<int>& i : ans) {
		for (int& j : i) cout << j << ' ';
		cout << endl;
	}
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <algorithm>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
using namespace std;

int main() {
  string s;
  cin >> s;
  rep(i, 0, s.size()/2) {
    if(s[i] != s[s.size()-1-i]) {
      cout << "No";
      return 0;
    } else if(s[i] != s[s.size()/2-i-1]) {
      cout << "No";
      return 0;
    } else if(s[i+s.size()/2+1] != s[s.size()-i-1]) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const int N = 1e5+10;
vector<int> g[201];
vector<pair<int,int>> ed;
int p[101];
int n,m,q;
void go(int s,int l){
	p[s]=1;
	for(int x=0;x<g[s].size();x++){
		bool c=false;
		for(int i=0;i<g[l].size();i++){
			if(g[s][x]==g[l][i]){
				c=1;
			}
		}
		if(g[s][x]==l||p[g[s][x]]){
			c=1;
		}
		if(c)
			continue;
		go(g[s][x],s);
	}
}
int main() {
	cin>>n>>m;
	for(int x=0;x<m;x++){
		int u,v;
		cin>>u>>v;
		ed.push_back({u,v});
	}
	int pp=0;
	for(int x=0;x<ed.size();x++){
		memset(p,0,sizeof(p));
		for(int i=1;i<=n;i++){
			g[i].clear();
		}
		q=0;
		for(int i=0;i<ed.size();i++){
			if(x==i){
				continue;
			}
			g[ed[i].first].push_back(ed[i].second);
			g[ed[i].second].push_back(ed[i].first);
		}
		go(ed[x].second,0);
		for(int i=0;i<51;i++){
			q+=p[i];
		}
		if(q<n){
			pp++;
		}
	}
	cout << pp << endl;
}

Measured memory_bytes: 256
n = int(input())

h = list(map (int,input().split()))

rs = [float("inf")] * n
rs[0] = 0

for i in range(1,n):
  rs[i] = min(rs[i], rs[i-1] + abs(h[i] - h[i-1]) )
  if i > 1 :
    rs[i] = min(rs[i], rs[i-2] + abs(h[i] - h[i-2]) )
    
print(rs[-1])


Measured memory_bytes: 13980
#include<stdio.h>
#include<string.h>
int main(){
	char a[10004];
	int n,m;
	scanf("%d",&n);
	scanf("%s",a);
		m=strlen(a);
		for(int i=0;i<m;i++)
		{
			if(a[i]+n>'Z')
			a[i]=a[i]+n-26;
			else
			a[i]=a[i]+n;
		}
	printf("%s\n",a);
	return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int n;
    cin>>n;
    map<string, int> mp;
    rep(i, n) {
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>

using namespace std;

int main(void){
    int n=0;
    int h=0;
    int w=0;
    int count=0;
    int a[1000]={0};
    int b[1000]={0};

    cin >> n >> h >> w;

    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i];
    }

    for(int i=0;i<n;i++){
        if(a[i]>=h&&b[i]>=w)count++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int A[500000];
int h;

void maxHeapify(int i){
  int l,r,largest,p;
  l=2*i;
  r=(2*i)+1;

  if(l <= h && A[l]>A[i]){largest=l;}
  else {largest=i;}

  if(r <= h && A[r]>A[largest]){largest=r;}

  if(largest!=i){
    p=A[i];
    A[i]=A[largest];
    A[largest]=p;
    maxHeapify(largest);
}
}

void buildMaxHeap(){
  int i,k;
  k=h/2;
  for(i=k;i>=1;i--){
    maxHeapify(i);
  }
}

int main(){
  int i;
  scanf("%d",&h);
  for(i=1;i<=h;i++){
    scanf("%d",&A[i]);
  }

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



Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp>

using namespace std;
using namespace boost;
using namespace boost::algorithm;

int main() {
	int n;
	vector<long long> s = {};
	long long temp_s;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> temp_s;
		s.push_back(temp_s);	
	}

	vector<vector<long long>> dp;
	dp.assign(n, vector<long long>(n,0));

	for (int i = 0; i < n; i++) {
		dp[i][i] = s[i];
	}

	for (int i = n - 2; i >= 0; i--) {
		for (int j = i + 1; j <= n - 1; j++) {
			auto a = s[i] - dp[i + 1][j];
			auto b = s[j] - dp[i][j - 1];
			if (a > b) {
				dp[i][j] = a;
			} else {
				dp[i][j] = b;
			}
		}
	}

	cout << dp[0][n - 1];

	return 0;
}


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

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

  if (A + B > C + D ) {
    cout << "Left" << endl;
  }
  else if(A + B == C + D ){
    cout << "Balanced" << endl;
  }
  else if(A + B < C + D ){
    cout << "Right" << endl;
  }
} 

Measured memory_bytes: 256
--prewritten code: https://github.com/antma/algo
{-# LANGUAGE BangPatterns #-}
{-# Options_GHC -O2 #-}
import Data.ByteString.Builder
import Data.Monoid
import System.IO
import qualified Data.ByteString.Char8 as C
import Data.Char

ru, ri :: C.ByteString -> Int

ru = C.foldl' (\a c -> a * 10 - 48 + ord c) 0
ri s
  | C.head s == '-' = negate $ ru $ C.tail s
  | otherwise = ru s

solve :: [Int] -> Int
solve (a:b:t:_) = b * div t a

main :: IO ()
main = print . solve . map ri . C.words =<< C.getContents


Measured memory_bytes: 380
#include <stdio.h>

int main(){
  char campany_A = 'A';
  char campany_B = 'B';
  
  char stations[4];
  int isBusMoving = 0;
  int isStationA, isStationB;
  isStationA = isStationB = 0;
  
  scanf("%s", stations);
  for(int i = 0; i < sizeof(stations); i++){
    if(stations[i] == campany_A)
      isStationA = 1;
    else if(stations[i] == campany_B)
      isStationB = 1;
  }
  
  if(isStationA && isStationB)
    puts("Yes");
  else
    puts("No");
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        if (a < b) {
            if (b < c) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }else{
             System.out.println("No");
        }
    }
}

Measured memory_bytes: 26260
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 2e5;
int n, m, k;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m >> k;
  setF(n);
  ll ans = 0;
  FOR(i, 0, k+1) ans += comb(n-1, i)*modPow(m-1, n-1-i)%MOD;
  cout << ans%MOD*m%MOD << endl;
}

Measured memory_bytes: 6284
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s; cin >> s; 
	int c = 0;
	for(int i = 0; i < s.size(); i ++)
		if(s[i] == 'x')
		    c ++;
	if(c <= 7) puts("YES");
	else puts("NO");
	return 0;
}

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

int main() {
  int N;
  string S;
  bool flag;
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> S;
    if(S == "Y") {
      flag = true;
      break;
    } else {
      flag = false;
      continue;
    }
  }
  if(flag == true) {
    cout << "Four" << endl;
  } else if(flag == false) {
    cout << "Three" << endl;
  }
  return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

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

typedef struct node *NodePointer;

NodePointer root;
NodePointer nil;

NodePointer treeMini(NodePointer x){
  while(x->left!=nil)x=x->left;
  return x;
}

NodePointer find(NodePointer u,int k){
  while(u!=nil&&k!=u->key){
    if(k<u->key)u=u->left;
    else u=u->right;
  }
  return u;
}

NodePointer treeSuccessor(NodePointer x){
  NodePointer y;
  if(x->right!=nil)return treeMini(x->right);
  y=x->parent;
  while(y!=nil&&x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void delete(NodePointer z){
  NodePointer y,x;
  if(z->left==nil||z->right==nil)y=z;
  else y=treeSuccessor(z);

  if(y->left!=nil)x=y->left;
  else x=y->right;

  if(x!=nil)x->parent=y->parent;

  if(y->parent==nil)root=x;
  else{
    if(y==y->parent->left)y->parent->left=x;
    else y->parent->right=x;			    
  }

  if(y!=z)z->key=y->key;

  free(y);
}

void insert(int k){
  NodePointer y,x,z;
  y=nil;
  x=root;
  z=(NodePointer)malloc(sizeof(struct node));
  z->key=k;
  z->left=nil;
  z->right=nil;

  while(x!=nil){
    y=x;
    if(z->key < x->key)x=x->left;
    else x=x->right;
  }
  z->parent=y;
  
  if(y==nil)root=z;
  else{
    if(z->key < y->key)y->left=z;
    else y->right=z;
  }
}

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

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

int main(){
int n,i,x;
  char c[7];
  NodePointer t;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",c);
    if(strcmp(c,"find")==0){
      scanf("%d",&x);
      t=find(root,x);
      if(t!=nil)printf("yes\n");
      else printf("no\n");
    }
    else if(strcmp(c,"insert")==0){
      scanf("%d",&x);
      insert(x);
    }
    else if(strcmp(c,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(strcmp(c,"delete")==0){
      scanf("%d",&x);
      delete(find(root,x));
    }
  }
  return 0;
}



Measured memory_bytes: 20456
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int a,b,c;
ll k;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>a>>b>>c>>k;
    if (k%2) cout<<b-a<<endl;
    else cout<<a-b;
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int h,w,d;
  cin >> h >> w >> d;
  if(d%2){
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if((i+j)%2){
          cout << "R" << flush;
        }else{
          cout << "B" << flush;
        }
      }
      cout << endl;
    }
  }else{
    char C[4]={'R','G','B','Y'};
    vector<char> field(w);
    bool zouka=true;
    int haba=0;
    char tmp;
    for(int i=0;i<h;i++){
      for(int j=0;j<=(w+d/2-1)/(d/2);j++){
        if(j%2){
          for(int k=-haba;k<haba;k++){
            // cout << j+k << endl;
            if(0<=j*(d/2)+k&&j*(d/2)+k<w) field[j*(d/2)+k]=C[j%4];
          }
        }else{
          for(int k=haba-d/2;k<d/2-haba;k++){
            // cout << j+k << endl;
            if(0<=j*(d/2)+k&&j*(d/2)+k<w) field[j*(d/2)+k]=C[j%4];
          }
        }
      }
      if(zouka){
        haba++;
        if(haba==d/2){
          zouka=false;
          tmp=C[2];
          C[2]=C[0];
          C[0]=tmp;
        }
      }else{
        haba--;
        if(haba==0){
          zouka=true;
          tmp=C[1];
          C[1]=C[3];
          C[3]=tmp;
        }
      }
      for(int j=0;j<w;j++){
        cout << field[j];
      }
      cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#ifdef TEST
#define getchar_unlocked _getchar_nolock
#define putchar_unlocked _putchar_nolock
#endif
#define ins insert
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define pp pop
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define g0(a) get<0>(a)
#define g1(a) get<1>(a)
#define g2(a) get<2>(a)
#define g3(a) get<3>(a)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef double db;
typedef long double ld;
typedef long long ll;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tree<pair<int, int>, null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<pair<int, int>, null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int N, X, T;
	cin >> N >> X >> T;
	cout << (N + X - 1) / X * T << '\n';
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long h,n;
    cin>>h>>n;
    long long a[n];
    for(long long i=0;i<n;i++){
        long long k;
        cin>>k;
        h=h-k;
    }
    if(h<=0)
    cout<<"Yes";
    else
    cout<<"No";

    return 0;
}


Measured memory_bytes: 256
//Created by Aminul on 3/28/2020.

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        pw.println(solve(in.nextInt()));
        pw.close();
    }

    static long solve(long n) {
        long res = 1000 * (n / 500);
        n %= 500;
        res += 5 * (n / 5);
        return res;
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}

Measured memory_bytes: 22868
#include<stdio.h>
int main(void)
{
	int pm,pe,pj,i,n,g3,g2;
	scanf("%d",&n);
	while(n!=0) {
		for(i=1;i<=n;i++) {
			scanf("%d %d %d",&pm,&pe,&pj);
			g3=(pm+pe+pj)/3;
			g2=(pm+pe)/2;
			if(pm==100 || pe==100 || pj==100) {
				printf("A\n");
			}
			else if(g2>=90) {
				printf("A\n");
			}
			else if(g3>=80) {
				printf("A\n");
			}
			else if(g3>=70) {
				printf("B\n");
			}
			else if(g3>=50 && (pm>=80 || pe>=80)) {
				printf("B\n");
			}
			else {
				printf("C\n");
			}
		}
	scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <cmath>
#include <stdio.h>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    double ans = 0;;

    for (int i = 1; i <= n; i++) {
        double p = 1 / double(n);
        int t = 0;
        while(i * pow(2, t) < k) {
            p *= 0.5;
            t++;
        }
        ans += p;
    }
    printf("%.12f\n", ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<int,int> mp;
int a[200010],js[200010];
void insert(int w)
{
	js[w]++;
	if (w-js[w]+1>0) mp[w-js[w]+1]++;
}
void erase(int w)
{
	if (w-js[w]+1>0)
	{
		mp[w-js[w]+1]--;
		if (mp[w-js[w]+1]==0) mp.erase(w-js[w]+1);
	}
	js[w]--;
}
int main()
{
	int n,q;scanf("%d%d",&n,&q);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		insert(a[i]);
	}
	while (q--)
	{
		int s,w;scanf("%d%d",&s,&w);
		erase(a[s]);a[s]=w;insert(a[s]);
		printf("%d\n",n-mp.size());
	}
}

Measured memory_bytes: 13568
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long int MOD = 1000000007;
const int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;

vector<vector<int>>matrix_product(vector<vector<int>>v, vector<vector<int>>w) {
	vector<vector<int>>ret(v.size(), vector<int>(w.front().size()));
	for (int i = 0; i < ret.size(); i++) {
		for (int j = 0; j < ret[i].size(); j++) {
			for (int k = 0; k < w.size(); k++) {
				ret[i][j] = ((long long int)v[i][k] * w[k][j] + ret[i][j]) % MOD;
			}
		}
	}
	return ret;
}

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

	cin >> N >> K;
	vector<vector<int>>v(N, vector<int>(N));
	for (auto &i : v) {
		for (auto &j : i)cin >> j;
	}
	vector<vector<int>>ans(N, vector<int>(1, 1));
	for (int i = 0; i < 62; i++) {
		if ((K >> i) & 1)ans = matrix_product(v, ans);
		v = matrix_product(v, v);
	}
	long long int ret = 0;
	for (auto i : ans)for (auto j : i)ret += j;
	ret %= MOD;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
import sys

def warshall_floyd():
    for k in range(10):
        for i in range(10):
            for j in range(10):
                C[i][j] = min(C[i][j], C[i][k] + C[k][j])

H, W = map(int, input().split())
inf = float("inf")
C = [list(map(int, sys.stdin.readline().rsplit())) for _ in range(10)]
A = [list(map(int, sys.stdin.readline().rsplit())) for _ in range(H)]
warshall_floyd()
res = 0
for row in A:
    for col in row:
        if col != -1:
            res += C[col][1]

print(res)


Measured memory_bytes: 9420
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e3 + 5, mod = 1e9 + 7, inf = 0x3f3f3f3f;
ll dp[maxn][maxn];
int a[maxn], b[maxn];
ll ps[maxn], pt[maxn];;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    string s;
    cin >> s;
    for (int i = 1; i < s.size(); ++i){
        if (s[i] == s[i - 1]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

const int IINF = 2002002002;
const ll LINF = 9009009009009009009LL;

//===


ll dp[100][2];


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

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

	int m = 0;
	ll K_tmp = K;
	while (K_tmp) {
		K_tmp >>= 1;
		++m;
	}

	Vi nums(m);
	for (int i = 0; i < m; ++i) {
		for (int j = 0; j < N; ++j) {
			if (A[j] & (1LL << i)) ++nums[i];
		}
	}

	Vl diff(m);
	for (int i = 0; i < m; ++i) {
		diff[i] = (N - 2 * nums[i]) * (1LL << i);
	}
	
	// 桁DP
	for (int i = 0; i <= m; i++) {
		for (int j = 0; j < 2; j++) {
			dp[i][j] = -LINF;
		}
	}
	dp[0][0] = 0;
	for (int i = 0; i < m; ++i) {
		ll mask = 1LL << (m - 1 - i);

		if (dp[i][0] != -LINF) {
			if (K & mask) dp[i + 1][0] = max(dp[i + 1][0], dp[i][0] + diff[m - 1 - i]);
			else dp[i + 1][0] = max(dp[i + 1][0], dp[i][0]);
		}

		if (dp[i][0] != -LINF) {
			if (K & mask) dp[i + 1][1] = max(dp[i + 1][1], dp[i][0]);
		}

		if (dp[i][1] != -LINF) {
			dp[i + 1][1] = max(dp[i + 1][1], dp[i][1] + max(diff[m - 1 - i], 0LL));
		}
	}

	cout << sum + max(dp[m][0], dp[m][1]) << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int MAXN=2010;
int n,m,x,y,eg,len,pa,pb,hd[2][MAXN],ver[2][MAXN*2],nx[2][MAXN*2],vis[MAXN],dis[MAXN],las[MAXN];
void add_edge (int t,int x,int y) {
	ver[t][++eg]=y;
	nx[t][eg]=hd[t][x];
	hd[t][x]=eg;
	return;
}
void dij (int x) {
	memset(dis,0x3f,sizeof(dis));
	memset(vis,0,sizeof(vis));
	memset(las,0,sizeof(las));
	dis[x]=0,vis[x]=1;
	queue <int> q;
	q.push(x);
	while (!q.empty()) {
		int a=q.front();
		q.pop();
		for (int i=hd[0][a];i;i=nx[0][i]) {
			if (!vis[ver[0][i]]) {
				dis[ver[0][i]]=dis[a]+1,las[ver[0][i]]=a;
				vis[ver[0][i]]=1;
				q.push(ver[0][i]);
			}
		}
	}
	return;
}
int main () {
	scanf("%d%d",&n,&m);
	len=n+1;
	for (int i=1;i<=m;i++) {
		scanf("%d%d",&x,&y);
		add_edge(0,x,y),add_edge(1,y,x);
	}
	for (int i=1;i<=n;i++) {
		dij(i);
		for (int j=hd[1][i];j;j=nx[1][j]) {
			if (dis[ver[1][j]]+1<len) {
				len=dis[ver[1][j]]+1,pa=i,pb=ver[1][j];
			}
		}
	}
	if (len==n+1) {
		printf("-1\n");
	}
	else {
		dij(pa);
		printf("%d\n%d\n",len,pa);
		while (pb!=pa) {
			printf("%d\n",pb);
			pb=las[pb];
		}
	}
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  while(1){
    int x;
    cin>>x;
    int co=0,a=0;
    if(x==0) break;
    for(int i=x+1;i<=2*x;i++){
      a=0;
      for(int j=2;j<=sqrt(i)+1;j++){
	if(i==1) {
	  a=1;
	  break;
	}
	
	if(i==2){
	  break;
	}
	if(i%j==0){
	  a=1;
	  break;
	}
      }
      if(a==0) co++;
    }
    cout<<co<<endl;
  }
  return 0;
}



Measured memory_bytes: 3092
input_str = input("")
input_elms = input_str.split(" ")
for login_cnt in range(1, int(input_elms[2]) + 1):
    if int(input_elms[0]) * login_cnt + int(input_elms[1]) * int(login_cnt/7) >= int(input_elms[2]):
        print(login_cnt)
        break


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

inline LL _lcm(LL a, LL b) {
    return a*b/__gcd(a,b);
}

void run_case() {
    int n; LL m;
    cin >> n >> m;
    vector<LL> a(n);
    for(auto &x: a) cin >> x, x >>= 1;
    LL lcm = a[0];
    for(int i = 1; i < n; ++i)
        lcm = _lcm(lcm, a[i]);
    for(int i = 0; i < n; ++i)
        if((lcm/a[i]) % 2 == 0) {
            cout << 0;
            return;
        }
    cout << (m/lcm+1)/2;
}


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(9);
    //int t; cin >> t;
    //while(t--)
    run_case();
    cout.flush();
    return 0;
}

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

int main() {
  string s;
  cin>>s;
  int i = 0;
  int j= s.length() - 1;
  int cnt = 0;
  while (i < j) {
    if (s[i] == s[j]) {
      ++i;
      --j;
      continue;
    }
    if (s[i] == 'x') {
      ++cnt;
      ++i;
    } else if (s[j] == 'x') {
      ++cnt;
      --j;
    } else {
      cout<<-1<<endl;
      return 0;
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    string s;
    cin >> s;
    string ans = "Yes";
    for (int i = 0; i < s.length(); i++)
    {
        if (i % 2 == 0 && s[i] == 'L')
        {
            ans = "No";
            break;
        }
        if (i % 2 == 1 && s[i] == 'R')
        {
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
	input! {
		n: i32,
		d: i64,
	}
	
	let mut ans = 0;
	
	for i in 0..n {
		input! {
			x: i64,
			y: i64,
		}
		if x * x + y * y <= d * d {
			ans += 1;
		}
	}
	
	println!("{}", ans);
}

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

int main()
{
    char x,y;
    int b,c,d,i;
    char a[6]= {'A','B','C','D','E','F'};
    scanf("%c %c",&x,&y);
    for(i=0; i<6; i++)
    {
        if(a[i]==x)
            b=i;
        if(a[i]==y)
            c=i;
    }
    d=b-c;
    if(d>0)
        printf(">\n");
    else if(d==0)
        printf("=\n");
    else
        printf("<\n");
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	long N;
	Map<Long, Integer> origins;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		N = Long.parseLong(in.readLine());
		long n = N;
		this.origins = new HashMap<>();
		long divVal = 2;
		while (Math.sqrt(N) + 1 > divVal) {
			if (n % divVal == 0) {
				if (!origins.containsKey(divVal)) {
					origins.put(divVal, 1);
				} else {
					origins.put(divVal, origins.get(divVal) + 1);
				}
				n /= divVal;
			} else {
				++divVal;
			}
		}
		if (n > 1) {
			if (!origins.containsKey(n)) {
				origins.put(divVal, 1);
			} else {
				origins.put(divVal, origins.get(divVal) + 1);
			}
		}
	}

	int count(int num) {
		int result = 0;
		int base = 1;
		while (num > base * 2) {
			++result;
			num -= base;
			base++;
		}
		++result;
		return result;
	}

	void calc() {
		int result = 0;
		for (Long key : origins.keySet()) {
			int count = origins.get(key);
			int c = count(count);
			result += c;
		}
		System.out.println(result);
	}

	void showResult() {
	}
}

Measured memory_bytes: 32752