akhauriyash/Code-Regression huggingface dataset:
#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 rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

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

struct edge_flow{int to, cap, rev;};

class FordFulkerson{
    public:
        int n;
        vector<vector<edge_flow>> edge;
        vector<bool> used;

        FordFulkerson(const vector<vector<edge_flow>>& edge, int n)
            : n(n), edge(edge){}

        int dfs(int v, int t, int f){
            if(v == t){
                return f;
            }
            used[v] = true;

            rep(i, (int)edge[v].size()){
                edge_flow &e = edge[v][i];
                if(not used[e.to] && e.cap > 0){
                    int d = dfs(e.to, t, min(f, e.cap));
                    if(d > 0){
                        e.cap -= d;
                        edge[e.to][e.rev].cap += d;
                        return d;
                    }
                }
            }
            return 0;
        }

        int max_flow(int s, int t){
            int flow = 0;
            while(true){
                used = vector<bool>(n+1, false);
                int f = dfs(s, t, INF);
                if(f == 0){
                    return flow;
                }
                flow += f;
            }
        }
};

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

    int n;
    cin >> n;
    vector<vector<edge_flow>> graph(n + 2, vector<edge_flow>());
    int sum = 0;
    for(int i = 1; i <= n; i++){
        int a;
        cin >> a;

        if(a > 0){
            sum += a;
            graph[i].push_back(edge_flow{n + 1, a, SZ(graph[n+1])});
            graph[n+1].push_back(edge_flow{i, 0, SZ(graph[i]) - 1});
        }else{
            graph[0].push_back(edge_flow{i, -a, SZ(graph[i])});
            graph[i].push_back(edge_flow{0, 0, SZ(graph[0]) - 1});
        }

        for(int j = i; j <= n; j += i){
            graph[i].push_back(edge_flow{j, INF, SZ(graph[j])});
            graph[j].push_back(edge_flow{i, 0, SZ(graph[i]) - 1});
        }
    }

    FordFulkerson ff(graph, n + 2);
    int ans = ff.max_flow(0, n + 1);
    cout << sum - ans << endl;

    return 0;
}


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

int main() {
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> vec(Q);
  for (int i = 0; i < Q; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  
  int n = 0;
  for (int i = 0; i < N; i++) {
    int count = 0;
    while (i + 1 == vec.at(n)){
      count++;
      if (n == Q - 1) {
        break;
      }
      n++;
    }
    
    int C = K - (Q - count);
    if ( C > 0 ) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


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


int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  rep(i,N){cin >> d.at(i);}
  
  int ans = 0;
  
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      ans += d[i]*d[j];
    }
  }
  

  cout << ans << endl;
}

Measured memory_bytes: 256
def checkWin(T_hp, A_hp):
    if (T_hp <= 0):
        print('No')
    if (A_hp <= 0):
        print('Yes')

T_hp, T_at, A_hp, A_at = list(map(int, input().split()))

while (T_hp > 0 and A_hp > 0):
    A_hp = A_hp - T_at
    T_hp = T_hp - A_at

    if (A_hp <= 0):
        print('Yes')
        break

    if (T_hp <= 0):
        print('No')
        break



    

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

int main() {
  int K , N;
  cin >> K >> N;
  vector<int>vec(N);
  int min;
  for(int i; i < N ; i++){
    cin >> vec.at(i);
  }
  min = K - vec.at(N-1) + vec.at(0);
  for(int i; i < N - 1 ; i++){
    if(min < vec.at(i+1) - vec.at(i)){
      min = vec.at(i+1) - vec.at(i);
    }
  }
  cout << K - min << endl;
}



Measured memory_bytes: 1024
/*
	watch me go
*/
#pragma GCC optimize("O3")
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#define d long double
#define pii pair<int,int>
#define pb push_back
#define inf (int)1e18
#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
int const mod=998244353;
int const mod1=1000000007;
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 #define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// ******** Using PBDS ********
// typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//                 os; 
// ******** Using PBDS ********
int modexp(int x, int n){
	if(n==0){
		return 1;
	}
	else if(n&1){
		return (modexp((x*x)%mod, n/2)%mod * x%mod)%mod;
	}
	else{
		return (modexp((x*x)%mod, n/2)%mod);
	}
}
 
int modinv(int n)
{
	return modexp(n,mod-2);
}


signed main()
{
    haha
    int n,m;
    cin>>n>>m;
    int s=0;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        s+=arr[i];
    }
    sort(arr,arr+n,greater<int>());
    double x=(s*1.0)/(4*m);
    //cout<<x<<endl;
    if(arr[m-1]<x)
    cout<<"No";
    else
    cout<<"Yes";
   
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <string>
using namespace std;
#define FL(i,a,b) for(int i = a;i<b;i++)
typedef vector<int> vi;

const int inf = numeric_limits<int>::max();


int main(){
    int n;
    cin>>n;
    set<string> s;
    int count = 0;
    FL(i,0,n){
        string temp;
        cin>>temp;
        if(s.count(temp)){
            
        }
        else{
            count++;
            s.insert(temp);
        }
    }
    cout<<count;
}

















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

