akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <bitset>
#include <sstream>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <climits>
#include <ctype.h>
using namespace std;

#define PI acos(-1.0)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second

#define eps 1e-8
#define mod 1000000007

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<int>> vvi;

struct Matrix {
    vvi data;
    int r, c;
    Matrix(int row, int col, bool identity = false) : r(row), c(col) {
        data.assign(row, vector<int>(col, 0));
        if (identity) {
            for (int i = 0; i < r; ++i) {
                data[i][i] = 1;
            }
        }
    }
    Matrix operator * (Matrix& other) {
        int m = r, n = c, p = other.c;
        Matrix res(m, p);
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < p; ++j) {
                for (int k = 0; k < n; ++k) {
                    res.data[i][j] += data[i][k] * other.data[k][j];
                }
            }
        }
        return res;
    }
};

// 扩展欧几里得算法 res[1] * a + res[2] * b = res[0] = gcd(a, b)
vector<int> extendGcd(int a, int b) {
    if (b == 0) {
        return {a, 1, 0};
    } else {
        vector<int> tmp = extendGcd(b, a % b);
        return {tmp[0], tmp[2], tmp[1] - (a / b) * tmp[2]};
    }
}

// 矩阵快速幂
Matrix matrix_power(Matrix base, ll exp) {
    int n = base.r;
    Matrix res(n, n, true);
    while (exp) {
        if (exp & 1) {
            res = res * base;
        }
        base = base * base;
        exp >>= 1;
    }
    return res;
}

// 带模快速幂
ll power_mod(ll base, int exp) {
    ll res = 1;
    while (exp) {
        if (exp & 1) res = res * base % mod;
        base = base * base % mod;
        exp >>= 1;
    }
    return res;
}

// 快速幂
ll power(ll base, int exp) {
    ll res = 1;
    while (exp) {
        if (exp & 1) res *= base;
        base *= base;
        exp >>= 1;
    }
    return res;
}

// 求逆元
ll inv(ll a) {
    return power_mod(a, mod - 2);
}

#define MAXFAC 100010

ll fac[MAXFAC];

void initFac() {
    fac[0] = 1;
    for (int i = 1; i < MAXFAC; ++i) {
        fac[i] = i * fac[i - 1] % mod;
    }
}

ll Combine(ll a, ll b) {
    return (fac[a] * inv(fac[b]) % mod) * inv(fac[a - b]) % mod;
}

/******************************** template ********************************/
#define MAXN 200010
int n, m;
unordered_set<int> s1, s2;

int main() {
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        if (a == 1) {
            s1.insert(b);
        } else if (b == n) {
            s2.insert(a);
        }
    }

    for (int i : s1) {
        if (s2.find(i) != s2.end()) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }

    cout << "IMPOSSIBLE";

    return 0;
}

Measured memory_bytes: 8520
import sys
# スペース区切りの整数入力
N,M = map(int, input().split())

sc = {}
snum = '0' * N

for i in range(M):
    s,c = map(int, input().split())
    if s in sc:
        if c != sc[s]:
            print(-1)
            sys.exit()
    sc[s] = c

for i in sc:
    snum = snum[:i-1] + str(sc[i]) + snum[i:] 

if N == len(str(int(snum))):
    print(snum)
else:
    if 1 in sc:
        print(-1)
    else:
        print("1"+snum[1:])



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e1+1;
const ll p=1e9+7;
int a[N]={0,0,2,0,1,0,1,0,0,1,0,1,0};
int main()
{
    int x,y;
    cin>>x>>y;
    if(a[x]==a[y])cout<<"Yes";
    else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]
c = [list(map(int, input().split())) for _ in range(N)]
sum_val = [[0] * C for _ in range(3)]

for color in range(1, C + 1):
    for i in range(N):
        for j in range(N):
            sum_val[(i + j) % 3][color - 1] += D[c[i][j] - 1][color - 1]

ans = float('inf')
for i in range(C):
    for j in range(C):
        for k in range(C):
            if i == j or j == k or i == k:
                continue
            ans = min(ans, sum_val[0][i] + sum_val[1][j] + sum_val[2][k])
print(ans)

Measured memory_bytes: 76256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    string S[310];
    rep(i, N) cin >> S[i];
    int ans = 0;
    rep(A, N) {
        bool ok = true;
        rep(i, N) {
            rep(j, N) {
                if(S[(i + A) % N][(j + 0) % N] != S[(j + A) % N][(i + 0) % N]) ok = false;

            }
        }
        if(ok) {
            //cout << A << " " << B << endl;
            ans += N;
        }
    }
    cout << ans << endl;


    return 0;
}
// abab 
// caca 
// abab
// caca

