akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  int H, W, K;
  cin >> H >> W >> K;
  vector<string> dmap(H);
  rep(i, H) {
    cin >> dmap[i];
  }
  
  vvi res(H, vi(W));
  
  int fh = 0;
  rep(h, H) {
    bool f = false;
    rep(w, W) {
      if(dmap[h][w] == '#') {
        fh = h;
        f = true;
        break;
      }
    }
    if(f) break;
  }
  
  int col = 1;
  
  //横に分ける
  for(int h=fh; h<H; h++) {
    int found = 0;
    rep(w, W) {
      if(dmap[h][w] == '#') {
        found++;
      }
    }
    if(found > 0) {
      int cf = 0;
      rep(w, W) {
        res[h][w] = col;
        if(dmap[h][w] == '#') {
          //wまでを塗る
          cf ++;
          if(found > cf) {
            col ++;
          }
        }
      }
      col ++;
    } else {
      rep(w, W) {
        res[h][w] = res[h-1][w];
      }
    }
  }
  
  for(int h=fh-1; h>=0; h--) {
    rep(w, W) {
      res[h][w] = res[h+1][w];
    }
  }
  
  rep(h, H) {
    rep(w, W) {
      cout << res[h][w] << " ";
    }
    cout << endl;
  }
}

Measured memory_bytes: 1280
N = int(input())
A = [int(_) for _ in input().split()]

s = [0]
for i in range(N):
  s.append(s[i] + A[i])

s.sort()
count = 0
c = 1
for i in range(N):
  if s[i] == s[i + 1]:
    c += 1
  else:
    count += c * (c - 1) // 2
    c = 1
count += c * (c - 1) // 2

print(count)

Measured memory_bytes: 26716
def solve():
  a,b,k = (int(i) for i in input().split())
  caneat = min(k,a+b)
  ans = [0,b]
  if a <= caneat:
    ans[0] = 0
    ans[1] = b-(caneat-a)
  else:
    ans[0] = a-caneat
  print(*ans)
solve()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  int N;cin>>N;
  cout<<360/__gcd(360,N)<<endl;
  return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;


int main(){
  int A,B;
  cin>>A>>B;
  cout<<6-A-B<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define llt long long int

using namespace std;
int main()
{
    int n;
    int res = 0;
    int mn = 1;
    cin >> n;

    for (int i = 1; i <= n; i++)
    {
        int idx = i;
        int cnt = 0;
        while (idx % 2 == 0)
        {
            idx /= 2;
            cnt++;
        }
        if (cnt > res)
        {
            res = cnt;
            mn = i;
        }
    }

    cout << mn << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7;
int a[N];
int f[10]={0,0,9,0,909,0,90909,0};
int getbit(int n){
	if(n<10) return 1;
	else if(n<100) return 2;
	else if(n<1000) return 3;
	else if(n<10000) return 4;
	else if(n<100000) return 5;
	else if(n<1000000) return 6;
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	int fg=0;
	int mn=0;
	for(int i=1;i<n;++i){
		if(a[i]>a[i+1]){
			mn=max(mn,a[i]);		
			fg=max(max(a[i]-a[i+1],fg),mn-a[i+1]);
			if(fg>=2) break;
		}
	}
	if(fg>=2) printf("No\n");
	else printf("Yes\n");
	return 0;
}

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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int N; cin >>N;
    vector<ll> a(N);
    vector<ll> s(N+1);
    s[0] = 0;
    rep(i, N) {
        cin >> a[i];
        s[i+1] = s[i] + a[i];
    }
    // cout_h(s);
    ll ans = LLONG_MAX;
    rep1(i, N) {
        ll x = s[i];
        ll y = s[N] - s[i];
        // cout << FMT2(x, y)<<endl;
        chmin(ans, abs(x-y));
    }

    cout << ans << endl;
}


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

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

  int n;
  cin >> n;

  vector<vector<pair<int,int>>> state(n);

  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;

    for (int j = 0; j < a; ++j) {
      int x, y;
      cin >> x >> y;

      state[i].emplace_back(x-1, y);
    }
  }

  int ans = 0;

  for (int bit = 0; bit < (1<<n); ++bit) {
    vector<int> honest;
    for (int i = 0; i < n; ++i) if (bit & (1<<i)) honest.emplace_back(i);

    bool ok = true;
    for (auto p : honest) {
      for (auto s : state[p]) {
        if (s.second && find(honest.begin(), honest.end(), s.first) == honest.end()) ok = false;
        else if (s.second == 0 && find(honest.begin(), honest.end(), s.first) != honest.end()) ok = false;
      }
    }

    if (ok) ans = max(ans, (int)honest.size());
  }

  cout << ans << '\n';

  return (0);
}

Measured memory_bytes: 3660
#include <array>
#include <iostream>
#include <map>
#include <vector>

