akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main()
{
	int i,j,k,m,n,l;
	int a[100][100] = {0};
	int b[100][100] = {0};
	long c;


	scanf("%d %d %d",&n,&m,&l);
	
	for (i = 0;i < n;i++){
    	for (j = 0;j < m;j++){
			scanf("%d",&a[i][j]);
		}
	}
	for (i = 0;i < m;i++){
    	for (j = 0;j < l;j++){
			scanf("%d",&b[i][j]);
		}
	}
	       
	for (i = 0;i < n;i++){
    	for (j = 0;j < l;j++){
			c = 0;
			for (k = 0;k < m;k++){
         	   c += a[i][k] * b[k][j]; 
			   
        }
		printf("%ld",c);
		if(j <l-1){
			putchar(' ');
			
		}
		else{
			putchar('\n');
		}
		
	}
}
return 0;
}


Measured memory_bytes: 2108
#include<iostream>
using namespace std;
int a[200010],b[200010];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<n;i++)
	{
		b[a[i]]++;
	}
	for(int i=1;i<=n;i++)
	{
		cout<<b[i]<<endl;
	}
    return 0;
}


Measured memory_bytes: 5152
import sys
import math


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


def main():
    A, B, C, D = map(int, input().split())
    T = math.ceil(C / B)
    Aoki = math.ceil(A / D)

    if Aoki + 1 <= T:
        print("No")
    else:
        print("Yes")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9052
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();
        int cnt = 0;
        for(int i = 0; i <= k; i++){
            for(int h = 0; h <= k; h++){
                    if(s - i - h <= k && s >= i + h){
                        cnt++;
                    }
                }
            }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define pb push_back
#define tam 100000
#define se second
#define fi first
#define pitem item*
#define forr(i,p,n) for(int i=p;i<n;i++)
using namespace std;
typedef long long ll;
const ll MOD=1000000007 ;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
typedef pair<int,int> ii;
typedef vector<vector<int> > vvi;
typedef  double lld;
ll N,M;
bool f(ll X)
{
    ll resta=max(0LL,X-N);
    if (M-(resta)*2>=2*X)
        return 1;
    return 0;
}
int main()
{
    
    cin>>N>>M;
    ll iz=0,der=1,mid;
    while(f(der)==1)
        der*=2;
    while(iz+1<der)
    {
        mid=(iz+der)/2;
        if (f(mid)==1)
            iz=mid;
        else
            der=mid;
    }
    cout<<iz<<endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N,M;
    N = sc.nextInt();
    M = sc.nextInt();
    int X[] = new int[M];
    for(int i=0; i<M; i++) X[i] = sc.nextInt();
    Arrays.sort(X);
    int interval[] = new int[M-1];
    for(int i=0; i<M-1; i++){
      interval[i] = X[i+1] - X[i];
    }
    Arrays.sort(interval);
    int ans = 0;
    for(int i=0; i<M-N; i++){
      ans += interval[i];
    }
    System.out.println(ans);
                               
  }
}

Measured memory_bytes: 50132
//Graph
//2019-01-23
//Ebitani Akira

#include <stdio.h>
#include <stdlib.h>

#define N 100
#define AN 128

int main (){
  int i, j;
  int array[128][128];
  int n;
  int u, k, v;

  scanf("%d", &n);
  if(n > N || n < 1){
    printf("頂点の数が適当ではありません。\n");
    exit(1);
  }

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

  for(i = 1 ; i < n+1 ; i++){
    for(j = 1 ; j < n+1 ; j++){
      if(array[i][j] == 1)
	printf("1");
      else if(array[i][j] == 0)
	printf("0");
      if(j != n)
	printf(" ");
    }
    printf("\n");
  }
  return 0;
}
	
      
      



