akhauriyash/Code-Regression huggingface dataset:
n,k = map(int,input().split())
s = input()
#しゃくとり法
left = 0
count,ans = 0,0

for right in range(n):
    if s[right] =="0":
        if right==0 or s[right-1]=="1":
            count += 1
    if count > k:
        while s[left] == "1":
            left += 1
        while s[left] == "0":
            left += 1
        count -= 1
    ans = max(ans,right-left+1)
print(ans)


Measured memory_bytes: 42096
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define all(a)		a.begin(),a.end()
#define giveup(...) return printf(__VA_ARGS__),0;
#define fill0(a)	memset(a,0,sizeof(a))
#define fill1(a)	memset(a,-1,sizeof(a))
#define fillbig(a)	memset(a,0x3f,sizeof(a))
#define fillsmall(a) memset(a,0xcf,sizeof(a))
#define mask(a)		(1ll<<(a))
#define maskx(a,x)	((a)<<(x))
#define _bit(a,x)	(((a)>>(x))&1)
#define _sz(a)		((int)(a).size())
#define filei(a)	freopen(a,"r",stdin);
#define fileo(a)	freopen(a,"w",stdout);
#define fileio(a) 	freopen(a".in","r",stdin);freopen(a".out","w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define put(x)		putchar(x)
#define eoln        put('\n')
#define space		put(' ')
#define y1			y_chenxiaoyan_1
#define y0			y_chenxiaoyan_0
typedef pair<int,int> pii;
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
inline void print(int x){
	if(x<0){
		putchar('-');
		print(abs(x));
		return;
	}
	if(x<=9)	putchar(x+'0');
	else{
		print(x/10);
		putchar(x%10+'0');
	}
}
inline int qpow(int x,int e,int _MOD){
	int ans=1;
	while(e){
		if(e&1)	ans=ans*x%_MOD;
		x=x*x%_MOD;
		e>>=1;
	}
	return ans;
}
int n=read(),m=read();
signed main(){
	if(n%2==1){
		fz(i,1,m)	cout<<i<<" "<<2*m+1-i<<endl;
	}
	else{
		fz(i,1,m){
			if(i<=m/2)	cout<<i<<" "<<2*m+2-i<<endl;
			else		cout<<i<<" "<<2*m+1-i<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N;
	cin >> N;
	int A[300000];
	rep(i, 3 * N) cin >> A[i];

	ll S[100001];
	S[0] = 0;

	priority_queue<int, vector<int>, greater<int>> que;
	rep(i, N) {
		que.push(A[i]);
		S[0] += A[i];
	}
	for (int i = N; i < 2 * N; i++) {
		que.push(A[i]);
		S[i - N + 1] = S[i - N] + A[i] - que.top();
		que.pop();
	}

	ll kari = 0;
	priority_queue<int> que2;
	for (int i = N * 2; i < 3 * N; i++) {
		que2.push(A[i]);
		kari += A[i];
	}
	ll kotae = S[N] - kari;
	for (int i = 2 * N - 1; i >= N; i--) {
		que2.push(A[i]);
		kari += A[i];
		kari -= que2.top();
		que2.pop();
		kotae = max(kotae, S[i - N] - kari);
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 3320
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int N,K;

int main(){
    cin>>N>>K;
    K--;
    int A[N];
    rep(i,N){
        cin>>A[i];
    }
    if((N-1)%K!=0){
        out((N-1)/K+1);
    }
    else{
        out((N-1)/K);
    }
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int n;
    ll c;
    cin >> n >> c;
    vector<ll> x(n + 2), RevX(n + 2);
    vector<int> v(n + 2);
    x[0] = x[n + 1] = 0;
    v[0] = v[n + 1] = 0;
    RevX[0] = RevX[n + 1] = 0;
    for(int i = 1; i <= n; ++i){
        cin >> x[i] >> v[i];
        RevX[i] = c - x[i];
    }
    // for(int i = 1; i <= n; ++i) cerr << x[i] << ' ';
    // cerr << endl;
    // for(int i = 1; i <= n; ++i) cerr << RevX[i] << ' ';
    // cerr << endl;
    vector<ll> CumSum(n + 2, 0), CumMax(n + 2, 0);
    for(int i = 1; i <= n; ++i){
        CumSum[i] = CumSum[i - 1] + v[i] - (x[i] - x[i - 1]);
        CumMax[i] = max(CumMax[i - 1], CumSum[i]);
    }
    // for(int i = 1; i <= n; ++i) cerr << CumSum[i] << ' ';
    // cerr << endl;
    // for(int i = 1; i <= n; ++i) cerr << CumMax[i] << ' ';
    // cerr << endl;
    vector<ll> RevCumSum(n + 2, 0), RevCumMax(n + 2, 0);
    for(int i = n; i >= 1; --i){
        // cerr << "revpoint:" << RevX[i] << ' ' << RevX[i + 1] << endl;
        RevCumSum[i] = RevCumSum[i + 1] + v[i] - (RevX[i] - RevX[i + 1]);
        RevCumMax[i] = max(RevCumMax[i + 1], RevCumSum[i]);
    }
    // for(int i = 1; i <= n; ++i) cerr << RevCumSum[i] << ' ';
    // cerr << endl;
    // for(int i = 1; i <= n; ++i) cerr << RevCumMax[i] << ' ';
    // cerr << endl;
    ll ans = max(CumMax[n], RevCumMax[1]);
    for(int i = 1; i <= n; ++i){
        chmax(ans, CumSum[i] + RevCumMax[i + 1] - x[i]);
        chmax(ans, RevCumSum[i] + CumMax[i - 1] - RevX[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 8216
while true

 h,w = gets.split(' ').collect{|n|n.to_i}
 break if h==0 && w==0
 h.times do |hc|
  w.times do |wc|
   if wc==0 || wc==w-1
    print '#' 
    next
   end
   if hc==0 || hc==h-1
    print '#'
   else
    print '.'
   end
  end
  puts
 end
 puts
end

Measured memory_bytes: 8860
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  string s;
  double x = 0.0, y = 0.0, angle = 90.;
  while(true){
    cin >> s;
    int d = 0, a = 0;
    rep(i, s.size()){
      if(s[i] == ','){
        d = stoi(s.substr(0, i));
        a = stoi(s.substr(i+1, s.size()));
        break;
      }
    }
    if(d == 0 && a == 0)break;
    x += double(d) * cos(angle * M_PI/180.);
    y += double(d) * sin(angle * M_PI/180.);
    angle -= a;
  }
  cout << int(x) << endl;
  cout << int(y) << endl;
	return 0;
}



Measured memory_bytes: 3440
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	while(true){
		scanf("%d %d",&a,&b);
		if(a == 0 && b == 0) break;
		if(a > b) printf("%d %d\n",b,a);
		else{
			printf("%d %d\n",a,b);
		}
	}
}



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


int main() {
  
  double N,K;
  cin>>N>>K;
  
  vector<double> p(N);
for (int i = 0; i < N; i++) {
  cin >> p.at(i);
}
  
  double sw=0;
  vector<double> B(N);
  for(int i=0;i<K;i++){
    
    sw=sw+p.at(i);
    //B.at(i)=sw;
    
  }
  B.at(0)=sw;
  
  
  
  for (int i = 0; i < N-K; i++) {
    // sw=max(sw,p.at(i)+p.at(i+1)+p.at(i+2));
    B.at(i+1)=B.at(i)-p.at(i)+p.at(i+K);
    
    sw=max(sw,B.at(i+1));
}
  
  double sw1;
  
  sw1=(sw+K)/2;
  
  // 小数点以下10桁まで
  cout << fixed << setprecision(12);
  
  cout<<sw1<<endl;
  
}




Measured memory_bytes: 3328
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int target = 1;
		int count = 0;
		for (int i = 0; i < n; i++) {
		    int x = sc.nextInt();
		    if (x == target) {
		        target++;
		    } else {
		        count++;
		    }
		}
		if (target == 1) {
		    count = -1;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 58504
# -*- coding: utf-8 -*-
import numpy as np

def solve():
    N, K = map(int, input().split())
    A = map(int, input().split())
    X = np.arange(K.bit_length())
    Y = np.zeros_like(X)
    Z = 0
    for a in A:
        Y += (a>>X)&1
        Z += a
    Y = np.maximum(Y, N-Y)-Y
    Y *= (1<<X)
    L = (K>>X)&1
    W = (Y*L).sum()
    for k in range(1, K.bit_length()):
        if L[k] == 1:
             L[:k+1]= ((((1<<k)-1)>>X)&1)[:k+1]
             W = max(W, (Y*L).sum())

    res = Z+W
    return str(res)
if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 21180
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,c,i,j,k,z;scanf("%d%d",&n,&c);
  int d[c][c],s[3][c];
  for(i=0;i<3;i++){
    for(j=0;j<c;j++) s[i][j] = 0;
  }
  for(i=0;i<c;i++){
    for(j=0;j<c;j++) scanf("%d",&d[i][j]);
  }
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      scanf("%d",&z);
      for(k=0;k<c;k++) s[(i+j)%3][k] += d[z-1][k];
    }
  }
  vector<vector<pair<int,int>>> m(3,vector<pair<int,int>>(c));
  for(i=0;i<3;i++){
    for(j=0;j<c;j++){
      m[i][j].first = s[i][j];m[i][j].second = j;
    }
  }
  for(i=0;i<3;i++) sort(m[i].begin(),m[i].end());
  long long ans = 1000000000000;
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      for(k=0;k<3;k++){
        if(m[0][i].second != m[1][j].second && m[0][i].second != m[2][k].second && m[1][j].second != m[2][k].second) ans = min(ans,(long long)(m[0][i].first+m[1][j].first+m[2][k].first));
      }
    }
  }
  printf("%lld\n",ans);
}

Measured memory_bytes: 256
# 2019/08/27

n,m=map(int,input().split())
edge=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    a-=1;b-=1
    edge[a].append(b)
    edge[b].append(a)

def dfs(s):
    global visited
    ret=1 if all(visited) else 0
    for e in edge[s]:
        if visited[e]==True:continue
        visited[e]=True
        ret+=dfs(e)
        visited[e]=False
    return ret

ans=0
visited=[False]*n
visited[0]=True
ans+=dfs(0)

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int N, A, B;
vector<int> ans;

int main(){
    cin >> N >> A >> B;
    if((N - 1) / A + 1 > B || B > N - A + 1){
        cout << -1 << endl;
        return 0;
    }

    int len = 1;
    int num = N - A + 1;
    for(int i = 0; i < A; i++){
        cout << num + i << " ";
    }
    while(len + num - A > B){
        num -= A;
        for(int i = 0; i < A; i++){
            cout << num + i << " ";
        }
        len++;
    }
    for(int i = B - len; i < num && i > 0; i++){
        cout << i << " ";
    }
    for(int i = B - len - 1; i  > 0; i--){
        cout << i << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2176
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
n,x = map(int,input().split())
li = list(map(int,input().split()))
m = 0
for i in range(n):
  m = gcd(li[i]-x,m)
print(abs(m))

Measured memory_bytes: 15020
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from queue import Queue


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    k = INT()
    q = Queue()
    for i in range(1, k+10):
        # print(q.queue)
        if i < 10:
            q.put(i)
        else:
            x = q.get()

            if x % 10 > 0:
                q.put(10*x + x % 10 - 1)

            q.put(10*x + x % 10)

            if x % 10 < 9:
                q.put(10*x + x % 10 + 1)

    print(x)


if __name__ == '__main__':
    main()


Measured memory_bytes: 13664
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
        int M = sc.nextInt();
      	int Road[] = new int[N];
      	int i = 0;
      	for(i = 0;i < M * 2;i++){
		  Road[sc.nextInt()-1] += 1;
        }
      	for(i = 0;i < N; i++){
          System.out.println(Road[i]);   
        }
 
    }
}

Measured memory_bytes: 35944
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(A: int, B: int):
    ret = A + B
    if A + B >= 10:
        ret = "error"
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


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

int main() {
  int L,M,N,a;
  while(cin>>L, L) {
    a = 0;
    for(int i=1; i<=12; ++i) {
      cin>>M>>N;
      L -= (M-N);
      if(L <= 0 && a == 0)
	a = i;
    }
    if(a == 0)
      cout<<"NA"<<endl;
    else
      cout<<a<<endl;
  }
}

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

int main() {
    int n;cin>>n;
    int cnt=0;
    for(int i=3;i<=n;i++){
        if(i%2==0) continue;
        else{
            int part_cnt=0;
            for(int j=1;j<=i;j++){

                if(i%j==0) part_cnt++;
            }
            if(part_cnt==8){
                cnt++;
            }
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define PI 3.14159265358979
#define sc ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int mod = 1e9+7;
ll const INF = 1e18;

int main()
{
	sc;
	int n;
	cin>>n;
	if(n < 10){
		if(n == 1 || n == 0 || n == 6 || n == 8){
			cout<<"pon\n";
		}
		else if(n==2||n==4||n==5||n==7||n==9){
			cout<<"hon\n";
		}
		else{
			cout<<"bon";
		}
	}
	else{
		int last = n%10;
		
		if(last == 1 || last == 0 || last == 6 || last == 8){
			cout<<"pon\n";
		}
		else if(last==2||last==4||last==5||last==7||last==9){
			cout<<"hon\n";
		}
		else{
			cout<<"bon";
		}
		
	}
}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		//入力表示
		int N = sc.nextInt();
		int T = sc.nextInt();

		int c[] = new int[N];
		int t[] = new int[N];

		for (int i = 0; i < N; i++) {
			c[i] = sc.nextInt();
			t[i] = sc.nextInt();
		}

		int mincost = 1001;
		for (int i = 0; i < N; i++) {
			if (t[i] <= T) {
				mincost = Math.min(mincost, c[i]);

			}
		}
		System.out.println(mincost == 1001 ? "TLE" : mincost);

	}
}

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

template <typename T>
void print_vector(vector<T>& vec) {
    cout << "print_vector -> ";
    for(int i=0; i<vec.size(); i++) {
        if(i == vec.size()-1) {
            cout << vec[i] << endl;
        }
        else {
            cout << vec[i] << " ";
        }
    }
    return;
}

map<unsigned long long, unsigned long long> m;

void solve(unsigned long long n) {
    if(n<=1) return;
    unsigned long long l = sqrt(n);
    for(int i=2; i<=l; i++) {
        if(n%i==0) {
            solve(i); solve((unsigned long long)(n/i)); return;
        }
    }
    m[n]++; return;
}

int main() {

    unsigned long long N;
    cin >> N;

    if(N==1) {
        cout << 0 << endl;
        return 0;
    }

    solve(N);

    unsigned long long result = 0;
    for(const auto& [key, value] : m) {
        long long temp = value;
        for(unsigned long long i=1; i<N; i++) {
            temp -= i;
            if(temp < 0) {
                break;
            }
            else {
                result++;
            }
        }
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 3680
from operator import itemgetter

def main():
    n = int(input())
    a = sorted(enumerate(map(int, input().split())), key=itemgetter(1), reverse=True)
    dp = [[0] * (n + 1) for _ in range(n + 1)]
    for x in range(n):
        for y in range(n - x):
            i, ai = a[x + y]
            dp[x + 1][y] = max(ai * (i - x) + dp[x][y], dp[x + 1][y])
            dp[x][y + 1] = max(ai * (n - 1 - y - i) + dp[x][y], dp[x][y + 1])
    print(max(dp[i][n - i] for i in range(n)))

if __name__ == '__main__':
    main()

Measured memory_bytes: 124960
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
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; }

int main(void){
  int n; cin >> n;
  if(n%1000 != 0) cout << 1000 - (n %1000) << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<string>
#define FIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define ll long long
#define mod (ll)(1e9+7)
#define nax (ll)(1e6 +2)
#define INFL LLONG_MAX
#define INF INT_MAX
#define disp(a,n,arr) for(int i=a;i<(ll)n;i++) cout << arr[i] << " "; cout << "\n";
#define check cout << "Working\n";
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vpl vector<pl>
#define vpi vector<pi>
#define vb vector<bool>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;

ll binpow(ll a, ll b) {
	ll x = 1;
	while (b) {
		if (b & 1) x = x * a;
		a = a * a;
		b >>= 1;
	}
	return x;
}

ll mult(ll a, ll b) {
	ll x = 0;
	while (b) {
		if (b & 1) x = (x + a);
		a = (a + a);
		b >>= 1;
	}
	return x;
}

ll gcd(ll a, ll b, ll& x, ll& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	ll x1, y1;
	ll d = gcd(b, a % b, x1, y1);
	x = y1;
	y = x1 - y1 * (a / b);
	return d;
}



int main() {

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

	// Write your code here

	int t = 1;
	//cin >> t;
	while (t--) {
		ll n;
		cin >> n;
		vl v(nax, 0);
		vb prime(nax, false);
		ll mx = 0;

		for (int i = 0; i < n; i++) {
			ll a;
			cin >> a;
			v[a]++;
			prime[a] = true;
			mx = max(mx, a);
		}

		ll ans = 0;
		if (v[1] == 1) {
			cout << "1\n";
			return 0;
		}

		if (v[1] > 1) {
			cout << "0\n";
			return 0;
		}
		//cout << v[2] << "\n";
		for (int i = 2; i <= mx; i++) {
			if (prime[i]) {
				for (int j = 2 * i; j <= mx; j += i) {
					prime[j] = false;
				}
				if (v[i] == 1) {
					ans++;
				}
			}
		}
		cout << ans << "\n";
	}


	return 0;
}

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

void solve() {
    ll k;
    cin >> k;
    ll a, b;
    cin >> a >> b;
    if(k > b) {cout << "NG"; return;}
    ll rem2 = b % k;
    if(b - rem2 >= a && b - rem2 <= b) cout << "OK";
    else cout << "NG";
}   

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

Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

double area(double a, double b, double c) {
    double s = (a + b + c) / 2;
    return sqrt(s * (s - a) * (s - b) * (s - c));
}

int main() {
    int a, l, x;
    while (cin >> a >> l >> x) {
        double s = area(a, l, l) + 2 * area(l, (l + x) / 2.0, (l + x) / 2.0);
        printf("%.6f\n", s);
    }

}

Measured memory_bytes: 1196
import sys
input=sys.stdin.readline

def main():
    N,K = map(int, input().split())

    if K == 0:
        print(N**2)
        return

    ans = 0
    for b in range(K+1,N+1):
        ans += ((b-1) - (K-1)) * (N//b) + max(0, N%b - (K-1))

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
# AC: 33 msec(Python3)
from itertools import combinations_with_replacement
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    x = int(readline())

    ab = [i**5 for i in range(200)]

    C = combinations_with_replacement(ab, 2)
    for a, b in C:
        if a + b == x:
            print(int(pow(b, 0.2)), -int(pow(a, 0.2)))
            break
        
        if b - a == x:
            print(int(pow(b, 0.2)), int(pow(a, 0.2)))
            break


if __name__ == "__main__":
    main()


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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

typedef pair<int, int> P;

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

const int INF = 1e9;
const int INFLL = 1e18;
const int MOD = 1e9 + 7;

signed main(){
    int N; cin >> N;
    REP( i, N ){
        set<string> train;
        string s; cin >> s;
        REP( i, s.size() - 1 ){
            string u = s.substr( 0, i + 1 );
            string t= s.substr( i + 1, s.size() - i - 1 );
            string ru = u; reverse( ALL( ru ) );
            string rt = t; reverse( ALL( rt ) );

            train.insert( u + t );
            train.insert( ru + t );
            train.insert( u + rt );
            train.insert( ru + rt );
            train.insert( t + u );
            train.insert( rt + u );
            train.insert( t + ru );
            train.insert( rt + ru );
        }

        cout << train.size() << endl;

    }

}



Measured memory_bytes: 3232
import java.util.Scanner;

public class Main {
	static int w;
	static int h;
	static char[][] tiles;
	static boolean[][] check;
	static int count;
	
	static int go(int i,int j,int count) {
		if(!check[i][j]) {
			check[i][j] = true;
			count++;
			if(i-1>=0 && tiles[i-1][j] == '.') {
				//System.err.println(count);
				count = go(i-1,j,count);
			}
			if(i+1<h && tiles[i+1][j] == '.') {
				//System.err.println(count);
				count = go(i+1,j,count);
			}
			if(j-1>=0 && tiles[i][j-1] == '.') {
				//System.err.println(count);
				count = go(i,j-1,count);
			}
			if(j+1<w && tiles[i][j+1] == '.') {
				//System.err.println(count);
				count = go(i,j+1,count);
			}
		}
		return count;
	}
	
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	while(true) {
    		w = Integer.parseInt(sc.next());
    		h = Integer.parseInt(sc.next());
    		if(w==0 && h==0) break;
    		tiles = new char[h][w];
    		check = new boolean[h][w];
    		for(int i=0;i<h;i++) {
    			tiles[i] = sc.next().toCharArray();
    		}
    		/*for(int i=0;i<h;i++) {
    			for(int j=0;j<w;j++) {
    				System.out.print(tiles[i][j]+" ");
    			}
    			System.out.println();
    		}*/
    		int m = 0;
    		int n = 0;
    		loop:for(int i=0;i<h;i++) {
    			for(int j=0;j<w;j++) {
    				if(tiles[i][j] == '@') {
    					m = i;
    					n = j;
    					break loop;
    				}
    			}
    		}
    		int count = go(m,n,0);
    		System.out.println(count);
    	}
    }
}


Measured memory_bytes: 36196
from collections import Counter
mod = 10**9 + 7
n, m = map(int, input().split())

def fact(m):
    c = Counter()
    s = 2
    while s**2 <= m:
        if m % s:
            s += 1
            continue
        while m % s == 0:
            c[s] += 1
            m //= s
    if m > 1:
        c[m] += 1
    return c

def comb(n, r):
    ret = 1
    for i in range(min(r, n-r)):
        ret = ret*(n-i)//(i+1)
    return ret

ans = 1
for cnt in fact(m).values():
    ans = ans*comb(cnt+n-1, cnt) % mod
#    for i in range(cnt):
#        ans = ans*(cnt+n-1-i)//(i+1)
print(ans % mod)

Measured memory_bytes: 3316
#[macro_use]
mod utils {
    macro_rules! input {
        ($($r:tt)*) => {
            let stdin = std::io::stdin();
            let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
            let mut next = move || -> String{
                bytes
                    .by_ref()
                    .map(|r|r.unwrap() as char)
                    .skip_while(|c|c.is_whitespace())
                    .take_while(|c|!c.is_whitespace())
                    .collect()
            };
            input_inner!{next, $($r)*}
        };
    }
    macro_rules! input_inner {
        ($next:expr) => {};
        ($iter:expr, ) => {};

        ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
            let $var = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };
        ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
            let mut $var = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };
    }
    macro_rules! read_value {
        ($next:expr, ( $($t:tt),* )) => {
            ( $(read_value!($next, $t)),* )
        };
        ($next:expr, [ $t:tt ; $len:expr ]) => {
            (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        };
        ($next:expr, chars) => {
            read_value!($next, String).chars().collect::<Vec<char>>()
        };
        ($next:expr, usize1) => {
            read_value!($next, usize) - 1
        };
        ($next:expr, $t:ty) => {
            $next().parse::<$t>().expect("Parse error")
        };
    }
}

fn main() {
    input! {
        n:i32, m:i32,
    }
    let mut r = 0;
    r += n * (n - 1) / 2;
    r += m * (m - 1) / 2;
    println!("{}", r);
}


Measured memory_bytes: 4476
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};

int N, M;
vector<vector<int>> G;

void PRINT(vector<bool> &seen){
	for(auto vis: seen){
		cout << vis << " ";
	}
	cout << endl;
}

void DFS(int v, vector<bool> &seen, int &res){
	//seen[v] = 1;

	bool ok = 1;
	rep(i,seen.size()){
		if(i==v) continue;
		if(seen[i]==0) ok=0;
	}
	if(ok){
		res++;
		return;
	}

	 seen[v] = 1;
	for(auto nv : G[v]){
		if(seen[nv]) continue;
		DFS(nv,seen,res);
	}

	seen[v] = 0;
}

int main(){
	cin >> N >> M;
	G.resize(N);
	rep(i,M){
		int a, b;
		cin >> a >> b;
		a--, b--;
		G[a].pb(b);
		G[b].pb(a);
	}

	vector<bool> seen(N, false);
	int res = 0;
	DFS(0,seen,res);
	cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int N, M;
struct edge {
    int to, cost;
};
vector<vector<edge>> E;
vector<int> memo;

int dfs(int on){
    if(memo[on]!=-1) return memo[on];
    memo[on] = 0;
    for(edge &e:E[on]){
        memo[on] = max(memo[on], dfs(e.to)+e.cost);
    }
    return memo[on];
}


int main() {
    cin >> N >> M;
    E.resize(N);
    memo.resize(N, -1);
    for(int i=0; i<M; i++){
        int a, b, c; cin >> a >> b >> c;
        edge e;
        e.to = b;
        e.cost = c;
        E[a].push_back(e);
    }
    
    cout << dfs(0) << endl;
    return 0;
}




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

int main (){
	int n;
	cin >> n;
	int a[114514];
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a, a+n);
	reverse (a, a+n);
	int alice = 0, bob = 0;
	for (int i = 0; i < n; i++){
		if (i % 2 == 0) alice += a[i];
		else bob += a[i];
	}
	cout << alice - bob << endl;
	return 0;
}


Measured memory_bytes: 256
N=int(input())                                       
H=list(map(int,input().split()))
for i in range(N-1):
  if H[i]<H[i+1]:
    H[i]=0
  else:
    H[i]=1
H[-1]=0
zero=[]
for i in range(N):
  if H[i]==0:
    zero.append(i)
if len(zero)==N:
  print(0)
elif len(zero)==1:
  print(N-1)
else:
  ans=0
  for i in range(len(zero)-1):
    ans=max(ans,zero[i+1]-zero[i]-1)
  ans=max(ans,zero[-1]-zero[-2]-1) 
  print(ans)

Measured memory_bytes: 14480
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int min(int a, int b, int c, int d, int e){
    int min;
    if(a<=b && a<=c && a<=d && a<=e){
        min = a;
    }
    else if(b<=a && b<=c && b<=d && b<=e){
        min = b;
    }
    else if(c<=a && c<=b && c<=d && c<=e){
        min = c;
    }
    else if(d<=a && d<=b && d<=c && d<=e){
        min = d;
    }
    else if(e<=a && e<=b && e<=c && e<=d){
        min = e;
    }
    return min;
}

int main() {
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;
    int t = 0;
    int last = 0;
    
    int a1=a%10;
    int b1=b%10;
    int c1=c%10;
    int d1=d%10;
    int e1=e%10;
    
    if (a%10 == 0){
        a1 = a1+10;
    }
    if (b%10 == 0){
        b1 = b1+10;
    }
    if (c%10 == 0){
        c1 = c1+10;
    }
    if (d%10 == 0){
        d1 = d1+10;
    }
    if (e%10 == 0){
        e1 = e1+10;
    }
    
    if (min(a1, b1, c1, d1, e1) == a1){
        last = a;
        a=0;
    }
    else if (min(a1, b1, c1, d1, e1) == b1){
        last = b;
        b=0;
    }
    else if (min(a1, b1, c1, d1, e1) == c1){
        last = c;
        c=0;
    }
    else if (min(a1, b1, c1, d1, e1) == d1){
        last = d;
        d=0;
    }
    else if (min(a1, b1, c1, d1, e1) == e1){
        last = e;
        e=0;
    }
    
    a = ceil(double(a)/10.0)*10;
    b = ceil(double(b)/10.0)*10;
    c = ceil(double(c)/10.0)*10;
    d = ceil(double(d)/10.0)*10;
    e = ceil(double(e)/10.0)*10;
    t = a + b + c + d + e + last;
    cout << t << endl;
}

Measured memory_bytes: 256
/* ex3_4
    riverstone*/

#include <stdio.h>
 
int main(void){
    //Nをnumberとする。
    int number;
    int factor=0;

    // number の入力を取得
    scanf("%d",&number);

    // factorを総当たり
    // 割り切れるものがあればyes、なければNoを出力
    for(factor=1;factor<10;factor++){
        //numberがiで割り切れてかつ商が9以下ならいい。
        if(number % factor == 0 && number/factor < 10){
            printf("Yes");
            return 0;
        } 
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 128
// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <numeric>
// #include <windows.h>
using namespace std;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T1, class T2> using P = pair<T1, T2>;
using I = int;
using D = double;
using B = bool;
using C = char;
using S = string;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = P<I, I>;
using VPII = V<PII>;
using PLL = P<LL, LL>;
using VPLL = V<PLL>;
using VI = V<I>;
using VVI = VV<I>;
using VLL = V<LL>;
using VVLL = VV<LL>;
using VC = V<C>;
using VVC = VV<C>;
using VS = V<S>;
using VVS = VV<S>;
using VB = V<B>;
using VVB = VV<B>;
#define REP(type, i, n) for (type i = 0; i < (type)(n); ++i)
#define REP2(type, i, m, n) for (type i = (m); i < (type)(n); ++i)
#define REPR(type, i, n) for (type i = (n)-1; i >= 0; --i)
#define REPR2(type, i, m, n) for (type i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a, type) sort(ALL(a), G<type>())
#define REVERSE(a) reverse(ALL(a))
#define SIZE(a, type) ((type)(a).size())
#define bit_search(bit, n) REP(LL, bit, 1LL<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REPx(&x, a) cin >> x;
#define INPUTP(a) REPx(&x, a) cin >> x.first >> x.second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n, PER) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(roop, n) a[idx][roop] = v[roop]; idx++;} while(next_permutation(ALL(v))); PER = a;} while(0); // int fact(), VVI PERを宣言しておく、n=10が限界(500 ms)
#define ENDL cout << endl;

const int INF = 2e9;
const LL MOD = 1e9 + 7;

template<class T> using PRIORITY_QUEUE = priority_queue< T, V<T>, greater<T> >;
template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}
template<class T> inline void debug1(V<T> A){REP(int, i, SIZE(A, int)){if (A[i] == INF) cout << "I ";else cout << A[i] << " ";}ENDL}
template<class T> inline void debug2(VV<T> A){REP(int, i, SIZE(A, int)){REP(int, j, SIZE(A[i], int)){if (A[i][j] == INF) cout << "I "; else cout << A[i][j] << " ";}ENDL}}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int k;
  string s;
  cin >> k >> s;
  if (SIZE(s, int) <= k) cout << s << endl;
  else
  {
    REP(int, i, k) cout << s[i];
    cout << "..." << endl;
  }

  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define vll vector<ll>
#define print(x) for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<'\n';
#define debug(a,b,c) cout << a << " " << b << " " << c << endl;
#define in(x,n) for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}
#define inl(x,n) for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
#define lower(sl)  transform(sl.begin(), sl.end(), sl.begin(), ::tolower); 
#define endl "\n";
#define pi pair<int,int>
#define vpi vector<pair<int,int>>
#define vvi vector<vector<int>>
 

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//code here
    ll k; cin >> k;
	ll curr = 7, prev = 7;
	ll res = 1;
	if(k%2==0 or k%5==0){
		cout << -1 << endl;
		return 0;
	}
	for(int i=0;i<k;i++){
		if(curr%k==0) break;
		prev = (prev*10) % k;
		curr = (curr+prev) % k;
		res++;
	}
	cout << res << endl;

}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n+1);
  for(int i=0; i<n+1; i++){
    cin >> a.at(i);
  }
  vector<int> b(n);
  for(int i=0; i<n; i++){
    cin >> b.at(i);
  }
  
  long count = 0;
  for(int i=0; i<n; i++){
    if(b.at(i) >= a.at(i)){
      count += a.at(i);
      if(a.at(i+1) >= (b.at(i) - a.at(i))){
        count += (b.at(i) - a.at(i));
        a.at(i+1) -= (b.at(i) - a.at(i));
      }
      else if(a.at(i+1) < (b.at(i) - a.at(i))){
        count += a.at(i+1);
        a.at(i+1) = 0;
      }
    }
    
    else if(b.at(i) < a.at(i)){
      count += b.at(i);
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * Programming Contest
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		int N = parseInt(br.readLine());

		int[] score = new int[102];

		StringTokenizer st = new StringTokenizer(br.readLine());

		for (int i = 0; i < N; i++) {
			score[parseInt(st.nextToken())]++;
		}

		int ans = 0;

		for (int i = 100; i >= 0; i--) {
			score[i] += score[i + 1];
			if (score[i] >= i) {
				ans = i;
				break;
			}
		}

		System.out.println(ans);
	}
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	long long N, ans=0;
	cin>>N;
	for(int i=1;1LL*i*i<N;i++) {
		if(N%i==0 && i<N/i-1) ans+=N/i-1;
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

	int a, b, c, temp,i;
	unsigned n;

	scanf("%d",&n);
	//??´??°a,b?????????????????????????????????
	for(i= 0; i < n; i++){
		scanf("%d %d %d",&a ,&b ,&c);

	//N<=1000??§???????????´????????¬??????????????????
		if(!(n <= 1000)){
			while( getchar() != '\n' );
			break;
		}
			//a,b,c???????????????1??\???1000??\??????????????????????????\??????break???
			if(!((a >= 1) && (a <= 1000)) && ((b >= 1) && (b <= 1000)) && ((c >= 1) &&( c <= 1000))){	
				while( getchar() != '\n' );	
				break;
			}
		
	//c>a ?????????c>b??¨????????????????????????????????????
		if(a<b){
			temp=a;
			a=b;
			b=temp;
		}
		if(c<a){
			temp=c;
			c=a;
			a=temp;
		}
		if(c<b){
			temp=c;
			c=b;
			b=temp;
		}
		
		if(c*c == a*a+b*b)
			printf("YES\n");
		else
			printf("NO\n");

	}	
    return 0;
}

Measured memory_bytes: 580
#include<iostream>

using namespace std;
const int MAX = 10e4;
// 入力
int N,x;

bool prime[MAX];
int ans;
bool flag;
void init(){
  for(int i=0;i<MAX;i++)prime[i]=true;
  prime[0]=prime[1]=false;
  for(int i=2;i<MAX;){
    if(prime[i]){
      for(int j=2*i;j<MAX;j+=i)prime[j]=false;
    }
    if(i==2)i++;
    else i+=2;
  }
}

int main(){
  cin >> N;
  ans = 0;
  init();
  while(N--){
    cin >> x;
    if(x < MAX){
      if(prime[x])ans++;
    } else {
      if(x%2!=0){
        flag = true;
        for(int i=3;i<MAX;i+=2){
          if(x%i==0){
            flag = false;
            break;
          }
        }
        if(flag)ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

int main(void){
	int A, B;
	cin >> A >> B;

	int res = max(A+B, max(A-B, A*B));
	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 256
n, m, l = map(lambda x: int(x), input().split(" "))
A, B = [], []
for i in range(n):
    A.append(list(map(lambda x: int(x), input().split(" "))))
for i in range(m):
    B.append(list(map(lambda x: int(x), input().split(" "))))
R = [[0] * l for i in range(n)]
for i in range(n):
    for j in range(l):
        for k in range(m):
            R[i][j] += A[i][k] * B[k][j]
for row in R:
    print(" ".join(map(lambda x: str(x), row)))



Measured memory_bytes: 6900
N = int(input())
S = list(input())
lst = ["A","B","C","D","E",
       "F","G","H","I","J",
       "K","L","M","N","O",
       "P","Q","R","S","T",
       "U","V","W","X","Y",
       "Z"
        ]

for i in range(len(S)):
    S[i] = lst[(lst.index(S[i])+N)%26]
    
print("".join(S))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int n;
    cin >> n;
    
    cout << n * n * n << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define M 2000001
#define VM 10000

int main(void){
  unsigned short *A, *B;
  int C[VM+1],n,i,j;

  scanf("%d",&n);

  A=(int *)malloc(sizeof(short)*n+1);
  B=(int *)malloc(sizeof(short)*n+1);

  for(i=0;i<VM+1;i++)
    C[i]=0;
  for(i=0;i<n;i++){
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }
  for(i=1;i<VM+1;i++) C[i]=C[i]+C[i-1];
  for(j=1;j<n+1;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<n+1;i++){
    printf("%d",B[i]);
    if(i != n) printf(" ");
}
  printf("\n");
  return 0;
}
  



Measured memory_bytes: 9708
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;

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

    map<string, int> cntb, cntr;
    int n;
    cin >> n;
    string s;
    rep(i, n){
        cin >> s;
        ++cntb[s];
    }
    int m;
    cin >> m;
    rep(i, m){
        cin >> s;
        ++cntr[s];
    }

    int res = 0;
    for(auto e: cntb){
        res = max(res, e.second-cntr[e.first]);
    }

    cout << res << endl;


    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
const double PI=acos(-1);
const int Maxn=3005;
int a[Maxn];
int main(){
	int n,l;scanf("%d%d",&n,&l);
	double ansx=0,ansy=0;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++){
			double o1=(a[i]+a[j])/2.0;
			ansx+=(n+i-j-1)*cos(2*PI*o1/l);
			ansy+=(n+i-j-1)*sin(2*PI*o1/l);
			double o2=(0ll+a[i]+a[j]+l)/2.0;
			ansx+=(j-i-1)*cos(2*PI*o2/l);
			ansy+=(j-i-1)*sin(2*PI*o2/l);
		}
	ansx/=1ll*n*(n-1)*(n-2)/6;
	ansy/=1ll*n*(n-1)*(n-2)/6;
	printf("%.15f %.15f",ansx,ansy);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit
#include <cstdio>	// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define DEBUG 0

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
string FILE_NAME = "testcase.C";
string NAME;
string itos (int n )
{
	stringstream ss;
	ss << n;

	return ss.str();
}

const int MAX_V = 1005;

int semi[MAX_V];

struct edge{
	int to, cost;
};

vector<edge> G[MAX_V];

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

int calc_cost (int u, int p ){

	int sum = 0;
	rep (i, G[u].size() ){
		int v = G[u][i].to;
		int cur = 0;
		if (v != p ){
			cur = G[u][i].cost;
			if (!semi[v] ){
				cur = min (cur, calc_cost (v, u ) );
			} // end if
		} // end if
		sum += cur;
	} // end rep

	return sum;
}

int main()
{
//	cut here before submit 
#if DEBUG
	NAME = FILE_NAME;
	int CNT = 1;
	NAME += itos (CNT );
	while (freopen (NAME.c_str() , "r", stdin ) != NULL ) {
#endif
	memset (semi, 0, sizeof (semi ) );
	rep (i, 1005 ) G[i].clear();
	ios_base::sync_with_stdio(0);
	int n; cin >> n;
	for (int i = 1; i < n; i++ ){
		cin >> semi[i];
	} // end for
	rep (i, n-1 ){
		int from, to, cost;
		cin >> from >> to >> cost;
		add_edge (from, to, cost );
	} // end rep

	int res = calc_cost (0, -1 );
	cout << res << endl;
#if DEBUG
	CNT++;	// cut here before submit
	NAME = FILE_NAME;
	NAME += itos (CNT );
	} // end loop; cut here before submit
#endif			
	return 0;
}

Measured memory_bytes: 1296
#include <stdio.h>
int main(void){
    int i, n;
    long long int ans=1, a[100000];
    scanf("%d",&n);
    for(i=0; i<n; i++){scanf("%lld", &a[i]);}
    for(i=0; i<n; i++){
        if(a[i]==0){
            printf("0\n");
            return 0;
        }
    }
    for(i=0; i<n; i++){
        if(a[i]<=1000000000000000000/ans){
            ans *= a[i];
        }else{
            printf("-1\n");
            return 0;
        }
    }
    printf("%lld\n",ans);
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define REREP(i,n) for(int i=int(n-1); i>=0; i--)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define REFOR(i,m,n) for(int i=int(n-1); i>=int(m); i--)
#define ALL(obj) (obj).begin(),(obj).end()
 
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VD vector<double>
#define VVD vector<vector<double>>
#define VVVD vector<vector<vector<double>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VVVB vector<vector<vector<bool>>>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVVS vector<vector<vector<string>>>
 
#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<ll,ll>
#define VPII vector<pair<int,int>>
#define VVPII vector<vector<pair<int,int>>>
#define VVVPII vector<vector<vector<pair<int,int>>>>
#define VPLL vector<pair<ll,ll>>
#define VVPLL vector<vector<pair<ll,ll>>>
#define VVVPLL vector<vector<vector<pair<ll,ll>>>>
 
#define SUMI(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SUMD(obj) accumulate((obj).begin(), (obj).end(), 0.)
#define SUML(obj) accumulate((obj).begin(), (obj).end(), 0LL)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

#define PB push_back
#define Cout(str) cout << str << endl

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const ll EPS = (ll)1e-8;

int main(){
	int n,m;
	int a,b,c;
	int sum;
	string str;
	string s,t;
	char ch;
	VI vi;
	vector<char> vc;
	VS vs;
	int reserve_vi = 100;
	map<int, int> table; 
	string str2, str3;
	map<char, string> vowel;
	vector<char> vowel_vec = {'a', 'e', 'i', 'o', 'u'};

	//cin >> n >> m;
	//cin >> a >> b;
	//cin >> a >> b >> c;
	cin >> str;
	//cin >> str >> str2 >> str3;
	//cin >> n;
	
	//cin >> s >> t;
	//cin >> ch;
	//cin >> a >> ch >> b;
	replace(ALL(str), ',', ' ');

	cout << str << endl;

	//cout << accumulate(vi.begin(), vi.begin()+n, 0) << endl;

	//swap(a, b);
	//vi.resize(N);
	//fill(vi.begin(), vi.end(), 1);
	//vi.reserve(reserve_vi);
	//vi.PB(n);

	//vc.resize(5);
	//vc[i] = (str[i]);

	//sort(vc.begin(), vc.end(), greater<char>());
	//sort(vc.begin(), vc.end());

	//for(auto itr = table.begin(); itr != table.end(); ++itr) {
	return 0;
}



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

count = 0
for _ in range(N):
  D = map(int, input().split())
  D = list(D)
  if D[0] == D[1]:
    count += 1
    if count >= 3:
      print('Yes')
      break
    continue
  count = 0
else:
  print('No')

Measured memory_bytes: 9152