akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
// 293206GT
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <unordered_set>
#include <stack>
#include <string>
#include<algorithm>
#include <random>
#include <bitset>
#include <chrono>

typedef long long ll;
#define int ll
using namespace std;
#define put(a) cout << (a) << '\n'
#define sqr(x) (x) * (x)
typedef pair<int, int> pii;
typedef long double ld;
typedef pair<ld, ld> pld;
#define rep(x, y, a) for (ll x = (y); x < (int)(a); ++x)
#define all(a) a.begin(), a.end()
#define chkmax(a, b) a = max(a, (b))
#define chkmin(a, b) a = min(a, (b))
#define prev asasdasd
#define next aasdasda
#define left asdasdasdasd
#define right asnabsdkasdl
#define rank asdasdknlasd
#define move asdasdas

typedef vector<int> vi;
typedef vector<pii> vpii;
namespace IO {
    template<class A, class B>
    ostream &operator<<(ostream &out, pair<A, B> a) {
        out << a.first << " " << a.second;
        return out;
    }

    template<class A, class B>
    ostream &operator<<(ostream &out, vector<pair<A, B>> a) {
        for (pair<A, B> x: a)
            out << x.first << " " << x.second << '\n';
        return out;
    }

    template<class A>
    ostream &operator<<(ostream &out, vector<A> a) {
        for (A x: a) out << x << ' ';
        return out;
    }

    template<class A, class B>
    istream &operator>>(istream &in, pair<A, B> &a) {
        in >> a.first >> a.second;
        return in;
    }

    template<class A>
    istream &operator>>(istream &in, vector<A> &a) {
        for (A &x: a) in >> x;
        return in;
    }
}
using namespace IO;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve() {
    int x, n;
    cin >> x >> n;
    vi p(n);
    cin >> p;
    set<int> c(all(p));
    int d = 0;
    while (c.count(x + d) && c.count(x - d)) ++d;
    if (!c.count(x - d)) put(x - d);
    else put(x + d);
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(30);
//    freopen("input.txt", "r", stdin);
//    freopen("input.txt", "r", stdin);
    int q = 1;
//    cin >> q;
    while (q--) solve();
}





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

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


Measured memory_bytes: 3076
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

string s;
int main(){
    cin>>s;
    if(s.length()%2==1){
        cout<<"No";
        return 0;
    }
    for(ll i=0;i<s.length();i++){
        if( (i%2==0 && s[i]!='h')||
        (i%2==1 && s[i]!='i') )
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
N,W=map(int,input().split())
w,v=[],[]
for i in range(N):
    weight, value = map(int,input().split())
    w.append(weight)
    v.append(value)
dp = [[0 for _ in range(100100)] for _ in range(N+2)]
for i in range(N):
    for sum_w in range(W+1):
        if sum_w -w[i] >=0:
            dp[i+1][sum_w] = max(dp[i+1][sum_w],dp[i][sum_w-w[i]] + v[i])
        dp[i+1][sum_w]=max(dp[i+1][sum_w],dp[i][sum_w])
print(dp[N][W])

Measured memory_bytes: 171656
using System;

namespace AtCoderMake.ABC162
{
    class ABC162B
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            long res = 0;
            for (int i= 0;i<= n; i++)
            {
                if (i % 3 > 0 && i % 5 > 0)
                {
                    res += i;
                }
            }
            Console.WriteLine(res);

        }
    }
}


Measured memory_bytes: 27540
from collections import deque

n = int(input())
A = list(input().split())
B= deque()

for i in range(n):
  if i % 2:
    B.append(A[i])
  else:
    B.appendleft(A[i])
  
if n % 2 == 0:
  B.reverse()
  
print(" ".join(B))

Measured memory_bytes: 31636
n = int(input())
h = list(map(int, input().split()))
pre = h[0]
flag = False
for i in range(1, n):
    if h[i] < pre:
        h[i] += 1
        if h[i] < pre:
            flag = True
    pre = h[i]
    if flag:
        break
if flag:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 14396
s=list(input())
if s[0]!="A":
    print("WA")
elif s[2:-1].count("C")!=1:
    print("WA")
else:
    s.pop(0)
    s.remove("C")
    if "".join(s).lower()!="".join(s):
        print("WA")
    else:
        print("AC")

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll 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 Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};
 
 
void solve(){
    ll a,b,c;
    cin>>a>>b>>c;
    c+=100*a+10*b;
    if(c%4==0) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
} 
 
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
     
    ll Q=1;
    // cin>>Q;
    rep(_,Q){
 
        solve();
 
    }
   
 
 
    return 0;
}

Measured memory_bytes: 256
//author:emre yazicioglu

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define fori(a,b,c) for(ll a = b;a < ll(c);a++)
#define ford(a,b,c) for(ll a = b;a >= ll(c);a--)
#define pb push_back

const int N = 1e3+ 7;
ll n,m,k,cnt,cur,ans;
char ar[N][N];
ll mod = 1e9 + 7, dp[N][N];

ll add(ll a, ll b){
	if(a + b >= mod)
		return a + b - mod;
	return a + b;
}

int main(){

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

	// freopen("in.txt","r",stdin);
	// freopen("out.txt","w",stdout);

	cin >> n >> m;
	fori(i,1,n + 1)
		fori(j,1,m + 1)
			cin >> ar[i][j];

	dp[1][1] = 1;
	fori(i,1,n + 1)
		fori(j,1,m + 1)
			if(ar[i][j] == '.')
				dp[i][j] = add(dp[i][j], dp[i - 1][j] + dp[i][j - 1]);
		
	cout << dp[n][m];
}