Measured memory_bytes: 2052
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define me(a,b) memset(a,b,sizeof(a))
#define INIT() std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>P;
const int MAX_N=5000+5;
const int MAX_M=100000+5;
const int INF=0x7fffffff;
const int inf=1000000000;
const double EPS=1e-6;
const ull base=123;
const ll mod=1e9+7;
const double pi=4*atan(1.0);
ll r,c,k;
ll mp[MAX_N][MAX_N];
ll dp[MAX_N][MAX_N][4];
int main()
{
    cin>>r>>c>>k;
    int i;
    for(i=1;i<=k;i++)
    {
        ll x,y,z;
        scanf("%lld%lld%lld",&x,&y,&z);
        mp[x][y]=z;
    }
    int j;
    for(i=1;i<=r;i++)
    {
        for(j=1;j<=c;j++)
        {
            if(!mp[i][j])
            {
                int k;
                for(k=0;k<=3;k++)
                {
                    dp[i][j][0]=max(dp[i][j][0],dp[i-1][j][k]);
                    dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k]);
                }
            }
            else
            {
                int k;
               
                for(k=1;k<=3;k++)
                {
                    dp[i][j][k]=max(dp[i][j][k],max(dp[i][j-1][k],dp[i][j-1][k-1]+mp[i][j]));
                }
                for(k=0;k<=3;k++)
                {
                    dp[i][j][0]=max(dp[i][j][0],max(dp[i-1][j][k],dp[i][j-1][0]));
                    //dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k]);
                    dp[i][j][1]=max(dp[i][j][1],dp[i-1][j][k]+mp[i][j]);
                }
            }
        }
    }
    ll ans=0;
    for(i=0;i<=3;i++)
    {
        ans=max(ans,dp[r][c][i]);
    }
    cout<<ans<<endl;
   // system("pause");
    
}

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

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define xlr8                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(c)              (c).begin(),(c).end()

int main()
{
    string s;cin>>s;
    int bad=0;
    for(int i=0;i<3;i++)
    {
        if(s[i]==s[i+1])
            bad=1;
    }
    bad==1 ? cout<<"Bad" : cout<<"Good";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
int n;
char s[10100],t[10100];
vector<pair<int,int> > S,T;
int main(){
	read(n);
	cin>>s+1;
	cin>>t+1;
	if(n==1){
		cout<<(s[1]!=t[1])<<'\n';
		return 0;
	}
	if(n==2){
		cout<<(s[1]!=t[1])+(s[2]!=t[2])<<'\n';
		return 0;
	}
	for(int i=1;i<n;i++)
		if(s[i]!=s[i+1]) S.emplace_back(i,s[i]);
	for(int i=1;i<n;i++)
		if(t[i]!=t[i+1]) T.emplace_back(i,t[i]);
	int ans=1e9;
	for(int i=0;i<T.size();i++)
		if(S[0].second==T[i].second){
			int now=0;
			for(int j=0;j<i;j++) now+=T[j].first;
			for(int j=i;j<T.size();j++)
				now+=abs(T[j].first-(j-i<S.size()?S[j-i].first:n));
			for(int j=T.size()-i;j<S.size();j++)
				now+=n-S[j].first;
			ans=min(ans,now);
		}
	swap(S,T);
	for(int i=0;i<T.size();i++)
		if(S[0].second==T[i].second){
			int now=0;
			for(int j=0;j<i;j++) now+=T[j].first;
			for(int j=i;j<T.size();j++)
				now+=abs(T[j].first-(j-i<S.size()?S[j-i].first:n));
			for(int j=T.size()-i;j<S.size();j++)
				now+=n-S[j].first;
			ans=min(ans,now);
		}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const long long INFL = 2e18;
const int MOD = 1000000007;
int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0;i < n;i++)cin >> a[i];
	cout << *max_element(a.begin(),a.end()) - *min_element(a.begin(),a.end()) << endl;
}


Measured memory_bytes: 3636
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Int
import qualified Data.IntMap                 as IM
import           Data.List
import qualified Data.Map                    as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

main = do
    [n, k, c] <- readInt
    s <- f . zip [1..] <$> getLine
    let ansf = take k $ solvef c s
    let ansb = reverse . take k $ solveb c (reverse s)
    mapM_ print (check ansf ansb)
 
 
f :: [(Int, Char)] -> [Int]
f [] = []
f ((i, b) : xs) | b == 'o' = i : f xs
                | otherwise = f xs
 
solvef :: Int -> [Int] -> [Int]
solvef _ [] = []
solvef c (x : xs) = x : solvef c (dropWhile (x + c >= ) xs)
 
solveb :: Int -> [Int] -> [Int]
solveb _ [] = []
solveb c (x : xs) = x : solveb c (dropWhile (x - c <= ) xs)
 
check :: [Int] -> [Int] -> [Int]
check [] _ = []
check _ [] = []
check (x : xs) (y : ys) | x == y = x : check xs ys
                        | otherwise = check xs ys

Measured memory_bytes: 38908
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000