int main(int argc, char const *argv[]) {
    int A, B;
    cin >> A >> B;
    if (A > B * 2) {
        cout << A - B * 2 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s, p;
    getline(cin, s);
    getline(cin, p);
    s = s + s;
    if(s.find(p) == string::npos){
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 1184
# include<bits/stdc++.h>
# include<ext/pb_ds/assoc_container.hpp>
# include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

# define int long long

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

# define S second
# define F first
# define kill(x) return(cout << x << '\n', 0LL)
# define debug(x) cerr<< #x << " = " << (x) << endl
# define ddebug(x, y) cerr<< #x << " = " << (x)  << ", " << #y << " = " << (y) << endl
# define tdebug(x, y, z) cerr<< #x << " = " << (x)  << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl
# define bin(x) cerr<< #x << " : " << bitset<4>(x) << endl
# define sz(s) (int)s.size()
# define sq(x) (x) * (x)
# define PB(x) push_back(x)
# define smax(x, y) (x) = max((x), (y))
# define smin(x, y) (x) = min((x), (y))
# define all(x) x.begin(), x.end()
# define SP fixed << setprecision(10)
# define uop(x, y) pii(min(x, y), max(x, y))
# define MP(x, y) make_pair(x, y)

const int MAXN = 3000 + 10;
int a[MAXN];
vector <int> adj[MAXN];
bool w[MAXN];

void dfs(int v, int p)
{
	for (int u : adj[v])
		if (u != p)
		{
			dfs(u, v);
			if (!w[u] && a[u] < a[v])
				w[v] |= true;
		}
}

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	int n;
	cin >> n;
	for (int i = 0; i < n; i ++)
		cin >> a[i];
	for (int i = 0; i < n - 1; i ++)
	{
		int u, v;
		cin >> u >> v;
		u --, v --;
		adj[u].PB(v);
		adj[v].PB(u);
	}

	for (int i = 0; i < n; i ++)
	{
		memset(w, 0, sizeof w);
		dfs(i, i);
		if (w[i])
			cout << i + 1 << " ";
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 4048
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair<int,int>
int const M=200+10,M2=300+10,inf=1e9+10,mod=1e9+7;
int a[M];
int dp[M][M][2],mark[M][M][2];
int pw(int x,int y)
{
	if(y==0)return 1;
	int tmp=pw(x,y/2);
	if(y%2==0)return (tmp*tmp)%mod;
	return ((tmp*tmp)%mod*x)%mod;
}
void fdp(int l,int r,bool ch)
{
	if(mark[l][r][ch])return;
	mark[l][r][ch]=1;
	int now=max(a[l-1],a[r+1]);
	now++;
	int mn=inf;
	for(int i=l;i<=r;i++)
	{
		mn=min(mn,a[i]);
	}
	int last=l;
	dp[l][r][ch]=1;
	if(ch)dp[l][r][ch]=pw(2,mn-now);
	//if(ch)cout<<now<<" "<<mn<<" "<<dp[l][r][ch]<<endl;
	int bad=2;
	//if(ch==0)cout<<l<<" "<<
	for(int i=l;i<=r;i++)
	{
		if(a[i]==mn)
		{
			if(last==i)
			{
				last=i+1;
				if(!ch)dp[l][r][ch]*=2,dp[l][r][ch]%=mod;
				continue;
			}
			if(ch)
			{
				fdp(last,i-1,1);
				dp[l][r][ch]*=dp[last][i-1][1];
				dp[l][r][ch]%=mod;
				dp[l][r][ch]*=2;
				dp[l][r][ch]%=mod;
				last=i+1;
				continue;
			}
			fdp(last,i-1,1);
			fdp(last,i-1,0);
			int tmp=dp[last][i-1][0]+(dp[last][i-1][1]*4);
			tmp*=2;
			tmp%=mod;
			dp[l][r][ch]*=tmp;
			dp[l][r][ch]%=mod;
			dp[l][r][ch]%=mod;
			bad*=dp[last][i-1][1]*2;
			last=i+1;
			//cout<<last<<endl;
		//	cout<<dp[last][i-1][1]<<endl;
			bad%=mod;
		}
	}
	if(last!=r+1)
	{
		if(ch)
		{
			fdp(last,r,1);
			dp[l][r][ch]*=(dp[last][r][1]);
			dp[l][r][ch]%=mod;
			dp[l][r][ch]*=2;
			dp[l][r][ch]%=mod;
		}
		else
		{
			fdp(last,r,0);
			fdp(last,r,1);
			bad*=dp[last][r][1]*2;
			bad%=mod;
			int tmp=dp[last][r][0]+dp[last][r][1]*4;
			tmp%=mod;
			dp[l][r][ch]*=tmp;
			dp[l][r][ch]%=mod;
		}
	}
//	if(!ch)cout<<l<<" "<<r<<" "<<dp[l][r][ch]<<" "<<bad<<endl;
	if(ch==0)
	{
		dp[l][r][ch]-=bad;
		dp[l][r][ch]+=mod;
		dp[l][r][ch]%=mod;
	}
}
int32_t main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	fdp(1,n,0);
	fdp(1,n,1);
	//cout<<dp[1][n][1]<<endl;
	cout<<(dp[1][n][1]*2+dp[1][n][0])%mod;
}	

Measured memory_bytes: 896
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var S = ReadLine();
        var c = S.ToCharArray();
        var lst = new List<string>();
        var bit = S.Length - 1;
        for (int i = 0; i < (1 << bit); i++) {
            var ch = c.ToList();
            var idx = 1;
            for (int j = 0; j < bit; j++) {
                if ((1 & i >> j) == 1) {
                    ch.Insert(j + idx, '+');
                    idx++;
                }
            }
            lst.Add(string.Join(null, ch));
        }

        long ans = 0;
        for (int i = 0; i < lst.Count; i++) {
            var s = lst[i].Split('+');
            ans += s.Select(str => long.Parse(str)).Sum();
        }

        WriteLine(ans);
    }
}



class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}

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

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

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i,N) cin >> A[i];

  map<int,int> mp;
  REP(i,N) ++mp[A[i]];
  int cnt = 0;
  for(auto e: mp) {
    cnt += e.second - 1;
  }
  if(cnt % 2) cnt += 1;
  cout << (N - cnt) << endl;
  return 0;
}



