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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef string str;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

inline ll combi2(const ll n) {
    return n * (n - 1) / 2;
}

int main() {
    int n, k;
    cin >> n >> k;
    REP(i, k) {
        int x, y;
        cin >> x >> y;
        int r = min(min(x, n + 1 - x), min(y, n + 1 - y)) % 3;
        cout << (r == 0 ? 3 : r) << "\n";
    }

    return 0;
}



Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define int long long
using namespace std;

int n;
int a[100000];
int ra[100001];

signed main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	
	for (i = 1; i <= n; i++) ra[i] = ra[i - 1] + a[i - 1];
	
	int pos = 0;
	for (i = 0; i < n; i++) {
		if (ra[i + 1] > ra[i] * 3) {
			pos = i;
		}
	}
	
	cout << n - pos << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int N;
	cin >> N;
	int C[N - 1], S[N - 1], F[N - 1];
	rep(i, 0, N - 1) cin >> C[i] >> S[i] >> F[i];

	int rsl[N];
	memset(rsl, 0, sizeof(rsl));

	rep(i, 0, N) {
		int tmp = 0;
		if(i != N - 1) tmp = S[i] + C[i];
		rep(j, i + 1, N - 1) {
			if(tmp < S[j]) tmp = (S[j] + C[j]);
			else if((tmp - S[j]) % F[j] == 0) tmp += C[j];
			else tmp += (C[j] + F[j] - tmp % F[j]);
		}
		rsl[i] = tmp;
	}

	rep(i, 0, N) cout << rsl[i] << endl;


}


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());//line-1
		double[] x = new double[n];
		double[] y = new double[n];
		String[] line = new String[n];
		double dxyP1=0;
		double dxyP2=0;
		double dxyP3=0;
		double dxyP=0;
	//input x
		line=sc.nextLine().split(" ");//line-2
		for(int i=0;i<n;i++){
			x[i]=Double.parseDouble(line[i]);
		}
	//input y	
		line=sc.nextLine().split(" ");//line-3
		for(int i=0;i<n;i++){
			y[i]=Double.parseDouble(line[i]);
		}
	//dxy		
		for(int i=0;i<n;i++){
			dxyP1+=Math.abs(x[i]-y[i]);
			dxyP2+=Math.abs(x[i]-y[i])*Math.abs(x[i]-y[i]);
			dxyP3+=Math.abs(x[i]-y[i])*Math.abs(x[i]-y[i])*Math.abs(x[i]-y[i]);
			if(dxyP<Math.abs(x[i]-y[i])){
				dxyP=Math.abs(x[i]-y[i]);
			}
		}
		dxyP2=Math.sqrt(dxyP2);
		dxyP3=Math.cbrt(dxyP3);
	//output	
		System.out.printf("%.6f",dxyP1);
		System.out.println();
		System.out.printf("%.6f",dxyP2);
		System.out.println();
		System.out.printf("%.6f",dxyP3);
		System.out.println();
		System.out.printf("%.6f",dxyP);
		System.out.println();
	}
}

Measured memory_bytes: 26500
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    ll k;
    cin >> k;
    int n = 50;
    ll ans[n];
    REP(i,n){
        ans[i] = n - 1 + k / n;
    }
    REP(i,k % n){
        ans[i] += n;
        REP(j,n){
            if(i == j) continue;
            ans[j]--;
        }
    }
    cout << n << endl;
    REP(i,n){
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
    long long int i, j, k, n, b, ans=0, po=0;
    scanf("%lld", &n);
    for(i=2; 1; i++){
        po=0;
        if(n%i==0){
        while(1){
            if(n%i==0){
                n = n/i;
                po++;
            }else break;
        }
        for(j=1; 1; j++){
            if(po>=j){
                po = po-j;
                ans++;
            }else break;
        }
        }
        if(n==1) break;
        if(i>1000000){
            ans += 1;
            break;
        }
    }
    printf("%lld", ans);
}

Measured memory_bytes: 1728
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		if(Character.isUpperCase(sc.next().charAt(0))) {
			System.out.println("A");
		}else {
			System.out.println("a");
		}

		sc.close();

	}

}

Measured memory_bytes: 26980
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

const ll MOD=1e9+7;

ll ad(ll x,ll y=0){
  return (x+y)%MOD;
}

ll mlt(ll x,ll y=1){
  return (x*y)%MOD;
}

ll fc[100010]={1};
ll fct(ll x){
  if(fc[x]==0) fc[x]=mlt(x,fct(x-1));
  return fc[x];
}

int main(){
  ll a,b;
  cin>>a>>b;
  cout<<mlt((abs(a-b)<2)*(1+(a==b)),fct(a)*fct(b))<<endl;;
}

Measured memory_bytes: 2560
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M = map(int, readline().split())
H = [0] + list(map(int, readline().split()))
A = [0]*(N+1)

m = map(int, read().split())
for a,b in zip(m,m):
	for _ in range(2):
		A[a] = max(A[a], H[b])
		a,b = b,a

print(sum(x>y for x,y in zip(H, A)))

Measured memory_bytes: 25956
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
using namespace std;

#define A_MAX 100000

typedef struct _tree {
    int parent;
    int sibling;
    int left;
    int right;
    int degree;
    int depth;
    int height;
} Tree;