inline constexpr std::size_t MaxValue = 100'000;

int
main()
{
    std::ios::sync_with_stdio(false);

    std::size_t valueCount;
    std::cin >> valueCount;

    std::vector<int> values(valueCount);

    for (std::size_t i = 0; i<valueCount; ++i)
    {
        std::cin >> values[i];
    }

    std::size_t operationCount;
    std::cin >> operationCount;

    std::vector<int> oldValues(operationCount);
    std::vector<int> newValues(operationCount);

    for (std::size_t i = 0; i<operationCount; ++i)
    {
        std::cin >> oldValues[i];
        std::cin >> newValues[i];
    }

    long long sum = 0;
    std::vector<int> valueCounts(MaxValue+1, 0);
    for (auto &value : values)
    {
        valueCounts[value] += 1;
        sum += value;
    }

    for (std::size_t i = 0; i<operationCount; ++i)
    {
        auto oldValue = oldValues[i];
        auto newValue = newValues[i];

        auto count = valueCounts[oldValue];
        if (count==0)
        {
            std::cout << sum << "\n";
            continue;
        }

        sum -= static_cast<long long>(oldValue)*count;
        sum += static_cast<long long>(newValue)*count;
        valueCounts[oldValue] = 0;
        valueCounts[newValue] += count;

        std::cout << sum << "\n";
    }
}


Measured memory_bytes: 4804
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll n;cin>>n;
    ll x=n,s=0;
    while(x>0){
        s+=x%10;
        x/=10;
    }
    if(n%s==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int main()
{
	char c;
	cin >> c;
    
	if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') cout << "vowel" << endl;
	else cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define EQ(a,b) (abs((a)-(b))<EPS)
int ans=0;
int main()
{
	string s1,s2;
	while(cin >> s1 >> s2)
	{
		ans=0;
		for(int i=0;i<s1.size();i++)
		{
			int cnt=0;
			for(int j=0;j<min(s1.size()-i,s2.size());j++)
			{
				if(s2[j]==s1[j+i])
				{
					cnt++;
					ans=max(ans,cnt);	
				}
				else
				{
					cnt=0;
				}
			}
		}
		for(int i=0;i<s2.size();i++)
		{
			int cnt=0;
			for(int j=0;j<min(s2.size()-i,s1.size());j++)
			{
				if(s1[j]==s2[j+i])
				{
					cnt++;
					ans=max(ans,cnt);
				}
				else
				{
					cnt=0;
				}
			}
		}
		cout << ans << endl;
		s1.clear();
		s2.clear();
	}
	return 0;
}

Measured memory_bytes: 1208
#include <iostream>

using namespace std;

const long long MOD = 1000000007;
long long factorial[200000], invFactorial[200000];

long long power(long long x, long long y) {
    long long ans = 1;

    while (y) {
        if (y & 1) {
            ans = ans * x % MOD;
        }

        x = x * x % MOD;
        y >>= 1;
    }

    return ans;
}

long long combination(long long n, long long r) {
    return factorial[n] * invFactorial[r] % MOD * invFactorial[n-r] % MOD;
}

int main() {
    int h, w, a, b;

    cin >> h >> w >> a >> b;

    factorial[0] = 1;

    for (int i = 1; i <= h+w-2; i++) {
        factorial[i] = factorial[i-1] * i % MOD;
    }

    for (int i = 0; i <= h+w-2; i++) {
        invFactorial[i] = power(factorial[i], MOD-2);
    }

    long long ans = 0;

    for (int i = 0; i < h-a; i++) {
        ans += combination(b-1+i, b-1) * combination(h+w-b-2-i, w-b-1) % MOD;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    rep(i, M){
        cin >> A.at(i);
    }

    int ans = 0;
    rep(i, M){
        N -= A.at(i);
    }
    if(N < 0){
        N = -1;
    }

    cout << N << endl;
    
    return 0;
}


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

#define MAX_LUGGAGE_NUM    100000
#define MAX_TRUCK_NUM      100000

static int BinarySearch(int *weight_buff, int luggage_num, int truck_num, int mid);

/***********************************************************************************
 ++module <main>
 ++outline
	main function
 ++arguments
	<>			<>					[]
 ++supp
 	<return>
 	  nothing
 ++end_module
************************************************************************************/
int main(void)
{
    int left = 0;
	int right;
	int mid;
	int sum = 0;
	int ans;
	int luggage_num;		/* luggage num */
	int truck_num;			/* truck num */
	int *weight_buff;		/* luggage weight buffer */
	int loop = 0;
	
	scanf("%d %d", &luggage_num, &truck_num);			/* get luggage num and truck num */
	
	if((luggage_num <= MAX_LUGGAGE_NUM)					/* If luggage num is within max luggage num */
		&& (truck_num <= MAX_TRUCK_NUM))
	{
		weight_buff = (int*)malloc(luggage_num * sizeof(int));
		
		while(((scanf("%d", &(weight_buff[loop]))) != EOF) && (loop < luggage_num))
		{
			sum += weight_buff[loop];
			loop++;
		}
		right = sum;
		
		while(right - left > 1)
		{
	        mid = (right + left) / 2;
			ans = BinarySearch(weight_buff, luggage_num, truck_num, mid);
	        if(ans >= luggage_num)
			{
	            right = mid;
			}
			else
			{
	            left = mid;
			}
		}
    }
    printf("%d\n",right);
	
    return 0;
}

static int BinarySearch(int *weight_buff, int luggage_num, int truck_num, int mid)
{
	int sum;
	int weight_point = 0;
	int loop;
	
	for(loop = 0; loop < truck_num; loop++ )
	{
		sum = 0;
		while((sum + weight_buff[weight_point] <= mid)
			&& (weight_point < luggage_num))
		{
			sum += weight_buff[weight_point];
			weight_point++;
		}
		if(weight_point == luggage_num)
		{
			break;
		}
	}
	return weight_point;
}


Measured memory_bytes: 2244
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    S = read_int() # 10^18
    # X <= 10^9
    # 10**9*Y3-X3=S
    low, high = 0, 10**9
    while high-low > 1:
        mid = low+(high-low)//2
        if 10**9*mid >= S:
            high = mid
        else:
            low = mid
    Y3 = high
    X3 = 10**9*Y3-S
    return 0, 0, 10**9, 1, X3, Y3


if __name__ == '__main__':
    print(*solve())


Measured memory_bytes: 61960
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int n = sc.nextInt();
            if (n == 0)
                break;
            int max = 0;
            Map<Integer, Integer> map = new HashMap<Integer, Integer>();
            for (int i = 0; i < n; i++) {
                int num = sc.nextInt();
                int d = sc.nextInt() + sc.nextInt();
                map.put(d, num);
                max = Math.max(max, d);
            }
            System.out.println(map.get(max) + " " + max);
        }
    }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){

  ll A,B;
  IN(A,B);

  if(A<=5) OUT(0);
  else if(A<=12) OUT(B/2);
  else OUT(B);

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
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; }