Measured memory_bytes: 5376
N, X = list(map(int, input().split()))
x = list(map(int, input().split()))

def gcd(a, b):
    if a % b == 0:
        return b
    return gcd(b, a % b)

res = 0
for i in range(N):
    res = gcd(res, abs(x[i] - X))

print(res)

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

int main()
{
int a, b, c; cin>>a>>b>>c;
int arr[12]; arr[a]++; arr[b]++; arr[c]++;

if(arr[5]==2 && arr[7] ==1)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<deque>
#include<vector>
#define io ios::sync_with_stdio(false)
#define inf 0x3f3f3f3f
#define ll long long 
#define P pair<int,int>
using namespace std;
int main()
{
	io;
	string str;
	cin >> str;
	deque<char>dq;
	for (auto i : str)
	{
		dq.push_back(i);
	}
	int q;
	cin >> q;
	int sum = 0;
	while (q--)
	{
		int t;
		cin >> t;
		if (t == 1)
		{
			sum++;
		}
		else
		{
			int f;
			char c;
			cin >> f >> c;
			if (f == 1)
			{
				if (sum % 2 == 0)
				{
					dq.push_front(c);
				}
				else
				{
					dq.push_back(c);
				}
			}
			else
			{
				if (sum % 2 == 0)
				{
					dq.push_back(c);
				}
				else
				{
					dq.push_front(c);
				}
			}
		}
	}
	if (sum % 2 == 1)
	{
		reverse(dq.begin(), dq.end());
	}
	for (auto i : dq)
	{
		cout << i;
	}
}

Measured memory_bytes: 976
N, K = gets.split.map(&:to_i)
R, S, P = gets.split.map(&:to_i)
T = gets.chomp

history = Hash.new(-1)

ans = 0

T.chars.each_with_index do |t, i|
  next_index = i + K
  before_index = i - K

  case t
  when 'r'
    if history[before_index] == 'p'
      if next_index < N - 1
        history[i] = T[next_index]
      end
    else
      history[i] = 'p'
      ans += P
    end
  when 'p'
    if history[before_index] == 's'
      if next_index < N - 1
        history[i] = T[next_index]
      end
    else
      history[i] = 's'
      ans += S
    end
  when 's'
    if history[before_index] == 'r'
      if next_index < N - 1
        history[i] = T[next_index]
      end
    else
      history[i] = 'r'
      ans += R
    end
  end
end

puts ans


Measured memory_bytes: 19836
N = int(input())
TB,XB,YB = 0,0,0
Flag = True
for Z in range(0,N):
    TA,XA,YA = (int(A) for A in input().split())
    RestT = (TA-TB)-(abs(XA-XB)+abs(YA-YB))
    if RestT<0 or RestT%2!=0:
        Flag = False
        break
    else:
        TB,XB,YB = TA,XA,YA
if Flag:
    print('Yes')
else:
    print('No')

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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  preprocess();
  int n; cin>>n;
  vector<string> st(n);
  rep(i,0,n) {
    cin>>st[i];
    sort(all(st[i]));
  }
  map<string, int> mm;
  lli ans = 0;
  rep(i,0,n) {
    ans += mm[st[i]];
    mm[st[i]]++;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 16640
#include <stdio.h>

int main () {
	int n, a, b;
	scanf("%d %d %d", &n, &a, &b);
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		int digSum = 0;
		int temp = i;
		while (temp != 0) {
			digSum = digSum + temp % 10;
			temp /= 10;
		}
		if(digSum >= a && digSum <= b) {
			sum += i;
		}
	}	
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 1736
import java.util.*;

class Main{
  public static boolean test(String test){
    int c = 0;
    for(int i = 0;i < test.length();i++){

      if(i == 0 ){
        if(test.charAt(i) == 'A'){
          continue;
        }else{
          return false;
        }
      }
      if(i >= 2 && i <= test.length() - 2){
        if(test.charAt(i) == 'C'){
          c++;
          if(c>1){
            return false;
          }
          continue;
        }
      }
      if(Character.isUpperCase(test.charAt(i))){
        return false;
      }
  }
  if(c == 0){
  return false;
}
  return true;
}
  public static void main(String args[]){
    Scanner scan = new Scanner(System.in);
    String a = scan.next();
    if(test(a)){
      System.out.println("AC");
    }else{
      System.out.println("WA");
    }
  }
}

Measured memory_bytes: 23636
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222


vll fac, inv, invfac;
void comb_set(ll x = MAX) {
  fac.resize(x + 1, 0);
  invfac.resize(x + 1, 0);
  inv.resize(x + 1, 0);
  fac[0] = inv[1] = invfac[0] = 1;
  FOR(i, 1, x + 1) (fac[i] = fac[i - 1] * i) %= mod;
  FOR(i, 2, x + 1) (inv[i] = (mod - mod / i) * inv[mod%i]) %= mod;
  FOR(i, 1, x + 1) (invfac[i] = invfac[i - 1] * inv[i]) %= mod;
}
ll comb(ll x, ll y) {
  if (x < y) return 0;
  return fac[x] * invfac[x - y] % mod * invfac[y] % mod;
}
ll mod_pow(ll x, ll y) {
  ll ret = 1;
  while (y > 0) {
    if (y & 1) ret = (x*ret) % mod;
    x = (x*x) % mod;
    y >>= 1;
  }
  return ret;
}


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


  cin >> n >> m;
  comb_set(MAX);
  ll b = m, r = n - m;

  FOR(i, 1, m + 1) {
    ans = comb(r + 1, i) % mod;
    (ans *= comb(b - 1, b - i)) %= mod;
    cout << ans << endl;
  }




  return 0;
}

Measured memory_bytes: 5504
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using ll = long long;
using P = pair<int, int>;
using MATRIX = vector< vector<ll> >;
template <class T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <class T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}