int calc_depth(Tree *nodes, int i, int depth) {
    int depth_l = 0;
    int depth_r = 0;
    nodes[i].depth = depth;
    if (nodes[i].left != -1) {
        depth_l = calc_depth(nodes, nodes[i].left, depth+1);
    }
    if (nodes[i].right != -1) {
        depth_r = calc_depth(nodes, nodes[i].right, depth+1);
    }
    int deeper = (depth_l > depth_r) ? depth_l : depth_r;
    deeper = (depth > deeper) ? depth : deeper;
    nodes[i].height = (deeper > 0) ? deeper - depth : 0;
    
    return deeper;
}
    

int main() {
    int n;
    Tree nodes[A_MAX];

    cin >> n;

    for (int i = 0; i < n; i++) {
        nodes[i].parent = -1;
        nodes[i].sibling = -1;
        nodes[i].left = -1;
        nodes[i].right = -1;
        nodes[i].degree = 0;
        nodes[i].depth = 0;
        nodes[i].height = 0;
    }

    
    // input
    for (int i = 0; i < n; i++) {
        int id, left, right;
        cin >> id >> left >> right;
        nodes[id].left = left;
        nodes[id].right = right;
        if (left != -1) {
            nodes[left].parent = id;
            nodes[left].sibling = right;
            nodes[id].degree++;
        }
        if (right != -1) {
            nodes[right].parent = id;
            nodes[right].sibling = left;
            nodes[id].degree++;
        }
    }

    // search root
    int root;
    for (int i = 0; i < n; i++) {
        if (nodes[i].parent == -1)  {
            root = i;
            break;
        }
    }

    // calc depth and print
    calc_depth(nodes, root, 0);

    // print
    for (int i = 0; i < n; i++) {
        printf("node %d: ", i);
        printf("parent = %d, ", nodes[i].parent);
        printf("sibling = %d, ", nodes[i].sibling);
        printf("degree = %d, ", nodes[i].degree);
        printf("depth = %d, ", nodes[i].depth);
        printf("height = %d, ", nodes[i].height);
        if (i == root) {
            printf("root\n");
        } else if (nodes[i].height == 0) {
            printf("leaf\n");
        } else {
            printf("internal node\n");
        }

    }

    return 0;
}



Measured memory_bytes: 3240
n = int(input())
a = list(map(int, input().split()))
a.sort()

ans = 1
f = True
if a[0] == 0:
    print(0)
    f = False
else:
    for aa in a[::-1]:
        ans*=aa
        if ans > 10**18:
            print(-1)
            f = False
            break
if f:
    print(ans)

Measured memory_bytes: 21792
while True:
    n, m = map(int, input().split())
    if n == 0 and m == 0:
        exit()
    A = list(map(int, input().split()))
    ans = 0
    for i in range(n - 1):
        for j in range(i + 1, n):
            if ans < A[i] + A[j] <= m:
                ans = A[i] + A[j]
    print(ans if ans != 0 else 'NONE')


Measured memory_bytes: 5628
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Object o = run();
        if (o != null)
            System.out.println(o);
    }

    static Object run() {
        try (Scanner sc = new Scanner(System.in)) {
            int k = sc.nextInt();
            ArrayList<Character> c = new ArrayList<>();
            boolean fastReturn = true;
            for (char ch : sc.next().toCharArray()) {
                if (ch == 'R') fastReturn = false;
                c.add(ch);
            }
            if (fastReturn) return 0;

            int currentR = k - 1, currentW = 0;
            for (int count = 0;;count++) {
                for (; currentR >= 0; currentR--) {
                    if (c.get(currentR) == 'R') {
                        currentR--;
                        break;
                    }
                }
                for (; currentW < k; currentW++) {
                    if (currentW > currentR) return count;
                    if (c.get(currentW) == 'W') {
                        currentW++;
                        break;
                    }
                }
            }
        }
    }
}

class ChenNumberUtil {
    static Collection<Integer> getDivisors(int n) {
        ArrayList<Integer> al = new ArrayList<>();
        for (int i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                al.add(i);
                if (n / i != i)
                    al.add(n / i);
            }
        }
        Collections.sort(al);
        return al;
    }
}

class ChenBitUtil {
    static int popCount(int bit) {
        return Integer.bitCount(bit);
    }

    static boolean isFlag(int bit, int i) {
        return 0 != (bit & (1 << i));
    }

    static int setTrue(int bit, int i) {
        return bit |= (1 << i);
    }

    static int setFalse(int bit, int i) {
        return bit &= ~(1 << i);
    }

    static int setReverse(int bit, int i) {
        return isFlag(bit, i) ? setFalse(bit, i) : setTrue(bit, i);
    }

    static int reverseAll(int bit) {
        return ~bit;
    }
}


Measured memory_bytes: 34908
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * 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; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));

signed main() {
	int N, K;
	cin >> N >> K;
	vector<int>A(N);
	rep(i, N)cin >> A[i];
	rep(i, N)A[i]--;
	vector<bool>seen(N, false);
	int now = 0;
	seen[0] = true;
	vector<int>loop;
	loop.push_back(0);
	int num;
	while (1) {
		int next = A[now];
		if (seen[next]) {
			num = next;
			break;
		}
		loop.push_back(next);
		seen[next] = true;
		now = next;
	}
	vector<int>v;
	rep(i, loop.size()) {
		if (loop[i] == num) {
			while (i < (int)loop.size()) {
				v.push_back(loop[i]);
				i++;
			}
		}
	}
	vector<int>tmp;
	rep(i, loop.size()) {
		if (loop[i] == num)break;
		tmp.push_back(loop[i]);
	}
	tmp.push_back(num);
	if ((int)tmp.size() - 1 >= K) {
		cout << tmp[K] + 1;
		return 0;
	}
	K -= tmp.size() - 1;
	int len = v.size();
	int ans = K % len;
	cout << v[ans] + 1 << endl;
}