Measured memory_bytes: 9216
from math import sqrt

n = int(input())

count = 0

def isPrime(num):
    if num == 2:
        return True
    if num % 2 == 0:
        return False
    i = 3
    while i <= sqrt(num):
        if num % i == 0:
            return False
        i += 1
    return True

for i in range(0, n):
    num = int(input())

    if isPrime(num):
        count += 1

print(count)


Measured memory_bytes: 5676
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
  public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
  public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};


int main(){
  int n,k; cin >> n >> k;
  int cnt = (n-1)*(n-2)/2 - k;
  if(cnt < 0){
    cout << -1 << endl;
    return 0;
  }

  vi a,b;
  rep(i,n-1) {
    a.pb(i+1); b.pb(n);
  }

  vi aa,bb;
  rep(i,n-1) rep(j,i) {
    aa.pb(i+1); bb.pb(j+1);
  }

  rep(i,cnt) {
    a.pb(aa[i]); b.pb(bb[i]);
  }

  cout << a.size() << endl;
  rep(i,a.size()) printf("%d %d\n", a[i],b[i]);
}

Measured memory_bytes: 384
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
U=[A[0]]
D=[0,B[0]]
for i in range(1,N):
    U.append(U[-1]+A[i])
    D.append(D[-1]+B[i])
ans=0
for i in range(N):
    ans=max(ans,U[i]+D[-1]-D[i])
print(ans)


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

int main() {
  string S;
  cin >> S;
  vector<int> alphabet(26, -1);
  for (int i = 0; i < S.size(); i++) alphabet[S[i] - 'a'] = i;
  string last = "zyxwvutsrqponmlkjihgfedcba";
  if (S.size() < 26) {
    for (int i = 0; i < 26; i++) {
      if (alphabet[i] == -1) {
        S += i + 'a';
        cout << S << endl;
        return 0;
      }
    }
  } else if (S == last) {
     cout << -1 << endl;
  } else {
    string t = S;
    next_permutation(t.begin(), t.end());
    for (int i = 0; i < 26; i++) {
      if (S[i] != t[i]) {
        cout << t.substr(0, i + 1) << endl;
        break;
      }
    }
  }
}


Measured memory_bytes: 256
import std.stdio;
import std.array;
import std.string;
import std.conv;
import std.algorithm;
import std.typecons;
import std.range;
import std.random;
import std.math;
import std.container;
import std.numeric;
import std.bigint;


void main() {
  auto input = readln.split.map!(to!long);
  auto Sx = input[0];
  auto Sy = input[1];
  auto Gx = input[2];
  auto Gy = input[3];
  auto N = readln.chomp.to!int;
  auto x = new long[](N);
  auto y = new long[](N);
  auto r = new long[](N);
  foreach (i; 0..N) {
    input = readln.split.map!(to!long);
    x[i] = input[0];
    y[i] = input[1];
    r[i] = input[2];
  }

  auto edge = new real[][](N+2, N+2);
  foreach (i; 0..N+2) foreach (j; 0..N+2) edge[i][j] = (i == j) ? 0 : real.max;
  foreach (i; 0..N)
    foreach (j; i+1..N) {
      real d = max(0, sqrt((x[i]-x[j])^^2.to!real + (y[i]-y[j])^^2.to!real) - r[i] - r[j]);
      edge[i][j] = min(edge[i][j], d);
      edge[j][i] = min(edge[j][i], d);
    }
  foreach (i; 0..N) {
    real ds = sqrt((x[i]-Sx)^^2.to!real + (y[i]-Sy)^^2.to!real) - r[i];
    real dg = sqrt((x[i]-Gx)^^2.to!real + (y[i]-Gy)^^2.to!real) - r[i];
    edge[i][N] = max(min(ds, edge[N][i]), 0);
    edge[N][i] = max(min(ds, edge[i][N]), 0);
    edge[i][N+1] = max(min(dg, edge[i][N+1]), 0);
    edge[N+1][i] = max(min(dg, edge[N+1][i]), 0);
  }
  edge[N][N+1] = sqrt((Gx-Sx)^^2.to!real + (Gy-Sy)^^2.to!real);
  edge[N+1][N] = sqrt((Gx-Sx)^^2.to!real + (Gy-Sy)^^2.to!real);

  auto d = new real[](N+2);
  foreach (i; 0..N+2) d[i] = 10L^^15;
  d[N] = 0;
  auto used = new bool[](N+2);
  while (true) {
    int v = -1;
    foreach (u; 0..N+2)
      if (!used[u] && (v == -1 || d[u] < d[v]))
        v = u;
    if (v == -1)
      break;
    used[v] = true;
    foreach (u; 0..N+2)
      d[u] = min(d[u], d[v] + edge[v][u]);
  }

  writefln("%.9f", d[N+1]);
}


Measured memory_bytes: 16508
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
vector<int> ch[200005];
int calc(int x, int p) {
	set<int> S;
	for (int y : ch[x]) {
		if (y == p) continue;
		int v = calc(y, x);
		S.insert(v);
	}
	for (int i = 0;; ++i) {
		if (!S.count(i)) return i;
	}
}
int main() {
	int n;
	scanf("%d", &n);
	vector<int> nex(n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &nex[i]);
		--nex[i];
		ch[nex[i]].push_back(i);
	}
	vector<bool> used(n);
	int x = 0;
	while (!used[x]) {
		used[x] = true;
		x = nex[x];
	}
	int init = x;
	int len = 0;
	// x is on cycle.
	int mx = INT_MIN;
	int mn = INT_MAX;
	do {
		int v = calc(nex[x], x);
		mx = max(mx, v);
		mn = min(mn, v);
		x = nex[x];
		++len;
	} while (x != init);
	if (mx == mn && len % 2) {
		printf("IMPOSSIBLE\n");
	} else {
		printf("POSSIBLE\n");
	}
}


