akhauriyash/Code-Regression huggingface dataset:
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const a = parseInt(arg[0].split(" ")[0]);
    const b = parseInt(arg[0].split(" ")[1]);
    
    if(a < 0 && b >= 0) {
        console.log("Zero");
        return;
    }
    
    if(a > 0 && b > 0) {
        console.log("Positive");
        return;
    }
    
    if((b - a) % 2 === 0) {
        console.log("Negative");
        return;
    }

    console.log("Positive");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
int main()
{
 string s;
 cin >> s;
 int a[26]={0};
 for(int i=0;i<s.size();i++)
 {
     a[s[i]-'A']++;
 }
 int c=0;
  for(int i=0;i<26;i++)
  {
      if(a[i]==2)
      c++;
  }
  if(c==2)
  cout << "Yes";
  else
  cout << "No";
  return 0;   
}

Measured memory_bytes: 256
program abc127c
  implicit none
  integer :: n, m, x
  integer,allocatable :: lr(:,:), l(:), r(:)

  read *, n, m
  allocate(lr(2,m))
  read *, lr
  l = lr(1,:)
  r = lr(2,:)
  x = minval(r)-maxval(l)+1
  print *, merge(x, 0, x > 0)
end program abc127c


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

int main(){

	int i = 0, num[26] = {0};
	char c;

	while(scanf("%c", &c) != EOF){
			if((c >= 65) && (c <= 90)){
				num[(c - 65)]++;
			} else if((c >= 97) && (c <= 122)){
				num[c - 97]++;
			}
			i++;
	}

	for(i = 0; i < 26; i++){
		printf("%c : %d\n", i + 97, num[i]);
	}

	return 0;
}

Measured memory_bytes: 540
#include <stdio.h>
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
    int n; int sum=100000;
    cin >> n;
    while(n--)
    {
       sum*=1.05;
       if(sum%1000!=0)sum-=sum%1000,sum+=1000;
    }
    cout << sum << endl;
}

Measured memory_bytes: 1156
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my $n = <STDIN>);
chomp (my @l = split / /, <STDIN>);
@l = sort { $a <=> $b } @l;

my $ans = 0;
for my $i (0..(2*$n-1)) {
  $ans += $l[$i] if $i % 2 == 0;
}
say $ans;

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

using namespace std;

int main() {
	
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	long long a, b, c, d;
	cin >> a >> b >> c >> d;

	long long total = b - a + 1ll;
	long long div_c = b / c - (a - 1) / c;
	long long div_d = b / d - (a - 1) / d;
	long long lcm = (c * d) / __gcd(c, d);
	long long div_cd = b / lcm - (a - 1) / lcm;

	long long ans = total - div_c - div_d + div_cd;
	cout << ans; 

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  } //山の高さを入力
  
  int count = 0;
  
  for (int i = 0; i < N; i++) {
    int x = 0;
    
    for (int k = 0; k <= i; k++) {
      if (vec.at(i) >= vec.at(k)) {
        x++;
      } 
    } // vec.at(i)以下のkの個数を数える

    if (x == i + 1) {
      count++;
    }
  }
  
  cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for(ll i=2; i*i<=n; i++) {
    while(n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if(n != 1) ++res[n];
  return res;
}

ll a, b;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> a >> b;
  ll gc = gcd(a, b);

  auto mp = prime_factor(gc);
  cout << mp.size() + 1 << endl;
}


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


int64_t saishou(int64_t C, int64_t D){
  int64_t large = max(C, D);
  int64_t small = min (C, D);

  int64_t amari = 1;

  while(amari!=0){
    amari = large % small;
    large = small;
    small = amari;
  }

  return C*D/large;
}

int main() {

  int64_t A, B, C, D;
  cin >> A >> B >> C >> D;

  int64_t s_c = B/C - (A-1)/C;
  int64_t s_d = B/D - (A-1)/D;

  int64_t E = saishou(C, D);

  int64_t s_e = B/E - (A-1)/E;
  cout << B - A + 1 - (s_c+s_d-s_e) << endl;
}


Measured memory_bytes: 256
import scala.io.StdIn._
object Main{
  def main(args:Array[String]){
    val in = readLine().split(' ').map(_.toLong)
    val N = in(0)
    val x = in(1)
    val a = readLine().split(' ').map(_.toLong)

    var ans = 0l
    if(a(0) > x){
      ans += a(0)-x
      a(0) = x
    }

    for(i <- 1 to N.toInt-1){
      if(a(i-1) + a(i) > x){
        val d = a(i-1)+a(i) - x
        ans += d
        a(i) -= d
        if(a(i)<0) a(i) = 0
      }
    }

    println(ans)
  }
}


Measured memory_bytes: 46812
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;


