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

const int MAX = 2 * pow(10, 5);
const int VISITED = 1;
const int UNVISITED = 0;
int color[MAX];
vector<vector<int>> G(MAX); //connected list G

int dfs(int r){
  stack<int> S;
  S.push(r);
  int num = 1;
  color[r] = VISITED;
  while(!S.empty()){
    int u = S.top();
    S.pop();
    for(int i = 0; i < G[u].size(); i++){
      int v = G[u][i];
      if(color[v] == UNVISITED){
        color[v] = VISITED;
        S.push(v);
        num += 1;
      }
    }
  }
  return num;
}



int main(){
  int N;
  int M;
  cin >> N >> M;
  vector<int> A(M);
  vector<int> B(M);
  for(int i = 0; i < M; i++){
    cin >> A[i]>> B[i];
  }
  
  for(int i = 0; i < M; i++){
    G[A[i] - 1].push_back(B[i] - 1);
    G[B[i] - 1].push_back(A[i] - 1);
  }
  
  for(int i = 0; i < N; i++){
    sort(G[i].begin(), G[i].end());
    color[i] = UNVISITED;
  }
  
  int ans = 0;
  for(int i = 0; i < N; i++){
    if(color[i] == UNVISITED){
      ans = max(ans, dfs(i));
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 17072
#include<stdio.h>
int main(void)
{
  double left,right;
  int lA=0,lB=0,lC=0,lD=0;
  int rA=0,rB=0,rC=0,rD=0;
  
  while(scanf("%lf %lf",&left,&right)!=EOF)
    {

      if(left>=1.1)lA++;
      else if(left>=0.6 && left<1.1)lB++;
      else if(left>=0.2 && left<0.6)lC++;
      else if(left<0.2)lD++;

      if(right>=1.1)rA++;
      else if(right>=0.6 && right<1.1)rB++;
      else if(right>=0.2 && right<0.6)rC++;
      else if(right<0.2)rD++;
    }
  printf("%d %d\n",lA,rA);
  printf("%d %d\n",lB,rB);
  printf("%d %d\n",lC,rC);
  printf("%d %d\n",lD,rD);
  
  return 0;
}

Measured memory_bytes: 0
// Problem : A - Nickname
// Contest : AtCoder - Tokio Marine & Nichido Fire Insurance Programming Contest
// 2020 URL :
// https://atcoder.jp/contests/tokiomarine2020/tasks/tokiomarine2020_a Memory
// Limit : 1024 MB Time Limit : 2000 ms Powered by CP Editor
// (https://github.com/cpeditor/cpeditor)
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb push_back
#define mk make_pair
#define fast                    \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define rep(i, a, b) for (ll i = a; i < b; i++)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define sz(x) (int)x.size()
#define mem(a, val) memset(a, val, sizeof(a))
#define deci(x) cout << fixed << setprecision(x);
#define bitcount(x) __builtin_popcountll(x)

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

const long long int mod = 1e9 + 7;
const long double EPS = 1e-12;
const int N = 1e5 + 20;

void solve() {
  string s;
  cin >> s;
  cout << (s.substr(0, 3));
}
int main() {
  fast;
  ll t;
  t = 1;

  // cin>>t;

  while (t--) {
    solve();
  }

  return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
	int n;
	cin >> n;
	int n1 = n / 10;
	int n2 = n % 1000;
	if(n1 % 111 == 0 || n2 % 111 == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
		int a,b,c,x,y,z;
	scanf("%d %d %d",&a,&b,&c);
	
	if(a>b){
		x=b;
		b=a;
		a=x;
	}
	
	if(b>c){
		x=b;
		b=c;
		c=x;
	}
	
		if(a>b){
		x=b;
		b=a;
		a=x;
	}
	
	printf("%d %d %d\n",a,b,c);
	
	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int n,m;
int map[510][510];
int q1[252510],p1[252510],x2[555510],y2[523510],cnt;
int main() {
	cin>>n>>m;
	for(int i=1; i<=n; ++i) {
		for(int j=1; j<=m; ++j) {
			cin>>map[i][j];
			map[i][j]%=2;
		}
	}
	for(int i=1; i<=n; ++i) {
		for(int j=1; j<=m; ++j) {
			if(map[i][j]==0)continue;
			if(map[i][j]==map[i+1][j]) {
				q1[++cnt]=i;
				p1[cnt]=j;
				x2[cnt]=i+1;
				y2[cnt]=j;
				map[i][j]=map[i+1][j]=0;
			} else if(map[i][j]==map[i][j+1]) {
				q1[++cnt]=i;
				p1[cnt]=j;
				x2[cnt]=i;
				y2[cnt]=j+1;
				map[i][j]=map[i][j+1]=0;
			} else if(i<n) {
				q1[++cnt]=i;
				p1[cnt]=j;
				x2[cnt]=i+1;
				y2[cnt]=j;
				map[i][j]=0;
				map[i+1][j]^=1;
			} else if(j<m) {
				q1[++cnt]=i;
				p1[cnt]=j;
				x2[cnt]=i;
				y2[cnt]=j+1;
				map[i][j]=0;
				map[i][j+1]^=1;
			}
		}
	}
	cout<<cnt<<endl;
	for(int i=1; i<=cnt; ++i) {
		cout<<q1[i]<<" "<<p1[i]<<' '<<x2[i]<<' '<<y2[i]<<endl;
	}
}

Measured memory_bytes: 7680
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mem(a,b) memset((a),(b),sizeof(a))
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
using namespace std;
#define _GLIBCXX_PERMIT_BACKWARD_HASH
#include <ext/hash_map>
using namespace __gnu_cxx;
struct str_hash{size_t operator()(const string& str)const{return __stl_hash_string(str.c_str());}};
typedef long long ll;
typedef unsigned long long ull;
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDD pair<double,double>
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-8;
const int MAX=1e3+10;
const ll mod=1e9+7;
vector<int> mp[MAX];
int link[MAX],used[MAX];
int dfs(int x)
{
	int i,to;
	for(i=0;i<sz(mp[x]);i++)
	{
		to=mp[x][i];
		if(!used[to])
		{
			used[to]=1;
			if(link[to]==-1||dfs(link[to]))
			{
				link[to]=x;
				return 1;
			}
		}
	}
	return 0;
}
int hungary(int n)
{
	mem(link,-1);
	int i,res=0;
	for(i=1;i<=n;i++)
	{
		mem(used,0);
		if(dfs(i)) res++;
	}
	return res;
}
int main()
{
	int n,i,j,x[211],y[211];
	while(~scanf("%d",&n))
	{
		n*=2;
		for(i=1;i<=n;i++)
		{
			scanf("%d%d",&x[i],&y[i]);
			mp[i].clear();
		}
		for(i=1;i<=n/2;i++)
		{
			for(j=n/2+1;j<=n;j++)
			{
				if(x[i]<x[j]&&y[i]<y[j])
				{
					mp[i].pb(j);
				}
			}
		}
		printf("%d\n",hungary(n));
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <iostream>
#include <queue>
#include <numeric>
#include <cmath>
typedef long long LL;
const LL maxn = 0x7fffffff;
const LL mo = 1000000007;
using namespace std;
LL findLine(LL n) {
    LL left, right, ret = 0;
    scanf("%lld", &left);
    for (int i = 1; i < n; i++) {
        scanf("%lld", &right);
        LL b = right - left;
        LL times = i * (n - i);
        (ret += b * times) %= mo;
        left = right;
    }
    //printf("%lld\n", ret);
    return ret;
}

int main() {
    LL m, n;
    scanf("%lld %lld", &n, &m);
    LL sum = findLine(n) * findLine(m) % mo;
    printf("%lld\n",  sum);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int q;
  cin >> q;

  priority_queue<int> l; priority_queue<int,vector<int>,greater<int>> r;
  l.push(-1e9); r.push(1e9);
  ll ans = 0;  
  rep(qi,q){
    int t;
    cin >> t;
    if(t==1){
      int a,b;
      cin >> a >> b;

      if(a<l.top()) {
        ans+=l.top()-a;
      }
      if(a>r.top()) {
        ans+=a-r.top();
      }
      if(a<l.top()) {
        rep(i,2)l.push(a);
        r.push(l.top()); l.pop();
      }else{
        rep(i,2)r.push(a);
        l.push(r.top()); r.pop();
      }

      ans += b;
    }else{
      printf("%d %lld\n",l.top(),ans);
    }
  }
}


Measured memory_bytes: 3828
//ALDS1_2_4 Sort I - Shell Sort
#include <iostream>
using namespace std;

void trace(int c[], size_t n)
{
    for(int i=0; i<n; i++ ) {
        cout << c[i];
        if(i<n-1) cout << " ";
    }
    cout << endl;
}

void traceV(int c[], size_t n)
{
    for(int i=0; i<n; i++ ) {
        cout << c[i] << endl;
    }
}

int insertionSort(int A[], int n, int gap)
{
    int j,key,cnt=0;

    for (int i = gap; i < n; i++)
    {
        key = A[i];
        j = i - gap;        
        while (j >= 0 && A[j] > key)
        {
            A[j+gap] = A[j];
            j= j - gap;
            cnt++;
        }
        A[j+gap] = key;
    }  
    return cnt;
}

void shellSort(int A[], int n)
{
    int cnt=0;
    int G[20];
    int d = 2;
    int count = 0;
    int nS=0;
    int nIns;
    int gap;

    if (n<=d) {
        nIns = insertionSort(A,n,d-1);
            G[nS++] = d-1;
            count += nIns;
    } else {
        for (gap = n/d; gap>0; gap /= d) {
            nIns = insertionSort(A,n,gap);
            G[nS++] = gap;
            count += nIns;
        }
    }
    cout << nS << endl;
    trace(G,nS);
    cout << count << endl;
    traceV(A,n);
}

int main()
{
    size_t length;
    cin >> length;
    int a[1000000];
    
    for(size_t i=0; i<length; i++) {
        cin >> a[i];
    }
    shellSort(a,length);

}


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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);
constexpr long long MOD(long long in) {
	return in % mod;
}

ll k;
ll f(ll n) {
	long double calc = inf;
	ll ans = 0;
	for (int d = 0, end = std::log10(n) + 1; d <= end; d++) {
		ll p = std::pow(10, d);
		ll num = (n / p) * p + (p * 10 - 1);

		ll tmp = num;
		ll sum = 0;
		while (tmp != 0) {
			sum += tmp % 10;
			tmp /= 10;
		}

		long double tmp2 = ((long double)num) / sum;
		if (calc > tmp2) {
			calc = tmp2;
			ans = num;
		}
	}

	return ans;
}

int main()
{
	std::cin >> k;

	for (int i = 1; i < 10 && k; i++, k--)
		std::cout << i << std::endl;

	ll n = 9;
	for (int i = 0; i < k; i++) {
		n = f(n + 1);
		std::cout << n << std::endl;
	}

	return 0;
}


Measured memory_bytes: 640
n,y =  map(int, input().split())
y *= 0.001
y = int(y)
a,b,c = -1,-1,-1
for i in range(0,n+1):
    d = i*10
    for j in range(0,n+1):
        money = y
        money -= d
        if n-i-j >= 0:
            money -= j*5 + (n-i-j)
            if money == 0:
                a,b,c = i,j,n-i-j
                break
print(a,b,c)


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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> vec(n);
  rep(i, m)
  {
    int a, b;
    cin >> a >> b;
    vec[a - 1]++;
    vec[b - 1]++;
  }
  rep(i, n)
  {
    cout << vec[i] << endl;
  }
}


Measured memory_bytes: 256
/*
Dont BLUNDER
*/

// #pragma GCC optimize("O3")
// //#pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;


 */
//#define d long double
#define int long long
#define pii pair<int,int>
#define pb push_back
#define endl '\n'
#define pi acos(-1)

#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
int const mod1 = 998244353;
int const mod = 1000000007;
#define bitcount(x)       __builtin_popcountll(x)
#define l first
#define r second
const int inf = LLONG_MAX;
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// * Using PBDS *
/*typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
               os; */



int modexp(int x, int n) {
	if (n == 0) {
		return 1;
	}
	else if (n & 1) {
		return (modexp((x * x) % mod, n / 2) % mod * x % mod) % mod;
	}
	else {
		return (modexp((x * x) % mod, n / 2) % mod);
	}
}

int modinv(int n)
{
	return modexp(n, mod - 2);
}

int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}
bool comp(pair<int, pii> a, pair<int, pii> b) {
	if (a.first == b.first) {
		return a.second.first < b.second.first;
	}
	return a.first < b.first;

}




signed main()
{
	haha
// #ifndef ONLINE_JUDGE

// 	freopen("inp.txt", "r", stdin);

// 	freopen("out1.txt", "w", stdout);
// #endif
	int d, s, t;
	cin >> d >> s >> t;
	if (s * t >= d)
		cout << "Yes";
	else
		cout << "No";















}

Measured memory_bytes: 3656
S = input()
N = 10**9 + 7
d = {str(i):[int(i == k) for k in range(10)] for i in range(10) }
d["?"] = [1] * 10 
l = d[S[0]] + [0]*3
#print(l)
for i in range(1, len(S)):
  if S[i] == "?":
    l = [(sum([l[((k - j) * 4)%13] for j in range(10)]))%N for k in range(13)]
  else:
    l = [l[((k - int(S[i])) * 4)%13] for k in range(13)]
  #print(l)
print(l[5])         

Measured memory_bytes: 44524
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  bool ans=false;
  if(s[0]==s[1] && s[0]!=s[2] && s[2]==s[3]) ans=true;
  if(s[0]==s[2] && s[0]!=s[1] && s[1]==s[3]) ans=true;
  if(s[0]==s[3] && s[0]!=s[1] && s[1]==s[2]) ans=true;
  puts(ans?"Yes":"No");
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int arr[n+1];
  memset(arr,0,sizeof arr);
  for(int i=0;i+1<n;i++){
    int j;
    cin>>j;
    arr[j]++;
  }
  for(int i=1;i<=n;i++) cout<<arr[i]<<"\n";
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
	char inp[10];
	scanf("%s",inp);
	int xb;
	for(xb=0;xb<strlen(inp)-1;++xb){
		if(inp[xb]=='A'&&inp[xb+1]=='C'){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()

def main():
    N,T=map(int,input().split())
    cc=[]
    for _ in range(N):
        c,t=map(int,input().split())
        if t <= T:
            cc.append(c)
    if cc:
        print(min(cc))
    else:
        print('TLE')

main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
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 Graph = vector<vector<int>>;
signed main(){
int a,b,c;
  cin>>a>>b>>c;
  if((a+b+c)<22)
    cout<<"win";
  else
    cout<<"bust";
}

Measured memory_bytes: 256
N, L = map(int, input().split())
if L >= 0:
    ans = L*(N-1) + N*(N-1)//2
    print(ans)
    exit()
elif -L <= N-1:
    ans = L*N + N*(N-1)//2
    print(ans)
    exit()
else:
    ans = L*(N-1) + (N-1)*(N-2)//2
    print(ans) 


Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long int ll;
int main(){
	ll k;
	ll a[100000];
	ll r = 3, l = 2;
	scanf("%lld",&k);
	for(int i=0;i<k;i++) scanf("%lld",a+i);
	reverse(a,a+k);
	for(int i=0;i<k;i++){
		ll nl,nr;
		if(l%a[i]==0) nl = l;
		else nl = (l/a[i]+1)*a[i];
		nr = ((r-1)/a[i])*a[i]+a[i];
		if(nl>=nr){
			printf("-1\n");
			return 0;
		}
		l = nl;
		r = nr;
	}
	printf("%lld %lld\n",l,r-1);
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int all = 1, odd = 1;
    rep(i,n)  {
        cin >> a[i];
        if(a[i]%2==0) odd*=2;
        all*=3; 
    } 
    int ans = all-odd;
    cout << ans << endl;

    return 0;
}

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

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

  int num[200010] = {};
  set<int> st;
  int maxid = -1;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    num[A]++;
    st.insert(A);
    if (A > maxid) maxid = A + 1;
  }

  int dif = K - st.size();

  if (dif >= 0) {
    cout << 0 << endl;
    return 0;
  }

  sort(num, num + maxid);
  
  int ans = 0, cnt = 0;
  for (int i = 0; i < maxid; i++) {
    if (num[i] > 0) {
      ans += num[i];
      cnt++;
    }
    if (cnt == abs(dif)) {
      cout << ans << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 10368
#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
// #define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

const ll MOD = 1e9 + 7;

void solve(string& S) {
    unordered_map<char, int> chars;

    for (const auto c : S) {
        chars[c]++;
    }

    bool answer = true;
    for (const auto pair : chars) {
        if (pair.second != 2) {
            answer = false;
            break;
        }
    }

	stringstream ss;
    ss << (answer ? "Yes" : "No");
	cout << ss.str() << '\n';

    return;
}

signed main() {
    string S;
    cin >> S;
    
    solve(S);
    
    return 0;
}



Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S = input()

print("No" if len(set(S))==1 else "Yes")


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

ll n, k;

int main() {
	cin>>n>>k;
	ll p[n+1], c[n+1], ans=-1e18;
	bool vis[n+1];
	memset(vis, 0, sizeof(vis));
	for (int i=1; i<=n; i++) {
		cin>>p[i];
	}
	for (int i=1; i<=n; i++) {
		cin>>c[i];
	}
	for (int i=1; i<=n; i++) {
		if (!vis[i]) {
			vector <ll> v;
			v.push_back(c[i]);
			vis[i]=1;
			ll x=i;
			while (!vis[p[x]]) {
				vis[p[x]]=1;
				x=p[x];
				v.push_back(c[x]);
			}
			ll u=v.size();
			for (int j=0; j<u; j++) {
				v.push_back(v[j]);
			}
			for (int j=1; j<=min(u, k); j++) {
				ll ps=0;
				for (int l=0; l<j; l++) {
					ps+=v[l];
				}
				ll temp=ps;
				for (int l=1; l<u; l++) {
					ps=ps-v[l-1]+v[l+j-1];
					temp=max(temp, ps);
				}
				ans=max(ans, temp);
			}
			if (k>u) {
				ll sum=0;
				for (int j=0; j<u; j++) {
					sum+=v[j];
				}
				if (sum>0) {
					ll cy=(k/u)*sum;
					ll sisa=k%u;
					for (int j=1; j<=sisa; j++) {
						ll ps=0;
						for (int l=0; l<j; l++) {
							ps+=v[l];
						}
						ll temp=ps;
						for (int l=1; l<u; l++) {
							ps=ps-v[l-1]+v[l+j-1];
							temp=max(temp, ps);
						}
						ans=max(ans, cy+temp);
					}
					cy-=sum;
					for (int j=1; j<=u; j++) {
						ll ps=0;
						for (int l=0; l<j; l++) {
							ps+=v[l];
						}
						ll temp=ps;
						for (int l=1; l<u; l++) {
							ps=ps-v[l-1]+v[l+j-1];
							temp=max(temp, ps);
						}
						ans=max(ans, cy+temp);
					}
				}
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3816
// C++ program to find LCM of n elements 
#include <bits/stdc++.h> 
using namespace std; 

typedef long long int ll; 

// Utility function to find 
// GCD of 'a' and 'b' 
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 

// Returns LCM of array elements 
ll findlcm(int arr[], int n) 
{ 
    // Initialize result 
    ll ans = arr[0]; 

    // ans contains LCM of arr[0], ..arr[i] 
    // after i'th iteration, 
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (gcd(arr[i], ans))); 

    return ans; 
} 

// Driver Code 
int main() 
{ 
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];

   int l= findlcm(arr, n);
float c=0;
   for(int i=0;i<n;i++)
   {
c=c+l/arr[i];
   } float k=l; 
   float ans=k/c;   // cout<<k<<' '<<c<<endl;
   cout<<fixed<<showpoint;
   cout<<setprecision(9)<<ans<<endl;
    return 0; 
} 


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

#define MAX 12
#define MAX_ORDER 16777216

char dec[MAX_ORDER][MAX];

int getChar_ID(char c){
  if(c == 'A'){
    return 1;
  }else if(c == 'C'){
    return 2;
  }else if(c == 'G'){
    return 3;
  }else if(c == 'T'){
    return 4;
  }else return -1;
}

long analysis(char *str){
  int len = strlen(str);
  int i;
  int id=0;
  int k=1;
  //printf("in to analysis\n" );
  for(i=0; i<len; i++){
    id += k * getChar_ID(str[len-i-1]);
    k *= 4;
    //printf("len-i=%d\n",len-i );
    //printf("Now ID: %d\n", id);
  }
  return id;
}

void insert(int id, char *str){
  strcpy(dec[id],str);
}

void find(int id,char *str){
  if(0==strcmp(dec[id],str)){
    printf("yes\n" );
  }else printf("no\n" );
}

int main() {
  int n;
  char str[MAX];
  char com[7];
  int i;

  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%s %s",com,str);
    if(com[0]=='i'){
      insert(analysis(str),str);
    }else if(com[0]=='f'){
      find(analysis(str),str);
    }else printf("Command is illegal\n");
  }
  return 0;
}



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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long n, k, a[200005], suma = 0, liczba = 0;
    cin >> n >> k;
    for(int i=0; i<n; i++) {
        cin >> a[i];
        liczba += a[i];
    }
    if(k == 0) {
        cout << liczba;
        return 0;
    }
    sort(a, a+n);
    for(int i=0; i<n-k; i++) {
        suma += a[i];
    }
    cout << suma;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long double n, k;
    cin >> n >> k;
    vector<long double> v;
    for (int i = 1; i <= n; i++)
    {
        long double y = k / i;
        long double x = ceil(log2(y));
        if (x < 0)
            x = 0;
        v.push_back(x);
    }
    vector<long double> st;
    for (int i = 0; i < v.size(); i++)
    {
        long double x = (long double)1 / n;
        for (int j = 0; j < v[i]; j++)
        {
            x *= (long double)1 / 2;
        }
        st.push_back(x);
    }
    long double sum = 0;
    for (int i = 0; i < v.size(); i++)
    {
        sum += st[i];
    }
    cout << setprecision(15) << sum<<endl;;
}


Measured memory_bytes: 6000
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

#define MOD_BIG 1000000007
#define MOD_BIG2 998244353
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using std::vector;

template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

//////////////////////////////////////


//////////////////////////////////////

int main() {
    
    string S;
    
    cin >> S;
    if (S == "SUN") {
        cout << 7 << endl;
    } else if (S == "MON") {
        cout << 6 << endl;
    } else if (S == "TUE") {
        cout << 5 << endl;
    } else if (S == "WED") {
        cout << 4 << endl;
    } else if (S == "THU") {
        cout << 3 << endl;
    } else if (S == "FRI") {
        cout << 2 << endl;
    } else if (S == "SAT") {
        cout << 1 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 384
// Last Change: 11/14/2019 18:38:01.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

void solve(ll N) {
  vector<ll> P(N);
  for (auto &&e : P) {
    cin >> e;
  }
  sort(P.begin(), P.end());
  ll res, temp;
  res = temp = 0;
  for (auto &&e : P) {
    temp += e;
    res += temp;
  }
  cout << res << endl;
}

int main() {
  ll N;
  while (cin >> N) {
    solve(N);
  }
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define ll long long
#define lsb(x) (x & (-x))


using namespace std;

const int MAXN = (int) 1e5;

struct Segm {
    int a, b, c;
}v[MAXN + 1];

int ind[MAXN + 1];

bool cmp(int a, int b) {
    return v[a].a * v[b].b > v[b].a * v[a].b;
}

int aib[MAXN + 1];

inline void update(int p) {
    for(int i = p; i <= MAXN; i += lsb(i))
        aib[i]++;
}

inline int query(int p) {
    int ans = 0;
    for(int i = p; i > 0; i -= lsb(i))
        ans += aib[i];
    return ans;
}

pair <double, int> vec[MAXN + 1];

inline int check(double x, int n) {
    int ans = 0;
    memset(aib, 0, sizeof(aib));
    for(int i = 1; i <= n; i++) {
        ans += query(vec[i].second);
        update(vec[i].second);
    }
    return ans;
}

int main() {
    //fstream cin("A.in");
    //ofstream cout("A.out");
    int i, n;
    ios::sync_with_stdio(false);
    cin >> n;
    for(i = 1; i <= n; i++) {
        cin >> v[i].a >> v[i].b >> v[i].c;
    }
    for(int t = 0; t < 2; t++) {
        for(i = 1; i <= n; i++) {
            if(v[i].b < 0) {
                v[i].a *= -1;
                v[i].b *= -1;
                v[i].c *= -1;
            }
            ind[i] = i;
        }
        sort(ind + 1, ind + n + 1, cmp);
        double pas = 1.0, rez = -1e9;
        for(; pas <= 1e9; pas *= 2.0);
        for(int p = 0; p < 80; p++) {
            for(i = 1; i <= n; i++)
                vec[i] = {(v[ind[i]].c - (rez + pas) * v[ind[i]].a) / v[ind[i]].b, i};
            sort(vec + 1, vec + n + 1);
            if(check(rez + pas, n) < ((n * (n - 1)) / 2 + 1) / 2)
                rez += pas;
            pas /= 2.0;
        }
        cout << setprecision(20) << rez;
        if(t == 0)
            cout << " ";
        for(i = 1; i <= n; i++)
            swap(v[i].a, v[i].b);
    }
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 1920
using System.Linq;
using System;

public class P
{
    public int id { get; set; }
    public int diff { get; set; }
    public int time { get; set; }
}

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var m = int.Parse(line[1]);
            if (n == 0 && m == 0) break;
            var ps = new P[n];
            line = Console.ReadLine().Trim().Split(' ');
            for (int i = 0; i < n; i++)
            {
                var w = int.Parse(line[i]);
                ps[i] = new P { id = i + 1, diff = w, time = (m / w) * w };
            }
            getAns(n, ps);
        }
    }
    static void getAns(int n, P[] ps)
    {
        var t = ps.OrderBy(x => x.time).ThenBy(x => x.diff).ToArray();
        if (t[0].time < t[1].time) { Console.WriteLine(t[0].id); return; }
        if (t[0].time == t[1].time && t[0].diff < t[1].diff) { Console.WriteLine(t[0].id); return; }
        Console.WriteLine(n);
    }
}



Measured memory_bytes: 14176
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>
#include <cctype>
#include <ctype.h>

#define INF 100000000

using namespace std;

int main()
{
    vector<int> a;
    int n;
    cin >> n;
    int tmp;
    for (int i = 0; i < n; i++)
    {
        cin >> tmp;
        a.push_back(tmp - 1);
    }
    int cnt = 0;
    tmp = 0;
    for (int i = 0; i < n; i++)
    {
        tmp = a[tmp];
        cnt++;
        if (tmp == 1)
        {
            cout << cnt << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n; cin >> n;
  int t, a; cin >> t >> a;
  vector<int> h(n);
  t *= 1000; a *= 1000;
  int ans = 0, min_d = 1000006;
  rep(i,n) {
    cin >> h[i];
    h[i] *= 6;
    int d = abs(a - (t - h[i]));
    if (d < min_d) {
      min_d = d;
      ans = i+1;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>
#include <map>
using namespace std;

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

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


constexpr lint MOD = 1000000007;
vector<lint> fac, facInv, inv;
void facInit(int nmax)
{
    fac = facInv = inv = vector<lint>(nmax + 1, 1);
    for (int i = 2; i <= nmax; i++)
    {
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        facInv[i] = facInv[i-1] * inv[i] % MOD;
    }
}
lint nCr(int n, int r)
{
    if (n < 0 or n<r or r<0) return 0;
    if (n >= (int)fac.size()) facInit(n);
    return (fac[n] * facInv[r] % MOD) * facInv[n-r] % MOD;
}

int main() {

    lint N,K;
    cin >> N >> K;

    for(lint i=1;i<K+1;++i){
    	cout << nCr(N-K+1,i)*nCr(K-1,i-1)% MOD << endl;
    }


}



Measured memory_bytes: 256
N,M = map(int,input().split())
judge = 0 #0:不可,1:可

if(M >= 2):
 #リスト 島1~a間に定期便あり:1,なし:0
 island1 = [0]*N
 #リスト 島b~N間に定期便あり:1,なし:0
 islandN = [0]*N

 for i in range(M):
  a,b = map(int,input().split())
  a,b = a-1,b-1
  if(a == 0): island1[b] = 1
  if(b == 0): island1[a] = 1 
  if(a == N-1): islandN[b] = 1
  if(b == N-1): islandN[a] = 1
    
 for i in range(len(island1)):
  if((island1[i] == 1)and(islandN[i] == 1)):
    judge = 1
    break
    
if(judge == 0):
  print('IMPOSSIBLE')
else:
  print('POSSIBLE')

Measured memory_bytes: 6132
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	long long int l;
	scanf("%d %lld", &n, &l);
	vector<string> s;
	for(int i=0; i<n; i++){
		string s1;
		cin >> s1;
		s.push_back(s1);
	}
	sort(s.begin(), s.end());
	vector<long long int> v;
	for(int k=0; k<=n; k++){
		if(k==0){
			for(long long int i=0; i<(long long int)s[0].length(); i++){
				if(s[0][i]=='1') v.push_back(l-i);
			}
		}else if(k==n){
			for(long long int i=0; i<(long long int)s[n-1].length(); i++){
				if(s[n-1][i]=='0') v.push_back(l-i);
			}
		}else{
			long long int i0;
			for(long long int i=0; i<(long long int)s[k].length(); i++){
				if(s[k][i]!=s[k-1][i]){
					i0=i;
					break;
				}
			}
			for(long long int i=i0+1; i<(long long int)s[k].length(); i++){
				if(s[k][i]=='1') v.push_back(l-i);
			}
			for(long long int i=i0+1; i<(long long int)s[k-1].length(); i++){
				if(s[k-1][i]=='0') v.push_back(l-i);
			}
		}
	}
	if(v.empty()){
		printf("%s\n", "Bob");
		return 0;
	}
	long long int ans=0;
	for(int i=0; i<v.size(); i++){
		long long int a=1;
		while(v[i]%2==0){
          v[i]/=2;
          a*=2;
        }
		ans^=a;
	}
	if(ans==0){
		printf("%s\n", "Bob");
	}else{
		printf("%s\n", "Alice");
	}
	return 0;
}

Measured memory_bytes: 1528
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))
#define LLONG_MAX numeric_limits<long long>::max()
#define INT_MAX numeric_limits<int>::max()

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<vb>		vvb;
typedef vector<vs>		vvs;
typedef vector<vc>		vvc;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
class mat2D {
private:
	vector<vector<T>> data;
public:
	mat2D(int rows, int cols) : data(vector<vector<T>>(rows, vector<T>(cols))) {}
	T operator () (int row, int col) { return data[row][col]; }

	friend istream& operator >> (istream& is, mat2D<T>& m) { return is >> m.data; }
	friend ostream& operator << (ostream& os, const mat2D<T>& m) {
		for (const vector<T>& row : m.data) os << row << endl;
		return os;
	}
};

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " " << p.second << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


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

	int ans = 0;
	for (auto s : S) {
		ans += int(s == '1');
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <chrono>
#include <stack>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

llong pow(int x, int n) {
    llong ans = x;
    if (n == 0) return 1;

    for(int i = 0; i < n - 1; i++) {
        ans *= x;
    }

    return ans;
}

void swap(int *X, int *Y){
    int t = *X; *X = *Y; *Y = t;
}

const static int N = 100;

int pow(int x) {
    return x * x;
}

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

    int n, a[N];
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    int sum = 0;
    vector<int > Sum;
    for (int x = -100; x <= 100; ++x) {
        for (int i = 0; i < n; ++i) {
            sum += pow(abs(a[i] - x));
        }
        Sum.push_back(sum);
        sum = 0;
    }

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

    cout << Sum[0] << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")
import numpy as np


def solve(N: int, K: int, A: "List[int]", F: "List[int]"):
    A.sort()
    F.sort(reverse=True)
    A = np.asarray(A, dtype=np.int)
    F = np.asarray(F, dtype=np.int)

    Asum = A.sum()

    def isOK(y):
        return Asum-np.minimum(A, y//F).sum() <= K

    def binary_search(x):
        ng = -1
        ok = len(x)
        while abs(ok - ng) > 1:
            mid = (ok + ng)//2
            # print("mid: {}, in ({}, {})".format(mid, ng, ok))
            if isOK(mid):
                ok = mid
            else:
                ng = mid
        return ng, ok

    ng, ok = binary_search(range(A.max()*F.max()))
    print(ok)

    # while k > 0:
    #     p1, a1, f1 = heapq.heappop(h)
    #     p2, a2, f2 = heapq.heappop(h)
    #     p1, p2 = -p1, -p2
    #     sub = min(a1 - math.ceil((p2/f1)-1), k)
    #     a1 -= sub
    #     k -= sub
    #     heapq.heappush(h, (-a1*f1, a1, f1))
    #     heapq.heappush(h, (-a2*f2, a2, f2))
    # # print(h)
    # p, a, f = heapq.heappop(h)
    # print(-p)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    F = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A, F)


if __name__ == '__main__':
    main()


Measured memory_bytes: 49884
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  int n,m;
  cin >> n >> m;
  vector<int> a(n);
  queue<int> b;
  for(int&x: a) scanf("%d",&x);
  sort(a.begin(),a.end());
  while(m--) {
    if(!a.empty() &&
       (b.empty() || a.back() > b.front())) {
      b.push(a.back()/2);
      a.pop_back();
    } else {
      b.push(b.front()/2);
      b.pop();
    }
  }
  LL answer = 0ll;
  for(int x:a) answer += x;
  while(!b.empty()) {
    answer += b.front();
    b.pop();
  }
  printf("%lld\n",answer);
  return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
long long int gcd(long long int a,long long int b){
	if(a<b){
		long long int c=a;
		a=b;
		b=c;
	}
	if(a%b==0)return b;
	else return gcd(b,a%b);
}

int main(){
	long long int p=998244353;
	long long int n;
	long long int ans=0;
	scanf("%lld",&n);
	long long int a,b;
	scanf("%lld%lld",&a,&b);
	long long int k;
	scanf("%lld",&k);
	if(k%gcd(a,b)!=0){
		ans=-1;
	}else{
		long long int t=gcd(a,b);
		a=a/t;
		b=b/t;
		k=k/t;
	}
	if(k==0)ans=-2;
	if(ans==0){ 
	long long int x[n+1]={};//nCi
	x[0]=1;
	x[1]=n;
	x[n]=1;
	long long int inv[n+1]={};
	inv[1]=1;
	for(int i=2;i<=n;i++){
		inv[i]=p - (p/i) * inv[p%i] % p;
	}
	
	for(long long int i=2;i<n;i++){
		x[i]=(x[i-1]*(n+1-i))%p;
		x[i]=x[i]*inv[i]%p;
	}
	
	long long int q=n+1;
	long long int r=-1;
	for(int i=0;i<=n;i++){
		if((k-a*i)%b==0){
			q=i;
			r=(k-a*i)/b;
			if(r>n);
			else break;
		}
	}
	for(long long int i=0;true;i++){
		if(q<=n&&r>=0){
			ans=ans+(x[q]*x[r])%p;
			ans=ans%p;
			q+=b;
			r-=a;
		}else{
			break;
		}
	}
	}
	if(ans==-1)ans=0;
	if(ans==-2)ans=1;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4864
# include<iostream>
using namespace std;
int A,B,C,D;
int NUM;
void divid(){
	D = NUM%10;
	NUM/=10;
	C = NUM%10;
	NUM/=10;
	B = NUM%10;
	NUM/=10;
	A = NUM%10;
	NUM/=10;
}

int main(){
	cin >>NUM;
	divid();
	if(A+B+C+D==7){
		cout<<A<<"+"<<B<<"+"<<C<<"+"<<D<<"=7"<<endl;
		return 0;
	}
	if(A+B+C-D==7){
		cout<<A<<"+"<<B<<"+"<<C<<"-"<<D<<"=7"<<endl;
		return 0;
	}
	if(A+B-C+D==7){
		cout<<A<<"+"<<B<<"-"<<C<<"+"<<D<<"=7"<<endl;
		return 0;
	}
	if(A+B-C-D==7){
		cout<<A<<"+"<<B<<"-"<<C<<"-"<<D<<"=7"<<endl;
		return 0;
	}
	if(A-B+C+D==7){
		cout<<A<<"-"<<B<<"+"<<C<<"+"<<D<<"=7"<<endl;
		return 0;
	}
	if(A-B+C-D==7){
		cout<<A<<"-"<<B<<"+"<<C<<"-"<<D<<"=7"<<endl;
		return 0;
	}
	if(A-B-C+D==7){
		cout<<A<<"-"<<B<<"-"<<C<<"+"<<D<<"=7"<<endl;
		return 0;
	}
	if(A-B-C-D==7){
		cout<<A<<"-"<<B<<"-"<<C<<"-"<<D<<"=7"<<endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("out.o", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string n;
	cin >> n;
	int k = n.size();
	int s = 0;
	for (int i = 0; i < k; i++) {
		s += (n[i] - '0');
	}
	if (s % 9 == 0) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}

Measured memory_bytes: 3792
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

const LL MOD = 1000000007;

int main(void)
{
	vector<LL>fact;
	fact.push_back(1);
	for (LL i = 1; i < 1e6; ++i)fact.push_back((fact.back() * i) % MOD);
	LL n, m;
	cin >> n >> m;
	LL a = max(n, m);
	LL b = min(n, m);
	if (a - b > 1)
	{
		cout << "0\n";
		return 0;
	}
	if (a - b == 1)
	{
		cout << fact[a] * fact[b] % MOD << endl;
	}
	else
	{
		cout << (2ll * fact[a] * fact[b]) % MOD << endl;
	}
	return 0;
}


Measured memory_bytes: 10604
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int n;
	char a[1000+10],b[1000+10];
	
	cin >> a;
	n = strlen(a);
	for(int i = 0;i < n;i++){
		if(a[i] == 'A'){
			b[i] = 'X';
		}
		else if(a[i] == 'B'){
			b[i] = 'Y';
		}
		else if(a[i] == 'C'){
			b[i] = 'Z';
		}
		else{
			b[i] = a[i] - 3;
		}
	}
	
	b[ n ] = '\0' ;
	
	cout << b << endl;
	return 0;
}

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

int main(void)
{
    char a,b;
    string s;
    char C[5];

    cin >> a >> b;

    if(a>b) cout << ">";
    if(a==b) cout << "=";
    if(a<b) cout << "<";

    return 0;
}

Measured memory_bytes: 256
def main():
	a,b = map(int,input().split())
	l = list(map(int,input().split()))
	
	l.sort()

	for i in range(b):
		if len(l) > 0:
			l.pop(-1)
	print(sum(l))



	

if __name__ == '__main__':
	main()

Measured memory_bytes: 87636
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ll long long
#define pb push_back
#define MEM(i,j) memset(i,j,sizeof i)
#define F first
#define S second
#define MP make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ET cout << "\n"
#define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;}
using namespace std;

int main()
{jizz
	ll n,k,ans=0,i=0;
	cin >> n >> k;
	ans+=(n/k)*(n/k)*(n/k);
	if(k%2==0)
	{
		for(ll x=k/2;x<=n;x+=k) ++i;
		ans+=i*i*i;
	}
	cout << ans << "\n";
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,end) for(ll i = 0; i < end ; i++ )
#define print(ans) cout << fixed << setprecision(15) << ans << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
typedef long long ll;
typedef vector<ll> vi;

double degree(double rad){
  double pi = 3.1415926535897932384626;
  return rad*360.0/2.0/pi;
}



int main() {
  double a,b,x;
  cin >> a >> b >> x;
  if (a*a*b < 2.0*x){
    print(degree(atan( -2.0*x/a/a/a + 2.0*b/a)));
  }
  else{
    print(degree(atan(a*b*b/2.0/x)));
  }
}


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

using namespace std;
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

//int dp[305][300];
VI ps(305*300);
int h,w, d, q;


int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	cin >>h >>w >>d;
	vector<VI> a(h,VI(w));
	rep(i,h) rep(j,w){
		cin >> a[i][j];
		ps[a[i][j]] = i*w + j;
	}
	//memset(dp, -1, sizeof dp);
	cin >>q;
	VI vl(q), vr(q);
	rep(i,q) cin >> vl[i] >>vr[i];

	
	vector<vector<ll>> cst(d); 
	rep(i,d) cst[i].push_back(0);
	rep(i, d){
		int st = i ;//i? i: d;
		for( ;st +d <= h*w; st+=d){
			int cy= ps[st]/w, cx=ps[st]%w;
			int ny= ps[st+d]/w, nx=ps[st+d]%w;
			cst[i].push_back(cst[i].back() +abs(cy-ny)+abs(cx-nx));
		}
	}
	//rep(i,d){ for(auto x: cst[i] ) cout << x <<" "; puts("");}
	
	rep(g, q){
		int md = vl[g] % d;
		cout << cst[md][vr[g]/d] - cst[md][vl[g]/d] <<"\n";
	}
	/*
	rep(gg,q){
		int l =vl[gg],r=vr[gg];
		ll ans =0;
		
		while(l !=r ){
			int cy= ps[l]/w, cx=ps[l]%w;
			int ny= ps[l+d]/w, nx=ps[l+d]%w;
			ans += abs(cy-ny)+abs(cx-nx);
			//printf("%d:%d, ",l,l+d);
			l = l+d;
		}
		cout << ans <<"\n";
	}
	*/
	return 0;
	
}


Measured memory_bytes: 6912
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;

    cout << n * n * n << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        if (a * b % 2 == 0) {
            System.out.println("Even");
        }
        else {
            System.out.println("Odd");
        }
    }
}



Measured memory_bytes: 23892
n=int(input())
a=list(map(int,input().split()))
count=0
flag=1
num=10*9+1
for i in range(n):
  if a[i]<0:
    count+=1
    a[i]*=-1
  elif a[i]==0:
    flag=0
if count%2==0 or flag==0:
  print(sum(a))
else:
  print(sum(a)-2*min(a))

Measured memory_bytes: 14412
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#include<queue>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int a, b;
	cin>>a>>b;
	rep(i, max(a, b)){
		cout<<min(a, b);
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int n=0,x=0,i=0,min=1001,d=0;
  int m[200];
  
  scanf("%d %d",&n,&x);
  for(i=0;i<n;i++){
  	scanf("%d",&m[i]);
    d++;
    x=x-m[i];
    if(m[i]<min){
      min=m[i];
    }
  }
  while(min<=x){
    x=x-min;
    d++;
  }
  printf("%d",d);
  
  return 0;
}

Measured memory_bytes: 128