// (i, j) (j, i)
// (i + a, j + b), (j + a, i + b)


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define INF 200000
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int N, M; cin >> N >> M;
    vector<int> check(N, INF);
    int a, b;
    rep(i, M) {
        cin >> a >> b;
        a--; b--;
        chmin(check[min(a, b)], max(a, b));
    }
    int tmp = check[0], cnt = 0;
    rep2(i, 1, N) {
        if (tmp == i) {
            cnt++;
            tmp = check[i];
        }
        else if (tmp > check[i]) {
            tmp = check[i];
        }
    }
    cout << cnt << endl;
}


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

int main(void){
    int n;
    cin >> n;
    
    int c_t = 0, c_x = 0, c_y = 0;
    int n_t, n_x, n_y;
    int dist;
    int i;
    for(i = 1; i <= n; i++){
        cin >> n_t >> n_x >> n_y;
        dist = abs(n_x - c_x) + abs(n_y - c_y);
        if(!(dist <= n_t - c_t && (dist + n_t - c_t) % 2 == 0)){
            cout << "No" << endl;
            return 0;
        }
        c_t = n_t;
        c_x = n_x;
        c_y = n_y;
    }
    
    cout << "Yes" << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		char[] temp = new char[str.length()];
		for(int i=0;i<str.length();i++){
			temp[i] = str.charAt(i);
			for(int j=0;j<i;j++){
				if(temp[j] == temp[i]){
					System.out.println("no");
					return;
				}
			}
		}
		System.out.println("yes");
	}

}


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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double


// ABC065B - Trained?
int main(){
  int N; // 2 <= N <= 1e5
  cin >> N;
  VECTOR_DIM1(int, ai, N+1, 0);
  bool has2 = false;
  rep(i, N) {
    cin >> ai[i+1];
    if (ai[i+1] == 2) {
      has2 = true;
    }
  }
  if (!has2) {
    cout << -1 << endl;
    return 0;
  }
  // 1度押したのに到達すると、ループするので-1

  // dp[i] = ボタンiが光るのに必要な最小回数
  VECTOR_DIM1(int, dp, N+10, INT_MAX);
  dp[1] = 0; // 最初からボタン1が光っている

  // dp[2] に 有効な数字があれば、それが答え
  bool loop = true;
  int pos = 1, bpos = 1;
  rep(i, N) {
    bpos = pos;
    pos = ai[pos];
    if (dp[pos] != INT_MAX) {
     // cout << "再訪" << endl;
      break; // 再訪
    }
    dp[pos] = dp[bpos] + 1;
    if (pos == 2) {
      //cout << "pos2 i:" << i << ",pos:" << pos << endl;
      break;
    }
    //cout << "i:" << i << ",pos:" << pos << endl;
  }

  cout << ((dp[2] < INT_MAX) ? dp[2] : -1) << endl;
  return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#include <string>
#include <unordered_map>

using namespace std;

// stringをintに
// string a = "123";
// stoi(a)
//
// intをstringに
// int a = 123;
// to_string(a)
//
// charをintに
// char a = '1';
// (int)a - 48 // asciiコードを値にする

vector<int> alphabetCount(string input) {
  vector<int> arr(26, 0);
  for (int i = 0; i < (int)input.size(); i++) {
    arr.at((int)(input.at(i))-96) += 1;
  }
  return arr;
}

// 配列Aにcinする
int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
  unordered_map<string, int> mp;

  int64_t counter = 0;
  for (int i = 0; i < N; i++) {
    sort(S[i].begin(), S[i].end());
    if(mp[S[i]] != 0) counter += mp[S[i]];
    mp[S[i]]++;
    //for (int j = i + 1; j < N; j++) {
    //  sort(S[j].begin(), S[j].end());
    //  if (S[i] == S[j]) {
    //    counter++;
    //  }
    //}
  }
  //for (auto it = mp.begin(); it != mp.end(); ++it) {
  //  // cout << it->second << endl;
  //  sum+=it->second;
  //  //for (int j = it->second - 1; j >= 2; j--) {
  //  //  sum+=it->second;
  //  //}
  //}

  //int sum = 0;
  //for (int i = 0; i < (int)S.size(); i++) {
  //  sort(S[i].begin(), S[i].end());
  //  int c = 0;
  //  for (int j = i + 1; j < N; j++) {
  //    sort(S[j].begin(), S[j].end());
  //    if (S[i] == S[j]) {
  //      c++;
  //      vector<string>::iterator result = find(S.begin(), S.end(), S[j]);
  //      S.erase(result);
  //    }
  //  }
  //  cout << c << endl;
  //  for (int k = c-1; k >= 2; k--) {
  //    sum++;
  //  }
  //}
  cout << counter << endl;
  return 0;
}

// 標準入出力
//int main() {
//	int K, X;
//	cin >> K >> X;
//  for (int i = (X - K + 1); i < X + K; i++) {
//    cout << i << ' ';
//  }
//  cout << endl;
//  return 0;
//}

