akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		long MOD = 1000000007;
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++){
		    a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		
		// 計算
		long result = 0;
		long maxSum = 0;
		long minSum = 0;
		Combination c = new Combination(n);
		for(int i = 0; i < n; i++){
		    long now = a[i];
		    maxSum += now*c.combination(i, k-1)%MOD;
		    minSum += now*c.combination(n-(i+1), k-1)%MOD;
		}
		result = maxSum + MOD - minSum;
		result %= MOD;
		
		// 出力
		System.out.println(result);
	}
}

class Combination {
    static final int MOD = 1000000007;
    long[] fact;
    long[] invFact;
    long[] inv;
    
    public Combination (int n) {
        fact = new long[n+1];
        invFact = new long[n+1];
        inv = new long[n+1];
        fact[0] = 1;
        fact[1] = 1;
        invFact[0] = 1;
        invFact[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < n+1; i++) {
            fact[i] = fact[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            invFact[i] = invFact[i - 1] * inv[i] % MOD;
        }
    }
    
    public long combination(int n, int k) {
        if (n < k || n < 0 || k < 0) {
            return 0;
        }
        return fact[n] * (invFact[k] * invFact[n - k] % MOD) % MOD;
    }
}




Measured memory_bytes: 51052
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
import java.lang.Math.*;
public class Main {
    static ArrayList<Node>[][] matches;
    static int [][]count;
    static int [][] cost;
    static LinkedList<Node> queue = new LinkedList<>();
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int n = in.nextInt();
        count = new int[n+1][n+1];
        cost = new int[n+1][n+1];
        matches = new ArrayList[n+1][n+1];
        for(int i=0;i<=n;i++){
            for(int j=0;j<=n;j++)
                matches[i][j] = new ArrayList<Node>();
        }
        for(int i=1;i<=n;i++){
            int next = in.nextInt();
            int pmin = Math.min(i,next);
            int pmax = Math.max(i,next);
            for(int j=1;j<n-1;j++){
                next = in.nextInt();
                int mn = Math.min(i,next);
                int mx = Math.max(i,next);
                count[mn][mx] +=1;
                matches[pmin][pmax].add(new Node(mn,mx));
                pmin = mn;pmax=mx;
            }
        }
        for(int i=1;i<n;i++){
            for(int j=i+1;j<=n;j++) {
                if(matches[i][j].size()>0 && count[i][j]==0){
                    queue.addLast(new Node(i,j));
                }
            }
        }
        while (queue.size()>0){
            Node next = queue.removeFirst();
            for(Node v:matches[next.l][next.h]){
                dfs(v,cost[next.l][next.h]);
            }
        }
        int day =0;
        for(int i=1;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                if(count[i][j]>0){
                    System.out.println(-1);
                    return;
                }
                day=Math.max(day,cost[i][j]);
            }
        }
        System.out.println(day+1);
    }
    static public class Node{
        int l;int h;
        public Node(int a,int b){
            l=a;h=b;
        }
    }
    static void dfs(Node vertice , int v){
        int curCost = 1+v;
        cost[vertice.l][vertice.h]= Math.max(curCost,cost[vertice.l][vertice.h]);
        count[vertice.l][vertice.h]--;
        if (count[vertice.l][vertice.h]==0){
            queue.addLast(vertice);
        }
    }

}

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

using namespace std;

typedef long long ll;

const ll INF = 1LL << 60;

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

    ll N;
    cin >> N;

    vector<ll> X;
    X.resize(N);

    for (ll i = 0; i < N; ++i) {
        cin >> X[i];
    }

    ll L;
    cin >> L;

    vector< vector<ll> > T;
    T.resize(N);

    //
    for (ll i = 0; i < N; ++i) {
        ll j = upper_bound(X.begin(), X.end(), X[i]+L) - X.begin() - 1;

        T[i].resize(20);
        T[i][0] = j;
    }

    for (ll x = 1; x < 20; ++x) {
        for (ll i = 0; i < N; ++i) {
            T[i][x] = T[T[i][x-1]][x-1];
        }
    }

    //
    ll Q;
    cin >> Q;

    while (Q--) {
        ll a;
        ll b;

        cin >> a >> b;
        a--;
        b--;

        if (a > b) {
            swap(a, b);
        }

        ll ans = 0;

        while (true) {
            if (T[a][0] >= b) {
                break;
            }
            for (ll x = 0; x < 19; ++x) {
                if (T[a][x] < b && b <= T[a][x+1]) {
                    ans += pow(2, x);
                    a = T[a][x];
                    break;
                }
            }
        }
        cout << ans+1 << endl;
    }

    return 0;
}


Measured memory_bytes: 21120
N, M = map(int, input().split())
S = input()[::-1]
l = []
p = 0

chk = True
while p<N:
    for i in range(1, min(M, N-p)+1)[::-1]:
        if S[p+i]=="0":
            break
    else:
        print(-1)
        chk = False
        break
    l.append(i)
    p += i

if chk:
    l.reverse()
    print(*l)

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

int main() {
    int n,a,b;
    string s;
    cin >> n >> a >> b;
    cin >> s;
    int countpass = 0;
    int countb = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'c'){
            cout << "No" << endl;
        } else {
            if(s[i] == 'a' && countpass < a+b){
                cout << "Yes" << endl;
                countpass++;
            } else if(s[i] == 'b' && countpass < a+b && countb < b){
                cout << "Yes" << endl;
                countb++;
                countpass++;
            } else {
                cout << "No" << endl;
            }
        }
    }
}

