akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

int main() {
	// x1=a1, x2=a2, y1=a3, y2=a4
	int x1[101], x2[101], y1[101], y2[101];

	for (int i = 0; i < 101; i++)
	{
		x1[i] = x2[i] = y1[i] = y2[i] = 0;
	}

	int w, h, n;

	std::cin >> w >> h >> n;

	for (int i = 0; i < n; i++)
	{
		int x, y, a;

		std::cin >> x >> y >> a;

		if (a == 1) {
			x1[x] = 1;
		}
		else if (a == 2) {
			x2[x] = 1;
		}
		else if (a == 3) {
			y1[y] = 1;
		}
		else {
			y2[y] = 1;
		}
	}

	int xl = 0, xr = w, yu = h, yd = 0;

	for (int i = 100; i >= 0; i--)
	{
		if (x1[i] == 1) {
			xl = std::max(xl, i);
		}
		if (x2[i] == 1) {
			xr = std::min(xr, i);
		}
		if (y1[i] == 1) {
			yd = std::max(yd, i);
		}
		if (y2[i] == 1) {
			yu = std::min(yu, i);
		}
	}

	if (xl >= xr || yd >= yu) {
		std::cout << 0 << std::endl;
	}
	else {
		std::cout << (xr - xl) * (yu - yd) << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
 	
int main() {
	string s;
	int K;
	cin>>s>>K;
	vecs(U);
	fx(s.size()){
		fyg(K+1,1){
			if(x+y<=s.size()){
			string h=s.substr(x,y);
			U.push_back(h);
			}
		}
	}
	
	sorts(U)
	int i=0,k=1;
string j=U.at(0);
while(k<K){
while(j==U.at(i)){
i++;
}
j=U.at(i);
k++;
}
ce(j)
	
}

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

template<typename T>
vector<pair<T, T>> prime_factorization(T N){
    vector<pair<T, T>> result;
    for(T i = 2; i * i <=N; i++){
        int count=0;
        while(N%i==0){
            N /= i;
            count++;
        }
        if(count!=0) result.push_back(make_pair(i, count));
    }
    if(N!=1) result.push_back(make_pair(N, 1));
    return result;
}

int main(){
    long long A, B; cin >> A >> B;
    auto GCD = __gcd(A, B);
    vector<pair<long long, long long>> result;
    result = prime_factorization(GCD);
    cout << result.size() + 1 << endl;
}

Measured memory_bytes: 256
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"QWERTYASDFZXCV"# => r#"5"#,
r#"ZABCZ"# => r#"4"#,
r#"HASFJGHOGAKZZFEGA"# => r#"12"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        s: chars,
    }
    let mut min = s.len();
    let mut max = 0;

    for i in 0..s.len() {
        if s[i] == 'A' {
            min = i;
            break;
        }
    }

    for i in (0..s.len()).rev() {
        if s[i] == 'Z' {
            max = std::cmp::max(max, i);
            break;
        }
    }

    if max - min > 0 { max - min + 1 } else { 0 }.to_string()
}

Measured memory_bytes: 4352
import math
import sys
sys.setrecursionlimit(100000)
f = math.factorial
n, m = map(int, input().split())
a = [-1] + [int(input()) for i in range(m)] + [n+1]
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 5  # N は必要分だけ用意する
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)


count = 1
for i in range(m+1):
    k = a[i+1] - a[i] - 2
    if k == -1:
        count = 0
        break
    else:
        work = 0
        for b in range(k//2+1):
            work += cmb(k-b, b, p)
        count *= work
print(count%p)


Measured memory_bytes: 21000
x, k, d = map(int, input().split())
a = abs(x) // d
b = abs(x) % d
if a >= k:
    print(abs(x) - (d * k))
else:
    if (k - a) % 2 == 0:
        print(abs(b))              
    else:
        print(abs(b - d))

Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define maxn 1000005

char s[55][55];
int fx[] = {0, 1, 0, -1}, fy[] = {1, 0, -1, 0};

int main() {
    int n, m, k, t;
    while(~scanf("%d %d", &n, &m)) {
        for(int i = 0; i < n; i++) scanf("%s", s[i]);
        int f = 1;
        for(int i = 0; i < n && f; i++) {
            for(int j = 0; j < m && f; j++) {
                if(s[i][j] != '#') continue;
                int num = 0;
                for(int k = 0; k < 4; k++) {
                    int dx = i + fx[k], dy = j + fy[k];
                    if(dx < 0 || dy < 0 || dx >= n || dy >= m) continue;
                    if(s[dx][dy] == '#') num++;
                }
                if(!num) f = 0;
            }
        }
        if(!f) puts("No");
        else puts("Yes");
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();

    Map<Integer, Integer> m = new HashMap<Integer, Integer>();

    for (int i = 0; i < n; i++) {
      int num = scanner.nextInt();
      if (m.get(num) == null) {
        m.put(num, 1);
      } else {
        m.remove(num);
      }
    }

    System.out.println(m.size());

  }

}

Measured memory_bytes: 60704
#include <bits/stdc++.h>
using namespace std;
using Int = __int128_t;

// https://kenkoooo.hatenablog.com/entry/2016/11/30/163533
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
    std::ostream::sentry s(dest);
    if (s) {
        __uint128_t tmp = value < 0 ? -value : value;
        char buffer[128];
        char *d = std::end(buffer);
        do {
            --d;
            *d = "0123456789"[tmp % 10];
            tmp /= 10;
        } while (tmp != 0);
        if (value < 0) {
            --d;
            *d = '-';
        }
        int len = std::end(buffer) - d;
        if (dest.rdbuf()->sputn(d, len) != len) {
            dest.setstate(std::ios_base::badbit);
        }
    }
    return dest;
}