// 文字列を1文字ずつループ
//int main() {
//  string str;
//  cin >> str;
//  int sum = 0;
//  for(int i = 0; i < (int)str.size(); ++i){
//    char ch = str[i];
//
//    if (ch == '1') {
//      sum++;
//    }
//  }
//  cout << sum << endl;
//  return 0;
//}



Measured memory_bytes: 17700
W, H, N = map(int, input().split())
x_l, x_r, y_l, y_r = 0, W, 0, H
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        x_l = max(x_l, x)
    elif a == 2:
        x_r = min(x_r, x)
    elif a ==3:
        y_l = max(y_l, y)
    else:
        y_r = min(y_r, y)
if x_l >= x_r or y_l >= y_r:
    print(0)
    exit()
print((x_r-x_l)*(y_r-y_l))


Measured memory_bytes: 3060
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

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

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

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

fn main() {
    input!{
        n: usize,
        m: usize,
        lr: [(usize1, usize1); m],
    }
    let mut cnt = vec![0i64; n+1];
    for (l, r) in lr {
        cnt[l] += 1;
        cnt[r+1] -= 1;
    }
    for i in 0..n {
        if (0 < i) {
            cnt[i] += cnt[i - 1];
        }
    }
    let ans = cnt.iter().filter(|&x| *x as usize == m).count();
    println!("{}", ans);
}


Measured memory_bytes: 6396
n=int(input())
arr=list(map(int,input().split()))
cnt=0
for i in range(n):
  for j in range(n-1,i,-1):
    if arr[j]<arr[j-1]:
      cnt+=1
      arr[j],arr[j-1]=arr[j-1],arr[j]
print(' '.join(map(str,arr)))
print(cnt)


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

int main( int argc, char **argv ) {

  int h[10] = {0};
  int i;
  int j;
  int temp;
  
  for (i = 0; i < 10; ++i) {
    scanf("%d", &h[i]);
  }
  
  for (i = 0; i < 9; ++i) {
    for (j = i + 1; j < 10; ++j) {
      if (h[i] < h[j]) {
        temp = h[i];
        h[i] = h[j];
        h[j] = temp;
      }
    }
  }

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

Measured memory_bytes: 0
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

const INF: i64 = 1_000_000_000_000;

fn main() {
    let n: i64 = read();
    let s: i64 = read();


    let b0 = solveSmall(n, s);
    let b1 = solveLarge(n, s);


    if min(b0, b1) == INF {
        println!("-1");
    } else {
        println!("{}", min(b0, b1));
    }
}

fn solveSmall(n: i64, s: i64) -> i64 {
    for b in 2..n+1 {
        if b * b > n {
            break
        }
        if f(n, b) == s {
            return b;
        }
    }
    INF
}

fn f(n: i64, b: i64) -> i64 {
    let mut nn = n;
    let mut sum = 0;
    while nn >= 1 {
        sum += nn % b;
        nn /= b;
    }
    sum
}

fn solveLarge(n: i64, s: i64) -> i64 {
    if n == s {
        return n + 1;
    }

    let am1 = n - s;
    let mut best = INF;
    for a in 1..(am1+1) {
        if a * a > am1 {
            break
        }
        if am1 % a != 0 {
            continue
        }
        let m = am1 / a + 1;
        if f(n, m) == s {
            best = min(best, m);
        }
    }
    best
}


Measured memory_bytes: 4476
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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;}

int N=100000;
vector<int> node(N);
map<int, int> mp;
void init(int n)
{
	for (int i = 0; i < n; i++)
	{
		node[i] = i;
		mp[i]++;
	}
}
int root(int x)
{
	return node[x] == x ? x : node[x] = root(node[x]);
}
bool same(int x, int y)
{
	return root(x) == root(y);
}

void unite(int x, int y)
{
	x = root(x);
	y = root(y);
	if (x == y)
	{
		return;
	}
	node[x] = y;
	mp[y] += mp[x];
	mp[x] = 0;
}