Measured memory_bytes: 896
const Main = () => {
    const line = require('fs').readFileSync('/dev/stdin', 'utf8');
    const lines = line.split('\n');
    const N = parseInt(lines[0], 10);
    const S = {};
    for (let i = 1; i <= N; i++) {
        S[lines[i]] = true;
    }
    const count = Object.keys(S).length;
    console.log(count);
}

Main();

Measured memory_bytes: 83476
#define _CRT_SECURE_NO_WARNINGS

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

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

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

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

#define INF 1e9

typedef long long ll;
int f[100000];

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
ll Max(ll a, ll b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}void hSwap(int x[], int i, int j)
{
	int temp;

	temp = x[i];
	x[i] = x[j];
	x[j] = temp;
}

void ShowData(int x[], int left, int right)
{
	int i;
	for (i = left; i <= right; i++)printf("%d  ", x[i]);
	printf("\n");
}
void QSort(int x[], int left, int right, int n) {
	int i, j;	//左端,右端
	int pivot;	//軸

	i = left;
	j = right;
	pivot = x[(left + right) / 2];

	while (1) {
		if (n > 0) {				//n>0なら昇順、n<=0なら降順
			while ((x[i] < pivot) && (i <= right))i++;	//軸値より大きい要素
			while ((pivot < x[j]) && (i <= right))j--;	//軸値より小さい要素
		}
		else {
			while ((x[i] > pivot) && (i <= right))i++;	//軸値より小さい要素
			while ((pivot > x[j]) && (i <= right))j--;	//軸値より大きい要素
		}
		if (i >= j)	break;
		hSwap(x, i, j);
		i++; j--;
	}
	//ShowData(x, left, right);

	if (left < i - 1)QSort(x, left, i - 1, n);
	if (j + 1 <  right)QSort(x, j + 1, right, n);
}

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

	return gcd(a, b);
}

int main() {
	int n, x;
	scanf("%d%d", &n,&x);
	int y[100000];
	REP(i, n) {
		scanf("%d", &y[i]);
	}
	int ans = abs(x - y[0]);
	//PRINTD(ans);
	REPS(i, n-1) {
		ans = gcd(ans, abs(x-y[i]));
		//PRINTD(ans);
	}
	PRINTD(ans);
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
using namespace std;
int gcd(int a,int b)
{
	if(a<b)
		{
			int temp;
			temp=b;
			b=a;
			a=temp;
		}
	if(a%b==0)
		return b;
	return gcd(b,a%b);
}
int lcm(int a,int b)
{
	int gcd1;
	gcd1=gcd(a,b);
	return (a/gcd1)*b;
}
int main()
{
	int a,b;
	while(scanf("%d %d",&a,&b)!=EOF)
		{
			cout<<gcd(a,b)<<" "<<lcm(a,b)<<"\n";	
		}
	return 0;
}

Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int n = scan.nextInt();
			int m = scan.nextInt();
			if (n == 0 && m == 0) {
				break;
			}
			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = scan.nextInt();
			}
			int sum = 0;
			for (int i = 0; i < n - 1; i++) {
				for (int j = i + 1; j < n; j++) {
					if (sum < a[i] + a[j] && m >= a[i] + a[j]) {
						sum = a[i] + a[j];
					}
				}
			}
			if (sum == 0) {
				System.out.println("NONE");
			} else {
				System.out.println(sum);
			}
		}
	}
}



Measured memory_bytes: 47288
import fractions
n = int(input())
a = list(map(int, input().split()))

LCM = a[0]
for i in range(1, n):
    LCM = LCM * a[i] // fractions.gcd(LCM, a[i])

ans = 0
for i in range(n):
        ans += (LCM - 1)%a[i]
print(ans)

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

/* → → → → → → → → → → → → → → → → → → → → → → → → → → → →
	→ → → → → → → → → → → → → → → → → → → → → → → → → → → → */

#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define pb push_back
#define endl '\n'

/* → → → → → → → → → → → → → → → → → → → → → → → → → → → →
	→ → → → → → → → → → → → → → → → → → → → → → → → → → → → */

void solve() {
	char s; cin >> s;
	if (isupper(s))
		cout << 'A';
	else
		cout << 'a';
	return ;
}