int main(){

	int H,W;
	cin>>H>>W;
	
	vector<string> S(H);
	for(int i=0;i<H;i++){
		cin>>S[i];
	}
	
	long long ans = 0;
	
	vector<vector<bool>> visited(H,vector<bool>(W,false));
	
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(visited[i][j])continue;
			queue<pair<int,int>> Q;
			Q.emplace(i,j);
			long long black = 0,white = 0;
			
			if(S[i][j]=='#')black++;
			else white++;
			
			visited[i][j]=true;
			
			while(Q.size()!=0){
				int y = Q.front().first;
				int x = Q.front().second;
				Q.pop();
				
				for(int k=0;k<4;k++){
					int yy = y;
					int xx = x;
					if(k==0)yy++;
					if(k==1)yy--;
					if(k==2)xx++;
					if(k==3)xx--;
					if(yy<0||xx<0||yy>=H||xx>=W)continue;
					if(S[y][x]==S[yy][xx])continue;
					if(visited[yy][xx])continue;
					
					if(S[yy][xx]=='#')black++;
					else white++;
					visited[yy][xx]=true;
					Q.emplace(yy,xx);
				}
			}
			
			ans += black*white;
			
			
		}
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}

Measured memory_bytes: 512
a=input()
t=-1
flag="False"
for i in range(len(a)-1):
  if a[i]==a[i+1]:
    flag="True1"
    t=i
    break
  if i!=len(a)-2:
    if a[i]==a[i+2]:
      flag="True2"
      t=i
      break
if flag=="False":
  print("{} {}".format(-1,-1))
elif flag=="True1":
  print("{} {}".format(t+1,t+2))
else:
  print("{} {}".format(t+1,t+3))

Measured memory_bytes: 3188
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::min;
using std::max;
using std::fill;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) <= (n); i++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
#define int long long

const long long MOD = 1e9 + 7;

const long long inf = 1e18;
const long long infsmart = 1e12;

ll n, m;
ll a[701][701];
vector<int> graph[701];
ll color[701];
ll ans = 0;
ll r, l;

void dfs(int v, int c)
{
    color[v] = c;

    if (c == 1) r++;
    else l++;

    for (auto u : graph[v])
    {
        if (color[u] == color[v])
        {
            cout << -1;
            exit(0);
        }
        if (color[u] == 0)
        {
            dfs(u, 3 - c);
        }
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int v, u;
        cin >> v >> u;
        a[v][u] = 1;
        a[u][v] = 1;
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            if (i == j) continue;
            if (!a[i][j])
            {
                graph[i].push_back(j);
            }
        }
    }
    vector<pii> v;
    for (int i = 1; i <= n; i++)
    {
        if (color[i] == 0)
        {
            int l0 = l, r0 = r;
            dfs(i, 1);
            v.push_back({l - l0, r - r0});
        }
    }
    vector<int> dp(800);
    dp[0] = 1;
    for (int i = 0; i < v.size(); i++)
    {
        vector<int> dp2(800);
        for (int j = 0; j <= n; j++)
        {
            if (j - v[i].fi >= 0 && dp[j - v[i].fi]) dp2[j] = 1;
            if (j - v[i].se >= 0 && dp[j - v[i].se]) dp2[j] = 1;
        }
        dp = dp2;
    }
    ans = 1e9;
    for (int i = 0; i <= n; i++)
    {
        if (dp[i])
        {
            ans = min(ans, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 5888
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <tuple>
#include <numeric>

using namespace std;

typedef long long ll;

int main(void){
    vector<vector<char> > c(3,vector<char> (3));
    for(ll i = 0;i < 3; i++){
        for(ll j = 0;j < 3; j++){
            cin >> c[i][j];
        }
    }
    for(ll i = 0;i < 3; i++){
        for(ll j = 0;j < 3; j++){
            if(i == j){
                cout << c[i][j];
            }
        }
    }
}


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

    ll n;
    cin>>n;
    ll arr[n+5]={0};
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    ll x=n/2;
    ll diff=arr[x]-arr[x-1];
    cout<<diff<<endl;


}



Measured memory_bytes: 4416
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	cout << max(0, c-a+b) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;
  string s, r, y;
  cin>>n>>a>>m;
  cout<<min(n*a,m);
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
   //cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main(){
   int a,b,c;
   vector<int>vec(3);
   for(int i=0;i<3;i++)cin>>vec[i];
   sort(vec.begin(),vec.end());
   cout<<vec[0]+vec[1]+vec[2]*10;
}


Measured memory_bytes: 256
//c++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
#include <fstream>
#include <random>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define sz(x) ((int)(x).size())

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
const ll MOD = 1000000007;
//const ll MOD = 998244353;
double EPS = 1e-10;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.9lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};


//コンビネーション
const int MAXcomb = 2000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 500010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}