const int INF = 1000000000;

template<class FT>
struct Dinic {
  const FT INF;

  struct edge {
    int to;
    FT cap;
    int rev;
    bool is_rev;
  };

  vector<vector<edge>> graph;
  vector<int> min_cost, iter;

  Dinic(int V) : INF(numeric_limits<FT>::max()), graph(V) {};

  void add_edge(int from, int to, FT cap, int idx = -1) {
    graph[from].emplace_back((edge) {to, cap, (int) graph[to].size(), false});
    graph[to].emplace_back((edge) {from, 0, (int) graph[from].size() - 1, true});
  }

  bool bfs(int s, int t) {
    min_cost.assign(graph.size(), -1);
    min_cost[s] = 0;
    queue<int> Q;
    Q.push(s);
    while(Q.size() && min_cost[t] == -1) {
      int v = Q.front();
      Q.pop();
      for(auto &e: graph[v]) {
        if(e.cap > 0 && min_cost[e.to] == -1) {
          min_cost[e.to] = min_cost[v] + 1;
          Q.push(e.to);
        }
      }
    }
    return min_cost[t] != -1;
  }

  FT dfs(const int v, const int t, FT flow) {
    if(v == t) return flow;
    for(int &i = iter[v]; i < graph[v].size(); i++) {
      edge &e = graph[v][i];
      if(e.cap > 0 && min_cost[v] < min_cost[e.to]) {
        FT d = dfs(e.to, t, min(flow, e.cap));
        if(d > 0) {
          e.cap -= d;
          graph[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }

  FT max_flow(int s, int t) {
    FT flow = 0;
    while(bfs(s, t)) {
      iter.assign(graph.size(), 0);
      FT f = 0;
      while((f = dfs(s, t, INF)) > 0) flow += f;
    }
    return flow;
  }

  void print() {
    for(int i = 0; i < graph.size(); i++) {
      for(auto &e: graph[i]) {
        if(e.isrev) continue;
        auto &rev_e = graph[e.to][e.rev];
        cout << i << "->" << e.to << " (flow:" << rev_e.cap << "/" << e.cap + rev_e.cap << ")" << endl;
      }
    }
  }
};

int main() {
  int H, W;
  cin >> H >> W;
  string a[100];
  Dinic<int> g(H + W + 2);
  int S, T;
  rep(i, H) {
    cin >> a[i];
  }
  rep(i, H) {
    rep(j, W) {
      if(a[i][j] == 'S') {
        g.add_edge(H+W, i, INF);
        g.add_edge(H+W, H+j, INF);
        S = W * i + j;
      }
      if(a[i][j] == 'T') {
        g.add_edge(i, H+W+1, INF);
        g.add_edge(H+j, H+W+1, INF);
        T = W * i + j;
      }
      if(a[i][j] == 'o') {
        g.add_edge(i, H+j, 1);
        g.add_edge(H+j, i, 1);
      }
    }
  }

  if(S / W == T / W || S % W == T % W) {
    cout << -1 << endl;
    return 0;
  }

  cout << g.max_flow(H + W, H + W + 1) << endl;

  return 0;
}

Measured memory_bytes: 4444
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, D; 
  cin >> N >> D;

  vector<vector<int>> X(N, vector<int>(D));
  REP(i, N) REP(j, D) cin >> X[i][j];

  int ans = 0;
  REP(i, N) FOR(j, i+1, N){
    int ret = 0;
    REP(k, D){
      ret += (X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
    }
    for(int k = 1; k*k <= ret; k++){
      if(k*k == ret) ans++;
    }
  }

  cout << ans << "\n";

  return 0;
}

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


using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if (a + b == c + d)cout << "Balanced";
    else if (a + b > c + d)cout << "Left";
    else cout << "Right";
    cout << endl;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc109/tasks/abc109_b

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  int n;
  set<string> w;
  cin >> n;

  char l;
  string r = "Yes";

  string wi;
  cin >> wi;
  w.insert(wi);
  l = wi.back();

  REP(i, n - 1)
  {
    cin >> wi;
    if (l != wi[0] || w.count(wi) != 0)
      r = "No";
    w.insert(wi);
    l = wi.back();
  }

  cout << r << '\n';

  return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    int b = a[0];
    for(int i = 1; i < n; i++) b = b^a[i];
    for(int i = 0; i < n; i++){
        cout << (b^a[i]) << endl;
    }
    return 0;
}

Measured memory_bytes: 4048
#include"bits/stdc++.h"
#define ll unsigned long long int
using namespace std;
int main()
{
    ll n;
    cin>>n;
    ll i;
    ll how=sqrt(n);
    ll ans=1e12+10;
    for(i=1;i<=how;i++) {
            if(n%i==0) {
                ll g=n/i;
                ans=min(ans,i+g);
            }
    }
    cout<<ans-2<<"\n";
}


Measured memory_bytes: 256
#include <iostream>


using namespace std;

int main(){
 int x,y,temp;
 cin >> x >> y;
 if (x<y) {
   temp=y;
   y=x;
   x=temp;
 }
 while (y>0) {
   x=x%y;
   temp=y;
   y=x;
   x=temp;
 }
 cout << x << endl;
 return 0;
}



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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}

long long dp[100005][3];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, a, b, c; cin >> n;

    for(int i = 1; i <= n; ++i){
        cin >> a >> b >> c;
        dp[i][0] = max(dp[i - 1][1] + b, dp[i - 1][2] + c);
        dp[i][1] = max(dp[i - 1][0] + a, dp[i - 1][2] + c);
        dp[i][2] = max(dp[i - 1][0] + a, dp[i - 1][1] + b);
    }

    cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << "\n";

    return 0;

}


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

int main() {
    string w;
    char ch;
    set<string> ss;
    int n;

    cin >> n;

    bool ans = true;
    for (int i = 0; i < n; i++) {
        cin >> w;
        if (ss.count(w)) 
            ans = false;

        if (i > 0 && w[0] != ch)
            ans = false;

        ch = w[w.size()-1];
        ss.insert(w);
    }

    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}


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

using namespace std;

int n,cnt,num[10010],num2[10010],maxa;
int num1[100010];
long long int prime[1000010],lcm,ans,mod=1000000007;
bool vis[1000010]; 

long long int qpow(long long int a,int x)
{
	if(x==0)
	    return 1;
	if(x==1)
	    return a;
	if(x%2==0)
	{
		long long int a1=qpow(a,x/2);
		return a1*a1%mod;
	}
	else
	{
		long long int a1=qpow(a,x/2);
		return a1*a1%mod*a%mod;
	}
}

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
    	scanf("%d",&num[i]);
    	maxa=max(num[i],maxa);
    	num2[i]=num[i];
	}
	
    for(int i=2;i<=maxa;i++)
    {
        if(!vis[i])
        prime[++cnt]=i;
        for(int j=1;j<=cnt && i*prime[j]<=maxa;j++)
        {
            vis[i*prime[j]]=true;
            if(i%prime[j]==0) 
			    break; 
        }
    }
    for(int i=1;i<=n;i++)
    {
    	for(int j=1,k=cnt;j<k;j++,k--)
    	{
    		if(num2[i]%prime[j]==0)
    		{
    			int cnt1=0;
    			while(num2[i]%prime[j]==0)
    			{
    				cnt1++;
    				num2[i]=num2[i]/prime[j];
				}
				num1[j]=max(num1[j],cnt1);
				if(num2[i]==1)
			        break;
			}
			if(num2[i]==1)
			    break;
			if(num2[i]%prime[k]==0)
    		{
    			int cnt1=0;
    			while(num2[i]%prime[k]==0)
    			{
    				cnt1++;
    				num2[i]=num2[i]/prime[k];
				}
				num1[k]=max(num1[k],cnt1);
				if(num2[i]==1)
			        break;
			}
			if(num2[i]==1)
			    break;
		}
	}
	lcm=1;
	for(int j=1;j<=cnt;j++)
		lcm=lcm*qpow(prime[j],num1[j])%mod;
	for(int i=1;i<=n;i++)
	    ans=(ans+lcm*qpow(num[i],mod-2)%mod)%mod;
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 20005
#define INF 1000000005LL
#define MOD 1000000007

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