int32_t main() {

	/* → → → → → → → → → → → → → → → → → → → → → → → → → → → →
	→ → → → → → → → → → → → → → → → → → → → → → → → → → → → */

	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);

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

	/* → → → → → → → → → → → → → → → → → → → → → → → → → → → →
	→ → → → → → → → → → → → → → → → → → → → → → → → → → → → */

	//int t;cin>>t;while(t--)
	solve();

	return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int t[n + 1], total_t = 0;
    for (int i = 1; i <= n; i++) {
        cin >> t[i];
        total_t += t[i];
    }
    int m;
    cin >> m;
    int p, x;
    for (int i = 1; i <= m; i++) {
        cin >> p >> x;
        cout << total_t - t[p] + x << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<stack>
#define FOR(i,a,b) for(int i=(a); i<int(b); ++i)
#define RFOR(i,a,b) for(int i=(b)-1; i>=int(a); --i)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,int(n)+1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
#define al(d) d.begin(),d.end()
using namespace std;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(int n){
	vector<T> vec;
	rep(i,n){
		T input;
		cin >> input;
		vec.emplace_back(input);
	}
	return vec;
}
using AdjList = vector<vector<int>>;
using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

// Recieve edge(=(int,int)) as an adj list.
vector<vector<int>> getadj(int N, int M){
	// Initialize all lists of the graph as a empty vector.
	vector<int> init;
	vector<vector<int>> graph(N,init);

	rep(i,M){
		int a, b;
		cin >> a >> b;
		graph[a-1].emplace_back(b-1);
		graph[b-1].emplace_back(a-1);
	}
// rep(i,N)
// 	putv(graph[i]);
	return graph;
}

#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
using namespace std;

vector<char> vec;
void step(char c);
int main(){
	string s;
	cin >> s;
	int len = s.length();
	rep(i,len)
		step(s[i]);
	for(auto c:vec)
		cout << c;
	cout << endl;
}
void step(char c){
	if(c=='0') vec.emplace_back('0');
	else if(c=='1') vec.emplace_back('1');
	else if(vec.size()==0) return;
	else vec.pop_back();
	// putv(vec);
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(a) (a).begin(),(a).end()
#define SIZE(a) (int)((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using namespace std;

typedef pair<int,int> P;
struct edge {
  int to, cost;
};

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

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " ";
  }
  return s;
}


signed main()
{
  string s; cin >> s;
  int x, y; cin >> x >> y;

  int cnt = 0;
  bool x_updated = false;
  vector<int> X, Y;
  rep(i, 0, SIZE(s)) {
    if (s[i] == 'F') {
      cnt++;
    } else {
      if (x_updated) {
        Y.push_back(cnt);
      } else {
        X.push_back(cnt);
      }
      x_updated = !x_updated;
      cnt = 0;
    }
  }
  if (x_updated) {
    Y.push_back(cnt);
  } else {
    X.push_back(cnt);
  }


  vector< vector<bool> > x_list(2, vector<bool>(2*SIZE(s), false)), y_list(2, vector<bool>(2*SIZE(s), false));
  x_list[1][X[0] +SIZE(s)] = true;
  y_list[0][0 +SIZE(s)] = true;
  rep(i, 1, SIZE(X)) {
    int x_step = X[i];
    fill(ALL(x_list[(i+1) % 2]), false);
    rep(j, 0, 2*SIZE(s)) {
      if (x_list[i % 2][j]) {
        if (j - x_step >= 0) {
          x_list[(i+1) % 2][j - x_step] = true;
        }
        if (j + x_step < 2*SIZE(s)) {
          x_list[(i+1) % 2][j + x_step] = true;
        }
      }
    }
  }
  rep(i, 0, SIZE(Y)) {
    int y_step = Y[i];
    fill(ALL(y_list[(i+1) % 2]), false);
    rep(j, 0, 2*SIZE(s)) {
      if (y_list[i % 2][j]) {
        if (j - y_step >= 0) {
          y_list[(i+1) % 2][j - y_step] = true;
        }
        if (j + y_step < 2*SIZE(s)) {
          y_list[(i+1) % 2][j + y_step] = true;
        }
      }
    }
  }

  if (x_list[SIZE(X) % 2][x +SIZE(s)] && y_list[SIZE(Y) % 2][y +SIZE(s)]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }


  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    string s;
    cin>>s;
    ll n=s.length()+1;
    ll a[n];
    rep(0,i,n)a[i]=0;
    rep(0,i,n-1){
        string s0=s.substr(i,1);
        if(s0=="<"){
            a[i+1]=max(a[i+1],a[i]+1);
        }
    }
    rep(0,i,n){
        ll x=n-1-i;
        string s0=s.substr(x,1);
        if(s0==">"){
            a[x]=max(a[x+1]+1,a[x]);
        }
    }
    ll ans=0;
    rep(0,i,n)ans+=a[i];
    cout<<ans;
}

Measured memory_bytes: 4740
#include<iostream>
#include<vector>
using namespace std;
 
int N, M, Q;
 
vector<vector<int>> sum;
int buildSumTable(vector<int> L, vector<int> R) {
	sum = vector<vector<int>>(N + 1, vector<int>(N + 1, 0));
	for (int i = 0; i < M; i++)
	{
		sum[L[i]][R[i]]++;
	}
 
	for (int i = 1; i <= N; i++)
	{
		for (int j = 1; j <= N; j++)
		{
			sum[i][j] += sum[i - 1][j];
			sum[i][j] += sum[i][j - 1];
			sum[i][j] -= sum[i - 1][j - 1];
		}
	}
}
 
int getSumRange(int L, int R) {
	int ans = sum[R][R] - sum[R][L - 1] - sum[L - 1][R] + sum[L - 1][L - 1];
	return ans;
}
 
int main() {
	cin >> N >> M >> Q;
	vector<int> L(M);
	vector<int> R(M);
	for (int i = 0; i < M; i++)
	{
		cin >> L[i] >> R[i];
	}
	vector<int> p(Q);
	vector<int> q(Q);
	for (int i = 0; i < Q; i++)
	{
		cin >> p[i] >> q[i];
	}
	buildSumTable(L, R);
 
	for (int i = 0; i < Q; i++)
	{
		int ans = getSumRange(p[i], q[i]);
		cout << ans << endl;
	}
}