ll disit(ll s, ll base = 10){
  ll res = 0;
  while(s){
    res++;
    s /= base;
  }
  return res;
}

ll K;
string S;
void solve(){
  COMinit();
  cin >> K >> S;
  ll N = S.size();
  ll ans = 0;
  rep(i, K+1){
    ans += comb(K-i+N-1, N-1) * pow_mod(25, K-i) % MOD * pow_mod(26, i) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 51108
#include <stdio.h>
int main(void){
   int a[]={1,5,10,50,100,500};
   int b[5],x=0,i;
   scanf("%d %d %d %d %d %d",&b[0],&b[1],&b[2],&b[3],&b[4],&b[5]);
   for(i=0;i<6;i++){
      x+=a[i]*b[i];
   }
   if(x>=1000)
      printf("1\n");
   else
      printf("0\n");

   return 0;
}

Measured memory_bytes: 1804
N = int( input())
S = [ input() for _ in range(N)]
ans = 0
for k in range(N):
    check = True
    for i in range(N):
        for j in range(i+1,N):
            if not S[i][(j+k)%N] == S[j][(i+k)%N]:
                check = False
                break
        if not check:
            break
    if check:
        ans += N
print(ans)


Measured memory_bytes: 43128
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;
 
    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);
 
    private void solve(Scanner sc) {
        long N = sc.nextLong();
 
        int ans = Integer.MAX_VALUE;
        for (long A = 1; A <= Math.sqrt(N); ++A) {
            if (N % A != 0) {
                continue;
            }
            long B = N / A;
            ans = Math.min(ans, F(A, B));
        }
        _out.println(ans);
    }
    private int F(long a, long b) {
        return Math.max(String.valueOf(a).length(), String.valueOf(b).length());
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();
 
        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();
 
        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

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

#define ld long double
#define ll long long int
#define ull unsigned long long int
#define vi vector<int>
#define vl vector<ll>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define repd(i, a, b) for (int i=(a);i<(b);i++)
#define rep(i, n) repd(i,0,n)
#define ALL(v) v.begin(), v.end()
#define INF 1e9

using namespace std;

/**
 * calculate GCD(greatest common divisor)
 * @param a
 * @param b
 * @return
 */
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

/**
 * change minimum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T>
inline bool changeMinimum(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * change maximum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T>
inline bool changeMaximum(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * output answer
 * @tparam T
 * @param answer
 * @return
 */
template<typename T>
T output(T answer) {
    cout << answer << endl;
    return 0;
}

/** ----from here ---------------------------------------------------------- */


// 入力
long long a[100010][3]; // a[i], b[i], c[i] をそれぞれまとめて a[i][0], a[i][1], a[i][2] にしてしまう

// DP テーブル
long long dp[100010][3];

int main() {

    int N;
    cin >> N;

    // 入力
//    long long a[100010][3]; // a[i], b[i], c[i] をそれぞれまとめて a[i][0], a[i][1], a[i][2] にしてしまう

    // DP テーブル
//    long long dp[100010][3];
    for (int i = 0; i < N; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];


    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) { continue; }
                changeMaximum(dp[i + 1][k], dp[i][j] + a[i][k]);
            }

        }
    }
    // 答え
    long long res = 0;
    for (int j = 0; j < 3; ++j) changeMaximum(res, dp[N][j]);
    cout << res << endl;


}

Measured memory_bytes: 4992
#include <iostream>
using namespace std;
int main(){
    long long x;
    cin >> x;
    long long a,b;
    a = x / 11;
    b = x % 11;
    long long res;
    res = 2 * a;
    if(1 <= b && b <= 6)cout << res + 1 << endl;
    else if(7 <= b)cout << res + 2 << endl;
    else cout << res << endl;
    return 0;
}

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

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll lcm(ll x, ll y) {
    return x / GCD(x, y) * y;//先に割り算をして掛けられる数を小さくして掛け算を行う
}
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> dp(N + 100), sdp(N + 100);
  vector<int> L(K), R(K);
ll mod = 998244353;
  for (int i = 0; i < K; i++)
  {
      cin >> L[i] >> R[i];
  }
 
  dp[1] = 1;
  sdp[1] = 1;
        for (int j = 2; j <= N; j++)
        {
            for (int i = 0; i < K; i++)
             {       
            int right = max(0, j - L[i]);
            int left = max(0, j - R[i] - 1);
            dp[j] += sdp[right] - sdp[left] + mod;
             //cout << left << " " << right << endl;
            dp[j] %= mod;
        }
        dp[j] %= mod;
        sdp[j] = sdp[j - 1] + dp[j];
        sdp[j] %= mod;
        
         
    }
   
    
    cout << dp[N] << endl;
  
 
    return 0;

}