const long long INF=1LL<<60;

int main(){
    int n,k;
    cin>>n>>k;
    long long h[100010];
    for(int i=0;i<n;++i) cin>>h[i];

    long long dp[100010];
    for(int i=0;i<n;++i) dp[i]=INF;
    dp[0]=0;
    for(int i=0;i<n;++i){
        for(int j=1;j<=k&&i+j<n;++j){
            chmin(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
        }
    }
    
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int, n);
	VAR(double, t, a);
	VEC(double, h, n);

	int ans;
	double d = INF;
	REP(i, n) {
		double tmp = t - h[i] * 0.006;
		if (abs(a - tmp) < d) {
			ans = i + 1;
			d = abs(a - tmp);
		} 
	}
	OUT(ans)BR;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int MOD = 1000000007;

long long modPow(int a, int p){
	if(p == 0) return 1;
	long long res = modPow(a, p/2);
	res *= res;
	res %= MOD;
	if(p%2){
		res *= a;
		res %= MOD;
	}
	return res;
}

int main(){
	int N, K;
	while(cin >> N >> K){
		if(N == 1){
			cout << K << endl;
			continue;
		}
		vector<int> d;
		for(int i=1;i*i<=N;++i){
			if(N%i == 0){
			   d.push_back(i);
			   if(N/i != i) d.push_back(N/i);
			}
		}
		sort(d.begin(), d.end());
		vector<long long> num(d.size(), 0);
		long long res = 0;
		for(int i=0;i<d.size();i++){
			long long cycle = d[i];
			num[i] = modPow(K, (cycle+1)/2);
			for(int j=0;j<i;j++){
				if(cycle%d[j] == 0) num[i] = (num[i]+MOD-num[j])%MOD;
			}
			if(cycle%2 == 0) cycle /= 2;
			res += num[i] * cycle;
			res %= MOD;
		}
		cout << res << endl;
	}
}



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

int main(){
    int h,w;
    cin >> h >> w;
    int s[h+2][w+2] = {};
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            char c;
            cin >> c;
            if(c == '#') s[i][j] = 1;
        }
    }
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            if(s[i][j] == 1){
                if(s[i-1][j] + s[i+1][j] + s[i][j-1] + s[i][j+1] == 0){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<string, int> dict;
string a;
int main(){
	dict["SUN"] = 7;
	dict["MON"] = 6;
	dict["TUE"] = 5;
	dict["WED"] = 4;
	dict["THU"] = 3;
	dict["FRI"] = 2;
	dict["SAT"] = 1;
	cin>>a;
	cout<<dict[a];
	return 0;
}


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

int main() {
    string S;
    cin >> S;

    int res = 0;
    for (int i = 0; i < 4; i++) {
        if (S.at(i) == '+') {
            res++;
        }
        else {
            res--;
        }
    }

    cout << res << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> data(N);
  for(int i = 0; i < N; i++) {
    cin >> data.at(i);
  }
  if(N == 1) {
    cout << 1 << endl;
    return 0;
  }
  sort(data.begin(), data.end());
  if(data.at(0) == 1) {
    if(data.at(1) != 1) {
      cout << 1 << endl;
      return 0;
    }
    else {
      cout << 0 << endl;
      return 0;
    }
  }
  set<int> keep;
  keep.insert(data.at(0));
  set<int> multi;
  for(int i = 1; i < N; i++) {
    if(data.at(i) == data.at(i - 1)) {
      if(!multi.count(data.at(i))) {
        multi.insert(data.at(i));
      }
    }
    else {
      keep.insert(data.at(i));
    }
  }
  int ans = 0;
  for(int i = 0; i < N; i++) {
     if(i == 0) {
      if(data.at(i) == data.at(i + 1)) {
        continue;
      }
      else {
        ans++;
      }
    }
    else if(i == N - 1 && data.at(i - 1) == data.at(i)) {
      continue;
    }
    else if(i != N - 1 && (data.at(i - 1) == data.at(i) || data.at(i) == data.at(i + 1))) {
      continue;
    }
    else {
      bool check = true;
      for(int j = 2; j * j <= data.at(i); j++) {
        if(data.at(i) % j == 0) {
          if(keep.count(j) || keep.count(data.at(i) / j)) {
            check = false;
            break;
          }
        }
      }
      if(check && !multi.count(data.at(i))) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 13468
#include<stdio.h>
#include<math.h>
int n;



double distance(double x1,double y1,double x2,double y2){
  return sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
}

void compute(int depth,double x1,double y1,double x2,double y2,int flg){
  double si60 = sqrt(3.0)/2.0;
  double co60 = 0.5;
  
  double sx = (x1+x1+x2)/3.0;
  double sy = (y1+y1+y2)/3.0;
  double tx = (x1+x2+x2)/3.0;
  double ty = (y1+y2+y2)/3.0;
  
  double vx = tx-sx;
  double vy = ty-sy;//distance(x1,y1,x2,y2) / 3.0 /2.0 * sqrt(3.0);
  
  double ux = sx + co60*vx - si60*vy;
  double uy = sy + si60*vx + co60*vy;
  
  //printf("%.8f %.8f\n",x2,y2);
  if(depth>=n)return;
  


  
  compute(depth+1,x1,y1,sx,sy, 0);
  printf("%.8f %.8f\n",sx,sy);  
  compute(depth+1,sx,sy,ux,uy, 0);
  printf("%.8f %.8f\n",ux,uy);
  compute(depth+1,ux,uy,tx,ty, 0);
  printf("%.8f %.8f\n",tx,ty);    
  compute(depth+1,tx,ty,x2,y2, 0);

  
}

int main(){
  scanf("%d",&n);
  printf("%.8f %.8f\n",0.0,0.0);
  compute(0,0.0,0.0,100.0,0.0,0);
  printf("%.8f %.8f\n",100.0,0.0);
  return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define OUT(x)                cout << #x << " = " << x << endl
#define rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r)          for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r)          for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << *i << " "; cout << endl; }
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int in() { int x; scanf("%d", &x); return x; }
long long lin() { long long x; scanf("%lld", &x); return x; }

signed main() { 
        string s;
        cin >> s;
        int cnt[26] = { 0 };
        bool ans = true;
        rep(i, s.size()) cnt[s[i] - 'a'] ++;
        rep(i, 26) if (cnt[i] >= 2) ans = false;
        cout << (ans ? "yes" : "no") << endl;
        return 0;
}               



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

int main(){
  int n;
  cin >> n;
  int result = 0;

  int i;
  for(i = 0; i < n; i++){
    int l, r;
    cin >> l >> r;
    result += r - l + 1;
  }

  cout << result << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>

using namespace std;

void read(int &v){int k=0,l=1;char ch;ch=getchar();while (ch>'9' || ch<'0'){if (ch=='-') l=-1;ch=getchar();}while (ch>='0' && ch<='9') k=k*10+ch-'0',ch=getchar();v=l*k;}
void print(int v){if (v<0) putchar('-'),v=-v;if (v>9) print(v/10);putchar(v%10+'0');}
int max(int a, int b) { return a>b ? a: b;}
int min(int a, int b) { return a<b ? a: b;}

static int x, y, z;

int main() {
        read(x), read(y), read(z);
        print(min(x * y, z));
        return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int main(){
    int m,k;cin>>m>>k;
    ll n=1;
    int cnt=0;
    while(cnt<m){
        n*=2;
        cnt++;
    }
    if(n-1<k){
        cout<<-1<<endl;
    }
    else{
        if(m==0){
            if(k!=0)cout<<-1<<endl;
            else cout<<0<<" "<<0<<endl;
        }
        else if(m==1){
            if(k!=0){
                cout<<-1<<endl;  
            }
            else cout<<0<<" "<<0<<" "<<1<<" "<<1<<endl;
        }
        else{
            vi a(n*2,0);
            if(k==0){
                int l=0;
                for(int i=0;i<n*2;i+=2){
                    a[i]=l;
                    a[i+1]=l;
                    l++;
                }
            }
            else{
            a[1]=k;
            a[n*2-1-(n-2)]=k;
            int l=1;
            for(int i=1;i+n*2-1-(n-2)<n*2;++i){
                if(l==k)l++;
                a[n*2-1-(n-2)+i]=l;
                a[n*2-1-(n-2)-i]=l;
                l++;
            }}
            rep(i,n*2){
                if(i!=n*2-1)cout<<a[i]<<" ";
                else cout<<a[i]<<endl;
            }
        }
    }
}

Measured memory_bytes: 4276
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] tmp = br.readLine().split(" ");
        int N = Integer.parseInt(tmp[0]); //お札の枚数
        int Y = Integer.parseInt(tmp[1]); //金額
        int x = -1; 
        int y = -1;
        int z = -1; // x,y,z それぞれ１００００円、５０００円、１０００円
        if(Y >= 100000){
            for (int i=0; i<=N; i++){
                for (int j=0; j<=N-i; j++){
                    if(Y == 10000*i + 5000*j + 1000*(N-i-j)){
                        x = i;
                        y = j;
                        z = N-i-j;
                    }
                }
            }
        } else {
            for (int i=0; i<=N; i++){
                for (int j=0; j<=N-i; j++){
                    if(Y == 1000*i + 5000*j + 10000*(N-i-j)){
                        z = i;
                        y = j;
                        x = N-i-j;
                    }
                }
            }
        }
        System.out.println(x + " " + y + " " + z);
    }
}

Measured memory_bytes: 23380
#include<cstdio>
const int MAXN=1e5+5;
int n,h,a[MAXN];
int sum;
int main(){
	scanf("%d%d",&h,&n);
	for(int i=1; i<=n; i++)
		scanf("%d",a+i),sum+=a[i];
	if(sum<h) puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

void sort( int *p ){
  int i;
  int a = 1;
  int temp;
  
  
  while( a ){
    a = 0;
    for( i = 0; i < 10; i++ ){
       if( p[i] < p[i+1] ) {
          temp = p[i];
          p[i] = p[i+1];
          p[i+1] = temp;
          a++;
       }
    }
  }
}   
      
  

int main(void)
{
  int height[10];
  int i;
  for( i = 0; i < 10; i++ ){
    scanf("%d",&height[i]);
  }
  
  sort( height );  

 for( i = 0; i < 3; i++ ){
    printf("%d\n", height[i]);
 } 
  
 
 
  return 0;
}       
    

Measured memory_bytes: 600
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if 500*i + 100*j + 50*k == x:
                cnt += 1
print(cnt)


Measured memory_bytes: 3060
s = list(input())
k = int(input())

if len(set(s)) == 1:
    print((len(s)*k)//2)
    exit()

def n_change(sss):
    s = sss.copy()
    x = 0
    for i in range(1, len(s)):
        if s[i] == s[i-1]:
            s[i] = "X"
            x += 1
    return x

print(n_change(s) + (k-1) * (n_change(2*s) - n_change(s)))

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

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

int main() {
    #ifdef LOCAL
        freopen("Data.inp", "r", stdin);
        freopen("Data.out", "w", stdout);
    #endif

    string S;
    cin >> S;

    S.insert(4, " ");
    cout << S << "\n";
    return 0;
}


Measured memory_bytes: 256
import bisect
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort()
b.sort()
c.sort()

res = 0

for y in b:
    i = bisect.bisect_left(a, y)
    j = bisect.bisect_right(c, y)
    res += i * (n - j)

print(res)



Measured memory_bytes: 23156
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int a[] = new int[n];

		for (int i = 0; i < n; i++)
			a[i] = (stdIn.nextInt() * 60) + stdIn.nextInt();

		int m = stdIn.nextInt();
		int b[] = new int[m];

		for (int i = 0; i < m; i++)
			b[i] = (stdIn.nextInt() * 60) + stdIn.nextInt();
		int c[] = new int[n + m];
		for (int i = 0; i < n; i++) {
			c[i] = a[i];
		}
		for (int i = 0; i < m; i++) {
			c[i + n] = b[i];
		}
		Arrays.sort(c);
		int co = 0;
		for (int i = 1; i < c.length; i++) {
			if (c[i] == c[i - 1]) {
				c[i - 1] = 0;
				co++;
			}
		}
		Arrays.sort(c);
		int a1[] = new int[n + m];
		int a2[] = new int[n + m];
		for (int i = 0; i < n + m; i++) {
			a1[i] = c[i] / 60;
			a2[i] = c[i] % 60;
		}
		for (; co < n + m; co++) {

			System.out.print(a1[co] + ":");
			if (a2[co] < 10)
				System.out.print("0");
			System.out.print(a2[co]);
			if (co != n + m - 1)
				System.out.print(" ");
		}

		System.out.println();
	}
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb push_back 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=1000000000000000;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> divisor(ll x){vector<ll> div;
	for(ll i=1;i*i<=x;i++){if(x%i==0){div.pb(i);if(i*i!=x)div.pb(x/i);}}
	sort(div.bg,div.ed);return div;}
	
vector<ll> Next[200001];
vector<ll> point(200001,0);

void dfs(ll x){
	if(Next[x].sz==0) return;
	else{
		rep(i,Next[x].sz){
			point[Next[x][i]]+=point[x];
			dfs(Next[x][i]);
		}
	}

}

int main(){
	ll N,Q; cin>>N>>Q;
	rep(i,N-1){
		ll A,B; cin>>A>>B;
		Next[A].pb(B);
	}
	rep(i,Q){
		ll p,x; cin>>p>>x;
		point[p]+=x;
	}
	dfs(1ll);
	rep1(i,N){
		cout<<point[i]<<" ";
	}
}

Measured memory_bytes: 24320
a=input()
p=[]
r=0
rp=0
l=0
lp=0
x="R"
y="L"
s=0
for i in range(len(a)):
  p.append(0)
  if s==0:
    if a[i]==x:
      rp=i
      r+=1
    else:
      p[i]+=r//2
      p[rp]+=r-p[i]
      lp=i
      l=0
      s=1
  if s==1:
    if a[i]==y:
       l+=1
    else:
      g=l//2
      p[rp]+=g
      p[lp]+=l-g
      rp=i
      r=1
      s=0
g=l//2
p[rp]+=g
p[lp]+=l-g
e=""
for i in p:
  e+=str(i)+" "
print(e)

Measured memory_bytes: 4604
#include <bits/stdc++.h>
#define int  __int128
#define ff first
#define dd second
#define mp make_pair
#define pb push_back
#define pp pair<int,int>
#define N 200007 // check
#define M 1007
#define K 130
#define endl "\n"
using namespace std;

int n, t;

int tab[N];
int x;
int k = 1e18;
int inf = k*k;
int pref[N];

int get(int a, int b) {
    return pref[b+1]-pref[a];
}

int pot[N];

int price(int ile) {
    int res = 0;
    int ind = n-1;
    int kk = 1;
    while(ind >= 0) {
        int r = ind;
        int l = max(ind - ile + 1, (int)0);
        res += get(l,r)*pot[kk];
        if(kk == 1) res += get(l,r);
        kk++;
        ind = l-1;
    }
    return res;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    int64_t temp; cin >> temp; n = temp;
    cin >> temp; x = temp;
    pref[0] = 0;
    pot[0] = 0;
    pot[1] = 4;
    for(int i = 2; i <= n; ++i) {
        pot[i] = 1 + 2*i;
    }
    for(int i = 0; i < n; ++i) {
        cin >> temp; tab[i] = temp;
        pref[i+1] = pref[i] + tab[i];
    }
    int mini = inf;
    for(int ile = 1; ile <= n; ++ile) {
        mini = min(mini, x*ile+n*x + price(ile));
        //cout << "ile " << ile << " " << (ile+n)*x  << " pr " << price(ile) << endl;
    }
    //price(1);
    temp = mini;
    cout << temp << endl;
}

Measured memory_bytes: 9600
#include<iostream>
#include<vector>
#include<map>
using namespace std;
 
typedef pair<int,int> P;
 
int n,m;
vector<P> g[500];
int a,b,c;
int d[500];
 
int rec(int v){
  if(d[v]>=0)return d[v];
 
  int res = 0;
  for(int i=0;i<g[v].size();i++){
    res = std::max(res,g[v][i].first + rec(g[v][i].second));
  }
  return d[v] = res;
}
 
int main(){
  cin >> n >> m;
  for(int i=0;i<m;i++){
    cin >> a >> b >> c;
    g[b].push_back(P(c,a));
  }
 
  for(int i=0;i<n;i++)d[i]=-1; d[0] = 0;
  cout << rec(n-1) << endl;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e2 + 7;
const int Inf = 1 << 30;
int n, m;
string s[maxx], t[maxx];
int ans;

map <string, int> mp1;
map <string, int> mp2;

int main() {
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> s[i];
		mp1[s[i]]++;
	}
	cin >> m;
	for(int i = 1; i <= m; i++) {
		cin >> t[i];
		mp2[t[i]]++;
	}
	for(int i = 1; i <= n; i++) {
		mp1[s[i]] -= mp2[s[i]];
		ans = max(ans, mp1[s[i]]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <string>
using namespace std;
#define LL long long
#define mp make_pair
#define fr first
#define sc second
#define pb push_back
#define lc (x<<1)
#define rc ((x<<1)|1)
const int N=100005,M=200005;
int v[M],nxt[M],point[N],bs;
int a[N],b[N],vis[N],tot,FF;
void addedge(int x,int y){
    bs++;v[bs]=y;nxt[bs]=point[x];point[x]=bs;
    bs++;v[bs]=x;nxt[bs]=point[y];point[y]=bs;
}
void dfs(int x){
    if (FF) return;
    int ff=0;a[++tot]=x;vis[x]=1;
    for (int p=point[x];p;p=nxt[p])
     if (!vis[v[p]]) {dfs(v[p]);ff=1;}
    if (!ff) FF=1;
}
int main(){
   // freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
    int i,n,m,t1,t2;
    scanf("%d%d",&n,&m);
    for (i=1;i<=m;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        addedge(x,y);
    }
    tot=0;FF=0;dfs(1);t1=tot;
    for (i=1;i<=t1;i++) b[i]=a[i];
    tot=0;FF=0;dfs(1);t2=tot;
    printf("%d\n",t1+t2-1);printf("%d",a[t2]);
    for (i=t2-1;i>=1;i--) printf(" %d",a[i]);
    for (i=2;i<=t1;i++) printf(" %d",b[i]);
    puts("");
  //  system("pause");
    return 0;
}


Measured memory_bytes: 4736
a,b,k = [ int(it) for it in input().split() ]

kk = 1
for i in range(max(a,b),0,-1):
  if ( a%i==0 and b%i==0 ):
    if ( kk == k ):
      print (i)
      kk += 1
    else:
      kk += 1
  

Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

ll C[2005][2005];
ll dp[100005][13];

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

int main(){
    ll K, ans = 0;
    cin >> K;
    for(int i=1; i<=K; i++){
        for(int j=1; j<=K; j++){
            for(int k=1; k<=K; k++){
                ans += gcd(gcd(i,j),k);
            }
        }   
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#define pb  push_back 
using namespace std;
int main(){
  vector<int> gdnum;
  for(int i=1;i<=300000;i++){
    if(i%7==1||i%7==6)
    gdnum.pb(i);
  }

  int n=gdnum.size();
  // cout<<n<<endl;
  vector<int> p(gdnum[gdnum.size()-1]+10);
  vector<int> prime;
  for(int i=0;i<n;i++){
    p[gdnum[i]]++;
  }
  p[1]=0;
  n=gdnum[gdnum.size()-1];
  for(int i=0;i<=n;i++){
    if(p[i]){
      prime.pb(i);
      //cout<<i<<endl;
      for(int j=i*2;j<=(long long)n;j+=i){
	p[j]=0;
	//cout<<"lllll"<<endl;
      }
    }
  }
  int k;
  while(cin>>k,k!=1){
    cout<<k<<":";
    for(int i=0;i<prime.size();i++){
      if(k%prime[i]==0){
	cout<<" "<<prime[i];
      }
    }
    cout<<endl;
  }

  
  return 0;
}

Measured memory_bytes: 3040
Scanf.scanf "%d %d" (fun n k ->
    let m = 1_000_000_007 in

    let extgcd x y =
        let rec eg r0 r1 a0 a1 b0 b1 =
            if r1 = 0 then a0, b0 else
                let q1 = r0 / r1 in
                eg r1 (r0 mod r1) a1 (a0 - q1 * a1) b1 (b0 - q1 * b1)
        in
        eg x y 1 0 0 1
    in

    let inv x y = (* 1/x in mod y *)
        let c, d = extgcd x y in
        if c < 0 then c + y else c
    in
    let ( +@) a b = (a + b) mod m in
    let ( -@) a b = (((a - b) mod m) + m) mod m in
    let ( *@) a b = ((a mod m) * (b mod m)) mod m in
    let ( /@) a b = a *@ inv b m in
    let rec loop i r1 r2 a b acc =
        if i > n || i > k then acc else (
            let acc = acc +@ r1 *@ r2 in
            let r1 = r1 *@ a /@ b in
            let r2 = r2 *@ (a - 1) /@ b in
            let a = a - 1 in
            let b = b + 1 in
            loop (i + 1) r1 r2 a b acc
        )
    in
    loop 0 1 1 n 1 0 |> Printf.printf "%d\n"
)

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(n) n.begin(),n.end()
#define yn(x) cout << (x ? "Yes":"No") << endl;

int main() {
  ll n;
  cin >> n;
  map<string,ll>memo;
  vector<string>s(n);
  rep(i,n) {
    cin >> s.at(i);
    memo[s.at(i)] += 1;
  }
  cout << memo.size() << endl;
  
  
}

Measured memory_bytes: 25172
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

int root(std::vector<int>& v, int x) {
    if (v[x] == x) return x;
    else return (v[x] = root(v, v[x]));
}

bool same(std::vector<int>& v, int x, int y) {
    return root(v, x) == root(v, y);
}

void unite(std::vector<int>& v, int x, int y) {
    x = root(v, x);
    y = root(v, y);
    if (x == y) return;
    v[x] = y;
}

int main() {
    int n, m;
    std::cin >> n >> m;
    std::vector<int> p(n+1);
    std::vector<int> uf(n + 1);
    for (int i = 0; i < n + 1; i++) uf[i] = i;
    for (int i = 1; i <= n; i++) std::cin >> p[i];
    int tx, ty;
    for (int i = 0; i < m; i++) {
        std::cin >> tx >> ty;
        unite(uf, tx, ty);
    }
    int count = 0;
    for (int i = 1; i <= n; i++) {
        if (same(uf, p[i], i)) count++;
    }

    std::cout << count << std::endl;

    return 0;
}


Measured memory_bytes: 1024
n, y = map(int, input().split())

for i in reversed(range(n + 1)):
    for j in reversed(range(n - i + 1)):
        k = n - i - j
        if 10000 * i + 5000 * j + 1000 * k == y:
            print(i, j, k)
            exit()
else:
    print(-1, -1, -1)


Measured memory_bytes: 2940
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        int K = in.i();
        int N  = in.i();
        int[] A = in.ii(N);
        int max = A[0] + K - A[N-1];
        for(int i = 0; i < N-1; i++){
            int tmp = A[i+1] - A[i];
            if (max < tmp) {
                max = tmp;
            }
        }
        out.println(K - max);
    }

    static class MyReader extends BufferedReader {
        char[] cbuf = new char[1024];
        int head = 0;
        int tail = 0;

        MyReader(){
            super(new InputStreamReader(System.in));
        }

        char next() {
            if (head == tail) {
                try {
                    tail = read(cbuf, 0, cbuf.length);
                } catch (IOException e) {}
                head = 0;
            }
            return cbuf[head++];
        }

        void back() {
            head--;
        }

        boolean minus() {
            boolean minus;
            while (true) {
                char c = next();
                if (c != ' ' && c != '\n' && c != '\r') {
                    if (!(minus = c == '-')) back();
                    return minus;
                }
            }
        }

        void skip() {
            while (true) {
                char c = next();
                if (c != ' ' && c != '\n' && c != '\r') {
                    back();
                    break;
                }
            }
        }

        char[] s(final int N) {
            skip();
            char[] s = new char[N];
            for (int i = 0; i < s.length; i++) {
                s[i] = next();
            }
            return s;
        }

        int i() {
            boolean minus = minus();
            int n = 0;
            while (true) {
                int k = next() - '0';
                if (k < 0 || 9 < k) break;
                n = 10 * n + k;
            }
            return minus ? -n : n;
        }

        int[] ii(final int N) {
            int[] a = new int[N];
            for (int j = 0; j < a.length; j++) a[j] = i();
            return a;
        }

        long l() {
            boolean minus = minus();
            long n = 0;
            while (true) {
                int k = next() - '0';
                if (k < 0 || 9 < k) break;
                n = 10 * n + k;
            }
            return minus ? -n : n;
        }
    }
}


Measured memory_bytes: 36268
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>
#include <cstdlib>
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;
using ll = long long;
const int INF = 1e9 + 5;

void print_vector2(vector<vector<ll> >v){
    for(ll i=0;i<v.size();i++){
        for(ll j=0;j< v[i].size();j++){
            cout<<v[i][j]<<" ";
        }cout<<"\n";
    }
}

void print_vector1(vector<ll> v){
    for(ll i=0; i<v.size();i++){
        cout<<v[i]<<" ";
    }cout<<"\n";
}

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

int main(){
    ll d, t, sum=0;
    cin>>d>>t;
    for(ll i=0; i<t; i++){
        ll temp;
        cin>>temp;
        sum = sum + temp;
    }
    if(d-sum>=0){
        cout<<d-sum;
    }
    else{
        cout<<"-1";
    }
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	int n;
	cin>>n;
	string s[n];
	map<string,int> m;
	rep(i,n){
		cin>>s[i];
		m[s[i]]++;
	}
	int mx=0;
	foreach(itr,m){
		mx=max(mx,itr->se);
	}
	vector<string> g;
	foreach(itr,m){
		if(itr->se==mx){
			g.pb(itr->fi);
		}
	}
	sort(all(g));
	rep(i,g.size()){
		cout<<g[i]<<endl;
	}
	re 0;
}

Measured memory_bytes: 28404