Measured memory_bytes: 11008
#include <iostream>
using namespace std;
typedef long long ll;
ll s;
string a;

void f(ll p, ll q, ll r) {
	if(p==a.size()) {s += q+r; return;}
	f(p+1, q, r*10+a[p]-'0');
	f(p+1, q+r, a[p]-'0');
}

int main() {
	cin>>a;
	f(1, 0, a[0]-'0');
	cout<<s;
	return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int[] ab = sc.intarr;

            int st = ab[0] + ab[1];

            if(st % 2 == 0)
            {
                Console.WriteLine(st / 2);
            }
            else
            {
                Console.WriteLine(st / 2 + 1);
            }
        }


    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


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


int main(){
	int x,y;
	cin>>x;
	y=x;
	int s=0;
	while(x>0){
		s+=x%10;
		x/=10;
	}
	printf(y%s==0?"Yes":"No");
	return 0;
}


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

long long N;
vector<long long> X;
vector<long long> XS;

int binSearch(long long v){
	int ret = 0;
	int s = 0, e = X.size() - 1;
	int m ;
	while(e - s > 1){
		m = (s + e) / 2;
		if(XS[m] > v){
			e = m;
		}
		else{
			s = m;
		}
	}
	if(XS[s] == v){
		ret = s;
	}
	else if(XS[s + 1] == v){
		ret = s + 1;
	}
	return ret;
}

int main(int argc, char* argv[]){

	cin >> N;
	for(int i=1; i<=N; i++){
		long long v;
		cin >> v;
		X.push_back(v);
		XS.push_back(v);
	}

	sort(XS.begin(), XS.end());

	for(int i=0; i<N; i++){
		long long B;
		//二分探索でX[i]の位置を探す
		int pos = binSearch(X[i]);
		if(pos <= (N/2) - 1){
			B = XS[N/2];
		}
		else{
			B = XS[(N/2) - 1];
		}
		printf("%lld\n", B);
	}
	return 0;
}

Measured memory_bytes: 5476
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int main() {
    int n, h, a = -1, b[100000];

    cin >> n >> h;

    for (int i=0; i<n; i++) {
        int tmp;
        cin >> tmp >> b[i];
        a = max(a, tmp);
    }
    sort(b, b+n, greater<int>());

    int dmg = 0, ret = 0, p = 0;
    while (dmg < h) {
        if (p < n && b[p] > a) {
            dmg += b[p];
            p++;
        }
        else {
            dmg += a;
        }
        ret++;
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 640
n = gets.chomp.to_i
hash = {"AC"=>0, "WA" =>0, "TLE"=>0, "RE"=>0}
n.times do 
	hash[gets.chomp] += 1
end
puts "AC x #{hash["AC"]}"
puts "WA x #{hash["WA"]}"
puts "TLE x #{hash["TLE"]}"
puts "RE x #{hash["RE"]}"



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

using u32 = uint32_t;
using u64 = uint64_t;
using i32 = int32_t;
using i64 = int64_t;

int main()
{
	std::ios_base::sync_with_stdio(0);
	
	u32 a, b, c;

	std::cin >> a >> b >> c;

	if(a+b+c>=22)
	{
		std::cout << "bust\n";
	}
	else
	{
		std::cout << "win\n";
	}
	
	return 0;
}

Measured memory_bytes: 256
n, c = map(int, input().split())

r = [[0 for i in range(c)] for j in range(100000)] 
for dummy in range(n): 
    s, t, c = map(int, input().split())
    for j in range(s - 1, t):
        r[j][c - 1] = 1 

ans = 0
for i in range(100000):
    if sum(r[i]) > ans:
        ans = sum(r[i]) 

print(ans)

Measured memory_bytes: 38260
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a;
	cin>>a;
	if(a[0]==a[a.length()-1]&&a.length()%2==1){
		cout<<"Second";
		return 0;
	}
	if(a[0]!=a[a.length()-1]&&a.length()%2==0){
		cout<<"Second";
		return 0;
	}
	cout<<"First";
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>	
#include <cmath>
#include <string>
#include<math.h>
#include<sstream>//���炵���̂Œ���
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int a = 1, b = 0, c, d, n, k = 0, ans = 0;
string s, t;
int mod = 1000000007;

int main()
{
	cin >> n;
	ll ans=1;
	for(int i=1;i<=n;i++) {
		ans = ans * i % mod;
	}
	cout << ans << endl;
	

	return 0;
}


Measured memory_bytes: 256
using System;

namespace ConsoleApp18
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int c = int.Parse(Console.ReadLine());
            int d = int.Parse(Console.ReadLine());
            int e = int.Parse(Console.ReadLine());
            int k = int.Parse(Console.ReadLine());

            

            if (k < e-a)
            {
                Console.WriteLine(":(");
            }
            else
            {
                Console.WriteLine("Yay!");
            }
        }
    }
}

Measured memory_bytes: 27536
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstdlib>
#include <queue>
#include <stack>
using namespace std;



int main(){
	int N,K;
	cin>>N>>K;
	vector<int> h(N);
	for(int i=0;i<N;i++){
		cin>>h[i];
	}
	sort(h.begin(),h.end());
	int ans;
	for(int i=0;i<N+1-K;i++){
		if(i==0)ans=h[i+K-1]-h[i];
		ans = min(h[i+K-1]-h[i],ans);
	}
	cout<<ans<<endl;
	return 0;
}


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