Measured memory_bytes: 6324
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<datas,ll>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

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

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll i,N,M,L,a,b,c,Q,cnt;
  cin>>N>>M>>L;
  pmat v(N,pvec(N,datas(-1,0)));
  pmat g(N);
  rep(i,M){
    cin>>a>>b>>c;
    a--;b--;
    if(c<=L){
      g[a].pb(datas(b,c));
      g[b].pb(datas(a,c));
    }
  }
  tdata pbdata;
  rep(i,N){
    v[i][i].first=0;
    priority_queue<tdata,vector<tdata>,greater<tdata>> que;
    for(auto j:g[i]){
      pbdata=tdata(datas(0,j.second),j.first);
      que.push(pbdata);
    }
    cnt=1;
    while(cnt<N&&!que.empty()){
      auto x=que.top();que.pop();
      if(v[i][x.second].first!=-1)continue;
      cnt++;
      v[i][x.second]=x.first;
      for(auto j:g[x.second]){
        Q=j.second+x.first.second;
        if(Q<=L){
          pbdata=tdata(datas(x.first.first,Q),j.first);
          que.push(pbdata);
        }else{
          pbdata=tdata(datas(x.first.first+1,j.second),j.first);
          que.push(pbdata);
        }
      }
    }
  }
  cin>>Q;
  while(Q--){
    cin>>a>>b;
    a--;b--;
    cout<<v[a][b].first<<endl;
  }
  return 0;
}

Measured memory_bytes: 10460
def searchPrime(n):
    i = 2
    p_list = []
    while i * i <= n:
        cnt = 0
        while n % i == 0:
            cnt += 1
            n = n // i
        if cnt != 0:
            p_list.append([i, cnt])
        i += 1
    if n != 1:
        p_list.append([n, 1])
    return p_list

n = int(input())
p_list = searchPrime(n)

ans = 0
for p in p_list:
    i = 1
    while p[1] > 0:
        p[1] = p[1] - i
        if p[1] >= 0:
            ans += 1
        i += 1
print(ans)

Measured memory_bytes: 9204
import math
n = int(input())
def divisor(x):
    div_list = []
    for div in range(1, int(math.sqrt(x)) + 1):
        if x % div == 0:
            if  x // div != div:
                div_list.append(div)
                div_list.append(int(x // div))
            else:
                div_list.append(div)
    return sorted(div_list)

ans = 0
for i in range(1, n + 1):
    if i % 2 == 0:
        continue
    if len(divisor(i))  == 8:
        ans += 1

print(ans)

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();
		String a = sc.nextLine();
		
		String[] tmp = a.split(" ");
		
		List<Integer> as = new ArrayList<>();
		for(int k = 0; k<tmp.length; k++) {
			as.add(Integer.parseInt(tmp[k]));
		}
		
		int sum = 0;
		for(int i : as) {
			while(true) {
				if(i%2 == 0) {
					i = i/2;
					sum++;
				}
				else
					break;
			}
		}
		System.out.println(sum);
	}
}

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

int main() {
    int n; cin >> n;
    vector<pair<int, int>> a(n); 
    REP(i, n) {
        cin >> a[i].first; 
        --a[i].first;
        a[i].second = INF;
    }
    a[0].second = 0;

    int cur = 0; bool cont = true;
    while(cont) {
        int dist = a[cur].second;
        cur = a[cur].first;
        if (a[cur].second != INF)
            cont = false;
        else
            a[cur].second = dist + 1;
    }

    if (a[1].second == INF)
        cout << -1 << endl;
    else   
        cout << a[1].second << endl;

    return 0;
}

Measured memory_bytes: 1024
// Author: Gaurang_Kothiya

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  

#define data_set(type) tree<type,null_type,less<type>,rb_tree_tag,tree_order_statistics_node_update>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define ld long double
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(int i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define ook(num) order_of_key(num)
#define fbo(num) find_by_order(num)
#define gcd(a,b) __gcd(a,b)
#define bits(n) __builtin_popcountll(n)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846

const int inf= 1e9 +1;
const int inf64= 1e18 -1;
const int MOD= 1e9 +7;



void Solve()
{
	string s;
	cin>>s;
	int ans=0,cur=0;
	fe(x,s)
	{
		if(x=='R') cur++;
		else
		{
			ans=max(ans,cur);
			cur=0;	
		}	
	}	
	ans=max(ans,cur);
	cout<<ans;
}
 
signed main() 
{
	speed		

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);	

	int q=1;
	//cin>>q;
	
	while(q--)
	Solve();
		
	return 0;
} 

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

