akhauriyash/Code-Regression huggingface dataset:
// 22
#include <bits/stdc++.h>
using namespace std;
#define coutc "\033[48;5;196m\033[38;5;15m"
#define endc "\033[0m"
#define endl '\n'
#define M(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) \
  M(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep4(_, x, n, s) \
  for (int _ = x; (s < 0) ? _ > n : _ < n; _ += s)
#define rep3(_, x, n) rep4(_, x, n, (x < n ? 1 : -1))
#define rep2(_, n) rep3(_, 0, n)
#define rep1(n) rep2(i, n)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define len(x) int(x.size())
#define lli __int128_t
#define li long long int
#define ld long double
// 4
template <class A, class B>
ostream &operator<<(ostream &o, const pair<A, B> &p) {
  return o << "(" << p.fi << ", " << p.se << ")";
}
// 5
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v) {
  rep(i, len(v)) o << setw(7) << left << v[i];
  return o << endc << endl << coutc;
}
// 5
template <class A, class B>
ostream &operator<<(ostream &o, const map<A, B> &m) {
  for (auto &kv : m) o << kv;
  return o;
}
// 7
template <class T, class... Ts>
void debug(const T &e, const Ts &... r) {
#ifdef DEBUG
  cerr << coutc << e;
  ((cerr << " " << r), ..., (cerr << endc << endl));
#endif
}
// 3
void _main(int tc) {
  int k, a, b;
  cin >> k >> a >> b;
  if (k > b) {
    cout << "NG" << endl;
    return;
  }
  int rightlimit = k * (b / k);
  if (rightlimit >= a) {
    cout << "OK" << endl;
  } else {
    cout << "NG" << endl;
  }
}
// 7
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M=0;cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++)cin>>A.at(i);
  sort(A.begin(),A.end());
  for(int i=0;i<=A.at(N-1);i++){
    int a=upper_bound(A.begin(),A.end(),i+2)-A.begin();
    int b=upper_bound(A.begin(),A.end(),i-1)-A.begin();
    M=max(M,a-b);
  }
  cout<<M<<endl;
}

Measured memory_bytes: 640
/*
 * 2101.cpp
 *
 *  Created on: 2012/07/08
 *      Author: shimomire
 */

#include <iostream>
#include<algorithm>
#include<string>
#include <complex>
#include<list>
#include<float.h>
#include <functional>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <queue>

using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define REP0(i,n)   REP(i,0,n)
#define REPr(i,b,n) for(int i=n-1;i>=b;i--)
#define REPr0(i,n)   REPr(i,0,n)

#define foreach(it,o) for(__typeof((o).begin()) it=(o).begin(); it!=(o).end(); ++it)
#define ALL(o) (o).begin(),(o).end()
#define ARRSIZE(x) (sizeof(x)/sizeof(x[0]))
#define ARRALL(x) x,x+ARRSIZE(x)
typedef complex<double> P;
typedef long long ll;

bool operator <(const P& a, const P& b) {
	return make_pair(real(a), imag(a)) < make_pair(real(b), imag(b));
}

int N;
int main() {
	while (true) {
		cin >> N;
		if(N==0){
			break;
		}
		int S = 0;
		for(int i=1;i*i<=N;i++) {
			if(N%i==0){
				if(i!=N/i)S +=i+N/i;
				else S+=i;//平方
			}
		}
		S-=N;
		if (N < S) {
			cout << "abundant number" << endl;
		} else if(N>S){
			cout << "deficient number" << endl;
		}else{
			cout << "perfect number" << endl;
		}
	}
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int C = sc.nextInt();
		
		int[] B = new int[M];
		int[][] A = new int[N][M];
		
		for(int i = 0; i < M; i++) {
			B[i] = sc.nextInt();
		}
		
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < M; j++) {
				A[i][j] = sc.nextInt();
			}
		}
		
		int sum = 0;
		int num = 0;
		
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < M; j++) {
				sum += A[i][j] * B[j];
			}
			if((sum + C) > 0) {
				num++;
			}
			sum = 0;
		}
		
		System.out.println(num);
	}
}


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

int main() {
  // int N;
  // cin>>N;
  string s;
  cin>>s;
  if (s == "Sunny") cout<<"Cloudy"<<endl;
  if (s == "Cloudy") cout<<"Rainy"<<endl;
  if (s == "Rainy") cout<<"Sunny"<<endl;

  // int val = 0;
  // cout<<val<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k = gi();
    int n = gi();
    int a0 = gi();
    int l = a0;
    int mx = 1;
    for (int i = 1; i < n; i++) {
        int a = gi();
        mx = MAX(mx, a-l);
        l = a;
    }
    mx = MAX(mx, k-(l-a0));
    printf("%d\n", k-mx);

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    string s; cin >> s;
    const ll n = s.size();

    // サイズ n は作れない、サイズ 1 は木ならば葉が存在するため必ず作れる
    if (s.back() == '1' || s.front() == '0') {
        cout << -1 << endl;
        return 0;
    }

    // サイズ i が作れたらサイズ n-i も作れる
    REP(i, n - 1) {
        if (s[i] != s[n-2-i]) {
            cout << -1 << endl;
            return 0;
        }
    }

    // ではどう作るか
    vector<pair<ll, ll>> ans;
    ll par = 1;
    REP(i, n/2) { // i は 0-indexed
        ans.emplace_back(par, i+2);
        if (s[i] == '1') {
            par = i+2;
        }
    }
    RANGE(i, n/2, n-2) { // i は 0-indexed
        ans.emplace_back(par, i+2);
    }
    REP(i, n-1) {
        cout << ans[i].first << " " << ans[i].second << endl;
    }

    
}