int main() {
  int D;
  cin>>D;
  vector<int> sage(26);
  for(int i=0;i<26;i++){
    cin>>sage.at(i);
  }
  vector<vector<int>> man(D,vector<int>(26));
  for(int i=0;i<D;i++){
    for(int j=0;j<26;j++){
      cin>>man.at(i).at(j);
    }
  }
  vector<int> hini(D);
  vector<vector<int>> rkai(D+1,vector<int>(26,1));
  for(int i=0;i<D;i++){
    int A=0,W=man.at(i).at(0)-3*rkai.at(i).at(0)*sage.at(0);
    for(int j=1;j<26;j++){
      int Y=man.at(i).at(j)-3*rkai.at(i).at(j)*sage.at(j);
      if(Y>W){
        W=Y,A=j;
      }
      rkai.at(i+1).at(j)=rkai.at(i).at(j)+1;
    }
    hini.at(i)=A;
    rkai.at(i).at(A)=0;
    rkai.at(i+1).at(A)=1;
  }
  /*for(int i=0;i<D;i++){
    Z+=man.at(i).at(hini.at(i));
    for(int j=0;j<26;j++){
      Z-=rkai.at(i).at(j)*sage.at(j);
    }
    cout<<Z<<endl;
  }*/
  int a=167,b=167;
  for(int i=0;i<1000000;i++){
    a=i%D;
      b=i%26;
      int Z=0;
    if(rkai.at(a).at(b)==0){
      continue;
    }
    int K=rkai.at(a).at(b),C=0;
    for(int j=a;j<D;j++){
      if(rkai.at(j).at(b)==0){
        break;
      }
      else{
        C++;
      }
    }
    Z+=K*C*sage.at(b);
    Z+=man.at(a).at(b);
    int e=hini.at(a);
    C=0;
      int G;
    if(a==0){
      G=1;
    }
    else{
      G=rkai.at(a-1).at(e)+1;
    }
    for(int j=a;j<D;j++){
      if(rkai.at(j).at(e)==0&&j!=a){
        break;
      }
      else{
        C++;
      }
    }
    Z-=G*C*sage.at(e);
    Z-=man.at(a).at(e);
      if(Z>0){
        for(int j=a;j<D;j++){
      if(rkai.at(j).at(b)==0){
        break;
      }
      else{
        rkai.at(j).at(b)-=K;
      }
    }
        for(int j=a;j<D;j++){
      if(rkai.at(j).at(e)==0&&j!=a){
        break;
      }
      else{
        rkai.at(j).at(e)+=G;
      }
    }
        hini.at(a)=b;
      }
    }
  
    
  for(int i=0;i<D;i++){
    cout<<hini.at(i)+1<<endl;
  }
}