using namespace std;

typedef long long int li;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

vi par;

li root(li a)
{
    while(a!=par[a])
    {
        par[a]=par[par[a]];
        a=par[a];
    }

    return a;
}

void unio(li a,li b)
{
    par[root(a)]=root(b);
}



    
int main()
{    
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li n,m;

    cin>>n>>m;

    li p[m];

    vector<string> s(m);

    vi ac(n+1),wa(n+1);

    for(li i=0;i<m;i++)
    {
        cin>>p[i]>>s[i];

        if(ac[p[i]])
            continue;

        if(s[i]=="WA" && ac[p[i]]==0)
        {
            wa[p[i]]++;
        }
        else if(s[i]=="AC")
        {
            ac[p[i]]=1;
        }
    }

    li ans1=0,ans2=0;

    f(i,1,n)
    {
        ans1+=ac[i];

        if(ac[i])
            ans2+=wa[i];
    }

    cout<<ans1<<" "<<ans2;

    return 0;
}

Measured memory_bytes: 8064
#include <algorithm>
#include <cstdio>
#include <string>
#include <vector>

using namespace std;

constexpr int kMaxC = 1000000000;

struct Edge
{
    int u, v, c;
};

struct Node
{
    int i, d;
    char color;
    vector<Edge*> edges;
};

bool operator<(const Node& u, const Node& v)
{
    if (u.d != v.d) return u.d < v.d;
    if (u.i != v.i) return u.i < v.i;
    return false;
}

int main()
{
    int n, m; scanf("%d%d", &n, &m);
    vector<Node> nodes(n);
    for (int i = 0; i < n; i++) {
        int d; scanf("%d", &d);
        nodes[i] = {i, d, '?', {}};
    }
    vector<Edge> edges(m);
    for (int i = 0; i < m; i++) {
        int u, v; scanf("%d%d", &u, &v);
        edges[i] = {--u, --v, kMaxC};
        nodes[u].edges.push_back(&edges[i]);
        nodes[v].edges.push_back(&edges[i]);
    }

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

    vector<Node*> sedon(n);
    for (int i = 0; i < n; i++)
        sedon[nodes[i].i] = &nodes[i];
    
    for (Node& v : nodes) {
        if (v.color != '?') continue;

        for (Edge* e : v.edges) {
            int u_i = (e->u != v.i) ? e->u : e->v;
            Node& u = *sedon[u_i];
            if (u.d == v.d || u.color != '?') {
                v.color = (u.color == 'B') ? 'W' : 'B';
                u.color = (v.color == 'B') ? 'W' : 'B';
                e->c = v.d;
                break;
            }
        }
        if (v.color == '?') {
            puts("-1");
            return 0;
        }
    }

    for (const Node* v : sedon)
        putchar(v->color);
    putchar('\n');
    for (const Edge& e : edges)
        printf("%d\n", e.c);

    return 0;
}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  ll n;
  cin >>n;
  ll d[n];
  for(ll i=0;i<n;i++) cin >>d[i];
  sort(d,d+n);
  cout <<d[n/2]-d[n/2-1]<<endl;
  }


Measured memory_bytes: 1024
/*
 *  I wish I could travel by the road that crosses baby's mind,
 *  and out beyond all bounds;
 *  Where messengers run errands for no cause
 *  between the kingdoms of kings of no history;
 *  Where Reason makes kites of her laws and flies them,
 *  and Truth sets Fact free from its fetters.
 *                                           Rabindranath Tagore
 */

#include <bits/stdc++.h>
using namespace std;

#ifndef ORZ_EVERYBODY_BUT_ME
#define ORZ_EVERYBODY_BUT_ME
#endif

#ifndef SOCIALISM
#define SOCIALISM
#endif

unsigned long long operator "" _love(unsigned long long literal) {
    return literal;
}

set<string> subs;

int main() {
    assert(1731_love);

    string str;
    int k, len;
    cin >> str >> k;
    len = str.size();

    for (int i = 0; i < len; ++i) {
        string t;
        for (int j = i; j < len && j < i + k; ++j) {
            t += str[j];
            subs.insert(t);
        }
    }
    
    int i = 0;
    for (auto s: subs) if (++i == k) return cout << s << '\n', 0;

    return 0;
}


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

int di[4] = {0, -1, 0, 1};
int dj[4] = {1, 0, -1, 0};

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