Measured memory_bytes: 5120
import java.util.Scanner;
public class Main { 
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) { 
        while (true) { 
        int n = sc.nextInt(); 
            if (n == 0) { 
            break; 
            } 
            int[] scores = new int[n]; 
            for (int i = 0; i < scores.length; i++) { 
            scores[i] = sc.nextInt(); 
            } 
            double average = 0, variance = 0;
            for(int i = 0; i < scores.length; i++){ 
                average += scores[i]; 
            } 
            average = average/n; 
            for(int i = 0; i < scores.length; i++){ 
                variance += (scores[i]-average)*(scores[i]-average); 
            }
            variance = variance/n;
            System.out.println(Math.sqrt(variance)); 
            } 
        } 
    }
}


Measured memory_bytes: 31160
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>
//<editor-fold desc="definitions">
#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
#define enl "\n"
using namespace std;
using ll=long long;
using ld=long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using vlll = vector<vector<vector<ll>>>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
ll mod = ll(1e9)+7;
ll inf = ll(1e18);
void bl(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void bl2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) {
            for (auto vvv : vv) cout << vvv << " ";
            cout << endl;
        }
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

dbg::Debug debug;
//</editor-fold>

class ARegistration {
public:
	void solve(std::istream& in, std::ostream& out) {
	    string s, t;
	    in >> s >> t;

	    int n = s.length();
	    bool judge = true;
	    for(int i=0; i<n; i++) {
	        if(s[i] != t[i]) judge = false;
	    }

	    bl(judge, out);
	}
};


int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	ARegistration solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3640
import java.math.*

fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    val a = readInputLine().split(" ").map { it.toLong() }.toLongArray()
    val b = readInputLine().split(" ").map { it.toLong() }.toLongArray()

    var aCnt = 0L
    var bCnt = 0L
    
    for (i in 0..N - 2) {
        if (a[i] % 2 != b[i] % 2) {
            b[i]++
            if (bCnt > 0L) bCnt-- else aCnt++
        }
        if (a[i] > b[i]) {
            val diff = a[i] - b[i]
            aCnt += Math.max(diff - bCnt, 0L)
            bCnt = Math.max(bCnt - diff, 0L)
            b[i] = a[i]
        }
        if (a[i] < b[i]) {
            val diff = (b[i] - a[i]) / 2L
            bCnt += Math.max(diff - aCnt, 0L)
            aCnt = Math.max(aCnt - diff, 0L)
            a[i] = b[i]
        }
    }
    
    a[N - 1] += aCnt * 2L
    b[N - 1] += bCnt
    
    if (b[N - 1] >= a[N - 1] && b[N - 1] - a[N - 1] >= 0L) {
        println("Yes")
    } else {
        println("No")
    }
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 41548
#include <iostream>
#include <vector>
#include <algorithm>
#define int long long

using namespace std;

