akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //   cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        int a[n];
        int xx = 0;

        for (int i = 0; i < n; ++i)
        {
            cin >> a[i];
        }
        for (int i = 0; i < n - 1; i += 2)
        {
            xx ^= a[i] ^ a[i + 1];
        }
        //cout << xx << "s\n";
        for (int i = 0; i < n; ++i)
        {
            if (i > 0)
                cout << " ";
            int ans = a[i] ^ xx;
            cout << ans;
        }
    }
}

Measured memory_bytes: 5096
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

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

  for (ll n = 1; n <= N; n++) {
    ll count = 0;
    for (ll x = 1; x * x < n; x++) {
      for (ll y = 1; (y * y) + (x * x) < n; y++) {
        for (ll z = 1;
             (y * y) + (x * x) + (z * z) + (x * y) + (y * z) + (z * x) <= n;
             z++) {
          if ((x * x + y * y + z * z + x * y + y * z + z * x) == n) {
            count++;
          }
        }
      }
    }
    cout << count << endl;
  }
  return 0;
}


Measured memory_bytes: 3476
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;


int main()
{
	int n, m;
	cin >> n >> m;
	int t = pow(2, m);
	int ans = t * 1900 * m + t * 100 * (n - m);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <list>
#include <map>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <numeric>
 
using namespace std;
 
#define ll long long
const int maxn = 1e5+5;
 
int main() {
 
    ios::sync_with_stdio(false);
    cin.tie(0);

    int a,b; cin >> a >> b;
    if (a > 9 || b > 9) {
        cout << "-1" << endl;
    } else {
        cout << a*b << endl;
    }
}
 

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

const ll MAXN = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, ans=0, tmp=0;
vector<ll> A;
set<ll> S;

signed main(){
    cin >> N;
    A.resize(N+2);
    A[0]=0;
    A[N+1]=N+1;
    for(int i=1;i<=N;i++) {
        ll a;
        cin >> a;
        A[a] = i;
    }
    S.insert(N+2);
    S.insert(N+1);
    S.insert(0);
    S.insert(-1);
    S.insert(A[N]);
    for(int i=N-1;i>0;i--) {
        set<ll>::iterator idu1 = S.lower_bound(A[i]);
        set<ll>::iterator idu2 = idu1;
        idu2++;
        set<ll>::iterator idl1 = idu1;
        idl1--;
        set<ll>::iterator idl2 = idl1;
        idl2--;
        S.insert(A[i]);
        if(*idl2!=-1) ans += i*(*idl1-*idl2)*(*idu1-A[i]);
        if(*idu2!=N+2) ans += i*(*idu2-*idu1)*(A[i]-*idl1);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    int res = 1;
    sort(s.begin(),s.end());
    if(s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

template<typename T> T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } }

const int MOD = 1000000007;

int main() {
    int N, M, K;
    cin >> N >> M >> K;

    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= M; j++) {
            if (M * i + N * j - 2 * i * j == K) {
                cout << "Yes" << endl;
                exit(0);
            }
        }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

// ceil of a/b
inline int ceil(int a, int b) { return (a%b?a/b+1:a/b); }


signed main() {
	int n,a,b;
	std::cin >> n >> a >> b;
	std::vector<int> h(n);
	rep(i,n) std::cin >> h[i];

	int l = 0; int r = 1e9+1;
	while(r-l>1) {
		int mid = (r+l)/2;
		int sum = 0;
		rep(i,n) {
			sum += ceil(std::max(h[i]-mid*b,(int)0),a-b);
		}
		if(sum>mid) l=mid;
		else r=mid;
	}
	print(r);
	return 0;
}


Measured memory_bytes: 1024
from sys import stdin
def sqmatrix(n):
  return [[0] * n for i in range(n)]

def magicsq(m):
    n = len(m)
    j = int(n/2)
    i = j + 1
    for num in range(1, n**2 + 1):
        m[i][j] = num
        i += 1
        j += 1
        i = i%n
        j = j % n
        if m[i][j] != 0:
            i += 1
            j -= 1
        if j < 0:
            j = n -1
        i = i % n
    return m

for line in stdin:
    n = int(line)
    if n == 0:
        break
    sm = sqmatrix(n)
    for row in magicsq(sm): print (''.join(map(lambda x: str(x).rjust(4, ' '),row)))

Measured memory_bytes: 7588
#include <stdio.h>

int main(void)
{
	int n;
	int a;
	
	while (1){
		a = 0;
		
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		while (n != 1){
			if (n % 2 == 0){
				n /= 2;
				a++;
			}
			else if (n % 2 == 1){
				n = n * 3 + 1;
				a++;
			}
		}
		printf("%d\n", a);
	}
	
	return (0);
}

Measured memory_bytes: 596
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<int, int> P;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  int T, A; cin >> T >> A;
  vector<P> v(N);
  FOR(i,0,N) {
    int h;
    cin >> h;
    v[i] = P(abs(1000 * (T - A) - 6 * h), i + 1);
  }
  sort(v.begin(), v.end());
  cout << v[0].second << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
 
#define mo 1000000007
#define inf 1e18
#define rep(i, s, n) for (ll i = s; i < n; i = i + 1)
#define rrep(i,s,n) for(ll i=s;i>=n;i--)
#define adiii \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);  \
  cout.tie(NULL);									
 
ll mod(ll n) { return (n % (ll)mo + (ll)mo)%(ll)mo;}
ll gcd(ll a,ll b) {if (b == 0) return a;return gcd(b, a % b);}
 
ll binpow(ll a, ll b) {ll res = 1;while (b > 0) {if (b & 1) res = res * a;a = a * a;b >>= 1;}return res;}

int main(){
	adiii
	ll n;cin>>n;
	vector <ll> a(n+1),b(n+1),c(n+1);
	vector<vector <ll>> dp(n+1,vector<ll>(3));
	rep(i,1,n+1) cin>>a[i]>>b[i]>>c[i];
	rep(i,1,n+1){
		
		if(i-1>=1){
				dp[i][0] = a[i] + max(dp[i-1][1],dp[i-1][2]);
				dp[i][1] = b[i] + max(dp[i-1][0],dp[i-1][2]);
				dp[i][2] = c[i] + max(dp[i-1][0],dp[i-1][1]);
		}
		else dp[i][0] = a[i],dp[i][1] = b[i],dp[i][2] = c[i];
	}
	cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));

}