Measured memory_bytes: 9516
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  int n;cin>>n;
  long double a[100],ans=0;
  rep(i,n)cin>>a[i];
  sort(a,a+n,greater<long double>());
  
  rep(i,n){
    int k=i+1;
    if(i==n-1)k=n-1;
    rep(j,k){
      a[i]=a[i]/2;
    }
    ans+=a[i];
  }
  cout<<setprecision(15)<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<chrono>
using namespace std;
#define ff first
#define pb push_back
#define ss second
#define ll long long
#define MAX 5000
#define mpi map<int, int>
#define mpll map<ll, ll>
#define pll pair<ll, ll>
#define plld pair<ll, double>
#define SKILLER ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define vi std::vector<int>
#define vll std::vector<ll>
#define vs std::vector<string>
#define vvi std::vector<std::vector<int>>
#define vvll std::vector<std::vector<ll>>
#define all(v) v.begin(), v.end()
#define loop(i, a, b) for(int i = a; i < b; i++)
const int Maxn = 1e5+1, Mod = 1e9 + 7;
int main(){
    SKILLER;
 
           
         float d = 3.1415926535;
      //   d/=7;
         ll n; cin >> n;
         d = 2*d*n;
         cout << fixed << setprecision(10) << d;
    return 0;
}

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

string A, B; int N, cnt; vector<int>X[2009];

int solve(int L, int R) {
	vector<pair<int, int>>D; cnt = 0;
	int G = 0; if (L < 0) G = L; else G = R;
	for (int i = 0; i < N; i++) {
		if (A[i] == B[(i + G + N) % N]) continue;
		cnt++;
		int pos1 = lower_bound(X[i].begin(), X[i].end(), L) - X[i].begin();
		if (X[i][pos1] <= R) continue;
		pos1--;
		int pos2 = lower_bound(X[i].begin(), X[i].end(), R) - X[i].begin();
		D.push_back(make_pair(X[i][pos1] - L, X[i][pos2] - R));
	}
	sort(D.begin(), D.end());
	int maxn = 0, rem = 100000000; if (D.size() == 0) rem = 0;
	for (int i = 0; i < D.size(); i++) {
		int Z1 = maxn, Z2 = -D[i].first;
		rem = min(rem, (Z1 + Z2) * 2);
		maxn = max(maxn, D[i].second);
	}
	rem = min(rem, maxn * 2);
	int score = rem + cnt + (R - L);
	return score;
}

int main() {
	cin >> A >> B; N = A.size();
	for (int i = 0; i < N; i++) {
		for (int j = -2 * N; j <= 3 * N; j++) {
			int V = (j + 3 * N) % N;
			if (B[V] == '1') X[i].push_back(j - i);
		}
	}
	if (X[0].size() == 0) {
		string V = A;
		for (int i = 0; i <= V.size(); i++) {
			string VV = V[V.size() - 1] + V.substr(0, V.size() - 1);
			if (V == B) { cout << min(i, N - i) << endl; return 0; }
			V = VV;
		}
		cout << "-1" << endl;
		return 0;
	}
	int ret = 100000009;
	for (int i = -N; i <= N; i++) {
		int C = 0;
		if (i <= 0) C = solve(i, 0);
		else C = solve(0, i);
		ret = min(ret, C);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 86528
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    string s;
    cin >> s;
    int l = 0, r = N - 1;
    int ans = 0;
    while(l < r) {
        if(s[l] == 'R') {
            l++;
            continue;
        }
        if(s[r] == 'W') {
            r--;
            continue;
        }
        if(s[l] == 'W' && s[r] == 'R') {
            ans++;
            l++;
            r--;
        }
        
    }
    output(ans);
    return 0;
}


Measured memory_bytes: 3772
using System;

namespace abc044_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int K = int.Parse(Console.ReadLine());
            int X = int.Parse(Console.ReadLine());
            int Y = int.Parse(Console.ReadLine());
            int output = 0;
            if (K < N)
            {
                for (int i = 0; i < K; i++)
                {
                    output += X;
                }
                for (int i = K; i < N; i++)
                {
                    output += Y;
                }
            }
            else
            {
                for (int i = 0; i < N; i++)
                {
                    output += X;
                }
            }
            Console.WriteLine(output);
            Console.ReadLine();
        }
    }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using llint = long long;
using vint = vector<int>;
using vvint = vector<vector <int>>;
const int INF = 1e9;
const llint llINF = 1e18;