signed main(){
    int n, sumr=0, sumb=0, sumg=0;
    vector<char> ch;
    cin >> n;
    ch.resize(n);
    for(int i=0;i<n;i++){
        cin >> ch[i];
        if(ch[i]=='R') sumr++;
        if(ch[i]=='B') sumb++;
        if(ch[i]=='G') sumg++;
    } 
    //cout << sumr << endl;
    //cout << sumb << endl;
    //cout << sumg << endl;

    int sum = sumr*sumg*sumb;
    for(int i=1;i<=n/2;i++){
        for(int j=0;j+2*i<n;j++){
            if(ch[j]!=ch[j+i]&&ch[j+2*i]!=ch[j+i]&&ch[j]!=ch[j+2*i]){
                sum=sum-1;
                //cout << "OK" << endl;
            }
        }
    }
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 3628
#include <cstring>
#include <iostream>
#include <cstdio>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#define f first
#define s second
#define mp make_pair

using namespace std;

int n[2], m[2];

struct edge{
  int src;
  int dst;
  string label;

  edge(int s = 0, int d = 0, string l = "") :
    src(s), dst(d), label(l) {}
};

vector<edge> e[2];
vector<vector<int> > re[2];

int memo[600][600];
const int mod = 1000000007;

int solve(int id1, int id2, int l1, int l2){
  if(e[0][id1].dst == n[0] - 1    &&
     e[1][id2].dst == n[1] - 1    &&
     l1 == e[0][id1].label.size() &&
     l2 == e[1][id2].label.size())
    return 1;

  if(l1 == e[0][id1].label.size() &&
     l2 == e[1][id2].label.size() &&
     memo[id1][id2] != -1)
    return memo[id1][id2];
  
  int ret = 0;

  if(l1 == e[0][id1].label.size()){
    int src = e[0][id1].dst;

    REP(i, re[0][src].size()){
      int i1 = re[0][src][i];
      int i2 = id2;
      int ln1 = 0;
      int ln2 = l2;
      const string &s1 = e[0][i1].label;
      const string &s2 = e[1][i2].label;

      while(ln1 < s1.size() && ln2 < s2.size() && s1[ln1] == s2[ln2]){
	ln1++; ln2++;
      }

      if(ln1 == s1.size() || ln2 == s2.size()){
	ret = ((long long)ret + solve(i1, i2, ln1, ln2)) % mod;
      }
    }
  }else if(l2 == e[1][id2].label.size()){
    int src = e[1][id2].dst;

    REP(i, re[1][src].size()){
      int i1 = id1;
      int i2 = re[1][src][i];
      int ln1 = l1;
      int ln2 = 0;
      const string &s1 = e[0][i1].label;
      const string &s2 = e[1][i2].label;

      while(ln1 < s1.size() && ln2 < s2.size() && s1[ln1] == s2[ln2]){
	ln1++; ln2++;
      }

      if(ln1 == s1.size() || ln2 == s2.size()){
	ret = ((long long)ret + solve(i1, i2, ln1, ln2)) % mod;
      }
    }
  }else{
    printf("solve(%d, %d, %d, %d)\n", id1, id2, l1, l2);

    printf("e[0][%d].label: %s\n", id1, e[0][id1].label.c_str());
    printf("e[1][%d].label: %s\n", id2, e[1][id2].label.c_str());

    throw "error";
  }

  if(l1 == e[0][id1].label.size() &&
     l2 == e[1][id2].label.size())
    memo[id1][id2] = ret;

  return ret;
}

int main(){
  int t; cin >> t;
  while(t --> 0){
    REP(i,2){
      cin >> n[i] >> m[i];

      e[i]  = vector<edge>(m[i]);
      re[i] = vector<vector<int> >(n[i]);

      REP(j,m[i]){
	int s, d;
	string l;
	cin >> s >> d >> l;
	e[i][j] = edge(s, d, l);
	re[i][s].push_back(j);
      }
    }

    memset(memo, -1, sizeof(memo));

    int ans = 0;
    REP(i, re[0][0].size()) REP(j, re[1][0].size()){
      int id1 = re[0][0][i];
      int id2 = re[1][0][j];
      int l1 = 0;
      int l2 = 0;
      const string &s1 = e[0][id1].label;
      const string &s2 = e[1][id2].label;

      while(l1 != s1.size() && l2 != s2.size() && s1[l1] == s2[l2]){
	l1++; l2++;
      }

      if(l1 == s1.size() || l2 == s2.size()){
	ans = ((long long)ans + solve(id1, id2, l1, l2)) % mod;
      }
    }

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

  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main()
{
          long int i,j,k,A[10000];
          scanf("%d",&k);
          for(i=0;i<k;i++)
          {
                    scanf("%d",&A[i]);
          }
          for(i=k-1;i>0;i--)
          {
                    printf("%d ",A[i]);
          }
          printf("%d",A[0]);
          printf("\n");
          return 0;
}



Measured memory_bytes: 2748
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		String[] result = new String[10000];
		int index = 0;

		while( n != 0 ){			
			int[][] stone = new int[n][2];
			for(int i = 0; i < n; i++){
				stone[i][0] = stdIn.nextInt();
				stone[i][1] = stdIn.nextInt();
			}
			int m = stdIn.nextInt();
			String[] direction = new String[m];
			int[] distance = new int[m];
			for(int i = 0; i < m; i++){
				direction[i] = stdIn.next();
				distance[i]= stdIn.nextInt();
			}
			int[] now = new int[2];
			now[0] = 10;
			now[1] = 10;
			int count = 0;
			for(int i = 0; i < m; i++){
				if( direction[i].equals("N")){
					for(int j = 1; j <= distance[i]; j++){
						now[1]++;
						for(int k = 0; k < stone.length; k++){
							if( stone[k][0] == now[0] && stone[k][1] == now[1] ){
								stone[k][0] = -1;
								stone[k][1] = -1;
								count++;
							}
						}
					}
				} else if( direction[i].equals("S")){
					for(int j = 1; j <= distance[i]; j++){
						now[1]--;
						for(int k = 0; k < stone.length; k++){
							if( stone[k][0] == now[0] && stone[k][1] == now[1] ){
								stone[k][0] = -1;
								stone[k][1] = -1;
								count++;
							}
						}
					}
				} else if( direction[i].equals("E")){
					for(int j = 1; j <= distance[i]; j++){
						now[0]++;
						for(int k = 0; k < stone.length; k++){
							if( stone[k][0] == now[0] && stone[k][1] == now[1] ){
								stone[k][0] = -1;
								stone[k][1] = -1;
								count++;
							}
						}
					}
				} else if( direction[i].equals("W")){
					for(int j = 1; j <= distance[i]; j++){
						now[0]--;
						for(int k = 0; k < stone.length; k++){
							if( stone[k][0] == now[0] && stone[k][1] == now[1] ){
								stone[k][0] = -1;
								stone[k][1] = -1;
								count++;
							}
						}
					}
				}
				if( count == n ){
					break;
				}
			}
			if( count == n ){
				result[index] = new String("Yes");
			} else {
			 	result[index] = new String("No");
			}
			index++;
			n = stdIn.nextInt();
		}
		for(int i = 0; i < index; i++){
			System.out.println(result[i]);
		}
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int l[n];
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }
    sort(l, l + n, greater<int>());
    cout << (l[0] < accumulate(l + 1, l + n, 0) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
def f():
    ax,ay,ar,bx,by,br=map(float,input().split())
    d=((ax-bx)* (ax - bx))+((ay-by)*(ay-by))
    r1=(ar+br)*(ar+br)
    r2=(ar-br)*(ar-br)
    if d<=r1 and d>=r2:return 1;
    elif d<r2 and ar>=br:return 2
    elif d < r2 and ar <= br:return -2
    else:return 0

for _ in range(int(input())):print(f())

Measured memory_bytes: 7680
import java.util.Scanner

object Main extends App  {
  val sc = new Scanner(System.in)

  val a = sc.next
  val b = sc.next

  val res = (a,b) match{
    case ("H","H") => "H"
    case ("H","D") => "D"
    case ("D","H") => "D"
    case ("D","D") => "H"
  }

  println(res)
}

Measured memory_bytes: 27984
S = input()
K = int(input())

rest = K
oz = ord('z')
oa = ord('a')
ans = list(S)

for ci in range(len(S)):
    if S[ci] == 'a':
        continue
    
    check = oz - ord(S[ci]) + 1
    if rest >= check:
        ans[ci] = 'a'
        rest -= check

if rest >= 0:
    for i in range(rest%26):
        if oz == ord(ans[-1]):
            ans[-1] = 'a'
        else:
            ans[-1] = chr(ord(ans[-1])+1)
    
print("".join(ans))



Measured memory_bytes: 10112
#include<iostream>
#include<algorithm>
using namespace std;
#define endl '\n'

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int K, N;
    cin >> N >> K;
    int a[N];
    for (int i = 0; i < N;i++){
        int n;
        cin >> n;
        a[i] = n;
    }
    sort(a, a + N);
    int num=0;
    for (int j = 0; j < K;j++){
        num = num + a[j];
    }
    cout << num << endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  int a[m],i;
  long long int sum=0;
  for(i=0;i<m;i++)
  {
    cin>>a[i];
    sum=sum+a[i];
}
if(sum>n)
{
  cout<<-1<<endl;
}
  else
  {
    cout<<n-sum<<endl;
  }
  return 0;
}

Measured memory_bytes: 3560
def main(A, B, C, K):
    """
    a = [1 for _ in range(A)]
    b = [0 for _ in range(B)]
    c = [-1 for _ in range(C)]
    k = a + b + c
    ans = sum(k[:K])
    """
    if K <= A:
        return K
    if A <= K <= A+B:
        return A
    else:
        return A - (K-A-B)

if __name__ == '__main__':
    A, B, C, K = map(int, input().split())
    ans = main(A, B, C, K)
    print(ans)



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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    li n;
    cin >> n;
    li res = INF;
    rin{
        li a;
        cin >> a;
        li tmp = 0;
        while (a % 2 == 0) {
            tmp++;
            a /= 2;
        }
        res = min(res, tmp);
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long m = sc.nextLong();

        long cnt = 0;
        if(n * 2 <= m) {
            cnt = n;
            m -= n * 2;
            cnt += m / 4;
        } else {
            cnt = m / 2;
        }

        System.out.println(cnt);
    }


}

Measured memory_bytes: 21840
p, q, r =(int(i) for i in input().split())
ans1=p+q
ans2=q+r
ans3=p+r

if ans1<=ans2 and ans1<=ans3:
    print(ans1)
elif ans2<= ans1 and ans2 <= ans3:
    print(ans2)
else:
    print(ans3)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int l = sc.nextInt();
		int [][] a = new int[n][m];
		int [][] b = new int[m][l];
		long [][] c = new long[n][l];
		for (int i=0;i<n; i++){
			for (int j=0; j<m; j++){
				a[i][j]=sc.nextInt();
			}
		}
		for (int j=0;j<m; j++){
			for (int k=0; k<l; k++){
				b[j][k]=sc.nextInt();
			}
		}
		for (int i=0; i<n; i++){
			for (int j=0; j<l; j++){
				for (int k=0;k<m; k++){
					c[i][j] += a[i][k] * b[k][j];
				}
				System.out.print(c[i][j]);
				if(j!=l-1)System.out.print(" ");
			}
			System.out.println();
		}
	}
}

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

