akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int mp[109][109];
vector<int>vec;

int main(){
  int h,w,n;
  cin>>h>>w>>n;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    for(int j=0;j<a;j++){
      vec.push_back(i+1);
    }
  }
  int cnt=0;
  for(int i=0;i<h;i++){
    if(i%2==0){
      for(int j=0;j<w;j++){
	mp[i][j]=vec[cnt];
	cnt++;
      }
    }
    else{
      for(int j=w-1;j>=0;j--){
	mp[i][j]=vec[cnt];
	cnt++;
      }
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cout<<mp[i][j];
      if(j+1==w)cout<<endl;
      else cout<<' ';
    }
  }
  return(0);
}


Measured memory_bytes: 384
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int         long long   
#define double      long double
#define endl        "\n"
#define pb          push_back
#define PI          3.1415926535897932384626433832795l
#define F           first
#define S           second
#define mp          make_pair
#define f(i,n)      for(int i=0;i<n;i++)
#define fastio      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)      (v).begin(),(v).end()
#define rall(v)     (v).rbegin(),(v).rend()
#define gcd(a,b)    __gcd((a),(b))
#define fill(a,value) memset(a,value,sizeof(a));
#define minn(v)     *min_element(v.begin(), v.end());
#define maxx(v)     *max_element(v.begin(), v.end());
#define print(x)    cout<<(x)<<endl;
#define sum(v)+x    accumulate(v.begin(), v.end(),x);
typedef pair<int,int> pii;  
typedef vector<int> vi;
signed main() 
{
    fastio;
    cout << fixed << setprecision(12);
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans=1;
    for(int i=1;i<n;i++)
    {
        if(s[i]!=s[i-1])ans++;
    }
    print(ans)
    return 0;
}

Measured memory_bytes: 3728
import Control.Monad
import Data.List
import Data.Bits
import Debug.Trace
import Data.Maybe
import qualified Data.ByteString.Char8 as C

main :: IO ()
main = do
  [a, b, c] <- readInts
  putStrLn $ solve a b c

solve :: Int -> Int -> Int -> String
solve a b c = if b - a == c - b then "YES" else "NO"

-- 以下ライブラリ

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

readNInts :: Int -> IO [[Int]]
readNInts = flip replicateM readInts

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

readNIntegers :: Int -> IO [[Integer]]
readNIntegers = flip replicateM readIntegers

getNLns :: Int -> IO [String]
getNLns = flip replicateM getLine

toTup2 :: [[a]] -> [(a, a)]
toTup2 = map (\ys -> case ys of y : z : zs -> (y, z))

encIdx2 :: Int -> (Int, Int) -> Int
encIdx2 mx (y, x) = y * mx + x

decIdx2 :: Int -> Int -> (Int, Int)
decIdx2 mx idx = (idx `div` mx, idx `mod` mx)

encIdx3 :: (Int, Int) -> (Int, Int, Int) -> Int
encIdx3 (my, mx) (z, y, x) = z * my * mx + y * mx + x

decIdx3 :: (Int, Int) -> Int -> (Int, Int, Int)
decIdx3 (my, mx) idx = (z, y, x)
  where
    basez = my * mx
    z = idx `div` basez
    y = (idx `mod` basez) `div` mx
    x = idx `mod` mx

while :: Monad m => m Bool -> m () -> m ()
while cond body = do
  b <- cond
  when b $ do
    body
    while cond body


Measured memory_bytes: 380
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>