int main () {
    int n, m; cin >> n >> m;
    if (n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
class Counting():
    def __init__(self,maxim,mod):
        maxim += 1

        self.mod = mod
        self.fact = [0]*maxim
        self.fact[0] = 1
        for i in range(1,maxim):
            self.fact[i] = self.fact[i-1] * i % mod

        self.invfact = [0]*maxim
        self.invfact[maxim-1] = pow(self.fact[maxim-1],mod-2,mod)
        for i in reversed(range(maxim-1)):
            self.invfact[i] = self.invfact[i+1] * (i+1) % mod
        


    def nCk(self,n,r):
        if n < 0 or n < r: return 0
        return self.fact[n] * self.invfact[r] * self.invfact[n-r] % self.mod

    def nPk(self,n,r):
        if n < 0 or n < r: return 0
        return self.fact[n] * self.invfact[n-r] % self.mod

def main():
    S=ii()
    MOD = 10**9+7

    k = 1
    ans = 0
    C = Counting(10**6,MOD)
    while S-3*k >= 0:
        ans += C.nCk(S-2*k-1,k-1)
        ans %= MOD
        k += 1
    
    print(ans%MOD)



if __name__ == "__main__":
    main()

Measured memory_bytes: 83216
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL N; cin >> N;
		multiset<UL> A; rep(i, N) { UL a; cin >> a; A.insert(a); }
		UL ans = 0;
		while (A.size()) {
			UL p = *(--A.end()); A.erase(--A.end());
			UL q = 1; while (q <= p) q <<= 1; q -= p;
			auto i = A.find(q);
			if (i == A.end()) continue;
			ans++;
			//cout << p << " " << q << endl;
			A.erase(i);
		}
		cout << ans << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    char ch;
    int re = 0, ro = 0;
    int a, b, c;
    while (cin >> a >> ch >> b >> ch >> c) {
        if (a * a + b * b == c * c) {
            re++;
        }
        if (a == b) {
            ro++;
        }
    }
    cout << re << endl;
    cout << ro << endl;
}


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

namespace CsharpProgramTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var s = input[0] + input[1];
            var a = int.Parse(s);
            var sqr = (int)Math.Sqrt(a);
            var ans = sqr*sqr == a ? "Yes": "No";

            Console.WriteLine(ans);
        }
    }
}

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

int main(){
    using namespace std;
    string a, b, c;
    cin >> a >> b >> c;
    long L = a.size(), M = b.size(), N = c.size();
    const auto& dif = [](const string& a, long i, const string& b, long j) -> char {
        if(i < 0 || i >= static_cast<long>(a.size()) || a[i] == '?')return false;
        if(j < 0 || j >= static_cast<long>(b.size()) || b[j] == '?')return false;
        return a[i] != b[j];
    };
    vector<long> ab, bc;
    vector<unsigned long> ac(L + N + 2 * M + 1UL);
    for(long i{-M - N}; i <= L + N; ++i)if([&]{ for(unsigned long j{0}; j < M; ++j)if(dif(a, i + j, b, j))return false;return true; }())ab.push_back(i);
    for(long i{-N - L}; i <= M + L; ++i)if([&]{ for(unsigned long j{0}; j < N; ++j)if(dif(b, i + j, c, j))return false;return true; }())bc.push_back(i);
    for(long i{-N - M}; i <= L + M; ++i)ac[i + N + M] = [&]{ for(unsigned long j{0}; j < N; ++j)if(dif(a, i + j, c, j))return 0UL;return 1UL; }();
    unsigned long ans{numeric_limits<unsigned long>::max()};
    for(const auto& i : ab)for(const auto& j : bc)if(i + j + N + M >= 0 && i + j <= L + M && ac[i + j + N + M])ans = min(ans, 0UL + max({L, i + M, i + j + N}) - min({0L, i, i + j}));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
/*
* Author. Silviase(@silviasetitech)
* For AtCoder
*/

import java.util.*;
import java.lang.*;
import java.math.*;


public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int[] ar = new int[3];
        for (int i = 0; i < 3; i++) {
            ar[i] = sc.nextInt();
        }
        Arrays.sort(ar);
        System.out.println(ar[0]*ar[1]/2);
        sc.close();
    }
}

Measured memory_bytes: 22868
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;

#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)

const int N = 1000000;
int dt[40];
bool prime[N];
bool dp[N];

int main(void){
	int n, x,lm;
	rep(i,N){
		prime[i]=true;
	}
	for(int i=2;i<N;i++){
		for(int j=i*2;j<N;j+=i){
			prime[j]=false;
		}
	}

	while(cin>>n>>lm,n||lm){
		bool find = false;
		rep(i,N){
			dp[i]=false;
		}
		dp[0] = 1;
		loop(i,0,n){
			cin>>dt[i];
			rep(j,lm){
				if(j + dt[i] > lm)continue;
				dp[j + dt[i]] |= dp[j];
			}
			
		}
		//rep(i,sizeof(okapon))if(okapon[i])cout<<i<<endl;
		for(int i = lm ; i >= 0 ; i --){
			if(i==1){cout<<"NA"<<endl;break;}
			if(dp[i] && prime[i]){cout<<i<<endl;break;}
		}
	}
}

Measured memory_bytes: 3116
# https://atcoder.jp/contests/abc135/tasks/abc135_c

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
l = A[0]
for i in range(N):
    r = A[i + 1]
    cur = B[i]
    # print(l, r, cur)
    # ans += min(l + r, cur)
    # l = max(r - max(cur - l, 0), 0)  # めちゃくちゃ整理するとこの形の式になる

    # わかりやすくかきなおす
    ans += min(l, cur)
    rest_power = max(cur - l, 0)
    ans += min(rest_power, r)
    l = max(r - rest_power, 0)  # next l

print(ans)


Measured memory_bytes: 18476
N,K = map(int,input().split(' '))
A = list(map(int,input().split(' ')))
MOD = 10**9 + 7

inv2 = pow(2,MOD-2,MOD)

right = 0
left = 0
for i in range(N):
	for j in range(i+1,N):
		if A[i] < A[j]:
			right += 1
		elif A[j] < A[i]:
			left += 1

M1 = (((K*(K-1) % MOD)*inv2) % MOD) + K
M2 = ((K*(K-1) % MOD) * inv2) % MOD

ans = (M1*left + M2 * right) % MOD
print(ans)



Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef unsigned long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

struct less_key {
    bool operator()(const std::pair<i64,i64> &left, const std::pair<i64,i64> &right) {
        return left.first < right.first;
    }
};