Measured memory_bytes: 3708
//By Vlgd
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll M=1000000007;
ll pow1(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%M;
		x=x*x%M;
		n>>=1;
	}
	return res;
} 
main(){
	ll n,x;
	scanf("%lld%lld",&x,&n);
	printf("%lld\n",pow1(x,n));
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PL = pair<ll, ll>;
// Welcome to my source code!

int main() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    int p[a], q[b], r[c];
    for (int i = 0; i < a; i++) cin >> p[i];
    for (int i = 0; i < b; i++) cin >> q[i];
    for (int i = 0; i < c; i++) cin >> r[i];
    sort(p, p + a, greater<int>());
    sort(q, q + b, greater<int>());
    sort(r, r + c, greater<int>());
    vector<int> vec;
    for (int i = 0; i < x; i++) vec.push_back(p[i]);
    for (int i = 0; i < y; i++) vec.push_back(q[i]);
    for (int i = 0; i < c; i++) vec.push_back(r[i]);
    sort(vec.begin(), vec.end(), greater<int>());
    ll ans = 0;
    for (int i = 0; i < x + y; i++) ans += vec[i];
    cout << ans << endl;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pll pair<long long int, long long int>
#define pii pair<int, int>
#define vii vector<int>
#define vll vector<long long int>
#define sii set<int>
#define sll set<long long int>
#define usi unordered_set<int, custom_hash>
#define usl unordered_set<long long int, custom_hash>
#define mii map<int, int>
#define mll map<long long int, long long int>
#define umi unordered_map<int, int, custom_hash>
#define uml unordered_map<long long int, long long int, custom_hash>
#define ski stack<int>
#define skl stack<long long int>
#define all(v) v.begin(),v.end()
using namespace std;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c`
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};


const int N=1e3+1;
const int mod=998244353;
ll a[N], b[N], c[N];

string mat[N];
ll dp[N][N];
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
#endif
    
    int n, m;
    cin>>n>>m;
    for(int i=0;i<n;++i){
        cin>>mat[i];
    }

    dp[1][1]=1;
    for(int i=1;i<=n;++i){
        for(int j=1;j<=m;++j){
            if(mat[i-1][j-1]=='#' || (i==1 && j==1)){
                continue;
            }

            dp[i][j]=dp[i-1][j]+dp[i][j-1];
            dp[i][j]%=1000000007;
        }
    }

    cout<<dp[n][m]<<endl;
}

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

int main(void){
  int N;
  string S;
  cin >> N >> S;
  int check = 0;
  if (N % 2 == 1){
    cout << "No" << endl;
  }
  else{
    for(int i = 0; i < N / 2; i++){
      if(S.at(i) != S.at(N / 2 + i)){
        check = 1;
        break;
      }    
    }
   	if(check == 1) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# ありえる平均は1..50のいずれか

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

N, A = map(int, input().split())
Xs = list(sorted(map(int, input().split())))

lower = []
same = 0
upper = []
for x in Xs:
    if x < A:
        lower.append(A - x)
    elif x == A:
        same += 1
    else:
        upper.append(x - A)

def make_counter(nums):
    counter = Counter({0: 1})
    for n in nums:
        # 使う場合、使わない場合
        new_counter = Counter()
        for k, v in counter.items():
            new_counter[k] += v
            new_counter[k + n] += v
        counter = new_counter
    return counter

lower_counter = make_counter(lower)
upper_counter = make_counter(upper)

ans = 0
for lk, lv in lower_counter.items():
    # (i) Aに等しい数だけ使う
    if lk == 0:
        # ひとつも選ばれない場合を除くために-1
        ans += 2 ** same - 1
    # (ii) それ以外
    else:
        # Aより小さい数たちと、Aより大きい数たちとの集合の平均がちょうどA
        if lk in upper_counter:
            ans += (2 ** same) * lv * upper_counter[lk]

print(ans)


    
    


Measured memory_bytes: 7212
#include<bits/stdc++.h>
using namespace std;
 
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define pfis(a) printf("%d ",a);
#define pfls(a) printf("%lld ",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,a,b) for(int i=a;i<b;i++)
#define pb(a) push_back(a);
#define mp(a,b) make_pair(a,b)
#define ll long long

int main()
{
    int n,k;
    sfi(n)
    sfi(k)

    int arr[n];
    f(i,0,n)
        sfi(arr[i])

    int dp[n];

    f(i,1,n)
        dp[i]=INT_MAX;

    dp[0]=0;

    f(i,1,n)
    {
        f(j,1,k+1)
        {
            if((i-j)>=0)
            {
                dp[i]=min(dp[i],(dp[i-j]+abs(arr[i]-arr[i-j])));
            }
            else
                break;
        }
    }

    pfin(dp[n-1])

    return 0;
}

Measured memory_bytes: 1024
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;

const ll INF = 1LL << 32;

int main() {
  ll n, m;
  cin >> n >> m;

  vvll dist(n, vll(n, INF));
  vvP es(n);

  for (ll i = 0; i < m; i++) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    dist[a][b] = c;
    dist[b][a] = c;
    es[a].push_back(P(b, c));
  }

  rep(i, n) dist[i][i] = 0;
  rep(k, n) rep(i, n) rep(j, n) chmin(dist[i][j], dist[i][k] + dist[k][j]);

  ll ans = 0;
  for (ll j = 0; j < n; j++) {
    for (auto p : es[j]) {
      for (ll i = 0; i < n; i++) {
        ll b = p.first;
        ll c = p.second;
        if (dist[i][j] + c == dist[i][b]) {
          ans++;
          break;
        }
      }  // i
    }    // p
  }      // j

  cout << m - ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 924844033;

#define ALL(v) v.begin(), v.end()

int len[4000];
ll dp1[2001][2001][2];
ll dp2[4001][4001];
ll fact[2001];
int main() {
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < K; i++) {
		int x = i;
		int l = 0;
		while (x + K < N) {
			x += K;
			l++;
		}
		len[i] = l;
		len[i + K] = l;
	}
	dp1[0][0][0] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= i; j++) {
			(dp1[i + 1][j][0] += dp1[i][j][0]) %= MOD;
			(dp1[i + 1][j][0] += dp1[i][j][1]) %= MOD;
			(dp1[i + 1][j + 1][1] += dp1[i][j][0]) %= MOD;
		}
	}
	dp2[0][0] = 1;
	int sum = 0;
	for (int i = 0; i < 2 * K; i++) {
		for (int j = 0; j <= sum; j++) {
			for (int k = 0; k <= len[i]; k++) {
				ll x = (dp1[len[i]][k][0] + dp1[len[i]][k][1]) % MOD;
				(dp2[i + 1][j + k] += dp2[i][j] * x%MOD) %= MOD;
			}
		}
		sum += len[i];
	}
	fact[0] = 1;
	for (int i = 1; i <= N; i++) fact[i] = fact[i - 1] * i%MOD;
	ll ans = 0;
	for (int i = 0; i <= N; i++) {
		ll x = dp2[2 * K][i] * fact[N - i] % MOD;
		if (i % 2) (x *= MOD - 1) %= MOD;
		(ans += x) %= MOD;
	}
	cout << ans << endl;
}


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

typedef long long ll;

// 素因数分解O(√n)
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> res;
	for (ll i = 2; i*i <= n; i++) {
		while (n%i == 0) {
			++res[i];
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

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

	map<ll,ll> div;
	div = prime_factor(P);
	ll ans=1;
	for (auto itr = div.begin(); itr != div.end(); itr++) {
		if (itr->second >= N) {
			ll d = itr->second / N;
			for (int i = 0; i < d; i++) {
				ans *= itr->first;
			}
		}
		//cout << itr->first <<" "<< itr->second << endl;
	}

	cout << ans << endl;
}
	


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
public class Main
{
	
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
	    int A=scan.nextInt();
	    int B=scan.nextInt();
	    int H=scan.nextInt();
	    int M=scan.nextInt();
	    double mangle = (360.0/60.0)*M;
	    double hangle = (30.0*H)+(30.0/360.0)*mangle;
	    double angle = Math.abs(mangle-hangle);
	    if(angle>180) angle= 360-angle;
	    double ans = A*A+B*B-2*A*B*Math.cos(angle*(Math.PI/180));
	    ans = Math.sqrt(ans);
	    System.out.println(ans);
	}
}

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

using namespace std;

int main(void){
  long long n;
  int count = 0;
  
  cin >> n;
  
  string s = "";
  while(n){
    n--;
    s += 'a' + n%26;
    n /= 26;
  }
  
  reverse(s.begin(), s.end());
  cout << s;
  
  return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<tuple>
#include<queue>
#include<functional>
#define llint long long int
#define lldo long double
#define fir first
#define sec second
#define pub push_back
#define mp make_pair
#define mt make_tuple
#define res resize
const llint big=5e15;
void maxeq(int &a,int b){if(a<b){a=b;}}
bool mineq(llint &a,llint b){if(a>b){a=b;return true;}return false;}
using namespace std;
vector<vector<pair<int,int>>>nizyu;
vector<bool>sad;
vector<int>fuka;
vector<int>imos;
int dfs_tree(int ter,int oyhen=-1,int dep=0){
	fuka[ter]=dep;
	for(auto it:nizyu[ter]){
		if(it.sec==oyhen){continue;}
		if(fuka[ter]>=fuka[it.fir]){imos[it.fir]--;imos[ter]++;}
		else if(fuka[it.fir]!=114514){continue;}
		else{imos[ter]+=dfs_tree(it.fir,it.sec,dep+1);}
	}
	if(imos[ter]==0&&oyhen!=-1){sad[oyhen]=true;}
	return imos[ter];
}
int main(void){
	//???????????£?????????????§£
	int i,n,m;cin>>n>>m;
	vector<vector<pair<llint,int>>> hen(n);
	vector<vector<pair<llint,int>>> rehen(n);
	vector<tuple<int,int,llint>>edges(m);
	for(i=0;i<m;i++){
		int a,b;llint c;cin>>a>>b>>c;a--;b--;
		hen[a].pub(mp(c,b));
		rehen[b].pub(mp(c,a));
		edges[i]=mt(a,b,c);
	}
	vector<llint>dis(n,big);dis[0]=0;
	priority_queue<pair<llint,int>,vector<pair<llint,int>>,greater<pair<llint,int>>> tourist;
	//que_tourist!w
	tourist.push(mp(0,0));
	while(tourist.size()>0){
		llint time=tourist.top().fir;
		int town=tourist.top().sec;
		tourist.pop();
		if(dis[town]<time){continue;}
		for(auto it:hen[town]){
			if(!mineq(dis[it.sec],time+it.fir)){continue;}
			tourist.push(mp(dis[it.sec],it.sec));
		}
	}
	vector<llint>redis(n,big);redis[1]=0;
	tourist.push(mp(0,1));
	while(tourist.size()>0){
		llint time=tourist.top().fir;
		int town=tourist.top().sec;
		tourist.pop();
		if(redis[town]<time){continue;}
		for(auto it:rehen[town]){
			if(!mineq(redis[it.sec],time+it.fir)){continue;}
			tourist.push(mp(redis[it.sec],it.sec));
		}
	}
	//????????????????????????
	//???????????£?????????????§£
	llint mtotime=dis[1];
	nizyu.res(n);//???????????????
	sad.res(m);//true=sad
	for(i=0;i<m;i++){
		if(dis[get<0>(edges[i])]+redis[get<1>(edges[i])]+get<2>(edges[i])==mtotime)
		{nizyu[get<0>(edges[i])].pub(mp(get<1>(edges[i]),i));
		nizyu[get<1>(edges[i])].pub(mp(get<0>(edges[i]),i));}
	}
	fuka.res(n,114514);
	imos.res(n);
	dfs_tree(0,-1,0);
	for(i=0;i<m;i++){
		int a,b;llint c;
		tie(a,b,c)=edges[i];
		if(dis[b]+redis[a]+c<mtotime){cout<<"HAPPY"<<endl;}
		else if(dis[b]+redis[a]+c==mtotime){cout<<"SOSO"<<endl;}
		else if(sad[i]){cout<<"SAD"<<endl;}
		else{cout<<"SOSO"<<endl;}
	}
	return 0;
}

Measured memory_bytes: 29420
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 09/13/20 20:47:40
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
constexpr int MOD = 1e9+7;

ll modpow(int x, int p) {
  ll u = x;
  ll t = 1;
  while (p) {
    if (p & 1)
      (t *= u) %= MOD;
    (u *= u)%= MOD;
    p>>=1;
  }
  return t;
}

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

  int n; cin>>n;
  cout << (modpow(10, n) + MOD - modpow(9, n) * 2 % MOD + modpow(8, n)) % MOD << endl;

  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
//#include "stdc++.h"
#define llint long long int
#define ldouble long double

using namespace std;

int main() {
    int maxi=0; //最大のやつ
    int tmx=0; //forの中でのtemporary
    string S;
    cin>>S;
    string enki="ATGC";
    for(int i=0;i<S.size();i++){
        bool jg=false;
        for(int j=0;j<4;j++){
            if(S[i]==enki[j]){
                tmx++;
                jg=true;
                break;
            }
        }

        if(jg==false || (i==S.size()-1 && jg==true)){
            if(tmx>maxi){
                maxi=tmx;
                tmx=0;
            }
        }
    }

    cout<<maxi<<endl;
return 0;
}

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

typedef int32_t i32;
typedef int64_t i64;

#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) > (0) ? (a) : -(a))

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  printf ("%" PRIi32 "\n", 180 * (n - 2));
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)

using namespace std;

uint64_t kRem = 998244353;


int64_t pow_rem(int64_t val, int64_t mul, int64_t rem)
{
	if (mul == 1) return val;

	int64_t ret = pow_rem(val, mul / 2, rem);
	ret *= ret;
	ret %= rem;

	if (mul & 1) {
		ret *= val;
		ret %= rem;
	}

	return ret;
}

int main()
{
	int n; cin >> n;
	vector<int> ns(n);
	int m = 0;
	for (auto& elem : ns) {
		cin >> elem;
		m += elem;
	}

	vector<vector<int64_t>> dp_r(n, vector<int64_t> (m + 1));

	dp_r[0][0] = 2;
	dp_r[0][ns[0]] = 1;

	FOR_LT(i, 0, n - 1) {
		FOR_LE(v, 0, m) {
			if (dp_r[i][v] != 0) {
				dp_r[i + 1][v] += dp_r[i][v] * 2;
				dp_r[i + 1][v + ns[i + 1]] += dp_r[i][v];
			}
		}

		FOR_LE(v, 0, m) {
			if (dp_r[i + 1][v] != 0) {
				dp_r[i + 1][v] %= kRem;
			}
		}
	}


	vector<vector<int64_t>> dp_rb(n, vector<int64_t>(m + 1));
	dp_rb[0][0] = 1;
	dp_rb[0][ns[0]] = 1;

	FOR_LT(i, 0, n - 1) {
		FOR_LE(v, 0, m) {
			if (dp_rb[i][v] != 0) {
				dp_rb[i + 1][v] += dp_rb[i][v];
				dp_rb[i + 1][v + ns[i + 1]] += dp_rb[i][v];
			}
		}

		FOR_LE(v, 0, m) {
			if (dp_rb[i + 1][v] != 0) {
				dp_rb[i + 1][v] %= kRem;
			}
		}
	}

	int64_t ng_cases = 0;
	FOR_LE(v, ((m + 1) / 2), m) {
		ng_cases += dp_r[n - 1][v];
		ng_cases %= kRem;
	}
	if ((m & 1) == 0) {
		ng_cases -= dp_rb[n - 1][m / 2];
		if (ng_cases < 0) ng_cases += kRem;
	}
	ng_cases *= 3;
	ng_cases %= kRem;

	int64_t all_cases = 0;
	all_cases = pow_rem(3, n, kRem);

	int64_t ans = (all_cases - ng_cases);
	if (ans < 0) ans += kRem;
 
	cout << ans << endl;
}

Measured memory_bytes: 422464
#include <stdio.h>

int main(){
  int a,b,c,d,e,i,j,n,t;

  scanf("%d\n",&t);
  for(i=0;i<t;i++){
    scanf("%d\n",&n);
    d=0;e=0;
    scanf("%d",&a);
    for(j=1;j<n;j++){
      scanf("%d",&b);
      c=a-b;
      if(c<d) d=c;
      if(c>e) e=c;
      a=b;
    }
    printf("%d %d\n",-d,e);
  }

  return 0;
}

Measured memory_bytes: 596
#include <iostream>
using namespace std;
int main(int argc, char *argv[]) {
    string S;
    cin >> S;
    int i = 1;
    bool easy = true;
    for (auto c : S) {
        if (i % 2 == 0) {
            if (!(c == 'L' || c == 'U' || c == 'D')) { easy = false; break; }
        } else {
            if (!(c == 'R' || c == 'U' || c == 'D')) { easy = false; break; }
        }
        i++;
    }
    cout << (easy ? "Yes" : "No") << endl;
    return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static string S;

        static void Main(string[] args)
        {
            //[summary]D - Lucky PIN
            int N = int.Parse(Console.ReadLine());
            S = Console.ReadLine();
            int count = 0;

            for(int i = 0; i < 1000; i++)
            {
                var pin = i.ToString().PadLeft(3, '0');

                if (CanBeSet(pin))
                {
                    count++;
                }                
            }

            Console.WriteLine(count);
        }

        static bool CanBeSet(string pin)
        {
            var s = S;

            foreach (var p in pin)
            {
                var n = s.IndexOf(p);

                if (n > -1)
                {
                    n++;
                    s = s.Substring(n, s.Length - n);
                }
                else
                {
                    return false;
                }
            }

            return true;
        }
    }
}

Measured memory_bytes: 31712
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    bool ok=false;
    for(int i=0;i<t.size();i++)
    {
        if(s==t)
        {
            ok=true;
            break;
        }
        t=t.back()+t.substr(0,t.size()-1); /// substr(string,start,length)

    }
       if(ok)
       {
           cout<<"Yes";
       }
       else
       {
           cout<<"No";
       }
}


Measured memory_bytes: 3604
A, B, K = map(int, input().split())
for i in range(K):
    if i % 2 == 0:
        if A % 2 == 1:
            A -= 1
        B += A // 2
        A //= 2
    else:
        if B % 2 == 1:
            B -= 1
        A += B // 2
        B //= 2
print(A, B)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    ll n; cin >> n;
    vector<ll> A(n);
    for(int i = 0; i < n; i++) cin >> A[i];
    vector<ll> abs_A(n);
    int negative_cnt = 0;
    for(int i = 0; i < n; i++)
    {
        if(A[i] <= 0) negative_cnt++;
        abs_A[i] = abs(A[i]);
    }
    ll m = INF;
    ll ans = 0;
    for(int i = 0; i < n; i++)
    {
        m = min(m, abs_A[i]);
        ans += abs_A[i];
    }
    if(negative_cnt % 2 == 0)
    {
        cout << ans << endl;
    }
    else
    {
        cout << ans - 2LL * m << endl;
    }
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void) {
    int n, k, q, i, a;
    scanf("%d %d %d", &n, &k, &q);
    int player[n+1];

    for (i = 1; i <= n; i++) {
        player[i] = k - q;
    }

    for (i = 0; i < q; i++) {
        scanf("%d", &a);
        player[a]++;
    }

    for (i = 1; i <= n; i++) {
        if (player[i] > 0) printf("Yes\n");
        else printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 896
#include<stdio.h>
int main()

{
	int A, B;
	scanf("%d%d", &A, &B);
	
	int deka;
	
	if (B>=0)
	{
		if (A+B >= A*B) deka = A+B;
		else deka = A*B;
	}
	
	else
	{
		if (A-B >= A*B) deka = A-B;
		else deka = A*B;
	}
	
	printf ("%d", deka);
		return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] strings = line.split(" ");
		int a = Integer.parseInt(strings[0]);
		int b = Integer.parseInt(strings[1]);
		int c = Integer.parseInt(strings[2]);
		if (a < b && b < c && a < c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}

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

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

#define fr first
#define sc second

int main(){
	static int n;
	static int a[200010],b[200010];
	scanf("%d",&n);
	for(int i = 0 ; i < n ; i ++){
		scanf("%d",&a[i]);
	}
	for(int i = 0 ; i < n ; i ++){
		scanf("%d",&b[i]);
	}
	
	int ret = 0;
	for(int t = 0 ; t < 30 ; t ++){
		ll cnt = 0;
		for(int i = 0 ; i < n ; i ++){
			cnt += (a[i]>>t)&1;
			cnt += (b[i]>>t)&1;
		}
		cnt *= n;
		vector<int> vec;
		for(int i = 0 ; i < n ; i ++){
			vec.push_back(b[i]&((1<<t)-1));
		}
		sort(vec.begin(),vec.end());
		for(int i = 0 ; i < n ; i ++){
			cnt += vec.end()-lower_bound(vec.begin(),vec.end(),(1<<t)-(a[i]&((1<<t)-1)));
		}
		/*vec.clear();
		for(int i = 0 ; i < n ; i ++){
			vec.push_back(a[i]&((1<<t)-1));
		}
		sort(vec.begin(),vec.end());
		for(int i = 0 ; i < n ; i ++){
			cnt += vec.end()-lower_bound(vec.begin(),vec.end(),(1<<t)-(b[i]&((1<<t)-1)));
		}*/
		if(cnt%2 == 1){
			ret += (1<<t);
		}
	}
	cout << ret << endl;
}



Measured memory_bytes: 3668
import math

ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

n = ii()
s = 0
for i in range(n):
    s += n // (i+1)
    if (n % (i+1)) == 0:
        s = s-1

print(s)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    string S = in<string>();
    cout << (S[2] == S[3] && S[4] == S[5] ? "Yes" : "No") << "\n";
}

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

int main()
{

	int hill[10];
	for (int i = 0; i < 10; i++) {
		cin >> hill[i];
	}

	for (int i = 0; i < 10; i++) {
		for (int j = i + 1; j < 10; j++) {
			if (hill[i] < hill[j]) {
				int tmp = hill[i];
				hill[i] = hill[j];
				hill[j] = tmp;
				//cout << "ALICE!" << endl;
			}
		}
	}

	//cout << endl << endl;

	for (int i = 0; i < 3; i++) {
		cout << hill[i] << endl;
	}

	//cin >> hill[1];
    return 0;
}

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

using namespace std;

#define N 100000

int n, m, cnt[N + 5];
set<int> s;

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; ++i)
        cnt[i] = 1;
    s.insert(1);
    for (int i = 1, x, y; i <= m; ++i) {
        scanf("%d%d", &x, &y);
        cnt[x]--, cnt[y]++;
        if (s.count(x))
            s.insert(y);
        if (!cnt[x] && s.count(x))
            s.erase(s.lower_bound(x));
        
    }
    printf("%d\n", s.size());
    return 0;
}

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


#define en "\n"
#define sqrt(n) sqrt((long double) n)
#define all(c) (c).begin() , (c).end()
#define MOD 1000000007
#define mem(a) memset(a,0,sizeof(a))
#define flash() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file_input(name) name!=""?freopen(name".in","r",stdin),freopen(name".out","w",stdout):0
#define SORT(x) sort(all(x))
#define REVERSE(x) reverse(all(x))


using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef set<int> seti;
typedef pair<double, double> pdd;
typedef long double ld;



const double EPS=0.000000001;
const double INFD32=1000000000;
const ll INF64=1000000000000000000;
const int INF32=1000000000;

#define maxN 30000000
int ans[200001];
int n,q,p,p1,a,b;
vector<vector<int> >v(200001);
void dfs(int i,int parent){
  for(int k:v[i]){
    if(k==parent)continue;
    ans[k]+=ans[i];
    dfs(k,i);
  }
}
signed main(void){
    int t=1;
    //cin>>t;
    while(t--){
     int n,q;
     cin>>n>>q;
     for(int i=1;i<n;i++){
       cin>>a>>b;
       v[a].push_back(b);
       v[b].push_back(a);
     }
     for(int i=1;i<=q;i++){
       cin>>p;
       cin>>p1;
       ans[p]+=p1;
     }
     dfs(1,0);
     for(int i=1;i<=n;i++){
       cout<<ans[i]<<" ";
     }
    }
    return 0;
  }


Measured memory_bytes: 23424