int size(int x){
	return node[x] == x ? mp[x]:size(node[x]);
}
int main(){
	ll n,m;
	cin >> n >> m;
	init(n);
	vector<int> a(m);
	vector<int> b(m);
	REP(i,m){
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
	}
	vector<ll> ans(m);
	ans[m-1]=n*(n-1)/2;
	IREP(i,m-1){
		if(same(a[i+1],b[i+1])){
			ans[i]=ans[i+1];
		}
		else{
			ans[i]=ans[i+1]-size(a[i+1])*size(b[i+1]);
		}
		unite(a[i+1], b[i+1]);
	}
	REP(i,m){
		cout << ans[i] << endl;
	}
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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; }

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

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

  string s;
  cin >> s;

  string t = "";

  rep(i, s.length()){
    if(s[i] != 'x'){
      t += s[i];
    }
  }

  // check
  int m = t.length();
  rep(i, t.length()/2){
    if(t[i] != t[m-1-i]){
      cout << -1 << endl;
      return 0;
    }
  }

  vector<int> cntx((m+1)/2);

  int cnt = 0;
  int now = 0;
  while(cnt < (m+1)/2){

    if(s[now] == 'x'){
      cntx[cnt]++;
      now++;
    }else{
      cnt++;
      now++;
    }
  }

  now = s.length()-1;
  cnt = 0;

  while(cnt < (m+1)/2){
    if(s[now] == 'x'){
      cntx[cnt]--;
      now--;
    }else{
      cnt++;
      now--;
    }
  }

  int ans = 0;
  rep(i, cntx.size()){
    ans += abs(cntx[i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 848
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 205
#define SIZE 105

int N;
int table[SIZE],from_index[SIZE],to_index[SIZE];

int V;
vector<int> G[NUM];
int match[NUM];
bool used[NUM];

void add_edge(int from,int to){
	G[from].push_back(to);
	G[to].push_back(from);
}

int dfs(int node_id){
	used[node_id] = true;

	for(int i = 0; i < G[node_id].size(); i++){
		int adj_node_id = G[node_id][i],pair_id = match[adj_node_id];
		if((pair_id < 0)||
				(used[pair_id] == false && dfs(pair_id) == true)){

			match[node_id] = adj_node_id;
			match[adj_node_id] = node_id;
			return true;
		}
	}
	return false;
}


int bipartie_matching(){
	int ret = 0;
	for(int i = 0; i < V; i++)match[i] = -1;
	for(int node_id = 0; node_id < V; node_id++){
		if(match[node_id] < 0){
			for(int i = 0; i < V; i++)used[i] = false;
			if(dfs(node_id)){
				ret++;
			}
		}
	}
	return ret;
}

void init(){
	for(int i = 0; i < NUM; i++){
		G[i].clear();
	}
}

int func(vector<int> ARRAY){

	if(ARRAY.size() == 0)return 0;

	init();

	int num_nodes = (int)ARRAY.size();

	int index = 0;

	for(int i = 0; i < num_nodes; i++)from_index[i] = index++;
	for(int i = 0; i < num_nodes; i++)to_index[i] = index++;

	for(int i = 0; i < num_nodes; i++){
		for(int k = 0; k < num_nodes; k++){
			if(ARRAY[k] >= ARRAY[i])continue;

			if(ARRAY[i]%ARRAY[k] == 0){
				add_edge(from_index[i],to_index[k]);
			}
		}
	}

	V = index;

	return num_nodes-bipartie_matching();
}

int main(){

	scanf("%d",&N);

	vector<int> ARRAY;

	for(int i = 0; i < N; i++){
		scanf("%d",&table[i]);
		ARRAY.push_back(table[i]);
	}

	int ans_value =func(ARRAY);

	bool FLG;
	vector<int> ans_V;

	bool check[N];
	for(int i = 0; i < N; i++)check[i] = true;

	int ans_num = 0;

	for(int base = 0; base < N; base++){

		FLG = true;
		for(int i = 0; i < ans_V.size(); i++){
			if(table[ans_V[i]]%table[base] == 0 || table[base]%table[ans_V[i]] == 0){
				FLG = false;
				break;
			}
		}
		if(!FLG)continue;

		ARRAY.clear();

		for(int i = 0; i < N; i++){
			if(check[i] == true && (table[i]%table[base] != 0 && table[base]%table[i] != 0)){
				ARRAY.push_back(table[i]);
			}
		}

		ans_num++;

		if(ans_num+func(ARRAY) == ans_value){
			ans_V.push_back(base);

			for(int i = 0; i < N; i++){
				if(table[i]%table[base] == 0 || table[base]%table[i] == 0){
					check[i] = false;
				}
			}
		}else{
			ans_num--;
		}
	}

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

	return 0;
}



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

int main()
{
    bool a[4][13] = {};
    unordered_map<char, bool *> holder_dictionary{};
    holder_dictionary['S'] = a[0];
    holder_dictionary['H'] = a[1];
    holder_dictionary['C'] = a[2];
    holder_dictionary['D'] = a[3];

    int n;
    char type;
    int index;
    cin >> n;
    while (cin >> type >> index)
    {
        holder_dictionary[type][index-1] = true;
    }
    for (auto x : {'S', 'H', 'C', 'D'})
    {
        for (int i = 0; i < 13; i++)
        {
            if (!holder_dictionary[x][i])
            {
                cout << x << " " << i + 1 << endl;
            }
        }
    }
}


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

int main(){
  char c;
  cin >> c;
  
  if(c == 'a' or c == 'i' or c == 'u' or c == 'e' or c == 'o'){
    cout << "vowel" << endl;
  }
    
    else{
      cout << "consonant" << endl;
    }
  }

Measured memory_bytes: 3568
A = input()
B = input()
if (len(A) > len(B)):
  print('GREATER')
elif (len(A) < len(B)):
  print('LESS')
else:
  i = 0
  while (i < len(A)):
    if (int(A[i]) == int(B[i])):
      i += 1
    elif (int(A[i]) < int(B[i])):
      i = -1
      break
    else:
      i = -2
      break
  if (i == -1):
    print('LESS')
  elif (i == -2):
    print('GREATER')
  else:
    print('EQUAL')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl;
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int k; cin >> k;
    if(k == 4 || k == 6 || k== 9 || k== 10 || k == 14 || k == 21 || k == 22 || k == 25 || k == 26){dunk(2);}
    else if(k == 8 || k == 12 || k == 18 || k == 20 || k == 27) {dunk(5);}
    else if(k == 16) {dunk(14);}
    else if(k == 24) {dunk(15);}
    else if(k == 28 || k == 30) {dunk(4);}
    else if(k == 32) {dunk(51);}

    else {dunk(1);}

}


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

lunlun_number_list = []

def dfs(N):
    lunlun_number_list.append(N)
    if len(str(N)) > 10:
        return
    now_int = int(str(N)[-1])
    if now_int == 0:
        for i in range(2):
            dfs(N*10 + i)
    elif now_int == 9:
        for i in range(8, 10, 1):
            dfs(N*10 + i)
    else:
        for i in range(now_int-1, now_int+2, 1):
            dfs(N*10 + i)

for i in range(1, 10, 1):
    dfs(i)

lunlun_number_list.sort()
print(lunlun_number_list[K-1])


Measured memory_bytes: 40760
package main

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

func makeSuffixArray(s string) []int {
	n := len(s)
	sa := make([]int, n)
	for i := 0; i < n; i++ {
		sa[i] = i
	}
	rnk := make([]int, n)
	for i, b := range []byte(s) {
		rnk[i] = int(b)
	}
	tmp := make([]int, n)

	for k := 1; k < n; k *= 2 {
		cmp := func(x, y int) bool {
			if rnk[sa[x]] != rnk[sa[y]] {
				return rnk[sa[x]] < rnk[sa[y]]
			}
			rx, ry := -1, -1
			if sa[x]+k < n {
				rx = rnk[sa[x]+k]
			}
			if sa[y]+k < n {
				ry = rnk[sa[y]+k]
			}
			return rx < ry
		}
		sort.Slice(sa, cmp)
		tmp[sa[0]] = 0
		for i := 1; i < n; i++ {
			tmp[sa[i]] = tmp[sa[i-1]]
			if cmp(i-1, i) {
				tmp[sa[i]]++
			}
		}
		tmp, rnk = rnk, tmp
	}
	return sa
}

func makeLcpArray(s string, sa []int) []int {
	b := []byte(s)
	n := len(s)
	rnk := make([]int, n)
	for i := 0; i < n; i++ {
		rnk[sa[i]] = i
	}
	lcp := make([]int, n-1)
	h := 0
	for i := 0; i < n; i++ {
		if h > 0 {
			h--
		}
		if rnk[i] == 0 {
			continue
		}
		j := sa[rnk[i]-1]
		for j+h < n && i+h < n {
			if b[j+h] != b[i+h] {
				break
			}
			h++
		}
		lcp[rnk[i]-1] = h
	}
	return lcp
}

func main() {
	defer flush()

	S := readString()
	sa := makeSuffixArray(S)

	result := len(S) * (len(S) + 1) / 2
	la := makeLcpArray(S, sa)
	for _, x := range la {
		result -= x
	}
	println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


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

using namespace std;

#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    FAST();
    string s;
    cin >> s;
    if(s[0] <= 'Z')cout << "A";
    else cout << "a";
    return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e18;
const ll MOD=1e9+7;

struct segtree{
    vector<ll> dat;
    int size;
    segtree(int n):dat(2*n-1,(1LL<<31)-1),size(n){};
    void update(int i,ll a){
        i+=this->size-1;
        dat[i]=a;
        while(i>0){
            i=(i-1)/2;
            dat[i]=min(dat[i+2+1],dat[i*2+2]);
        }
    }
    ll query(int a,int b){
        return querysub(a,b,0,0,this->size);
    }
    ll querysub(int a,int b,int k,int l,int r){
        if(r<=a||b<=l) return (1LL<<31)-1;
        else if(a<=l&&r<=b) return dat[k];
        else{
            ll vl=querysub(a,b,k*2+1,l,(l+r)/2);
            ll vr=querysub(a,b,k*2+2,(l+r)/2,r);
            return min(vl,vr);
        }
    }
};
int main(){
    int k;cin>>k;
    vector<bool> rem(k,false);
    ll tmp=7;
    int cnt=1;
    while(true){
        if(rem[tmp%k]){
            cout<<-1<<endl;
            return 0;
        }
        if(tmp%k==0){
            cout<<cnt<<endl;
            return 0;
        }
        rem[tmp%k]=true;
        tmp=(tmp*10+7)%k;
        cnt++;
    }
}

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

#define LOOP(val,times) for(val = 0;val < (times);++val)


int lcs(string X, string Y){
    int dp[1010][1010];
    int i,j;
    LOOP(i,1010){
        dp[0][i] = 0;
        dp[i][0] = 0;
    }
    LOOP(i,Y.size()){
        LOOP(j,X.size()){
            if(X[j] == Y[i]){
                dp[i+1][j+1] = dp[i][j] + 1;
            }
            else{
                dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j]);
            }
        }
    }
    return dp[Y.size()][X.size()];    
}

int main(){
    int i,q;
    cin >> q;
    LOOP(i,q){
        string X,Y;
        cin >> X >> Y;
        cout << lcs(X,Y) << endl;
    }
    int k;cin >> k;
}


Measured memory_bytes: 7196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=3e3+10;
struct node{
    int w,v;
    bool operator<(const node &a)const{
        return w<a.w;
    }
}a[maxn];
int dp[maxn][6010];
int main(){
    int n,t;
    scanf("%d%d",&n,&t);
    for(int i=1;i<=n;i++)scanf("%d %d",&a[i].w,&a[i].v);
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++){
        for(int j=a[i].w+t-1;j>=0;j--){
            if(j>=a[i].w)
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-a[i].w]+a[i].v);
            else dp[i][j]=dp[i-1][j];
        }
    }
    int maxx=0;
    for(int i=1;i<=n;i++)maxx=max(maxx,dp[i][t+a[i].w-1]);
    printf("%d\n",maxx);
    return 0;
}


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

