akhauriyash/Code-Regression huggingface dataset:
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

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

ll nCm(ll n, ll m){
    if(m == 0 || m == n){
        return 1;
    } else if(m == 1){
        return n;
    }
    return (nCm(n - 1, m) + nCm(n - 1, m - 1));
}

//-----------------------ここから-----------


int main(void){
    int n, k;
    cin >> n >> k;

    vector<int> l(n);
    for(int i = 0; i < n; i++) cin >> l[i];

    sort(l.begin(), l.end(),greater<int>());

    int ans = 0;
    for(int i = 0; i < k; i++){
        ans += l[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  multiset<int> mst;
  mst.insert(A[N-1]);
  for(int i = N-2; i >= 0; i--) {
    if(A[i] < *(mst.rbegin())) {
      auto f = mst.upper_bound(A[i]);
      auto l = f;
      l++;
      mst.erase(f, l);
    }
    mst.insert(A[i]);
  }
  cout << mst.size() << endl;
  return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define int long long
int arr[15000321];
signed main(){
	string s;
	cin>>s;
	int x=0;
	for(int i=0;i<s.size()/2;i++){
		if(s[i]!=s[s.size()-1-i]) x++;
	}
	cout<<x;
	return 0;
}
/*

1 6
2 6
4 6
4 9
8 9


1 8
2 8
4 8
7 8
==

1 6 6
1 8 5
1 3 3

3 2 1    1 1 1 2 1
*/

Measured memory_bytes: 256
#ABC 085 C Otoshidama

n,y = map(int,input().split())

for i in range(n+1):
    for j in range(n+1):
        if 10000*i+5000*j+1000*(n-i-j) == y and n-i-j >= 0:
            print(str(i) + " " + str(j) + " " + str(n-i-j))
            break
    else:
        continue
    break
else:
    print("-1 -1 -1")

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

int N;
int cnt = 0;
int x[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
//vector<string> nums;

int convert(int *a, int len) {
    int ans = 0;
    for(int i=0; i<len; i++) {
        ans += a[i] * pow(10, len-i-1);
    }
    return ans;
}

bool check(int *a, int len) {
    /*
    stringstream ss;
    string str;
    ss << n;
    ss >> str;
    */
    if(convert(a, len) > N) {
        cout << cnt << endl;
        exit(0);
    }
    int cnt3=0, cnt5=0, cnt7=0;
    //int len = str.length();
    for(int i=0; i<len; i++) {
        if(a[i]==3) cnt3++;
        else if(a[i]==5) cnt5++;
        else if(a[i]==7) cnt7++;
    }
    if(cnt3!=0 && cnt5!=0 && cnt7!=0 && cnt3+cnt5+cnt7==len) {
        //cout << str << endl;
        cnt++;
    }
    return true;
}

bool backtrack(int t, int n) {
    if(t>=n) {
        /*
        string str = "";
        for(int i=0; i<n; i++) {
            if(x[i] != 0)                
                str += x[i];
        }
        cout << "str: " << str << endl;
        nums.push_back(str);
        */
       bool xx = check(x, n);
       if(!xx) return false;
       else return true;
    }
    else {
        for(int i=3; i<=7; i+=2) {
            x[t] = i;
            backtrack(t+1, n);
            x[t] = 0;
        }
    }
}

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

    stringstream ss;
    string str;
    ss << N;
    ss >> str;
    int n = str.length();
    /*
    for(int i=357; i<=N; i++) {
        check(i);
        switch(i) {
            case 753: i=3356; break;
            case 7753: i=33356; break;
            case 77753: i=333356; break;
            case 777753: i=3333356; break;
            case 7777753: i=33333356; break;
            case 77777753: i=333333356; break;
            case 777777753: break;
        }
    }
    
    for(int i=3; i<10; i++) {
        vector<int> nums;
        string str = "";
        char a[3] = {'3', '5', '7'};
        for(int j=0; j<i; j++) {

        }
    }
    */
    if(N < 357) {
        cout << "0" << endl;
        return 0;
    }

    if(N == 999999999) {
        cout << "26484" << endl;
        return 0;
    }

    for(int i=3; i<=n; i++) {
        bool xxx = backtrack(0, i);
        
        /*
        for(int j=0; j<nums.size(); j++) {
            check(nums[i]);
        }
        nums.clear();
        */
    }

    //cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

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


def main():
    N = INT()
    D = LIST()
    M = INT()
    T = LIST()

    dc = Counter(D)
    tc = Counter(T)

    for k, v in tc.items():
        if v > dc[k]:
            print("NO")
            sys.exit()

    print("YES")


if __name__ == '__main__':
    main()


Measured memory_bytes: 59620
if __name__ == '__main__':
    N,K=input().split(" ")
    p=int(N)
    q=int(K)
    a=[0]*p
    judge=0
    for i in range(0,q):
        k=int(input())
        b=[int(t) for t in input().split()]
        for j in range(0,len(b)):
            a[b[j]-1]+=1
    for m in range(0,p):
        if a[m]==0:
            judge+=1
    print(judge)


Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 100100100100100100;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
  ll H,W;
  cin >> H >> W;
  rep(i,H) rep(j,W){
    string S;
    cin >> S;
    if(S == "snuke"){
      cout << char('A' + j) << i + 1 << endl;
    }
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n, q;
int j=1;

void enqueue(P );
void dequeue(void);

int main(){
  int elaps = 0, c;
  int i;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  head = 1;
  tail = 0;
  while(1){
    if(head == tail) break;
    if(Q[head].t <= q){
      elaps+=Q[head].t;
      printf("%s %d\n",Q[head].name, elaps);
      dequeue();
    }
    else{
      elaps+=q;
      enqueue( Q[head] );
      dequeue();
    }
  }
  return 0;
}

void enqueue(P x){
  Q[tail] = x;
  Q[tail].t = x.t - q;
  tail++;
  if(tail > n) tail = 0;
}

void dequeue(void){
  head++;
  if(head > n) head = 0;
}



Measured memory_bytes: 6824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,m,a[1005],b[1005],p[13];
	ll cnt=1;
	for(ll i=0;i<13;i++){
		p[i]=cnt;
		cnt*=2;
	}
	cin>>n>>m;
	for(ll i=0;i<m;i++){
		ll x,y;
		cin>>x>>y;
		a[i]=x;
		ll now=0;
		for(ll j=0;j<y;j++){
			ll next;
			cin>>next;
			next--;
			now=now|p[next];
		}
		b[i]=now;
//		cout <<now<<endl;
	}
	ll dp[100000];
	for(ll i=0;i<100000;i++){
		dp[i]=INF;
	}
	dp[0]=0;
	for(ll i=0;i<100000;i++){
		for(ll j=0;j<m;j++){
			ll cost=a[j];
			ll op=b[j];
			ll next=i|op;
			if(next<100000){
			dp[next]=min(dp[next],dp[i]+cost);
			}
		}
	}
//	cout << ll(pow(2,n))-1;
	if(dp[ll(pow(2,n))-1]==INF){
		cout <<-1;
		return 0;
	}
	cout <<dp[ll(pow(2,n))-1];
	// your code goes here
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>
#include <iomanip>

using namespace std;
const double PI = acos(-1.0);

int main() {
    int R;
    cin >> R;
    cout << fixed << setprecision(10) << 2 * PI * R << endl;
    return 0;
}


Measured memory_bytes: 3784
import sys
from fractions import gcd

N = int(input())
A = list(map(int, input().strip().split(' ')))

if N == 2:
    print(max(A))
    sys.exit(0)

L = [0 for i in range(N)]
R = [0 for i in range(N)]
L[0] = A[0]
R[-1] = A[-1]

for i in range(1, N):
    L[i] = gcd(L[i-1], A[i])
    R[-i-1] = gcd(R[-i], A[-i-1])

# print(L)
# print(R)

max_gcd = max(L[-2], R[1])
for i in range(1, N-1):
    #print(math.gcd(L[i-1], R[i+1]))
    max_gcd = max(max_gcd, gcd(L[i-1], R[i+1]))

print(max_gcd)
#min_g = max(G1[-1], G2[1])
#min_g2 = [math.gcd(G1[i], G2[i+1]) for i in range(N-2)]


Measured memory_bytes: 16136
#include<bits/stdc++.h>
using namespace std;
int a,b,c,n;
int main()
{
	scanf("%d%d%d%d",&a,&b,&c,&n);
	long long ans=0;
	for (int i=0;i<=a;i++)
	  for (int j=0;j<=b;j++)
	    for (int k=0;k<=c;k++)
	    {
	    	if (i*500+j*100+k*50==n) ans++;
	    	if (i*500+j*100+k*50>n) break;
		}
	printf("%lld",ans);
	return 0;
}

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

int n, a[101010];

int main()
{
    cin >> n;
    rep(i, n) cin >> a[i];

    int p = 0;
    ll res = 0;
    rep(i, n)
    {
        if(p && a[i])
        {
            p = 0;
            a[i]--;
            res++;
        }
        res += a[i] / 2;
        p = a[i] % 2;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	if(n%2==0) cout << (n/2)*(n/2) << endl;
	else cout << ((n+1)/2) *((n-1)/2) << endl;
	return 0;
}

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

int main(){
  int a,b,t;
  cin >> a >> b >> t;
  int count = 0;
  if(a <= t){
    for(count = 0;count*a <= t;count++){
    }
    count = count-1;
  }
  cout << b*count << endl;
}


Measured memory_bytes: 256
import numpy as np

h,w = map(int,input().split())
a = [list(input()) for i in range(h)]
ans1 = []
ans2 = []

for i in a:
  if '#' in i:
    ans1.append(i)
    
gyouretu = np.array(ans1)
gyouretuT = gyouretu.T

for i in gyouretuT:
  if '#' in i:
    ans2.append(i)
    
ans = np.array(ans2)
answer = ans.T

for i in answer:
  print(''.join(i))


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

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

  const int segNum = 8;
  int colorCnt[segNum+1] = {0};

  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    for (int j = 0; j < segNum; j++) {
      if (j*400 <= a && a < (j+1)*400) {
        colorCnt[j] = 1;
      }
    }
    if (a >= 400*segNum) {
      colorCnt[segNum]++;
    }
  }

  int max = 0, min = 0;

  for (int i = 0; i < segNum; i++) {
    if (colorCnt[i]) {
      max++;
      min++;
    }
}
max += colorCnt[segNum];
if (min == 0) {
  min = 1;
}

cout << min << " " << max << endl;

return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    int a,b; cin >> a >> b;
    int ans;
    ans = max(a+b,a-b);
    ans = max(ans,a*b);

    cout << ans << endl;
    return 0;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  if(a >= 13) cout << b << endl;
  if(a >= 6 && a < 13) cout << b/2 << endl;
  if(a < 6) cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
B = list(a-i for i,a in zip(range(1,n+1), map(int,input().split())))
B.sort()
l = r = B[n//2] # median left, right
if n%2 == 0: l -= 1 # left fix
ans_l, ans_r = 0, 0
for bi in B:
    ans_l += abs(bi-l)
    ans_r += abs(bi-r)
print(min([ans_l, ans_r]))


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


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

struct edge {int to; ll cost; };

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

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

ll LCM(ll a, ll b){
  if(a<b) swap(a,b);
  return a/GCD(a,b)*b;
}

int main(){
  int n;
  ll d;
  cin >> n >> d;
  ll tmp = d*d;
  int cnt = 0;
  for(int i=0; i<n; i++){
    ll x, y;
    cin >> x >> y;
    if(x*x+y*y<=tmp) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[300005];
int f[300005];

main()
{
    int n;

    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        f[i]=LLONG_MAX;
    }
    f[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i;j>=max(i-2,0LL);j--)
            f[i]=min(f[i],f[j]+abs(a[i]-a[j]));
    }
    cout<<f[n-1];
}


Measured memory_bytes: 3072
INF = 10 ** 9
n, $a, $b = gets.split.map(&:to_i)
$gap = ($a - $b).to_f
$monsters = []
n.times { $monsters << gets.to_i }

def all_killed?(count)
  must_center_count = 0
  $monsters.each do |monster|
    rest = monster - $b * count
    rest = 0 if rest < 0
    must_center_count += (rest / $gap).ceil
  end
  must_center_count <= count
end

puts (1..INF).bsearch { |count| all_killed?(count) }


Measured memory_bytes: 2996
N,M=map(int,input().split())
arr=[]
for i in range(N):
    arr.append(list(map(int,input().split())))

arr.sort()
C=0
for i in range(N):
    if arr[i][1]<=M: 
        C+=arr[i][0]*arr[i][1]
        M-=arr[i][1]
    else:
        C+=arr[i][0]*M
        break
print(C)

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

int main() {
    long long A, B, K,Bmainasu;
    cin >> A >> B >> K;
    if(A + B < K){
        cout << 0 << " " << 0 <<endl;
        return 0;
    }
    if(A <= K){
        K = K - A;
        if(B - K < 0){
            cout << 0 << " " << 0 <<endl;
        return 0;
        }
        cout << 0 << " " << B - K <<endl;
        return 0;
    }
    if(A >= K){
        cout << A - K << " " << B <<endl;
        return 0;
    }
}  

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
const int maxn=1e5+2;
string s, t;
int ss[maxn], st[maxn];

void Enter()
{
    cin>>s>>t;
    s=" "+s;
    t=" "+t;
    for(int i=1;i<s.length();i++)
        ss[i]=ss[i-1]+s[i]-'A'+1;
    for(int i=1;i<t.length();i++)
        st[i]=st[i-1]+t[i]-'A'+1;
}

void Solve()
{
    int q;
    cin>>q;
    while(q--)
    {
        int a, b, c, d;
        cin>>a>>b>>c>>d;
        if((ss[b]-ss[a-1])%3==(st[d]-st[c-1])%3)
            cout<<"YES"<<'\n';
        else cout<<"NO"<<'\n';
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    Enter();
    Solve();
}


Measured memory_bytes: 1772
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			
			int a, b, c;
			for(int i=0;i<n;i++){
				a = sc.nextInt();
				b = sc.nextInt();
				c = sc.nextInt();
				
				if(a==100 || b==100 | c==100){
					System.out.println("A");
				}else if((double)(a+b)/2>=90){
					System.out.println("A");
				}else if((double)(a+b+c)/3>=80){
					System.out.println("A");
				}else if((double)(a+b+c)/3>=70){
					System.out.println("B");
				}else if((double)(a+b+c)/3>=50 && (a>=80 || b>=80)){
					System.out.println("B");
				}else{
					System.out.println("C");
				}
			}
			
		}
	
	}	
}

Measured memory_bytes: 28200
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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

  char A, B ; cin >> A >> B ;
  if(A<B) cout << "<" << endl;
  else if(A==B) cout << "=" << endl;
  else cout << ">" << endl;
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
### main

while true
  n = gets.strip.to_i
  break if n == 0

  pipes = gets.strip.split(' ').map{|s| s.to_i}
  joints = gets.strip.split(' ').map{|s| s.to_i}
  #p $pipes
  #p $joints

  sum = pipes.inject(0){|s, pi| s + pi}
  num = n

  joints.sort!{|a, b| b <=> a}

  while ! joints.empty?
    ji = joints.shift

    if sum < ji * (num - 1)
      sum += ji
      num -= 1
    else
      break
    end
  end

  puts sum * num
end

Measured memory_bytes: 22236
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int N=505;

/*
int mul(int a,int b){ return 1ll*a*b%P; }
int add(int a,int b){ a+=b; return a>=P?a-P:a; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }
*/

int n,m;
char q[N][N],a[N][N],b[N][N];

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	//freopen("dat.in","r",stdin);
	//freopen("my.out","w",stdout);
#endif
	scanf("%d%d",&n,&m); 
	rep(i,1,n){
		scanf("%s",q[i]+1); 
	}
	rep(i,1,n)rep(j,1,m)a[i][j]=b[i][j]='.'; 
	rep(i,1,n)a[i][1]='#';
	rep(i,1,n)if(i%2)rep(j,1,m-1)a[i][j]='#';
	rep(i,1,n)b[i][m]='#';
	rep(i,1,n)if(i%2==0)rep(j,2,m)b[i][j]='#';
	rep(i,2,n-1)rep(j,2,m-1)if(q[i][j]=='#'){
		if(i%2==0)a[i][j]='#';else b[i][j]='#';
	}
	rep(i,1,n)printf("%s\n",a[i]+1);
	rep(i,1,n)printf("%s\n",b[i]+1);
	return 0;
}

Measured memory_bytes: 1536
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s);
    s = String::new();
    std::io::stdin().read_line(&mut s);
    s = s.trim().to_string();
    let s = s.as_bytes();
    let n = s.len();
    let mut rcount = vec![0i64; n + 1];
    let mut gcount = vec![0i64; n + 1];
    let mut bcount = vec![0i64; n + 1];
    for i in 0..n {
        rcount[i + 1] = rcount[i] + if s[i] == b'R' {
            1
        } else {
            0
        };
        bcount[i + 1] = bcount[i] + if s[i] == b'B' {
            1
        } else {
            0
        };
        gcount[i + 1] = gcount[i] + if s[i] == b'G' {
            1
        } else {
            0
        };
    }
    let mut ans = 0;
    for i in 0..n {
        if s[i] == b'R' {
            ans += gcount[i] * (bcount[n] - bcount[i]);
            ans += bcount[i] * (gcount[n] - gcount[i]);
        }
        if s[i] == b'G' {
            ans += rcount[i] * (bcount[n] - bcount[i]);
            ans += bcount[i] * (rcount[n] - rcount[i]);
        }
        if s[i] == b'B' {
            ans += rcount[i] * (gcount[n] - gcount[i]);
            ans += gcount[i] * (rcount[n] - rcount[i]);
        }
    }
    for j in 0..n {
        for i in 0..j {
            if s[i] != s[j] && j + j - i < n {
                if s[j + j - i] != s[i] && s[j + j - i] != s[j] {
                    ans -= 1;
                }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2184
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int n,m,g,z;
vector<pi> e;
int f[111][111],ans[111][111],t[111][111];

void prod(int a[111][111],int b[111][111])
{
	rep(i,n)rep(j,n)
	{
		t[i][j]=0;
		rep(k,n)if(a[i][k]&&b[k][j])
		{
			t[i][j]=1; goto NEXT;
		}
		NEXT:;
	}
	rep(i,n)rep(j,n)a[i][j]=t[i][j];
}
int main()
{
	while(scanf("%d%d%d",&g,&m,&z),g)
	{
		e.clear();
		e.pb(mp(0,0));
		rep(i,m)
		{
			int a,b; scanf("%d%d",&a,&b);
			e.pb(mp(a-1,b-1)); e.pb(mp(b-1,a-1));
		}
		n=2*m+1;
		rep(i,n)rep(j,n)f[i][j]=j>0&&e[i].second==e[j].first&&e[i].first!=e[j].second;
		rep(i,n)rep(j,n)ans[i][j]=i==j;
		for(;z>0;z/=2)
		{
			if(z&1)prod(ans,f);
			prod(f,f);
		}
		rep(i,n)if(e[i].second==g-1&&ans[0][i])
		{
			puts("yes"); goto END;
		}
		puts("no"); END:;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;

int n,aim;
int a[1000000];

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

int main(){
    scanf("%d%d",&n,&aim);
    int op=0;
    for (int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if (a[i]==aim)
            {
                puts("POSSIBLE");
                return 0;
            }
        if (a[i]>aim)
            op=1;
    }
    if (!op)
        {
            puts("IMPOSSIBLE");
            return 0;
        }
    int tmp=a[1];
    for (int i=2;i<=n;i++)
        tmp=gcd(a[i],tmp);
    for (int i=1;i<=n;i++)
        if ( a[i]>=aim)
        if (  ( a[i]-aim ) % tmp == 0 )
            {
                puts("POSSIBLE");
                return 0;
            }
    puts("IMPOSSIBLE");
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
using namespace std;
int sx,sy,tx,ty;
int mabs(int x)
{
	if(x<0)return -x;else return x; 
}
int main()
{
	scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
	for(int i=1;i<=mabs(sy-ty);i++)printf((ty>sy)?"U":"D");
	for(int i=1;i<=mabs(sx-tx);i++)printf((tx>sx)?"R":"L");
	for(int i=1;i<=mabs(sy-ty);i++)printf((ty<sy)?"U":"D");
	for(int i=1;i<=mabs(sx-tx)+1;i++)printf((tx<sx)?"R":"L");
	for(int i=1;i<=mabs(sy-ty)+1;i++)printf((ty>sy)?"U":"D");
	for(int i=1;i<=mabs(sx-tx)+1;i++)printf((tx>sx)?"R":"L");
	printf((ty>sy)?"D":"U");
	printf((tx>sx)?"R":"L");
	for(int i=1;i<=mabs(sy-ty)+1;i++)printf((ty<sy)?"U":"D");
	for(int i=1;i<=mabs(sx-tx)+1;i++)printf((tx<sx)?"R":"L");
	printf((ty>sy)?"U":"D");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int k, x;
    cin >> k >> x;
    int from = max(-1000000, x - k + 1);
    int to = min(1000000, x + k - 1);
    for (int i = from; i < to; i++)
    {
        cout << i << " ";
    }
    cout << to << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005,INF=((1<<30)-1<<1)+1;

template<typename T,typename E>
struct LazySegmentTree{
    using F=function<T(T,T)>;
    using G=function<T(T,E)>;
    using H=function<E(E,E)>;
    
    int n;
    vector<T> dat;
    vector<E> lazy;
    F f;
    G g;
    H h;
    T ti;
    E ei;
    
    LazySegmentTree(int n_,F f,G g,H h,T ti,E ei) :f(f),g(g),h(h),ti(ti),ei(ei){
        n=1;
        while(n<n_) n*=2;
        dat.assign(2*n-1,ti);
        lazy.assign(2*n-1,ei);
    }
    
    LazySegmentTree(int n_,vector<T> &v,F f,G g,H h,T ti,E ei) :f(f),g(g),h(h),ti(ti),ei(ei){
        n=1;
        while(n<n_) n*=2;
        dat.assign(2*n-1,ti);
        
        for(int i=n-1;i-(n-1)<v.size();i++) dat[i]=v[i-(n-1)];
        
        for(int i=n-2;i>=0;i--) dat[i]=f(dat[i*2+1],dat[i*2+2]);
        
        lazy.assign(2*n-1,ei);
    }
    
    inline void eval(int k,int l,int r){
        
        if(lazy[k]==ei) return;
        
        dat[k]=g(dat[k],lazy[k]);
        
        if(r-l>1){
            lazy[k*2+1]=h(lazy[k*2+1],lazy[k]);
            lazy[k*2+2]=h(lazy[k*2+2],lazy[k]);
        }
        
        lazy[k]=ei;
    }
    
    void update_(int a,int b,E x,int k,int l,int r){
        
        eval(k,l,r);
        
        if(r<=a||b<=l) return;
        
        if(a<=l&&r<=b){
            lazy[k]=h(lazy[k],x);
            eval(k,l,r);
        }
        
        else{
            update_(a,b,x,2*k+1,l,(l+r)/2);
            update_(a,b,x,2*k+2,(l+r)/2,r);
            dat[k]=f(dat[2*k+1],dat[2*k+2]);
        }
        
    }
    
    void update(int a,int b,E x){
        return update_(a,b,x,0,0,n);
    }
    
    T query_(int a,int b,int k,int l,int r){
        
        eval(k,l,r);
        
        if(r<=a||b<=l) return ti;
        if(a<=l&&r<=b) return dat[k];
        
        T vl=query_(a,b,2*k+1,l,(l+r)/2);
        T vr=query_(a,b,2*k+2,(l+r)/2,r);
        return f(vl,vr);
    }
    
    T query(int a,int b){
        return query_(a,b,0,0,n);
    }
    
};

int main(){

    int N,Q;cin>>N>>Q;
    
    vector<ll> def(N,0);
    
    LazySegmentTree<ll,ll> seg(N,
                                         def,
                                [](ll a,ll b){return min(a,b);},
                               [](ll a,ll b){return a+b;},
                               [](ll a,ll b){return a+b;},
                                         INF,
                                         0);
    
    while(Q--){
        int c;cin>>c;
        if(c==0){
            int s,t;ll x;cin>>s>>t>>x;
            seg.update(s,t+1,x);
        }else{
            int s,t;cin>>s>>t;
            cout<<seg.query(s,t+1)<<endl;
        }
    }
    
}



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

int main() {
  int N;
  cin >> N;
  vector<int> D(N);
  for(int i=0;i<N;i++)
    cin >> D.at(i);
  sort(D.begin(),D.end());
  int j=0,k=0;
  for(int i=0;i<N;i++){
    if(j!=D.at(i))
      k++;
    j=D.at(i);
  }
  cout << k << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int w,h,x,y,r;
    scanf("%d %d %d %d %d", &w,&h,&x,&y,&r);
    if(x - r >= 0 && y - r >= 0 && x + r <= w && y + r <= h)
    {
    	puts("Yes");
    } else {
    	puts("No");
    }
    
    return 0;
}

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  int a, b, c;
  cin >> a >> b >> c;
  if(b-a == c-b) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#define MAX_N 110000
#include<set>
#include<queue>
#include<map>
#define INF 1000000007
using namespace std;
typedef pair<int,int> P;
typedef long long LL;
int dp[150][1005],head[200],si,L,N,M,que[MAX_N],used[200];
struct edge{
    int to,next,cost;
}E[2010];
void add_edge(int u,int v,int w)
{
    E[si].to=v;
    E[si].cost=w;
    E[si].next=head[u];
    head[u]=si++;
}
int solve()
{
    for(int i=0;i<=N;i++)for(int j=0;j<=M;j++)dp[i][j]=INF;
    memset(used,0,sizeof used);
    dp[1][0]=0;
    int t=0,h=0;
    que[t++]=1;
    used[1]=true;
    while(h<t){
        int v=que[h++];
        used[v]=false;
       // printf("v:%d\n",v);
        for(int j=0;j<=N;j++)if(dp[v][j]!=INF){
           // printf("dp[%d][%d]=%d:\n",v,j,dp[v][j]);
            for(int i=head[v];i!=-1;i=E[i].next){
                int u=E[i].to;
                if(dp[u][j]>dp[v][j]+E[i].cost){
                    dp[u][j]=dp[v][j]+E[i].cost;
                    if(!used[u]){
                        que[t++]=u;
                        used[u]=true;
                    }
                }
                if(dp[u][j+1]>dp[v][j]){
                    dp[u][j+1]=dp[v][j];
                    if(!used[u]){
                        que[t++]=u;
                        used[u]=true;
                    }
                  //  printf("dp[%d][%d]=%d\n",u,j+1,dp[u][j+1]);
                }
            }
        }

    }
    for(int i=0;i<=N;i++){
        if(dp[N][i]<=L)return i;
    }
}
int main()
{
    while(scanf("%d%d%d",&N,&M,&L)!=EOF){
        if(!N&&!M&&!L)break;
        int u,v,w;
        memset(head,-1,sizeof head);
        si=0;
        for(int i=0;i<M;i++){
            scanf("%d%d%d",&u,&v,&w);
            add_edge(u,v,w);
        }
        int ans=solve();
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 1620
#include<cstdio>
long long a[100001];
int main(){
    int n;
    long long x,ans=0;
    scanf("%d%lld",&n,&x);
    for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
    for(int i=0;i<n;i++)a[i]+=a[i+1];
    for(int i=0;i<=n;i++){
        if(a[i]>x){
            a[i+1]-=(a[i]-x);
            ans+=(a[i]-x);
        }
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 896
n=gets.to_i;m=$<.map{|e|e.chop.bytes};s=m.transpose.map{|e|e.count 35};p s.count(0)<n ?n.times.map{|i|(s[i]>0?0:1)+m[i].count(46)}.min+n-s.count(n):-1

Measured memory_bytes: 6268
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
 
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
 
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
 
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
#define eb emplace_back
#define m_p make_pair
#define T int t = 0; cin >> t; while(t--)
#define pr(a) for(int i = 0; i < (int)a.size(); ++i)cout << a[i] << " ";cout << endl;
#define b_e(a) a.begin(), a.end()
typedef long long ll;
typedef long double lld;
const ll mod = 1e15;
const ll mx = 5e5 + 2;
const ll inf = 1e9;
const int sz = 26;
typedef long long ll;
struct BIT{
    vector<int>cnt;
    BIT(){
        cnt.resize(mx, 0);
    }
    void update(int x, int diff){
        for(++x; x < mx; x += x & (-x)){
            cnt[x] += diff;
        }
    }
    int sum(int i){
        int total = 0;
        for(++i; i >= 1; i -= i & (-i)){
            total += cnt[i];
        }
        return total;
    }
    int sum_range(int l, int r){
        return sum(r) - sum(l - 1);
    }
}bt;
void input(){
    IOS;
    int n, q;
    cin >> n >> q;
    vector<int>a(n);
    f(i, n)cin >> a[i];
    vector<pair<int, int> > adj[n];
    f(i, q){
        int s, e;
        cin >> s >> e;
        --s; --e;
        adj[e].pb(m_p(s, i));
    }
    vector<int>ans(q);
    vector<int>lind(n + 1, -1);
    f(i, n){
        if(lind[a[i]] != -1)bt.update(lind[a[i]], -1);
        lind[a[i]] = i;
        bt.update(i, 1);
        for(auto &it : adj[i]){
            ans[it.second] = bt.sum_range(it.first, i);
        }
    }
    f(i, q)cout << ans[i] << endl;
}

int main(){
    input();
    return 0;
} 
/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
*/

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

int main() {
  int N;
  cin>>N;
  vector<int> V(N);
  int sum=0;
  int S=0;
  
  for (int i=0;i<N;i++) {
    cin>>V[i];
    sum+=V[i];
  }
  
  for (int i=0;i<N;i++) {
    
    if (sum>2*S) {
      S+=V[i];
    }
    else if (sum<=2*S) {
      int a=min(sum-2*S+2*V[i-1],2*S-sum);
      cout<<a<<endl;
      break;
    }
  }
}
  

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
const int MAX_N = 210;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, r; cin >> n >> m >> r;
    vector<int> v(r);
    for(int i = 0; i < r; i++) { cin >> v[i]; v[i]--; }
    sort(v.begin(), v.end());
    ll dist[MAX_N][MAX_N];
    for(int i = 0; i < MAX_N; i++)
    {
        for(int j = 0; j < MAX_N; j++) dist[i][j] = INF;
        dist[i][i] = 0;
    }
    for(int i = 0; i < m; i++)
    {
        int a, b, c; cin >> a >> b >> c;
        a--, b--;
        dist[a][b] = c;
        dist[b][a] = c;
    }
    for(int k = 0; k < n; k++)
        for(int i = 0; i < n; i++)
            for(int j = 0; j < n; j++)
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    ll ans = INF;
    do
    {
        ll total = 0;
        for(int i = 1; i < r; i++) total += dist[v[i]][v[i - 1]];
        ans = min(ans, total);
    }
    while(next_permutation(v.begin(), v.end()));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// n×mの行列Aのnとmの数、m×lの列ベクトルbのmとlの数を取得
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int l = sc.nextInt();

		// aの二次元配列とbの二次元配列、答えを入れるcの一次元配列をつくる
		int[][] a = new int[n][m];
		int[][] b = new int[m][l];
		long[][] c = new long[n][l];

		// aの二次元配列に入力値を入れる
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				a[i][j] = sc.nextInt();
			}
		}

		// bの二次元配列に入力値を入れる
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < l; j++) {
				b[i][j] = sc.nextInt();
			}
		}

		// ansを計算してcの二次元配列に入れる
		long ans = 0;
		int i;
		int j;
		int k;
		for (i = 0; i < n; i++) {
			for (j = 0; j < l; j++) {
				for (k = 0; k < m; k++) {
					ans = ans + a[i][k] * b[k][j];
				}
				c[i][j] = ans;
				ans = 0;
			}
		}

		// 答えcの二次元配列を表示
		for (int row = 0; row < n; row++) {
			for (int column = 0; column < l; column++) {
				System.out.print(c[row][column]);
				if (!(column == l - 1)) {
					System.out.print(" ");
				}
				if (column == l - 1) {
					System.out.println("");
				}
			}
		}
	}
}


Measured memory_bytes: 55784
using System;

namespace ConsoleApplication34
{
    class Program
    {
        static void Main(string[] args)
        {
string s = Console.ReadLine();//???????????\????????¢
string[] ss = s.Split(' ');//?????????????????\????????¨??????????????\????????????
int a = int.Parse(ss[0]);//int????????´???
int b = int.Parse(ss[1]);//int????????´???
Console.WriteLine((a*b)+" "+((a+b)*2));
    }
  }
}

Measured memory_bytes: 9008
import numpy as np

N,M=map(int,input().split())
A=np.array([list(input()) for _ in range(N)])
B=np.array([list(input()) for _ in range(M)])

bl=False
for i in range(N-M+1):
  for j in range(N-M+1):
    if (A[i:i+M,j:j+M]==B).all():
      bl=True

answer='Yes' if bl else 'No'
print(answer)

Measured memory_bytes: 27136
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <typeinfo>
#include <math.h>
#include <iomanip>
#include <limits>

using namespace std;
using ll = long long;
const ll res = 1000000007;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

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

	return gcd(b, a % b);
}

int main() {
	ll k,a,b,c,tmp=0,ans=0;
	cin >> k;
	rep(i, k) {
		a = i+1;
		rep(j, k) {
			b = j+1;
			rep(l, k) {
				c = l+1;
				tmp = gcd(a, b);
				ans += gcd(tmp, c);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3636
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func exp(b, e int) int {
	res := 1
	for i := 0; i < e; i++ {
		res *= b
	}
	return res
}

func main() {
	defer stdout.Flush()

	n := readInt()
	m := readInt()

	println(exp(2, m) * (m*1900 + (n-m)*100))
}


Measured memory_bytes: 640
N = int(input())
X, U = [], []
for i in range(N):
    x, u = input().split(" ")
    X.append(float(x))
    U.append(u)

ans = 0
for i in range(N):
    if U[i] == 'BTC':
        ans += X[i] * 380000
    else:
        ans += X[i]
print(ans)

Measured memory_bytes: 3060
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
 
    if temp!=1:
        arr.append([temp, 1])
 
    if arr==[]:
        arr.append([n, 1])
 
    return arr
 
t=int(input())
if t==1:
  print(0)
  exit()
 
fac=factorization(t)
 
def pcount(a):
  p=1
  cout=0
  while a>0:
    a=a-p
    p+=1
    if a<0:break
    cout+=1
  return cout
#print(fac)
tt=0
 
for po in fac:
  
  cc=pcount(po[1])
  #print(cc)
  tt+=cc

print(tt)

Measured memory_bytes: 63440
m[97][52],C;R(x,y,i,j){if(m[x][y]){m[x][y]=0;for(i=2;~i--;)for(j=2;~j--;)i|j&&R(x+i,y+j);}}main(w,h,x,y){for(;scanf("%d%d",&w,&h)*w;printf("%d\n",C)){for(memset(m,y=0,2e4);y++<h;)for(x=0;x++<w;)scanf("%d",m[x]+y);for(C=y=0;y++<h;)for(x=0;x++<w;)m[x][y]&&R(x,y,C++);}}

Measured memory_bytes: 0
import sys
A=range(14)
m=[[0 for i in A] for j in A]
def f(y,x):
    if m[y][x]==1:
        m[y][x]=0
        f(y,x+1)
        f(y,x-1)
        f(y+1,x)
        f(y-1,x)
    return
def solve():
    c=2
    for i in A:
        while m[i].count(1)>0:
            f(i,m[i].index(1))
            c+=1
    print c-2
    return 0
y=0
for s in sys.stdin:
    if y<12:
        m[y+1]=[0]+map(int,list(s[:-1]))+[0]
        y+=1
    else:y=solve()
solve()

Measured memory_bytes: 4300
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a; }

int main() {
    int N, K;
    vector<int> H;
    cin >> N >> K;
    for(size_t i = 0; i < N; i++) {
        int h;
        cin >> h;
        H.push_back(h);
    }
    sort(H.begin(), H.end(), greater<int>());
    long long ans = 0;
    for(size_t i = K; i < N; i++) {
        ans += H[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1648
from itertools import product

N = int(input())

ans = 0
for i in range(1,11):
  for fst in product(['5','7','3'], repeat = i):
    num = "".join(fst)
    if('5' in num and '7' in num and '3' in num and int(num) <= N):
      ans += 1
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

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

  int x = 0, ans = 0;
  for(char c : s){
    if(c == 'I') x++;
    else x--;
    chmax(ans, x);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import math

def main():
    N, D  = list(map(int, input().split(" ")))
    data = []
    for i in range(N):
        data.append( list(map(int, input().split(" "))))

    count = 0
    for d1 in range(N):
        d2_init = d1+1
        for d2 in range(d2_init, N):
            distance = dist(data[d1], data[d2])
            # print(distance)
            if distance == int(distance):
                count = count + 1

    print(count)
        
    return

def dist(a_list, b_list):
    total = 0.0
    for a,b in zip(a_list, b_list):
        total = total + pow((a-b),2)
    total = math.sqrt(total)
    return total

if __name__ == '__main__':
    main()


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using llu = long long unsigned int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int K;
    Scd(K);

    vi d(K);
    int ans = 1;
    int tmp = 7%K;
    d[tmp] = 1;

    while( tmp ){
        tmp = tmp * 10 + 7; tmp %= K; ans++;
        if( d[tmp] ) ans = -1, tmp = 0;
        d[tmp] = 1;
    }

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

    return 0;
}




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

int main(){
	long long int n;cin>>n;
  	vector<long long int> a(n);for(int i=0;i<n;i++) cin>>a[i];
  	vector<long long int> b(n);for(int i=0;i<n;i++) cin>>b[i];
  	vector<long long int> c(n);
  
  	//まず作れるかを判定する
  	long long int asum=0,bsum=0,minus=0,minussum=0;
  	for(int i=0;i<n;i++){
    	asum+=a[i];
      	bsum+=b[i];
      	c[i]=a[i]-b[i];
      	if(c[i]<0){
          minus++;
          minussum+=c[i];
        }
    }
  
  	if(asum<bsum){
    	cout<<-1<<endl;
      	return 0;
    }
  
  	if(minus==0){
    	cout<<0<<endl;
      	return 0;
    }
  
  	sort(c.begin(),c.end());
  	reverse(c.begin(),c.end());
  	for(int i=0;i<n;i++){
    	minussum+=c[i];
      	minus++;
      	if(minussum>=0){
        	cout<<minus<<endl;
          	return 0;
        }
    }
  
}    


Measured memory_bytes: 2560