akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int D; // D: 365
  cin >> D;
  vector< int > C(26);
  cin >> C;
  auto S = make_v< int >(D, 26);
  cin >> S;

  vector< int > T(D);
  cin >> T;
  for(auto &p : T) --p;

  int M;
  cin >> M;
  while(M--) {
    int d, q;
    cin >> d >> q;
    --d, --q;
    T[d] = q;


    int ret = 0;
    vector< int > last(26, -1);
    for(int i = 0; i < D; i++) {
      last[T[i]] = i;
      ret += S[i][T[i]];
      for(int j = 0; j < 26; j++) ret -= C[j] * (i - last[j]);
    }
    cout << ret << "\n";

  }
}



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

using namespace std;
using ll = long long;

int main(void) {
  int n;
  cin >> n;
  vector<char> v(n);
  map<char, ll> m;
  m['R'] = 0;
  m['G'] = 0;
  m['B'] = 0;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    m[v[i]]++; 
  }
  ll ans = m['R'] * m['G'] * m['B'];
  for (int i = 0; i <= n - 3; i++) {
    for (int j = i + 1; j <= n - 2; j++) {
      int k = 2 * j - i;
      if (k > n - 1) {
        continue;
      }
      if (v[i] != v[j] && v[j] != v[k] && v[k] != v[i]) {
        ans--;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3580
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

const int MOD = 1e9 + 7;
int pw(int x, int y) {
	int res = 1;
	while(y) {
		if(y & 1) res = (ll)res * x % MOD;
		x = (ll)x * x % MOD;
		y >>= 1;
	}
	return res;
}

int N, K;
int D[110][10010];

void solve() {
	scanf("%d%d", &N, &K);
	ll ans = K * (K + 1) / 2;
	ans = ans * pw(K+1, N-1) % MOD;
	ans = ans * N % MOD;
	D[N+1][0] = 1;
	int mx = 0;
	for(int i=N;i;i--) {
		for(int j=-i;j<=K-i;j++) {
			for(int k=0;k<=mx;k++) {
				int nk = k;
				if(j <= 0 && -j <= k) {
					nk = (k + (k + j) / i + 1);
					ans = (ans - pw(K+1, i-1) * (ll)D[i+1][k] % MOD * (nk - k)) % MOD;
					if(ans < 0) ans += MOD;
				}
				D[i][nk] = (D[i][nk] + D[i+1][k]) % MOD;
				if(D[i][nk]) mx = max(mx, nk);
			}
		}
	}
	printf("%lld\n", ans);
}

int main(){
	int Tc = 1; // scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}


Measured memory_bytes: 2560
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())

flag = False
for i in range(10):
    for j in range(10):
        if i*j==N:
            flag=True


ans = 'Yes' if flag else 'No'
print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
 
int main()
{
	int h, w;
	char aTemp[101];
	scanf("%d %d", &h, &w);
 
	for (int i = 0; i < w + 2; i++) {
		printf("#");
	}
	printf("\n");
 
	for (int i = 0; i < h; i++) {
		scanf("%s", aTemp);
		aTemp[w] = '\0';
		printf("#%s#\n", aTemp);
	}
 
	for (int i = 0; i < w + 2; i++) {
		printf("#");
	}
 
    return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import division, print_function
import sys


def main():
    n = int(sys.stdin.readline().strip())
    a = map(int, sys.stdin.readline().strip().split(" "))
    b = [0 for _ in range(n)]
    j = 0
    for i in range(n - 1, -1, -2):
        b[j] = a[i]
        j += 1
    for i in range(0 if n % 2 == 0 else 1, n, 2):
        b[j] = a[i]
        j += 1
    print(" ".join(map(str, b)))


if __name__ == '__main__':
    main()


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

int main() {
  int N;
  cin >> N;
  map<int, int> A;
  ll sum = 0;
  rep(i, N) {
    int a;
    cin >> a;
    A[a]++;
    sum += a;
  }
  int Q;
  cin >> Q;
  rep(i, Q) {
    int B, C;
    cin >> B >> C;
    if (A[B] > 0) {
      sum += A[B] * (C - B);
      A[C] += A[B];
      A[B] = 0;
    }
    cout << sum << endl;
  }
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int H, W;
int C[10][10];

int main(){
  cin >> H >> W;
  for (int i = 0; i < 10; i++){
    for (int j = 0; j < 10; j++){
      cin >> C[i][j];
    }
  }

  for (int k = 0; k < 10; k++){
    for (int i = 0; i < 10; i++){
      for (int j = 0; j < 10; j++){
        C[i][j] = min(C[i][j], C[i][k] + C[k][j]);
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < H * W; i++){
    int A; cin >> A;
    if (A == -1) continue;
    ans += C[A][1];
  }
  cout << ans << endl;

  return 0;
}


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

  int N ;
  cin >> N ;
  int A[N+1][2] ;
  double count = 0 ;
  rep(i,N) cin >> A[i][0] >> A[i][1] ;
  vector<double> B(1000) ;
  for(int i = 0 ; i < N ; i++ ){
    for(int j = i+1 ; j < N ; j++ ){
      B[count] =sqrt( (A[j][0] - A[i][0])*(A[j][0] - A[i][0]) + (A[i][1]-A[j][1])*(A[i][1]-A[j][1]) );
      count++ ;
    }
  }
  double ans = 0 ;
  //cout << count << endl ;
  //rep(i,count) cout << B[i] << endl;
  rep(i,1000) ans += B[i] ;
  //cout << ans << endl;
  ans = (N-1)*ans / count ;
  printf("%.6f"  , ans) ;
}

Measured memory_bytes: 256
num = gets.strip.to_i
arr = gets.strip.split(' ').map(&:to_i)
result = true
arr.each_with_index do |e, i|
  if e.even?
    if e % 3 != 0 && e % 5 != 0
      result = false
      break
    end
  end
end
msg = 'DENIED'
msg = 'APPROVED' if result
puts msg

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
 
int main() {
  ll n,m;
  cin >> n >> m;
  vl a;
  inputv(a,m);
  rep(i,100){
    a.push_back(INF);
  }
  
  vl s(n+1,0);
  s[0] = 1;
  ll point = 0;
  if(a[0] == 1){
    s[1] = 0;
    point++;
  } else {
    s[1] = 1;
  }
  for(ll i=2; i<=n; i++){
    if(a[point] == i){
      s[i] = 0;
      point++;
    } else {
      s[i] = (s[i-1] + s[i-2])%MOD;
    }
  }
  cout << s[n];
 return 0;
}

Measured memory_bytes: 1908
import java.util.*;



public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int x = scanner.nextInt();
    
    if(x >= 30){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
    scanner.close();
    return;
  }
  
}


Measured memory_bytes: 35600
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int W = Integer.parseInt(sc.next());
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        
        if(a > b){
            int tmp = a;
            a = b;
            b = tmp;
        }
        
        System.out.println(Math.max(b - (a + W), 0));
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ans = 0;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a, a + n);
  bool b[a[n - 1] + 1];
  for (int i = 0; i < a[n - 1] + 1; i++)
    b[i] = true;

  for (int i = 0; i < n; i++) {
    if (b[a[i]] == true) {
      for (int j = 1; j < a[n - 1] / a[i] + 1; j++)
        b[j * a[i]] = false;
      if (i != n - 1)
        if (a[i] != a[i + 1])
          ans++;
      if (i == n - 1)
        ans++;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 5308
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	ll n, a, b;
	cin >> n >> a >> b;

	if(a + b - 1 > n || a * b < n){
		cout << -1 << endl;
		return 0;
	}

	ll t = n;
	ll v[n];
	for(ll i = b; i >= 1; i--){
		v[n-t] = i;
		t--;
	}

	ll excd = 0;
	for(ll i = 2 * b; i <= a * b; i += b){
		ll d = min(t - (a - i / b), b);
		excd += b - d;
		v[n-t] = i - excd;
		t--;
		
		for(ll j = 0; j < d - 1; j++){
			v[n-t] = i - j - 1 - excd;
			t--;
		}

	}

	rep(i, n){
		cout << v[i] << (i == n - 1 ? "\n" : " ");
	}

}


Measured memory_bytes: 4608
import Data.Vector (Vector)
import qualified Data.Vector as V

main = do
  [a,b,q] <- map read . words <$> getLine
  input   <- V.fromList . map read . lines <$> getContents :: IO (Vector Int)
  let
    (ss, left ) = V.splitAt a input
    (ts, left') = V.splitAt b left
    xs = V.toList left'
  putStr . unlines . map show $ solve ss ts xs

solve ss ts = map (inner ss ts)
  where
  inner ss ts x =
    minimum [ abs (p2 - p1) + abs (p1 - x)
            | (first, second) <- [(fst, snd), (snd, fst)]
            , let nx = ( nears x ss, nears x ts ); ps1 = first nx; ps2 = second nx
            , p1 <- [fst ps1, snd ps1], p2 <- [fst ps2, snd ps2] ]

nears x ps
  | x < V.head ps = ( -10000000000,V.head ps)
  | x < V.last ps = ( V.unsafeIndex ps i, V.unsafeIndex ps (i+1) )
  | otherwise     = ( V.last ps, 20000000000)
  where i = borderl (<=x) ps

borderl f v = inner 0 (V.length v - 1)
  where
  inner i j
    | i == j    = i
    | otherwise = if f $ V.unsafeIndex v m then inner m j else inner i (m-1)
    where m = div (i+j+1) 2


Measured memory_bytes: 150780
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;}


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

int N, M; cin >> N >> M;
VI H(N);
invec(H);
VVI G(N+1);
rep(i, 0, M){
    int a, b; cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
}

int cnt = 0;
rep(s, 1, N+1) {
    bool good = true;
    for(int t : G[s]) {
        if (H[s-1] <= H[t-1]) {
            good = false;
            break;
        }
    }
    cnt += good;
}

cout << cnt << "\n";

return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 問題文から考える。自分ができることから考える。
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索。逆から考える。
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 9772
from collections import Counter
n=int(input())
l=[]
for i in range(2,n+1):
    k=2
    t=i
    while k*k<=t:
        if t%k==0:
            l.append(k)
            t=t//k
        else:k+=1
    if n>0:l.append(t)

c=Counter(l)
ans=1
for key,value in c.items():
    ans*=value+1
print(ans%(10**9+7))



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

using namespace std;
typedef long long ll;
#define rep(i, n, s) for (int i = s; i < (int)(n); i++)

ll calcNumOfCombination(ll n, ll r) {
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }

int findSumDigits(int s) {
    int num = 0;
    int temp = 0;
    while (s) {
        temp = s % 10;
        num += temp;
        s = s / 10;
    }
    return num;
}

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, n, 0) cin >> a[i];
    int alice = 0;
    int bob = 0;

    sort(a, a + n, greater<int>());

    for (int j = 0; j < n; j++) {
        if (j % 2 == 0) {
            alice += a[j];
        } else {
            bob += a[j];
        }
    }

    int ans = alice - bob;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
n, x, m = map(int, input().split())
mod_cnt = [False for _ in range(m)]
mod_cnt[x] = True
cycle = [x]
while len(cycle) < n and not mod_cnt[(x*x) % m]:
	x = (x*x) % m
	mod_cnt[x] = True
	cycle.append(x)

if len(cycle) == n:
	print(sum(cycle))
	sys.exit()

nxt = (x*x) % m
for i in range(len(cycle)):
	if cycle[i] == nxt:
		head = i
		break

ans = sum(cycle[:head])
cycle = cycle[head:]
period = len(cycle)
n -= head
for i, x in enumerate(cycle):
	if i < n % period:
		ans += (n // period + 1) * x
	else:
		ans += (n // period) * x
print(ans)

Measured memory_bytes: 73252
n = int(input())
A = list(map(int,input().split()))
mod = 10**9+7

B = []
tmp = 0
for i in range(n):
    tmp += A[n-i-1]
    tmp %= mod
    B.append(tmp)

sum = 0
for i in range(n-1):
    sum += A[i]*B[n-i-2]
    sum %= mod
print(sum)

Measured memory_bytes: 31408
#include<iostream>
#include<math.h>
#include<iomanip>
using namespace std;

int main(){
    double n, k;
    cin >> n >> k;
    double ans = 0;
    for (double m = 1; m < n + 1; m++)
    {
        int t = 0;
        int point = m;
        double now = 1.0 / n;
        while (point <k)
        {
            point *= 2;
            now /= 2;
        }
        ans += now;
    }
    cout << fixed << setprecision(15) << ans  << endl;
    return 0;
}

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

int main (void){
  int a,b,n,m;
  int road[55] = {};
  cin >> n >> m;

  for(int i = 0;i < m;i++){
    cin >> a >> b;
    a--;
    b--;
    road[a]++;
    road[b]++;
  }

  for(int i = 0;i < n;i++){
    cout << road[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 3560
#include <iostream>
using namespace std;
int main () {
    int n, x;
    cin >> n >> x;
    while (n != 0 || x != 0) {
        int w = 0;
        for (int i = 1; i <= n - 2; i++)
            for (int j = i + 1; j <= n - 1; j++) 
                for (int k = j + 1; k <= n; k++)
                    if (i + j + k == x)
                        w += 1;
        cout << w << "\n";
        cin >> n >> x;
    }
    
}


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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}
ll n;
ll  a[100000] = {0};
int main(){
  scanf("%lld",&n);
  REP(i,n){
    int b;
    scanf("%lld",&b);
    if(i==0){
      a[i] = b;
    }else{
      a[i] = a[i-1]+b;
    }
  };
  ll cnt = 0;
  ll tmp = 0;
  REP(i,n){
    ll t = a[i]+tmp;
    //printf("%lld %lld %lld %lld\n",t,cnt,a[i],tmp);
    if(i%2 == 0 && t>=0){
      cnt += abs(t)+1;
      tmp -= (abs(t)+1);
    }else if(i%2 == 1 && t <= 0){
      cnt += abs(t)+1;
      tmp += abs(t)+1;
    }
  }
  ll cnt_t = 0;
  tmp = 0;
  REP(i,n){
    ll t = a[i]+tmp;
    //printf("%lld %lld %lld %lld\n",t,cnt_t,a[i],tmp);
    if(i%2 == 1 && t>=0){
      cnt_t += abs(t)+1;
      tmp -= (abs(t)+1);
    }else if(i%2 == 0 && t <= 0){
      cnt_t += abs(t)+1;
      tmp += abs(t)+1;
    }
  }
  printf("%lld\n",min(cnt,cnt_t));
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
    int k,x;
    cin>>k>>x;
    if(k==1){cout<<x<<endl;return 0;}
    for(int i=x-k+1;i<=k+x-1;i++){
        cout<<i<<" ";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a[10000],i=0,k=0,j,l;
	while(k==0){
		scanf("%d %d",&a[i],&a[i+1]);
		if(a[i]==0 && a[i+1]==0){
			k=1;
		}else{
			i=i+2;
		}
	}
	l=i/2;
	int x,y,z,q;
	for(j=1;j<=l;j++){
		for(x=1;x<=a[2*j-1];x++){
			printf("#");
		}
		printf("\n");
		for(y=1;y<=a[2*j-2]-2;y++){
			printf("#");
			for(z=1;z<=a[2*j-1]-2;z++){
				printf(".");
			}
			printf("#\n");
		}
		for(q=1;q<=a[2*j-1];q++){
			printf("#");
		}
		printf("\n\n");
	}
	return 0;
}


Measured memory_bytes: 2032
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
// please, read the question correctly (do you need set or multiset)???
const int N=200010; //check the limits, dummy
int a[N];
int n, m;
int main(){
	int t;
	// while(){
	int k;
		scanf("%d%d",&n,&k);
		for(int i=0; i<n; ++i){
			scanf("%d",a+i);
		}
		for(int i=k; i<n; ++i){
			if(a[i]>a[i-k]){
				printf("Yes\n");
			}
			else{
				printf("No\n");
			}
		}
	// }
}

Measured memory_bytes: 4540
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<utility>
#include<queue>
#include<stdbool.h>
#include<math.h>
#include<sstream>
typedef long long ll;
#define N (1000000000+7)
using namespace std;
typedef pair<int, int> P;

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

bool num[32][32];
int main(void) {
	int n, m, k, l;
	for (int i = 0;i < 32;i++) {
		for (int j = 0;j < 32;j++) {
			num[i][j] = false;
		}
	}
	cin >> n >> m;
	for (int i = 1;i <= n;i++) {
		cin >> k;
		for (int j = 1;j <= k;j++) {
			cin >> l;
			num[i][l] = true;
		}
	}
	int ans = 0, numb = 0;;
	for (int i = 1;i <= m;i++) {
		numb = 0;
		for (int j = 1;j <= n;j++) {
			if (num[j][i])numb++;
		}
		if (numb == n)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
using namespace std;


long long n, m;

int main(){
    cin >> n >> m;
    

    set<long long> from_1;
    set<long long> from_n;

    for(int i = 1;i <= m; i++){
        long long a, b;
        cin >> a >> b;
        if(a == 1){
            from_1.insert(b);
        }
        if(b == n){
            from_n.insert(a);
        }    
    }

    if(from_n.empty()){
        printf("IMPOSSIBLE\n");
        return 0;
    }

    if(m == 1){
        printf("IMPOSSIBLE\n");
        return 0;
    }

    bool flag = false;

    set<long long>::iterator it;

    for(it = from_1.begin(); it != from_1.end(); it++){
        if(from_n.find(*it) != from_n.end()){
            flag = true;
            break;
        }
    }

    if(flag == true){
        printf("POSSIBLE\n");
    }
    else{
        printf("IMPOSSIBLE\n");
    }
    
    return 0;

}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
//#define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef vector<ll>Vl;
typedef pair<ll,ll>PII;
typedef vector<PII>Vll;
typedef vector<pair<ll,pair<ll,ll> > >Vlll;
typedef priority_queue<ll>PQL;
typedef map<ll,ll>MP;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) scanf("%lld",&n)
#define pl(n) printf("%lld",n)
const ll mod=1e9+7;
const ll sze=1e5+2;

ll WilsonT(ll N){
   ll fact=1;
   for(ll i=1;i<=N-1;i++)fact=(fact*i)%N;
   return (fact%N)==N-1;
}

int main(){
	ll N;
	sl(N);
	for(ll i=N;;i++){
		if(WilsonT(i)){
			cout<<i<<endl;
			return 0;
		}
		
	}
  return 0;
}


Measured memory_bytes: 384
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)

    val s = sc.nextLine()
    val n = sc.nextInt()


    var list = LinkedList<String>()
    list.addFirst(s)
    var isReverse = false

    for(i in 0 until n){
        val q = sc.nextInt()
        if(q == 1){
//            a = a.reversed()
            isReverse = !isReverse
        } else if(q == 2){
            val t = sc.nextInt()
            val c = sc.next()

            if(t == 1){
                if(isReverse){
//                    a = a + c
                    list.addLast(c)
                } else {
//                    a = c + a
                    list.addFirst(c)
                }
            }
            if(t == 2){
                if(isReverse){
//                    a = c + a
                    list.addFirst(c)
                } else {
//                    a = a + c
                    list.addLast(c)
                }
            }
        }
    }

    if(isReverse) {
//        a = a.reversed()
        list.reverse()
        list.forEach {
            if(it.length > 1){
                print(it.reversed())
            } else {
                print(it)
            }
        }
    } else {

        list.forEach(::print)
    }


//    println(a)


}


Measured memory_bytes: 128316
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/



int main() {
int N;
cin>>N;
int X[N];
rep(i,N){
    cin>>X[i];

}
ll min_sum=100000000000000;
rep3(P,100){
    ll sum=0;
    rep(i,N){
        sum+=(ll)powl(X[i]-P,2);
    }
    min_sum=min(min_sum,sum);
}
cout<<min_sum<<endl;

return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//MOD
//--------------------------------------------
#define MUL(a,b) (((a) % MOD) * ((b) % MOD)) % MOD

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//main code

int main(int argc, char const* argv[])
{
	string s;
	cin >> s;
	int f = (s[0] - '0') * 10 + (s[1] - '0');
	int b = (s[2] - '0') * 10 + (s[3] - '0');
	if (f > 12 or f == 0) { // f = YY
		if (b > 12 or b == 0) {
			cout << "NA" << endl;
		}
		else {
			cout << "YYMM" << endl;
		}
	}
	else { // f = MM
		if (b > 12 or b == 0) {
			cout << "MMYY" << endl;
		}
		else {
			cout << "AMBIGUOUS" << endl;
		}
	}
	return 0;
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    if(n == 1){
    	cout << 1 << endl;
    	return 0;
    }
    long long a[n];
    cin >> a[0];
    bool up = false, down = false, next = true;
    long long ans = 1;
    for(int i = 1; i < n; i++){
    	cin >> a[i];
    	if(a[i] == a[i-1]) continue;
    	if(next){
    		if(a[i] > a[i-1]) up = true;
    		else down = true;
    		next = false;
    	}
    	else{
    		if(up){
    			if(a[i] < a[i-1]){
    				up = false;
    				ans++;
    				next = true;
    			}
    		}
    		else if(down){
    			if(a[i] > a[i-1]){
    				down = false;
    				ans++;
    				next = true;
    			}
    		}
    	}
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(void){
  int a,b,n;
  
  cin >> a >> b;
  
  for (n=1;n<2000;n++){
    if (n*8/100==a && n/10==b){
      cout << n << endl;
      return 0;
    }
  }
  
  cout << -1 << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.math.BigDecimal;

public class Main{
	public Main(){
		Scanner sc = new Scanner(System.in);
		BigDecimal n = new BigDecimal(sc.next());
		
		BigDecimal sum = new BigDecimal("0");
		while(sc.hasNext()){
			BigDecimal tmp = new BigDecimal(sc.next());
			sum = sum.add(tmp);
		}
		sum = sum.divide(n, BigDecimal.ROUND_HALF_UP);
		System.out.println(sum);
	}
	
	public static void main(String[] args){
		Main test = new Main();
	}
}

Measured memory_bytes: 12000
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
  long long  TIME[11111],sum[11111],ret;
  int n;
  while(1){
    cin >> n;
    if(!n)break;
    memset( TIME , 0 , sizeof(TIME) );
    memset( sum , 0 , sizeof(sum) );
    for(int i=0;i<n;i++){
      cin >> TIME[i];
    }
    sort( TIME , TIME + n );
    ret = 0;
    sum[0] = 0;
    for(int i=1;i<n;i++){
      sum[i] = TIME[i-1] + sum[i-1];
      ret += sum[i];
    }
    cout << ret << endl;
  }
}

Measured memory_bytes: 1360
n = int(input())
ansl = [0 for _ in range(n+1)]
for x in range(1, 101):
	for y in range(1, 101):
		for z in range(1, 101):
			targ = x**2 + y**2 + z**2 + x*y + y*z + z*x
			if targ <= n:
				ansl[targ] += 1
for i in range(1, n+1):
	print(ansl[i])

Measured memory_bytes: 69420
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
using namespace std;

int n;

int main(){
  int v[40];
  for (int i = 1; i < 31; i++){
    v[i] = 0;
  }
  for (int i = 1; i < 29; i++){
    cin >> n;
    v[n] = 1;
  }
  for (int i = 1; i < 31; i++){
    if(v[i] == 0) cout << i << endl;
  }
  return 0;
}

Measured memory_bytes: 3120
/*
题意是求一个序列中"所有子序列的中位数"所组成的序列的中位数 
看题解了，完全不会。https://www.cnblogs.com/quzhizhou/p/9535597.html  

首先我们先二分最后序列的中位数。设tot为中位数 >= mid的区间个数，若中位数序列的中位数 >= mid，
则有tot >= n(n+1)/4。
我们另外构造一个序列b[i], 当a[i]>=mid时b[i]=1, 否则bi=-1. 
那么若区间[l, r]的中位数 >= mid, 则b[l]+...+b[r] >= 0. 
于是我们求出序列b[i]的前缀和序列sum[i]，那么问题就变成了求满足l <= r且sum[r]-sum[l-1]>=0的数对(l,r)数量(0<=l,r<=n)，
这个问题可以用与求逆序对数量相似的方法解决. 树状数组即可. 
*/ 
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;

const int NN = 110000;
int a[NN], l, r, n, mid, ans;
int s[NN * 2];  
//树状数组，注意，[-n-1, n], 为了让每一个存的值都是>0, 都加上n即可（因为树状数组不能从0开始）
//所以开双倍空间给数组 

int lowbit(int x){
	return x & (-x);
} 

void add1(int x, int k){
	while (x <= n * 2){
		s[x] += k;
		x += lowbit(x);
	}
}

int getsum(int x){
	int sum = 0;
	while (x > 0){
		sum += s[x];
		x -= lowbit(x);
	}
	return sum;
}

int check(int mid){
	memset(s, 0, sizeof(s));  //树状数组清0 
	//for(int i=1;i<=2*n;i++)s[i]=0;
	//与求逆序对的方法相同 
	add1(n, 1);  //因为在每个数的基础上都加了n，所以这句话相当于在和等于0的点+1
	ll sum = 0;
	ll tmp = 0;
	for (int i=1; i<=n; i++){
		if (a[i] >= mid) sum++;
		else sum--;
		tmp += getsum(sum + n);
		add1(sum + n, 1);
	} 
	//return tmp>=1ll*n*(n+1)/4;
	long long nn = n * (n + 1) / 4; //注意！nn必须给long long
	if (tmp >= 1ll*n*(n+1)/4) return true;
	else return false; 
}

int main(){
	//freopen("atcoderarc101d.in", "r", stdin);
	
	scanf("%d", &n);
	l = 0x7fffffff; r = 0;
	for (int i=1; i<=n; i++){
		scanf("%d", &a[i]);
		if (a[i] >= r) r = a[i];
		if (a[i] <= l) l = a[i];
	}
	//printf("%d %d\n", l, r);
	while (l <= r){
		mid = (l + r) / 2;
		if (check(mid)){
			ans = mid; 
			l = mid + 1;
		} else r = mid-1;
	}
	printf("%d", ans);
	
	return 0;
} 

Measured memory_bytes: 1536
import heapq

X, Y, A, B, C = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = list(map(lambda x: int(x) * -1, input().split()))
heapq.heapify(r)


base = p[0:X] + q[0:Y]
heapq.heapify(base)

for i in range(X+Y):
    if i >= C:
        break

    R = -r[0]
    b = base[0]
    if R > b:
        heapq.heappop(base)
        heapq.heappop(r)
        heapq.heappush(base, R)
    else:
        break

print(sum(base))






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

int main() {
  int N, A;
  cin >> N >> A;
  int amari;
  amari = N % 500;
  if ( A >= amari){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3596
# import sys
# input = sys.stdin.readline

def mp(): return map(int, input().split())
def lmp(): return list(map(int, input().split()))
x,k,d = mp()
x = abs(x)
if x - k*d >= 0:
    print(x-k*d)
else:
    u = x % d
    l = abs(u - d)
    if (k - x//d) % 2 == 0:
        print(u)
    else:
        print(l)




Measured memory_bytes: 61796
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define MOD 1000000007



int main() {
    int N,M;
    cin >> N >> M;
    vi a(M),b(M);
    rep(i,M) cin >> a[i] >> b[i];

    vector<pii> inv(M);
    rep(i,M) inv[i] = mp(b[i],a[i]);
    sort(all(inv));

    int ans = 0;
    int tmp = 0;
    rep(i,M)
    if(inv[i].second >= tmp){
        ans++;
        tmp = inv[i].first;
    }

    cout << ans << endl;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

#define INF 1e20

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vi X[3], Y[3]; //-1, +1, 0
    int _v[]={-1,1,0};
    rep(i,n){
        int x,y; char c;
        cin>>x>>y>>c;
        if (c=='L'){
            X[0].pb(x);
            Y[2].pb(y);
        }
        if (c=='R'){
            X[1].pb(x);
            Y[2].pb(y);
        }
        if (c=='U'){
            X[2].pb(x);
            Y[1].pb(y);
        }
        if (c=='D'){
            X[2].pb(x);
            Y[0].pb(y);
        }
    }
    vector<pi> xp, yp;
    rep(i,3){
        if (X[i].size()){
            sort(all(X[i]));
            xp.emplace_back(X[i].front(), _v[i]);
            if (X[i].front()!=X[i].back()) xp.emplace_back(X[i].back(), _v[i]);
        }
        if (Y[i].size()){
            sort(all(Y[i]));
            yp.emplace_back(Y[i].front(), _v[i]);
            if (Y[i].front()!=Y[i].back()) yp.emplace_back(Y[i].back(), _v[i]);
        }
    }
    int xsz = xp.size();
    int ysz = yp.size();
    vector<double> epoch;
    epoch.pb(0.0);
    rep(i,xsz)FOR(j,i+1,xsz-1){
        int s = xp[j].se-xp[i].se;
        int x = xp[i].fi-xp[j].fi;
        if (s*x>0) epoch.pb((double)x/s);
    }
    rep(i,ysz)FOR(j,i+1,ysz-1){
        int s = yp[j].se-yp[i].se;
        int y = yp[i].fi-yp[j].fi;
        if (s*y>0) epoch.pb((double)y/s);
    }
    int sz = epoch.size();
    double ans=INF;
    rep(i,sz){
        double t = epoch[i];
        double xmi=INF,xma=-INF;
        double ymi=INF,yma=-INF;
        rep(j,xsz){
            double x = t*xp[j].se+xp[j].fi;
            xmi = min(xmi, x);
            xma = max(xma, x);
        }
        rep(j,ysz){
            double y = t*yp[j].se+yp[j].fi;
            ymi = min(ymi, y);
            yma = max(yma, y);
        }
        ans = min(ans, (xma-xmi)*(yma-ymi));
    }
    cout<<setp(12)<<ans<<endl;
    return 0;
}


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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;

int N, M, K;
int Asum[200200];
int Bsum[200200];

signed main() {
    cin >> N >> M >> K;
    rep(i, N) {
        int a;
        cin >> a;
        Asum[i + 1] = Asum[i] + a;
    }
    rep(i, M) {
        int b;
        cin >> b;
        Bsum[i + 1] = Bsum[i] + b;
    }
    int ans = 0;
    for (int a = 0; a <= N; ++a) {
        if (Asum[a] > K)break;
        int b = upper_bound(Bsum, Bsum + M + 1, K - Asum[a]) - Bsum - 1;
        ans = max(ans, a + b);
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
const long double eps = 1e-9;
int a[2900], b[2000];
long double f[300][300];
int n;
int main() {
    ios_base::sync_with_stdio(0);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) cin >> b[i];
    for (int i = 0; i <= n + 1; i++)
    for (int j = 0; j <= 100; j++) f[i][j] = -1;
    f[1][0] = 0;
    b[0] = 0;
    for (int i = 1; i <= n; i++) {
        for (int v = 0; v <= b[i]; v++)
        for (int nv = 0 ; nv <= b[i]; nv++) {
            if (f[i][v] == -1) continue;
            int d = abs(v - nv);
            if (d > a[i]) continue;
            long double dst = 0;
            if (b[i] - v + b[i] - nv <= a[i]) {
                dst += v * (b[i] - v) + 1.0 * (b[i] - v) * (b[i] - v) / 2;
                dst += b[i] * (b[i] - nv) - 1.0 * (b[i] - nv) * (b[i] - nv) / 2;
                dst += b[i] * (a[i] - b[i] + v - b[i] + nv);
            }
            else {
                long double speed = (1.0 * a[i] + v + nv) / 2;
                long double t1 = (speed - v);
                long double t2 = (speed - nv);
                dst += v * t1 + t1 * t1 / 2;
                dst += speed * t2 - t2 * t2 / 2;
            }
            f[i + 1][nv] = max(f[i + 1][nv], f[i][v] + dst);
        }
    }
    cout.precision(10);
    cout << fixed << f[n + 1][0] << "\n";
    return 0;
}


Measured memory_bytes: 768
#include<stdio.h> 
#include<iostream> 
#include<string.h>
#include<cstring>
#include<string>
#include<math.h>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
#define cuttime ios::sync_with_stdio(false)
#define swap(x, y) x ^= y, y ^= x, x^= y
#define INF 0x3f3f3f3f
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define dep(i,a,b) for(int i=(a);i>=(b);--i)
#define scan1(x) scanf("%d",&x)
#define scan2(x,y) scanf("%d%d",&x,&y)
#define scan3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define scanll1(x) scanf("%lld",&x)
#define scanll2(x,y) scanf("%lld%lld",&x,&y)
#define scanll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define lowbit(x) (x&(-x))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N=2e5+20;
const int MAX=10000007;
inline int read() {
    char c=getchar();int x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0',c=getchar();}
    return x*f;
}

inline void out(int x) {   
	if(x>9) out(x/10);   
	putchar(x%10+'0'); 
} 
char s[20];
int main(){
	cin>>s+1;
	int len=strlen(s+1);
	for(int i=1;i<=len;++i){
		if(s[i]=='7'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3584
def mi():
    return map(int, input().split())

def main():
    S = input()
    T = input()
    ds = {}
    dt = {}
    for i in range(len(S)):
        if not S[i] in ds:
            ds[S[i]] = 0
        if not T[i] in dt:
            dt[T[i]] = 0

        ds[S[i]] += 1
        dt[T[i]] += 1
    ls = sorted(list(ds.values()))
    lt = sorted(list(dt.values()))
    
    print('Yes' if ls == lt else 'No')


if __name__ == '__main__':
    main()

Measured memory_bytes: 41840
#include<stdio.h>

int main(void) {
	int m = 0, n = 0;
	char a[10], b[10], c[10];
	scanf("%s %s %s", a, b, c);
	for (; a[m] != '\0'; m++) ;
	for (; b[n] != '\0'; n++) ;
	if (a[m - 1] == b[0] && b[n - 1] == c [0]) printf("YES");
	else printf("NO");
	return 0;
}

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

int main(){
    int n, r;
    cin >> n >> r;
    if(n >= 10) cout << r << endl;
    else cout << r + 100*(10 - n) << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>

int main(void)
{
    int a, b, c, m;

    scanf("%d %d %d", &a, &b, &c);

    if (a > b){
        m = b;
        b = a;
        a = m;
    }
    
    if (b > c){
        m = c;
        c = b;
        b = m;
        }
        
    if (a > b){
        m = b;
        b = a;
        a = m;
    }
    
    printf("%d %d %d\n", a ,b ,c);

    return 0;
    
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
#define db(x) cerr<<#x<<" = "<<x<<'\n';
using namespace std;

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

int L;
vector<Edge> edges;

void addEdge(int u,int v,int w) {
	edges.push_back({u,v,w});
}

void print(int n) {
	cout<<n<<' '<<edges.size()<<'\n';
	for(Edge edge:edges)
		cout<<edge.u<<' '<<edge.v<<' '<<edge.w<<'\n';
}

int main() {
	//freopen("input","r",stdin);
	//freopen("output","w",stdout);
	cin>>L;
	int k=log2(L),mul=1;
	for(int i=1;i<=k;i++) {
		addEdge(i,i+1,mul);
		addEdge(i,i+1,0);
		mul*=2;
	}
	int rem=L-(1<<k);
	for(int i=k;i>=1;i--)
		if(rem>=(1<<(i-1))) {
			rem-=(1<<(i-1));
			addEdge(i,k+1,mul);
			mul+=(1<<(i-1));
		}
	print(k+1);
}



Measured memory_bytes: 3820
#include <iostream>
#include <string>
 
int main() {
    std::string S;
    std::cin >> S;

 
    if (S == "ARC") {
        std::cout << "ABC" << std::endl;
    }else {
        std::cout << "ARC" << std::endl;
    }
 

 
    return 0;
}

Measured memory_bytes: 3532
def main():
    s = list(input())
    s12 = int(s[0]) * 10 + int(s[1]) * 1
    s34 = int(s[2]) * 10 + int(s[3]) * 1
    l = list()
    for i in [s12, s34]:
        if i >= 1 and i <= 12:
            l.append(True)
        else:
            l.append(False)
    if l[0] == False and l[1] == False:
        print('NA')
    elif l[0] == False and l[1] == True:
        print('YYMM')
    elif l[0] == True and l[1] == False:
        print('MMYY')
    else:
        print('AMBIGUOUS')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <math.h>

using namespace std;

int main(void) {
	string s;

	
	cin >> s ;
	int flag = 0;
	int f = 0;
	
	for (int i = 0; i < s.length(); i++)
	{
		if (s.at(i) == 'C')
		{
			flag = 1;
		}
		if ((flag == 1) && (s.at(i) == 'F'))
		{
			f = 1;
		}
	}

	if (f > 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi   = vector<int>;
using vll  = vector<long long>;
using vvi  = vector<vi>;
using vb   = vector<bool>;
using vvb  = vector<vb>;
using pii  = pair<int,int>;
using vpii = vector<pii>;



int find (int x, vi &par) {
    if (par.at(x) == x) {
        return x;
    } else {
        return par.at(x) = find(par.at(x), par);
    }
}

void unite (int x, int y, vi &rank, vi &par) {
    x = find(x, par);
    y = find(y, par);
    if (x==y) return;

    if (rank.at(x) < rank.at(y)) {
        par.at(x) = y;
    } else {
        par.at(y) = x;
        if (rank.at(x) == rank.at(y)) rank.at(x)++;
    }
}

int main() {
    int N, M; cin >> N >> M;
    vi par(N); for(int i = 0; i < N; i++) par.at(i) = i;
    vi rank(N);for(int i = 0; i < N; i++) rank.at(i) = 0;
    vi A(M), B(M);for(int i = 0; i < M; i++) cin >> A.at(i) >> B.at(i);
    for(int i = 0; i < M; i++) {
        A.at(i)--;
        B.at(i)--;
    }

    for (int i = 0; i < M; i++) {
        unite(A.at(i), B.at(i), rank, par);
    }

    vi tmp(N);for(int i = 0; i < N; i++) tmp.at(i) = 1;
    for (int i = 0; i < N; i++) {
      int aaa = find (i, par);
        if(i!= aaa) tmp.at(aaa)++;
    }
  	sort(tmp.begin(), tmp.end());
  	cout << tmp.at(N-1);
}

Measured memory_bytes: 7164
import sys
sys.setrecursionlimit(10**7)

#debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)



def solve():
    n, x = map(int, input().split())
    l_list = list(map(int, input().split()))

    d = 0
    count = 1
    for l in l_list:
        d = d + l
        if d <= x:
            count += 1
        else:
            break
    print(count)

solve()

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>

#define MAX 1000001

using namespace std;

int main(){
  bool p[MAX];
  memset(p, 0, sizeof(p));
  
  for(int i = 1 ; i < MAX ; i++){
    int tmp = i;
    bool flag = true;
    while(tmp != 1){
      if(tmp % 2 == 0) tmp /= 2;
      else if(tmp % 3 == 0) tmp /= 3;
      else if(tmp % 5 == 0) tmp /= 5;
      else{
	flag = false;
	break;
      }
    }
    if(flag) p[i] = true;
  }

  int n, m;
  while(cin >> m, m){
    cin >> n;
    int cnt = 0;
    for(int i = m ; i <= n ; i++){
      if(p[i]) cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 0
import math
A,B,H,M = list(map(int, input().split()))
A = float(A)
B = float(B)
H = float(H)
M = float(M)

t = abs((H/12 + (M/60)/12) - M/60)
print( math.sqrt( A**2 + B**2 - 2*A*B*math.cos(2*math.pi*t) ) )

Measured memory_bytes: 9492
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace MyProgram
{
    public class Program
    {	
        public static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int N = int.Parse(s);
            int a = 0;
            for(int i = 0 ; i < s.Length ; i++)
            {
                a += int.Parse(s[i].ToString());
            }

            if(N%a==0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k, s;
    cin >> n >> m >> s;
    vector<vector<pair<ll, pair<ll, ll>>>> G(n);
    for(i = 0; i < m; i++) {
        ll u, v, a, b;
        cin >> u >> v >> a >> b;
        G[--u].push_back({--v, {a, b}});
        G[v].push_back({u, {a, b}});
    }
    vector<pair<ll, ll>> chenge(n);
    for(auto &x : chenge) {
        cin >> x.first >> x.second;
    }
    s = min(6000ll,s);
    vector<vector<ll>> cost(n, vector<ll>(6000, INF));
    priority_queue<pair<ll, pair<ll, ll>>, vector<pair<ll, pair<ll, ll>>>, greater<pair<ll, pair<ll, ll>>>> que;
    cost[0][s] = 0;
    que.push({0, {0, s}});
    while(!que.empty()) {
        auto now = que.top();
        auto pos = now.second.first;
        auto tim = now.first;
        auto silver = now.second.second;
        que.pop();
        //if(pos==1 && silver == 1)cout << tim << " " << pos << " " << silver << endl;
        if(tim > cost[pos][min(6000ll,silver)]) continue;
        if(tim + chenge[pos].second < cost[pos][min(6000ll, silver + chenge[pos].first)]) {
            //if(pos==1 && silver+chenge[pos].first == 1)cout << "a" << endl;
            cost[pos][min(6000ll, silver + chenge[pos].first)] = tim + chenge[pos].second;
            que.push({cost[pos][min(silver + chenge[pos].first, 6000ll)], {pos, min(6000ll,silver + chenge[pos].first)}});
        }
        for(auto &x : G[pos]) {
            if(silver >= x.second.first && tim + x.second.second < cost[x.first][silver - x.second.first]) {
                cost[x.first][silver - x.second.first] = tim + x.second.second;
                que.push({cost[x.first][silver - x.second.first], {x.first, silver - x.second.first}});
            }
        }
    }
    for(i = 1; i < n; i++) {
        ll ret = INF;
        for(auto &x : cost[i]) {
            ret = min(ret, x);
        }
        cout << ret << endl;
    }
    //cout << cost[1][1] << endl;
    return 0;
}

Measured memory_bytes: 11892