long long int cnt[1050000 * 2] = {0};
long long int as[1050000 * 2] = {0};

int main() {

  long long int n, q;

  cin >> n >> q;
  
  long long int n2 = 1;
  while(n2 < n){
    n2 *= 2;
  }

  for(int i = 0; i < n2; i++){
    as[i + (n2- 1)] = i + 1;
  }

  for(int query = 0; query < q; query++){
    long long int a = 0;
    long long int v = 0;

    cin >> a >> v;
    a--;

    long long int index = a + (n2 - 1);
    cnt[index] += v;

    do{
      index = (index - 1) / 2;
      
      long long int left  = index * 2 + 1;
      long long int right = index * 2 + 2;
      
      if(cnt[left] >= cnt[right]){
	cnt[index] = cnt[left];
	as[index] = as[left];
      }else if(cnt[left] < cnt[right]){
	cnt[index] = cnt[right];
	as[index] = as[right];
      }

    }while(index > 0);   
    
    cout << as[0] << " " << cnt[0] << endl;
  }

  return 0;

}

Measured memory_bytes: 33848
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	string s;
	cin>>s;
	string t=s;
	reverse(all(t));
	if(s!=t){
		cout<<"No";
		re 0;
	}
	s=s.substr(0,(s.size()-1)/2);
	t=s;
	reverse(all(t));
	if(s!=t){
		cout<<"No";
	}
	else{
		cout<<"Yes";
	}
	re 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	
	public boolean stringMach(char[] base,String boardStr) {
		int boardStrlen = boardStr.length()-1; 
		int baseIndex = 0;
		for(int i=0;i<boardStrlen;i++){
			if(base[baseIndex]==boardStr.charAt(i)){
				baseIndex++;
				for(int j=i+1;j<boardStrlen;j++){
					if(base[baseIndex]==boardStr.charAt(j)){
						int margin = j-i;
						baseIndex++;
						for(int k=j+margin;k<=boardStrlen;k+=margin){
							if(base[baseIndex]==boardStr.charAt(k)){
								baseIndex++;
							}else k=boardStrlen;
								if(baseIndex==base.length){
									return true;
								}
							}
						}
					baseIndex = 1;
					}
				}
			baseIndex = 0;
			}
		return false;
	}
	
	public void doIt(){
		Scanner sc = new Scanner(System.in);
		int boardNam = sc.nextInt();
		String [] board  = new String[boardNam];
		char base[] = sc.next().toCharArray();
		int trueNum = 0;
		for(int i=0;i<boardNam;i++){
			board[i] = sc.next();
		}
		for(int i=0;i<boardNam;i++){
			if(stringMach(base, board[i])){
				trueNum++;
			}
		}
		System.out.println(trueNum);
	}
	
	public static void main(String[] args){
		new Main().doIt();
	}
}