const i64 MAXN = 300005;

i64 n, m;

i64 a[MAXN];

i64 gcd (i64 a, i64 b) {
    return b ? gcd (b, a % b) : a;
}

i64 nok(i64 a, i64 b) {
    i64 g = gcd(a, b);
    return a / g * b;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> n >> m;

    for (i64 i = 0; i < n; i++) {
        cin >> a[i];
    }

    for (i64 i = 0; i < n; i++) {
        if (a[i] % 2 == 1) {
            cout << 0 << endl;
            return 0;
        }
    }

    i64 g = a[0];

    for (i64 i = 0; i < n; i++) {
        g = gcd(g, a[i]);
    }

    if (g % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }

    for (i64 i = 0; i < n; i++) {
        if (a[i] / g % 2 == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    i64 k = 1;
    for (i64 i = 0; i < n; i++) {
        k = nok(k, a[i]);
        if (k > 2 * m) {
            cout << 0 << endl;
            return 0;
        }
    }

    k /= 2;
    i64 t = m / k;
    i64 r = t / 2 + t % 2;
    cout << r << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
  int x,a,b,i=0;
  scanf("%d",&x);
  scanf("%d",&a);
  scanf("%d",&b);
  x=x-a;
  while(x>=b){
    x=x-b;
    i++;
  }
  printf("%d",x);
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();

        int cnt = 0;
        if(s.contains("ABC")) {
            for(int i=0; i<s.length(); i++) {
                if(s.charAt(i) == 'A') {
                    if(i+1 < s.length() && s.charAt(i+1) == 'B') {
                        if(i+2 < s.length() && s.charAt(i+2) == 'C') {
                            cnt++;
                        }
                    }
                }
            }
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 35856
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

int main(){
    ll n, c; cin >> n >> c;
    map<ll, vpl> m;
    REP(i, n){
        ll s, t, c; cin >> s >> t >> c;
        m[c].pb(PL(s,t));
    }
    
    map<ll, map<ll, ll>> mn;
    FORMAP(it, m){
        if(it->ss.size() == 0) continue;
        auto tasks = it->ss;
        sort(tasks.begin(), tasks.end(), p_comp_fs);
        map<ll, ll> nt; nt.emplace(tasks[0].ff, tasks[0].ss);
        for(auto t : tasks){
            auto nt_last = nt.rbegin();
            if(nt_last->ss == t.ff){
                nt[nt_last->ff] = t.ss;
            }
            else{
                nt[t.ff] = t.ss;
            }
        }
        nt[-1] = -1;
        nt[1e6] = 1e6;
        mn[it->ff] = nt;
    }
    
    ll ans = 0;
    REP(t, 1e5+10){
        ll cnt = 0;
        FORMAP(it, mn){
            auto t_it = it->ss.upper_bound(t);
            t_it--;
            if(t_it->ff <= t && t <= t_it->ss) cnt++;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endstr;
    return 0;
}


Measured memory_bytes: 8832
#include <algorithm>
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

void check(bool *R, bool *G, bool *B, char c) {
  switch (c) {
    case 'R':
      *R = true;
      break;
    case 'G':
      *G = true;
      break;
    case 'B':
      *B = true;
      break;
  }
}

int main() {
  int n;
  string s;
  cin >> n;
  cin >> s;
  long long r, g, b;
  r = g = b = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R')
      r++;
    else if (s[i] == 'G')
      g++;
    else if (s[i] == 'B')
      b++;
  }
  long long ans = r * g * b;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int k = 2 * j - i;
      if (k >= n) continue;
      bool R, G, B;
      R = false;
      G = false;
      B = false;
      check(&R, &G, &B, s[i]);
      check(&R, &G, &B, s[j]);
      check(&R, &G, &B, s[k]);
      if (R && G && B) ans--;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divCeil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

int main()
{
  ll N;
  cin >> N;
  vector<double> A(N);
  for (ll i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }

  double ans = 0;
  for (ll i = 0; i < N; i++)
  {
    ans += 1.0 / A.at(i);
  }
  ans = 1.0 / ans;

  cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{

    auto check = [](int p, int q) {
        const auto squareNorm = p * p + q * q;
        for (int n = 0;; ++n) {
            if (n * n > squareNorm) {
                break;
            }
            for (int m = 0; m <= n; ++m) {
                if (m * m > squareNorm) {
                    break;
                }
                if (n * n + m * m <= 0) {
                    continue;
                }
                auto f = [p, q](int n_, int m_) {
                    // clang-format off
                    if ((n_ ==  1 && m_ ==  0) ||
                        (n_ ==  0 && m_ ==  1) ||
                        (n_ == -1 && m_ ==  0) ||
                        (n_ ==  0 && m_ == -1) ||
                        (n_ ==  p && m_ ==  q) ||
                        (n_ == -q && m_ ==  p) ||
                        (n_ == -p && m_ == -q) ||
                        (n_ ==  q && m_ == -p)) {
                        return false;
                    }
                    // clang-format on
                    return (n_ * p + m_ * q) % (n_ * n_ + m_ * m_) == 0 &&
                           (n_ * q - m_ * p) % (n_ * n_ + m_ * m_) == 0;
                };
                if (f(n, m) || f(n, -m) || f(-n, m) || f(-n, -m) || f(m, n) ||
                    f(m, -n) || f(-m, n) || f(-m, -n)) {
                    return false;
                }
            }
        }
        return true;
    };

    int N;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        int n, m;
        cin >> n >> m;
        cout << (check(n, m) ? 'P' : 'C') << endl;
    }
}


Measured memory_bytes: 2968
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define ll long long
#define rep(i,l,r)for(int i=(l);i<(r);i++)
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007

//辺の情報を個別に持つタイプ
typedef struct edge{ll s,g,c;}E;
typedef struct graph{
	int vcnt,ecnt;
	E  e[2000010];//適宜変える(ecnt)
	int id[250010];//適宜変える(vcnt)
}G;
G g;

int esort(const void*a,const void*b){
	E*p=(E*)a,*q=(E*)b;
	if((*p).s<(*q).s)return -1;
	if((*p).s>(*q).s)return  1;
	if((*p).g<(*q).g)return -1;
	return 1;
}

ll n,m;
int d4[]={0,1,0,-1,0};
#define in(i,j)(0<=i&&i<n&&0<=j&&j<m)
void readgraph(){
	//適宜変える
	scanf("%lld%lld",&n,&m);
	ll e=0;
	rep(i,0,n)rep(j,0,m){
		rep(k,0,4){
			int ii=i+d4[k];
			int jj=j+d4[k+1];
			if(in(ii,jj)){
				g.e[e].s= i*m+ j;
				g.e[e].g=ii*m+jj;
				g.e[e].c=1;
				e++;
			}
		}
		g.e[e].s= i*m+ j;
		g.e[e].g= 0*m+ j;
		g.e[e].c=1;
		e++;
		g.e[e].s= i*m+ j;
		g.e[e].g= i*m+ 0;
		g.e[e].c=1;
		e++;
		g.e[e].s= i*m+ j;
		g.e[e].g=(n-1)*m+j;
		g.e[e].c=1;
		e++;
		g.e[e].s= i*m+ j;
		g.e[e].g= i*m+(m-1);
		g.e[e].c=1;
		e++;
	}
	g.vcnt=n*m;
	g.ecnt=e;
	
	qsort(g.e,g.ecnt,sizeof(E),esort);
//	qsort(g.e,g.ecnt,sizeof(E),csort);
//	makeinvedge();

	int p=0;
	rep(i,0,g.vcnt){
		while(p<g.ecnt&&g.e[p].s<i)p++;
		g.id[i]=p;
	}
	g.id[g.vcnt]=g.ecnt;//番兵
}


//プラキュー（二分ヒープ）（優先度変更ありバージョン）
ll heapN,heap[1<<20],heapinv[1<<20];
int PQhikaku(int i,int j);//jの方が優先度が高いならtrueを返す
void PQchange(int n);
void heap_utod(int n){
	if(2*n>heapN)return;
	int rflag=(2*n+1<=heapN)&&(PQhikaku(2*n,2*n+1));
	if(PQhikaku(n,2*n+rflag)){
		ll temp=heap[2*n+rflag];
		heap[2*n+rflag]=heap[n];
		heap[n]=temp;
		heapinv[heap[n]]=n;
		heapinv[heap[2*n+rflag]]=2*n+rflag;	
		heap_utod(2*n+rflag);
	}
}
void heap_dtou(int n){
	if(n==1||PQhikaku(n,n/2))return;
	ll temp=heap[n];
	heap[n]=heap[n/2];
	heap[n/2]=temp;
	heapinv[heap[n]]=n;
	heapinv[heap[n/2]]=n/2;
	heap_dtou(n/2);
}
ll PQpop(){
	ll rr=heap[1];
	heapinv[heap[1]]=0;
	heap[1]=heap[heapN--];
	heapinv[heap[1]]=1;
	heap_utod(1);
	return rr;
}
void PQpush(ll n){
	heap[++heapN]=n;
	heapinv[heap[heapN]]=heapN;
	heap_dtou(heapN);
}

//早い方のダイクストラ
//グラフと始点を引いて各点への最短距離・最短経路を返す
//プラキューが必要
//O((E+V)logV)
ll daikusutorappp[1<<20];
ll daikusutoracnt[1<<20];
void daikusutora2(ll s){
	rep(i,0,g.vcnt){
		daikusutorappp[i]=i==s?0:INF;
		daikusutoracnt[i]=i==s?1:0;
	}
	rep(i,0,g.vcnt)PQpush(i);
	while(heapN){
		ll mv=PQpop();
		for(ll t=g.id[mv];t<g.ecnt&&g.e[t].s==mv;t++){
			if(daikusutorappp[g.e[t].g]==daikusutorappp[mv]+g.e[t].c){
				daikusutoracnt[g.e[t].g]+=daikusutoracnt[mv];
				daikusutoracnt[g.e[t].g]%=MOD;
			}else if(daikusutorappp[g.e[t].g]>daikusutorappp[mv]+g.e[t].c){
				daikusutorappp[g.e[t].g]=daikusutorappp[mv]+g.e[t].c;
				daikusutoracnt[g.e[t].g]=daikusutoracnt[mv];
				PQchange(g.e[t].g);
			}
		}
	}
}
int PQhikaku(int i,int j){return daikusutorappp[heap[i]]>daikusutorappp[heap[j]];}
void PQchange(int n){if(heapinv[n])heap_dtou(heapinv[n]);}

int main(){
	readgraph();
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	daikusutora2(a*m+b);
	printf("%d %d\n",daikusutorappp[c*m+d],daikusutoracnt[c*m+d]);
}


Measured memory_bytes: 52788
import sys
K = int(input())
if K == 0:
    print('2')
    print('0 0')
    sys.exit(0)
elif K == 1:
    print('2')
    print('2 0')
    sys.exit(0)
N = min((50, K))
nK = K // N
remain = K % N
a = []
for i in range(N):
    a.append(N-1+nK)
    if i + 1 <= remain:
        a[-1] += N - (remain - 1)
    else:
        a[-1] += -remain
print(N)
print(' '.join(map(str, a)))


Measured memory_bytes: 3064
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import Control.Monad
import Control.Monad.ST
-- import Data.Array.ST
-- import Data.Array.Unboxed
import Data.Vector.Unboxed (create, (!), Vector)
import qualified Data.Vector.Unboxed.Mutable as VM
import Data.Bits

main = putStrLn . show . solve =<< parse

parse :: IO (Int, Int, Int, Int)
parse = (\[h, w, a, b] -> (h, w, a, b)) . map read . words <$> getLine

solve :: (Int, Int, Int, Int) -> Int
solve (h, w, a, b) = foldl add 0 $ map intrude [b .. w - 1] where
    fact = newFact $ h + w
    inv = newInv fact $ max h w
    ways x y = (fact ! (x + y)) `mul` (inv ! x) `mul` (inv ! y)
    intrude i = (ways (h - a - 1) i) `mul` (ways (a - 1) (w - i - 1))


-- newFact :: Int -> UArray Int Int
-- newFact n = runSTUArray $ do
--     fact <- newArray_ (0, n) :: ST s (STUArray s Int Int)
--     writeArray fact 0 1
--     forM_ [1 .. n] $ \i -> do
--         n <- readArray fact $ i - 1
--         writeArray fact i $ mul n i
--     return fact
newFact :: Int -> Vector Int
newFact n = create $ do
    fact <- VM.new $ n + 1
    VM.unsafeWrite fact 0 1
    forM_ [1 .. n] $ \i -> do
        n <- VM.unsafeRead fact $ i - 1
        VM.unsafeWrite fact i $ mul n i
    return fact

-- newInv :: UArray Int Int -> Int -> UArray Int Int
-- newInv fact n = runSTUArray $ do
--     inv <- newArray_ (0, n) :: ST s (STUArray s Int Int)
--     writeArray inv 0 1 -- XXX
--     writeArray inv 1 1 -- XXX
--     writeArray inv n $ pow (fact ! n) (modulo - 2)
--     forM_ [n - 1, n - 2 .. 2] $ \i -> do
--         x <- readArray inv $ i + 1
--         writeArray inv i $ mul x (i + 1)
--     return inv
newInv :: Vector Int -> Int -> Vector Int
newInv fact n = create $ do
    inv <- VM.new $ n + 1
    VM.unsafeWrite inv 0 1 -- XXX
    VM.unsafeWrite inv 1 1 -- XXX
    VM.unsafeWrite inv n $ pow (fact ! n) (modulo - 2)
    forM_ [n - 1, n - 2 .. 2] $ \i -> do
        x <- VM.unsafeRead inv $ i + 1
        VM.unsafeWrite inv i $ mul x (i + 1)
    return inv

add :: Int -> Int -> Int
add n m = (n + m) `mod` modulo

mul :: Int -> Int -> Int
mul n m = mul' (n `mod` modulo) m 0
mul' n m res
    | m <= 0 = res
    | m .&. 1 == 1 = mul' (shiftL n 1 `mod` modulo) (shiftR m 1) (add res n)
    | otherwise = mul' (shiftL n 1 `mod` modulo) (shiftR m 1) res

pow :: Int -> Int -> Int
pow _ 0 = 1
pow n m
    | m .&. 1 == 0 = mul x x
    | otherwise = mul n . pow n $ m - 1 where
          x = pow n $ m `div` 2

modulo :: Int
modulo = 10 ^ 9 + 7

Measured memory_bytes: 18812
#include <iostream>
#include <string>
#include <string_view>

int main() {
  int K;
  std::string S;
  std::cin >> K >> S;

  if (S.size() <= K) {
    std::cout << S << '\n';
  } else {
    std::cout << std::string_view{S}.substr(0, K) << "...\n";
  }
}


Measured memory_bytes: 3620
K=int(input())
A,B=(input().split())
A=int(A)
B=int(B)

s=range(A,B+1)   
for n in range(1,1000):  
        if K*n in s:
            print("OK")
            break
        if K==1:
            print("OK")
            break
else:
    print("NG")
        

Measured memory_bytes: 9080
// https://atcoder.jp/contests/dp/tasks/dp_a

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

int main(){
    int n;
    cin>>n;
    vector<int> v(n,0);
    for(int i=0;i<n;i++) cin>>v[i];
    vector<int> cost(n,INT_MAX);
    cost[0] = 0;
    for(int i=1;i<n;i++){
        cost[i] = min((i-1)>=0 ? cost[i-1] + abs(v[i] - v[i-1]) : INT_MAX, (i-2)>=0 ? cost[i-2] + abs(v[i] - v[i-2]) : INT_MAX);
    }
    cout<<cost[n-1]<<"\n";
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

#define MOD 1e9+7

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

ll factorial(ll n);
void rfactorial(ll n);
ll binary_square(ll x, ll n);

vector<ll> fact(2e5+1, -1), rfact;

int main() {
    ll n , a ,b;
    cin >> n>> a >> b;
    ll x = factorial(b+1);
    rfactorial(b+1);
    ll ans=lldiv(binary_square(2, n) - 1, MOD).rem;
    //cout << ans << endl;
    ll chi=1;
    rep2(i, 1, a+1){
        chi = lldiv(chi * (n - i + 1), MOD).rem;
        //par = lldiv(par * i, MOD).rem;
        // if(i!=a&i!=b){
        //     ans += lldiv(lldiv(x * rfact[i], MOD).rem * rfact[n - i], MOD).rem;
        // }
    }
    // cout << ans << " " << lldiv(chi * rfact[a], MOD).rem  << endl;
    ans = lldiv(ans - lldiv(chi * rfact[a], MOD).rem, MOD).rem;
    if(ans<0){
        ans += MOD;
    }
    // cout << ans << endl;
    rep2(i, a+1, b+1){
        chi = lldiv(chi * (n - i + 1), MOD).rem;
    }
    ans = lldiv(ans - lldiv(chi * rfact[b], MOD).rem, MOD).rem;
    if (ans < 0) {
      ans += MOD;
    }
    cout << ans << endl;
    return 0;
}

ll factorial(ll n) {
  if (n == 0) {
    return 1;
  } else {
    if (fact[n - 1] == -1) {
      fact[n - 1] = factorial(n - 1);
    }
    fact[n] = lldiv(n * fact[n - 1], MOD).rem;
    return fact[n];
  }
}

void rfactorial(ll n) {
  rep(i, n) { rfact.push_back(binary_square(fact[i], MOD - 2)); }
}

ll binary_square(ll x, ll n) {
  ll m = MOD;
  ll ans = 1;
  while (n) {
    if (n % 2 == 1) {
      ans = ans * x % m;
    }
    x = x * x % m;
    n >>= 1;
  }
  return ans % m;
}

Measured memory_bytes: 16124
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace q2
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Convert.ToInt32(Console.ReadLine());
            var a = n / 500;
            n -= a * 500;
            var b = n / 5;
            Console.WriteLine(a * 1000 + b * 5);
        }
    }
}


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

int main() {
  int n;
  cin >> n;
  if(n==2) {
    cout << -1 << endl;
    return 0;
  }
  int a[n];
  for(int i=0; i<n; i++) a[i]=i+1;
  for(int i=0; i<n; i++) {
    rotate(a,a+1,a+n);
    if(n%2==0&&i>=n/2) swap(a[n/2-1],a[n/2]);
    for(int j=0; j<n-1; j++) {
      if(j) cout << " ";
      cout << a[j];
    }
    cout << endl;
    if(n%2==0&&i>=n/2) swap(a[n/2-1],a[n/2]);
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b;
    char c;
    cin>>a>>b;
    for(int i=0;i<a+b+1;i++){
        cin>>c;
        if(((i<a)||(i>a))&&!isdigit(c)){
            cout<<"No";
            return 0;
        }
        if(i==a&&c!='-'){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";

}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
vector<int>edge[100010];
int x,y,n,m,q,u,d,c;
int color[100010],maxu[100010],U[100010],D[100010],C[100010];
void dfs(int u,int d,int c)
{
 if(color[u]==0)color[u]=c;
 if(d==0)return;
 if(maxu[u]>=d)return;
 maxu[u]=d; 
 for(int i=0;i<edge[u].size();i++)
  {int to=edge[u][i];
   dfs(to,d-1,c);
  }
}
int main()
{
    cin>>n>>m;
	for(int i=1;i<=m;i++)
	 {scanf("%d%d",&x,&y);
	  edge[x].push_back(y);
	  edge[y].push_back(x);
	 }
	cin>>q;
	for(int i=1;i<=q;i++)scanf("%d%d%d",&U[i],&D[i],&C[i]);	
	for(int i=q;i>=1;i--)dfs(U[i],D[i],C[i]);
	for(int i=1;i<=n;i++)printf("%d\n",color[i]);
	return 0;
} 

Measured memory_bytes: 8440
import kotlin.math.*

fun main() {
    println(solve())
}

val solve: () -> Any = {
    val N = readInt()

    val dp = mutableListOf(1L, 0L, 0L, 0L)

    for (n in 0 until N) {
        val (a0, a10, a19, a2) = dp
        dp[0] = (a0 * 8) % mod
        dp[1] = (a0 + a10 * 9) % mod
        dp[2] = (a0 + a19 * 9) % mod
        dp[3] = (a2 * 10 + a10 + a19) % mod
    }
    dp[3]
}

val mod: Int = 1_000_000_007


fun readString() = readLine()!!
fun readStringList() = readLine()!!.split(" ")
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

fun <T> T.alsoPrintln() = also { println(this) }

fun Boolean.toYesOrNo(yes: String = "Yes", no: String = "No") = if (this) yes else no

fun <E> List<E>.toPair() = this[0] to this[1]

fun <T> readPair(t: (String) -> T) = readPair(t, t)
fun <S, T> readPair(s: (String) -> S, t: (String) -> T) =
    readLine()!!.split(" ").let { Pair(s(it[0]), t(it[1])) }

fun Int.pow(n: Int) = this.toDouble().pow(n).toInt()

fun minAndMax(a: Int, b: Int) = if (a < b) a to b else b to a

fun <T> T.ifOrThis(bool: (T) -> Boolean, trans: (T) -> T) = if (bool(this)) trans(this) else this
fun <T> T.ifOrThis(bool: Boolean, trans: (T) -> T) = if (bool) trans(this) else this

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

int main(){
  int L, R, d;
  cin >> L >> R >> d;

  int count = 0;
  for (int i = L; i <= R; ++i){
    if (i % d == 0){
      count++;
    }
  }
  cout << count << endl;

  return 0;
}

Measured memory_bytes: 3620