Measured memory_bytes: 8064
N = input()
A = []
B = list(map(int, input().split()))

A.append(B[0])
A.append(B[0])

for i in range(1, len(B), 1):
    if B[i] < A[i]:
        A[i] = B[i]
    A.append(B[i])

print(sum(A))


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

// マクロ //
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) x * x

// 型エイリアス //
using lint = long long;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;

// 関数 //
int gcd(int a, int b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

// End of Template //

int main() {

    int N, M, P;
    cin >> N >> M >> P;
    cou((N + M + P > 21 ? "bust" : "win"));


}

Measured memory_bytes: 256
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var N = Number(lines[0].split(" ")[0])
    var K = Number(lines[0].split(" ")[1])
    var S = lines[1].split("")

    switch (S[K - 1]) {
        case "A": S[K - 1] = "a"; break
        case "B": S[K - 1] = "b"; break
        case "C": S[K - 1] = "c"; break
    }
    console.log(S.join(""))

});

Measured memory_bytes: 23220
#include <iostream>
using namespace std;
int main() {
    int N, T;
    cin >> N >> T;
    int t[N];
    cin >> t[0];
    long long sum = 0;
    for (int i=1; i<N; i++) {
        cin >> t[i];
        sum += min(t[i]-t[i-1], T);
    }
    sum += T;
    cout << sum << endl;
}

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