/*
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::'''```````:::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::''`_,-''.,...  `::::::::::::::::::
:::::::::::::::::::::::::::::::::::::' _,-',;;!!!!!!!!!; `::::::::::::::::
::::::::::::::'`````:::::::::::::'' .-' ;<!!!!!!!'''`_..' `:::::::::::::::
::::::::::'' ,;!!!;,`::::::::::' .-`.,,,zcccc,,cccd$$"",;> `::::::::::::::
:::::::::' ;!!!!!!!!; ``:::::' ;' ,c$$$$$$$$$$$CC<<"  ````_ ::::::::::::::
:::::::' ;!!!!!!!!!!!!!;   ' ;! z$$$$$$$$$$$$$$$$$$$$$$??". ::::::::::::::
::::::: <!!!!!!!!!!!!!' .  .!',c$$$$$$$$$$$$$c, `"""',;;<!! ::::::::::::::
:::::: ,!!!!!!!!!!!'`,;! .<! ,$$$$$$$$$$$$$$$$hc,,,..- !!!! `:::::::::::::
::::'  <!!!!!!!!!' .<!!!;!! ,$$$$$""???$$$"""?????"" .<!!!! ::::::::::::::
::: ;><!!!!!!!!! ,<!!!!!!!',c,  "??.< . "??h. -;;;;!!!!!!!' ::::::::::::::
::: !!!!!!!!!!' ;!!!!!!!!' d$$h.`$ccr,$h `;,."  `!!!!!!!!! :::::::::::::::
:::.`<!!!!!!!' !!!!!!!!!! dP"""?.`$$F`$$h.`!!!!!!!!!!!!!! .:::::::::::::::
::::. <!!!!!! !!!!!!!!!! ,$ .nn.' "$$ P"   <!!!!!!!!!!!' .::::::::::::::::
:::::. <!!!! ;!!!!!!!!!! $$ MMMMx  ?$  ,dx `!!!!!!!!!!' ::::::::::::::::::
```:::: `!!! !!!'!!!!!!  `$ MMMMMM, $r MMMr !!!!!!!!' .:::::::::::::::::::
`!!;,.`' ``' ``,;!!!!' ch." 4MMMMMM "$ 4MMM `!!!!!' ..::::::::::::::::::::
 !!!!!'````'``<!!!'`.z$$$$.  MMMMMMb $h MMM `!!'' .:::::::::::::::::::::::
 ..``.,d$$$$$c,,,. $$$$$F"?  "MMMMMM $$ 4P" '  .::::::::::::::::::::::::::
dM""..""?$$$$$$$$$$$$$$$$$$c  "MM"   $$>`   ,c  `:::::::::::::::::::::::::
MMn.`"?hc,d$$$$$$$$$$$$$$$$$$. `P    $P'   -??P== `:::::::::::::::::::::::
MMMMMnx`"?$$$$$$$$$$$P".,.`"??$ccccc$.z$$$$.  `' .:::::::::::::::::'    ''
MMMMMM,' .?$$$$$$$$$$ d$$$    d$$$$$$$$$$$$$h..``::::::::::::::::'
MMMMMMMn `?$$$$$$$$$$,.?$$h. =."?$$$$$$$$$$$$$$hc,.``'::::::::::'
MMMMMMMM ;, `"??$$$$$$h  ?$$h. -m,``""??$$$$$$$$$$$$$c,.``````'
MMMMMMM> !!! ?cc,.,d$$$$h.`"?$hc   `P  .`"?$$$$$$$$$$$$$$$$$$$          .:
MMMMMMM ,!!'. $$$$$$$$$??=== `"""=c, " P  n. "$$$$$$$$$$$$$$$$c_    ,.::::
MMMMMMP !!! Mr<$$$$"".,c,;M ;<!! ..""=_ ' 4 .br .`""??$$$$$$$$??"".:::::::
MMMMMM';!!',M>'$$$$$$$$$>4M `!!! 4MMbn.`"=cc," -'P",c=.,.`.. .=  :::::::::
MMMMM' !!! dMb $$$$$$$$P MM> !!! 4MMMMMMr :..`"-._""Pr4"'-P" .,.`:::::::::
MMMM' <!!!,MMM "$$$$$$P dMM>;!!! 4MMMMMMb :::::.. "-=cczyycc??" .:::::::::
MMMP <!!! dMMMb "?$$P" uMMM>;!!! 4MMMMMMMr`:::::::::.........:::::::::::::
MMP';!!! ;MMMMMMn,.".uMMMMM ;!!! MMMMMMMMM,`::::::::::::::::::::::::::::::
MM ;!!!! MMMMMMMMMMMMMMMMMM !!!! MMMMMMMMMb `:::::::::::::::::::::::::::::
M" !!!! uMMMMMMMMMMMMMMMMMP !!! ;MMMMMMMMMMx :::::::::::::::::::::::::::::
P.!!!! ,MMMMMMMMMMMMMMMMMM ,!!! MMMMMMMMMMMMx`::::::::::::::::::::::::::::
 !!!!> MMMMMMMMMMMMMMMMMMP !!!',MMMMMMMMMMMMM `:::::::::::::::::::::::::::
*/


int main() {
	long long x;

	std::cin >> x;

	long long ans = 0;

	while (ans * (ans + 1) / 2 < x) {
		ans++;
	}

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n, m, k, a, b, a_num, b_num, num_max = 0;
    cin >> n >> m >> k;
    vector<long long> A(n+1, 0), B(m+1, 0);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a);
        A[i] = A[i-1] + a;
    }
    for (int j = 1; j <= m; j++) {
        scanf("%d", &b);
        B[j] = B[j-1] + b;
    }
    auto au = upper_bound(A.begin(), A.end(), k);
    for (a_num = au - A.begin() - 1; a_num >= 0; a_num--) {
        auto bu = upper_bound(B.begin(), B.end(), k - A[a_num]);
        b_num = bu - B.begin() - 1;
        if (a_num + b_num > num_max) num_max = a_num + b_num;
    }
    cout << num_max << endl;
    return 0;
}

Measured memory_bytes: 6424
s = input()
n = len(s)
try:
  a = s.count("a")
except:
  a = 0
try:
  b = s.count("b")
except:
  b = 0
try:
  c = s.count("c")
except:
  c = 0
if a >= n//3 and b >= n//3 and c >= n//3 and a <= n//3 +1 and b <= n//3 +1 and c <= n//3 +1 :
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  cin>>n;
  while(n--){
    double x[4];
    double y[4];
    rep(i,4)cin>>x[i]>>y[i];
    if(abs((y[1]-y[0])*(x[3]-x[2])-(y[3]-y[2])*(x[1]-x[0]))<ESP)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 1224
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        a: [usize1; n],
    }
    let mut b = vec![0; n];
    for i in 0..n {
        b[a[i]] = i;
    }
    for i in 0..n {
        puts!("{} ", b[i] + 1);
    }
    puts!("\n");
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 11132
while True:
  H,W = map(int,input().split())
  if H == W == 0:
    break
  for j in range(H):
    for i in range(W):
      if j%2 == 0:
        if i%2 == 0:
          print('#', end='')
        else:
          print('.', end='')
      else:
        if i%2 == 1:
          print('#', end='')
        else:
          print('.', end='')
    print()
  print() 