int main(){
    int N;
    cin >> N;
    int A[N];
    for ( int i = 0; i < N; i++) cin >> A[i];
    bool flag = true;
    int mem;
    int cnt = 0;
    
    while (flag == true) {
        flag = false;
        for ( int j = N - 1; j > 0; j--){
            if ( A[j] < A[j-1]){
                mem = A[j];
                A[j] = A[j-1];
                A[j-1] = mem;
                cnt++;
                flag = true;
            }
        }
    }
    
    for (int i = 0; i < N; i++){
        cout << A[i];
        if (i < N - 1) cout << " ";
        else cout << endl;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3136
/*
name:       Egyptian Tourist
PlatForm:   CodeForces/SPOJ...etc
LANG:       C++
DIV:        Training
TIME:       *
RATE:       *
*/

/*
Time Consumed:*
Problem Topics: *
*/

#include <bits/stdc++.h>
#include <iostream>

using namespace std;

//-------------------------------------------------------//
#define rep(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define repr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define lp(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define lpr(i,n) for (int i = (n) - 1; ~i; i--)
#define foreach(it, ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )
//-------------------------------------------------------------------------------------//

#define clr(ar, val) memset(ar, val, sizeof(ar))
//----------------------------------------------//

#define inn freopen("in.in","r",stdin)
#define outt freopen("out.out","w",stdout)
#define PI 3.1415926535897932385
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define pob pop_back
#define bit(n) (1<<(n))
#define Last(i) ( (i) & (-i) )
#define all(v) ((v).begin()), ((v).end())
#define sq(x) ((x) * (x))
#define INF INT_MAX
#define Ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

//-------------------------------------------------------------//
#ifndef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1)
{
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1<<" | ";
    __f(comma+1, args...);
}
#else
#define debug(...)
#endif
#define _ist_ cout << "\nSTART OF INPUT DISPLAYING CHECK\n";
#define _iend_ cout << "\nEND OF INPUT DISPLAYING CHECK\n";
//------------------------------------------------------------//
#define mod (int)(1e9 + 7)
//#define N (int)2e5 + 5
#define N (int)1e5 + 5
//----------------------------------//
typedef pair<int, char> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
//---------------------------------//
template<class T, class T2>
T _f_pow(T a, T2 b)
{
    T res = 1LL;
    //a%=mod;
    while (b > 0)
    {
        if (b & 1)
            res = (res*a);//res = (res * a)%mod;
        a = (a * a);
        //a%=mod;
        b >>= 1;
    }
    return (res);
}
template<class T>
T gcd(T a, T b)
{
    while(a && b)
        if(a > b)
            (a%=b);
        else(b%=a);

    return a + b;
}
template<class T>
T lcm(T a, T b)
{
    return (a * b) / gcd(a, b);
}
int n;
int main()
{
    Ios;
    //inn;outt;
    //auto tt = clock();
    cin >> n;
    int ans = n * (n + 1) / 2;
    cout << ans << endl;
    //cout << (double(clock() - tt)/CLOCKS_PER_SEC * 1.00) << endl;
    //system("sleep 50");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
int main(){
    using namespace std;
    int i,x,y,z;
    vector<int> v;
    x = 1;
    y = 1;
    while(x!=0||y!=0){
        cin >> x >> y;
        if(x==0&&y==0){
            break;
        }
        if(x>y){
            z = x;
            x = y;
            y = z;
        }
        v.push_back(x);
        v.push_back(y);
    }
    int size = v.size();
    for(i=0;i<(size/2);i++){
        cout << v[2*i] << " " << v[2*i+1] << endl;
    }
    return 0;
}

Measured memory_bytes: 3156
#include<stdio.h>
#include<string.h>
#define N 1000

int Max(int a, int b){
	if(a >= b){
		return a;
	} else {
		return b;
	}
}

int lcs(char x[], char y[]){
	int i, j;
	int c[N+1][N+1];
	int m = strlen(x);
	int n = strlen(y);
	int maxl = 0;
	
	char x1[m+1] , y1[n+1];
	
	x1[0] = ' ';
	y1[0] = ' ';
	
	for(i=1;i<= m;i++ ) x1[i]=x[i-1];
	for(i=1; i<=n;i++ ) y1[i]=y[i-1];
	
	for(i = 0; i <= m; i++) c[i][0] = 0;
	for(j = 1; j <= n; j++) c[0][j] = 0;
	
	for(i=1; i<= m;i++){
		for(j = 1; j <= n; j++){
			if(x1[i]==y1[j]){
				c[i][j] = c[i-1][j-1] + 1;
			} else {
				c[i][j] = Max(c[i-1][j], c[i][j-1]);
			}
			maxl = Max(maxl, c[i][j]);
		}
	}
	return maxl;
}

int main( void ){
	char s1[N] , s2[N];
	int n;
	scanf( "%d" , &n );
	
	for( int i = 0; i < n; i++ ){
		scanf( "%s" , s1 );
		scanf( "%s" , s2 );
		printf( "%d\n" , lcs(s1 , s2) );
	}
	
	return 0;
}



Measured memory_bytes: 5648
#include <iostream>
#include <algorithm>
#include <iostream>
#include <math.h>
using namespace std;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
    int X;
    cin >> X;
    int res = X;

    while (true) {
        if (IsPrime(res)) {
            break;
        }
        ++res;
    }

	cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

#include <atcoder/convolution>
#include <atcoder/dsu>
#include <atcoder/fenwicktree>
#include <atcoder/lazysegtree>
#include <atcoder/math>
#include <atcoder/maxflow>
#include <atcoder/mincostflow>
#include <atcoder/modint>
#include <atcoder/scc>
#include <atcoder/segtree>
#include <atcoder/string>
#include <atcoder/twosat>

using namespace atcoder;
//typedef modint998244353 mint;

int main(){
  int N,M;
  cin>>N>>M;
  VS S(N);
  rep(i,N) cin>>S[i];
  mf_graph<int> G(N*M+2);
  rep(i,N) rep(j,M){
    if(S[i][j]=='#') continue;
    int now=i*M+j;
    if((i+j)%2==0){
      G.add_edge(N*M,now,1);
      auto add=[&](int n,int m){
        int nn=i+n,mm=j+m;
        if(nn>=0 and nn<N and mm>=0 and mm<M and S[nn][mm]=='.'){
          G.add_edge(now,nn*M+mm,1);
        }
      };
      add(0,1);
      add(0,-1);
      add(1,0);
      add(-1,0);
    }else G.add_edge(now,N*M+1,1);
  }
  cout<<G.flow(N*M,N*M+1)<<endl;
  auto E=G.edges();
  for(auto e:E){
    if(e.from==N*M or e.to==N*M+1 or e.flow==0) continue;
    int fn=e.from/M,fm=e.from%M;
    int tn=e.to/M,tm=e.to%M;
    if(fn-1==tn){
      S[tn][tm]='v';
      S[fn][fm]='^';
    }else if(fn+1==tn){
      S[fn][fm]='v';
      S[tn][tm]='^';
    }else if(fm-1==tm){
      S[tn][tm]='>';
      S[fn][fm]='<';
    }else{
      S[fn][fm]='>';
      S[tn][tm]='<';
    }
  }
  rep(i,N) cout<<S[i]<<endl;
}

Measured memory_bytes: 5584
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Info{
	double vw,pf,vf,th;
};

int N;
double pw;

Info* flower;


double calc(double water_amount){
	double ret = water_amount*pw;

	for(int i = 0; i < N; i++){
		ret += max(0.0,flower[i].pf*((flower[i].th-water_amount*flower[i].vw)/flower[i].vf));
	}
	return ret;
}

double thirds_search(double left,double right){

	if(fabs(right-left) < EPS){
		return calc((right+left)/2);
	}

	double mid1 = (2.0*left+right)/3.0;
	double mid2 = (1.0*left+2.0*right)/3.0;

	if(calc(mid1) > calc(mid2)){
		return thirds_search(mid1,right);
	}else{
		return thirds_search(left,mid2);
	}
}

void func(){
	scanf("%lf",&pw);

	for(int i = 0; i < N; i++){
		scanf("%lf %lf %lf %lf",&flower[i].vw,&flower[i].pf,&flower[i].vf,&flower[i].th);
	}

	printf("%.10lf\n",thirds_search(0.0,(double)BIG_NUM));
}

int main(){

	flower = (Info*)malloc(sizeof(Info)*100000);

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 6300
N = int(input())
lis = [0] * (10 ** 6)
for x in range(1,200):
    for y in range(1,200):
        for z in range(1,200):
            val = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if val <= N:
                lis[val] += 1
for i in range(1,N+1):
    print(lis[i])


Measured memory_bytes: 76920
#include<iostream>
#include<string>
using namespace std;
int main() {
	int n;
	cin >> n;
	std::string s = to_string(n);
	int b = s.size();
	string t;
	for (int i = 0;i < b-2;i++) {
		t = t + "0";
	}
	string x = "1" + t;
	int a = stoi(x);
	int c = n - a;
	string h = to_string(a);
	string j = to_string(c);
	int y = h.size();
	int u = j.size();
	int count1 = 0, count2 = 0;
	for (int f = 0;f < y;f++) {
		count1 = a % 10 + count1;
		a = a / 10;
	}
	for (int e = 0;e < u;e++) {
		count2 = c%10 + count2;
		c = c / 10;
	}
	cout << count1+count2;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 100000000000;
int main()
{
    int N,W;
    cin >> N >> W;
    ll w[N+1],v[N+1];
    ll V = 0;
    for(int i=1;i<=N;i++){
        cin >> w[i] >> v[i];
        V += v[i];
    }
    ll dp[N+1][V+1];//dp[i][j] is minimum weight with value j and i items
    for(int i=0;i<=N;i++){
        for(int j=0;j<=V;j++)
            dp[i][j] = INF;
    }
    for(int i=0;i<=N;i++)
        dp[i][0] = 0;
    for(int i=1;i<=N;i++){
        for(int j=1;j<=V;j++){
            if(j-v[i] >= 0)
                dp[i][j] = min(dp[i-1][j-v[i]]+w[i],dp[i-1][j]);
            else
                dp[i][j] = dp[i-1][j];
        }
    }
    ll ans = 0;
    for(ll i=1;i<=V;i++){
        if(dp[N][i] <= W)
            ans = max(ans,i);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 82440
#include<bits/stdc++.h>
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using namespace std;

int main(){
  int n,k,d,a;cin>>n>>k;
  vector<int> s(n,0);
  rep(i,k){
    cin>>d;
    rep(i,d){
      cin>>a;
      s[a-1]++;
    }
  }
  int sum=0;
  rep(i,n){
    if(s[i]==0)sum++;
  }
  cout<<sum;
}



Measured memory_bytes: 3600
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    cin>>N;
    if(N>=1&&N<=999){
        cout<<"ABC"<<endl;
    }
    if(N>999){
        cout<<"ABD"<<endl;
    }
    return 0;
}


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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 100010, M = 13;

int n, m;
int a[N], d[N];

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i ++ ) scanf("%d", a + i);
	
	int mina = 0x3f3f3f3f, maxd = -1;
	for (int i = 0; i < n; i ++ )
	{
		mina = min(mina, a[i]);
		int t = a[i] - mina;
		maxd = max(maxd, t);
		d[i] = t;
	}
	
	int res = 0;
	for (int i = 0; i < n; i ++ )
		if (d[i] == maxd)
			res ++ ;
	printf("%d\n", res);
	return 0;
}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout << 'A' << s2[0] << 'C' << endl;
    return 0;
}

Measured memory_bytes: 3608