Measured memory_bytes: 3312
def gen(n):
    for _ in range(1000):

        if n%2==0:
            g = int(n/2)
            yield g
        else:
            g = int(n*3+1)
            yield g
        n = g


def main():
    N = int(input())
    a=gen(N)
    post = [N]
    for i,generated in enumerate(a):
        if generated in post:
            print(i+2)
            exit()
        else:
            post.append(generated)

        
    
if __name__== "__main__":
    main() 


Measured memory_bytes: 3060
// A - Traveling Budget
#include <iostream>
using namespace std;

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  cout<<min(A,B)+min(C,D)<<endl;
  return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
count = 0
if k==0:
    print(n ** 2)
    exit()

for i in range(1,n+1):
    if i <= k:
        continue
    count += max(0, (n%i) - k + 1)
    count += (n // i) * (i - k)
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <cstdlib>
using namespace std;
int main()
{
	char s[1024] = "", b[6];
	//t:before; u:after
	char t[32][9] = {"100101", "10011010", "0101", "0001", "110",
		"01001", "10011011", "010000", "0111", "10011000", "0110",
		"00100", "10011001", "10011110", "00101", "111", "10011111",
		"1000", "00110", "00111", "10011100", "10011101", "000010",
		"10010010", "10010011", "10010000", "101", "010001", "000011",
		"10010001", "000000", "000001"};
	char u[32][6] = {"00000", "00001", "00010", "00011", "00100",
		"00101", "00110", "00111", "01000", "01001", "01010", "01011",
		"01100", "01101", "01110", "01111", "10000", "10001", "10010",
		"10011", "10100", "10101", "10110", "10111", "11000", "11001",
		"11010", "11011", "11100", "11101", "11110", "11111"};
	int i, j, c;
	while (cin.getline(s, sizeof(s)), !cin.eof())
	{
		char a[5120] = "", r[5120] = "";
		c = 0;
		for (i = 0; i < strlen(s); i++)
		{
			switch (s[i])
			{
			case ' ':
				for (j = 0; j < 3; j++, c++)
					a[c] = t[26][j];
				break;
			case '.':
				for (j = 0; j < 6; j++, c++)
					a[c] = t[27][j];
				break;
			case ',':
				for (j = 0; j < 6; j++, c++)
					a[c] = t[28][j];
				break;
			case '-':
				for (j = 0; j < 8; j++, c++)
					a[c] = t[29][j];
				break;
			case '\'':
				for (j = 0; j < 6; j++, c++)
					a[c] = t[30][j];
				break;
			case '?':
				for (j = 0; j < 6; j++, c++)
					a[c] = t[31][j];
				break;
			default:
				for (j = 0; j < strlen(t[s[i]-'A']); j++, c++)
					a[c] = t[s[i]-'A'][j];
			}
		}
		for (i = c = 0; i < strlen(a); i += 5, c++)
		{
			for (j = 0; j < 5; j++)
			{
				if (a[i+j] != '\0')
					b[j] = a[i+j];
				else
					b[j] = '0';
			}
			b[5] = '\0';
			for (j = 0; j < 32; j++)
			{
				if (strcmp(b, u[j]) == 0)
				{
					switch (j)
					{
					case 26:
						r[c] = ' ';
						break;
					case 27:
						r[c] = '.';
						break;
					case 28:
						r[c] = ',';
						break;
					case 29:
						r[c] = '-';
						break;
					case 30:
						r[c] = '\'';
						break;
					case 31:
						r[c] = '?';
						break;
					default:
						r[c] = j + 'A';
					}
				}
			}
		}
		r[c+1] = '\0';
		cout << r << endl;
	}
}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-
"""
Created on Sat Apr  6 21:07:41 2019

@author: qqwx2_000
"""
import itertools

a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

coordinate = [a,b,c,d,e]

distance = []

for i in itertools.combinations(coordinate, r=2):
    com = i
    d = com[1] - com[0]
    distance.append(d)
k_up = [i for i in distance if k < i]

if len(k_up) >= 1: 
    print(':(')
else:
    print('Yay!')



Measured memory_bytes: 3064
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A&lang=jp
process.stdin.resume();
process.stdin.setEncoding('utf8');

// Here your code !
function main (input) {
    input = input.trim().split('\n');
    
    // ??°??????
    var N = Number(input[0]);
    // ??°???
    var A = input[1].split(' ').map(Number);

    /*
    insertionSort(A, N) // N??????????´??????????0-?????????????????????A
        for i ??? 1 ?????? N-1 ?????§
            v = A[i]
            j = i - 1
            while j >= 0 ?????? A[j] > v
               A[j+1] = A[j]
               j--
            A[j+1] = v
    */
    for (var i = 1; i < N; i ++) {
        console.log(A.join(' '));

        v = A[i];
        j = i - 1;
        
        while (j >= 0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        
        A[j+1] = v;
    }

    console.log(A.join(' '));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 20844
import sys

from collections import deque
# q = deque(); q.append(x); q.appendleft(x); q.pop() -> x; q.popleft() -> x
from collections import defaultdict
# d = defaultdict(lambda: []); d[key] -> []
import heapq
# hq = []; heapq.heappush(hq, x); heapq.heappop(hq) -> x; heapq.heappushpop(hq, x) -> x
import bisect
# i = bisect.bisect_left([1,2,3,4], 1.5); i = bisect.bisect_right([4,3,2,1], 1.5)

#import numpy as np
#from scipy.misc import comb

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

# 個数制限なしナップサック
def main():
    N = i2n()
    coins = [1]
    d = 6
    while d <= N:
        coins.append(d)
        d *= 6
    d = 9
    while d <= N:
        coins.append(d)
        d *= 9
    # アイテム = (重さ=金額, 価値=枚数) = (1, 1), (6, 1), ..., (9, 1), ...
    # DP[アイテムID][重さ] = 価値
    # DP[アイテムID][金額] = 枚数
    # 価値の最大化／枚数の最小化
    items = [(c, 1) for c in coins]
    itemlen = len(items)
    dp = [[int(1e+6)] * (N+1) for _ in range(itemlen+1)]
    for i in range(itemlen+1):
        dp[i][0] = 0
    # dp[i+1][w] = max(dp[i+1][w - item[0]] + item[1], dp[i][w])
    for item_id, (coin, coin_n) in enumerate(items):
        for n in range(1, N+1):
            if n - coin >= 0:
                dp[item_id+1][n] = min(dp[item_id][n], dp[item_id+1][n-coin] + coin_n)
            else:
                dp[item_id+1][n] = dp[item_id][n]
    #print(dp)
    print(dp[itemlen][N])


main()


Measured memory_bytes: 49520
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.append(1000000000000)
a.sort()

b = list()
cn = 1

for i in range(1,n+1):
    if(a[i]==a[i-1]):
        cn += 1
    else:
        b.append((a[i-1],cn))
        cn = 1
        
sn = 0        
    
b.sort(key = lambda x : (x[1],x[0]),reverse = True)    
    
if(len(b)<=k):
    print(0)
else:
    for i in range(len(b)-1,k-1,-1):
        sn += b[i][1]
    print(sn)

Measured memory_bytes: 89936
#include "bits/stdc++.h"
using namespace std;

int main(){
  int N, T, A, x = 0, flag = 1<<30, ans = 1;
  cin >> N >> T >> A;
  int d[N];
  for (size_t i = 0; i < N; i++) {
    cin >> x;
    d[i] = abs(T * 1000 - x * 6 - A * 1000);
  }
  for (int j = 0; j < N; j++) {
    if(flag > d[j]){
      flag = d[j];
      ans = j + 1;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
typedef pair<int, int> P;
typedef pair<int, P> S;
int main(){
  int N;
  while(cin>>N && N){
    string ss, gs; cin>>ss>>gs;
    int St = 0, G = 0;
    REP(i, N){
      St |= (int)(ss[i] == 'B') << i;
      G |= (int)(gs[i] == 'B') << i;
    }
    priority_queue<S> que;
    int dist[1<<16][16];
    REP(i, 1<<N)REP(j, N) dist[i][j] = INF;
    REP(i, N){
      dist[St][i] = 0;
      que.push(S(0, P(St, i)));
    }
    while(!que.empty()){
      S s = que.top(); que.pop();
      int d = s.first * -1;
      int state = s.second.first;
      int u = s.second.second;
      if(state == G){
        cout<<d<<endl;
        break;
      }
      if(dist[state][u] < d) continue;
      REP(i, N)REP(j, N)if((state >> i & 1) != (state >> j & 1)){
        int nst = state ^ (1 << i) ^ (1 << j);
        if(((nst ^ G) >> i & 1) && (nst ^ G) >> j & 1) continue;
        int nd = d + abs(i - u) + abs(j - i);
        int nu = j;
        if(dist[nst][nu] > nd){
          dist[nst][nu] = nd;
          que.push(S(nd * -1, P(nst, nu)));
        }
      }
    }
  }
  return 0;
}

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

using namespace std;

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(t) for(ll i =0;i<t;i++)
#define bs(a,x) binary_search(a.begin(),a.end(),x)
#define ll long long int
#define ul unsigned long int
#define ld long double
#define umpi unordered_map<int,int> 
#define umpl unordered_map<ll,ll> 
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define mod 1000000007 
#define N 10000000
#define all(a) a.begin(),a.end()
#define point pair<int,int>
const int inf = 1000000007;
const ll linf = 1ll * inf * inf;

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

string to_string(char x)
{
	string s(1,x);
	return s;
}

int main()
{	
	fio;
	ll t;t=1;
	while(t--)
	{
		string s1,s2;
		cin>>s1>>s2;
		ll dp[s1.length()+1][s2.length()+1];
		memset(dp,0,sizeof(dp));
		for(ll i=1;i<=s1.length();i++)
		{
			for(ll j=1;j<=s2.length();j++)
			{
				if(s1[i-1]==s2[j-1])
				{
					dp[i][j]=max(dp[i][j],1+dp[i-1][j-1]);
				}
				dp[i][j]=max(dp[i][j],dp[i-1][j]);
				dp[i][j]=max(dp[i][j],dp[i][j-1]);
			}
		}
		string ans="";int n=dp[s1.length()][s2.length()];
		ll i=s1.length(),j=s2.length();
		while(i>0 && j>0)
		{
			if(s1[i-1]==s2[j-1])
			{
				ans.append(to_string(s1[i-1]));
				i--;j--;
			}
			else if(dp[i-1][j]>dp[i][j-1])i--;
			else j--;
		}
		reverse(all(ans));
		cout<<ans<<"\n";
	}
}


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

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

using namespace std;

template <class T>
void printv(vector<T> v)
{
  cout << '[';
  for (auto vec: v)
  {
    cout << vec << ' ';
  }
  cout << ']' << endl;
}

int main()
{
  int str;
  cin >> str;

  if (str == 25)
    cout << "Christmas" << endl;
  else if (str == 24)
    cout << "Christmas Eve" << endl;
  else if (str == 23)
    cout << "Christmas Eve Eve" << endl;
  else
    cout << "Christmas Eve Eve Eve" << endl;
}


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

signed main() {
  int N;
  cin >> N;
  
  vector<vector<int>> hito(N, vector<int>(N));
  for( int i = 0; i < N; i++ ){
    for( int j = 0; j < N; j++ ){
      hito.at(i).at(j) = -1;
    }
  }
  
  int A, X, Y;
  for( int i = 0; i < N; i++ ){
    cin >> A;
    for( int j = 0; j < A; j++ ){
      cin >> X >> Y;
      hito.at(i).at(X-1) = Y;
    }
  }
  
  int ans = 0;
  for (int bit = 0; bit < (1<<N); ++bit){
    int cnt = 0;
    for (int i = 0; i < N; ++i) {
      if (bit & (1<<i)) {
        bool fg = true;
        for( int j  = 0; j < N; j++ ){
          if( hito.at(i).at(j) == 1 && hito.at(j).at(i) == 0 ) fg = false;
          if (bit & (1<<j)){
            if( hito.at(i).at(j) == 0 ) fg = false;
          }else{
          if( hito.at(i).at(j) == 1 ) fg = false;
          }
        }
        if(fg) cnt++;
        else{
          cnt = 0;
          break;
        }
      }
    }
    ans = max( ans, cnt );
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.datetime;
import std.numeric;
import std.math;
import std.string;

string my_readln() { return chomp(readln()); }

void main()
{//try{
	//auto tokens = split(my_readln());
	//auto N = to!ulong(tokens[0]);
	//auto W = to!ulong(tokens[1]);

	auto N = my_readln().to!ulong();
	auto H = my_readln().to!ulong();
	auto W = my_readln().to!ulong();


	auto x = N - H + 1;
	auto y = N - W + 1;
	writeln(x * y);
	stdout.flush();
	/*}catch (Throwable e)
	{
	writeln(e.toString());
	}
	readln();*/
}

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

int main(void)
{
  string n;
  cin >> n;
  if (n[0]=='7' || n[1]=='7' || n[2]=='7'){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef unsigned long long ull;
typedef long double ld;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.14159265
const int MOD=1e9+7;
 
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a)  (a).begin(),(a).end()

const int N=1e5+5;

int n,m;
string s[1010];
int dp[1010][1010];

int go(int i,int j)
{
    if(s[i][j]=='#' || i>=n || j>=m)
        return 0;
    if(i==n-1 && j==m-1)
        return 1;
    int &ans=dp[i][j];
    if(ans!=-1) 
        return ans;
    ans=go(i+1,j)+go(i,j+1);
    ans%=MOD;
    return ans;
}

int32_t main()
{
    IOS;
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<go(0,0);
}

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

int minCost(vector<int>& nums, int k)
{
	int n = nums.size();
	if(n<2)
		return 0;
	vector<int> cost(n);
	for(int i = 0; i < n; i++ )
		cost[i]=INT_MAX;
	cost[0] = 0;
	for(int  i = 1; i < n ; i++)
	{
		for(int j = i-1; j >=0 && j >= i - k; j--)
		{
			cost[i] = min(cost[i], cost[j] + abs(nums[i]-nums[j]));
		}
		// cout << cost[i] << " ";
	}
	return cost[n-1];
}

int main(){
	int n,k;
	cin>>n>>k;
	vector<int> vec(n);
	for(int i = 0; i < n; i++)
		cin>>vec[i];
	cout<<minCost(vec,k)<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <bits/extc++.h>
#include <atcoder/all>

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
//#define inf 2000000000
#define inf 8000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;
using namespace atcoder;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;
const int maxn=105;
//i_am_noob
#define y1 _y_1
int n,m,s=10001,t=10002,x1,y1,x2,y2;
char c[maxn][maxn];
mf_graph<int> g(maxn*maxn);
vector<mf_graph<int>::edge> vec;

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> n >> m;
  	rep(n) rep1(j,m) cin >> c[i][j];
  	rep(n*m){
      	if(i/m+i%m&1) g.add_edge(s,i,1);
      	else g.add_edge(i,t,1);
    }
  	rep(n-1) rep1(j,m) if(c[i][j]=='.'&&c[i+1][j]=='.'){
      	if(i+j&1) g.add_edge(m*i+j,m*(i+1)+j,1);
      	else g.add_edge(m*(i+1)+j,m*i+j,1);
    }
  	rep(n) rep1(j,m-1) if(c[i][j]=='.'&&c[i][j+1]=='.'){
      	if(i+j&1) g.add_edge(m*i+j,m*i+j+1,1);
      	else g.add_edge(m*i+j+1,m*i+j,1);
    }
  	print1(g.flow(s,t));
  	vec=g.edges();
  	for(auto e: vec) if(e.flow&&e.from!=s&&e.to!=t){
      	x1=e.from/m,y1=e.from%m,x2=e.to/m,y2=e.to%m;
    	if(x1==x2&&y1<y2) c[x1][y1]='>',c[x2][y2]='<';
      	else if(x1==x2&&y1>y2) c[x1][y1]='<',c[x2][y2]='>';
      	else if(y1==y2&&x1<x2) c[x1][y1]='v',c[x2][y2]='^';
      	else c[x1][y1]='^',c[x2][y2]='v';
    }
  	rep(n){
      	rep1(j,m) cout << c[i][j];
      	cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 6376
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		char[] s = sc.next().toCharArray();
		int R = 0;
		for(int i=0; i<N; i++)
			if(s[i] == 'R')
				R++;
		
		System.out.println(R>N-R ? "Yes" : "No");
		sc.close();
	}
}


Measured memory_bytes: 22612
#include<stdio.h>
int main()
{
	int a[3],i,t;
	for(i=0;i<=3;i++)
	scanf("%d",&a[i]);
	if(a[0]<=a[2])
	{
		if(a[1]<=a[2])
		t=0;
		else if(a[1]>=a[3])
		t=a[3]-a[2];
		else
		t=a[1]-a[2];
	}
	else
	{
		if(a[3]<=a[0])
		t=0;
		else if(a[3]>=a[1])
		t=a[1]-a[0];
		else
		t=a[3]-a[0];
	}
	printf("%d",t);
	return 0;
	
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


// dp[i] := 長さが i の増加部分列として最後尾の要素のとりうる最小値
template<class T> int LIS(vector<T> a,  bool is_strong = true) {
    const T INF = 1<<30; // to be set appropriately
    int n = (int)a.size();
    vector<T> dp(n, INF);
    for (int i = 0; i < n; ++i) {
        if (is_strong) *lower_bound(dp.begin(), dp.end(), a[i]) = a[i];
        else *upper_bound(dp.begin(), dp.end(), a[i]) = a[i];
    }
    return lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
}


int main() {
    int N;
    while (cin >> N) {
        vector<int> a(N);
        for (int i = 0; i < N; ++i) cin >> a[i], a[i] *= -1;

        cout << LIS(a, false) << endl;
    }
}


Measured memory_bytes: 1408
#include <iostream>
using namespace std;
 
int main()
{
    int r, c;
 
    cin >> r >> c;
 
    int array[128][128] = {0};
    int sum = 0;
    for (int i = 0; i < r; i++){
        for (int j = 0; j < c; j++){
            cin >> array[i][j];
            array[i][c] += array[i][j];
            array[r][j] += array[i][j];
            sum += array[i][j];
        }
    }
    array[r][c] = sum;
    for (int i = 0; i <= r; i++){
        for (int j = 0; j <= c; j++){
            cout << array[i][j] << "\n "[j < c];
        }
    }
 
    return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <cmath>

using namespace std;
int main() {
  double v;
  
  while(cin>>v) {
    double t = v/9.8;
    double y = 4.9*t*t;
    cout << ceil((y+5)/5) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;

struct Lowlink{
    ll n;
    vector<vector<ll> > g;
    vector< mp > bridge;
    vector< ll > articulation;
    vector< ll > ord , low;
    vector< bool > used;
    Lowlink(){}
    Lowlink( ll n ):n(n){
	g = vector<vector<ll> >(n);
	ord = vector<ll>(n);
	low = vector<ll>(n);
	used = vector<bool>(n,false);
    }
    void add_edge( ll s , ll t ){
	g[s].push_back( t );
	g[t].push_back( s );
    }
    void solve(){
	ll k = 0;
	for(ll i=0;i<n;i++)if( !used[i] )dfs( i , -1 , k );
	sort( bridge.begin(),bridge.end() );
	sort( articulation.begin(),articulation.end() );
    }
    void dfs(ll v, ll p ,ll &k){
	used[v] = true;
	ord[v] = k++;
	low[v] = ord[v];
	bool isarticulation = false;
	ll cnt = 0;
	for(ll i=0;i<g[v].size();i++){
	    if( !used[ g[v][i] ] ){
		cnt++;
		dfs(g[v][i],v,k);
		low[v] = min( low[v] , low[ g[v][i] ] );
		if( ~p && ord[v] <= low[g[v][i]])isarticulation = true;
		if( ord[v] < low[ g[v][i] ] )bridge.push_back( mp( min( v, g[v][i] ) , max( v, g[v][i] ) ) );
	    }else if( g[v][i] != p ){
		low[v] = min( low[v] , ord[ g[v][i] ] );
	    }
	}
	if( p==-1 && cnt > 1 )isarticulation = true;
	if( isarticulation ) articulation.push_back( v );
    }
};

int main(){
    ll v,e;
    cin>>v>>e;
    Lowlink L(v);
    for(ll i=0;i<e;i++){
	ll s,t;
	cin>>s>>t;
	L.add_edge( s,t );
    }
    L.solve();
    for(auto i:L.bridge ){
	cout<<i.first<<' '<<i.second<<endl;
    }
    return 0;
}



Measured memory_bytes: 5352
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}

ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

int main(void){
  ll N, M;
  cin >> N >> M;
  vec S(N), T(M);
  rep(i, N) cin >> S[i];
  rep(i, M) cin >> T[i];
  ll dp[N+1][M+1];
  ll sum[N+1][M+1];
  memset(dp, 0, sizeof(dp));
  memset(sum, 0, sizeof(sum));
  rep(i, N){
    rep(j, M){
      if(S[i] == T[j]){
        dp[i+1][j+1] = sum[i][j] + 1;
        dp[i+1][j+1] %= MOD;
      }
      sum[i+1][j+1] = sum[i+1][j] + sum[i][j+1] - sum[i][j] + dp[i+1][j+1];
      sum[i+1][j+1] %= MOD;
      sum[i+1][j+1] += MOD;
      sum[i+1][j+1] %= MOD;
    }
  }
  cout << (sum[N][M] + 1) % MOD << endl;
}


Measured memory_bytes: 62848
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    int n;
    cin >> n;
    int c = 0;
    for (int i = 1; i <= n; i++) {
        int e;
        cin >> e;
        c += (e != i);
    }
    
    cout << (c > 2 ? "NO" : "YES");



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}
void YN(bool z){cout<<(z?"YES\n":"NO\n");}
void Yn(bool z){cout<<(z?"Yes\n":"No\n");}
void yn(bool z){cout<<(z?"yes\n":"no\n");}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;
int a[3];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  FOR(i, 0, 3) cin >> a[i];
  sort(a, a+3);
  cout << a[2]*10+a[1]+a[0] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
long long s;
string st;
char ch[18]={'C','O','D','E','F','E','S','T','I','V','A','L','2','0','1','6'};
int main()
{
	cin>>st;
	for(int i=0;i<st.size();i++)
	{
		if(st[i]!=ch[i]) s++;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  AOJ
//
//  Created by user on 2014/02/01.
//  Copyright (c) 2014年 user. All rights reserved.
//

#include <iostream>
#include <memory>
#include <sstream>
using namespace std;

pair<string, string> getTree(string str){
    int stack = 0;
    int ptr = -1;
    
    for(int i=0;i<str.size();i++){
        if(str[i] == '('){
            ++stack;
        } else if(str[i] == ')'){
            --stack;
        } else if(str[i] == ','){
            if(stack == 1){
                ptr = i;
                break;
            }
        }
    }
    
    string Ls = str.substr(1, ptr - 1);
    string Rs = str.substr(ptr + 1, str.size() - ptr - 2);
    
    return make_pair(Ls, Rs);
}


string TreeInsect(string As, string Bs){
    if(As.empty())return "";
    if(Bs.empty())return "";
    
    string res = "(";
    
    pair<string, string> TreeA = getTree(As);
    pair<string, string> TreeB = getTree(Bs);
    
    res += TreeInsect(TreeA.first, TreeB.first);
    res += ",";
    res += TreeInsect(TreeA.second, TreeB.second);
    res += ")";
    
    return res;
}

string TreeUnion(string As, string Bs){
    if(As.empty())return Bs;
    if(Bs.empty())return As;
    
    string res = "(";
    
    pair<string, string> TreeA = getTree(As);
    pair<string, string> TreeB = getTree(Bs);
    
    res += TreeUnion(TreeA.first, TreeB.first);
    res += ",";
    res += TreeUnion(TreeA.second, TreeB.second);
    res += ")";
    
    return res;
}


int main(int argc, const char * argv[])
{
    string line;
    while(getline(cin, line)){
        stringstream ss(line);
        string com, As, Bs;
        ss >> com >> As >> Bs;
        
        string Cs = "";
        
        if(com == "i"){
            Cs = TreeInsect(As, Bs);
        }
        if(com == "u"){
            Cs = TreeUnion(As, Bs);
        }
        
        cout << Cs << endl;
    }
    return 0;
}

Measured memory_bytes: 1212
#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);

  int ac, wa, tle, re;
  ac = 0;
  wa = 0;
  tle = 0;
  re = 0;
  int n;
  cin >> n;

  rep(i, n){
    string s;
    cin >> s;
    if(s == "AC") ac++;
    if(s == "WA") wa++;
    if(s == "TLE") tle++;
    if(s == "RE") re++;
  }

  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re <<endl;


  return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <cmath>
#include <map>
#include <tuple>
#include <queue>
#include <iomanip>

#define MOD (1000000007)
using namespace std;

typedef long long ll;

typedef tuple<ll, ll> tup; // mp, tairyoku

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

    vector<int> x(N, 0), y(N, 0), ind(N, 0);
    for(int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
        ind[i] = i;
    }

    ll count = 0;
    double sum = 0;
    do {
        count++;
        for(int i = 0; i < N - 1; i++) {
            // cout <<  sqrt((double)(pow(x[ind[i+1]] - x[ind[i]], 2) + pow(y[ind[i+1]] - y[ind[i]], 2))) << " ";
            sum += sqrt((double)(pow(x[ind[i+1]] - x[ind[i]], 2) + pow(y[ind[i+1]] - y[ind[i]], 2)));
        }

    } while(next_permutation(ind.begin(), ind.end()));

    //cout << sum << "," << count  << endl;
    cout <<std::fixed << std::setprecision(15) << sum / count << endl;

    return 0;
}

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

using namespace std;

int main(void) {
  int n;
  cin >> n;
  long a[n];
  long min_abs = 1000000001, abs_a;
  long abs_sum = 0;
  bool is_even = true;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    abs_a = abs(a[i]);
    if (abs_a < min_abs) min_abs = abs_a;
    abs_sum += abs_a;
    if (a[i] < 0) is_even = !is_even;
  }
  if (!is_even) abs_sum -= min_abs * 2;
  cout << abs_sum << endl;
  return 0;
}

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

int main()
{
  int x, n, i, j, k, C;

  while(1)
    {
      C=0;
      cin >> n >> x;

      if(n==0 && x==0)
	break;
      
      for(i=1;i<=n-2;i++)
	for(j=1+i;j<=n-1;j++)
	  for(k=1+j;k<=n;k++)
	    if(i+j+k==x)
	      C += 1;

      cout << C << endl;
    }
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long int n;
    cin >> n;
    long long int k;
    cin >> k;
    long long int a[n];
    long long int ans=0;
    long long int count;
    for(int i=0;i<n;i++)cin >> a[i];
    for(long long int i=40;i>=0;i--){
            count=0;
            for(int j=0;j<n;j++)if(a[j] & (1LL<<i))count++;
            if(count>=n-count || (1LL<<i)>k)ans+=(1LL<<i)*count;
            else{
                ans+=(1LL<<i)*(n-count);
                k-=(1LL<<i);
            }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	private static final int x = 1000000000 + 7;

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] a = new int[n];
		int[] c = new int[n/2+1];
		for(int i=0;i<n/2+1;i++){
			c[i] = 0;
		}

		for(int i=0;i<n;i++){
			a[i] = scanner.nextInt();
			if(n % 2 == 0){
				c[a[i]/2+1]++;
			}else{
				c[a[i]/2]++;
			}
		}
		boolean check = true;
		for(int i=0;i<c.length;i++){
			if(n % 2 == 0){
				if(c[i] % 2 != 0){
					check = false;
					break;
				}
			}else{
				if(c[0] != 1){
					check = false;
					break;
				}else if(c[i] % 2 != 0 && i != 0){
					check = false;
					break;
				}
			}
		}
		long result = 1;
		if(check){
			for(int i=0;i<n/2;i++){
				result = (result*2) % x;
			}
			System.out.println(result);
		}else{
			System.out.println(0);
		}

	}

}


Measured memory_bytes: 48244
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion
#pragma region chminmax
template <typename T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

int INF = 2e5 + 5;
int main()
{
    int h, w;
    cin >> h >> w;
    vector<vector<int>> dp(10, vector<int>(10, INF));
    rep(i, 10) rep(j, 10) cin >> dp[i][j];
    rep(k, 10) rep(i, 10) rep(j, 10)
    {
        chmin(dp[i][j], dp[i][k] + dp[k][j]);
    }

    int ans = 0;
    rep(i, h) rep(j, w)
    {
        int n;
        cin >> n;
        if (n < 0)
        {
            continue;
        }
        ans += dp[n][1];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int rishi(int n,int a){
	int a1;
	if(n>0){
		a=a*1.05;
		a1=a%1000;
		if(a1!=0){
			a=a-a1+1000;
		}
		n=n-1;
		return (rishi(n,a));
	}
	else{
		return a;
	}
}
int main(void) {
	int n,a=100000;
	scanf("%d",&n);
	printf("%d\n",rishi(n,a));
	return 0;
}


Measured memory_bytes: 2036
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;

class Edge {
public:
    int from;
    int to;
    int cost;

    Edge(int from, int to, int cost): from{from}, to{to}, cost{cost} {}
    bool operator<(const Edge& other) const {
        return this->cost < other.cost;
    }
    bool operator>(const Edge& other) const {
        return this->cost > other.cost;
    }
};

class UnionFindTree {
public:
    vector<int> parent;

    UnionFindTree(int size) {
        parent.resize((unsigned long) (size + 1));
        iota(parent.begin(), parent.end(), 0);
    }

    bool isSameSet(int x, int y) {
        return findRoot(x) == findRoot(y);
    }

    void unionSet(int x, int y) {
        int xRoot { findRoot(x) };
        int yRoot { findRoot(y) };
        if (xRoot == yRoot) { return; }

        parent[xRoot] = yRoot;
    }

    int getNumberOfSet() {
        int n = 0;
        for (int i = 0; parent.size(); ++i) {
            if (parent[i] == i) { n++; }
        }
        return n;
    }

private:
    int findRoot(int x) {
        if (parent[x] == x) {
            return x;
        }
        return parent[x] = findRoot(parent[x]);
    }
};

int kruskal(int v, vector<Edge>& edges) {
    sort(edges.begin(), edges.end());
    UnionFindTree uf(v);
    int res { 0 };
    for (auto& e : edges) {
        if (!uf.isSameSet(e.from, e.to)) {
            uf.unionSet(e.from, e.to);
            res += e.cost;
        }
    }
    return res;
}

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

    vector<pair<int, int>> xList((unsigned long) N);
    vector<pair<int, int>> yList((unsigned long) N);
    for (int i { 0 }; i < N; ++i) {
        int x, y;
        cin >> x >> y;
        xList[i] = { x, i };
        yList[i] = { y, i };
    }
    sort(xList.begin(), xList.end());
    sort(yList.begin(), yList.end());

    vector<Edge> edges;
    for (int i { 1 }; i < N; ++i) {
        edges.push_back(Edge(xList[i - 1].second, xList[i].second, abs(xList[i - 1].first - xList[i].first)));
        edges.push_back(Edge(xList[i].second, xList[i + 1].second, abs(xList[i].first - xList[i + 1].first)));
        edges.push_back(Edge(yList[i - 1].second, yList[i].second, abs(yList[i - 1].first - yList[i].first)));
        edges.push_back(Edge(yList[i].second, yList[i + 1].second, abs(yList[i].first - yList[i + 1].first)));
    }

    cout << kruskal(N, edges) << endl;
    return 0;
}


Measured memory_bytes: 9840
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    }

    private static void solve(Scanner in) {
        int N = in.nextInt();
        int[] P = new int[N];
        int[] R = new int[N];
        for (int i = 0; i < N; i++) {
            int nextInt = in.nextInt();
            P[i] = nextInt;
            R[nextInt - 1] = i;
        }

        // R < N <= 20,000
        int X = 30000;

        int a[] = new int[N];
        int b[] = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = (i + 1) * X;
            b[i] = (N - i) * X + R[i];
        }
        for (int ai : a) {
            System.out.print(ai + " ");
        }
        System.out.println();
        for (int bi : b) {
            System.out.print(bi + " ");
        }
        System.out.println();
    }
}

Measured memory_bytes: 32880
from math import gcd 
N,K=map(int,input().split())

mod=10**9+7

A=[0]*K

for i in range(K,0,-1):
    a=K//i
    b=pow(a,N,mod)
    A[i-1]=b

for i in range(K,0,-1):
    for j in range(K//i-1):
        c=i*(j+2)
        A[i-1]-=A[c-1]
        A[i-1]%=mod

s=0
for i in range(K):
    s+=A[i]*(i+1)
    s%=mod

print(s)


Measured memory_bytes: 11172
#define vi vector<int>
#define pb push_back
#define ll long long
#include <bits/stdc++.h>
using namespace std;

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

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

	int n;
	cin >> n;
	int ans = (n % 1000);
	if (ans != 0) {
		ans = 1000 - ans;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3616
import copy

n, k = map(int, input().split())
nums = list(map(int, input().split()))

ref = [False] * (n + 1)
cyc = False
cyc_num = -1

idx = 0
path = []

while True:
    if ref[idx + 1] == True:
        cyc_num = idx + 1
        break

    cur = nums[idx]
    ref[idx + 1] = True
    path += [idx + 1]
    idx = cur - 1

prev = len(path)

# print('Cyc', cyc_num)
# print('path 1:', ' '.join(list(map(str, path))))

from_idx = 0
for p in path:
    if p == cyc_num:
        break
    else:
        from_idx += 1

new_path = copy.deepcopy(path[from_idx:])

#print('path 2:', ' '.join(list(map(str, new_path))))

start = len(path) - len(new_path)

if k <= start:
    idx = 0

    for i in range(k):
        cur = nums[idx]
        idx = cur - 1

    print(idx + 1)
else:
    k -= start
    k %= len(new_path)

    print(new_path[k])


"""
5 2
2 3 4 5 3
"""

Measured memory_bytes: 100032
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	if(n==m){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256