typedef pair<int,int>P;

char direc[]={'U','R','D','L'};

bool used[1007][1007];

int AX,AY;

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

    int h, w; cin >> h >> w;
    vector<vector<bool> > g(h + 3, vector<bool> (w + 3, false));
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            char input; cin >> input;
            g[i][j] = (input == '#');
        }
    }

    int right = 0,p=0;     //初期位置からどれだけ右に進んだか
    while(true){
        cout << "? R" << endl;p++;
        string res; cin >> res;
        if(res == "YES") right++;
        else break;
    }

    //初期位置からの差分

    set<P>st,ans;
    int sub_i = 0, sub_j = 0;

    int x=504, y=504 , d=2;

    while(1){

        if( st.size() && x==504 && y==504 && d==2 ) break;

        st.insert(P(x,y));
       
        cout<<"? "<<direc[d]<<endl;p++;


        string res;
        cin>>res;
        if(res=="YES"){
            x += dx[d] ;
            y += dy[d] ;
            d=(d+3)%4;
        }
        else d=(d+1)%4;
    }


    for(int sx = 1; sx <= w; sx++){
        for(int sy = 1; sy <= h; sy++)if(!used[sx][sy])
        {

            ans.clear();
            
            if(!g[sy][sx] || g[sy][sx + 1]) continue;

            x = 504;
            y = 504;
            d = 2;
            int cnt=0;
            
            while(true){


                if( cnt && x==504 && y==504 && d==2 ){
                    if(st.size()!=ans.size())break;
                    int ax,ay;
                    int X=(*st.begin()).first-(*ans.begin()).first;
                    int Y=(*st.begin()).second-(*ans.begin()).second;
                    for(set<P>::iterator it=ans.begin(),it2=st.begin();it!=ans.end();it++,it2++){

                        if((*it2).first!=(*it).first+X)goto L;
                        if((*it2).second!=(*it).second+Y)goto L;

                        if((*it2).first==504&&(*it2).second==504) ax=(*it).first,ay=(*it).second;
                    }
                    
                        cout << "! " << ay - 1 -504+sy << " " << ax - 1 - right -504+sx << endl;
                        return 0;
                    
  

                        L:;
                        break;

                }

                cnt++;

                ans.insert(P(x,y));
                used[sx+x-504][sy+y-504]=1;
                
                int nx = x + dx[d];
                int ny = y + dy[d];
                
                if(g[ny + sy - 504][nx + sx- 504]){
                    x = nx ;
                    y = ny ; 
                    d=(d+3)%4; 
                }
                else{
                    d=(d+1)%4;
                }
            }       

        }
    }
    return 0;
}


Measured memory_bytes: 15432
#include<bits/stdc++.h>
using namespace std;
int n;
long long a[10010],b[10010],sa,sb,so,o[10010],oo; 
void sad(){cout<<"No"<<endl;exit(0);}
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) cin>>b[i];
	for(int i=1;i<=n;i++) sa+=a[i];
	for(int i=1;i<=n;i++) sb+=b[i];
	for(int i=1;i<=n;i++){
		o[i]=max(a[i],b[i]);
		if((a[i]%2LL)==1LL) o[i]+=(1LL-(o[i]%2LL));
		else o[i]+=(o[i]%2LL);
	}
	for(int i=1;i<=n;i++) so+=o[i];
	if(sa>sb) sad();
	oo=sb+sb-sa;
	if(so>oo) sad();
	if((so%2LL)!=(oo%2LL)) sad();
	cout<<"Yes"<<endl;
	return 0;
}



