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

#define ll long long

#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define fill(a,b) memset(a,b,sizeof(a))

#define f first
#define s second
#define pb push_back

#define inf 1e17
#define ninf -1*1e17
#define mod 1000000007
#define N 500005
#define Ns 5005

string s;
ll n,m,o,x,y,z,d,k,l,r;
ll a[N];

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
	int t=1;
	//cin>>t;
	while(t--){
	    
	    ll ans=0;
	    cin>>n;
	    ans=(n==0);

	    cout<<ans<<"\n";
	    
	    
	}
	return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <array>
#include <map>
#include <set>

using namespace std;

int64_t digit(int64_t num)
{
    int64_t ans = 0;
    while (num > 0)
    {
        ans += num % 10;
        num /= 10;
    }
    return ans;
}

int main()
{
    int64_t num;
    cin >> num;
    cout << (num % digit(num) == 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readInteger()
    val acount = readIntegerList().distinct().size
    if (n == acount) {
        println("YES")
    } else {
        println("NO")
    }
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 80864
n = gets.chop.to_i
a = gets.chop.split.map(&:to_i)

sum_n = a.inject(:+)

x = 0
ans = Float::INFINITY

(n-1).times do |i|

  x += a[i]
  y = sum_n - x

  ans = [ans, (x-y).abs].min
end


p ans

Measured memory_bytes: 20484
#include <iostream>
#include <vector>

using namespace std;


int main(void){
   int N, l, r;
   char s;
   cin >> N;
   vector<char> vec(N);
   
   l = 0, r = 0;
   for(int i = 0; i < N; i++)
   {
      cin >> s;
      vec[i] = s;
      //みぎかっこ必要な数求める
      if(s == ')')
      {
          if(l > 0 )
          {
              l--;
          }else{
              r++;
          }
      }
      else if(s == '(' )
      {
          l++;
      }
   }
   
   if(l > 0)
   {
       for(int i = 0; i < l ; i++)
       {
           vec.push_back(')');
       }
   }
   if(r > 0)
   {
       for(int i = 0; i < r; i++)
       {
           vec.insert(vec.begin(),'(');
       }
   }
   
   for(auto x:vec){
       cout << x;
   }
   cout << endl;
   return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b, ans;
    scanf("%d %d", &a, &b);
    int p = a + b;
    int m = a - b;
    int k = a * b;
    if (m > p) {
        if (m > k) {
            ans = m;
        } else {
            ans = k;
        }
    } else {
        if (p > k) {
            ans = p;
        } else {
            ans = k;
        }
    }
    printf("%d", ans);
    return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if (abs(c-a) <= d || (abs(b-a) <= d && abs(c-b) <= d)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define ff first
#define ss second
#define sfi(a) scanf("%d",&a)
#define sfi2(a,b) scanf("%d %d",&a,&b)
#define sfi3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfll(a) scanf("%lld",&a)
#define inf 1e9
#define m_p make_pair
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define mem(x,val) memset(x,val,sizeof(x))
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)
#define FAST  ios_base::sync_with_stdio(0);cout.tie(0)
#define sqr(x) ((x)*(x))

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
const ll M = 1e9+7;
const int sz = 1000001;
int main()
{
    int k,n;
    cin >> k >> n;
    ll arr[n];
    for(int i=0;i<n;i++) cin >> arr[i];

    sort(arr,arr+n);
    ll tot = 10000000000;
    ll start = 0;
    tot = min(arr[n-1]-arr[0],tot);
    tot = min(tot,(k - (arr[1] - arr[0])));
    for(int i=1;i<n-1;i++){
        ll tmp1 = k - (arr[i] - arr[i-1]);
        ll tmp2 = k - (arr[i+1] - arr[i]);
        tot = min({tmp1,tmp2,tot});
    }

    cout << tot << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, K, V[50], res;

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

	for (int i = 0; i < N; ++i) {
		for (int j = N; j >= i; --j) {
			if (i + N - j <= K) {
				int c = 0;
				priority_queue<int, vector<int>, greater<int>>q;
				for (int k = 0; k < i; ++k) {
					c += V[k];
					q.push(V[k]);
				}
				for (int k = N - 1; k >= j; --k) {
					c += V[k];
					q.push(V[k]);
				}
				res = max(res, c);
				for (int k = i + N - j + 1; k <= K&&!q.empty(); ++k) {
					c -= q.top();
					q.pop();
					res = max(res, c);
				}
			}
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
class Program
{

    static void Main()
    {
        string[] DTS = Console.ReadLine().Split(' ');
        int D = int.Parse(DTS[0]);
        int T = int.Parse(DTS[1]);
        int S = int.Parse(DTS[2]);
        long a = 0;

        a = T * S;

        if(a>=D)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }

}



Measured memory_bytes: 27520
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {        
    int n;
    cin >> n;
    vector<long long int> v{2, 1};
    for (int i = 2; i <= n; i++) {
        v.push_back(v[i - 1] + v[i - 2]);
    }
    cout << v[n] << endl;
}


Measured memory_bytes: 3632
#pragma warning( disable : 6031)

#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <math.h>
int minimum(int a, int b) { return a < b ? a : b; }
int maximum(int a, int b) { return a > b ? a : b; }
//const long long mod = 1000000007;
const long long mod = 998244353;
const double PI = 3.14159265358979323846;
using std::vector;
using std::pair;
using std::string;
using std::map;
using std::abs;
using std::priority_queue;

int main() {
	int A, B, H, M;
	scanf("%d %d %d %d", &A, &B, &H, &M);
	double a = A;
	double b = B;
	double h = H;
	double m = M;
	double res = sqrt(a * a + b * b - 2 * a * b * cos(((h + m / 60) / 12 - m / 60) * 2 * PI));
	printf("%12.12lf", res);
	return 0;
}

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

int main()
{
	int N,i,j,c,m;
	while(cin>>N)
	{
		m=0;
		for(i=1;i<=9;i++)
		{
			for(j=1;j<=9;j++)
			{
				c=i*j;
				if(c==N){
					m=1;
					break;
				}
			}
		}
		if(m==0){
			cout<<"No"<<endl;
		}
		else if(m==1){
			cout<<"Yes"<<endl;
		}
	}
}

Measured memory_bytes: 256
N = gets.to_i
S = N.times.map{
	gets.strip
}

T = S.map{|si|
	(0...N).select{|j| si[j]==?1 }
}
Ds = lambda{|dbase|
	ds, d, q = [nil]*N, 1, [nil]*N
	ds[dbase] = d
	q.clear; q << dbase
	until q.empty?
		q.size.times{
			T[q.shift].each{|j|
				case ds[j]
				when nil
					ds[j] = d+1
					q << j
				when d+1
				when d-1
				else
					raise
				end
			}
		}
		d += 1
	end
	return ds
}
begin
	p (0...N).map{|i| Ds[i].max }.max
rescue RuntimeError
	p(-1)
end


Measured memory_bytes: 4220
from functools import reduce
import math

def main():
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    

    s = list(_ for _ in input())
    max_s = 0
    from_i = 0
    to_i = 0
    for i in range(len(s)):
        if s[i] == 'A':
            from_i = i
            break
    s = s[::-1]
    for i in range(len(s)):
        if s[i] == 'Z':
            to_i = i
            break

    print((len(s)-to_i) - from_i)
    
if __name__ == '__main__':
    main()


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

int main()
{
  int student_n;
  int score[1000];
  double score_sum = 0, score_ave_m, bunsan_sum = 0, hensa_a;
  int counter_i;

  for( ; ; )
  {
    scanf("%d", &student_n);
    if(student_n == 0)
      break;

    for(counter_i = 0 ; counter_i < student_n ; counter_i++)
    {
      scanf("%d", &score[counter_i]);
      score_sum += score[counter_i];
    }
    score_ave_m = score_sum / student_n;

    for(counter_i = 0 ; counter_i < student_n ; counter_i++)
      bunsan_sum = bunsan_sum + (score[counter_i] - score_ave_m) * (score[counter_i] - score_ave_m);
    hensa_a = sqrt(bunsan_sum / student_n);

    printf("%lf\n", hensa_a);
    score_sum = 0;
    bunsan_sum = 0;
  }
  return 0;
}



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

int main(){
    ll n;
    cin >> n;
    if(n%2 == 0) cout << n << endl;
    else cout << n * 2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPS(i,n) for(int i=1;i<=(int)(n);i++)
using namespace std;
using ll = long long;
using ld = long double;

int main(void) {
    ll L, R;
    cin >> L >> R;

    if (R-L >= 2019) {
        cout << 0 << endl;
    } else {
        ll min = 2019;
        for (int i = L; i < R; i++) {
            for (int j = i+1; j <= R; j++) {
                ll i_mod = i % 2019;
                ll j_mod = j % 2019;
                if (i_mod * j_mod % 2019 < min) {
                    min = i_mod * j_mod % 2019;
                }
            }
        }
        cout << min << endl;
    }
}

Measured memory_bytes: 384
import sys
def input():
    return sys.stdin.readline()[:-1]
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
dic={}
dic["r"]=p
dic["s"]=r
dic["p"]=s
li=[[] for i in range(k)]
for i in range(n):
    li[i%k].append(t[i])
ans=0
for i in range(k):
    tmp=""
    for j in range(len(li[i])):
        # print(li[i][j])
        if tmp==li[i][j]:
            tmp=""
            continue
        else:
            ans+=dic[li[i][j]]
            tmp=li[i][j]
        # print(ans)
print(ans)

Measured memory_bytes: 53120
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;
#pragma endregion

void solve() {
    int n, t;
    cin >> n >> t;
    vector<int> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }
    vector<int> alt;
    int mini = INF;
    for (int i=0; i<n; i++) {
        if (mini < a.at(i)) {
            alt.push_back(a.at(i) - mini);
        } else {
            mini = a.at(i);
        }
    }
    sort(alt.begin(), alt.end(), greater<int>());
    int res = 1;
    for (int i=1; i<(int)alt.size(); i++) {
        if (alt.at(i) == alt.at(i-1)) {
            res++;
        } else {
            break;
        }
    }
    cout << res << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 1276
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007
ll fac[1000000];
ll finv[1000000];
ll inv[1000000];

void comb_init(){
  fac[0] = 1;
  for(int i=1;i<1000000;i++){
    fac[i] = i*fac[i-1];
    fac[i] %= MOD;
  }
  inv[1] = 1;
  for(int i=2;i<1000000;i++){
    inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
  }
  finv[0] = 1;
  for(int i=1;i<1000000;i++){
    finv[i] = inv[i]*finv[i-1];
    finv[i] %= MOD;
  }
}

ll comb(ll n,ll k){
  ll c = fac[n];
  c *= finv[k];c %= MOD;
  c *= finv[n-k];c %= MOD;
  return c;
}



int main(){
  string s;
  cin >> s;
  ll ans;
  if(s == "SUN") ans = 7;
  else if(s == "MON") ans=6;
  else if(s == "TUE") ans=5;
  else if(s == "WED") ans=4;
  else if(s == "THU") ans=3;
  else if(s == "FRI") ans=2;
  else ans = 1;

  cout << ans << endl;
  //cout << setprecision(12) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args)  {
		Scanner sc = new Scanner((System.in));
		int sx = sc.nextInt();
		int sy = sc.nextInt();
		int tx = sc.nextInt();
		int ty = sc.nextInt();
		int x = tx - sx;
		int y = ty - sy;
		for(int i = 0; i < y; i++) {
			System.out.print("U");
		}
		for(int i = 0; i < x; i++) {
			System.out.print("R");
		}
		for(int i = 0; i < y; i++) {
			System.out.print("D");
		}
		for(int i = 0; i < x + 1; i++) {
			System.out.print("L");
		}
		for(int i = 0; i < y + 1; i++) {
			System.out.print("U");
		}
		for(int i = 0; i < x + 1; i++) {
			System.out.print("R");
		}
		System.out.print("D");
		System.out.print("R");
		for(int i = 0; i < y + 1; i++) {
			System.out.print("D");
		}
		for(int i = 0; i < x + 1; i++) {
			System.out.print("L");
		}
		System.out.println("U");
	}
}

Measured memory_bytes: 24644
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
using tiii = tuple<int, int, int>;
int main()
{
    int n;
    cin >> n;

    int ans = 0;
    vector<tiii> ac;
    vector<int> a(n), b(n), c(n);
    rep(i, 0, n)
        cin >> a[i];
    rep(i, 0, n)
    {
        cin >> b[i];
        ans += b[i];
    }
    rep(i, 0, n - 1)
        cin >> c[i];

    rep(i, 0, n - 1)
    if (a[i] + 1 == a[i + 1])
        ans += c[a[i] - 1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io;

fn is_match(a: &Vec<String>, b: &Vec<String>, bx: usize, by: usize) -> bool {
    let m = b.len();
    for x in 0..m {
        for y in 0..m {
            if a[y + by].chars().nth(x + bx) != b[y].chars().nth(x) {
                return false;
            }
        }
    }
    true
}

fn solve(a: &Vec<String>, b: &Vec<String>) -> bool {
    let n = a.len();
    let m = b.len();
    for y in 0..(n-m+1) {
        for x in 0..(n-m+1) {
            if is_match(a, b, x, y) {
                return true
            }
        }
    }
    false
}

fn main() {
    let stdin = io::stdin();
    let input = &mut String::new();
    stdin.read_line(input);
    let mut iter = input.split_whitespace();
    let n = iter.next().unwrap().parse::<i32>().unwrap();
    let m = iter.next().unwrap().parse::<i32>().unwrap();
    let mut a = Vec::new();
    let mut b = Vec::new();
    for _ in 0..n {
        let input = &mut String::new();
        stdin.read_line(input);
        a.push(input.to_string());
    }
    for _ in 0..m {
        let input = &mut String::new();
        stdin.read_line(input);
        b.push(input.to_string());
    }
    let answer = if solve(&a, &b) { "Yes" } else { "No" };
    println!("{}", answer);
}


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

using namespace std;

#define nl '\n'

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

  vector<pair<int, int>> data(n, make_pair(0, 0));

  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    data[i] = make_pair(x, y);
  }

  map<pair<int, int>, int> freq;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) {
        continue;
      }
      int xDiff = data[i].first - data[j].first;
      int yDiff = data[i].second - data[j].second;
      pair<int, int> diff = make_pair(xDiff, yDiff); 
      freq[diff]++;
    }
  }

  int maxCount = 0;
  pair<int, int> maxPair = make_pair(0, 0);
  for (auto it = freq.begin(); it != freq.end(); it++) {
    if (it->second > maxCount) {
      maxCount = it->second;
      maxPair = it->first;
    }
  }

  cout << n - maxCount << nl;
  
  return 0;
}


Measured memory_bytes: 384
N = int(input())
h = list(map(int, input().split()))
max_ = 100*50
h = [0] + h + [0]
cnt = 0
if max(h) == 0:
    print(0)
    exit()
for _ in range(max_):
    for i in range(1, N+1):
        if h[i] == 0 and h[i-1] != 0:
            cnt += 1
            break
        if h[i] > 0:
            h[i] -= 1
            if h[i] == 0 and h[i+1] == 0:
                cnt += 1
                break
        if i == N:
            cnt += 1
            break
    if sum(h) == 0:
        break
print(cnt)


Measured memory_bytes: 9100
#include<stdio.h>
int main()
{
	int n,k,x,y,i,m;
	
	scanf("%d",&n);
	scanf("%d",&k);
	scanf("%d",&x);
	scanf("%d",&y);
	
	for(i=1;i<=n;i++){
		if(i>k){
			m+=y;
		}else{
			m+=x;
		}
	}
	
	printf("%d\n",m);
	
	return 0;
}

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

int ans=0;

void func(int s){
  if(s==4 || s==2 || s==1){
    ans+=4;
    return;
  }else if(s==0)return;
  if(s%2==0){
    ans++;
    return func(s/2);
  }else{
    ans++;
    return func(3*s+1);
  }
}

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

  func(s);
  cout << ans << endl;
}

Measured memory_bytes: 3628
fun main(args: Array<String>) {
    val N = Integer.parseInt(readLine())
    val line = readLine()
    var result = true
    if (line != null) {
        val list = line.split(" ")
        if (N == 2) {
            if (Integer.parseInt(list[1]) < Integer.parseInt(list[0])-1) {
                result = false
            }
        } else {
            var min = 0
            for (i in 1..(N - 1)) {
                if (i == 1) {
                    if (Integer.parseInt(list[1]) >= Integer.parseInt(list[0])) {
                        min = Integer.parseInt(list[1]) - 1
                    } else if (Integer.parseInt(list[1]) == Integer.parseInt(list[0]) - 1){
                        min = Integer.parseInt(list[1])
                    } else {
                        result = false
                        break
                    }
                } else {
                    if (Integer.parseInt(list[i]) < min) {
                        result = false
                        break
                    } else {
                        if (Integer.parseInt(list[i]) - 1 >= min) {
                            min = Integer.parseInt(list[i]) - 1
                        }
                    }
                }
            }
        }
    }
    if (result) {
        println("Yes")
    } else {
        println("No")
    }
}

Measured memory_bytes: 59688
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS

void solve(){
	ll a,b,x;
	cin>>a>>b>>x;
	ll ans = b/x; 
	if(a == 0){
		ans += 1;
	}
	if(a > 1){
		ans -= (a-1)/x;

	}
	cout<<ans<<endl;
}

int main(){
	fastread;
	int t = 1;
	// cin>>t;
	for(int i=1;i<=t;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll = long long;
using P = pair<int, int>;

const double PI = 3.14159265358979;

// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
  vector<pair<ll,int>> factor(ll x) {
    vector<pair<ll,int>> res;
    for (int p : primes) {
      int y = 0;
      while (x%p == 0) x /= p, ++y;
      if (y != 0) res.emplace_back(p,y);
    }
    if (x != 1) res.emplace_back(x,1);
    return res;
  }
};

void solve()
{
  Sieve si(100000);

  vector<int> pr(100001, 0);
  for(int i = 3; i <= 100000; ++i)
  {
    if (si.isPrime(i) && si.isPrime((i + 1) / 2)) pr[i] = 1;
    pr[i] += pr[i - 1];
  }

  int q, l, r;
  cin >> q;
  for(int i = 0; i < q; ++i)
  {
    cin >> l >> r;
    cout << pr[r] - pr[l - 1] << endl;
  }  


}

int main()
{
  fastio;
  solve();

  return 0;
}

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

int k[2020],f[2000005],a[2000005],g[2000005];
long long sum;

int main()
{
	string s;
	cin>>s;
	int n=s.size();
	for(int i=0; i<n; i++)
		a[i+1]=s[i]-48;
	
	int l=1;
	for(int i=n; i>=1; i--)
	{
		g[i]=l;
		l*=10;
		l%=2019;
	}
	
	for(int i=n; i>=1; i--)
	{
		g[i]=l;
		l*=10;
		l%=2019;
	}
	
	for(int i=n; i>=1; i--)
	{
		f[i]=(f[i+1]+a[i]*g[i])%2019;
		k[f[i]]++;
	}
	
	sum=k[0];
	sum+=(k[0]*(k[0]-1)/2);
	
	for(int i=1; i<=2018; i++)
		sum+=(k[i]*(k[i]-1)/2);
	
	cout<<sum<< endl;
	return 0;
}


Measured memory_bytes: 6088
#include<bits/stdc++.h>
typedef long long i64;
int n,k;
i64 sa=0;
void mins(i64&a,i64 b){if(a>b)a=b;}
struct node{
	node*lc,*rc;
	int D,sz,rnd;
	i64 vl,vr;
	void sp(node*&,node*&,int);
	i64 gl(){return lc?lc->gl():vl;}
	i64 gmn(){
		i64 mn=vr;
		if(lc)mins(mn,lc->gmn());
		if(rc)mins(mn,rc->gmn());
		return mn;
	}
}ns[1000007],*np=ns,*rt,*p1,*p2,*p3,*p4;
node*mg(node*a,node*b){
	if(!a)return b;
	if(!b)return a;
	if(a->rnd>b->rnd){
		a->sz+=b->sz;
		a->rc=mg(a->rc,b);
		return a;
	}
	b->sz+=a->sz;
	b->lc=mg(a,b->lc);
	return b;
}
void node::sp(node*&l,node*&r,int k){
	if(!this){l=r=0;return;}
	int ls=lc?lc->sz:0;
	if(k<=ls)return r=this,sz-=k,lc->sp(l,lc,k);
	if(k>=ls+D)return l=this,sz=k,rc->sp(rc,r,k-ls-D);
	k-=ls;
	node*a=np++,*b=np++;
	*a=(node){0,0,k,k,rand(),vl,vl};
	*b=(node){0,0,D-k,D-k,rand(),vr,vr};
	if(vl>vr){
		a->vr=vl-k+1;
		b->vl=vl-k;
	}
	l=mg(lc,a);
	r=mg(b,rc);
}
char buf[2000007],*ptr=buf;
int _(){
	int x=0;
	while(*ptr<48)++ptr;
	while(*ptr>47)x=x*10+*ptr++-48;
	return x;
}
int main(){
	fread(buf,1,sizeof(buf),stdin);
	n=_(),k=_();
	srand(time(0));
	*(rt=np++)=(node){0,0,k,k,rand(),0,0};
	for(int i=1,a,b;i<=n;++i){
		a=_(),b=_();
		sa+=a;
		if(b==1){
			if(a*2>k)return puts("-1"),0;
			rt->sp(p1,p2,1);
			p2->sp(p2,p3,a*2-1);
			p3=mg(p3,p1);
			int D=a*2-1;
			i64 y=p3->gl();
			*(p4=np++)=(node){0,0,D,D,rand(),y+D,y+1};
			rt=mg(p3,p4);
		}else{
			rt->sp(p1,p2,a*2%k);
			rt=mg(p2,p1);
		}
	}
	printf("%lld\n",sa*2+rt->gmn());
	return 0;
}

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

int main() {
  int N,num;
  cin >>N;
  vector<int> boss(N);
  vector<int> buka(N);
  for(int i=1;i<N;i++){
    cin >> boss.at(i);
    num=boss.at(i);
    buka.at(num-1)++;
  }
  for(int i=0;i<N;i++){
	cout << buka.at(i) << endl;
  }
}


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

int main ()
{


unsigned long long n,a,b;
   cin>>a>>b>>n;
   int ll=n;
     if(b<=n+1)n=b-1;
    unsigned long long g=(a*(n)/b)-a*((n)/b);
    //unsigned long long ans=max(g,l);
    //if(b>n)


   cout<<g<<endl;
    return 0;
}
//1239123 12312 5
//12312 5443234 1235


Measured memory_bytes: 3620
#include <iostream>
#include <queue>
#include <algorithm>
#include <vector>
using namespace std;

const int INF = 1e9;

//<最小コスト, 町番号>
typedef pair<int, int> P;
struct edge{int to, cost;};
int c, n, m, s, dist;
vector<edge> G[100];
//割引券が残りiの時のj地点における最小コスト
int d[10][100];

void dijkstra(int s, int a){
	priority_queue<P, vector<P>, greater<P> > Q;
	for(int i = 0; i < n; i++) d[a][i] = INF;
	d[a][s] = 0;
	Q.push(P(0, s));

	while(!Q.empty()){
		P p = Q.top(); Q.pop();
		int v = p.second;

		if(d[a][v] < p.first)	continue;
		for(int i = 0; i < G[v].size(); i++){
			edge e = G[v][i];
			
			//割引券を使った時と使ってない時でよりコストが小さい時をdmに代入
			int dm;
			if(a == 0)	dm = d[a][v] + e.cost;
			else dm = min(d[a][v] + e.cost, d[a-1][v] + e.cost / 2);

			if(d[a][e.to] > dm){
				d[a][e.to] = dm;
				Q.push(P(d[a][e.to], e.to));
			}
		}
	}
}

int main(void){
	while(true){
		cin >> c >> n >> m >> s >> dist;
		s--; dist--;
		if(!c)	break;

		edge e;
		for(int i = 0; i < m; i++){
			int a, b, f;
			cin >> a >> b >> f;
			a--; b--;
			e.to = b; e.cost = f;
			G[a].push_back(e);
			e.to = a;
			G[b].push_back(e);
		}

		int ans = INF;

		for(int i = 0; i <= c; i++){
			dijkstra(s, i);
		}

		cout << d[c][dist] << endl;

		for(int i = 0; i < 100; i++) G[i].clear();
	}

  return 0;
}

Measured memory_bytes: 1240
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define nn '\n'
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    VI a(n+1); REP(i,n+1) cin >> a[i];
    VI b(n); REP(i,n) cin >> b[i];
    int ans = 0;
    REP(i,n){
        if(b[i]>=a[i]){
            int tmp = a[i]+a[i+1];
            a[i+1]=max(a[i+1]-(b[i]-a[i]),0LL);
            a[i]=0;
            ans += tmp-a[i]-a[i+1];
        }else{
            a[i]-=b[i];
            ans += b[i];
        }
    }
    out(ans);

    return 0;
}

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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))