vector<string> parse(const string &S) {
    vector<string> ret;
    auto itr = S.begin();
    const auto itr_end = S.end();
    while (itr != itr_end) {
        switch (*itr) {
            case 'n':
                ret.push_back("north");
                itr += 5;
                break;
            case 'w':
                ret.push_back("west");
                itr += 4;
            default:
                break;
        }
    }
    return ret;
}

void put_answer(Int numerator, Int denominator) {
    Int gcd = __gcd(numerator, denominator);
    numerator /= gcd;
    denominator /= gcd;
    if (denominator == (Int)1) {
        cout << numerator << endl;
    } else {
        cout << numerator << '/' << denominator << endl;
    }
}

void solve(const string &S) {
    auto tokens = parse(S);
    reverse(tokens.begin(), tokens.end());
    Int numerator = (tokens[0] == "north" ? 0 : 90);
    Int denominator = 1;
    for (size_t i = 1; i < tokens.size(); i++) {
        numerator *= (Int)2;
        denominator *= (Int)2;
        if (tokens[i] == "north") {
            numerator -= 90;
        } else {
            numerator += 90;
        }
    }
    put_answer(numerator, denominator);
}

int main() {
    string S;
    while (true) {
        cin >> S;
        if (S == "#") {
            break;
        }
        solve(S);
    }
}


Measured memory_bytes: 3036
#include <stdio.h>
#include <string.h>
int main(){
  int abc[26]={0},i,len;
  char input[101];
  
  scanf("%s",input);
  len=strlen(input);
  
  for(i=0;i<len;i++){
    abc[(input[i]-'a')]++;
  }
  
  for(i=0;i<26;i++){
    if(abc[i]%2==1){
      printf("No");
      return 0;
    }
  }
  
  printf("Yes");
}

Measured memory_bytes: 128
/*author : Yashvardhan
Sunday, June 23, 2019
12:32 PM
*/

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

typedef long long ll;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int takemod(int a){return ((a%mod)+mod)%mod;}