Measured memory_bytes: 512
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const int INF = (1 << 30);
const ll INFL = (1LL << 62);
const ll MOD = 1000000007;
void print() { std::cout << std::endl; }
template <typename T, typename... A>
void print(const T& first, const A&... rest) {
    cout << sizeof...(rest) << endl;
    std::cout << first;
    if (sizeof...(rest)) std::cout << " ";
    print(rest...);
}
template <typename... A>
void print(const A&... rest) {
    print(rest...);
}
template <typename A>
void print(const std::vector<A>& v) {
    std::for_each(v.begin(), v.end(), [](A x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> key;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        int s = 0;
        rep(j, b) {
            int c;
            cin >> c;
            --c;
            s |= 1 << c;
        }
        key.emplace_back(s, a);
    }

    vector<int> dp(1 << n, INF);
    dp[0] = 0;
    rep(s, 1 << n) {
        rep(i, m) {
            int t = s | key[i].first;
            int cost = dp[s] + key[i].second;
            dp[t] = min(dp[t], cost);
        }
    }
    int ans = dp.back();
    if (ans == INF) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	double d;
	cin >> d;

	double dy = floor(d);
	double dx = sqrt(d*d - dy*dy) + dy*dy;
	double m = dx + dy + (1 - abs(dx));
	printf("%.13f\n", max(m, sqrt(2)*d));
	
	return 0;
}

Measured memory_bytes: 3276
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int b,f,r,v;
		int d[][][] = new int[4][3][10];

		for(int i=1;i<=n;i++){
			b = sc.nextInt();
			f = sc.nextInt();
			r = sc.nextInt();
			v = sc.nextInt();
			d[b-1][f-1][r-1] = d[b-1][f-1][r-1]+v;
		}
		for(int i=0;i<4;i++){
			for(int j=0;j<=2;j++){
				for(int k=0;k<=9;k++){
					System.out.print(" "+d[i][j][k]);
				}
				System.out.println();
			}
			if(i!=3){
				System.out.println("####################");
			}
		}
	}
}

Measured memory_bytes: 29940
def histogram(mass, h, w):
    table = [[0]*w for i in range(h)]
    for i in range(h):
        for j in range(w):
            if mass[i][j] == '*':
                table[i][j] = 0
            else:
                table[i][j] = table[i-1][j] + 1
    return table


def get_rectangle_area(table, w):
    maxv = 0
    stack = []
    table.append(0)
    for i, rect in enumerate(table):
        if stack == []:
            stack.append((rect, i))
        elif stack[-1][0] < rect:
            stack.append((rect, i))
        elif stack[-1][0] == rect:
            pass
        elif stack[-1][0] > rect:
            while stack != [] and stack[-1][0] >= rect:
                high, pos = stack.pop()
                maxv = max(maxv, high*(i-pos))
            stack.append((rect, pos))
    return maxv

while True:
    h, w = map(int, raw_input().split())
    if h == w == 0:
        break
    mass = [raw_input() for i in range(h)]
    table = histogram(mass, h, w)
    ans = 0
    for tab in table:
        ans = max(ans, get_rectangle_area(tab, w))
    print ans

Measured memory_bytes: 8748
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);
vll res;
string s, p;
ll n, k, c;
ll dp[200020], dp2[200020];

ll rec1(ll idx) {
	if(idx >= n) return 0;
	ll &ans = dp[idx];
	if(ans != -1) return ans;
	ans = 0;
	if(s[idx] == 'o') ans = 1 + rec1(idx + c + 1);
	ans = max(ans, rec1(idx + 1));
	return ans;
}

ll rec2(ll idx) {
	if(idx >= n) return 0;
	ll &ans = dp2[idx];
	if(ans != -1) return ans;
	ans = 0;
	if(p[idx] == 'o') ans = 1 + rec2(idx + c + 1);
	ans = max(ans, rec2(idx + 1));
	return ans;
}

int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  cin >> n >> k >> c;
  cin >> s;
  reverse(all(s));
  p = s;
  reverse(all(s));
  memset(dp, -1, sizeof dp);
  memset(dp2, -1, sizeof dp2);
  rec1(0);
  rec2(0);
  for(ll i = 0; i < n; i++) {
  	if(s[i] == 'x') continue;
  	ll curr = 0;
  	ll ii = n - 1 - i;
  	curr = rec1(i + 1);
  	curr+= rec2(ii + 1);
  	// cout << rec1(i + 1) << " " << rec2(ii + 1) << endl;
  	if(curr < k)  res.pb(i + 1);
  }
  for(auto it: res) cout << it << endl;
  return 0;
} //good night.	

Measured memory_bytes: 9864
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int a, b, c;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a >> b >> c;
	cout << ((a + b >= c) ? "Yes\n" : "No\n");
	return 0;
}

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

using namespace std;

const int mxn = 2e5;

int a[mxn + 11];

int main(){
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		scanf("%d", a + i);
	}
	int cnt = 1;
	for (int i = 0; i < n; i++){
		if (a[i] == cnt)
			cnt++;
	}
	if (cnt == 1)
		puts("-1");
	else 
		printf("%d\n", n - cnt + 1);
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int x, y, s;
	
	scanf("%d%d", &x, &y);
	if(x < y){
		x ^= y;
		y ^= x;
		x ^= y;
	}
	while((s = x % y) != 0){
		x = y;
		y = s;
	}
	printf("%d\n", y);
	
	return(0);
}



Measured memory_bytes: 2076