Measured memory_bytes: 7000
#include<cstdio>
#include<iostream>
#include<cstring>
#include<queue>
#include<vector>
#define RG register
using namespace std;
const int N=1e5+10;
struct dabt{
	int next,to;
}e[N<<1];
struct node{
	int id,num;
	bool operator <(const node&x)const{return x.num<num;}
};
int head[N],k,n,m,num[N];
bool vis[N],fx[N];
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
inline void add(int from,int to){e[++k]=(dabt){head[from],to}; head[from]=k;}
priority_queue<node>pn;
int main()
{
//	freopen("Integers on a Tree.in","r",stdin);
	//freopen(".out","w",stdout);
	read(n);
	for(int i=1,a,b;i<n;i++)
	{
		read(a,b);
		add(a,b); add(b,a);
	}
	read(m);
	for(int i=1,a,b;i<=m;i++)
	{
		read(a,b);
		num[a]=b; fx[a]=1;
		pn.push((node){a,b});
	}
	while(!pn.empty())
	{
		node u=pn.top(); pn.pop();
		int id=u.id, x=u.num; vis[id]=1;
		for(int i=head[id];i;i=e[i].next)
		{
			int v=e[i].to, tt=x+1;
			if(vis[v]) continue ;
			if(!fx[v])
			{
				vis[v]=1; num[v]=tt;
				pn.push((node){v,tt});
			}
			else {
				if(num[v]!=tt) return printf("No\n"), 0;
			}
		}
	}
	printf("Yes\n"); for(int i=1;i<=n;i++) printf("%d\n",num[i]);
	//fclose(stdin); fclose(stdout);
	return 0;
}


Measured memory_bytes: 4340
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define lli long long int
#define ld long double
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

map<lli, lli > ma[N];

void solve()
{
    lli A, B, M;
    cin>>A>>B>>M;
    lli a[A], b[B];
    vector<pair<lli, lli> > v1, v2;
    for(int i = 0; i < A; i ++) {
        cin>>a[i];
//        v1.push_back({a[i], i});
    }
    for(int i = 0; i < B; i ++) {
        cin>>b[i];
 //       v2.push_back({b[i], i});
    }
    lli X = *min_element(a, a + A);
    lli Y = *min_element(b, b + B);
    lli ans = X + Y;
    lli x[M], y[M], c[M];
    for(int i = 0; i < M; i ++) {
        cin>>x[i]>>y[i]>>c[i];
        x[i] --;
        y[i] --;
        ans = min(ans, a[x[i]] + b[y[i]] - c[i]);
    }
    cout<<ans;
    cout<<'\n';
    return ;
}



/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 18304
#include <iostream>

using namespace std;

int main(){
  int N;
  long double M;
  cin >> N >> M;
  int A[N];
  int count = 0;
  long double sum = 0;

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

for(int i=0;i<N;i++){
  if(sum/(4*M) > A[i]){
         count++;
    }
}

  if(N-count < M){
    cout << "No"; return 0;
  }
  else{
    cout << "Yes"; return 0;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)










int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    vector<vector<int>> g(n);
    for(int i = 0; i < m; i++){
        ll u, v;
        scanf("%d %d", &u, &v);
        u--; v--;
        g[u].push_back(v);
    }
    int s, t;
    scanf("%d %d", &s, &t);
    s--; t--;
    vector<int> dist(n, 1e9);
    vector<vector<bool>> used(n, vector<bool>(3));
    queue<pair<int, int>> que;
    que.push({s, 0});
    while(!que.empty()){
        auto tmp = que.front(); que.pop();
        int now = tmp.first, cnt = tmp.second;
        if(used[now][cnt % 3]) continue;
        if(now == t && cnt % 3 == 0){
            printf("%d\n", cnt / 3);
            return 0;
        }
        used[now][cnt % 3] = true;
        for(auto c : g[now]){
            que.push({c, cnt + 1});
        }
    }
    printf("-1\n");
}

Measured memory_bytes: 13184
#include<stdio.h>
#include<math.h>

int main(){

    int N,D,i,j,k;
    int X[10][10],result = 0;
    double dist = 0;

    scanf("%d %d",&N,&D);
    for(i = 0; i < N; i++){
        for(j = 0; j < D; j++){
            scanf("%d",&X[i][j]);
        }
    }

    for(i = 0;i < N; i++){
        for(k = i + 1; k < N; k++){
            dist = 0;
            for(j = 0;j < D;j++){
                dist += (X[k][j] - X[i][j])*(X[k][j] - X[i][j]);
            }
            if(ceil(sqrt(dist)) == floor(sqrt(dist))){

                result++;
            }
        }
    }

    printf("%d",result);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const ll MOD = 1e9 + 7;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }

int main() {
   string S;
   cin >> S;

   int ans = 0;
   for (int i = 0; i < (int)S.size(); i++) {
      for (int j = i; j < (int)S.size(); j++) {
         string tmp = S.substr(i, j - i + 1);
         for (int k = 0; k < (int)tmp.size(); k++) {
            if (tmp[k] != 'A' && tmp[k] != 'C' && tmp[k] != 'G' && tmp[k] != 'T') break;
            if (k == (int)tmp.size() - 1) chmax(ans, (int)tmp.size());
         }
      }
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	LL n,a[55]={},b[55]={},minc=-1;
	LL g[55][55]={},e[55][55]={},able[55][55]={};
	FOR(i,0,52)FOR(j,0,52)g[i][j]=1LL<<60;
	FOR(j,0,52)g[j][j]=0;
	FOR(i,0,52)FOR(j,0,52)able[i][j]=1LL*mod*mod;
	FOR(i,0,52)able[i][i]=0;
	cin>>n;
	FORQ(i,1,n)cin>>a[i];
	FORQ(i,1,n)cin>>b[i];
	int f=1;
	FORQ(i,1,n){
		if(a[i]!=b[i])f=0;
	}
	if(f)minc=0;
	else{
		//cerr<<"tes"<<endl;
		FOR(i,0,51){
			FOR(j,1,52){
				g[i][i%j]=min(g[i][i%j],(1LL<<j));
				e[i][i%j]=1;
				able[i][i%j]=1;
			}
		}
		for (int i = 0; i < 52; i++)      // 経由する頂点
	    for (int j = 0; j < 52; j++)    // 開始頂点
	      for (int k = 0; k < 52; k++)  // 終端
	        able[j][k] = min(able[j][k], able[j][i] + able[i][k]);
		FORQ(i,1,n){
			if(able[a[i]][b[i]]==1LL*mod*mod){
				cout<<-1<<endl;
				return 0;
			}
		}
		minc=0;
		//FOR(i,0,n)cout<<" i:"<<i<<" g:"<<g[a[i]][b[i]]<<endl;
		FORD(kk,52,1){
			for (int k = 0; k < 51; k++)
			for (int i = k; i < 51; i++)
					for (int j = 0; j <=k; j++)
							if (g[i][k] + g[k][j] < g[i][j]) {
									g[i][j] = g[i][k] + g[k][j];
							}
		  //if(kk==51)FORQ(i,1,n)cout<<" i:"<<i<<" g:"<<g[a[i]][b[i]]<<endl;
			//cout<<"g[48][7]:"<<g[48][7]<<endl;
			int dc=0;
			int maxk=0;
			FORQ(i,1,n){
				int mnk=0;
				if(g[a[i]][b[i]]!=0)if((g[a[i]][b[i]]&(1LL<<kk)&&!(g[a[i]][b[i]]>>(kk+1)))) {
							dc=1;
					}
				//if(mnk<100)maxk=max(maxk,mnk);

			}
			//if(dc)cout<<"kk:"<<kk<<" maxk:"<<maxk<<endl;
			if(dc){
				//cout<<kk<<endl;
				minc+=(1LL<<kk);
				FORQ(i,0,50)g[i][i%kk]=0;
			}

		}


	}
	cout<<minc<<endl;
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin 
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}
fn main() {
    let a : String = read();
    let b : String = read();

    if a == b {
        for _i in 0..a.parse().unwrap() {
            print!("{}", a);
        }
    } else if a < b {
        for _i in 0..b.parse().unwrap() {
            print!("{}", a);
        }
    } else {
        for _i in 0..a.parse().unwrap() {
            print!("{}", b);
        }
    }
}


Measured memory_bytes: 4352
//region #include <cp_helper>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>//region #include <cp_helper>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<ll>
#define vii vector<ii>
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define pin(n) in(n.first) >> n.second
#define vin(a, n) for (ll i=0; i<n; ++i) in(a[i])
#define viin(a, n) for (ll i=0; i<n; ++i) in2(a[i].first, a[i].second);
#define out(n) cout << n
#define outs(n) out(n) << ' '
#define outn(n) out(n) << '\n'
#define out2(n, m) cout << n << ' ' << m
#define out2s(n, m) out2(n, m) << ' '
#define out2n(n, m) out2(n, m) << '\n'
#define pout(n) out2(n.first, n.second)
#define pouts(n) pout(n) << ' '
#define poutn(n) pout(n) << '\n'
#define vout(a) for (auto i : a) outs(i)
#define viout(a) for (auto i : a) out2n(i.first, i.second)
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pp(a, b) emplace_back(make_pair(a, b))
#define fori(i, n) for (ll i=0; i<n; ++i)
#define foris(i, a, b) for (ll i=a; i<b; ++i)
#define ford(i, n) for (ll i=n-1; i>=0; --i)
#define fords(i, a, b) for (ll i=a; i>=b; --i)
#define forr(i, a) for (auto i : a)
const int mod = (int)(1e9) + 7;
//endregion

double a, b;

int main() {
    io();
    in2(a, b);
    out(ceil((b-a)/(a-1))+1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

ll qmi(int a, int k){
	ll res = 1;
	while(k){
		if(k & 1){
			res = res * a % mod;
		}
		a = a * a % mod;
		k >>= 1;
	}
	return res;
}
int main(){
	int n;
	cin >> n;
//	ll all = qmi(10, n);
//	ll none = qmi(8, n); 
//	ll only = qmi(9, n) - qmi(8, n);
////	cout << (all - none + mod - 2 * only % mod + 2 * mod) % mod << endl;
//	cout << (qmi(10, n) - qmi(9, n) - qmi(9, n) + qmi(8, n) + 4 * mod) % mod << endl;
	ll res1 = 1, res2 = 1, res3 = 1;
	for(int i = 1; i <= n; i++){
		res1 = res1 * 10 % mod;
		res2 = res2 * 9 % mod;
		res3 = res3 * 8 % mod;
	} 
	cout << (res1 - res2 - res2 + res3 + 4 * mod) % mod << endl;
	
}

Measured memory_bytes: 3636
/// However long the night,
///     The dawn will break
/// ICPC next year

#include<bits/stdc++.h>
using namespace std ;
const int N = 2e5+5 ;

long long n ,ans ;
int main(){
    cin >> n ;
    ans = n*(n-1)/2 ;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
def solve(n, a):
    box = [0] * (n + 1)
    for i in reversed(range(1, n + 1)):
        j = 2
        count = 0
        while i * j < n + 1:
            if box[i * j] == 1:
                count += 1
            j += 1
        if a[i - 1] != count % 2:
            box[i] = 1
    ans = [str(i) for i, it in enumerate(box) if it == 1]
    return len(ans), ans


if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    m, b = solve(N, A)
    print(m)
    if m > 0:
        print(' '.join(b))

Measured memory_bytes: 16436
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int arr[n];
    int sol[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
        sol[i] = 0;
    }
    int maxx = 0;
    for(int i=1;i<n;i++)
    {
        if(arr[i] <= arr[i-1])
        {
            sol[i] = sol[i-1] + 1;
            maxx = max(sol[i], maxx);
        }
    }
    cout<<maxx<<endl;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
	int n;
	while(cin>>n&&n){
		vector<int> v(n);
		rep(i,n){
			string s;
			cin>>s;
			v[i] = s.size();
		}
		
		rep(i,n){
			int now;
			int pos = i;
			
			int p[]={5,7,5,7,7};
			rep(j,5){
				now=0;
				while(now<p[j]){
					now+=v[pos++];
					if(now==p[j])break;
					if(now>p[j])goto next;
				}
			}
			cout<<i+1<<endl;
			break;
next:;
		}
	}
}

Measured memory_bytes: 3192
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
vector<int> a[1100];

int main(){
	int n; cin >> n;
	for(int i=0;i<n;i++){
		a[i].resize(n-1);
		for(int j=0;j<n-1;j++){
			cin >> a[i][j];
			a[i][j]--;
		}
		reverse(a[i].begin(),a[i].end());
	}
	vector<P> q;
	auto check = [&](int i){
		if(a[i].size()==0)return;
		int j=a[i].back();
		if(a[j].back()==i){
			if(j<i) swap(i,j);
			q.push_back(make_pair(i,j));
		}
	};
	for(int i=0;i<n;i++){
		check(i);
	}
	int day=0;
	while(q.size()>0){
		day++;
		vector<P> prevQ;
		sort(q.begin(),q.end());
		q.erase(unique(q.begin(),q.end()),q.end());
		swap(prevQ,q);
		for(pair<int,int> p:prevQ){
			int i=p.first,j=p.second;
			a[i].pop_back();
			a[j].pop_back();
		}
		for(pair<int,int> p:prevQ){
			int i=p.first,j=p.second;
			check(i);
			check(j);
		}
	}
	for(int i=0;i<n;i++){
		if(a[i].size()!=0){
			cout << -1 << endl;
			return 0;
		}
	}
	cout << day << endl;
	return 0;
}

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

ll solve() {
    string S;
    cin >> S;
    ll N = S.size();
    const ll MOD = 998244353;
    auto Add = [&](ll& x, ll y) { x = ( x % MOD + y % MOD ) % MOD; };
    vector<vector<ll>> dp1(N+2, vector<ll>(N+2)), dp2(N+1, vector<ll>(N+1));
    dp1[0][0] = 1;
    for ( int k = 0; k < N; k++ ) {
        int di, dj;
        if ( S[k] == '0' ) {
            di = 0, dj = 2;
        } else if ( S[k] == '1' ) {
            di = 1, dj = 1;
        } else {
            di = 2, dj = 0;
        }
        for ( int i = 0; i <= k; i++ ) {
            if ( i+di >= 0 && k-i+dj >= 0 ) {
                Add(dp1[i+di][k-i+dj], dp1[i][k-i]);
            }
        }
        for ( int i = 0; i <= k+1; i++ ) {
            dp1[i][k+1-i] = 0;
            Add(dp1[i][k+1-i], dp1[i][k+1-i+1]);
            Add(dp1[i][k+1-i], dp1[i+1][k+1-i]);
        }
    }
    for ( int i = 0; i <= N; i++ ) {
        dp2[i][N-i] = dp1[i][N-i];
    }
    for ( int k = N-1; k >= 0; k-- ) {
        for ( int i = 0; i <= k; i++ ) {
            Add(dp2[i][k-i], dp2[i][k-i+1]);
            Add(dp2[i][k-i], dp2[i+1][k-i]);
        }
    }
    
    ll ans = dp2[0][0];
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 62976
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x,y;
    while(1){
        cin >> x >> y;
        if(x==0 && y==0) break;
        if(x > y){
            swap(x,y);
            cout << x <<" "<< y << endl;
        }else{
            cout << x <<" "<< y << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2988
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;
int n, a[nax], k;

int main () {
    scanf("%d %d", &n, &k);

    for (int i = 1 ; i <= n ; ++ i)
        scanf("%d", a + i);

    for (int i = k ; i < n ; ++ i) {
        if (a[i + 1] > a[i - k + 1]) {
            puts("Yes");
        } else puts("No");
    }
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 4528
/*
 * ABC083C.cpp
 *
 *  Created on: May 18, 2018
 *      Author: 13743
 */
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	lng X, Y;
	cin >> X >> Y;
	lng a = X;
	int cnt = 0;
	while(a <= Y) {
		++cnt;
		a *= 2;
	}
	cout << cnt << endl;
}






Measured memory_bytes: 256
n,d = map(int,input().split())
x = []
for _ in range(n):
  xi = list(map(int,input().split()))
  x.append(xi)
def dis(a,b,d):
  s = 0
  for i in range(d):
    s += (a[i] - b[i])**2
  return s
count = 0
for i in range(n-1):
  for j in range(i+1,n):
    e = dis(x[i],x[j],d)
    ed = e**(1/2)
    if (ed - int(ed)) == 0:
      count += 1
print(count)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

#define MV 10010
char Maze[MV][MV];
int D[MV][MV];
int N,M;

int BFS(int sx,int sy,int gx,int gy){
	queue<P> que;
	int dx[]={1,0,-1,0};
	int dy[]={0,1,0,-1};
	REP(i,N)REP(j,M){
		D[i][j]=INF;
	}
	que.push(P(sx,sy));
	D[sx][sy]=0;
	while(!que.empty()){
		P p=que.front();
		que.pop();
		if(p.first==gx && p.second==gy){
			break;
		}
		for(int i=0;i<4;i++){
			int nx=p.first+dx[i];
			int ny=p.second+dy[i];
			if(0<=nx && nx<N && 0<=ny && ny<M && Maze[nx][ny]!='#' && D[nx][ny]==INF){
				que.push(P(nx,ny));
				D[nx][ny]=D[p.first][p.second]+1;
			}
		}
	}
	return D[gx][gy];
}

int main(){
	int count=0;
	cin>>N>>M;
	REP(i,N)REP(j,M){
		cin>>Maze[i][j];
		if(Maze[i][j]=='#'){
			count++;
		}
	}
	int dist=BFS(0,0,N-1,M-1);
	DEB(dist)END
	if(dist==INF){
		cout<<-1<<endl;
	}
	else{
		cout<<(N*M-count)-(dist+1)<<endl;
	}
	return 0;
}
//diff[3][2]

Measured memory_bytes: 2560
#include <cstdio>
#include <algorithm>
#include <cctype>
#include <vector>
#include <set>
#include <cstring>
using namespace std;
inline int read(int f = 1,int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar(); 
    return f*x;
}
const int N = 1e5+5;
int n, a[N], b[N], c[N], d[N], ans[N], p, q = 1;
multiset<int> f[N], g[N];
multiset<pair<int, int> > s;
int kth(int x) { return lower_bound(c+1, c+1+n, x)-c; }
int main()
{
    n = read(), ++n;
    for(int i = 1; i < n; ++i) a[i] = read(), b[i] = read();
    for(int i = 1; i <= n; ++i) c[i] = read(), d[i] = 1;
    sort(c+1, c+1+n);
    for(int i = 1; i < n&&q; ++i)
    {
        if(a[i] > c[n]&&b[i] > c[n]) q = 0;
        else if(a[i] <= c[n])
        {
            a[i] = kth(a[i]), b[i] = kth(b[i]), --d[a[i]];
            if(a[i] > b[i]) f[a[i]].insert(b[i]+1), g[b[i]+1].insert(a[i]);
        }
        else b[i] = kth(b[i]), --d[b[i]], ++p;
    }
    memcpy(b+1, d+1, sizeof(int)*n);
    for(int i = n; i&&q; --i)
    {
        d[i] += d[i+1];
        for(multiset<int>::iterator it = f[i].begin(); it != f[i].end(); ++it) s.insert(make_pair(*it, -i));
        for(int l, r; d[i] < 0&&s.size(); ++p)
            l = (*s.begin()).first, r = -(*s.begin()).second, 
            s.erase(s.begin()), g[l].erase(g[l].find(r)), 
            --d[l-1], ++d[i], --b[l-1], ++b[r];
        if(d[i] < 0) q = 0;
    }
    if(!q) for(int i = 1; i <= n; ++i) ans[i] = n+1;
    for(int i = n; i; --i) b[i] += b[i+1];
    for(int i = 1; i <= n; ++i) d[i] = b[i]-b[i-1]; 
    s.clear();
    for(int i = 1; i <= n&&q; ++i)
    {
        d[i] += d[i-1];
        for(multiset<int>::iterator it = g[i].begin(); it != g[i].end(); ++it) s.insert(make_pair(*it, -i));
        for(int r; d[i] < 1&&s.size(); ++p) 
            r = (*--s.end()).first, s.erase(--s.end()),
            ++d[i], --d[r+1];
        if(d[i] < 1) q = 0;
        if(!q) for(int k = i; k <= n; ++k) ans[k] = n+1;
        else ans[i] = p;
    }
    q = read();
    while(q--)
    {
        int d = read(), e = read(), h = n+1;
        if(d <= c[n]) h = min(h, ans[kth(d)]);
        if(e <= c[n]) h = min(h, ans[kth(e)]+1);
        printf("%d\n", n-h);
    }
    return 0;
}

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


Measured memory_bytes: 5596
import java.util.Scanner;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int k = sc.nextInt();
    int r = 0;
    
    if(1<=k && k<=n && n<=100){
      r = (n%k);
      System.out.println(r);
    }
  }
}

Measured memory_bytes: 21716
n = int(input())
a = [int(x) - 1 for x in input().split()]

target, point = 0, 0
ans = 0
for i in range(n):
    if a[i] == target:
        ans += i - point
        point = i + 1
        target += 1

if target == 0:
    print(-1)
else:
    ans += n - point
    print(ans)

Measured memory_bytes: 32052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define INF 1007654321
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }

const int MOD = 1e9 + 7;
const int MAXV = 1e5;

int main() {
    FAST_IO();
    int N; cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    rep(i, N) A[i] -= i + 1;
    sort(all(A));
    int b = A[N/2];
    ll ans = 0;
    rep(i, N) {
        ans += (ll)abs(A[i] - b);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define MOD 1000000007;

int main(){
	int n;
	cin >> n;
	int ans=0;
	for(int i=105; i<=n; i+=2){
		int count=0;
		for(int j=1; j<=i; j++){
			if(!(i%j))
				count++;
		}
		if(count==8)
			ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CGeTAC solver = new CGeTAC();
        solver.solve(1, in, out);
        out.close();
    }

    static class CGeTAC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int q = in.nextInt();
            String s = in.next();

            int p[] = new int[n];
            char a[] = s.toCharArray();
            if (a[0] == 'A' && a[1] == 'C') p[0] = 1;
            for (int i = 1; i < n - 1; i++) {
                if (a[i] == 'A' && a[i + 1] == 'C') {
                    p[i] = p[i - 1] + 1;
                } else {
                    p[i] = p[i - 1];
                }
            }
            p[n - 1] = p[n - 2];
            int ans = 0;
            for (int i = 0; i < q; i++) {
                int l = in.nextInt();
                int r = in.nextInt();
                l--;
                r--;
                if (l == 0) {
                    ans = p[r - 1];
                } else {
                    ans = p[r - 1] - p[l - 1];
                }
                out.println(ans);
            }
        }

    }
}



Measured memory_bytes: 71168
#include<cstdio>
#include<cstring>

int main(){
    char s[201],p[101],s1[101];
    scanf("%s %s",s,p);
    strcpy(s1,s);
    strcat(s,s1);
    if(strstr(s,p)==NULL) printf("No\n");
    else printf("Yes\n");
    return 0;
}


Measured memory_bytes: 2672
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
int main()
{
	ll t = 1,f1 = 2,f2 = 1,n;
	scanf("%d",&n);
	rep(i,2,n + 1){
		t = f1 + f2;
		f1 = f2;
		f2 = t;
	}
	cout<<t<<endl;
	return 0;
}


Measured memory_bytes: 256
/*
  NAME : RISHABH SINGH
  INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY
*/
#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define pii pair<int, int>
#define bi __builtin_inf()
#define ll long long
#define mp make_pair
#define ss second
#define pb push_back
#define ff first
#define speed_cubing ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define um unordered_map
#define us unordered_set
#define bp __builtin_popcount
#define ld long double
#define rep(n) for (int i = 0; i < n; i++)
#define pll pair<ll, ll>
#define mx = 1e18;
#define lb(v, val) (lower_bound(v.begin(), v.end(), val) - v.begin())
#define ub(v, val) (upper_bound(v.begin(), v.end(), val) - v.begin())
#define PI 3.1415926535
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
#define sz(v) (int)v.size()
#define endl '\n'
const int mod = 1e9+7;
ll mul_inv(ll a,ll b = mod) {ll t1=a,t2=b,t3,v1=1,v2=0,v3;while(t2!=1){ll x=t1/t2;t3=t1-x*t2;v3=v1-x*v2;t1=t2,t2=t3;v1=v2,v2=v3;}return(v2+b)%b;}
const int N = 1e6+5;
int arr[N];

int32_t main(){
   
   speed_cubing
   
   int k;
   cin>>k;
   
   int temp = 0;

   for(int i=1;;i++){
      temp = (temp*10+7)%k;
      if(temp==0){
        cout<<i;
        return 0;
      }
      if(arr[temp]){
        cout<<-1;
        return 0; 
      }
      arr[temp]++;
   }

   return 0;
}

Measured memory_bytes: 11444
public class Main{
    Main(){
	for(int i = 1; i < 10; i++)
	    for(int j = 1; j < 10; j++)
		System.out.println(Integer.toString(i) + "x" + Integer.toString(j)+"="+Integer.toString(i*j));
    }

    public static void main(String[] args){
	new Main();
    }
}

Measured memory_bytes: 0
package main
import(
  "fmt"
)

func main(){
  var a, b, c, d, n, time, x, y int
  fmt.Scan(&a, &b, &c, &d, &n)
  x=60*a+b
  y=60*c+d
  time=y-x
  fmt.Println(time-n)
}


Measured memory_bytes: 1748
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
const int mod=1e9+7;
// Not for Rating """"""""""I'm in Love with Experience :)""""""""""""""""""
void solve()
{
    ll N;cin>>N;
    double T,x,a;cin>>T>>x;
    double p=0.0;
    double mn=99999999999999.999999;
    for(ll i=1;i<=N;++i)
    {
        cin>>p;
        p=T -p*(0.006);
        p=abs(x-p);
        if(mn>p)
        {
            mn=p;
            a=i;
        }
    }
    cout<<a<<'\n';
}
int main(void)
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int T=1;while(T--){solve();}return 0;
}/*Solved By:- RITIK AGARWAL*/

Measured memory_bytes: 3820
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int a = 0;
    vector<int> A(N);
    int sum = 0;
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
        a = max(a, A.at(i));
        sum += A.at(i);
    }
    sum -= a;
    if(a < sum){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fromIntegral . fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

divide :: [Int] -> Int
divide as
  | all (\x -> x `mod` 2 == 0) as = 1 + divide (map ((`div` 2)) as)
  | otherwise = 0

main = do
  n <- getInt
  as <- getIntList
  print $ divide as


Measured memory_bytes: 892
import Control.Applicative
import Control.Monad

main :: IO ()
main = do
  ls <- lines <$> getContents
  forM_ ls $ \l -> do
    let [x1,y1,x2,y2,x3,y3,xp,yp] = map read $ words l
        cr1 = cross (x2-x1) (y2-y1) (xp-x1) (yp-y1)
        cr2 = cross (x3-x2) (y3-y2) (xp-x2) (yp-y2)
        cr3 = cross (x1-x3) (y1-y3) (xp-x3) (yp-y3)
    putStrLn $ if cr1>0 && cr2>0 && cr3>0 || cr1<0 && cr2<0 && cr3<0
      then "YES"
      else "NO"

cross :: Double -> Double -> Double -> Double -> Double
cross x1 y1 x2 y2 = x1*y2 - y1*x2

Measured memory_bytes: 4284
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, D;
int A[300000];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> D;
  rep(i, N) cin >> A[i];
  long long x = 0;
  rep(i, N) x ^= (A[i]-1)%(D+1);
  if (x)cout<<"First\n";
  else cout << "Second\n";
  return 0;
}



Measured memory_bytes: 4100
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;

int main() {
  int N;
  cin >> N;
  int c[4] = {0,0,0,0};
  string s;
  for(int i = 0;i < N;++i){
    cin >> s;
    if(s == "AC"){
		c[0]++;
    }
    else if(s == "WA"){
		c[1]++;
    }
    else if(s == "TLE"){
		c[2]++;
    }
    else if(s == "RE"){
		c[3]++;
    }
  }

  cout << "AC x " << c[0] << endl;
  cout << "WA x " << c[1] << endl;
  cout << "TLE x " << c[2] << endl;
  cout << "RE x " << c[3] << endl;
}


Measured memory_bytes: 3628
# -*- coding: utf-8 -*-


N = input()
mod = 10**9+7
num = 1
cnt = 0
ans = 1
for i in range(N):
    num = num*(i+1)
for i in range(N-1):
    while(num%(i+2)==0):
        num = num/(i+2)
        cnt += 1
    ans *= (cnt+1)
    ans = ans % mod
    cnt = 0
    
print(ans)

Measured memory_bytes: 2820
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    cout << B + min(A + B + 1, C) << endl;
    return 0;
}

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

int main(){
  int n,m,c;
  cin >> n >> m >> c;
  
  vector<int> b(m);
  for(int i=0;i<m;i++)
    cin >> b.at(i);
  
  vector<vector<int>> a(n,vector<int>(m));
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++)
      cin >> a.at(i).at(j);
  }
  
  int k=0;
  
  for(int i=0;i<n;i++){
    
    int x=c;
    
    for(int j=0;j<m;j++)
      x+=a.at(i).at(j)*b.at(j);
    
    if(x>0)
      k++;
    
  }
  
  cout << k << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main()
{
    int r,g;
    cin>>r>>g;
    cout<<2*g-r<<endl;
}

Measured memory_bytes: 256
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")



/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  string s;cin>>s;
  for(int i = 0; s.size() > i; i++){
    cout << 'x';
  }
  cout << endl;
}

Measured memory_bytes: 256
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

h, w = LI()

if h == 1 or w == 1:
    print(1)

else:    
    if (h * w) % 2 == 0:
        print(int(h * w / 2))
    else:
        print(int(h * w / 2 + 1))

Measured memory_bytes: 62060