Measured memory_bytes: 27564
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 1005;

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

int mp[SIZE][SIZE];

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

    int h, w;
    cin >> h >> w;
    queue< P > q;
    for( int i = 1; i <= h; ++i ) {
        for( int j = 1; j <= w; ++j ) {
            char c;
            cin >> c;
            if( c == '#' ) {
                q.push( MP( i, j ) );
                mp[i][j] = -1;

            }
        }
    }
    
    int cnt = 1;
    while( !q.empty() ) {
        int qsize = q.size();
        bool flg = true;
        for( int i = 0; i < qsize; ++i ) {
            P p = q.front(); q.pop();

            bool tmp = true;
            if( p.F > 1 && mp[p.F - 1][p.S] == 0 ) {
                mp[p.F - 1][p.S] = cnt;
                q.push( MP( p.F - 1, p.S ) );

            }
            if( p.S > 1 && mp[p.F][p.S - 1] == 0 ) {
                mp[p.F][p.S - 1] = cnt;
                q.push( MP( p.F, p.S - 1 ) );

            }
            if( p.S < w && mp[p.F][p.S + 1] == 0 ) {
                mp[p.F][p.S + 1] = cnt;
                q.push( MP( p.F, p.S + 1 ) );

            }
            if( p.F < h && mp[p.F + 1][p.S] == 0 ) {
                mp[p.F + 1][p.S] = cnt;
                q.push( MP( p.F + 1, p.S ) );

            }

        }
        ++cnt;
    }

    int res = 0;
    for( int i = 1; i <= h; ++i ) {
        for( int j = 1; j <= w; ++j ) {
            res = max( res, mp[i][j] );

        }
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 12432
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> L(n);
  for(int j=0;j<n;j++){
    cin>>L.at(j);
  }
  sort(L.begin(),L.end());
  reverse(L.begin(),L.end());
  int sum,i;
  sum=0;
  for(i=1;i<n;i++){
    sum =sum+ L.at(i);
  }
  if(sum>L.at(0)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
using namespace std;
const long long INF = 1LL<<60;

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

    long long ans = INF;
    for (int bit = 0; bit < (1<<N); bit++) {
        int t = bitset<20>(bit).count();
        if (t < K) continue;
        long long cost = 0;
        int highest = A[0];
        for (int i = 1; i < N; i++) {
            if (bit & (1<<i) && A[i] <= highest) {
                cost += highest++ - A[i] + 1;
            } else {
                highest = max(highest, A[i]);
            }
        }
        ans = min(ans, cost);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>

using namespace std;

int main() {
  int n;
  array<int, 26> dict, buf;
  string str;

  dict.fill(1<<30);
  buf.fill(0);
  cin >> n;
  for (int i=0; i<n; i++) {
    cin >> str;
    int c;
    for (int j=0; j<str.length(); j++) {
      c = str[j];
      buf[c - 0x61] += 1;
    }
    for (int k=0; k<26; k++) {
      dict[k] = min(buf[k], dict[k]);
      buf[k] = 0;
    }
  }

  string ans = "";
  for (int i=0; i<26; i++) {
    for (int j=0; j<dict[i]; j++) {
      ans += (char) i + 0x61;
    }
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = atan(1.0) * 4.0;
// const int MOD = 998244353;
const ll LINF = 9e18;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};

void cinfast() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

VL A, Ar;

signed main() {
    LCIN(N);
    VL a;
    A.resize(N + 2);
    Ar.resize(N + 2);
    REP(i, N) { a.emplace_back(IN()); }
    REP(i, N) { A[i + 1] = max(A[i], a[i]); }
    FORR(i, N + 1, 1) { Ar[i - 1] = max(Ar[i], a[i - 2]); }
    FOR(i, 1, N + 1) { cout << max(A[i - 1], Ar[i + 1]) << "\n"; }
}


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

#define watch(x) cerr << (#x) << ": " << (x) << endl

const int N = 3005;
int n, t;
pair<int, int> food[N];
int ans, dp[N][2*N];

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> t;
    for(int i = 0; i < n; ++i) {
        cin >> food[i].first >> food[i].second;
    }

    sort(food, food+n);

    for(int i = 1; i <= n; ++i) {
        int time = food[i-1].first, del = food[i-1].second;
        for(int j = 0; j < t+time; ++j) {
            dp[i][j] = dp[i-1][j];
            if(j >= time) {
                dp[i][j] = max(dp[i][j], dp[i-1][j-time]+del);
            }
        }
    }
    for(int i = 1; i < 2*N; ++i) {
        ans = max(ans, dp[n][i]);
    }

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


Measured memory_bytes: 70784
k = input()
d = int(input())
mod = 10**9 + 7

dp = [[[0] * d for i in range(2)] for j in range(len(k)+1)]
dp[0][0][0] = 1

for i in range(len(k)):
    for j in range(2):
        for m in range(d):
            if j == 1:
                for num in range(10):
                    dp[i+1][j][(m+num)%d] += dp[i][j][m]
                    dp[i+1][j][(m+num)%d] %= mod
            else:
                for num in range(int(k[i])+1):
                    if num != int(k[i]):
                        dp[i+1][1][(m+num)%d] += dp[i][j][m]
                        dp[i+1][1][(m+num)%d] %= mod
                    else:
                        dp[i+1][0][(m+num)%d] += dp[i][j][m]
                        dp[i + 1][0][(m + num) % d] %= mod

print((dp[len(k)][0][0] + dp[len(k)][1][0] - 1) % mod)


Measured memory_bytes: 63452
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define rall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

	int N;
	cin >> N;
	vector<int> D(N);
	for(int i = 0; i < N; i++){
		cin >> D[i];
	}
	ll ans = 0;
	for(int i = 0; i < N-1; i++){
		for(int j = i+1; j < N; j++){
			ans += D[i]*D[j];
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3600
#include <iostream>

#define N 100000

bool solve(int n, int h[]) {
    for (int i=n-1; i>0; --i) {
        if (h[i] < h[i-1]) --h[i-1];
    }
    for (int i=0; i<n-1; ++i) {
        if (h[i] > h[i+1]) return false;
    }
    return true;
}

int main() {
    int n;
    int h[N];
    std::cin >> n;
    for (int i=0; i<n; ++i) std::cin >> h[i];

    std::cout << (solve(n, h) ? "Yes" : "No") << std::endl;

    return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
    char str[100];
    char c;
    scanf("%s",&str);
    int sum=0,flag=0,sum1=0;
    for(int i=0;(c=str[i])!='\0';i++)
    {
        if(c=='C')
            sum++;
        if(c>='a'&&c<='z')
            flag++;
    }
   // cout<<flag<<"*"<<sum<<endl;
    int len=strlen(str);
    //cout<<len<<"*22"<<endl;
    int t=len-2;
    if(str[0]=='A'&&str[1]!='C'&&str[len-1]!='C'&&sum==1&&flag==t)
        cout<<"AC"<<endl;
    else
        cout<<"WA"<<endl;
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define eb emplace_back
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> x(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    ll res = LINF;
    for (int i = 1; i <= 100; i++) {
        ll s = 0;
        for (int j = 0; j < n; j++) {
            s += (x[j] - i) * (x[j] - i);
        }
        chmin(res, s);
    }
    cout << res << endl;
}


Measured memory_bytes: 256
package main

import "fmt"
import "strconv"
import "strings"

func main() {
	var a, b, c int
	fmt.Scanf("%d %d %d", &a, &b, &c)

	//fmt.Println(a, b, c)
	sa := strconv.Itoa(a)
	sb := strconv.Itoa(b)
	sc := strconv.Itoa(c)
	sabc := (sa + sb + sc)
	//fmt.Println(sabc)

	if (strings.Count(sabc, "5")) == 2 {
		if (strings.Count(sabc, "7")) == 1 {
		fmt.Println("YES")
	  }
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
    public static int a;
    public static int b;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        a=sc.nextInt();
        b=sc.nextInt();
        int ans = gcd(a,b);
        System.out.println(ans);
        sc.close();
    }
    private static int gcd(int c,int d){
        if (c%d==0) return(d);
	    else return(gcd(d,c%d));
    }
}


Measured memory_bytes: 26348
<?php

list($nums, $k) = array_map("trim", file("php://stdin"));
$k = intval($k);
$nums = array_map("intval", explode(" ", $nums));


$max = max($nums);
$maxKey = array_search($max, $nums);
$nums[$maxKey] = $max * pow(2, $k);

echo array_sum($nums);



Measured memory_bytes: 4728
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
const unsigned long long h = 1e9+7;
typedef pair<ll,ll> P;
const ll MAX = 100010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    if (w >= h) PRINT("unsafe");
    else PRINT("safe");
}    


Measured memory_bytes: 3648
import sys
input=sys.stdin.readline
n=int(input())
lists=list(map(int,input().split()))
length=61
use=[0 for i in range(61)]
a,b=divmod(n,9)
anslist=[0 for i in range(a+1)]
for  j in range(n):
    k=format(lists[j],"0%ib"%length)
    k=k[::-1]
    p,q=divmod(j,9)
    if p>a:
        anslist.append(str(k))
    else:
        anslist[p]+=int(k)
answer=0
for some in anslist:
    some=str(some)
    some=some.zfill(61)
    for j in range(61):
        if int(some[j])!=0:
            use[j]+=int(some[j])

for j in range(61):
    answer+=(2**j)*use[j]*(n-use[j])%(10**9+7)
print(answer%(10**9+7))


Measured memory_bytes: 123180