int n;
ll p[SIZE],a[SIZE],b[SIZE];

int main(){
  cin >> n;
  rep(i,0,n){
    cin >> p[i];
    a[i] = i*(ll)n;
  }
  ll t=0;
  ll mn = INF;
  rep(i,0,n){
    b[p[i]-1] = t-a[p[i]-1];
    mn = min(b[p[i]-1],mn);
    t++;
  }
  rep(i,0,n) {
    a[i]++;
    b[i] -= mn;
    b[i]++;
  }
  rep(i,0,n){
    if(i!=0)cout << " ";
    cout << a[i];
  }
  cout << endl;
  rep(i,0,n){
    if(i!=0)cout << " ";
    cout << b[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class A
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int r = GetInt();
		WriteLine(r * r);
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 13140
#include<stdio.h>
int main (void){
int n,i,a,b,ai[10001];
long c;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&ai[i]);
if(i==0){
a=ai[0];
b=ai[0];
} else{
if(a<=ai[i]){
a=ai[i];
}
if(b>=ai[i]){
b=ai[i];
}
}
} 
c=0;
for(i=0;i<n;i++){
c+=ai[i];
}
printf("%d %d %ld\n",b,a,c);
return 0;
}

Measured memory_bytes: 640
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
ans=[0,0,0]
for i in l:
    ans[0],ans[1],ans[2]=max(ans[1],ans[2])+i[0],max(ans[0],ans[2])+i[1],max(ans[0],ans[1])+i[2]
print(max(ans))

Measured memory_bytes: 30580
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

int a,b,c,d;

int main(){
	cin >> a >> b >> c;
	if(a > b) swap(a,b);
	if(b > c) swap(b,c);
	if(a > b) swap(a,b);
	cout << b - a + c - b;
} 

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

using namespace std;

int main(){
    int n;
    cin>>n;
    long long ans=0;
    
    for(int i=1;i<=n;i++){
        if(i%3!=0 && i%5!=0) ans+=i;
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int memo[1001][1001]={},ma,mb;
int a[40],b[40],c[40];
void sai(int n,int mx,int aa,int bb){
  if(n>=mx){
    return ;
  }
  for(int i=n+1;i<mx;i++){
    int na=aa+a[i],nb=bb+b[i];
    while(na-ma>=0&&nb-mb>=0&&!(na==ma&&nb==mb)){
      na-=ma;
      nb-=mb;
    }
    if(memo[na][nb]==0||memo[na][nb]>memo[aa][bb]+c[i]){
      memo[na][nb]=memo[aa][bb]+c[i];
      sai(i,mx,na,nb);
    }
  }
  return;
}
int main(){
  int n;
  cin>>n>>ma>>mb;
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i]>>c[i];
  }
  sai(-1,n,0,0);
  if(memo[ma][mb]!=0){
    cout<<memo[ma][mb]<<endl;
  }else{
    cout<<"-1"<<endl;
  }
  return(0);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    double l;
    cin>>l;
    double ans=(l*l*l)/27;
    int ans2=(int)ans;
    if(ans==ans2)cout<<ans2<<endl;
    else cout<<fixed<<setprecision(15)<<ans<<endl;
}

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

int main(void){
  int a;
  cin>>a;
  int front,rear;
  front=a/100;
  rear=a%100;
  
  
  if((front==0 || 12<front) && (1<=rear && rear<=12))cout<<"YYMM"<<endl;
  else if((1<=front && front<=12) && (rear==0 || 12<rear))cout<<"MMYY"<<endl;
  else if((1<=front && front<=12) && (1<=rear && rear<=12))cout<<"AMBIGUOUS"<<endl;
  else cout<<"NA"<<endl;
  
  return 0;
}


Measured memory_bytes: 3632
import sys
from io import StringIO
import unittest


def resolve():
    L = int(input())
    print((L / 3)**3)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3"""
        output = """1.000000000000"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """999"""
        output = """36926037.000000000000"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


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

struct UnionFind {
    std::vector<int> data;

    UnionFind(int n=1e5): data(n, -1) {}

    int root(int x){
        if(data[x]<0) return x;
        else return data[x] = root(data[x]);
    }

    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x==y) return;
        data[x] += data[y];
        data[y] = x;
    }
};