/***** MAIN *****/
signed main() {
  int n;
  cin >> n;
  string sf, ss;
  cin >> sf >> ss;
  ll ans = 1;
  bool prevIsTate;
  REP(i,n) {
    bool isTate = (sf[i] == ss[i]);
    if(i == 0) {
      if(isTate) ans = (ans * 3) % MOD;
      else ans = (ans * 6) % MOD;
    } else {
      if(prevIsTate) {
        ans = (ans * 2) % MOD;
      } else {
        if(!isTate) ans = (ans * 3) % MOD;
      }
    }
    if(!isTate) ++i;
    prevIsTate = isTate;
  }
  cout << ans;
  
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
/*"Success isn't permanent, failure isn't fatal,
                                      it's the courage to continue that counts"*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=2e6+4;

int main()
{
	double a,b; cin>>a>>b;

	double c,d; cin>>c>>d;

	double hr=30.0*c,mn=d;

	hr+=(mn*0.5);

	mn*=6.0;

	double pi=acos(-1.0);

	double dif=fabs(hr-mn);

	dif=min(dif,360.0-dif);

	//cout<<hr<<" "<<mn<<" "<<dif<<" ";

	dif=(dif*pi)/180.0;

	double ans=(a*a)+(b*b);

	ans-=(2*cos(dif)*a*b);

	ans=sqrt(ans);

	printf("%.12lf",ans);

	return 0;
}

Measured memory_bytes: 4212
#include <iostream>
#define MOD 1000000007
typedef long long LL;
using namespace std;

LL calc(LL x, LL n){
    LL ans = 1;
    while(n > 0){
        if(n & 1){
            ans = ans * x % MOD;
        }
        x = x * x % MOD;
        n >>= 1;
    }
    return ans;
}


int main(){
    LL x,n;

    cin >> x >> n;
    cout << calc(x,n) << endl;

}


Measured memory_bytes: 3116
#include <iostream>
#include <vector>
using namespace std ;
using ll = long long ;

int main(){
	ll n ; cin >> n ;
	ll mx = 0 ;
	ll sum = 0 ;
	for(int i=1;i<=n;i++){
		sum += i ;
		if(sum>=n){
			mx = i ;
			break ;
		}
	}
	vector<int> ans ;
	while(n>0){
		if(mx<=n){
			n -= mx ;
			ans.push_back(mx) ;
		}
		mx-- ;
	}
	for(int i=0;i<ans.size();i++){
		cout << ans.at(ans.size()-1-i) << endl ;
	}
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

char S[4000];

long long i,j,k,N,ans,M,b,r,g;

int main()
{
  cin >>N>>S;
  
  b=0;
  g=0;
  r=0;
  
  for(i=0;i<N;i++)
  {
    if(S[i]=='B') b++;
    else if(S[i]=='R') r++;
    else if(S[i]=='G') g++;
  }
  
  ans=b*r*g;
  
  for(i=0;i<N;i++)
  {
    for(j=i+1;j<N;j++)
    {
      k=2*j-i;
      if(k<N)
      {
      if(S[i]!=S[j] && S[i]!=S[k] && S[j]!=S[k]) ans--;
      }
    }
    
  }
  
  cout <<ans;
  
  
  
}

Measured memory_bytes: 3636
N = gets.to_i
adMat = Array.new(N){ Array.new(N,0) }
N.times do
  data = gets.split.map(&:to_i)
  id = data[0]
  counter = data[1] - 1
  0.upto(counter) do |j|
     adMat[id-1][data[j+2]-1] += 1
  end
end
adMat.each do |elem|
  puts elem.join(" ")
end

Measured memory_bytes: 6188
#include <bits/stdc++.h>
using namespace std;
int pos;
string S;
struct Node
{
    using Ptr = shared_ptr<Node>;
    Node(const int v, const Ptr l, const Ptr r) : value{v}, l{l}, r{r} {}
    int value;
    Ptr l, r;
};
using Ptr = Node::Ptr;
Ptr parse()
{
    if (S[pos] == ')') { return Ptr{}; }
    pos++;
    const Ptr l = parse();
    pos += 2;
    int num = 0;
    for (; isdigit(S[pos]); pos++) { num = num * 10 + S[pos] - '0'; }
    pos += 2;
    const Ptr r = parse();
    pos++;
    return make_shared<Node>(num, l, r);
}
Ptr merge(const Ptr t1, const Ptr t2)
{
    const int sum = t1->value + t2->value;
    Ptr l;
    if (t1->l and t2->l) { l = merge(t1->l, t2->l); }
    Ptr r;
    if (t1->r and t2->r) { r = merge(t1->r, t2->r); }
    return make_shared<Node>(sum, l, r);
}
string dump(const Ptr t) { return t == nullptr ? "()" : "(" + dump(t->l) + "[" + to_string(t->value) + "]" + dump(t->r) + ")"; }
int main()
{
    cin >> S;
    const auto t1 = parse();
    pos = 0;
    cin >> S;
    const auto t2 = parse();
    const auto t = merge(t1, t2);
    string ans = dump(t);
    cout << ans.substr(1, ans.size() - 2) << endl;
    return 0;
}



Measured memory_bytes: 3336
import itertools
N=int(input())
candi=[str(i) for i in range(1,N+1)]
P="".join(input().split())
Q="".join(input().split())
count=0
#候補列挙
for j in itertools.permutations(candi,N):
  k="".join(list(j))
  count+=1
  if k==P:
    a=count
  if k==Q:
    b=count
print(abs(a-b))

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int DP[110000] = {};

int main(){
	
	long long int N, M;
	cin >> N >> M;
	
	DP[0] = 1;
	long long int S = 1;
	
	for(int i = 1; i <= M; i++){
		DP[i] = S;
		S += DP[i];
		S %= MOD;
	}
	
	for(int i = M + 1; i <= N; i++){
		S += MOD - DP[i - M - 1];
		S %= MOD;
		DP[i] = S;
		S += DP[i];
		S %= MOD;
	}
	
	long long int ans = 1;
	
	for(int i = 0; i < N; i++){
		ans *= 2;
		ans %= MOD;
	}
	
	for(int i = 0; i < M; i++){
		ans += MOD - DP[N - i];
		ans %= MOD;
	}
	
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 3856
#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator<<(ostream & os, vector<T> const &);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }
template<class T, class U> ostream & operator<<(ostream & os, pair<T,U> const & p){ return os << "(" << p.first << ", " << p.second << ") "; }
template<class T> ostream & operator<<(ostream & os, vector<T> const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif

int const inf = (1LL<<31)-1;
int const B = 10;
struct RMQ {
    int n;
    vector<int> Bmin;
    vector<vector<int>> dat;
    RMQ(int n_){
        n = n_;
        if(n%B) n += B-n%B;
        dat.assign(n/B,vector<int>(B,inf));
        Bmin.assign(n/B,inf);
    }
    void set(int idx, int x){
        get(idx) = x;
        Bmin[idx/B] = inf;
        for(int i=0;i<B;i++) Bmin[idx/B] = min(Bmin[idx/B], get(idx/B*B+i));
    }
    int & get(int idx){
        return dat[idx/B][idx%B];
    }
    int rmq(int l, int r){
        int res = inf;
        if(l/B != r/B){
            while(l%B){
                res = min(res, get(l));
                l++;
            }
            while(r%B){
                r--;
                res = min(res, get(r));
            }
            while(l<r){
                res = min(res, Bmin[l/B]);
                l+=B;
            }
        } else {
            while(l<r){
                res = min(res, get(l));
                l++;
            }
        }
        return res;
    }
};

int main(){
    int n,q;
    cin >> n >> q;
    RMQ rmq(n);
    rep(i,q){
        int c, x, y;
        cin >> c >> x >> y;
        if(c) cout << rmq.rmq(x,y+1) << endl;
        else rmq.set(x,y);
    }
}

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
using namespace std;

bool solve(vector<string>_m,int H,int W,int N){
	int score=0,score_round=-1,cnt,color,i;
	for(int w=0;w<W;w++){
		i=H-1;
		for(int h=H-1;h>=0;h--)if(_m[h][w]!='.')_m[i][w]=_m[h][w],i--;
		for(;i>=0;i--)_m[i][w]='.';
	}
	for(;score_round;){
		vector<string>m=_m;
		score_round=0;
		for(int h=0;h<H;h++){
			cnt=1;
			color=-1; //-1=undefined,0=empty
			for(int w=0;w<W;w++){
				if(color==_m[h][w])cnt++;
				else{
					if(color!='.'&&cnt>=N)for(score_round+=cnt*color,i=w-cnt;i<w;i++)m[h][i]='.';
					cnt=1;
					color=_m[h][w];
				}
			}
			if(color!='.'&&cnt>=N)for(score_round+=cnt*color,i=W-cnt;i<W;i++)m[h][i]='.';
		}
		for(int w=0;w<W;w++){
			cnt=1;
			color=-1; //-1=undefined,0=empty
			for(int h=0;h<H;h++){
				if(color==_m[h][w])cnt++;
				else{
					if(color!='.'&&cnt>=N)for(score_round+=cnt*color,i=h-cnt;i<h;i++)m[i][w]='.';
					cnt=1;
					color=_m[h][w];
				}
			}
			if(color!='.'&&cnt>=N)for(score_round+=cnt*color,i=H-cnt;i<H;i++)m[i][w]='.';
		}
		for(int w=0;w<W;w++){
			i=H-1;
			for(int h=H-1;h>=0;h--)if(m[h][w]!='.')m[i][w]=m[h][w],i--;
			for(;i>=0;i--)m[i][w]='.';
		}
		score+=score_round;
		_m=m;
	}
	for(int i=0;i<H;i++){
		if(_m[i]!=string(W,'.'))return false;
	}
	return true;
}

int main(){
	int H,W,N;
	cin>>H>>W>>N;
	vector<string>m(H);
	for(int i=0;i<H;i++)cin>>m[i];
	for(int h=0;h<H;h++){
		for(int w=0;w<W-1;w++){
			swap(m[h][w],m[h][w+1]);
			if(solve(m,H,W,N)){
				cout<<"YES"<<endl;
				return 0;
			}
			swap(m[h][w],m[h][w+1]);
		}
	}
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 1232
from sys import stdin
import sys
# sys.setrecursionlimit(10**8)

def nextLine(): return next(stdin)
def nextStrList(): return nextLine().split()
def nextIntList(): return [int(_) for _ in nextStrList()]

import numpy as np

def main():
	r=int(nextLine())
	
	print(2*r*np.pi)
				
	
if __name__=="__main__":
	main()


Measured memory_bytes: 27136
import java.util.Scanner;

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

        long N = scan.nextLong();
        long M = scan.nextLong();
        for (long i = 0; i < M; i++) {
            N -= scan.nextLong();
        }
        if (N < 0) {
            System.out.println(-1);
            return;
        }
        System.out.println(N);
    }
}


Measured memory_bytes: 46308
import numpy as np


def yoko(row):
    cnt = sum(row)
    return cnt == len(row)


def main():
    h, w = map(int, input().split(' '))
    a = []

    for i in range(h):
        b = input()
        a += [1 if c == '.' else 0 for c in b]
    a = np.array(a).reshape(h, w)

    while True:
        cnt = 0
        del_list = []
        for i in range(len(a)):
            judge = yoko(a[i])
            if judge:
                del_list.append(i)

        if len(del_list):
            del_cnt = 0
            for idx in del_list:
                a = np.delete(a, idx - del_cnt, axis=0)
                del_cnt += 1
        else:
            cnt += 1

        a = a.T

        del_list = []
        for i in range(len(a)):
            judge = yoko(a[i])
            if judge:
                del_list.append(i)

        if len(del_list):
            del_cnt = 0
            for idx in del_list:
                a = np.delete(a, idx - del_cnt, axis=0)
                del_cnt += 1
        else:
            cnt += 1

        a = a.T

        if cnt >= 2:
            break

    for i in range(len(a)):
        r = ''
        for j in a[i]:
            if j == 1:
                r += '.'
            else:
                r += '#'
        print(r)


main()


Measured memory_bytes: 12624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X;
  cin >> X;
  
  int i = 1;
  while(true){
    if(X == 0){
      i = 0;
      false;
    }else if(X / i == 0){
      
      i /= 10;
      break;
    }else{
      i *= 10;
    }
  }
  
  int sum;
  int remainder = X;
  for(int j = i; j >= 1; j /= 10){
    sum += remainder / j;
    remainder %= j;
  }
  
  int harshadNumber = X % sum;
  if(harshadNumber == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}
  
  
  

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <utility>
#include <cstdio>
#include <stack>
#include <set>
#include <deque>
using namespace std;
int a,b,c,x,y;
long long ans,cnt,sum;
int main()
{
	cin>>a>>b>>c>>x>>y;
	if (x>y)
	{
		cnt=y*c*2+(x-y)*a;
		sum=x*c*2;
	}
	else
	{
  		cnt=x*c*2+(y-x)*b;
  		sum=y*c*2;
	}
	ans=x*a+y*b;
	cout<<min(ans,min(cnt,sum));
    return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

class A {
	int x, a, b;
public:
	void solve()
	{
		x -= a;
		cout << (x % b) << endl;
	}
	A() { cin >> x >> a >> b; }
};


int main()
{
	A solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
}

fn main() {
    let s = scan!();
    let t = scan!();

    let mut index = None;
    for i in 0..(s.len() - t.len() + 1) {
        let (_, splitted) = s.split_at(i);
        let mut valid = true;
        for (c0, c1) in splitted.chars().zip(t.chars()) {
            //println!("{}:{} {}", i, c0, c1);
            if !(c0 == c1 || c0 == '?') {
                valid = false
            }
        }
        if valid {
            index = Some(i);
        }
    }

    if let Some(index) = index {
        let (first, _) = s.split_at(index);
        let (_, last) = s.split_at(index + t.len());
        for c in format!("{}{}{}", first, t, last).chars() {
            if c == '?' {
                print!("a")
            } else {
                print!("{}", c)
            }
        }
        println!();
        return;
    }

    println!("UNRESTORABLE")
}


Measured memory_bytes: 4352
#include<stdio.h>

int main() {
	int S;
	int h, m, s;
	
	//?§????????????????S?????\???
	scanf("%d", &S);

	//?§????????????????????§??????????
	h = S / 3600;
	m = (S - h * 3600) / 60;
	s = S % 60;

	//h???m???s ?????????????????§??¨???
	printf("%d:%d:%d\n", h, m, s);

	return 0;
}

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

int main(){
    long long N; cin >> N;
    long long a[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    if(a[0]!=0){
        cout << -1 << endl;
        return  0;
    }
    for(int i=1;i<N;i++){
        if(a[i]-a[i-1]>1){
            cout << -1 << endl;
            return 0;
        }
    }
    long long ans=0;
    for(int i=1;i<N;i++){
        if(a[i-1]<a[i]){
            ans+=a[i]-a[i-1];
        }else{
            ans+=a[i];
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
ll n,k,h[200001],ans;
int main(){
	cin>>n>>k;
	rep(i,n){
		cin>>h[i];
	}
	sort(h,h+n);
	reverse(h,h+n);
	forn(i,k,n){
		ans+=h[i];
	}
	cout<<ans;
	re 0;
}


Measured memory_bytes: 1792
#include <iostream>

int main(int argc, const char * argv[]) {
	int num = 0;
	char c;
	for (int i = 0; i < 4; i++) {
		c = std::cin.get();
		if (c == '+')
			num++;
		else if (c == '-')
			num--;
	}
	std::cout << num << std::endl;
	return 0;
}

Measured memory_bytes: 256