int pow(int a, int b, int m)
{
	int ans = 1;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

int modinv(int a){return takemod(pow(takemod(a), mod-2,mod));}


signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	int n,l;
	cin>>n>>l;

	int si = (n)*(n+1)/2;
	int nl = n*l;

	int ov = si + nl - n;
	int ans = -1;
	int mini = inf;
	for(int i = 1; i <= n ; i++){
		int curr = l + i - 1;
		int nv = ov - curr;
		int diff = abs(ov - nv);
		if(diff < mini){
			mini = diff;
			ans = nv;
		}
	}

	cout<<ans<<endl;
	

	t2 = clock();
	cerr<<endl<<t2-t1<<endl;
	
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
const int maxn=310;
int N,M,L,dis[maxn][maxn],rem[maxn][maxn],lin[maxn],len;
struct edge{
	int y,next,v;
}e[maxn*maxn];
inline void insert(int xx,int yy,int vv){
	e[++len].next=lin[xx];
	lin[xx]=len;
	e[len].y=yy;
	e[len].v=vv;
}
inline void ins(int xx,int yy,int vv){
	insert(xx,yy,vv);
	insert(yy,xx,vv);
}
bool vis[maxn];
void dijkstra(int x){
	memset(vis,0,sizeof(vis));
	dis[x][x]=0,rem[x][x]=L;
	for(int i=1;i<=N;i++){
		int mn=1<<30,id,mx;
		for(int j=1;j<=N;j++)
			if(!vis[j]){
				if(dis[x][j]<mn)
					mn=dis[x][j],id=j,mx=rem[x][j];
				else if(dis[x][j]==mn&&rem[x][j]>mx)
					id=j,mx=rem[x][j];
			}
		vis[id]=1;
		dis[x][id]=mn;
		for(int j=lin[id];j;j=e[j].next){
			if(e[j].v>L)continue;
			if(dis[x][e[j].y]>dis[x][id]+(rem[x][id]<e[j].v)){
				dis[x][e[j].y]=dis[x][id]+(rem[x][id]<e[j].v);
				if(rem[x][id]<e[j].v)
					rem[x][e[j].y]=L-e[j].v;
				else
					rem[x][e[j].y]=rem[x][id]-e[j].v;
			}
			else if(dis[x][e[j].y]==dis[x][id]+(rem[x][id]<e[j].v)){
				if(rem[x][id]<e[j].v)
					rem[x][e[j].y]=max(rem[x][e[j].y],L-e[j].v);
				else
					rem[x][e[j].y]=max(rem[x][e[j].y],rem[x][id]-e[j].v);
			}
		}
	}
}
int main(){
	//freopen("in","r",stdin);
	N=read(),M=read(),L=read();
	for(int i=1;i<=M;i++){
		int x=read(),y=read(),v=read();
		ins(x,y,v);
	}
	memset(dis,10,sizeof(dis));
	for(int i=1;i<=N;i++)
		dijkstra(i);
	for(int i=1;i<=N;i++)
		for(int j=1;j<=N;j++)
			if(dis[i][j]==dis[0][0])
				dis[i][j]=-1;
	/**for(int i=1;i<=N;i++){
		for(int j=1;j<=N;j++)
			printf("%3d ",dis[i][j]);
		puts("");
	}
	puts("");
	for(int i=1;i<=N;i++){
		for(int j=1;j<=N;j++)
			printf("%3d ",rem[i][j]);
		puts("");
	}*/
	for(int Q=read();Q;Q--){
		int x=read(),y=read();
		printf("%d\n",dis[x][y]);
	}
	return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
ll find(vector<ll>& grp, int x) {
    if (grp[x] == x)
        return x;
    return grp[x] = find(grp, grp[x]);
}

int main() {
    int n, m, a, b;
    cin >> n >> m;
    vector<pair<int, int>> edge;
    for(int i = 0; i < m; i++) {
        cin >> a >> b;
        edge.push_back({a-1, b-1});
    }
    vector<ll> grp(n, 0);
    vector<ll> grp_size(n, 1);
    for(int i = 0; i < n; i++)
        grp[i] = i;
    ll cnt = ll(n)*ll(n-1) / 2;
    vector<ll> ans = {cnt};

    for(int i = m-1; i >= 0; i--) {
        int r1 = find(grp, edge[i].first);
        int r2 = find(grp, edge[i].second);
        if (r1 != r2) {
            ll sz1 = grp_size[r1] * (grp_size[r1]-1) / 2;
            ll sz2 = grp_size[r2] * (grp_size[r2]-1) / 2;
            cnt += sz1 + sz2;
            grp_size[r1] = grp_size[r2] = grp_size[r1]+grp_size[r2];
            cnt -= grp_size[r2] * (grp_size[r2]-1) / 2;
            grp[r1] = grp[r2] = min(grp[r2], grp[r2]);

        }
        ans.push_back(cnt);
    }
    ans.pop_back();
    reverse(ans.begin(), ans.end());
    for(auto val: ans) {
        cout << val << endl;
    }
    return 0;
}




Measured memory_bytes: 4596
// AtCoder ABC125: A - Biscuit Generator
// 2019.9.9 bal4u

#include <stdio.h>

int main()
{
	int A, B, T, t, ans;
	
	scanf("%d%d%d", &A, &B, &T);
	ans = 0; for (t = A; t <= T; t += A) ans += B;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int n = s.length();
  sort(s.begin(), s.end());
  if(s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>


int main() {


	int i, cnt1 = 0,cnt2=0;
	char s[100001];
	scanf("%s", s);
	
	for (i = 0; i < strlen(s); i++) {
		if (i % 2 == 0) {
			if (s[i] == '0')cnt1++;
		}
		else {
			if (s[i] == '1')cnt1++;
		}
	}for (i = 0; i < strlen(s); i++) {
		if (i % 2 == 0) {
			if (s[i] == '1')cnt2++;
		}
		else {
			if (s[i] == '0')cnt2++;
		}
	}
       cnt1>cnt2 ? printf("%d",cnt2) : printf("%d", cnt1);

	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	n %= k
	min := Min(n, abs(n-k))
	fmt.Println(min)
}

func abs(a int) int {
	if a < 0 {
		return a * (-1)
	}
	return a
}

func Min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

Measured memory_bytes: 512
#include<iostream>

using namespace std;

int main(){
	 
	int n;
	
	while( cin >> n ) {
	
	if ( n % 39 == 0)
	n = 39;
	
	else
	n %= 39;
	
	if( n < 10)
	cout << "3C0" << n << "\n";
	
	else
	cout << "3C" << n << "\n";
	
}
  	return 0;
}


Measured memory_bytes: 3080
import java.util.*;
class Main{
	public static void main(String args[]){
    	Scanner sc = new Scanner(System.in);
      	int A = sc.nextInt();
      	int B = sc.nextInt();
      	int C = sc.nextInt();
      	if(A + B + C >= 22)
          System.out.println("bust");
      	else
          System.out.println("win");
    }
}

Measured memory_bytes: 35800
N=int(input())
K=2
h=[int(i) for i in input().split()]
dp=[float("inf")]*N
dp[0]=0
for i in range(N):
  for k in range(1,K+1):
    if i+k>=N:
      break
    dp[i+k]=min(dp[i+k],dp[i]+abs(h[i]-h[i+k]))
print(dp[N-1])
    


Measured memory_bytes: 52208
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1001001001;

// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

int N, P;
int d[100][100];

int main(){
    std::cin >> N;

    REP(i, 100){
        REP(j, 100){
            if(i == j){d[i][j] = 0;}
            else{d[i][j] = INF;}
        }
    }

    REP(i, N){
        int from, k;
        std::cin >> from >> k;
        --from;
        
        REP(j, k){
            int to;
            std::cin >> to;
            --to;
            
            d[from][to] = 1;
        }
    }

    REP(k, N){
        REP(i, N){
            REP(j, N){
                d[i][j] = std::min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    std::cin >> P;
    REP(i, P){
        int s, t, ttl;
        std::cin >> s >> t >> ttl;
        --s; --t;

        if(d[s][t] == INF || d[s][t] >= ttl){
            puts("NA");
        }else{
            printf("%d\n", d[s][t] + 1);
        }
    }
}

Measured memory_bytes: 1192
use proconio::input;

#[allow(unused_variables)]
fn main() {
    input! {
      n: f32,
    };

    let a = (n / 1.08f32).ceil();

    println!(
        "{}",
        if (a * 1.08).floor() == n {
            a.to_string()
        } else {
            ":(".to_string()
        }
    );
}


Measured memory_bytes: 2660
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;


void solve(long long N, string S){
  vvl ex1(N+1,vl(10)), ex2(N+1,vl(10));
  vl now(10);
  rep(i,N){
    ll num = ll(S[i]-'0');
    now[num] = 1;
    ex1[i+1] = now;
  }
  rep(i,10) now[i] = 0;
  rrep(i,N-1){
    ll num = ll(S[i]-'0');
    now[num] = 1;
    ex2[i] = now;
  }
  set<ll> st;
  rep(i,N){
    ll b = ll(S[i]-'0');
    rep(a,10) rep(c,10){
      if(ex1[i][a]==1 && ex2[i+1][c]==1) st.insert(a*100+b*10+c);
    }
  }
  cout << st.size() << endl;
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  long long N;
  scanf("%lld",&N);
  string S;
  cin >> S;
  solve(N, S);
  return 0;
}


Measured memory_bytes: 7424
import math
while True:
    n = int(input())
    if n == 0:
        break
    else:
       points = list(map(int, input().split()))
       mean = sum(points) / len(points)
       std = 0
       for num in points:
           std += (num-mean)**2
       std = math.sqrt(std / len(points))
       print(std)


Measured memory_bytes: 5700
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0

for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if 500 * i + 100 * j + 50 * k == x:
                cnt += 1

print(cnt)

Measured memory_bytes: 3060
// at_abc156c.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define FOR(i,a) for(int i=0;i<a;i++)
int n;
vector<int> v;
int dist(int center) {
    int out = 0;
    for (auto x : v) {
        out += (x - center) * (x - center);
    }
    return out;
}
int main()
{
    cin >> n;
    v.resize(n, 0);
    FOR(i, n) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    int ans = 1e8;
    int idx = v[0];
    while (idx <= v[n - 1]) {
        ans = min(ans, dist(idx));
        idx++;
    }
    cout << ans << "\n";
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        // 天気
        String s = sc.next();
		//連続最大日数
        int max=0;
      	//現在何連続目か
      	int now=0;
      
      	for(int i=0;i<s.length();i++){
          if(s.charAt(i)=='R'){
            now+=1;
          }else{
            now=0;
          }
          if(now>=max){
            max=now;
          }
        }
      System.out.println(max);
    }
}

Measured memory_bytes: 35332
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define mp make_pair
#define M 1000000007
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
const int N = 1e2 + 1 , W = 1e5 + 1;
int n , w;
ll  dp[N][W] , mx;
int main(){
	scanf("%d%d",&n,&w);
	for (int i = 1,x,val; i <= n; ++i){
		scanf("%d%d",&x,&val);
		for (int j = 1; j <= w; ++j){
			if(j - x < 0)dp[i][j] = dp[i-1][j];
			else dp[i][j] = max(dp[i-1][j] ,dp[i-1][j-x] + val );
			//cout << dp[i][j] <<" ";
		}
		//puts("");
	}
	for (int i = 0; i <= w; ++i){
		mx = max(dp[n][i],mx);
	}
	//cout << dp[1][3] <<endl;
	cout << mx << endl;



}	

Measured memory_bytes: 81648
#include <cstdio>
#include <algorithm>

using i8 = std::int8_t;
using u8 = std::uint8_t;
using i16 = std::int16_t;
using u16 = std::uint16_t;
using i32 = std::int32_t;
using u32 = std::uint32_t;
using i64 = std::int64_t;
using u64 = std::uint64_t;
using usize = std::size_t;

i32 a[200000];

auto main() -> i32 {
	i32 n, k;
	scanf("%d%d", &n, &k);
	for (i32 i = 0; i < n; i += 1) {
		scanf("%d", a + i);
	}
	i32 b[200001];
	for (i32 step = 0; step < std::min(64, k); step += 1) {
		std::fill(b, b + n + 1, 0);
		for (i32 i = 0; i < n; i += 1) {
			b[std::max(0, i - a[i])] += 1;
			b[std::min(n, i + a[i] + 1)] -= 1;
		}
		a[0] = b[0];
		for (i32 i = 1; i < n; i += 1) {
			b[i] += b[i - 1];
			a[i] = b[i];
		}
	}
	for (i32 i = 0; i < n; i += 1) {
		printf("%d%c", a[i], i == n - 1 ? '\n' : ' ');
	}
	return 0;
}


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

int main() {
  int r,g,b,n; cin >>r >>g >>b >>n;
  int cnt = 0;
  int rn = n/r, gn = n/g;
  for(int i = 0; i<=rn; i++){
    for(int j = 0; j<=gn; j++){
      int x = n-r*i-g*j;
      if(x<0) continue;
      if(x%b==0) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3600
// sum_{i=0}^{N-2} \sum_{j=i+1}^{N-1} A_i*A_j
// sum_{i=0}^{N-2} A_i * (\sum_{j=i+1}^{N-1} A_j)
#include <iostream>
#include <vector>
using namespace std;
using ll = int64_t;

ll MOD = static_cast<ll>(1e9+7);
ll ADD(ll x, ll y) { return (x+y)%MOD; }
ll MUL(ll x, ll y) { return (x*y)%MOD; }

int main() {
  ll n;
  cin >> n;
  vector<ll> A(n, 0);
  for(ll i=0; i<n; i++) {
    cin >> A[i];
  }
  vector<ll> SUFFIX_SUM(n, 0);
  SUFFIX_SUM[n-1] = A[n-1];
  for(ll i=n-2; i>=0; i--) {
    SUFFIX_SUM[i] = ADD(SUFFIX_SUM[i+1], A[i]);
  }
  ll ans = 0;
  for(ll i=0; i+1<n; i++) {
    ans = ADD(ans, MUL(A[i], SUFFIX_SUM[i+1]));
  }
  cout << ans << endl;
}


Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
float PHI = 1.6180339;
//const float  PI_F=3.14159265358979f;
#define MAX 100000 
#define endl "\n"    
//typedef long long float;
#define int long long
//#define float unsigned long long
  


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(9);

    int a ,b,c;
    cin>>a>>b>>c;
    int sum=a+b+c;
    if(sum>=22)
    cout<<"bust"<<endl;
    else
    cout<<"win"<<endl;

}



Measured memory_bytes: 256
//
//  AT3532 [ABC074A] Bichrome Cells.cpp
//  Algorithm
//
//  Created by SkyGao on 2020/2/13.
//  Copyright © 2020 skygao. All rights reserved.
//

#include <stdio.h>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
#define re register
using namespace std;
int main()
{
    int n,a;
    scanf("%d%d",&n,&a);
    printf("%d",n*n-a);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
vector <int> a[200010];
void solve()
{
    int i,j,k,n,m,u,v,x;
    cin>>n;
    for(i=2;i<=n;i++)
    {
        cin>>x;
        a[x].push_back(i);
    }
    for(i=1;i<=n;i++)
    {
        cout<<a[i].size()<<"\n";
    }
    
}

int main() 
{
    solve();
    return 0;
}

Measured memory_bytes: 14508
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000000007;
ll rui(ll number1,ll number2){

    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){

    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){

    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){

    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
	rfact[800000] = rui(fact[800000],mod - 2);
	for(ll i=800000; i>=1; i--){
	   rfact[i-1] = rfact[i] * i;
	   rfact[i-1] %= mod;
	}
	return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/

ll n,m,num,sum,ans,a,b,c,d,e,g,h,w,i,j,k,q,l,r;
ll x[500005],y[500005],z[500005];
ll dp[100][100];
bool used[500005];
char s[500005],t[500005];
bool flag,dame;

int main(){
	cin >> n >> m;
	for(i=0;i<m;i++){
		cin >> x[i];
		for(j=0;j<x[i];j++){
			cin >> dp[i][j];
			dp[i][j]--;
		}
	}
	for(i=0;i<m;i++){
		cin >> y[i];
	}
	for(i=0;i<(1ll<<n);i++){
		flag = false;
		for(j=0;j<m;j++){
			a = 0;
			for(k=0;k<n;k++){
				for(l=0;l<x[j];l++){
					if(((1 << k) & i) && dp[j][l] == k)a++;
				}
			}
			if((a%2)!= y[j])flag = true;
		}
		if(!flag)ans++;
	}
	p(ans);
	return 0;
}

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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  int N,P;
  cin>>N>>P;
  string s;
  cin>>s;
  ll ans(0);
  if(P == 2 || P == 5) {
    for(int i(0);i<N;i++){
      if((s[i]-'0') % P == 0){
        ans += i+1;
      }
    }
  }else{
    ll cnt[100000] = {0};
    cnt[0] = 1;
    int amari = 0;
    int ten(1);
    for(int i(N-1);i>=0;i--){
      amari += (s[i]-'0')*ten;
      amari %= P;
      cnt[amari]++;
      ten *= 10;ten%=P;
    }
    // for(int i(0);i<N;i++){
    //   if(s[i]-'0' == P) ans++;
    // }
    //cnt[amari]++;
    for(int i(0);i<P;i++){
      //cout << cnt[i] << endl;
      ans += (cnt[i]-1)*(cnt[i])/2;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1412
#include <cstdint>
#include <iostream>
#include <string.h>

using namespace std;

int32_t main()
{
  char str[200];

  cin >> str;

  uint32_t n = strlen(str);

  for (uint32_t i = n - 2; i > 0; i -= 2) {
    if (strncmp(str, str + (i / 2), i / 2) == 0) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 384
# 2019/09/18

n=int(input())
a=list(map(int,input().split()))
cnt=0
minus=0
suma=0
mina=float('inf')
for i in range(n):
    if a[i]<0:
        minus+=1
    suma+=abs(a[i])
    mina=min(mina,abs(a[i]))

ans=suma
if minus%2 and 0 not in a:
    ans-=mina*2
print(ans)

Measured memory_bytes: 14412
// Example program
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 2e5 + 1;

typedef long long int ll;

ll dp[MAXN];
ll a[MAXN];
ll b[MAXN];
ll c[MAXN];


int main()
{
    ll n;
    cin >> n;
    for (ll i = 0 ; i < n; i++)
    {
        cin >> a[i];
        c[a[i]] = i;
    }
    ll cnt = 0;
    b[cnt] = a[0];
    cnt++;
    ll m = a[0];
    dp[a[0]] = a[0];
    for (int i = 1; i < n; i++)
    {
        ll x = c[a[i]] - c[b[cnt - 1]];
        while (cnt > 0)
        {
            if (b[cnt - 1] < a[i])
            {
                dp[a[i]] = (x * a[i]) + dp[b[cnt - 1]];
                break;
            }
            else
            {
                if (cnt > 1)
                {
                    x += c[b[cnt - 1]] - c[b[cnt - 2]];
                }
                else
                    x += c[b[cnt - 1]] + 1;
                cnt--;
            }
        }
        if (cnt == 0)
        {
            dp[a[i]] = (x * a[i]);
        }
        m += dp[a[i]];
        b[cnt] = a[i];
        cnt++;
    }
    cout << m;
}


Measured memory_bytes: 6528
# Trick or Treat
N, K = map(int,input().split())
sweets = [0]*N
for _ in range(K):
    d = int(input())
    A = list(map(int,input().split()))
    for a in A:
        sweets[a-1] += 1
ans = sum([e == 0 for e in sweets])
print(ans)

Measured memory_bytes: 9104
def solve():
    S= input()
    ue = int(S[:2])
    sita = int(S[2:])

    ueok = 1 <= ue <= 12
    sitaok = 1 <= sita <= 12
    if ueok and sitaok:
        print("AMBIGUOUS")
    elif not ueok and sitaok:
        print("YYMM")
    elif ueok and not sitaok:
        print("MMYY")
    else:
        print("NA")

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=1000000007;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}


int main(void){
    double L;
    cin>>L;
    double X=L/3;
    cout<<fixed<<setprecision(15)<<X*X*X<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int data[10],n,a;
	while(cin>>n,n){
		memset(data,0,sizeof(data));
		for(int i=0;i<n;i++){
			cin>>a;
			data[a]++;
		}
		for(int i=0;i<10;i++){
			if(data[i]==0){
				cout<<"-"<<endl;
			}else{
				for(int j=0;j<data[i];j++){
					cout<<"*";
				}
				cout<<endl;
			}
		}
	}
}

Measured memory_bytes: 1152
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#define ordered_set tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;
#define deb1a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
        cout << it << " ";        \
    cout << endl;
#define deb2a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        for (auto it1 : it)       \
        {                         \
            cout << it1 << " ";   \
        }                         \
        cout << endl;             \
    }
#define deb3a(v)                               \
    cout << #v << "-->" << endl;               \
    for (auto it : v)                          \
    {                                          \
        cout << it.fi << " " << it.se << endl; \
    }
#define mod 1000000007
#define so(v) sort(v.begin(), v.end())
#define fi first
#define se second
#define db1(x) cout << #x << "=" << x << endl
#define db2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int mI(int a, int m)
{
    return power(a, m - 2, m);
}
vector<vector<int>> dir = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};



void solve()
{
    int d, t, s;
    cin >> d >> t >> s;
    if(s*t>=d){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    srand(time(0));

    // FILE *fin = freopen("ip.txt","r",stdin);
    // FILE *fout = freopen("op.txt","w",stdout);
    int t = 1, nn = 1;
    //cin >> t;
    while (t--)
    {
        // cout << "Case #" << nn << ":"
        //      << " ";
        // nn++;
        solve();
       
    }
}

Measured memory_bytes: 3656
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


def cumsum(li):
    ret = []
    sum = 0
    for i in li:
        sum += i
        ret.append(sum)
    return ret


# 解説AC
N = int(sys.stdin.readline())
A = [int(sys.stdin.readline()) for _ in range(N)]

# dp[i]: i まで見たときの答えの最小値
# dp[i][0]: どこも通ってない
# dp[i][1]: D まで通った
# dp[i][2]: S まで通った
# dp[i][3]: T まで通った
# dp[i][4]: U まで通った
dp = [[0] * 5 for _ in range(N)]
for i, a in enumerate(cumsum(A)):
    dp[i][0] = a
dp[0][1] = int((A[0] % 2 != 0) + (A[0] == 0) * 2)
dp[0][2] = int(A[0] % 2 != 1)
dp[0][3] = int((A[0] % 2 != 0) + (A[0] == 0) * 2)
dp[0][4] = A[0]

for i in range(1, N):
    dp[i][ 1] = min(dp[i - 1][ :1 + 1]) + int((A[i] % 2 != 0) + (A[i] == 0) * 2)
    dp[i][ 2] = min(dp[i - 1][ :2 + 1]) + int(A[i] % 2 != 1)
    dp[i][ 3] = min(dp[i - 1][ :3 + 1]) + int((A[i] % 2 != 0) + (A[i] == 0) * 2)
    dp[i][ 4] = min(dp[i - 1][ :4 + 1]) + A[i]
print(min(dp[-1]))


Measured memory_bytes: 88788
//
//AtCoder Beginner Contest 142
//A - Odds of Oddness
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int n;

    cin >> n;

    cout << fixed;
    cout << setprecision(12) <<  (double)(n%2+n/2)/(double)n << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int h = sc.nextInt();
		int n = sc.nextInt();
		int totalx;
		int totaly;
		int [][] kanko = new int[n][2];
		for(int i = 0; i < n; i++){
			kanko [i][0] = sc.nextInt();
			kanko [i][1] = sc.nextInt();
		}
		int x = kanko [0][0];
		int y = kanko [0][1];
		int answer = 0;
		int total;
		for(int i = 1;i < n;i++){
			if(kanko[i][0] - x > 0 && kanko[i][1] - y > 0){
				for(;;){
					x++;
					y++;
					answer++;
					if(kanko[i][0] == x || kanko[i][1] == y){
						break;
					}
				}
			}
			else if (kanko[i][0] - x < 0 && kanko[i][1] - y < 0){
				for(;;){
					x--;
					y--;
					answer++;
					if(kanko[i][0] == x || kanko[i][1] == y){
						break;
					}
				}
			}
			totalx = kanko[i][0] - x;
			totaly = kanko[i][1] - y;
			if(totalx < 0){
				totalx *= -1;
			}
			if(totaly < 0){
				totaly *= -1;
			}
			total = totalx + totaly;
			answer += total;
			x = kanko[i][0];
			y = kanko[i][1];
		}
		System.out.println(answer);
	}

}

Measured memory_bytes: 25664
inputstr1 = input().split()
n = inputstr1[0]
k = inputstr1[1]
s = input()

k = int(k)
moji = s[(k-1):k]              #mojiという変数に変換したい文字を入れる
moji = str.lower(moji)         #小文字にする
s = s[:(k-1)] + moji + s[k:]   #連結する
k = str(k)

print(s)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i < n + 1; i++)
    {
        ans += i;
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    char cake[h][w];
    int used[h][w] = {0}, index[h] = {-1}, tmp = 0;
    vector <bool> here(h, false);

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> cake[i][j];
            if (cake[i][j] == '#') {
                here[i] = true;
            }
        }
    }
    int first;
    for (int i = 0; i < h; i++) {
        if (here[i]) {
            first = i;
            break;
        }
    }
    int now = first;
    int num = 1, cnt = 0;
    for (int i = 0; i < h; i++) {
        if (here[i]) now = i;
        else index[i] = now;
    }

    //for (int i = 0; i < h; i++) cout << index[i] << endl;

    for (int i = 0; i < h; i++) {
        cnt = 0;
        if (here[i]) {
            for (int j = 0; j < w; j++) {
                if (cake[i][j] == '#') {
                    cnt++;
                    if (cnt > 1) num++;
                }
                used[i][j] = num;
            }
            num++;
        }
    }

    for (int i = 0; i < h; i++) {
        if (!here[i]) {
            for (int j = 0; j < w; j++) {
                used[i][j] = used[index[i]][j];
            }
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << used[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1280
N = gets.to_i
A = gets.split.map(&:to_i)

counts = A.inject({}) {|acc, i|
  acc[i] ||= 0
  acc[i] += 1
  acc
}.select {|_k, v| v >= 2 }

all = counts.inject(0) {|acc, (k, v)|
  acc + v * (v - 1) / 2
}

A.each do |i|
  c = counts[i]
  if c && 1 < c
    puts all - ((c * (c - 1) / 2) - ((c - 1) * (c - 2) / 2))
  else
    puts all
  end
end

Measured memory_bytes: 34060
#include<bits/stdc++.h>
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000007
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vii vector<int>
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define plll pair<ll,pll>
#define vpll vector<pll>
using namespace std;
typedef long long int ll;

ll powerstore[100010];

void initialise()
{
    powerstore[0]=1;
    for(ll i=1;i<100010;i++)
    {
        powerstore[i]=(powerstore[i-1]*10)%13;
    }
    return;
}

ll dp[100010][13];
ll len;
string str;

ll solve(ll idx,ll rem)
{
    if(idx==len)
    {
        if(rem==5)
        {
            return 1;
        }
        return 0;
    }
    if(dp[idx][rem]!=-1)
    {
        return dp[idx][rem];
    }    
    ll ans=0,store;
    if(str[idx]!='?')
    {
        store=(str[idx]-'0');
        store=(store*powerstore[idx])%13;
        ans=solve(idx+1,(rem+store)%13);
    }
    else
    {
        store=0;
        for(ll i=0;i<10;i++)
        {
            ans=(ans+solve(idx+1,(rem+store)%13));
            if(ans>=MOD)
            {
                ans-=MOD;
            }
            store=(store+powerstore[idx])%13;
        }
    }
    dp[idx][rem]=ans;
    return ans;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    memset(dp,-1,sizeof(dp));
    initialise();

    cin>>str;
    reverse(str.begin(),str.end());
    len=str.size();
    ll ans=solve(0,0);
    cout<<ans;
    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

#define maxn 300005

int vis[maxn] ;
vector <int> g[maxn] , ans[maxn] ;

int dfs(int u, int par)
{
    vis[u] = 1 ;

    bool fl = 0 ;

    for(int i=0 ; i<g[u].size() ; i++)
    {
        int v = g[u][i] ;

        if(v==par) continue ;

        if( vis[v]==1 )
        {
            fl ^= 1 ;
            ans[u].pb(v) ;
            continue ;
        }
        if(vis[v]==2) continue ;
        if( dfs(v,u) == 0 )
        {
            fl ^= 1 ;
            ans[u].pb(v) ;
        }
    }
    if(fl)
    {
        ans[u].pb(par) ;
    }

    vis[u] = 2 ;

    return fl ;
}

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

    for(int i=1 ; i<=m ; i++)
    {
        int u , v ;
        scanf("%d %d",&u,&v) ;
        g[u].pb(v) ; g[v].pb(u) ;
    }

    if(m%2)
    {
        printf("-1\n") ;
        return 0 ;
    }

    dfs(1,0) ;

    for(int i=1 ; i<=n ; i++)
    {
        for(int j=0 ; j<ans[i].size() ; j++ ) printf("%d %d\n" , i , ans[i][j] ) ;
    }

    return 0 ;
}


Measured memory_bytes: 29952
import java.util.*;
public class Main {

	public void doIt(){
		Scanner sc = new Scanner(System.in);

		while(sc.hasNext()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			int x = a;
			int y = b;
			if(x < y){
				int temp = x;
				x = y;
				y = temp;
			}
			//ツ催妥・ツ古カツ姪アツ青板づーツ仰づ淞づゥ
			while(y != 0){
				int temp = x % y;
				x = y;
				y = temp;
			}
			long lcm = (long)a * b / x;
			System.out.println(x + " " + lcm);

		}
	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();

	}

}

Measured memory_bytes: 12000