int main(){
    int k, a, b, c, d, n, m, x;
    scanf("%d", &k);
    int from[k], to[k], tea[k], stu[k];
    for(int i = 0; i < k; i++){
        scanf("%d:%d-%d:%d", &a, &b, &c, &d);
        from[i] = a*60+b;
        to[i] = c*60+d;
        tea[i] = stu[i] = 0;
    }
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &x);
        while(x-- > 0){
            scanf("%d:%d-%d:%d", &a, &b, &c, &d);
            int f = a*60+b, t = c*60+d;
            for(int j = 0; j < k; j++){
                if(f <= from[j] && to[j] <= t)  tea[j]++;
            }
        }
    }
    scanf("%d", &m);
    for(int i = 0; i < m; i++){
        scanf("%d", &x);
        while(x-- > 0){
            scanf("%d:%d-%d:%d", &a, &b, &c, &d);
            int f = a*60+b, t = c*60+d;
            for(int j = 0; j < k; j++){
                if(f <= from[j] && to[j] <= t)  stu[j]++;
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < k; i++)  ans += min(tea[i], stu[i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3248
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define itn int
using ll = long long;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
///                →,↑,←,↓,↗,↖,↙,↘
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

signed main() {
	int n, k,i;
	cin >> n >> k;
	ll ans = k;
	rep(i, n - 1) ans *= k - 1;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define reps(i,n) for(int i=1;i<=(int)n;i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define MOD 1000000007
#define itn int
#define enld endl
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
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;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

vector<pair<long long, long long>> prime_factorize(long long N) {
    vector<pair<long long, long long>> res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main(){
    int N,K; cin >> N >> K;
    if(K == 1) cout << 0 << endl;
    else{
        cout << N - K << enld;
    }
    return 0;
}

Measured memory_bytes: 3552
#include <stdio.h>

int main(void)
{
	char s[17];
	char t[] = "CODEFESTIVAL2016";
	int count = 0;
	int i;

	scanf("%[^\n]s", s);
	
	for (i = 0; i < 16; i++)
	{
		if (s[i] == t[i])
		{}
		else
		{
			count++;
		}
	}	
	printf("%d", count);
	return 0;
}

Measured memory_bytes: 128
using System;
class Program
{
	static void Main(string[] args)
	{
      string C1 = Console.ReadLine();
      string C2 = Console.ReadLine();
      if (C1[0] == C2[2] && C1[1] == C2[1] && C1[2] == C2[0])
      {
        Console.WriteLine("YES");
      }
      else
      {
        Console.WriteLine("NO");       
      }
	}
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int mod=7+1e9;
int main()
{ int n,k;
  cin>>n>>k;
  int arr[n];
  for(int &a:arr)
      a=0;
  while(k--)
  {
      int d,s;
      cin>>d;
      while(d--)
      {cin>>s;
      arr[s-1]++;}

  }
  int count=0;
  for(int i=0;i<n;i++)
  {if(arr[i]==0)
          count++;}
      cout<<count;

}


Measured memory_bytes: 3636
def get_ans ms
  m_len = ms.length
  dp = Array.new(m_len){Array.new(m_len)}
  0.upto(m_len - 1) do |i|
    0.upto(m_len - 1) do |j|
      from_i = j
      to_i = j + i
      break if to_i > m_len - 1
      dp[from_i][to_i] = if from_i == to_i
                           0
                         else
                           min_v = Float::INFINITY
                           from_i.upto(to_i - 1) do |k|
                             v = dp[from_i][k] + dp[k + 1][to_i] + ms[from_i][0] * ms[k][1] * ms[to_i][1]
                             min_v = v if v < min_v
                           end
                           min_v
                         end
    end
  end

  dp[0][m_len - 1]
end

ms = []
n = gets.chomp.to_i
while l = gets
  ms << l.chomp.split(' ').map(&:to_i)
end
puts get_ans ms


Measured memory_bytes: 6944
#include<stdio.h>
int main()
{
	int n;
	char s[100];
	int i,f=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%c",&s[i]);
	}
	for(i=0;i<n;i++){
		if(s[i]=='Y'){
			f=1;
		}
	}
	if(f==0){
		printf("Three\n");
	}
	else{
		printf("Four\n");
	}
	return 0;
}

Measured memory_bytes: 1660
import copy
from scipy.sparse.csgraph import floyd_warshall

N, M = map(int, input().split())
graph = [[0 for _ in range(N)] for _ in range(N)]
ab = []
for _ in range(M):
    a1, b1 = map(int, input().split())
    ab.append([a1, b1])
    graph[a1-1][b1-1] = 1
    graph[b1-1][a1-1] = 1

ans = 0
for i, j in ab:
    d = copy.deepcopy(graph)
    d[i-1][j-1] = 0
    d[j-1][i-1] = 0
    d = floyd_warshall(d)
    for k in range(1,N):
        if d[0][k] == float("inf"):
            ans += 1
            break

print(ans)

Measured memory_bytes: 26468
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val A = Integer.parseInt(sc.next())
    val B = Integer.parseInt(sc.next())

    if (A == B) {
      println(A + B)
      return
    }

    val Large = Math.max(A, B)
    println(Large * 2 - 1)
  }
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    int n;
    cin>>n;
    vi p(n);
    rep(i,n)cin>>p[i];

    int min=p[0],ans=0;

    rep(i,n){
        if(p[i]<=min){
            ans++;
            min=p[i];
        }
    }

    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000005LL
#define MOD 100000

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

int dp[3005][50];

int main()
{
	int N,M,S;
	while(1){
		scanf("%d%d%d",&N,&M,&S);
		if(N==0 && M == 0)break;
		N = N*N;
		S -= N*(N+1)/2;
		M -= N;
		if(S < 0 || M < 0){
			puts("0");
			continue;
		}
		for(int i=0;i<=S;i++){
			for(int j=0;j<=N;j++){
				dp[i][j]=0;
			}
		}
		dp[0][0]=1;
		for(int i=0;i<=S;i++){
			for(int j=1;j<=N;j++){
				dp[i][j] = dp[i][j-1];
				if(i-j>=0)(dp[i][j] += dp[i-j][j])%=MOD;
				if(i-j-M >= 0)(dp[i][j] += MOD-dp[i-j-M][j-1])%=MOD;
			}
		}
		printf("%d\n",dp[S][N]);
	}

	return 0;
}



Measured memory_bytes: 2924
# 奇数が絡んできた場合だけできない可能性がある
# 奇数の数をk、4の倍数であって2の倍数でない数をfとすると k f k f や f k fはok 
# 2の倍数であって4の倍数でないやつはどっか適当に影響しないとこ（両端とか）においとけばいいので考えないで済む
# ↑間違い 1WA
# 2の倍数であって4の倍数でないやつをbとすると
# k f k f k (S(f)-1>=S(k))は大丈夫だが
# b b k f k f k b b b とかはダメ
# 
# S(f)>=S(k)

n = gets.chomp.to_i
odd_n, two_n, four_n = 0, 0, 0
gets.chomp.split.map(&:to_i).each do |ai|
  if ai.odd?
    odd_n+=1
  elsif ai%4==0
    four_n+=1
  else
    two_n+=1
  end
end
if four_n>=odd_n-1 && two_n == 0
  puts "Yes"
elsif four_n>=odd_n
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 9476
S=input()
ans=0
for i in range(1<<len(S)-1):
    tmp=[]
    end=0
    for j in range(len(S)):
        if i&(1<<j):
            tmp.append(int(S[end:j+1]))
            end=j+1
    tmp.append(int(S[end:len(S)]))
    ans+=sum(tmp)
print(ans)


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


const ll mod=1000003;

ll ksm(ll a,ll b){
    ll ans=1ll;
    while(b){
        if(b&1) ans=ans*a%mod;
        b>>=1;
        a=a*a%mod;
    }
    return ans;
}


const int maxn=2e6+70;
ll fac[maxn],inv[maxn],finv[maxn];
void init(){
    inv[0]=inv[1]=fac[0]=fac[1]=finv[0]=finv[1]=1;
    for(int i=2;i<maxn;i++) {
        fac[i]=1ll*fac[i-1]*i%mod;
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}

void solved(int x,int d,int n){
    if(d==0) {
        cout<<ksm(x*1ll,n*1ll)<<endl;
        return ;
    }
    ll zx=1ll*x*inv[d]%mod;
    if(zx+n-1>=mod) {
        cout<<0<<endl;
        return ;
    }
    ll ret=ksm(d*1ll,n);
    ret=ret*fac[zx+n-1]%mod;
    ret=ret*finv[zx-1]%mod;
    cout<<ret<<endl;
    return ;
}

int main (){
    init();
    int Q;scanf("%d",&Q);
    int x,d,n;
    while(Q--) {
        scanf("%d %d %d",&x,&d,&n);
        solved(x,d,n);
    }
    return 0;
}


Measured memory_bytes: 47744
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;
#define rep(i,n) for(int i=0;i<(n);i++)
const int MOD = 1000000007;

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

  if(s.length() <= k) {
    cout << s << endl;
  } else {
    s = s.substr(0,k) + "...";
    cout << s << endl;
  }
}

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

int main() {
  int N;
  cin >> N;
  vector<int64_t> L;
  L.push_back(2);
  L.push_back(1);
  int64_t sum = 0;
  for (int i = 0; i < N; i++) {
    sum = L.at(i) + L.at(i + 1);
    L.push_back(sum);
    if (i + 1 == N) {
      sum -= L.at(i);
      break;
    }
  }
  
  cout << sum << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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 ctoi(char c){return c-'0';}

// TODO: write
int main() {
  int n;cin>>n;
  int t;cin>>t;
  vector<int> a;
  rep(i,n){
    int c,u;cin>>c>>u;
    if(u <= t)a.pb(c);
  }
  sort(all(a));
  if(a.size())print(a[0]);
  else print("TLE");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
int main()
{
    int a;
    double pi,ans;
    cin>>a;
    pi=acos(-1);
    ans= 2*pi*a;
   // printf("%.6lf\n",ans);
    cout<<ans<<endl;
}


Measured memory_bytes: 3784
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;


int main()
{
	string s;
	cin >> s;
	long a[2] = { 0,0 };

	for (long i = 0; i < s.length(); i++) {
		if (s.substr(i, 1) == "0") {
			a[0]++;
		}
		else {
			a[1]++;
		}
	}

	cout << 2 * min(a[0], a[1]) << endl;

    return 0;
}

Measured memory_bytes: 512
S = input()
s = ['01', '10']

ans = 0
count = len(S)
i = 0
while count >= 2:
    # 削除できる場合、2文字削除し基準点iはそのままとする
    if S[i:i + 2] in s:
        S = S[:i] + S[i + 2:]
        ans += 2
        count -= 1
        i -= 1
    # 削除できない場合
    else:
        i += 1
        count -= 1

print(ans)

Measured memory_bytes: 3424
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

while true
    h,w=get_i
    break if h.zero? and w.zero?
    h.times do|i|
        w.times do|j|
          if (i+1).odd? and (j+1).odd?
              print "#"
          elsif (i+1).even? and (j+1).even?
              print "#"
          else
              print "."
          end
        end
        print "\n"
    end
    print "\n"
end


Measured memory_bytes: 6884
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	cout<<(s[2]==s[3]&&s[4]==s[5]?"Yes":"No")<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const int MAXS = 114514;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
signed main(){
    int a,b,c,d,e,f,g,h,i;
    cin>>a>>b>>c>>d>>e>>f>>g>>h>>i;
    string res = "No";
    for(int p=0;p<=100;p++){
        for(int q=0;q<=100;q++){
            for(int r=0;r<=100;r++){
                if(a-p==d-q&&d-q==g-r&&b-p==e-q&&e-q==h-r&&c-p==f-q&&f-q==i-r){
                    res="Yes";
                }
            }
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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 int INF = 1e9;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, n;
    cin >> h >> n;
    vector<int> dp(h+10005, INF);
    dp[0] = 0;
    rep(i,n){
        int a, b;
        cin >> a >> b;
        rep(j,h+1){
            chmin(dp[j+a], dp[j] + b);
        }
    }
    int ans = INF;
    for(int j = h; j <= h+10000; ++j) chmin(ans, dp[j]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3684
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a==5&&b==5&&c==7){
		printf("YES\n");
	}
	else if(a==5&&b==7&&c==5){
		printf("YES\n");
	}
	else if(a==7&&b==5&&c==5){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	return 0;
}

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

int dfs(int p, vector<vector<int>>& edge, vector<int>& prev) {
    for (int i : edge[p]) {
        if (prev[i] == -1) {
            prev[i] = p;
            return dfs(i, edge, prev);
        }
    }
    return p;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> edge(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    vector<int> prev(n, -1);
    prev[0] = 0;
    int p = dfs(0, edge, prev);
    int q = dfs(0, edge, prev);
    vector<int> ans, ans2;
    for (; p != 0; p = prev[p]) {
        ans.push_back(p + 1);
    }
    for (; q != 0; q = prev[q]) {
        ans2.push_back(q + 1);
    }
    cout << (ans.size() + ans2.size() + 1) << "\n";
    for (int i : ans) {
        cout << i << " ";
    }
    cout << 1;
    for (int i = ans2.size() - 1; i >= 0; --i) {
        cout << " " << ans2[i];
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 7160
#include <iostream>

int main()
{
    int w, h, x, y, r;

    std::cin >> w >> h >> x >> y >> r;

    int x1, x2, y1, y2;

    x1 = x + r;
    x2 = x - r;
    y1 = y + r;
    y2 = y - r;

    if (x1 <= w && x2 >= 0 && y1 <= h && y2 >= 0)
    {
        std::cout << "Yes" << std::endl;
    }
    else
    {
        std::cout << "No" << std::endl;
    }

    return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <climits>
#include <cmath>
#include <unordered_map>

using namespace std;

typedef long long ll;

int main(void) {
  ll A, B;
  cin >> A >> B;
  if (A < B) {
    cout << (B + (B - 1)) << endl;
  } else if (A > B) {
    cout << (A + (A - 1)) << endl;
  } else {
    cout << (A + B) << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

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

    if (a < 10 && b < 10) {
      System.out.println(a*b);
    } else {
      System.out.println(-1);
    }

  }

}


Measured memory_bytes: 23636
#include <iostream>
#include <string>
#include<algorithm>
#include <cstdlib>
#include <cmath>
#include <regex>

using namespace std;
int main()
{
	string s;
	cin >> s;
	s = regex_replace(s,regex(",")," ");
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <math.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265358979323846264338327950L
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

float metric(vector<int>& a, vector<int>& b) {
  float sum = 0;

  rep(i, a.size()) { sum += (a[i] - b[i]) * (a[i] - b[i]); }
  return sqrt(sum);
}

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

  vector<vector<int>> v(N, vector<int>(D));
  rep(i, N) {
    rep(j, D) {
      int a;
      cin >> a;
      v.at(i).at(j) = a;
    }
  }

  float met;

  int count = 0;

  rep(i, N) {
    rep(j, N) {
      if (i != j) {
        vector<int> a = v.at(i);
        vector<int> b = v.at(j);
        met = metric(a, b);
        if (ceil(met) == floor(met)) {
          count++;
        }
      }
    }
  }
  cout << count / 2 << endl;
}


Measured memory_bytes: 504
N = int(input())

L = []
B = []
A = []
for _ in range(N):
    a, b = map(int, input().split())
    L.append((a, b))
    B.append(b)
    A.append(a)

L.sort(key=lambda x: x[1])

max_B = max(B)
sum_A = sum(A)

if (sum_A > max_B):
    print('No')
    exit()
else:
    count = 0
    for i in range(N):
        count += L[i][0]

        if (count > L[i][1]):
            print('No')
            exit()
        else:
            continue

    print('Yes')


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

namespace tree {
struct union_find {
  vector<int> par, rank, size;
  int compnum;

  union_find(int N) {
    compnum = N;
    par.resize(N), rank.resize(N), size.resize(N);
    for(int i=0; i<N; i++) {
      par[i] = i;
      rank[i] = 0;
      size[i] = 1;
    }
  }

  int root(int x) {
    return par[x] == x ? x : par[x] = root(par[x]);
  }

  void unite(int x, int y) {
    x = root(x), y = root(y);
    if(x == y) return;
    if(rank[x] < rank[y]) {
      par[x] = y, size[y] += size[x];
    } else {
      par[y] = x, size[x] += size[y];
      if(rank[x] == rank[y]) rank[x]++;
    }
    compnum--;
  }

  int operator[](int x) { return root(x); }
  void operator()(int x, int y) { return unite(x, y); }

  bool same(int x, int y) { return root(x) == root(y); }
  int size_of(int x) { return size[root(x)]; }
  int num_of_comps() { return compnum; }
};
}

int main() {

  int N, K, L; cin >> N >> K >> L;
  tree::union_find uf1(N), uf2(N);
  rep(i, K) {
    int a, b; scanf("%d%d", &a, &b); a--, b--;
    uf1(a, b);
  }

  rep(i, L) {
    int a, b; scanf("%d%d", &a, &b); a--, b--;
    uf2(a, b);
  }

  map<pair<int, int>, int> mp;
  rep(i, N) {
    mp[{uf1[i], uf2[i]}]++;
  }

  rep(i, N) {
    printf("%d\n", mp[{uf1[i], uf2[i]}]);
  }
  
  return 0;
}

Measured memory_bytes: 16640
#include<cstdio>
#include<iostream>
using namespace std;
int a,b,c;
int main()
{
	cin>>a>>b>>c;
	
	for (int i = 0 ; i < b; i++)
	{
		if (i * a % b == c) {cout<<"YES"<<endl; return 0;}
	}

	cout<<"NO"<<endl;
return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 real signed
#define                 endl '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)

vector<int>adj[100500],topo;

int visited[100500],dp[100500];

void dfs(int node)
{
    visited[node]=true;

    for(auto i : adj[node])
        if(!visited[i])
            dfs(i);
    topo.pb(node);        
}


signed main() 
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;

    forn(i,1,m)
    {
        int a,b;
        cin>>a>>b;
        adj[a].pb(b);
    }
    
    forn(i,1,n)
        if(!visited[i])
            dfs(i);

    for(auto i : topo)
        for(auto j : adj[i])
            dp[i]=max(dp[i],dp[j]+1); 

    int ans=0;

    for(auto i : dp)
        ans=max(ans,i);   

    cout<<ans;                

     return 0;

}

//       g++ -g c4.cpp ; ./a.exe

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

int main(){
  int A,B,C,a;
  cin >> A >> B >>C;
  
  if(max(A,max(B,C)) > max(B,C)){
  	a = A;
    cout << a*10+B+C << endl;
  }else{
  	a = max(B,C);
    cout << a*10 + min(B,C) + A << endl;
  }
  
  
}

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

using namespace std;

#define INF 210000000
#define int long long

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

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

signed main() {
		string s;
		int n;
		int x = 0;
		int ans = 0;
		cin >> n;
		cin >> s;
		for(int i=0;i<n;i++){
				if(s[i] == 'I') x++;
				else x--;
				if(ans < x) ans = x;
		}
		cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define il inline
#define RG register
#define ll long long

using namespace std;

int f[200005],n,ans;

il int gi(){
  RG int x=0,q=1; RG char ch=getchar();
  while ((ch<'0' || ch>'9') && ch!='-') ch=getchar();
  if (ch=='-') q=-1,ch=getchar();
  while (ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
  return q*x;
}

int main(){
  n=gi();
  for (RG int i=1,p;i<=n;++i) p=gi(),f[p]=f[p-1]+1,ans=max(ans,f[p]);
  cout<<n-ans; return 0;
}


Measured memory_bytes: 1024
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	a := iScan()
	b := iScan()
	v := iSScan(n)
	sort.Sort(sort.Reverse(sort.IntSlice(v)))
	ans := 0
	ave := -1.
	for q := a; q <= b; q++ {
		g := gcd(sum(v[:q]), q)
		r := float64(sum(v[:q])/g) / float64(q/g)
		if r == ave || ave == -1. {
			x, y := -1, -1
			ave = r
			for i := 0; i < n; i++ {
				if v[i] == v[q-1] {
					x = i
					break
				}
			}
			for i := 0; i < n; i++ {
				if v[i] == v[a-1] {
					y = i + 1
				}
			}
			z := 1
			s, t := y-x, q-x
			t = smaller(t, s-t)
			u := 1
			for j := s; j > s-t; j-- {
				z *= j
				for u <= t {
					if z%u == 0 {
						z /= u
						u++
					} else {
						break
					}
				}
			}
			ans += z
		} else {
			break
		}
	}
	fmt.Println(ave)
	fmt.Println(ans)
}
func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}


Measured memory_bytes: 1792
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N,K;
LL A[200000];

LL ans = INF;

void solve(){
	if(K==0){
		ans = -1;
		for(int i=0;i<N;i++) ans = max(ans,A[i]);
		return;
	}

	LL times_per1 = 0;
	for(int i=0;i<N;i++){
		times_per1 += (A[i]-1LL);
	}
	if(times_per1<=K){
		ans = 1;
		return;
	}

	//最小の長さを2部探索
	LL left = 2;
	LL right = 1000000001LL;
	while(left+1<right){
		LL center = (left+right)/2LL;

		auto ok = [&](){
			LL times = 0;//切る回数
			for(int i=0;i<N;i++){
				if(A[i]%center==0) times += A[i]/center - 1;
				else times += (A[i]/center);
			}
			return times>K;
		};

		if(ok()) left = center;
		else right = center;
	}

	ans = right;
	if(ans>=3){
		LL sum = 0;
		for(int i=0;i<N;i++){
			if(A[i]%(ans-1)==0) sum += A[i]/(ans-1) - 1;
			else sum += (A[i]/(ans-1));
		}
		if(sum<=K) ans--;
	}
}

int main(){
    cin >> N >> K;
    for(int i=0;i<N;i++) cin >> A[i];

    solve();

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

Measured memory_bytes: 4668
#include <stdio.h>
#include <vector>
#include <iostream>
#include <sstream>
#include <string>
using namespace std;

int main(void) {
	vector<string> r;
	int y,m,d;
	while (scanf("%d %d %d",&y,&m,&d) != EOF)
	{
		ostringstream os;
		if ((y < 1868)||(y==1868 && m < 9)||(y==1868 && m == 9 && d<8))
		{
			r.push_back("pre-meiji");
		} else if ((y < 1912)||(y==1912 && m < 7)||(y==1912 && m == 7 && d<30)) {
			os << "meiji " << y - 1868 + 1 << " " << m << " " << d;
			r.push_back(os.str());
		} else if ((y < 1926)||(y==1926 && m < 12)||(y==1926 && m == 12 && d<25)) {
			os << "taisho " << y - 1912 + 1 << " " << m << " " << d;
			r.push_back(os.str());
		} else if ((y < 1989)||(y==1989 && m < 1)||(y==1989 && m == 1 && d<8)) {
			os << "showa " << y - 1926 + 1 << " " << m << " " << d;
			r.push_back(os.str());
		} else {
			os << "heisei " << y - 1989 + 1 << " " << m << " " << d;
			r.push_back(os.str());
		}
	}
	for(int i=0; i<r.size(); i++)
	{
		cout << r[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String s=br.readLine().trim();
		//System.out.println(s);
		
		if((s.charAt(2)==s.charAt(3)) && (s.charAt(4)==s.charAt(5)))
		    System.out.println("Yes");
		else
		    System.out.println("No");
	}
}


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

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;

const char nl = '\n' ;
const ll MOD = 1e9 + 7;


int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);
   int n, k; cin >> n >> k;
   int ans = 1;
   for(int i = 0; i < n; i++)
   {
      ans = min(ans*2, ans+k);
   }
   cout << ans << nl;
   return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAXN 1010
#define MAXM 2010
#define INF 10000000000000010
struct edge{
  ll from,to,cost;
};
edge es[MAXM];
ll d[MAXN];
ll N,M;
bool find_positive_loop(){
  for(int i=1;i<=N;i++) d[i]=-INF;
  d[1]=0;
  for(int i=0;i<=N;i++){
    for(int j=0;j<M;j++){
      edge e=es[j];
      if(d[e.to]<d[e.from]+e.cost){
        d[e.to]=d[e.from]+e.cost;
        if(i==N&&e.to==N) return true;
      }
    }
  }
  return false;
}
int main(){
  cin>>N>>M;
  for(int i=0;i<M;i++){
    cin>>es[i].from>>es[i].to>>es[i].cost;
  }
  if(find_positive_loop()){
    cout<<"inf"<<endl;
  }else{
    cout<<d[N];
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
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; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;
const double PI = 3.1415926535;

int main() {
    int n, m;
    cin >> n >> m;
    vector<pii>a(m);
    vector<bool>p(200020,false),q(200020,false);
    rep(i, 0, m){
        int a, b;
        cin >> a >> b; 

        if(a == 1)q[b]=true;
        if(b == n)p[a]=true;
    }
    rep(i, 0, 200020){
        if(p[i]&&q[i]){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
     cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 1920
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


string S;
int main() {
    while (cin >> S) {
        set<char> se;
        for (auto c : S) se.insert(c);
        
        if (se.size() == 26) {
            vector<char> vec;
            for (int i = 0; i < S.size(); ++i) {
                vec.push_back(S[i]);
            }
            if (next_permutation(vec.begin(), vec.end())) {
                string res = "";
                for (int i = 0; i < vec.size(); ++i) {
                    res += vec[i];
                    if (vec[i] != S[i]) break;
                }
                cout << res << endl;
            }
            else {
                cout << -1 << endl;
            }
        }
        else {
            char c;
            for (c = 'a'; c <= 'z'; ++c) {
                if (!se.count(c)) break;
            }
            S += c;
            cout << S << 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 x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		x-=a;
		
		while(x-b>=0) {
			x-=b;
		}
		System.out.println(x);
	}
}

Measured memory_bytes: 21716
digitSum n = inner n 0
  where inner 0 rv = rv
        inner m rv = let (q, r) = quotRem m 10
                     in
                       inner q (r + rv)

sums n = [ (k, digitSum k) | k <- [1 .. n]]

sums10000 = sums 10000

filterSums n a b = filter (\(_, x) -> a <= x && x <= b) $ take n sums10000

answer n a b = foldr (\(x, _) y -> x + y) 0
               $ filterSums n a b

main = interact $ (++ "\n")
       . show 
       . (\[x, y, z] -> answer x y z)
       . map read
       . take 3
       . words
       . head
       . lines
       


Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N,X;
  cin >> N >> X;
  
  vector<int> m(N);
  for(int i=0; i<N; i++){
    cin >> m.at(i);
  }
  
  int sumg=X;
  for(int i=0; i<N; i++){
    sumg -= m.at(i);
  }
  
  sort(m.begin(),m.end());
  
  int cnt = N;
  for(int i=0; i<N; i++){
    int a = 0;
    a = sumg / m.at(i);
    sumg -= a * m.at(i);
    cnt += a;
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
#define endl '\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; }
using namespace std;

signed main(void){
    int n,a; cin>>n>>a;
    cout<<n*n-a<<endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>){
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map { it.toInt() }.toIntArray()

    val count = IntArray(100001)
    A.forEach {
        count[it]++
    }
    var evenCount = 0
    var all = 0
    for(i in count.indices){
        if(count[i] != 0){
            if(count[i] % 2 == 0) {
                evenCount++
            }
            all++
        }
    }
    if(evenCount % 2 == 0){
        println(all)
    }else{
        println(all - 1)
    }
}

Measured memory_bytes: 50020