int main(void)
{
	int a, b, c, k;
	while(scanf("%d%d%d%d", &a, &b, &c, &k)==4)
	{
		int ans=min(a, k);
		k-=a;
		if(k>0) k-=b;
		if(k>0) ans-=k;

		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 1732
N,M=map(int,input().split())
A = list(map(int,input().split()))
import numpy as np
import math
import fractions
import functools
A = np.array(A)
A = np.unique(A)
B = A.copy()
x=0
while np.all(B%2==0):
  B//=2
  x+=1
if np.any(B%2==0):
  print(0)
  exit()
  
A /= 2
n = A[0]
for a in A[1::]:
  n = n*a//fractions.gcd(n,a)
ans = math.ceil(M//n/2)
print(ans)

Measured memory_bytes: 18380
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string a, b, c; cin >> a >> b >> c;
  cout << (a.back() == b.front() && b.back() == c.front() ? "YES\n" : "NO\n");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include <bits/stdc++.h> 
#include<math.h>
#include<set>
#include<algorithm>
#define ll long long
using namespace std;
const double pi = acos(-1.0); 
ll m=-10000000000;
ll M=998244353;
ll gcd(ll x,ll y){
    if(y==0){
        return x;
    }
    gcd(y,x%y);
}

ll lcm(ll x,ll y){
    return (x*y)/gcd(x,y);
}

ll divCount(ll n) 
{ 
    ll cnt = 0; 
    for (ll i = 1; i <= sqrt(n); i++) { 
        if (n % i == 0) { 
            // If divisors are equal, 
            // count only one 
            if (n / i == i) 
                cnt++; 
  
            else // Otherwise count both 
                cnt = cnt + 2; 
        } 
    } 
    return cnt; 
} 

double nGon(int N) 
{ 
  
    // Projection angle variation 
    // from axes 
    double proAngleVar; 
  
    // Projection angle variation 
    // when the number of 
    // sides are in multiple of 4 
    if (N % 4 == 0) { 
        proAngleVar 
            = pi * (180.0 / N) 
              / 180; 
    } 
    else { 
        proAngleVar 
            = pi * (180.0 / (2 * N)) 
              / 180; 
    } 
  
    // Distance between the end points 
    double negX = 1.0e+99, 
           posX = -1.0e+99, 
           negY = 1.0e+99, 
           posY = -1.0e+99; 
  
    for (int j = 0; j < N; ++j) { 
  
        // Projection from all N points 
        // on X-axis 
        double px = cos(2 * pi * j / N 
                        + proAngleVar); 
  
        // Projection from all N points 
        // on Y-axis 
        double py = sin(2 * pi * j / N 
                        + proAngleVar); 
  
        negX = min(negX, px); 
        posX = max(posX, px); 
        negY = min(negY, py); 
        posY = max(posY, py); 
    } 
  
    // Maximum side 
    double opt2 = max(posX - negX, 
                      posY - negY); 
  
    // Return the portion of side 
    // forming the square 
    return (double)opt2 
           / sin(pi / N) / 2; 
} 

void solve(){
    ll a,b,c;
    cin>>a>>b>>c;
    ll x=a/b;
    if(a%b!=0){
        x++;
    }
    x*=c;
    cout<<x;
    
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
	int t;
	t=1;
	while(t--){
	    solve();
	}
	
	return 0;
}







//0 0 329221   


//0 0 502890  
//

Measured memory_bytes: 3676
w, h, n = map( int, input().split())
l = 0
r = w
d = 0
u = h
for _ in range(n):
    x, y, a = map( int, input().split())
    if a == 1:
        l = max(l,x)
    elif a == 2:
        r = min(r,x)
    elif a == 3:
        d = max(d,y)
    else:
        u = min(u,y)
if r-l <= 0 or u-d <= 0:
    print(0)
else:
    print(max(0,(r-l)*(u-d)))


Measured memory_bytes: 3064
S = list(input())
Q = int(input())
rev = False
F = []

for i in range(Q):
    X = list(input().split(" "))

    if X[0] == "1" and rev is False:
        rev = True
    elif X[0] == "1" and rev is True:
        rev = False
    elif X[0] == "2" and X[1] == "1" and rev is False:
        F.append(X[2])
    elif X[0] == "2" and X[1] == "1" and rev is True:
        S.append(X[2])
    elif X[0] == "2" and X[1] == "2" and rev is False:
        S.append(X[2])
    elif X[0] == "2" and X[1] == "2" and rev is True:
        F.append(X[2])

F.reverse()
F.extend(S)

if rev is True:
    F.reverse()

print(*F, sep="")

Measured memory_bytes: 97128
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000009;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-4;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;

int main() {
	string s; cin >> s; int n = s.length();
	int out = 1000;
	rep(i, n - 3 + 1) {
		int u = stoi(s.substr(i, 3));
		out = min(out, abs(u - 753));
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
p = [input() for i in range(h)]

r = set()
c = set()

for i in range(h):
    for j in range(w):
        if p[i][j] == '#':
            r.add(i)
            c.add(j)

for i in range(h):
    for j in range(w):
        if i in r and j in c:
            print(p[i][j], end='')
    if i in r:
        print()


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

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

  for (int i = 0; i < N; i++) {
    int startSheet, endSheet, orgNum;
    cin >> startSheet >> endSheet;
    
    orgNum = endSheet - startSheet+1;
    peopleNum += orgNum;
  }
  
  cout << peopleNum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=100001;
int mod=(int)(1e9 +7);
int main()
{
  int n,m;
  cin>>n>>m;
  int dp[1001][1001];
  dp[1][1]=1;
 char arr[n+1][m+1];
 

  for(int i=1;i<=n;i++)
  {
     for(int j=1;j<=m;j++)
     {
         cin>>arr[i][j];
     }
  }
  for(int i=0;i<1001;i++)dp[i][0]=0;
  for(int i=0;i<1001;i++)dp[0][i]=0;
  for(int i=1;i<=n;i++)
  {
      for(int j=1;j<=m;j++)
      {
          if(i*j!=1)
              
              {if(arr[i][j]=='.')dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
              else dp[i][j]=0;
              }
      }
  }
  cout<<dp[n][m]<<endl;

    
}
  


Measured memory_bytes: 5120
n, a, b, c, d = map(int, input().split())

S = input()
x = [0]

for s in S:
    if s == '#':
        x.append(1)
    else:
        x.append(0)

flag = 0

for i in range(a, c):
    if x[i] + x[i+1] == 2:
        flag = 1
for i in range(b, d):
    if x[i] + x[i+1] == 2:
        flag = 1

flag2 = 1

if c > d:
    for i in range(b-1, d):
        if x[i] + x[i+1] + x[i+2] == 0:
            flag2 = 0
else:
    flag2 = 0

if flag + flag2 == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 4916
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,a,b,c,d = map(int,ipt().split())
    mod = 10**9+7

    #nCrをmodで割った余りを求める。Nに最大値を入れて使用。
    N = n
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル
    def cmb(n,r,mod):
        if r<0 or r>n :
            return 0
        r = min(r,n-r)
        return g1[n]*g2[r]*g2[n-r]%mod
    for i in range(2,N+1):
        g1.append((g1[-1]*i)%mod)
        inverse.append((-inverse[mod % i]*(mod//i))%mod)
        g2.append((g2[-1]*inverse[-1])%mod)

    dp = [[0]*(n+1) for i in range(n+1)]
    dp[a][0] = 1
    for i in range(c,d+1):
        if i*a > n:
            break
        dp[a][a*i] = g1[n]*g2[n-a*i]%mod*g2[i]%mod*pow(g2[a],i,mod)%mod

    for i in range(a+1,b+1):
        dpi = dp[i]
        dppi = dp[i-1]
        for j in range(0,n+1):
            sm = dppi[j]
            for k in range(c,min(j//i+1,d+1)):
                sm = (sm+dppi[j-i*k]*g1[n-j+i*k]%mod*g2[n-j]%mod*g2[k]%mod*pow(g2[i],k,mod)%mod)%mod
            dpi[j] = sm
    print(dp[b][n])

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 50136
#include<bits/stdc++.h>
#define lli	long long int
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
#define rep(i,l,r)	for(i=l;i<r;i++)
using namespace std;
int main()
{
	lli a,b,k,i;
	cin >> a >> b >> k;
	if(a>=1)
	{
		if(a>=k)
		{
			a-=k;
			cout << a << " " << b << endl;
		}
		else
		{
			k-=a;
			b-=k;
			cout << "0 ";
			if(b<0)	cout << "0" << endl;
			else	cout << b << endl;
		}
	}
	else
	{
		cout << "0 ";
		if(b>=k)	cout << b-k << endl;
		else	cout << "0" << endl;
	}
	
	
	
	return 0;
}

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

int num_operate(vector<int> &A) {
    for(int i;i < A.size();i++){
        if(A.at(i) % 2 != 0){
            return 0;
        }else{
            A.at(i) /= 2;
        }
    }
    return num_operate(A) + 1;
}

int main(void) {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i;i < N;i++){
        cin >> A[i];
    }

    cout << num_operate(A) << endl;

    
}


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

int main()
{
	int h, w;
	while (cin >> h >> w && h != 0) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (i == 0 || i == h - 1 || j == 0 || j == w -1) cout << "#";
				else cout << ".";
			}
			cout << "\n";
		}
		cout << "\n";
	}
}



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

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int array[] = {a, b, c};
  if (count(array, array+(sizeof(array)), 5) == 2 && count(array, array+(sizeof(array)), 7) == 1) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  	}
	return 0;
}

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

const int N = 1010;

struct node
{
	int x,y,r;
} a[N];

struct edge
{
	int v;
	double cost;
	edge(int x,double b):v(x),cost(b){};
};
int n;
double d[N];
bool vis[N];

vector<edge> G[N];

double cal(int i,int j)
{
	double sum = a[i].r + a[j].r;
	double xx = 1.0 * (a[i].x - a[j].x) * (a[i].x - a[j].x);
	double yy = 1.0 * (a[i].y - a[j].y) * (a[i].y - a[j].y);
	double ans = sqrt(xx+yy);
	if (sum >= ans) return 0;
	else return ans - sum;
}

void dij(void)
{
	for (int i = 0;i <= n + 1;i++) d[i] = 1e30;
	d[0] = 0;
	for (int i = 0;i <= n;i++)
	{
		double mi = 1e30;
		int x;
		for (int j = 0;j <= n + 1;j++)
		{
			if (!vis[j] && d[j] < mi)
			{
				mi = d[j];
				x = j;
			}
		}
		if (mi == 1e30) break;
		vis[x] = 1;
		for (auto e : G[x])
		{
			double cost = e.cost;
			int v = e.v;
			if (d[v] > cost + d[x])
			{
				d[v] = cost + d[x];
			}
		}
	}
}

int main()
{
	scanf("%d%d",&a[0].x,&a[0].y);
	a[0].r = 0;
	int x,y;
	scanf("%d%d",&x,&y);
	scanf("%d",&n);
	a[n+1].x = x,a[n+1].y = y,a[n+1].r = 0;
	for (int i = 1;i <= n;i++) scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].r);
	for (int i = 0;i <= n + 1;i++)
	{
		for (int j = i + 1;j <= n + 1;j++)
		{
			double len = cal(i,j);
			G[i].push_back(edge(j,len));
			G[j].push_back(edge(i,len));
		}
	}
	dij();
	printf("%.15f\n",d[n+1]);
	return 0;
}

Measured memory_bytes: 16512
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(n)-1,i##_len=(int)(s);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
//今回の変数

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
ll Maxl(ll a, ll b) {
	return (a)>(b) ? (a) : (b);
}

int main() {
	int w,h,x,y;
	scanf("%d%d%d%d", &w, &h,&x,&y);
	int z = 0;
	if (x * 2 == w&&y * 2 == h)z = 1;
	printf("%.10f %d\n", (double)w*h / 2, z);
}


Measured memory_bytes: 128
#include<vector>
#include<climits>
#include<cmath>
template<typename T>
class LazyPropagationSegmentTree {
public:
  LazyPropagationSegmentTree(int n) : size_(1) {
    while(size_ < n) size_ <<= 1;
    node_.assign(size_ << 1, 0);
    lazy_.assign(size_ << 1, 0);
  }
  T find(int left, int right) {return query(left, right + 1, 1, 0, size_);}
  void add(int left, int right, T value) {propagate(left, right + 1, value, 1, 0, size_);}
private:
  int left_child(int node) const {return node << 1;}
  int right_child(int node) const {return (node << 1) + 1;}
  T query(int a, int b, int k, int l, int r) {
    if(b <= l || r <= a) return 0;
    if(a <= l && r <= b) return node_.at(k) + (r - l) * lazy_.at(k);
    lazy_.at(left_child(k)) += lazy_.at(k);
    lazy_.at(right_child(k)) += lazy_.at(k);
    lazy_.at(k) = 0;
    auto vl = query(a, b, left_child(k), l, (l + r) / 2);
    auto vr = query(a, b, right_child(k), (l + r) / 2, r);
    return vl + vr;
  }
  T propagate(int a, int b, T value, int k, int l, int r) {
    if(b <= l || r <= a) return node_.at(k) + (r - l) * lazy_.at(k);
    if(a <= l && r <= b) return node_.at(k) + (r - l) * (lazy_.at(k) += value);
    lazy_.at(left_child(k)) += lazy_.at(k);
    lazy_.at(right_child(k)) += lazy_.at(k);
    lazy_.at(k) = 0;
    auto vl = propagate(a, b, value, left_child(k), l, (l + r) / 2);
    auto vr = propagate(a, b, value, right_child(k), (l + r) / 2, r);
    return node_.at(k) = vl + vr;
  }
  int size_;
  std::vector<T> node_;
  std::vector<T> lazy_;
};

#include<iostream>
using namespace std;
int main() {
  int n, q;
  cin >> n >> q;
  LazyPropagationSegmentTree<int> RSQ(n);
  for(int i = 0; i < q; ++i) {
    int com, x, y;
    cin >> com >> x >> y;
    if(com) cout << RSQ.find(x-1, y-1) << endl;
    else    RSQ.add(x-1, x-1, y);
  }
}

Measured memory_bytes: 3108
#include<iostream>
#include<queue>
#include<string>

using namespace std;

int main()
{
	int n,q;
	int elapsed_time=0; //????????????
	queue<int> TIME;
	queue<string> NAME;
	cin>>n>>q;

	//??\???
	for(int i=0;i<n;i++){
		string name;
		int time;
		cin>>name>>time;
		NAME.push(name);
		TIME.push(time);
	}

	//??????
	while(! NAME.empty()){
		if(TIME.front()>q){
			elapsed_time+=q;

			//?????????????????£?????????????????????
			string temp_name=NAME.front();
			NAME.pop();
			NAME.push(temp_name);

			int temp_time=TIME.front()-q;
			TIME.pop();
			TIME.push(temp_time);
		} else {
			elapsed_time+=TIME.front();
			TIME.pop();
			cout<<NAME.front()<<" "<<elapsed_time<<endl;
			NAME.pop();
		}
	}

	return 0;
}

Measured memory_bytes: 5836
#include <stdio.h>
int main(){
  int r,c,i,j,sum,s[101][101];
  scanf("%d %d", &r, &c);
  for (i = 0; i < r; i++){
    sum=0;
    for (j = 0; j < c; j++){
      scanf("%d",&s[i][j]);
      sum+=s[i][j];
    }
    s[i][c]=sum;
  }
  for (j = 0; j < c+1; j++){
    sum = 0;
    for (i = 0; i < r; i++)
      sum += s[i][j];
    s[r][j]=sum;
  }
  for (i = 0; i < r+1; i++){
    for (j= 0; j < c+1; j++){
      printf("%d",s[i][j]);
      if (j!=c) printf("%s"," ");
    }
    printf("%s","\n");
  }
  return 0;
}


Measured memory_bytes: 2048
a,b,c = map(int,input().split())

K = int(input())

judge = False
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            x = a*2**i
            y = b*2**j
            z = c*2**k
            if i+j+k <= K and x < y and y < z:
                judge = True
                
if judge:
    print("Yes")
else:
    print("No")

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

int main(){
  int a,b,c,x,out=0;
  cin >> a >> b >> c >> x;
  for(int l=0;l<=a;l++){
    for(int m=0;m<=b;m++){
      for(int n=0;n<=c;n++){
        if(x==500*l+100*m+50*n) out++;
      }
    }
  }
  cout << out << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main(){
    string s;
    int temp = 0, ans = 0;
    cin >> s;
    for(char p:s){
        if(p == 'A'|| p == 'G' || p == 'C' || p == 'T'){
            temp++;
            ans = max(temp, ans);
        }else{
            temp = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int Balls[10];

bool dfs(int i, int R, int L)
{
	if(i == 10) return true;

	if(dfs(i+1, Balls[i], L) && Balls[i] > R) return true;

	if(dfs(i+1, R, Balls[i]) && Balls[i] > L) return true;

	return false;
}

int main()
{
	int n;

	cin >> n;
	for(int i=0; i<n; i++){
		for(int j=0; j<10; j++)
			cin >> Balls[j];

		if(dfs(0, 0, 0)) cout << "YES\n";
		else cout << "NO\n";
	}

	return 0;
}

Measured memory_bytes: 1120
card_num = int(input())
Tarou_score = 0
Hanako_score = 0

for i in range(card_num):
    Tarou_card,Hanako_card = input().split()
    if Tarou_card > Hanako_card:
        Tarou_score += 3
    elif Tarou_card < Hanako_card:
        Hanako_score += 3
    else:
        Tarou_score += 1
        Hanako_score += 1

print(f'{Tarou_score} {Hanako_score}')



Measured memory_bytes: 5608
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 100005;

int A[MAX_N << 1], N, B[MAX_N << 1];

bool check(int mid) {
  int len = N * 2 - 1;
  for (int i = 1; i <= len; ++i)
    B[i] = A[i] >= mid;

  int L = 0, R = len + 1;
  
  for (int i = 1, j; i <= len; ++i) {
    j = i;
    while (j < len && B[j + 1] == B[i]) j++;
    
    if (j - i >= 1 && i <= N && j >= N) return B[i];
    if (j - i >= 1) {
      if (j <= N) L = max(L, j);
      if (i >= N) R = min(R, i);
    }
    
    i = j;
  }

  if (L != 0 && R != len + 1) {
    return N - L > R - N ? B[R] : B[L];
  } else if (L != 0) {
    return B[L];
  } else if (R != len + 1) {
    return B[R];
  } else {
    return B[1];
  }
}

int main() {
  scanf("%d", &N);
  for (int i = 1; i < N << 1; ++i)
    scanf("%d", &A[i]);
  
  int l = 1, r = 2 * N - 1, res = 0;

  while (l <= r) {
    int mid = (l + r) >> 1;
    if (check(mid)) res = mid, l = mid + 1;
    else r = mid - 1;
  }

  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		int a = Integer.parseInt(tokens[0]);
		int b = Integer.parseInt(tokens[1]);
		if (a <= 8 && b <= 8) {
			System.out.println("Yay!");
		} else {
			System.out.println(":(");
		}
		in.close();
	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int n, m, i, a, b;
int freq[55];

int main() {
  //freopen("test.in", "r", stdin);
  scanf("%d %d\n", &n, &m);

  for (int i=0; i < m; i++) {
    scanf("%d %d\n", &a, &b);

    freq[a]++;
    freq[b]++;
  }

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

  return 0;
}

Measured memory_bytes: 3792
#include<stdio.h>
#define NIL -1

static const int MAX = 500;
static const int INFTY = (1<<21);

main(){
  int n, i, j, e, sum;
  int M[MAX][MAX],d[MAX],p[MAX],visit[MAX];
  int min,v,u;

  min=INFTY;

  scanf("%d", &n);

  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      scanf("%d", &e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }

  for(i=0;i<n;i++)
    {
      d[i]=INFTY;
      visit[i]=0;
      p[i]=NIL;
    }
  d[0]=0;
  while(1)
    {
      u=NIL;
      min=INFTY;
      for(i=0;i<n;i++)
	{
	  if(d[i]<min&&!visit[i])
	    {
	      u=i;
	      min=d[i];
	    }
	}
      if(u==NIL) break;
      visit[u]=1;

      for(v=0;v<n;v++)
	{
	  if(d[v]>=M[u][v]&&!visit[v])
	    {
	      d[v]=M[u][v];
	      p[v]=u;
	    }
	}
    }


  sum = 0;

  for ( i = 0; i < n; i++ ){
    if ( p[i] != -1 ) sum += M[i][p[i]];
  }

  printf("%d\n", sum);

  return 0;
}

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

const int maxn = 1e5 + 5; 
int a[maxn];
long long dp[maxn];

int main(){
//	freopen("in.txt", "r", stdin);
	int n;
	scanf("%d", &n);
	for(int i=1; i<=n; i++){
		scanf("%d", &a[i]);
	}
	for(int i=0; i<=n; i++)dp[i] = 1e17;
	dp[1] = 0;
	for(int i=1; i<=n; i++){
		if(i+1 <= n){
			dp[i+1] = min(dp[i+1], dp[i] + abs(a[i]-a[i+1]));
		}
		if(i+2 <= n){
			dp[i+2] = min(dp[i+2], dp[i] + abs(a[i]-a[i+2]));
		}
	}printf("%lld", dp[n]);
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define repeat(i,a,b) for(int i=(a),i##__end=(b);i<i##__end;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,i##__end=(a);i>=i##__end;i--)
#define mst(a,x) memset((a),(x),sizeof(a))
#define pii pair<int,int>
#define N 100010
#define mod 1000000007
#define int ll
int n,m,k;
int v[10],to[10];
signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>n;
	int r=0,ans=0;
	repeat(i,0,n){
		int d,c;
		cin>>d>>c;
		if(r==0){
			r=d;
			c--;
		}
		repeat(j,0,10){
			v[j]=(j+d)/10;
			to[j]=(j+d+v[j])%10;
		}
		int p=r,cnt=0,vv=0;
		while(1){
			cnt++;
			vv+=v[p];
			p=to[p];
			if(p==r)break;
		}
		ans+=c;
		ans+=vv*(c/cnt);
		c%=cnt;
		repeat(i,0,c){
			ans+=v[p];
			p=to[p];
		}
		r=p;
		//cout<<r<<endl;
	}
	cout<<ans<<endl;
	return 0;
}
//4 2 1 3 1 7 1 8 1

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll fac[MAX], finv[MAX], inv[MAX];

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

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

int main(){
  ll k; string s; cin >> k >> s; ll ans = 0; ll n = (ll)s.size();
  vl pow25(k+1); vl pow26(k+1);
  pow25[0] = pow26[0] = 1;
  nCrprep();
  
  rep(i,k){
    pow25[i+1] = mod(pow25[i]*25);
    pow26[i+1] = mod(pow26[i]*26);
  }
  
  for(ll i=k; i >= 0; i--){
    ans += mod(pow25[i]*pow26[k-i])*nCr(n-1+i,n-1);
    ans = mod(ans);
  }
  
  cout << ans << endl;
  
  
}

Measured memory_bytes: 66756
<?php
fscanf(STDIN, "%d", $n);
fscanf(STDIN, "%s %s", $s, $t);

$s = str_split($s);
$t = str_split($t);
$ans = '';

for ($i = 0; $i <= $n; $i++) {
    $ans .= $s[$i] . $t[$i];
}
echo $ans;

Measured memory_bytes: 4604
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define len(n) (int)n.length()
#define pb push_back
#define ll long long
#define make_pair mkp
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n-1;i >= 0;i--)
#define ALL(v) (v).begin(), (v).end()
#ifdef DBGPRT
#define dbg(n) cerr << "//" << #n << ":" << n <<endl
#else
#define dbg(n) ;
#endif
typedef pair<ll, ll> LLARR;
#define INF 999999999
const double PI = 3.1415926535897932384626433832795;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

/// ??????????´???????????????????????????????
class DisjointSet
{
public:
	vector<int> rank, p;
	DisjointSet(int n)
	{
		p.resize(n,0);
		rank.resize(n,0);
		REP(i, n)
		{
			p[i] = i;
			rank[i] = 0;
		}
	}
	
	int FindSet(int i)
	{
		if (p[i] != i)
		{
			/// ????????§???
			p[i] = FindSet(p[i]);
		}
		return p[i];
	}
	
	bool isSame(int x, int y)
	{
		return (FindSet(p[x]) == FindSet(p[y]));
	}
	
	void Link(int x, int y)
	{
		if (rank[x] > rank[y])
		{
			p[y] = x;
		}
		else
		{
			p[x] = y;
			if (rank[x] == rank[y])
			{
				rank[y]++;
			}
		}
	}
	
	void Unite(int x, int y)
	{
		Link(FindSet(x), FindSet(y));
	}
};


int main()
{
	ios::sync_with_stdio(false);

	int n, q;
	cin >> n;
	DisjointSet d(n);
	cin >> q;
	REP(i, q)
	{
		int c, x, y;
		cin >> c >> x >> y;
		if (c == 0)
			d.Unite(x,y);
		else
		{
			cout << ( d.isSame(x,y) ? 1 : 0 ) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3296
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
#include <assert.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
const int MOD=998244353;
#define SZ 666666
int n;
struct G
{
vector<int> v[SZ];
int sg[SZ];
bool b[SZ];
void dfs(int x)
{
	if(b[x]) return;
	b[x]=1;
	set<int> sp;
	for(auto bb:v[x])
	{
		dfs(bb);
		sp.insert(sg[bb]);
	}
	sg[x]=0;
	while(sp.count(sg[x]))
		++sg[x];
}
void ip()
{
	int m;
	scanf("%d",&m);
	while(m--)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		if(a>b) swap(a,b);
		v[a].pb(b);
	}
	for(int i=n;i>=1;--i) dfs(i);
}
}T[3];
ll qp(ll a,ll b)
{
	ll x=1; a%=MOD;
	while(b)
	{
		if(b&1) x=x*a%MOD;
		a=a*a%MOD; b>>=1;
	}
	return x;
}
map<int,int> c[3];
int main()
{
	scanf("%d",&n);
	ll x[2]={1,0};
	for(int i=0;i<3;++i)
	{
		T[i].ip();
		for(int j=1;j<=n;++j) (c[i][T[i].sg[j]]+=qp(1e18,j))%=MOD;
	}
	ll ans=0;
	for(auto i_:c[0])
		for(auto j_:c[1])
		{
			int i=i_.fi,j=j_.fi;
			ans+=c[0][i]*(ll)c[1][j]%MOD*c[2][i^j]%MOD;
		}
	cout<<(ans%MOD+MOD)%MOD<<"\n";
}


Measured memory_bytes: 61056
L,R=map(int,input().split())

result=float("inf")
R=min(R,L+4038)
for i in range(L,R+1):
  for j in range(i+1,R+1):
    result=min(result,i*j%2019)
#if R-L>= 2019:
#  result=0
#else:
#  l=L%2019
#  r=R%2019
#  for i in range(l,r+1):
#    for j in range(i+1,r+1):
#      result=min(result,i*j%2019)

print(result)


Measured memory_bytes: 40812
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();

        if(k <= a){
            System.out.println(k);
        } else if (k <= a + b){
            System.out.println(a);
        } else {
            System.out.println(a + b * 0 -(k-a-b));
        }
    }

}

Measured memory_bytes: 35768
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n;
    string move[100];
    while(cin >> n && n) {
        fill(move, move + 100, "");
        char preUd = 'd', state = 'd';
        int count = 0;
        for (int i = 0; i < n; ++i) {
            string move;
            cin >> move;
            char ud = move[1];
            if (preUd == ud && state != ud) {
                ++count;
                state = ud;
            }
            preUd = ud;
        }
        cout << count << endl;
    }
    return 0;
}

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

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

    int n = 4;
    vector<int> A(n, 0);
    for(int i = 0; i < n - 1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        A[a]++;
        A[b]++;
    }

    for(int i = 0; i < 4; i++){
        if(A[i] == 3){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 256
# AOJ 0110 Alphametic
# Python3 2018.6.21 bal4u

while 1:
	try:
		ab, s = list(input().split('='))
		a, b = list(ab.split('+'))
		start = 0
		if (len(a) > 1 and a[0] == 'X') or (len(b) > 1 and b[0] == 'X') \
			or (len(s) > 1 and s[0] == 'X'): start = 1
		f = 1
		for x in range(start, 10):
			na = a.replace('X', str(x))
			nb = b.replace('X', str(x))
			ns = s.replace('X', str(x))
			if int(na) + int(nb) == int(ns):
				print(x)
				f = 0
				break
		if f: print("NA")
	except: break


Measured memory_bytes: 5600
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] argv) throws IOException {
        //*
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int count = 1;
        count = Integer.parseInt(in.readLine());
        while (count-- > 0) {
            String s = in.readLine();
            if (s == null) {
                break;
            }
            f(s);
        }
        //*/
    }

    public static void f(String s) {
        String[] temp = s.split(" ");
        double[] points = new double[temp.length];
        for (int i = 0; i < temp.length; i++) {
            points[i] = Double.parseDouble(temp[i]);
        }
        
        double a = Math.sqrt(Math.pow(Math.abs(points[0] - points[2]), 2) + Math.pow(Math.abs(points[1] - points[3]), 2));
        double b = Math.sqrt(Math.pow(Math.abs(points[2] - points[4]), 2) + Math.pow(Math.abs(points[3] - points[5]), 2));
        double c = Math.sqrt(Math.pow(Math.abs(points[4] - points[0]), 2) + Math.pow(Math.abs(points[5] - points[1]), 2));
        double R = (a * b * c) / Math.sqrt((a + b + c) * (-a + b + c) * (a - b + c) * (a + b - c));
        double a1 = 2 * (points[2] - points[0]);
        double b1 = 2 * (points[3] - points[1]);
        double c1 = Math.pow(points[0], 2) - Math.pow(points[2], 2) + Math.pow(points[1], 2) - Math.pow(points[3], 2);
        double a2 = 2 * (points[4] - points[0]);
        double b2 = 2 * (points[5] - points[1]);
        double c2 = Math.pow(points[0], 2) - Math.pow(points[4], 2) + Math.pow(points[1], 2) - Math.pow(points[5], 2);
        double x = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1);
        double y = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1);
        System.out.println(String.format("%.3f %.3f %.3f", Math.round(x * 1000) / 1000.0, Math.round(y * 1000) / 1000.0, Math.round(R * 1000) / 1000.0));
    }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define ll long long
#define pii pair<int,int>
#define sz(x) (int) x.size()
#define f first
#define s second
using namespace std;
const int N=1e6+2;
const int M=1e8;
int cnt[N];
int a[N];
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    int x;
    for(int i=0;i<n;i++){
        cin>>a[i];
        x=a[i];
        cnt[x]++;
    }
    int ans=0;
    for(int i=0;i<n;i++){
        ll how=0;
        cnt[a[i]]--;
        for(int j=1;j*j<=a[i];j++){
            if(a[i]%j) continue;
            if(j*j==x){
                how+=cnt[j];
            }
            else{
                how+=cnt[j];
                how+=cnt[a[i]/j];
            }
        }
        ans+=(how==0);
        cnt[a[i]]++;
       // cout<<how<<" ";
    }
//    ll ans1=0;
//    for(int i=0;i<n;i++){
//        bool ok=1;
//        for(int j=0;j<n;j++){
//            if(i==j) continue;
//            if(a[j]%a[i]==0){
//                ok=0;
//                break;
//            }
//        }
//        ans1+=ok;
//    }
    cout<<ans;
    return 0;
}
// abcd


Measured memory_bytes: 8224
#include <iostream>
using namespace std;
int main(void){
  string a,b;
  cin>>a>>b;
  
  if(a==b){
      cout<<"H"<<endl;
  }
  
  else if(a=="D"&&b=="H"){
      cout<<"D"<<endl;
  }
  
  else if(a=="H"&&b=="D"){
      cout<<"D"<<endl;
  }
}

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

const string str[4] = {"dream", "dreamer", "erase", "eraser"};
const size_t MAX_L = (size_t)1e5 + 5;

string s;
bool ok[MAX_L][4];
bool dp[MAX_L];

int main() {
    ios::sync_with_stdio(false);
    cin >> s;
    int len = s.size();
    for (int i = 0; i < 4; i++)
        for (int j = str[i].size() - 1; j < len; j++)
            for (int k = 0; k <= str[i].size(); k++)
                if (k == str[i].size()) ok[j][i] = true;
                else if (s[j - k] != str[i][str[i].size() - 1 - k]) break;
    dp[0] = true;
    for (int i = 1; i <= len; i++)
        for (int j = 0; j < 4; j++)
            if (i >= str[j].size())
                dp[i] |= ok[i - 1][j] && dp[i - str[j].size()];
    cout << (dp[len] ? "YES" : "NO");
}

Measured memory_bytes: 976
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int vis[10],ans[10],vis1[10];
int a[100],b[100],k=0;
char mp[10][10];
struct note
{
    int x,y;
} l[1000];
int check(int x,int y)
{
    for(int i=0; i<k; i++)
    {
        if(l[i].x==x||l[i].y==y||abs(x-l[i].x)==abs(y-l[i].y))
            return 0;
    }
    return 1;
}
void pri()
{
    for(int i=0; i<9; i++)
    {
        for(int j=0; j<9; j++)
            mp[i][j]='.';
    }
    for(int i=0; i<k; i++)
        mp[l[i].x][l[i].y]='Q';
    for(int i=1; i<9; i++)
    {
        for(int j=1; j<9; j++)
            printf("%c",mp[i][j]);
        printf("\n");
    }
}
void dfs(int x)
{
    if(x>8)
    {
        pri();
        return;
    }
    else if(vis[x]==0)
    {
        for(int j=1; j<=8; j++)
        {
            if(vis1[j]==0&&check(x,j))
            {
                l[k].x=x;
                l[k++].y=j;
                vis1[j]=1;
                dfs(x+1);
                vis1[j]=0;
                k--;
            }
        }
    }
    else
        dfs(x+1);
}
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        memset(vis,0,sizeof(vis));
        memset(vis1,0,sizeof(vis1));
        k=0;
        for(int i=1; i<=n; i++)
        {
            scanf("%d%d",&a[i],&b[i]);
            vis[a[i]+1]=1;
            vis1[b[i]+1]=1;
            l[k].x=a[i]+1;
            l[k++].y=b[i]+1;
        }
        dfs(1);
    }
    return 0;
}



Measured memory_bytes: 2700
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const ll mod = 1000000007;
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
int t[26];
int main() {
	int N;
	scanf("%d", &N);
	getc(stdin);
	rep(i, 0, N)t[getc(stdin) - 'a']++;
	ll r = 1;
	rep(i, 0, 26)r *= (t[i] + 1), r %= mod;
	printf("%lld\n", r - 1);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////

int n,k;int a[3100];
int dp[3100][3100];
int r[3100];
int sum(int i, int j){
  return r[j] - r[i];
}
int rec(int i, int j){
  if(dp[i][j] != -1)return dp[i][j];
  if(i == j)return dp[i][j] = 0;
  dp[i][j] = max(sum(i+1, j) - rec(i+1, j)+a[i], sum(i, j-1) - rec(i,j-1)+a[j-1]);
  return dp[i][j];
}
signed main(){
  cin>>n;rep(i,n)cin>>a[i];
  rep(i,n)r[i+1] = r[i]+a[i];
  rep(i,3100)rep(j,3100)dp[i][j] = -1;
  rec(0, n);
  cout << dp[0][n]*2 - sum(0, n) << endl;
}


Measured memory_bytes: 75520
# Problem C - Guess The Number

# input
N, M = map(int, input().split())

# initialization
input_ok = True
num_list = [-1]*N
for i in range(M):
    s, c = map(int, input().split())
    if N>=2 and s==1:
        if c==0:
            input_ok = False
            break

    if num_list[s-1]==-1:
        num_list[s-1] = c
    else:
        if not c==num_list[s-1]:
            input_ok = False
            break

# min_search
if input_ok:
    min_num = 1000
    for n in range(1000):
        n_str = str(n)
        is_ok = True
        if len(n_str)==N:
            for i in range(N):
                if not num_list[i]==-1:
                    if not int(n_str[i])==num_list[i]:
                        is_ok = False
            if is_ok:
                min_num = min(min_num, int(n_str))
        else:
            continue
    # output
    print(min_num)
else:
    print(-1)


Measured memory_bytes: 40524
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

bool solve(int N, const vector<int> &p)
{
	int m = 0;
	for (int i = 0; i < N; ++i) {
		if (p[i] != i + 1) {
			++m;
		}
	}
	return m == 0 || m == 2;
}

int main()
{
	int N;
	cin >> N;
	vector<int> p(N);
	for (auto &x : p) {
		cin >> x;
	}
	if (solve(N, p)) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include <string.h>
 
int main(){
 int a,b,c,d,e,k;
 scanf("%d",&a);
 scanf("%d",&b);
 scanf("%d",&c);
 scanf("%d",&d);
 scanf("%d",&e);
 scanf("%d",&k);

if(b-a<=k &&c-a<=k && d-a<=k && e-a<=k &&
  
  c-b<=k && d-b<=k && e-b<=k && d-c<=k &&
  
  e-c<=k && e-d<=k){
  	printf("Yay!");}
  	
else printf(":(");

  
    return 0;}

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

using namespace std;

typedef long long int LL;
typedef unsigned long long int ULL;
typedef pair<int, int> PII;
typedef map<int, int> MII;

const int SZ = 112345;
const int MOD = 1e9 + 7;

char s[4];

int main() {
  scanf("%s", s);
  int a = 0, b = 0;
  for (int i = 0; i < 3; i++) {
    if (s[i] == 'A') a++;
    else b++;
  }
  if (a > 0 && b > 0) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 256
// Problem : B - Substring
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


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


#define sc(ar,n) for(int pen=0;pen<n;pen++){ cin>>ar[pen];}
#define pr(ar,n) for(int pen=0;pen<n;pen++){ cout<<ar[pen]<<" ";} cout<<endl;
#define mem(ar,x) memset(ar,x,sizeof(ar))
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define rt return 0;
#define ct continue;
#define pb push_back
#define ll long long int
#define ff first
#define ss second
#define mod 1000000007
#define maxn 1000003
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif



int main(){
	
	fastio;
	string s,t;
	cin>>s>>t;
	if(s==t){
		cout<<0;
		rt;
	}
	ll n = sz(t);
	ll m  = sz(s);
	ll ans=1005;
	for(int i=0;i<m-n+1;i++){
		string str = s.substr(i,n);
		ll cnt=0;
		for(int j=0;j<n;j++){
			if(str[j]!=t[j])cnt++;
		}
		ans = min(ans,cnt);
	}
	if(ans == 1005)cout<<n;
	else cout<<ans;
	}


	
	
	
	



Measured memory_bytes: 3616