int main(){
  int n, q, p, a, b;
  scanf("%d %d", &n, &q);
  UnionFind uf(n);
  for(int i=0; i<q; i++){
    scanf("%d %d %d", &p, &a, &b);
    if(p==0) uf.unite(a, b);
    else{
      if(uf.root(a)==uf.root(b)){
        puts("1");
      }else{
        puts("0");
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3932
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<int> v(N);
  vector<int> w(N+2);
  rep(i,N){
    cin >> v[i];
    w[v[i]] = i+1;
  }
  set<int> stl;
  set<int> str;
  ll ans = 0;
  perr(x,1,N+1){
    auto itl = stl.upper_bound(-w[x]);
    auto itr = str.upper_bound(w[x]);
    ll l1=0,l2=0,r1=N+1,r2=N+1;
    //自分より大きい一番近く
    if(itl == stl.end()) l1 = 0;
    else l1 = *itl;
    if(itr == str.end()) r1 = N+1;
    else r1 = *itr;

    //自分より大きい二番目に近く
    if(l1==0)l2 == 0;
    else{
      stl.erase(itl);
      itl = stl.upper_bound(-w[x]);
      if(itl == stl.end()) l2 = 0;
      else l2 = *itl;
      stl.insert(l1);
    }
    if(r1==N+1)r2 = N+1;
    else{
      str.erase(itr);
      itr = str.upper_bound(w[x]);
      if(itr == str.end()) r2 = N+1;
      else r2 = *itr;
      str.insert(r1);
    }
    stl.insert(-w[x]);
    str.insert(w[x]);

    l1=-l1;
    l2=-l2;
    ans += x*(l1-l2)*(r1-w[x]); 
    ans += x*(r2-r1)*(w[x]-l1);
    //if(l1 != 0) ans += x*(l1-l2)*(r1-w[x]);
    //if(r1 != N+1) ans += x*(r2-r1)*(w[x]-l1);
    //cout << x SP l2 SP l1 SP r1 SP r2 SP ans << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	int a,b;
	cin>>a>>b;
	if(b>=100) a=a*1000+b;
	else if(b>=10) a=a*100+b;
	else a=a*10+b;
	b=sqrt(a);
	if(b*b==a) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


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

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

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n,k;
    cin >> n >> k;
    ll ans = 0;
    for(ll i=k;i<=n+1;i++){
        // i個選ぶとする
        ll mn = (i-1)*i/2LL;
        ll mx = (n + n - i + 1) * i / 2LL;
        ans += (mx - mn + 1 + mod);
        ans %= mod;
        // 最低値は(0+i-1)*i/2;
        // 最大値は (n + n-i) *i /2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
# 6, 5, 6, 5, ...

x = int(input())
q = x // 11
r = x % 11
if r == 0:
    ans = q * 2
elif 1 <= r <= 6:
    ans = q * 2 + 1
elif 7 <= r <= 10:
    ans = q * 2 + 2
print(ans)


Measured memory_bytes: 9176
N, K = map(int, input().split())
V = [int(i) for i in input().split()]
ans = 0
for M in range(K+1):
    for m in range(M+1):
        ls = []
        for i, x in enumerate(V):
            if i < m:
                ls.append(x)
        for i, x in enumerate(V[::-1]):
            if i < min(M-m, N-m):
                ls.append(x)
        ls.sort()
        s = sum(ls)
        for i, x in enumerate(ls):
            if i < K-M and x < 0:
                s -= x
        ans = max(ans, s)
print(ans)


Measured memory_bytes: 9056
<?php
fscanf(STDIN,"%d",$n);
$h=explode(" ", rtrim(fgets(STDIN)));

$result=$h[0];
for ($i=1; $i <$n; $i++)
	$result=gcd($result,$h[$i]);

echo($result);

function gcd($n1,$n2)
{
    $n1=abs($n1);
    $n2=abs($n2);
    
    if($n1<$n2)
    {
        $temp=$n1;
        $n1=$n2;
        $n2=$temp;
    }
    if($n2<1)
        return -1;

    if($n1%$n2==0)
        return $n2;
    return gcd($n2,$n1%$n2);
}

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

int N, M, Q;
vvi X(Q, vi(4));
int C;

void gh(int, vi);

int main() {
    cin >> N >> M >> Q;
    rep(i, Q){
        X.push_back(vi(4));
        rep(j, 4){
            
            cin >> X[i][j];
        }
    }
    vi A (N, 1);
    gh(0, A);
    cout << C << endl;
}

void gh(int i, vector<int> A){
    if(i >= N) {
        return;
    }
    if(A[i] > M) {
        return;
    }
    int sum=0;
    rep(i, Q){
        if(A[X[i][1]-1] - A[X[i][0]-1] == X[i][2]){
            sum += X[i][3];
        }
    }
    if(C<sum){
        C = sum;
    }
    gh(i+1, A);
    for(int j=i; j<N; ++j) {
        ++A[j];
        
    }
    gh(i, A);
}

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

int main()
{
    int a[3];
    while(~scanf("%d%d%d", &a[0], &a[1], &a[2]))
    {
        sort(a, a + 3);
        if(a[0] == 5 && a[1] == 5 && a[2] == 7)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    N = int(input())
    txy_list = [[0,0,0]] + [list(map(int, input().split())) for i in range(N)]

    answer = "Yes"
    for i in range(1, len(txy_list)):
        before_t = txy_list[i-1][0]
        t = txy_list[i][0]
        before_x = txy_list[i-1][1]
        x = txy_list[i][1]
        before_y = txy_list[i-1][2]
        y = txy_list[i][2]

        if t - before_t < (x - before_x) + (y - before_y):
            answer = 'No'
            break
        elif ((t - before_t) - ((x - before_x) + (y - before_y)))%2 != 0:
            answer = 'No'
            break

    print(answer)

Measured memory_bytes: 28068
#include <stdio.h>

int prime(int num){
  int i=3;

  if(num==2) return 1;
  if(num<2 || num%2==0) return 0;

  while(i*i<=num){
    if(num%i==0) return 0;
    i+=2;
  }
  return 1;
}

int main(){

  int n,i,num,count=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&num);
    if(prime(num)) count++;
  }
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 596
#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int m,n;
    cin>>m>>n;
    vector<int> A(n);
    for(int i=0;i<n;i++)
        cin>>A[i];
    int ans = 0;
    for(int i=0;i<n;i++){
        ans = ans + A[i];
    }
    if(m<ans){
        cout<<-1<<endl;
    }
    else{
        cout<<m-ans<<endl;
    }
    return 0;
}

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

using namespace std;

bool bijiaodaxiao(int a,int b,int c){
	if(a <= c && c <= b)return true;
	else return false;
}

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(bijiaodaxiao(a,b,c))cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

  int x,y,gcd,temp;

  scanf("%d%d",&x,&y);
  
  while(y!=0){
    temp=x;
    gcd=y;
    x=y;
    y=temp%gcd;
  }

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

  return 0;
}


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

int main() {
    string s;
    cin >> s;
    int counter = 0;
    if (s[0] == '1') ++counter;
    if (s[1] == '1') ++counter;
    if (s[2] == '1') ++counter;
    cout << counter << endl;
}

Measured memory_bytes: 888
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String str = null;
		int count[] = new int[26];

		while (sc.hasNext()) {
			str = sc.nextLine();
			str = str.toLowerCase();
			char ch[] = str.toCharArray();
			for (int i = 0; i < ch.length; i++) {
				if (Character.isAlphabetic(ch[i])) {
					int x = ch[i] - 'a';
					count[x]++;
				}
			}
		}

		for (int i = 0; i < count.length; i++) {
			char x = (char) ('a' + i);
			System.out.print(x + " : ");
			System.out.println(count[i]);
		}

	}

}

Measured memory_bytes: 26036
#include <bits/stdc++.h>
using namespace std;
#define cout (cout<<fixed<<setprecision(10))
int main(){
  int N;
  cin>>N;
  vector<int> P(N), Q(N);
  for(int i=0; i<N; i++){
    cin>>P[i];
  }
  for(int i=0; i<N; i++){
    cin>>Q[i];
  }
  vector<int> L;
  for(int i=1; i<=N; i++){
    L.push_back(i);
  }

  int a, b, i=0;
  do{
    if(L==P)a = i;
    if(L==Q)b = i;
    i++;
  }while(next_permutation(L.begin(), L.end()));

  cout<<abs(a-b)<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int tax_ex = (int) Math.ceil(n/1.08);
        int tax_in = (int) Math.floor(tax_ex*1.08);
        System.out.println(n==tax_in ? tax_ex : ":(");
    }
}

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}

int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int n=0,count=0;
  vector<string> a(3);
  rep(i,3) cin>>a[i],a[i].push_back('0'),reverse(a[i].begin(),a[i].end());
  while(true){
    if(a[count][a[count].size()-1]=='a'){
      a[count].pop_back();
      count=0;
    }else if(a[count][a[count].size()-1]=='b'){
      a[count].pop_back();
      count=1;
    }else if(a[count][a[count].size()-1]=='c'){
      a[count].pop_back();
      count=2;
    }else if(a[count][a[count].size()-1]=='0'){
      if(count==0){
        cout<<'A'<<endl;
        return 0;
      }else if(count==1){
        cout<<'B'<<endl;
        return 0;
      }else if(count==2){
        cout<<'C'<<endl;
        return 0;
      }
    
    }
  }
  
  
  
  
  
  
  
  
}
///////////////////////////

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

int main() {

	int N, A, B;
	cin >> N;
	cin >> A;
	cin >> B;

	if (A*N >= B) {
		cout << B << endl;
	}
	else {
		cout << A * N << endl;
	}

	return 0;
}

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

int countFlip(const string& str) {
	int cnt = 0;
	char c = str[0];
	for (unsigned i = 1; i < str.size(); i++) {
		if (c != str[i]) {
			cnt++;
			c = str[i];
		}
	}
	return cnt;
}

int main () {
	string field;
	cin >> field;
	
	int c = countFlip(field);
	if (c & 1) {
		cout << 'o' << endl;
	}
	else {
		cout << field[0] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1176
#include <stdio.h>

int max(int a, int b, int c) {
	if (a >= b && a >= c) return a;
	else if (b >= a && b >= c) return b;
	else if (c >= a && c >= b) return c;
}

int main() {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	
	int m = max(a, b, c);
	if (m == a + b + c - m) puts("Yes");
	else puts("No");

	return 0;
}

Measured memory_bytes: 128